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