// Generated by gtkmmproc -- DO NOT MODIFY!


#include <glibmm.h>

#include <gstreamermm/buffer.h>
#include <gstreamermm/private/buffer_p.h>


/* gstreamermm - a C++ wrapper for gstreamer
 *
 * Copyright 2008 The gstreamermm Development Team
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free
 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include <stdexcept>
#include <gst/gstutils.h>
#include <gst/gstenumtypes.h>


namespace
{

extern "C"
{

static void Buffer_gstreamermm_callback_destroy(void* data,
  GstMiniObject* /* where_the_object_was */)
{
  delete static_cast<Gst::Buffer*>(data);
}

}

}

namespace Gst
{

Glib::RefPtr<Gst::Buffer> Buffer::copy() const
{
  return Gst::wrap(gst_buffer_copy(gobj()));
}

Glib::RefPtr<Gst::Buffer> Buffer::create_writable()
{
  return Gst::wrap(gst_buffer_make_writable(gobj()));
}

Gst::MiniObject* Buffer_Class::wrap_new(GstMiniObject* object)
{
  // Use this wrap_new() method to ensure that the wrapper is destroyed
  // when the miniobject loses its last reference.

  Gst::Buffer* wrapper = new Gst::Buffer((GstBuffer*)(object));
  gst_mini_object_weak_ref(object, &Buffer_gstreamermm_callback_destroy, wrapper);
  return wrapper;
}

} // namespace Gst

namespace
{
} // anonymous namespace

// static
GType Glib::Value<Gst::BufferFlag>::value_type()
{
  return gst_buffer_flag_get_type();
}

// static
GType Glib::Value<Gst::BufferCopyFlags>::value_type()
{
  return gst_buffer_copy_flags_get_type();
}


namespace Gst
{

Glib::RefPtr<Gst::Buffer> wrap(GstBuffer* object, bool take_copy)
{
  //Note that we use Gst::wrap() instead of Glib::wrap() 
  //because we are dealing with a GstMiniObject, not a GObject:
  return Glib::RefPtr<Gst::Buffer>( dynamic_cast<Gst::Buffer*> (Gst::wrap_auto ((GstMiniObject*)(object), take_copy)) );
  //We use dynamic_cast<> in case of multiple inheritance.
}

} /* namespace Gst */


namespace Gst
{


/* The *_Class implementation: */

const Glib::Class& Buffer_Class::init()
{
  if(!gtype_) // create the GType if necessary
  {
    // Glib::Class has to know the class init function to clone custom types.
    class_init_func_ = &Buffer_Class::class_init_function;

    // This is actually just optimized away, apparently with no harm.
    // Make sure that the parent type has been created.
    //CppClassParent::CppObjectType::get_type();

    // Create the wrapper type, with the same class/instance size as the base type.
    register_derived_type(gst_buffer_get_type());

    // Add derived versions of interfaces, if the C type implements any interfaces:

  }

  return *this;
}


void Buffer_Class::class_init_function(void* g_class, void* class_data)
{
  BaseClassType *const klass = static_cast<BaseClassType*>(g_class);
  CppClassParent::class_init_function(klass, class_data);


}


/* The implementation: */

GstBuffer* Buffer::gobj_copy()
{
  // Use the mini object copying function to get a copy of the underlying
  // gobject instead of referencing and returning the underlying gobject as
  // would be done normally:
  return reinterpret_cast<GstBuffer*>(gst_mini_object_copy(reinterpret_cast<GstMiniObject*>(gobj())));
}


Buffer::Buffer(GstBuffer* castitem)
:
  Gst::MiniObject((GstMiniObject*)(castitem))
{}

Buffer::~Buffer()
{}


Buffer::CppClassType Buffer::buffer_class_; // initialize static member

GType Buffer::get_type()
{
  return buffer_class_.init().get_type();
}


GType Buffer::get_base_type()
{
  return gst_buffer_get_type();
}


Glib::RefPtr<Gst::Buffer> Buffer::create()
{
  return Gst::wrap(gst_buffer_new());
}


Glib::RefPtr<Gst::Buffer> Buffer::create(guint size)
{
  return Gst::wrap(gst_buffer_try_new_and_alloc(size));
}


void Buffer::copy_metadata(const Glib::RefPtr<Gst::Buffer>& source_buffer, BufferCopyFlags flags)
{
  gst_buffer_copy_metadata(gobj(), Gst::unwrap(source_buffer), ((GstBufferCopyFlags)(flags)));
}

bool Buffer::is_metadata_writable() const
{
  return gst_buffer_is_metadata_writable(const_cast<GstBuffer*>(gobj()));
}

Glib::RefPtr<Gst::Buffer> Buffer::make_metadata_writable() const
{
  return Gst::wrap(gst_buffer_make_metadata_writable(const_cast<GstBuffer*>(gobj())));
}

Glib::RefPtr<Gst::Caps> Buffer::get_caps()
{
  return Glib::wrap(gst_buffer_get_caps(gobj()));
}

Glib::RefPtr<const Gst::Caps> Buffer::get_caps() const
{
  return const_cast<Buffer*>(this)->get_caps();
}

void Buffer::set_caps(const Glib::RefPtr<Gst::Caps>& caps)
{
  gst_buffer_set_caps(gobj(), Glib::unwrap(caps));
}

Glib::RefPtr<Gst::Buffer> Buffer::create_sub(const guint& offset, const guint& size)
{
  return Gst::wrap(gst_buffer_create_sub(gobj(), offset, size));
}

Glib::RefPtr<const Gst::Buffer> Buffer::create_sub(const guint& offset, const guint& size) const
{
  return const_cast<Buffer*>(this)->create_sub(offset, size);
}

bool Buffer::is_span_fast(const Glib::RefPtr<const Gst::Buffer>& other_buffer) const
{
  return gst_buffer_is_span_fast(const_cast<GstBuffer*>(gobj()), const_cast<GstBuffer*>(Gst::unwrap(other_buffer)));
}

Glib::RefPtr<Gst::Buffer> Buffer::span(const guint32& offset, const Glib::RefPtr<Gst::Buffer>& other_buffer, const guint32& len) const
{
  return Gst::wrap(gst_buffer_span(const_cast<GstBuffer*>(gobj()), offset, Gst::unwrap(other_buffer), len));
}

Glib::RefPtr<Gst::Buffer> Buffer::merge(const Glib::RefPtr<const Gst::Buffer>& other_buffer) const
{
  return Gst::wrap(gst_buffer_merge(const_cast<GstBuffer*>(gobj()), const_cast<GstBuffer*>(Gst::unwrap(other_buffer))));
}

 guint8* Buffer::get_data() const
{
  return gobj()->data;
}
 
 guint Buffer::get_size() const
{
  return gobj()->size;
}
 
 ClockTime Buffer::get_timestamp() const
{
  return ((ClockTime)(gobj()->timestamp));
}
 
 ClockTime Buffer::get_duration() const
{
  return ((ClockTime)(gobj()->duration));
}
 
 guint64 Buffer::get_offset() const
{
  return gobj()->offset;
}
 
 guint64 Buffer::get_offset_end() const
{
  return gobj()->offset_end;
}
 
 guint8* Buffer::get_malloc_data() const
{
  return gobj()->malloc_data;
}
 

} // namespace Gst


