| 1 | // Generated by gmmproc 2.50.1 -- DO NOT MODIFY! |
| 2 | |
| 3 | |
| 4 | #include <glibmm.h> |
| 5 | |
| 6 | #include <gstreamermm/sample.h> |
| 7 | #include <gstreamermm/private/sample_p.h> |
| 8 | |
| 9 | |
| 10 | /* gstreamermm - a C++ wrapper for gstreamer |
| 11 | * |
| 12 | * Copyright 2008-2016 The gstreamermm Development Team |
| 13 | * |
| 14 | * This library is free software; you can redistribute it and/or |
| 15 | * modify it under the terms of the GNU Lesser General Public |
| 16 | * License as published by the Free Software Foundation; either |
| 17 | * version 2.1 of the License, or (at your option) any later version. |
| 18 | * |
| 19 | * This library is distributed in the hope that it will be useful, |
| 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 22 | * Lesser General Public License for more details. |
| 23 | * |
| 24 | * You should have received a copy of the GNU Lesser General Public |
| 25 | * License along with this library; if not, write to the Free |
| 26 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 27 | */ |
| 28 | |
| 29 | namespace Gst { |
| 30 | |
| 31 | 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) |
| 32 | { |
| 33 | GstSample *sample = gst_sample_new(buffer->gobj(), caps->gobj(), segment.gobj(), info.gobj()); |
| 34 | Gst::Structure empty_structure; |
| 35 | info.swap(empty_structure); |
| 36 | |
| 37 | return Glib::wrap(sample, false); |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | namespace |
| 42 | { |
| 43 | } // anonymous namespace |
| 44 | |
| 45 | |
| 46 | /* Why reinterpret_cast<Sample*>(gobject) is needed: |
| 47 | * |
| 48 | * A Sample instance is in fact always a GstSample instance. |
| 49 | * Unfortunately, GstSample cannot be a member of Sample, |
| 50 | * because it is an opaque struct. Also, the C interface does not provide |
| 51 | * any hooks to install a destroy notification handler, thus we cannot |
| 52 | * wrap it dynamically either. |
| 53 | * |
| 54 | * The cast works because Sample does not have any member data, and |
| 55 | * it is impossible to derive from it. This is ensured by using final on the |
| 56 | * class and by using = delete on the default constructor. |
| 57 | */ |
| 58 | |
| 59 | namespace Glib |
| 60 | { |
| 61 | |
| 62 | Glib::RefPtr<Gst::Sample> wrap(GstSample* object, bool take_copy) |
| 63 | { |
| 64 | if(take_copy && object) |
| 65 | gst_sample_ref(object); |
| 66 | |
| 67 | // See the comment at the top of this file, if you want to know why the cast works. |
| 68 | return Glib::RefPtr<Gst::Sample>(reinterpret_cast<Gst::Sample*>(object)); |
| 69 | } |
| 70 | |
| 71 | } // namespace Glib |
| 72 | |
| 73 | |
| 74 | namespace Gst |
| 75 | { |
| 76 | |
| 77 | |
| 78 | void Sample::reference() const |
| 79 | { |
| 80 | // See the comment at the top of this file, if you want to know why the cast works. |
| 81 | gst_sample_ref(reinterpret_cast<GstSample*>(const_cast<Sample*>(this))); |
| 82 | } |
| 83 | |
| 84 | void Sample::unreference() const |
| 85 | { |
| 86 | // See the comment at the top of this file, if you want to know why the cast works. |
| 87 | gst_sample_unref(reinterpret_cast<GstSample*>(const_cast<Sample*>(this))); |
| 88 | } |
| 89 | |
| 90 | GstSample* Sample::gobj() |
| 91 | { |
| 92 | // See the comment at the top of this file, if you want to know why the cast works. |
| 93 | return reinterpret_cast<GstSample*>(this); |
| 94 | } |
| 95 | |
| 96 | const GstSample* Sample::gobj() const |
| 97 | { |
| 98 | // See the comment at the top of this file, if you want to know why the cast works. |
| 99 | return reinterpret_cast<const GstSample*>(this); |
| 100 | } |
| 101 | |
| 102 | GstSample* Sample::gobj_copy() const |
| 103 | { |
| 104 | // See the comment at the top of this file, if you want to know why the cast works. |
| 105 | const auto gobject = reinterpret_cast<GstSample*>(const_cast<Sample*>(this)); |
| 106 | gst_sample_ref(gobject); |
| 107 | return gobject; |
| 108 | } |
| 109 | |
| 110 | |
| 111 | Glib::RefPtr<Gst::Buffer> Sample::get_buffer() |
| 112 | { |
| 113 | Glib::RefPtr<Gst::Buffer> retvalue = Glib::wrap(gst_sample_get_buffer(gobj())); |
| 114 | if(retvalue) |
| 115 | retvalue->reference(); //The function does not do a ref for us. |
| 116 | return retvalue; |
| 117 | } |
| 118 | |
| 119 | Glib::RefPtr<const Gst::Buffer> Sample::get_buffer() const |
| 120 | { |
| 121 | return const_cast<Sample*>(this)->get_buffer(); |
| 122 | } |
| 123 | |
| 124 | Glib::RefPtr<Gst::Caps> Sample::get_caps() |
| 125 | { |
| 126 | Glib::RefPtr<Gst::Caps> retvalue = Glib::wrap(gst_sample_get_caps(gobj())); |
| 127 | if(retvalue) |
| 128 | retvalue->reference(); //The function does not do a ref for us. |
| 129 | return retvalue; |
| 130 | } |
| 131 | |
| 132 | Glib::RefPtr<const Gst::Caps> Sample::get_caps() const |
| 133 | { |
| 134 | return const_cast<Sample*>(this)->get_caps(); |
| 135 | } |
| 136 | |
| 137 | Gst::Structure Sample::get_info() const |
| 138 | { |
| 139 | return Glib::wrap(const_cast<GstStructure*>(gst_sample_get_info(const_cast<GstSample*>(gobj()))), false); |
| 140 | } |
| 141 | |
| 142 | Glib::RefPtr<Gst::Sample> Sample::copy() const |
| 143 | { |
| 144 | return Glib::wrap(gst_sample_copy(const_cast<GstSample*>(gobj()))); |
| 145 | } |
| 146 | |
| 147 | Gst::Segment Sample::get_segment() const |
| 148 | { |
| 149 | return Glib::wrap(gst_sample_get_segment(const_cast<GstSample*>(gobj())), true); |
| 150 | } |
| 151 | |
| 152 | |
| 153 | } // namespace Gst |
| 154 | |
| 155 |