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