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