1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module gstreamer.CapsFeatures;
26 
27 private import glib.ConstructionException;
28 private import glib.Str;
29 private import gobject.ObjectG;
30 private import gstreamer.c.functions;
31 public  import gstreamer.c.types;
32 public  import gstreamerc.gstreamertypes;
33 private import gtkd.Loader;
34 
35 
36 /**
37  * #GstCapsFeatures can optionally be set on a #GstCaps to add requirements
38  * for additional features for a specific #GstStructure. Caps structures with
39  * the same name but with a non-equal set of caps features are not compatible.
40  * If a pad supports multiple sets of features it has to add multiple equal
41  * structures with different feature sets to the caps.
42  * 
43  * Empty #GstCapsFeatures are equivalent with the #GstCapsFeatures that only
44  * contain #GST_CAPS_FEATURE_MEMORY_SYSTEM_MEMORY. ANY #GstCapsFeatures as
45  * created by gst_caps_features_new_any() are equal to any other #GstCapsFeatures
46  * and can be used to specify that any #GstCapsFeatures would be supported, e.g.
47  * for elements that don't touch buffer memory. #GstCaps with ANY #GstCapsFeatures
48  * are considered non-fixed and during negotiation some #GstCapsFeatures have
49  * to be selected.
50  * 
51  * Examples for caps features would be the requirement of a specific #GstMemory
52  * types or the requirement of having a specific #GstMeta on the buffer. Features
53  * are given as a string of the format "memory:GstMemoryTypeName" or
54  * "meta:GstMetaAPIName".
55  */
56 public class CapsFeatures
57 {
58 	/** the main Gtk struct */
59 	protected GstCapsFeatures* gstCapsFeatures;
60 	protected bool ownedRef;
61 
62 	/** Get the main Gtk struct */
63 	public GstCapsFeatures* getCapsFeaturesStruct(bool transferOwnership = false)
64 	{
65 		if (transferOwnership)
66 			ownedRef = false;
67 		return gstCapsFeatures;
68 	}
69 
70 	/** the main Gtk struct as a void* */
71 	protected void* getStruct()
72 	{
73 		return cast(void*)gstCapsFeatures;
74 	}
75 
76 	/**
77 	 * Sets our main struct and passes it to the parent class.
78 	 */
79 	public this (GstCapsFeatures* gstCapsFeatures, bool ownedRef = false)
80 	{
81 		this.gstCapsFeatures = gstCapsFeatures;
82 		this.ownedRef = ownedRef;
83 	}
84 
85 	~this ()
86 	{
87 		if ( Linker.isLoaded(LIBRARY_GSTREAMER) && ownedRef )
88 			gst_caps_features_free(gstCapsFeatures);
89 	}
90 
91 	/**
92 	 * Creates a new, ANY #GstCapsFeatures. This will be equal
93 	 * to any other #GstCapsFeatures but caps with these are
94 	 * unfixed.
95 	 *
96 	 * Free-function: gst_caps_features_free
97 	 *
98 	 * Return: a new, ANY #GstCapsFeatures
99 	 *
100 	 * Since: 1.2
101 	 *
102 	 * Throws: ConstructionException GTK+ fails to create the object.
103 	 */
104 	public static newAny()
105 	{
106 		auto p = gst_caps_features_new_any();
107 
108 		if(p is null)
109 		{
110 			throw new ConstructionException("null returned by new_any");
111 		}
112 
113 		return new CapsFeatures(cast(GstCapsFeatures*)p);
114 	}
115 
116 	/**
117 	 */
118 
119 	/** */
120 	public static GType getType()
121 	{
122 		return gst_caps_features_get_type();
123 	}
124 
125 	/**
126 	 * Creates a new, empty #GstCapsFeatures.
127 	 *
128 	 * Free-function: gst_caps_features_free
129 	 *
130 	 * Returns: a new, empty #GstCapsFeatures
131 	 *
132 	 * Since: 1.2
133 	 *
134 	 * Throws: ConstructionException GTK+ fails to create the object.
135 	 */
136 	public this()
137 	{
138 		auto p = gst_caps_features_new_empty();
139 
140 		if(p is null)
141 		{
142 			throw new ConstructionException("null returned by new_empty");
143 		}
144 
145 		this(cast(GstCapsFeatures*) p);
146 	}
147 
148 	/**
149 	 * Creates a new #GstCapsFeatures with the given features.
150 	 *
151 	 * Free-function: gst_caps_features_free
152 	 *
153 	 * Params:
154 	 *     feature1 = name of first feature to set
155 	 *     varargs = variable argument list
156 	 *
157 	 * Returns: a new, empty #GstCapsFeatures
158 	 *
159 	 * Since: 1.2
160 	 *
161 	 * Throws: ConstructionException GTK+ fails to create the object.
162 	 */
163 	public this(GQuark feature1, void* varargs)
164 	{
165 		auto p = gst_caps_features_new_id_valist(feature1, varargs);
166 
167 		if(p is null)
168 		{
169 			throw new ConstructionException("null returned by new_id_valist");
170 		}
171 
172 		this(cast(GstCapsFeatures*) p);
173 	}
174 
175 	/**
176 	 * Creates a new #GstCapsFeatures with the given features.
177 	 *
178 	 * Free-function: gst_caps_features_free
179 	 *
180 	 * Params:
181 	 *     feature1 = name of first feature to set
182 	 *     varargs = variable argument list
183 	 *
184 	 * Returns: a new, empty #GstCapsFeatures
185 	 *
186 	 * Since: 1.2
187 	 *
188 	 * Throws: ConstructionException GTK+ fails to create the object.
189 	 */
190 	public this(string feature1, void* varargs)
191 	{
192 		auto p = gst_caps_features_new_valist(Str.toStringz(feature1), varargs);
193 
194 		if(p is null)
195 		{
196 			throw new ConstructionException("null returned by new_valist");
197 		}
198 
199 		this(cast(GstCapsFeatures*) p);
200 	}
201 
202 	/**
203 	 * Adds @feature to @features.
204 	 *
205 	 * Params:
206 	 *     feature = a feature.
207 	 *
208 	 * Since: 1.2
209 	 */
210 	public void add(string feature)
211 	{
212 		gst_caps_features_add(gstCapsFeatures, Str.toStringz(feature));
213 	}
214 
215 	/**
216 	 * Adds @feature to @features.
217 	 *
218 	 * Params:
219 	 *     feature = a feature.
220 	 *
221 	 * Since: 1.2
222 	 */
223 	public void addId(GQuark feature)
224 	{
225 		gst_caps_features_add_id(gstCapsFeatures, feature);
226 	}
227 
228 	/**
229 	 * Check if @features contains @feature.
230 	 *
231 	 * Params:
232 	 *     feature = a feature
233 	 *
234 	 * Returns: %TRUE if @features contains @feature.
235 	 *
236 	 * Since: 1.2
237 	 */
238 	public bool contains(string feature)
239 	{
240 		return gst_caps_features_contains(gstCapsFeatures, Str.toStringz(feature)) != 0;
241 	}
242 
243 	/**
244 	 * Check if @features contains @feature.
245 	 *
246 	 * Params:
247 	 *     feature = a feature
248 	 *
249 	 * Returns: %TRUE if @features contains @feature.
250 	 *
251 	 * Since: 1.2
252 	 */
253 	public bool containsId(GQuark feature)
254 	{
255 		return gst_caps_features_contains_id(gstCapsFeatures, feature) != 0;
256 	}
257 
258 	/**
259 	 * Duplicates a #GstCapsFeatures and all its values.
260 	 *
261 	 * Free-function: gst_caps_features_free
262 	 *
263 	 * Returns: a new #GstCapsFeatures.
264 	 *
265 	 * Since: 1.2
266 	 */
267 	public CapsFeatures copy()
268 	{
269 		auto p = gst_caps_features_copy(gstCapsFeatures);
270 
271 		if(p is null)
272 		{
273 			return null;
274 		}
275 
276 		return ObjectG.getDObject!(CapsFeatures)(cast(GstCapsFeatures*) p, true);
277 	}
278 
279 	/**
280 	 * Frees a #GstCapsFeatures and all its values. The caps features must not
281 	 * have a parent when this function is called.
282 	 *
283 	 * Since: 1.2
284 	 */
285 	public void free()
286 	{
287 		gst_caps_features_free(gstCapsFeatures);
288 		ownedRef = false;
289 	}
290 
291 	/**
292 	 * Returns the @i-th feature of @features.
293 	 *
294 	 * Params:
295 	 *     i = index of the feature
296 	 *
297 	 * Returns: The @i-th feature of @features.
298 	 *
299 	 * Since: 1.2
300 	 */
301 	public string getNth(uint i)
302 	{
303 		return Str.toString(gst_caps_features_get_nth(gstCapsFeatures, i));
304 	}
305 
306 	/**
307 	 * Returns the @i-th feature of @features.
308 	 *
309 	 * Params:
310 	 *     i = index of the feature
311 	 *
312 	 * Returns: The @i-th feature of @features.
313 	 *
314 	 * Since: 1.2
315 	 */
316 	public GQuark getNthId(uint i)
317 	{
318 		return gst_caps_features_get_nth_id(gstCapsFeatures, i);
319 	}
320 
321 	/**
322 	 * Returns the number of features in @features.
323 	 *
324 	 * Returns: The number of features in @features.
325 	 *
326 	 * Since: 1.2
327 	 */
328 	public uint getSize()
329 	{
330 		return gst_caps_features_get_size(gstCapsFeatures);
331 	}
332 
333 	/**
334 	 * Check if @features is %GST_CAPS_FEATURES_ANY.
335 	 *
336 	 * Returns: %TRUE if @features is %GST_CAPS_FEATURES_ANY.
337 	 *
338 	 * Since: 1.2
339 	 */
340 	public bool isAny()
341 	{
342 		return gst_caps_features_is_any(gstCapsFeatures) != 0;
343 	}
344 
345 	/**
346 	 * Check if @features1 and @features2 are equal.
347 	 *
348 	 * Params:
349 	 *     features2 = a #GstCapsFeatures.
350 	 *
351 	 * Returns: %TRUE if @features1 and @features2 are equal.
352 	 *
353 	 * Since: 1.2
354 	 */
355 	public bool isEqual(CapsFeatures features2)
356 	{
357 		return gst_caps_features_is_equal(gstCapsFeatures, (features2 is null) ? null : features2.getCapsFeaturesStruct()) != 0;
358 	}
359 
360 	/**
361 	 * Removes @feature from @features.
362 	 *
363 	 * Params:
364 	 *     feature = a feature.
365 	 *
366 	 * Since: 1.2
367 	 */
368 	public void remove(string feature)
369 	{
370 		gst_caps_features_remove(gstCapsFeatures, Str.toStringz(feature));
371 	}
372 
373 	/**
374 	 * Removes @feature from @features.
375 	 *
376 	 * Params:
377 	 *     feature = a feature.
378 	 *
379 	 * Since: 1.2
380 	 */
381 	public void removeId(GQuark feature)
382 	{
383 		gst_caps_features_remove_id(gstCapsFeatures, feature);
384 	}
385 
386 	/**
387 	 * Sets the parent_refcount field of #GstCapsFeatures. This field is used to
388 	 * determine whether a caps features is mutable or not. This function should only be
389 	 * called by code implementing parent objects of #GstCapsFeatures, as described in
390 	 * the MT Refcounting section of the design documents.
391 	 *
392 	 * Params:
393 	 *     refcount = a pointer to the parent's refcount
394 	 *
395 	 * Returns: %TRUE if the parent refcount could be set.
396 	 *
397 	 * Since: 1.2
398 	 */
399 	public bool setParentRefcount(int* refcount)
400 	{
401 		return gst_caps_features_set_parent_refcount(gstCapsFeatures, refcount) != 0;
402 	}
403 
404 	/**
405 	 * Converts @features to a human-readable string representation.
406 	 *
407 	 * For debugging purposes its easier to do something like this:
408 	 * |[<!-- language="C" -->
409 	 * GST_LOG ("features is %" GST_PTR_FORMAT, features);
410 	 * ]|
411 	 * This prints the features in human readable form.
412 	 *
413 	 * Free-function: g_free
414 	 *
415 	 * Returns: a pointer to string allocated by g_malloc().
416 	 *     g_free() after usage.
417 	 *
418 	 * Since: 1.2
419 	 */
420 	public override string toString()
421 	{
422 		auto retStr = gst_caps_features_to_string(gstCapsFeatures);
423 
424 		scope(exit) Str.freeString(retStr);
425 		return Str.toString(retStr);
426 	}
427 
428 	/**
429 	 * Creates a #GstCapsFeatures from a string representation.
430 	 *
431 	 * Free-function: gst_caps_features_free
432 	 *
433 	 * Params:
434 	 *     features = a string representation of a #GstCapsFeatures.
435 	 *
436 	 * Returns: a new #GstCapsFeatures or
437 	 *     %NULL when the string could not be parsed. Free with
438 	 *     gst_caps_features_free() after use.
439 	 *
440 	 * Since: 1.2
441 	 */
442 	public static CapsFeatures fromString(string features)
443 	{
444 		auto p = gst_caps_features_from_string(Str.toStringz(features));
445 
446 		if(p is null)
447 		{
448 			return null;
449 		}
450 
451 		return ObjectG.getDObject!(CapsFeatures)(cast(GstCapsFeatures*) p, true);
452 	}
453 }