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.Caps; 26 27 private import glib.ConstructionException; 28 private import glib.Str; 29 private import gobject.ObjectG; 30 private import gobject.Value; 31 private import gstreamer.CapsFeatures; 32 private import gstreamer.Structure; 33 private import gstreamerc.gstreamer; 34 public import gstreamerc.gstreamertypes; 35 36 37 /** 38 * Caps (capabilities) are lightweight refcounted objects describing media types. 39 * They are composed of an array of #GstStructure. 40 * 41 * Caps are exposed on #GstPadTemplate to describe all possible types a 42 * given pad can handle. They are also stored in the #GstRegistry along with 43 * a description of the #GstElement. 44 * 45 * Caps are exposed on the element pads using the gst_pad_query_caps() pad 46 * function. This function describes the possible types that the pad can 47 * handle or produce at runtime. 48 * 49 * A #GstCaps can be constructed with the following code fragment: 50 * |[ 51 * GstCaps *caps = gst_caps_new_simple ("video/x-raw", 52 * "format", G_TYPE_STRING, "I420", 53 * "framerate", GST_TYPE_FRACTION, 25, 1, 54 * "pixel-aspect-ratio", GST_TYPE_FRACTION, 1, 1, 55 * "width", G_TYPE_INT, 320, 56 * "height", G_TYPE_INT, 240, 57 * NULL); 58 * ]| 59 * 60 * A #GstCaps is fixed when it has no properties with ranges or lists. Use 61 * gst_caps_is_fixed() to test for fixed caps. Fixed caps can be used in a 62 * caps event to notify downstream elements of the current media type. 63 * 64 * Various methods exist to work with the media types such as subtracting 65 * or intersecting. 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 Caps 74 { 75 /** the main Gtk struct */ 76 protected GstCaps* gstCaps; 77 78 /** Get the main Gtk struct */ 79 public GstCaps* getCapsStruct() 80 { 81 return gstCaps; 82 } 83 84 /** the main Gtk struct as a void* */ 85 protected void* getStruct() 86 { 87 return cast(void*)gstCaps; 88 } 89 90 /** 91 * Sets our main struct and passes it to the parent class. 92 */ 93 public this (GstCaps* gstCaps) 94 { 95 this.gstCaps = gstCaps; 96 } 97 98 /** 99 * Creates a new GstCaps that indicates that it is compatible with 100 * any media format. 101 * Returns: 102 * the new GstCaps 103 */ 104 public static Caps newAny() 105 { 106 // GstCaps* gst_caps_new_any (void); 107 auto p = cast(GstCaps*)gst_caps_new_any(); 108 109 if(p is null) 110 { 111 throw new ConstructionException("null returned by gst_caps_new_any"); 112 } 113 114 return new Caps(cast(GstCaps*)p); //, true); 115 } 116 117 /** 118 */ 119 120 public static GType getType() 121 { 122 return gst_caps_get_type(); 123 } 124 125 /** 126 * Creates a new #GstCaps that is empty. That is, the returned 127 * #GstCaps contains no media formats. 128 * The #GstCaps is guaranteed to be writable. 129 * Caller is responsible for unreffing the returned caps. 130 * 131 * Return: the new #GstCaps 132 * 133 * Throws: ConstructionException GTK+ fails to create the object. 134 */ 135 public this() 136 { 137 auto p = gst_caps_new_empty(); 138 139 if(p is null) 140 { 141 throw new ConstructionException("null returned by new_empty"); 142 } 143 144 this(cast(GstCaps*) p); 145 } 146 147 /** 148 * Creates a new #GstCaps that contains one #GstStructure with name 149 * @media_type. 150 * Caller is responsible for unreffing the returned caps. 151 * 152 * Params: 153 * mediaType = the media type of the structure 154 * 155 * Return: the new #GstCaps 156 * 157 * Throws: ConstructionException GTK+ fails to create the object. 158 */ 159 public this(string mediaType) 160 { 161 auto p = gst_caps_new_empty_simple(Str.toStringz(mediaType)); 162 163 if(p is null) 164 { 165 throw new ConstructionException("null returned by new_empty_simple"); 166 } 167 168 this(cast(GstCaps*) p); 169 } 170 171 /** 172 * Creates a new #GstCaps and adds all the structures listed as 173 * arguments. The list must be %NULL-terminated. The structures 174 * are not copied; the returned #GstCaps owns the structures. 175 * 176 * Params: 177 * structure = the first structure to add 178 * varArgs = additional structures to add 179 * 180 * Return: the new #GstCaps 181 * 182 * Throws: ConstructionException GTK+ fails to create the object. 183 */ 184 public this(Structure structure, void* varArgs) 185 { 186 auto p = gst_caps_new_full_valist((structure is null) ? null : structure.getStructureStruct(), varArgs); 187 188 if(p is null) 189 { 190 throw new ConstructionException("null returned by new_full_valist"); 191 } 192 193 this(cast(GstCaps*) p); 194 } 195 196 /** 197 * Appends the structures contained in @caps2 to @caps1. The structures in 198 * @caps2 are not copied -- they are transferred to @caps1, and then @caps2 is 199 * freed. If either caps is ANY, the resulting caps will be ANY. 200 * 201 * Params: 202 * caps2 = the #GstCaps to append 203 */ 204 public void append(Caps caps2) 205 { 206 gst_caps_append(gstCaps, (caps2 is null) ? null : caps2.getCapsStruct()); 207 } 208 209 /** 210 * Appends @structure to @caps. The structure is not copied; @caps 211 * becomes the owner of @structure. 212 * 213 * Params: 214 * structure = the #GstStructure to append 215 */ 216 public void appendStructure(Structure structure) 217 { 218 gst_caps_append_structure(gstCaps, (structure is null) ? null : structure.getStructureStruct()); 219 } 220 221 /** 222 * Appends @structure with @features to @caps. The structure is not copied; @caps 223 * becomes the owner of @structure. 224 * 225 * Params: 226 * structure = the #GstStructure to append 227 * features = the #GstCapsFeatures to append 228 * 229 * Since: 1.2 230 */ 231 public void appendStructureFull(Structure structure, CapsFeatures features) 232 { 233 gst_caps_append_structure_full(gstCaps, (structure is null) ? null : structure.getStructureStruct(), (features is null) ? null : features.getCapsFeaturesStruct()); 234 } 235 236 /** 237 * Tries intersecting @caps1 and @caps2 and reports whether the result would not 238 * be empty 239 * 240 * Params: 241 * caps2 = a #GstCaps to intersect 242 * 243 * Return: %TRUE if intersection would be not empty 244 */ 245 public bool canIntersect(Caps caps2) 246 { 247 return gst_caps_can_intersect(gstCaps, (caps2 is null) ? null : caps2.getCapsStruct()) != 0; 248 } 249 250 /** 251 * Creates a new #GstCaps and appends a copy of the nth structure 252 * contained in @caps. 253 * 254 * Params: 255 * nth = the nth structure to copy 256 * 257 * Return: the new #GstCaps 258 */ 259 public Caps copyNth(uint nth) 260 { 261 auto p = gst_caps_copy_nth(gstCaps, nth); 262 263 if(p is null) 264 { 265 return null; 266 } 267 268 return ObjectG.getDObject!(Caps)(cast(GstCaps*) p); 269 } 270 271 /** 272 * Calls the provided function once for each structure and caps feature in the 273 * #GstCaps. In contrast to gst_caps_foreach(), the function may modify the 274 * structure and features. In contrast to gst_caps_filter_and_map_in_place(), 275 * the structure and features are removed from the caps if %FALSE is returned 276 * from the function. 277 * The caps must be mutable. 278 * 279 * Params: 280 * func = a function to call for each field 281 * userData = private data 282 * 283 * Since: 1.6 284 */ 285 public void filterAndMapInPlace(GstCapsFilterMapFunc func, void* userData) 286 { 287 gst_caps_filter_and_map_in_place(gstCaps, func, userData); 288 } 289 290 /** 291 * Modifies the given @caps into a representation with only fixed 292 * values. First the caps will be truncated and then the first structure will be 293 * fixated with gst_structure_fixate(). 294 * 295 * Return: the fixated caps 296 */ 297 public Caps fixate() 298 { 299 auto p = gst_caps_fixate(gstCaps); 300 301 if(p is null) 302 { 303 return null; 304 } 305 306 return ObjectG.getDObject!(Caps)(cast(GstCaps*) p); 307 } 308 309 /** 310 * Calls the provided function once for each structure and caps feature in the 311 * #GstCaps. The function must not modify the fields. 312 * Also see gst_caps_map_in_place() and gst_caps_filter_and_map_in_place(). 313 * 314 * Params: 315 * func = a function to call for each field 316 * userData = private data 317 * 318 * Return: %TRUE if the supplied function returns %TRUE for each call, 319 * %FALSE otherwise. 320 * 321 * Since: 1.6 322 */ 323 public bool foreac(GstCapsForeachFunc func, void* userData) 324 { 325 return gst_caps_foreach(gstCaps, func, userData) != 0; 326 } 327 328 /** 329 * Finds the features in @caps that has the index @index, and 330 * returns it. 331 * 332 * WARNING: This function takes a const GstCaps *, but returns a 333 * non-const GstCapsFeatures *. This is for programming convenience -- 334 * the caller should be aware that structures inside a constant 335 * #GstCaps should not be modified. However, if you know the caps 336 * are writable, either because you have just copied them or made 337 * them writable with gst_caps_make_writable(), you may modify the 338 * features returned in the usual way, e.g. with functions like 339 * gst_caps_features_add(). 340 * 341 * You do not need to free or unref the structure returned, it 342 * belongs to the #GstCaps. 343 * 344 * Params: 345 * index = the index of the structure 346 * 347 * Return: a pointer to the #GstCapsFeatures corresponding 348 * to @index 349 * 350 * Since: 1.2 351 */ 352 public CapsFeatures getFeatures(uint index) 353 { 354 auto p = gst_caps_get_features(gstCaps, index); 355 356 if(p is null) 357 { 358 return null; 359 } 360 361 return ObjectG.getDObject!(CapsFeatures)(cast(GstCapsFeatures*) p); 362 } 363 364 /** 365 * Gets the number of structures contained in @caps. 366 * 367 * Return: the number of structures that @caps contains 368 */ 369 public uint getSize() 370 { 371 return gst_caps_get_size(gstCaps); 372 } 373 374 /** 375 * Finds the structure in @caps that has the index @index, and 376 * returns it. 377 * 378 * WARNING: This function takes a const GstCaps *, but returns a 379 * non-const GstStructure *. This is for programming convenience -- 380 * the caller should be aware that structures inside a constant 381 * #GstCaps should not be modified. However, if you know the caps 382 * are writable, either because you have just copied them or made 383 * them writable with gst_caps_make_writable(), you may modify the 384 * structure returned in the usual way, e.g. with functions like 385 * gst_structure_set(). 386 * 387 * You do not need to free or unref the structure returned, it 388 * belongs to the #GstCaps. 389 * 390 * Params: 391 * index = the index of the structure 392 * 393 * Return: a pointer to the #GstStructure corresponding 394 * to @index 395 */ 396 public Structure getStructure(uint index) 397 { 398 auto p = gst_caps_get_structure(gstCaps, index); 399 400 if(p is null) 401 { 402 return null; 403 } 404 405 return ObjectG.getDObject!(Structure)(cast(GstStructure*) p); 406 } 407 408 /** 409 * Creates a new #GstCaps that contains all the formats that are common 410 * to both @caps1 and @caps2. Defaults to %GST_CAPS_INTERSECT_ZIG_ZAG mode. 411 * 412 * Params: 413 * caps2 = a #GstCaps to intersect 414 * 415 * Return: the new #GstCaps 416 */ 417 public Caps intersect(Caps caps2) 418 { 419 auto p = gst_caps_intersect(gstCaps, (caps2 is null) ? null : caps2.getCapsStruct()); 420 421 if(p is null) 422 { 423 return null; 424 } 425 426 return ObjectG.getDObject!(Caps)(cast(GstCaps*) p); 427 } 428 429 /** 430 * Creates a new #GstCaps that contains all the formats that are common 431 * to both @caps1 and @caps2, the order is defined by the #GstCapsIntersectMode 432 * used. 433 * 434 * Params: 435 * caps2 = a #GstCaps to intersect 436 * mode = The intersection algorithm/mode to use 437 * 438 * Return: the new #GstCaps 439 */ 440 public Caps intersectFull(Caps caps2, GstCapsIntersectMode mode) 441 { 442 auto p = gst_caps_intersect_full(gstCaps, (caps2 is null) ? null : caps2.getCapsStruct(), mode); 443 444 if(p is null) 445 { 446 return null; 447 } 448 449 return ObjectG.getDObject!(Caps)(cast(GstCaps*) p); 450 } 451 452 /** 453 * A given #GstCaps structure is always compatible with another if 454 * every media format that is in the first is also contained in the 455 * second. That is, @caps1 is a subset of @caps2. 456 * 457 * Params: 458 * caps2 = the #GstCaps to test 459 * 460 * Return: %TRUE if @caps1 is a subset of @caps2. 461 */ 462 public bool isAlwaysCompatible(Caps caps2) 463 { 464 return gst_caps_is_always_compatible(gstCaps, (caps2 is null) ? null : caps2.getCapsStruct()) != 0; 465 } 466 467 /** 468 * Determines if @caps represents any media format. 469 * 470 * Return: %TRUE if @caps represents any format. 471 */ 472 public bool isAny() 473 { 474 return gst_caps_is_any(gstCaps) != 0; 475 } 476 477 /** 478 * Determines if @caps represents no media formats. 479 * 480 * Return: %TRUE if @caps represents no formats. 481 */ 482 public bool isEmpty() 483 { 484 return gst_caps_is_empty(gstCaps) != 0; 485 } 486 487 /** 488 * Checks if the given caps represent the same set of caps. 489 * 490 * Params: 491 * caps2 = another #GstCaps 492 * 493 * Return: %TRUE if both caps are equal. 494 */ 495 public bool isEqual(Caps caps2) 496 { 497 return gst_caps_is_equal(gstCaps, (caps2 is null) ? null : caps2.getCapsStruct()) != 0; 498 } 499 500 /** 501 * Tests if two #GstCaps are equal. This function only works on fixed 502 * #GstCaps. 503 * 504 * Params: 505 * caps2 = the #GstCaps to test 506 * 507 * Return: %TRUE if the arguments represent the same format 508 */ 509 public bool isEqualFixed(Caps caps2) 510 { 511 return gst_caps_is_equal_fixed(gstCaps, (caps2 is null) ? null : caps2.getCapsStruct()) != 0; 512 } 513 514 /** 515 * Fixed #GstCaps describe exactly one format, that is, they have exactly 516 * one structure, and each field in the structure describes a fixed type. 517 * Examples of non-fixed types are GST_TYPE_INT_RANGE and GST_TYPE_LIST. 518 * 519 * Return: %TRUE if @caps is fixed 520 */ 521 public bool isFixed() 522 { 523 return gst_caps_is_fixed(gstCaps) != 0; 524 } 525 526 /** 527 * Checks if the given caps are exactly the same set of caps. 528 * 529 * Params: 530 * caps2 = another #GstCaps 531 * 532 * Return: %TRUE if both caps are strictly equal. 533 */ 534 public bool isStrictlyEqual(Caps caps2) 535 { 536 return gst_caps_is_strictly_equal(gstCaps, (caps2 is null) ? null : caps2.getCapsStruct()) != 0; 537 } 538 539 /** 540 * Checks if all caps represented by @subset are also represented by @superset. 541 * 542 * Params: 543 * superset = a potentially greater #GstCaps 544 * 545 * Return: %TRUE if @subset is a subset of @superset 546 */ 547 public bool isSubset(Caps superset) 548 { 549 return gst_caps_is_subset(gstCaps, (superset is null) ? null : superset.getCapsStruct()) != 0; 550 } 551 552 /** 553 * Checks if @structure is a subset of @caps. See gst_caps_is_subset() 554 * for more information. 555 * 556 * Params: 557 * structure = a potential #GstStructure subset of @caps 558 * 559 * Return: %TRUE if @structure is a subset of @caps 560 */ 561 public bool isSubsetStructure(Structure structure) 562 { 563 return gst_caps_is_subset_structure(gstCaps, (structure is null) ? null : structure.getStructureStruct()) != 0; 564 } 565 566 /** 567 * Checks if @structure is a subset of @caps. See gst_caps_is_subset() 568 * for more information. 569 * 570 * Params: 571 * structure = a potential #GstStructure subset of @caps 572 * features = a #GstCapsFeatures for @structure 573 * 574 * Return: %TRUE if @structure is a subset of @caps 575 * 576 * Since: 1.2 577 */ 578 public bool isSubsetStructureFull(Structure structure, CapsFeatures features) 579 { 580 return gst_caps_is_subset_structure_full(gstCaps, (structure is null) ? null : structure.getStructureStruct(), (features is null) ? null : features.getCapsFeaturesStruct()) != 0; 581 } 582 583 /** 584 * Calls the provided function once for each structure and caps feature in the 585 * #GstCaps. In contrast to gst_caps_foreach(), the function may modify but not 586 * delete the structures and features. The caps must be mutable. 587 * 588 * Params: 589 * func = a function to call for each field 590 * userData = private data 591 * 592 * Return: %TRUE if the supplied function returns %TRUE for each call, 593 * %FALSE otherwise. 594 * 595 * Since: 1.6 596 */ 597 public bool mapInPlace(GstCapsMapFunc func, void* userData) 598 { 599 return gst_caps_map_in_place(gstCaps, func, userData) != 0; 600 } 601 602 /** 603 * Appends the structures contained in @caps2 to @caps1 if they are not yet 604 * expressed by @caps1. The structures in @caps2 are not copied -- they are 605 * transferred to a writable copy of @caps1, and then @caps2 is freed. 606 * If either caps is ANY, the resulting caps will be ANY. 607 * 608 * Params: 609 * caps2 = the #GstCaps to merge in 610 * 611 * Return: the merged caps. 612 */ 613 public Caps merge(Caps caps2) 614 { 615 auto p = gst_caps_merge(gstCaps, (caps2 is null) ? null : caps2.getCapsStruct()); 616 617 if(p is null) 618 { 619 return null; 620 } 621 622 return ObjectG.getDObject!(Caps)(cast(GstCaps*) p); 623 } 624 625 /** 626 * Appends @structure to @caps if its not already expressed by @caps. 627 * 628 * Params: 629 * structure = the #GstStructure to merge 630 * 631 * Return: the merged caps. 632 */ 633 public Caps mergeStructure(Structure structure) 634 { 635 auto p = gst_caps_merge_structure(gstCaps, (structure is null) ? null : structure.getStructureStruct()); 636 637 if(p is null) 638 { 639 return null; 640 } 641 642 return ObjectG.getDObject!(Caps)(cast(GstCaps*) p); 643 } 644 645 /** 646 * Appends @structure with @features to @caps if its not already expressed by @caps. 647 * 648 * Params: 649 * structure = the #GstStructure to merge 650 * features = the #GstCapsFeatures to merge 651 * 652 * Return: the merged caps. 653 * 654 * Since: 1.2 655 */ 656 public Caps mergeStructureFull(Structure structure, CapsFeatures features) 657 { 658 auto p = gst_caps_merge_structure_full(gstCaps, (structure is null) ? null : structure.getStructureStruct(), (features is null) ? null : features.getCapsFeaturesStruct()); 659 660 if(p is null) 661 { 662 return null; 663 } 664 665 return ObjectG.getDObject!(Caps)(cast(GstCaps*) p); 666 } 667 668 /** 669 * Returns a #GstCaps that represents the same set of formats as 670 * @caps, but contains no lists. Each list is expanded into separate 671 * @GstStructures. 672 * 673 * This function takes ownership of @caps. 674 * 675 * Return: the normalized #GstCaps 676 */ 677 public Caps normalize() 678 { 679 auto p = gst_caps_normalize(gstCaps); 680 681 if(p is null) 682 { 683 return null; 684 } 685 686 return ObjectG.getDObject!(Caps)(cast(GstCaps*) p); 687 } 688 689 /** 690 * removes the structure with the given index from the list of structures 691 * contained in @caps. 692 * 693 * Params: 694 * idx = Index of the structure to remove 695 */ 696 public void removeStructure(uint idx) 697 { 698 gst_caps_remove_structure(gstCaps, idx); 699 } 700 701 /** 702 * Sets the #GstCapsFeatures @features for the structure at @index. 703 * 704 * Params: 705 * index = the index of the structure 706 * features = the #GstCapsFeatures to set 707 * 708 * Since: 1.2 709 */ 710 public void setFeatures(uint index, CapsFeatures features) 711 { 712 gst_caps_set_features(gstCaps, index, (features is null) ? null : features.getCapsFeaturesStruct()); 713 } 714 715 /** 716 * Sets fields in a #GstCaps. The arguments must be passed in the same 717 * manner as gst_structure_set(), and be %NULL-terminated. 718 * 719 * Params: 720 * field = first field to set 721 * varargs = additional parameters 722 */ 723 public void setSimpleValist(string field, void* varargs) 724 { 725 gst_caps_set_simple_valist(gstCaps, Str.toStringz(field), varargs); 726 } 727 728 /** 729 * Sets the given @field on all structures of @caps to the given @value. 730 * This is a convenience function for calling gst_structure_set_value() on 731 * all structures of @caps. 732 * 733 * Params: 734 * field = name of the field to set 735 * value = value to set the field to 736 */ 737 public void setValue(string field, Value value) 738 { 739 gst_caps_set_value(gstCaps, Str.toStringz(field), (value is null) ? null : value.getValueStruct()); 740 } 741 742 /** 743 * Converts the given @caps into a representation that represents the 744 * same set of formats, but in a simpler form. Component structures that are 745 * identical are merged. Component structures that have values that can be 746 * merged are also merged. 747 * 748 * This method does not preserve the original order of @caps. 749 * 750 * Return: The simplified caps. 751 */ 752 public Caps simplify() 753 { 754 auto p = gst_caps_simplify(gstCaps); 755 756 if(p is null) 757 { 758 return null; 759 } 760 761 return ObjectG.getDObject!(Caps)(cast(GstCaps*) p); 762 } 763 764 /** 765 * Retrieves the structure with the given index from the list of structures 766 * contained in @caps. The caller becomes the owner of the returned structure. 767 * 768 * Params: 769 * index = Index of the structure to retrieve 770 * 771 * Return: a pointer to the #GstStructure corresponding 772 * to @index. 773 */ 774 public Structure stealStructure(uint index) 775 { 776 auto p = gst_caps_steal_structure(gstCaps, index); 777 778 if(p is null) 779 { 780 return null; 781 } 782 783 return ObjectG.getDObject!(Structure)(cast(GstStructure*) p); 784 } 785 786 /** 787 * Subtracts the @subtrahend from the @minuend. 788 * <note>This function does not work reliably if optional properties for caps 789 * are included on one caps and omitted on the other.</note> 790 * 791 * Params: 792 * subtrahend = #GstCaps to subtract 793 * 794 * Return: the resulting caps 795 */ 796 public Caps subtract(Caps subtrahend) 797 { 798 auto p = gst_caps_subtract(gstCaps, (subtrahend is null) ? null : subtrahend.getCapsStruct()); 799 800 if(p is null) 801 { 802 return null; 803 } 804 805 return ObjectG.getDObject!(Caps)(cast(GstCaps*) p); 806 } 807 808 /** 809 * Converts @caps to a string representation. This string representation 810 * can be converted back to a #GstCaps by gst_caps_from_string(). 811 * 812 * For debugging purposes its easier to do something like this: 813 * |[ 814 * GST_LOG ("caps are %" GST_PTR_FORMAT, caps); 815 * ]| 816 * This prints the caps in human readable form. 817 * 818 * The current implementation of serialization will lead to unexpected results 819 * when there are nested #GstCaps / #GstStructure deeper than one level. 820 * 821 * Return: a newly allocated string representing @caps. 822 */ 823 public override string toString() 824 { 825 return Str.toString(gst_caps_to_string(gstCaps)); 826 } 827 828 /** 829 * Discard all but the first structure from @caps. Useful when 830 * fixating. 831 * 832 * Return: truncated caps 833 */ 834 public Caps truncate() 835 { 836 auto p = gst_caps_truncate(gstCaps); 837 838 if(p is null) 839 { 840 return null; 841 } 842 843 return ObjectG.getDObject!(Caps)(cast(GstCaps*) p); 844 } 845 846 /** 847 * Converts @caps from a string representation. 848 * 849 * The current implementation of serialization will lead to unexpected results 850 * when there are nested #GstCaps / #GstStructure deeper than one level. 851 * 852 * Params: 853 * str = a string to convert to #GstCaps 854 * 855 * Return: a newly allocated #GstCaps 856 */ 857 public static Caps fromString(string str) 858 { 859 auto p = gst_caps_from_string(Str.toStringz(str)); 860 861 if(p is null) 862 { 863 return null; 864 } 865 866 return ObjectG.getDObject!(Caps)(cast(GstCaps*) p); 867 } 868 }