// Generated by gmmproc 2.50.0 -- DO NOT MODIFY!


#include <glibmm.h>

#include <gstreamermm/sample.h>
#include <gstreamermm/private/sample_p.h>


/* gstreamermm - a C++ wrapper for gstreamer
 *
 * Copyright 2008-2016 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.
 */

namespace Gst {

Glib::RefPtr<Gst::Sample> Sample::create(const Glib::RefPtr<Gst::Buffer>& buffer, const Glib::RefPtr<Gst::Caps>& caps, const Gst::Segment& segment, Gst::Structure&& info)
{
  GstSample *sample = gst_sample_new(buffer->gobj(), caps->gobj(), segment.gobj(), info.gobj());
  Gst::Structure empty_structure;
  info.swap(empty_structure);

  return Glib::wrap(sample, false);
}
}

namespace
{
} // anonymous namespace


/* Why reinterpret_cast<Sample*>(gobject) is needed:
 *
 * A Sample instance is in fact always a GstSample instance.
 * Unfortunately, GstSample cannot be a member of Sample,
 * because it is an opaque struct.  Also, the C interface does not provide
 * any hooks to install a destroy notification handler, thus we cannot
 * wrap it dynamically either.
 *
 * The cast works because Sample does not have any member data, and
 * it is impossible to derive from it.  This is ensured by using final on the
 * class and by using = delete on the default constructor.
 */

namespace Glib
{

Glib::RefPtr<Gst::Sample> wrap(GstSample* object, bool take_copy)
{
  if(take_copy && object)
    gst_sample_ref(object);

  // See the comment at the top of this file, if you want to know why the cast works.
  return Glib::RefPtr<Gst::Sample>(reinterpret_cast<Gst::Sample*>(object));
}

} // namespace Glib


namespace Gst
{


void Sample::reference() const
{
  // See the comment at the top of this file, if you want to know why the cast works.
  gst_sample_ref(reinterpret_cast<GstSample*>(const_cast<Sample*>(this)));
}

void Sample::unreference() const
{
  // See the comment at the top of this file, if you want to know why the cast works.
  gst_sample_unref(reinterpret_cast<GstSample*>(const_cast<Sample*>(this)));
}

GstSample* Sample::gobj()
{
  // See the comment at the top of this file, if you want to know why the cast works.
  return reinterpret_cast<GstSample*>(this);
}

const GstSample* Sample::gobj() const
{
  // See the comment at the top of this file, if you want to know why the cast works.
  return reinterpret_cast<const GstSample*>(this);
}

GstSample* Sample::gobj_copy() const
{
  // See the comment at the top of this file, if you want to know why the cast works.
  const auto gobject = reinterpret_cast<GstSample*>(const_cast<Sample*>(this));
  gst_sample_ref(gobject);
  return gobject;
}


Glib::RefPtr<Gst::Buffer> Sample::get_buffer()
{
  Glib::RefPtr<Gst::Buffer> retvalue = Glib::wrap(gst_sample_get_buffer(gobj()));
  if(retvalue)
    retvalue->reference(); //The function does not do a ref for us.
  return retvalue;
}

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

Glib::RefPtr<Gst::Caps> Sample::get_caps()
{
  Glib::RefPtr<Gst::Caps> retvalue = Glib::wrap(gst_sample_get_caps(gobj()));
  if(retvalue)
    retvalue->reference(); //The function does not do a ref for us.
  return retvalue;
}

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

Gst::Structure Sample::get_info() const
{
  return Glib::wrap(const_cast<GstStructure*>(gst_sample_get_info(const_cast<GstSample*>(gobj()))), false);
}

Glib::RefPtr<Gst::Sample> Sample::copy() const
{
  return Glib::wrap(gst_sample_copy(const_cast<GstSample*>(gobj())));
}

Gst::Segment Sample::get_segment() const
{
  return Glib::wrap(gst_sample_get_segment(const_cast<GstSample*>(gobj())), true);
}


} // namespace Gst


