Debian Codegraph @

gstreamer/gstreamermm/caps.cc

raw symbols SCIP
1 // Generated by gmmproc 2.50.1 -- DO NOT MODIFY!
2
3
4 #include <glibmm.h>
5
6 #include <gstreamermm/caps.h>
7 #include <gstreamermm/private/caps_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 #include <gstreamermm/capsfeatures.h>
30
31 namespace Gst
32 {
33
34 GType Caps::get_type()
35 {
36 return gst_caps_get_type();
37 }
38
39 Glib::RefPtr<Caps> Caps::create_writable()
40 {
41 return Glib::RefPtr<Caps>::cast_static(MiniObject::create_writable());
42 }
43
44 Glib::RefPtr<Gst::Caps> Caps::create(const Structure& structure)
45 {
46 //We take a copy because gst_caps_append_structure() wants to take ownership:
47 GstStructure* copy = gst_structure_copy(structure.gobj());
48 return Glib::wrap(gst_caps_new_full(copy, nullptr));
49 }
50
51 void Caps::append_structure(const Structure& structure)
52 {
53 //We take a copy because gst_caps_append_structure() wants to take ownership:
54 GstStructure* copy = gst_structure_copy(structure.gobj());
55 gst_caps_append_structure(gobj(), copy);
56 }
57
58 void Caps::append_structure(const Structure& structure, const CapsFeatures& features)
59 {
60 //We take a copy because gst_caps_append_structure_full() wants to take ownership:
61 GstStructure* copy_structure = gst_structure_copy(structure.gobj());
62 GstCapsFeatures* copy_features = gst_caps_features_copy(features.gobj());
63 gst_caps_append_structure_full(gobj(), copy_structure, copy_features);
64 }
65
66
67 Glib::RefPtr<Caps> Caps::merge_structure(const Structure& structure)
68 {
69 //We take a copy because gst_caps_merge_structure() wants to take ownership:
70 GstStructure* copy = gst_structure_copy(structure.gobj());
71 return Glib::wrap(gst_caps_merge_structure(gobj(), copy), true);
72 }
73
74 Glib::RefPtr<Caps> Caps::merge_structure(const Structure& structure, const CapsFeatures& features)
75 {
76 //We take a copy because gst_caps_merge_structure_full() wants to take ownership:
77 GstStructure* copy_structure = gst_structure_copy(structure.gobj());
78 GstCapsFeatures* copy_features = gst_caps_features_copy(features.gobj());
79 return Glib::wrap(gst_caps_merge_structure_full(gobj(), copy_structure, copy_features), true);
80 }
81
82 //TODO: Want to return RefPtr to Caps but using RefPtr in expressions such
83 // as 'caps->set_simple(name1, value1)->set_simple(name2, value2)' a
84 // causes gstreamer Structure immutability warnings because the Caps is
85 // referenced more than once in the expression (see bug #510301).
86 /*
87 This method is implemented in place of gst_caps_set_simple which is a
88 variable argument function and cannot be wrapped. We don't call
89 gst_caps_set_simple() directly because we are using a Glib::ValueBase as the
90 value to be set instead of listing out each field in the value as would be
91 done with gst_caps_set_simple()
92 */
93 //Glib::RefPtr<Gst::Caps>
94 void
95 Caps::set_simple(const Glib::ustring& name, const Glib::ValueBase& value)
96 {
97 g_return_if_fail (g_atomic_int_get(&(this->gobj())->mini_object.refcount) == 1); // IS_WRITABLE(caps) fails
98
99 //The result of gst_caps_get_structure() should not be modified, according to
100 //its documentation, but we are reimplementing gst_caps_set_simple() which
101 //does that:
102 GstStructure* structure = gst_caps_get_structure(gobj(), 0);
103 if(structure)
104 gst_structure_set_value(structure, name.c_str(), value.gobj());
105
106 //return Glib::wrap(gobj(), true);
107 }
108
109 void
110 Caps::set_simple(const Glib::ustring& name, const char* data)
111 {
112 set_simple(name, std::string(data));
113 }
114
115 CapsFeatures Caps::get_features(guint index) const
116 {
117 GstCapsFeatures* features = gst_caps_get_features(gobj(), index);
118 return CapsFeatures(features, true);
119 }
120
121 void Caps::set_features(guint index, const CapsFeatures& features)
122 {
123 GstCapsFeatures* copy = gst_caps_features_copy(features.gobj());
124 gst_caps_set_features(gobj(), index, copy);
125 }
126
127 Glib::RefPtr<Gst::Caps> Caps::truncate()
128 {
129 reference();
130 return Glib::wrap(gst_caps_truncate(gobj()));
131 }
132
133 Glib::RefPtr<Gst::Caps> Caps::merge(Glib::RefPtr<Gst::Caps>&& caps)
134 {
135 if (is_writable())
136 {
137 return Glib::wrap(gst_caps_merge(gobj(), caps.release()->gobj()), true);
138 }
139 else
140 {
141 reference();
142 return Glib::wrap(gst_caps_merge(gobj(), caps.release()->gobj()), false);
143 }
144 }
145
146 } //namespace Gst
147
148 namespace Glib
149 {
150 Glib::RefPtr<Gst::Caps> Value< Glib::RefPtr<Gst::Caps> >::get()
151 {
152 return Glib::wrap(reinterpret_cast<GstCaps*>(get_boxed()), true);
153 }
154 }
155
156 namespace
157 {
158 } // anonymous namespace
159
160 // static
161 GType Glib::Value<Gst::CapsFlags>::value_type()
162 {
163 return gst_caps_flags_get_type();
164 }
165
166
167 /* Why reinterpret_cast<Caps*>(gobject) is needed:
168 *
169 * A Caps instance is in fact always a GstCaps instance.
170 * Unfortunately, GstCaps cannot be a member of Caps,
171 * because it is an opaque struct. Also, the C interface does not provide
172 * any hooks to install a destroy notification handler, thus we cannot
173 * wrap it dynamically either.
174 *
175 * The cast works because Caps does not have any member data, and
176 * it is impossible to derive from it. This is ensured by using final on the
177 * class and by using = delete on the default constructor.
178 */
179
180 namespace Glib
181 {
182
183 Glib::RefPtr<Gst::Caps> wrap(GstCaps* object, bool take_copy)
184 {
185 if(take_copy && object)
186 gst_caps_ref(object);
187
188 // See the comment at the top of this file, if you want to know why the cast works.
189 return Glib::RefPtr<Gst::Caps>(reinterpret_cast<Gst::Caps*>(object));
190 }
191
192 } // namespace Glib
193
194
195 namespace Gst
196 {
197
198
199 // static
200 Glib::RefPtr<Caps> Caps::create()
201 {
202 // See the comment at the top of this file, if you want to know why the cast works.
203 return Glib::RefPtr<Caps>(reinterpret_cast<Caps*>(gst_caps_new_empty()));
204 }
205
206 void Caps::reference() const
207 {
208 // See the comment at the top of this file, if you want to know why the cast works.
209 gst_caps_ref(reinterpret_cast<GstCaps*>(const_cast<Caps*>(this)));
210 }
211
212 void Caps::unreference() const
213 {
214 // See the comment at the top of this file, if you want to know why the cast works.
215 gst_caps_unref(reinterpret_cast<GstCaps*>(const_cast<Caps*>(this)));
216 }
217
218 GstCaps* Caps::gobj()
219 {
220 // See the comment at the top of this file, if you want to know why the cast works.
221 return reinterpret_cast<GstCaps*>(this);
222 }
223
224 const GstCaps* Caps::gobj() const
225 {
226 // See the comment at the top of this file, if you want to know why the cast works.
227 return reinterpret_cast<const GstCaps*>(this);
228 }
229
230 GstCaps* Caps::gobj_copy() const
231 {
232 // See the comment at the top of this file, if you want to know why the cast works.
233 const auto gobject = reinterpret_cast<GstCaps*>(const_cast<Caps*>(this));
234 gst_caps_ref(gobject);
235 return gobject;
236 }
237
238
239 Glib::RefPtr<Gst::Caps> Caps::create_from_string(const Glib::ustring& string)
240 {
241 return Glib::wrap(gst_caps_from_string(string.c_str()));
242 }
243
244 Glib::RefPtr<Gst::Caps> Caps::copy_nth(guint nth) const
245 {
246 return Glib::wrap(gst_caps_copy_nth(const_cast<GstCaps*>(gobj()), nth));
247 }
248
249 void Caps::append(Glib::RefPtr<Gst::Caps>&& caps)
250 {
251 gst_caps_append(gobj(), (caps) ? caps.release()->gobj() : nullptr);
252 }
253
254 void Caps::append_structure(Gst::Structure&& structure)
255 {
256 gst_caps_append_structure(gobj(), (structure) ? structure.release() : nullptr);
257 }
258
259 const Structure Caps::get_structure(guint idx) const
260 {
261 return Glib::wrap(gst_caps_get_structure(const_cast<GstCaps*>(gobj()), idx), true);
262 }
263
264 void Caps::remove_structure(guint idx)
265 {
266 gst_caps_remove_structure(gobj(), idx);
267 }
268
269 guint Caps::size() const
270 {
271 return gst_caps_get_size(const_cast<GstCaps*>(gobj()));
272 }
273
274 Structure Caps::steal_structure(guint index)
275 {
276 return Glib::wrap(gst_caps_steal_structure(gobj(), index));
277 }
278
279 void Caps::set_value(const Glib::ustring& field, const Glib::ValueBase& value)
280 {
281 gst_caps_set_value(gobj(), field.c_str(), (value).gobj());
282 }
283
284 bool Caps::is_any() const
285 {
286 return gst_caps_is_any(const_cast<GstCaps*>(gobj()));
287 }
288
289 bool Caps::empty() const
290 {
291 return gst_caps_is_empty(const_cast<GstCaps*>(gobj()));
292 }
293
294 bool Caps::is_fixed() const
295 {
296 return gst_caps_is_fixed(const_cast<GstCaps*>(gobj()));
297 }
298
299 bool Caps::equals(const Glib::RefPtr<const Gst::Caps>& other_caps) const
300 {
301 return gst_caps_is_equal(const_cast<GstCaps*>(gobj()), Glib::unwrap(other_caps));
302 }
303
304 bool Caps::equals_fixed(const Glib::RefPtr<const Gst::Caps>& other_caps) const
305 {
306 return gst_caps_is_equal_fixed(const_cast<GstCaps*>(gobj()), Glib::unwrap(other_caps));
307 }
308
309 bool Caps::is_always_compatible(const Glib::RefPtr<const Gst::Caps>& other_caps) const
310 {
311 return gst_caps_is_always_compatible(const_cast<GstCaps*>(gobj()), Glib::unwrap(other_caps));
312 }
313
314 bool Caps::is_subset(const Glib::RefPtr<const Gst::Caps>& superset_caps) const
315 {
316 return gst_caps_is_subset(const_cast<GstCaps*>(gobj()), Glib::unwrap(superset_caps));
317 }
318
319 bool Caps::can_intersect(const Glib::RefPtr<const Gst::Caps>& caps2) const
320 {
321 return gst_caps_can_intersect(const_cast<GstCaps*>(gobj()), Glib::unwrap(caps2));
322 }
323
324 Glib::RefPtr<Gst::Caps> Caps::fixate() const
325 {
326 return Glib::wrap(gst_caps_fixate(const_cast<GstCaps*>(gobj())));
327 }
328
329 bool Caps::is_strictly_equal(const Glib::RefPtr<const Gst::Caps>& caps2) const
330 {
331 return gst_caps_is_strictly_equal(const_cast<GstCaps*>(gobj()), Glib::unwrap(caps2));
332 }
333
334 Glib::RefPtr<Gst::Caps> Caps::copy() const
335 {
336 return Glib::wrap(gst_caps_copy(const_cast<GstCaps*>(gobj())));
337 }
338
339 bool Caps::is_subset_structure(const Gst::Structure& structure) const
340 {
341 return gst_caps_is_subset_structure(const_cast<GstCaps*>(gobj()), structure.gobj());
342 }
343
344 bool Caps::is_subset_structure(const Gst::Structure& structure, const Gst::CapsFeatures& features) const
345 {
346 return gst_caps_is_subset_structure_full(const_cast<GstCaps*>(gobj()), structure.gobj(), features.gobj());
347 }
348
349 Glib::RefPtr<Gst::Caps> Caps::create_any()
350 {
351 return Glib::wrap(gst_caps_new_any());
352 }
353
354 Glib::RefPtr<Gst::Caps> Caps::get_intersect(const Glib::RefPtr<const Gst::Caps>& other_caps) const
355 {
356 return Glib::wrap(gst_caps_intersect(const_cast<GstCaps*>(gobj()), const_cast<GstCaps*>(Glib::unwrap(other_caps))));
357 }
358
359 Glib::RefPtr<Gst::Caps> Caps::get_intersect(const Glib::RefPtr<const Gst::Caps>& other_caps, CapsIntersectMode p2) const
360 {
361 return Glib::wrap(gst_caps_intersect_full(const_cast<GstCaps*>(gobj()), const_cast<GstCaps*>(Glib::unwrap(other_caps)), ((GstCapsIntersectMode)(p2))));
362 }
363
364 Glib::RefPtr<Gst::Caps> Caps::get_normal() const
365 {
366 return Glib::wrap(gst_caps_normalize(const_cast<GstCaps*>(gobj())));
367 }
368
369 Glib::RefPtr<Gst::Caps> Caps::simplify()
370 {
371 return Glib::wrap(gst_caps_simplify(gobj()));
372 }
373
374 Glib::ustring Caps::to_string() const
375 {
376 return Glib::convert_return_gchar_ptr_to_ustring(gst_caps_to_string(const_cast<GstCaps*>(gobj())));
377 }
378
379 Glib::RefPtr<Gst::Caps> Caps::get_difference(const Glib::RefPtr<const Gst::Caps>& subtrahend_caps) const
380 {
381 return Glib::wrap(gst_caps_subtract(const_cast<GstCaps*>(gobj()), const_cast<GstCaps*>(Glib::unwrap(subtrahend_caps))));
382 }
383
384
385 } // namespace Gst
386
387