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.Structure; 26 27 private import glib.ConstructionException; 28 private import glib.Date; 29 private import glib.Str; 30 private import gobject.ObjectG; 31 private import gobject.Value; 32 private import gobject.ValueArray; 33 private import gstreamer.DateTime; 34 private import gstreamerc.gstreamer; 35 public import gstreamerc.gstreamertypes; 36 37 38 /** 39 * A #GstStructure is a collection of key/value pairs. The keys are expressed 40 * as GQuarks and the values can be of any GType. 41 * 42 * In addition to the key/value pairs, a #GstStructure also has a name. The name 43 * starts with a letter and can be filled by letters, numbers and any of "/-_.:". 44 * 45 * #GstStructure is used by various GStreamer subsystems to store information 46 * in a flexible and extensible way. A #GstStructure does not have a refcount 47 * because it usually is part of a higher level object such as #GstCaps, 48 * #GstMessage, #GstEvent, #GstQuery. It provides a means to enforce mutability 49 * using the refcount of the parent with the gst_structure_set_parent_refcount() 50 * method. 51 * 52 * A #GstStructure can be created with gst_structure_new_empty() or 53 * gst_structure_new(), which both take a name and an optional set of 54 * key/value pairs along with the types of the values. 55 * 56 * Field values can be changed with gst_structure_set_value() or 57 * gst_structure_set(). 58 * 59 * Field values can be retrieved with gst_structure_get_value() or the more 60 * convenient gst_structure_get_*() functions. 61 * 62 * Fields can be removed with gst_structure_remove_field() or 63 * gst_structure_remove_fields(). 64 * 65 * Strings in structures must be ASCII or UTF-8 encoded. Other encodings are 66 * not allowed. Strings may be %NULL however. 67 * 68 * Be aware that the current #GstCaps / #GstStructure serialization into string 69 * has limited support for nested #GstCaps / #GstStructure fields. It can only 70 * support one level of nesting. Using more levels will lead to unexpected 71 * behavior when using serialization features, such as gst_caps_to_string() or 72 * gst_value_serialize() and their counterparts. 73 */ 74 public class Structure 75 { 76 /** the main Gtk struct */ 77 protected GstStructure* gstStructure; 78 protected bool ownedRef; 79 80 /** Get the main Gtk struct */ 81 public GstStructure* getStructureStruct() 82 { 83 return gstStructure; 84 } 85 86 /** the main Gtk struct as a void* */ 87 protected void* getStruct() 88 { 89 return cast(void*)gstStructure; 90 } 91 92 /** 93 * Sets our main struct and passes it to the parent class. 94 */ 95 public this (GstStructure* gstStructure, bool ownedRef = false) 96 { 97 this.gstStructure = gstStructure; 98 this.ownedRef = ownedRef; 99 } 100 101 public static Structure fromString(string name) 102 { 103 auto p = gst_structure_new_from_string(Str.toStringz(name)); 104 105 if(p is null) 106 { 107 throw new ConstructionException("null returned by gst_structure_new_from_string(Str.toStringz(name))"); 108 } 109 110 return new Structure(cast(GstStructure*)p); //, true); 111 } 112 113 /** 114 */ 115 116 /** */ 117 public static GType getType() 118 { 119 return gst_structure_get_type(); 120 } 121 122 /** 123 * Creates a new, empty #GstStructure with the given @name. 124 * 125 * See gst_structure_set_name() for constraints on the @name parameter. 126 * 127 * Free-function: gst_structure_free 128 * 129 * Params: 130 * name = name of new structure 131 * 132 * Returns: a new, empty #GstStructure 133 * 134 * Throws: ConstructionException GTK+ fails to create the object. 135 */ 136 public this(string name) 137 { 138 auto p = gst_structure_new_empty(Str.toStringz(name)); 139 140 if(p is null) 141 { 142 throw new ConstructionException("null returned by new_empty"); 143 } 144 145 this(cast(GstStructure*) p); 146 } 147 148 /** 149 * Creates a new, empty #GstStructure with the given name as a GQuark. 150 * 151 * Free-function: gst_structure_free 152 * 153 * Params: 154 * quark = name of new structure 155 * 156 * Returns: a new, empty #GstStructure 157 * 158 * Throws: ConstructionException GTK+ fails to create the object. 159 */ 160 public this(GQuark quark) 161 { 162 auto p = gst_structure_new_id_empty(quark); 163 164 if(p is null) 165 { 166 throw new ConstructionException("null returned by new_id_empty"); 167 } 168 169 this(cast(GstStructure*) p); 170 } 171 172 /** 173 * Creates a new #GstStructure with the given @name. Structure fields 174 * are set according to the varargs in a manner similar to 175 * gst_structure_new(). 176 * 177 * See gst_structure_set_name() for constraints on the @name parameter. 178 * 179 * Free-function: gst_structure_free 180 * 181 * Params: 182 * name = name of new structure 183 * firstfield = name of first field to set 184 * varargs = variable argument list 185 * 186 * Returns: a new #GstStructure 187 * 188 * Throws: ConstructionException GTK+ fails to create the object. 189 */ 190 public this(string name, string firstfield, void* varargs) 191 { 192 auto p = gst_structure_new_valist(Str.toStringz(name), Str.toStringz(firstfield), varargs); 193 194 if(p is null) 195 { 196 throw new ConstructionException("null returned by new_valist"); 197 } 198 199 this(cast(GstStructure*) p); 200 } 201 202 /** 203 * Tries intersecting @struct1 and @struct2 and reports whether the result 204 * would not be empty. 205 * 206 * Params: 207 * struct2 = a #GstStructure 208 * 209 * Returns: %TRUE if intersection would not be empty 210 */ 211 public bool canIntersect(Structure struct2) 212 { 213 return gst_structure_can_intersect(gstStructure, (struct2 is null) ? null : struct2.getStructureStruct()) != 0; 214 } 215 216 /** 217 * Duplicates a #GstStructure and all its fields and values. 218 * 219 * Free-function: gst_structure_free 220 * 221 * Returns: a new #GstStructure. 222 */ 223 public Structure copy() 224 { 225 auto p = gst_structure_copy(gstStructure); 226 227 if(p is null) 228 { 229 return null; 230 } 231 232 return ObjectG.getDObject!(Structure)(cast(GstStructure*) p, true); 233 } 234 235 /** 236 * Calls the provided function once for each field in the #GstStructure. In 237 * contrast to gst_structure_foreach(), the function may modify the fields. 238 * In contrast to gst_structure_map_in_place(), the field is removed from 239 * the structure if %FALSE is returned from the function. 240 * The structure must be mutable. 241 * 242 * Params: 243 * func = a function to call for each field 244 * userData = private data 245 * 246 * Since: 1.6 247 */ 248 public void filterAndMapInPlace(GstStructureFilterMapFunc func, void* userData) 249 { 250 gst_structure_filter_and_map_in_place(gstStructure, func, userData); 251 } 252 253 /** 254 * Fixate all values in @structure using gst_value_fixate(). 255 * @structure will be modified in-place and should be writable. 256 */ 257 public void fixate() 258 { 259 gst_structure_fixate(gstStructure); 260 } 261 262 /** 263 * Fixates a #GstStructure by changing the given field with its fixated value. 264 * 265 * Params: 266 * fieldName = a field in @structure 267 * 268 * Returns: %TRUE if the structure field could be fixated 269 */ 270 public bool fixateField(string fieldName) 271 { 272 return gst_structure_fixate_field(gstStructure, Str.toStringz(fieldName)) != 0; 273 } 274 275 /** 276 * Fixates a #GstStructure by changing the given @field_name field to the given 277 * @target boolean if that field is not fixed yet. 278 * 279 * Params: 280 * fieldName = a field in @structure 281 * target = the target value of the fixation 282 * 283 * Returns: %TRUE if the structure could be fixated 284 */ 285 public bool fixateFieldBoolean(string fieldName, bool target) 286 { 287 return gst_structure_fixate_field_boolean(gstStructure, Str.toStringz(fieldName), target) != 0; 288 } 289 290 /** 291 * Fixates a #GstStructure by changing the given field to the nearest 292 * double to @target that is a subset of the existing field. 293 * 294 * Params: 295 * fieldName = a field in @structure 296 * target = the target value of the fixation 297 * 298 * Returns: %TRUE if the structure could be fixated 299 */ 300 public bool fixateFieldNearestDouble(string fieldName, double target) 301 { 302 return gst_structure_fixate_field_nearest_double(gstStructure, Str.toStringz(fieldName), target) != 0; 303 } 304 305 /** 306 * Fixates a #GstStructure by changing the given field to the nearest 307 * fraction to @target_numerator/@target_denominator that is a subset 308 * of the existing field. 309 * 310 * Params: 311 * fieldName = a field in @structure 312 * targetNumerator = The numerator of the target value of the fixation 313 * targetDenominator = The denominator of the target value of the fixation 314 * 315 * Returns: %TRUE if the structure could be fixated 316 */ 317 public bool fixateFieldNearestFraction(string fieldName, int targetNumerator, int targetDenominator) 318 { 319 return gst_structure_fixate_field_nearest_fraction(gstStructure, Str.toStringz(fieldName), targetNumerator, targetDenominator) != 0; 320 } 321 322 /** 323 * Fixates a #GstStructure by changing the given field to the nearest 324 * integer to @target that is a subset of the existing field. 325 * 326 * Params: 327 * fieldName = a field in @structure 328 * target = the target value of the fixation 329 * 330 * Returns: %TRUE if the structure could be fixated 331 */ 332 public bool fixateFieldNearestInt(string fieldName, int target) 333 { 334 return gst_structure_fixate_field_nearest_int(gstStructure, Str.toStringz(fieldName), target) != 0; 335 } 336 337 /** 338 * Fixates a #GstStructure by changing the given @field_name field to the given 339 * @target string if that field is not fixed yet. 340 * 341 * Params: 342 * fieldName = a field in @structure 343 * target = the target value of the fixation 344 * 345 * Returns: %TRUE if the structure could be fixated 346 */ 347 public bool fixateFieldString(string fieldName, string target) 348 { 349 return gst_structure_fixate_field_string(gstStructure, Str.toStringz(fieldName), Str.toStringz(target)) != 0; 350 } 351 352 /** 353 * Calls the provided function once for each field in the #GstStructure. The 354 * function must not modify the fields. Also see gst_structure_map_in_place() 355 * and gst_structure_filter_and_map_in_place(). 356 * 357 * Params: 358 * func = a function to call for each field 359 * userData = private data 360 * 361 * Returns: %TRUE if the supplied function returns %TRUE For each of the fields, 362 * %FALSE otherwise. 363 */ 364 public bool foreac(GstStructureForeachFunc func, void* userData) 365 { 366 return gst_structure_foreach(gstStructure, func, userData) != 0; 367 } 368 369 /** 370 * Frees a #GstStructure and all its fields and values. The structure must not 371 * have a parent when this function is called. 372 */ 373 public void free() 374 { 375 gst_structure_free(gstStructure); 376 } 377 378 /** 379 * This is useful in language bindings where unknown #GValue types are not 380 * supported. This function will convert the %GST_TYPE_ARRAY and 381 * %GST_TYPE_LIST into a newly allocated #GValueArray and return it through 382 * @array. Be aware that this is slower then getting the #GValue directly. 383 * 384 * Params: 385 * fieldname = the name of a field 386 * array = a pointer to a #GValueArray 387 * 388 * Returns: %TRUE if the value could be set correctly. If there was no field 389 * with @fieldname or the existing field did not contain an int, this function 390 * returns %FALSE. 391 */ 392 public bool getArray(string fieldname, out ValueArray array) 393 { 394 GValueArray* outarray = null; 395 396 auto p = gst_structure_get_array(gstStructure, Str.toStringz(fieldname), &outarray) != 0; 397 398 array = ObjectG.getDObject!(ValueArray)(outarray); 399 400 return p; 401 } 402 403 /** 404 * Sets the boolean pointed to by @value corresponding to the value of the 405 * given field. Caller is responsible for making sure the field exists 406 * and has the correct type. 407 * 408 * Params: 409 * fieldname = the name of a field 410 * value = a pointer to a #gboolean to set 411 * 412 * Returns: %TRUE if the value could be set correctly. If there was no field 413 * with @fieldname or the existing field did not contain a boolean, this 414 * function returns %FALSE. 415 */ 416 public bool getBoolean(string fieldname, out bool value) 417 { 418 int outvalue; 419 420 auto p = gst_structure_get_boolean(gstStructure, Str.toStringz(fieldname), &outvalue) != 0; 421 422 value = (outvalue == 1); 423 424 return p; 425 } 426 427 /** 428 * Sets the clock time pointed to by @value corresponding to the clock time 429 * of the given field. Caller is responsible for making sure the field exists 430 * and has the correct type. 431 * 432 * Params: 433 * fieldname = the name of a field 434 * value = a pointer to a #GstClockTime to set 435 * 436 * Returns: %TRUE if the value could be set correctly. If there was no field 437 * with @fieldname or the existing field did not contain a #GstClockTime, this 438 * function returns %FALSE. 439 */ 440 public bool getClockTime(string fieldname, out GstClockTime value) 441 { 442 return gst_structure_get_clock_time(gstStructure, Str.toStringz(fieldname), &value) != 0; 443 } 444 445 /** 446 * Sets the date pointed to by @value corresponding to the date of the 447 * given field. Caller is responsible for making sure the field exists 448 * and has the correct type. 449 * 450 * On success @value will point to a newly-allocated copy of the date which 451 * should be freed with g_date_free() when no longer needed (note: this is 452 * inconsistent with e.g. gst_structure_get_string() which doesn't return a 453 * copy of the string). 454 * 455 * Params: 456 * fieldname = the name of a field 457 * value = a pointer to a #GDate to set 458 * 459 * Returns: %TRUE if the value could be set correctly. If there was no field 460 * with @fieldname or the existing field did not contain a data, this function 461 * returns %FALSE. 462 */ 463 public bool getDate(string fieldname, out Date value) 464 { 465 GDate* outvalue = null; 466 467 auto p = gst_structure_get_date(gstStructure, Str.toStringz(fieldname), &outvalue) != 0; 468 469 value = new Date(outvalue); 470 471 return p; 472 } 473 474 /** 475 * Sets the datetime pointed to by @value corresponding to the datetime of the 476 * given field. Caller is responsible for making sure the field exists 477 * and has the correct type. 478 * 479 * On success @value will point to a reference of the datetime which 480 * should be unreffed with gst_date_time_unref() when no longer needed 481 * (note: this is inconsistent with e.g. gst_structure_get_string() 482 * which doesn't return a copy of the string). 483 * 484 * Params: 485 * fieldname = the name of a field 486 * value = a pointer to a #GstDateTime to set 487 * 488 * Returns: %TRUE if the value could be set correctly. If there was no field 489 * with @fieldname or the existing field did not contain a data, this function 490 * returns %FALSE. 491 */ 492 public bool getDateTime(string fieldname, out DateTime value) 493 { 494 GstDateTime* outvalue = null; 495 496 auto p = gst_structure_get_date_time(gstStructure, Str.toStringz(fieldname), &outvalue) != 0; 497 498 value = ObjectG.getDObject!(DateTime)(outvalue); 499 500 return p; 501 } 502 503 /** 504 * Sets the double pointed to by @value corresponding to the value of the 505 * given field. Caller is responsible for making sure the field exists 506 * and has the correct type. 507 * 508 * Params: 509 * fieldname = the name of a field 510 * value = a pointer to a gdouble to set 511 * 512 * Returns: %TRUE if the value could be set correctly. If there was no field 513 * with @fieldname or the existing field did not contain a double, this 514 * function returns %FALSE. 515 */ 516 public bool getDouble(string fieldname, out double value) 517 { 518 return gst_structure_get_double(gstStructure, Str.toStringz(fieldname), &value) != 0; 519 } 520 521 /** 522 * Sets the int pointed to by @value corresponding to the value of the 523 * given field. Caller is responsible for making sure the field exists, 524 * has the correct type and that the enumtype is correct. 525 * 526 * Params: 527 * fieldname = the name of a field 528 * enumtype = the enum type of a field 529 * value = a pointer to an int to set 530 * 531 * Returns: %TRUE if the value could be set correctly. If there was no field 532 * with @fieldname or the existing field did not contain an enum of the given 533 * type, this function returns %FALSE. 534 */ 535 public bool getEnum(string fieldname, GType enumtype, out int value) 536 { 537 return gst_structure_get_enum(gstStructure, Str.toStringz(fieldname), enumtype, &value) != 0; 538 } 539 540 /** 541 * Finds the field with the given name, and returns the type of the 542 * value it contains. If the field is not found, G_TYPE_INVALID is 543 * returned. 544 * 545 * Params: 546 * fieldname = the name of the field 547 * 548 * Returns: the #GValue of the field 549 */ 550 public GType getFieldType(string fieldname) 551 { 552 return gst_structure_get_field_type(gstStructure, Str.toStringz(fieldname)); 553 } 554 555 /** 556 * Read the GstFlagSet flags and mask out of the structure into the 557 * provided pointers. 558 * 559 * Params: 560 * fieldname = the name of a field 561 * valueFlags = a pointer to a guint for the flags field 562 * valueMask = a pointer to a guint for the mask field 563 * 564 * Returns: %TRUE if the values could be set correctly. If there was no field 565 * with @fieldname or the existing field did not contain a GstFlagSet, this 566 * function returns %FALSE. 567 * 568 * Since: 1.6 569 */ 570 public bool getFlagset(string fieldname, out uint valueFlags, out uint valueMask) 571 { 572 return gst_structure_get_flagset(gstStructure, Str.toStringz(fieldname), &valueFlags, &valueMask) != 0; 573 } 574 575 /** 576 * Sets the integers pointed to by @value_numerator and @value_denominator 577 * corresponding to the value of the given field. Caller is responsible 578 * for making sure the field exists and has the correct type. 579 * 580 * Params: 581 * fieldname = the name of a field 582 * valueNumerator = a pointer to an int to set 583 * valueDenominator = a pointer to an int to set 584 * 585 * Returns: %TRUE if the values could be set correctly. If there was no field 586 * with @fieldname or the existing field did not contain a GstFraction, this 587 * function returns %FALSE. 588 */ 589 public bool getFraction(string fieldname, out int valueNumerator, out int valueDenominator) 590 { 591 return gst_structure_get_fraction(gstStructure, Str.toStringz(fieldname), &valueNumerator, &valueDenominator) != 0; 592 } 593 594 /** 595 * Sets the int pointed to by @value corresponding to the value of the 596 * given field. Caller is responsible for making sure the field exists 597 * and has the correct type. 598 * 599 * Params: 600 * fieldname = the name of a field 601 * value = a pointer to an int to set 602 * 603 * Returns: %TRUE if the value could be set correctly. If there was no field 604 * with @fieldname or the existing field did not contain an int, this function 605 * returns %FALSE. 606 */ 607 public bool getInt(string fieldname, out int value) 608 { 609 return gst_structure_get_int(gstStructure, Str.toStringz(fieldname), &value) != 0; 610 } 611 612 /** 613 * Sets the #gint64 pointed to by @value corresponding to the value of the 614 * given field. Caller is responsible for making sure the field exists 615 * and has the correct type. 616 * 617 * Params: 618 * fieldname = the name of a field 619 * value = a pointer to a #gint64 to set 620 * 621 * Returns: %TRUE if the value could be set correctly. If there was no field 622 * with @fieldname or the existing field did not contain a #gint64, this function 623 * returns %FALSE. 624 * 625 * Since: 1.4 626 */ 627 public bool getInt64(string fieldname, out long value) 628 { 629 return gst_structure_get_int64(gstStructure, Str.toStringz(fieldname), &value) != 0; 630 } 631 632 /** 633 * This is useful in language bindings where unknown #GValue types are not 634 * supported. This function will convert the %GST_TYPE_ARRAY and 635 * %GST_TYPE_LIST into a newly allocated GValueArray and return it through 636 * @array. Be aware that this is slower then getting the #GValue directly. 637 * 638 * Params: 639 * fieldname = the name of a field 640 * array = a pointer to a #GValueArray 641 * 642 * Returns: %TRUE if the value could be set correctly. If there was no field 643 * with @fieldname or the existing field did not contain an int, this function 644 * returns %FALSE. 645 * 646 * Since 1.12 647 */ 648 public bool getList(string fieldname, out ValueArray array) 649 { 650 GValueArray* outarray = null; 651 652 auto p = gst_structure_get_list(gstStructure, Str.toStringz(fieldname), &outarray) != 0; 653 654 array = ObjectG.getDObject!(ValueArray)(outarray); 655 656 return p; 657 } 658 659 /** 660 * Get the name of @structure as a string. 661 * 662 * Returns: the name of the structure. 663 */ 664 public string getName() 665 { 666 return Str.toString(gst_structure_get_name(gstStructure)); 667 } 668 669 /** 670 * Get the name of @structure as a GQuark. 671 * 672 * Returns: the quark representing the name of the structure. 673 */ 674 public GQuark getNameId() 675 { 676 return gst_structure_get_name_id(gstStructure); 677 } 678 679 /** 680 * Finds the field corresponding to @fieldname, and returns the string 681 * contained in the field's value. Caller is responsible for making 682 * sure the field exists and has the correct type. 683 * 684 * The string should not be modified, and remains valid until the next 685 * call to a gst_structure_*() function with the given structure. 686 * 687 * Params: 688 * fieldname = the name of a field 689 * 690 * Returns: a pointer to the string or %NULL when the 691 * field did not exist or did not contain a string. 692 */ 693 public string getString(string fieldname) 694 { 695 return Str.toString(gst_structure_get_string(gstStructure, Str.toStringz(fieldname))); 696 } 697 698 /** 699 * Sets the uint pointed to by @value corresponding to the value of the 700 * given field. Caller is responsible for making sure the field exists 701 * and has the correct type. 702 * 703 * Params: 704 * fieldname = the name of a field 705 * value = a pointer to a uint to set 706 * 707 * Returns: %TRUE if the value could be set correctly. If there was no field 708 * with @fieldname or the existing field did not contain a uint, this function 709 * returns %FALSE. 710 */ 711 public bool getUint(string fieldname, out uint value) 712 { 713 return gst_structure_get_uint(gstStructure, Str.toStringz(fieldname), &value) != 0; 714 } 715 716 /** 717 * Sets the #guint64 pointed to by @value corresponding to the value of the 718 * given field. Caller is responsible for making sure the field exists 719 * and has the correct type. 720 * 721 * Params: 722 * fieldname = the name of a field 723 * value = a pointer to a #guint64 to set 724 * 725 * Returns: %TRUE if the value could be set correctly. If there was no field 726 * with @fieldname or the existing field did not contain a #guint64, this function 727 * returns %FALSE. 728 * 729 * Since: 1.4 730 */ 731 public bool getUint64(string fieldname, out ulong value) 732 { 733 return gst_structure_get_uint64(gstStructure, Str.toStringz(fieldname), &value) != 0; 734 } 735 736 /** 737 * Parses the variable arguments and reads fields from @structure accordingly. 738 * valist-variant of gst_structure_get(). Look at the documentation of 739 * gst_structure_get() for more details. 740 * 741 * Params: 742 * firstFieldname = the name of the first field to read 743 * args = variable arguments 744 * 745 * Returns: %TRUE, or %FALSE if there was a problem reading any of the fields 746 */ 747 public bool getValist(string firstFieldname, void* args) 748 { 749 return gst_structure_get_valist(gstStructure, Str.toStringz(firstFieldname), args) != 0; 750 } 751 752 /** 753 * Get the value of the field with name @fieldname. 754 * 755 * Params: 756 * fieldname = the name of the field to get 757 * 758 * Returns: the #GValue corresponding to the field with the given name. 759 */ 760 public Value getValue(string fieldname) 761 { 762 auto p = gst_structure_get_value(gstStructure, Str.toStringz(fieldname)); 763 764 if(p is null) 765 { 766 return null; 767 } 768 769 return ObjectG.getDObject!(Value)(cast(GValue*) p); 770 } 771 772 /** 773 * Check if @structure contains a field named @fieldname. 774 * 775 * Params: 776 * fieldname = the name of a field 777 * 778 * Returns: %TRUE if the structure contains a field with the given name 779 */ 780 public bool hasField(string fieldname) 781 { 782 return gst_structure_has_field(gstStructure, Str.toStringz(fieldname)) != 0; 783 } 784 785 /** 786 * Check if @structure contains a field named @fieldname and with GType @type. 787 * 788 * Params: 789 * fieldname = the name of a field 790 * type = the type of a value 791 * 792 * Returns: %TRUE if the structure contains a field with the given name and type 793 */ 794 public bool hasFieldTyped(string fieldname, GType type) 795 { 796 return gst_structure_has_field_typed(gstStructure, Str.toStringz(fieldname), type) != 0; 797 } 798 799 /** 800 * Checks if the structure has the given name 801 * 802 * Params: 803 * name = structure name to check for 804 * 805 * Returns: %TRUE if @name matches the name of the structure. 806 */ 807 public bool hasName(string name) 808 { 809 return gst_structure_has_name(gstStructure, Str.toStringz(name)) != 0; 810 } 811 812 /** 813 * Parses the variable arguments and reads fields from @structure accordingly. 814 * valist-variant of gst_structure_id_get(). Look at the documentation of 815 * gst_structure_id_get() for more details. 816 * 817 * Params: 818 * firstFieldId = the quark of the first field to read 819 * args = variable arguments 820 * 821 * Returns: %TRUE, or %FALSE if there was a problem reading any of the fields 822 */ 823 public bool idGetValist(GQuark firstFieldId, void* args) 824 { 825 return gst_structure_id_get_valist(gstStructure, firstFieldId, args) != 0; 826 } 827 828 /** 829 * Get the value of the field with GQuark @field. 830 * 831 * Params: 832 * field = the #GQuark of the field to get 833 * 834 * Returns: the #GValue corresponding to the field with the given name 835 * identifier. 836 */ 837 public Value idGetValue(GQuark field) 838 { 839 auto p = gst_structure_id_get_value(gstStructure, field); 840 841 if(p is null) 842 { 843 return null; 844 } 845 846 return ObjectG.getDObject!(Value)(cast(GValue*) p); 847 } 848 849 /** 850 * Check if @structure contains a field named @field. 851 * 852 * Params: 853 * field = #GQuark of the field name 854 * 855 * Returns: %TRUE if the structure contains a field with the given name 856 */ 857 public bool idHasField(GQuark field) 858 { 859 return gst_structure_id_has_field(gstStructure, field) != 0; 860 } 861 862 /** 863 * Check if @structure contains a field named @field and with GType @type. 864 * 865 * Params: 866 * field = #GQuark of the field name 867 * type = the type of a value 868 * 869 * Returns: %TRUE if the structure contains a field with the given name and type 870 */ 871 public bool idHasFieldTyped(GQuark field, GType type) 872 { 873 return gst_structure_id_has_field_typed(gstStructure, field, type) != 0; 874 } 875 876 /** 877 * va_list form of gst_structure_id_set(). 878 * 879 * Params: 880 * fieldname = the name of the field to set 881 * varargs = variable arguments 882 */ 883 public void idSetValist(GQuark fieldname, void* varargs) 884 { 885 gst_structure_id_set_valist(gstStructure, fieldname, varargs); 886 } 887 888 /** 889 * Sets the field with the given GQuark @field to @value. If the field 890 * does not exist, it is created. If the field exists, the previous 891 * value is replaced and freed. 892 * 893 * Params: 894 * field = a #GQuark representing a field 895 * value = the new value of the field 896 */ 897 public void idSetValue(GQuark field, Value value) 898 { 899 gst_structure_id_set_value(gstStructure, field, (value is null) ? null : value.getValueStruct()); 900 } 901 902 /** 903 * Sets the field with the given GQuark @field to @value. If the field 904 * does not exist, it is created. If the field exists, the previous 905 * value is replaced and freed. 906 * 907 * Params: 908 * field = a #GQuark representing a field 909 * value = the new value of the field 910 */ 911 public void idTakeValue(GQuark field, Value value) 912 { 913 gst_structure_id_take_value(gstStructure, field, (value is null) ? null : value.getValueStruct()); 914 } 915 916 /** 917 * Intersects @struct1 and @struct2 and returns the intersection. 918 * 919 * Params: 920 * struct2 = a #GstStructure 921 * 922 * Returns: Intersection of @struct1 and @struct2 923 */ 924 public Structure intersect(Structure struct2) 925 { 926 auto p = gst_structure_intersect(gstStructure, (struct2 is null) ? null : struct2.getStructureStruct()); 927 928 if(p is null) 929 { 930 return null; 931 } 932 933 return ObjectG.getDObject!(Structure)(cast(GstStructure*) p, true); 934 } 935 936 /** 937 * Tests if the two #GstStructure are equal. 938 * 939 * Params: 940 * structure2 = a #GstStructure. 941 * 942 * Returns: %TRUE if the two structures have the same name and field. 943 */ 944 public bool isEqual(Structure structure2) 945 { 946 return gst_structure_is_equal(gstStructure, (structure2 is null) ? null : structure2.getStructureStruct()) != 0; 947 } 948 949 /** 950 * Checks if @subset is a subset of @superset, i.e. has the same 951 * structure name and for all fields that are existing in @superset, 952 * @subset has a value that is a subset of the value in @superset. 953 * 954 * Params: 955 * superset = a potentially greater #GstStructure 956 * 957 * Returns: %TRUE if @subset is a subset of @superset 958 */ 959 public bool isSubset(Structure superset) 960 { 961 return gst_structure_is_subset(gstStructure, (superset is null) ? null : superset.getStructureStruct()) != 0; 962 } 963 964 /** 965 * Calls the provided function once for each field in the #GstStructure. In 966 * contrast to gst_structure_foreach(), the function may modify but not delete the 967 * fields. The structure must be mutable. 968 * 969 * Params: 970 * func = a function to call for each field 971 * userData = private data 972 * 973 * Returns: %TRUE if the supplied function returns %TRUE For each of the fields, 974 * %FALSE otherwise. 975 */ 976 public bool mapInPlace(GstStructureMapFunc func, void* userData) 977 { 978 return gst_structure_map_in_place(gstStructure, func, userData) != 0; 979 } 980 981 /** 982 * Get the number of fields in the structure. 983 * 984 * Returns: the number of fields in the structure 985 */ 986 public int nFields() 987 { 988 return gst_structure_n_fields(gstStructure); 989 } 990 991 /** 992 * Get the name of the given field number, counting from 0 onwards. 993 * 994 * Params: 995 * index = the index to get the name of 996 * 997 * Returns: the name of the given field number 998 */ 999 public string nthFieldName(uint index) 1000 { 1001 return Str.toString(gst_structure_nth_field_name(gstStructure, index)); 1002 } 1003 1004 /** 1005 * Removes all fields in a GstStructure. 1006 */ 1007 public void removeAllFields() 1008 { 1009 gst_structure_remove_all_fields(gstStructure); 1010 } 1011 1012 /** 1013 * Removes the field with the given name. If the field with the given 1014 * name does not exist, the structure is unchanged. 1015 * 1016 * Params: 1017 * fieldname = the name of the field to remove 1018 */ 1019 public void removeField(string fieldname) 1020 { 1021 gst_structure_remove_field(gstStructure, Str.toStringz(fieldname)); 1022 } 1023 1024 /** 1025 * va_list form of gst_structure_remove_fields(). 1026 * 1027 * Params: 1028 * fieldname = the name of the field to remove 1029 * varargs = %NULL-terminated list of more fieldnames to remove 1030 */ 1031 public void removeFieldsValist(string fieldname, void* varargs) 1032 { 1033 gst_structure_remove_fields_valist(gstStructure, Str.toStringz(fieldname), varargs); 1034 } 1035 1036 /** 1037 * This is useful in language bindings where unknown GValue types are not 1038 * supported. This function will convert a @array to %GST_TYPE_ARRAY and set 1039 * the field specified by @fieldname. Be aware that this is slower then using 1040 * %GST_TYPE_ARRAY in a #GValue directly. 1041 * 1042 * Since 1.12 1043 * 1044 * Params: 1045 * fieldname = the name of a field 1046 * array = a pointer to a #GValueArray 1047 */ 1048 public void setArray(string fieldname, ValueArray array) 1049 { 1050 gst_structure_set_array(gstStructure, Str.toStringz(fieldname), (array is null) ? null : array.getValueArrayStruct()); 1051 } 1052 1053 /** 1054 * This is useful in language bindings where unknown GValue types are not 1055 * supported. This function will convert a @array to %GST_TYPE_ARRAY and set 1056 * the field specified by @fieldname. Be aware that this is slower then using 1057 * %GST_TYPE_ARRAY in a #GValue directly. 1058 * 1059 * Since 1.12 1060 * 1061 * Params: 1062 * fieldname = the name of a field 1063 * array = a pointer to a #GValueArray 1064 */ 1065 public void setList(string fieldname, ValueArray array) 1066 { 1067 gst_structure_set_list(gstStructure, Str.toStringz(fieldname), (array is null) ? null : array.getValueArrayStruct()); 1068 } 1069 1070 /** 1071 * Sets the name of the structure to the given @name. The string 1072 * provided is copied before being used. It must not be empty, start with a 1073 * letter and can be followed by letters, numbers and any of "/-_.:". 1074 * 1075 * Params: 1076 * name = the new name of the structure 1077 */ 1078 public void setName(string name) 1079 { 1080 gst_structure_set_name(gstStructure, Str.toStringz(name)); 1081 } 1082 1083 /** 1084 * Sets the parent_refcount field of #GstStructure. This field is used to 1085 * determine whether a structure is mutable or not. This function should only be 1086 * called by code implementing parent objects of #GstStructure, as described in 1087 * the MT Refcounting section of the design documents. 1088 * 1089 * Params: 1090 * refcount = a pointer to the parent's refcount 1091 * 1092 * Returns: %TRUE if the parent refcount could be set. 1093 */ 1094 public bool setParentRefcount(int* refcount) 1095 { 1096 return gst_structure_set_parent_refcount(gstStructure, refcount) != 0; 1097 } 1098 1099 /** 1100 * va_list form of gst_structure_set(). 1101 * 1102 * Params: 1103 * fieldname = the name of the field to set 1104 * varargs = variable arguments 1105 */ 1106 public void setValist(string fieldname, void* varargs) 1107 { 1108 gst_structure_set_valist(gstStructure, Str.toStringz(fieldname), varargs); 1109 } 1110 1111 /** 1112 * Sets the field with the given name @field to @value. If the field 1113 * does not exist, it is created. If the field exists, the previous 1114 * value is replaced and freed. 1115 * 1116 * Params: 1117 * fieldname = the name of the field to set 1118 * value = the new value of the field 1119 */ 1120 public void setValue(string fieldname, Value value) 1121 { 1122 gst_structure_set_value(gstStructure, Str.toStringz(fieldname), (value is null) ? null : value.getValueStruct()); 1123 } 1124 1125 /** 1126 * Sets the field with the given name @field to @value. If the field 1127 * does not exist, it is created. If the field exists, the previous 1128 * value is replaced and freed. The function will take ownership of @value. 1129 * 1130 * Params: 1131 * fieldname = the name of the field to set 1132 * value = the new value of the field 1133 */ 1134 public void takeValue(string fieldname, Value value) 1135 { 1136 gst_structure_take_value(gstStructure, Str.toStringz(fieldname), (value is null) ? null : value.getValueStruct()); 1137 } 1138 1139 /** 1140 * Converts @structure to a human-readable string representation. 1141 * 1142 * For debugging purposes its easier to do something like this: 1143 * |[<!-- language="C" --> 1144 * GST_LOG ("structure is %" GST_PTR_FORMAT, structure); 1145 * ]| 1146 * This prints the structure in human readable form. 1147 * 1148 * The current implementation of serialization will lead to unexpected results 1149 * when there are nested #GstCaps / #GstStructure deeper than one level. 1150 * 1151 * Free-function: g_free 1152 * 1153 * Returns: a pointer to string allocated by g_malloc(). 1154 * g_free() after usage. 1155 */ 1156 public override string toString() 1157 { 1158 auto retStr = gst_structure_to_string(gstStructure); 1159 1160 scope(exit) Str.freeString(retStr); 1161 return Str.toString(retStr); 1162 } 1163 1164 /** 1165 * Creates a #GstStructure from a string representation. 1166 * If end is not %NULL, a pointer to the place inside the given string 1167 * where parsing ended will be returned. 1168 * 1169 * Free-function: gst_structure_free 1170 * 1171 * Params: 1172 * str = a string representation of a #GstStructure. 1173 * end = pointer to store the end of the string in. 1174 * 1175 * Returns: a new #GstStructure or %NULL 1176 * when the string could not be parsed. Free with 1177 * gst_structure_free() after use. 1178 */ 1179 public static Structure fromString(string str, out string end) 1180 { 1181 char* outend = null; 1182 1183 auto p = gst_structure_from_string(Str.toStringz(str), &outend); 1184 1185 end = Str.toString(outend); 1186 1187 if(p is null) 1188 { 1189 return null; 1190 } 1191 1192 return ObjectG.getDObject!(Structure)(cast(GstStructure*) p, true); 1193 } 1194 }