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