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