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.Query; 26 27 private import glib.ConstructionException; 28 private import glib.MemorySlice; 29 private import glib.Str; 30 private import glib.c.functions; 31 private import gobject.ObjectG; 32 private import gstreamer.AllocationParams; 33 private import gstreamer.Allocator; 34 private import gstreamer.BufferPool; 35 private import gstreamer.Caps; 36 private import gstreamer.Context; 37 private import gstreamer.Structure; 38 private import gstreamer.c.functions; 39 public import gstreamer.c.types; 40 41 42 /** 43 * Queries can be performed on pads (gst_pad_query()) and elements 44 * (gst_element_query()). Please note that some queries might need a running 45 * pipeline to work. 46 * 47 * Queries can be created using the gst_query_new_*() functions. 48 * Query values can be set using gst_query_set_*(), and parsed using 49 * gst_query_parse_*() helpers. 50 * 51 * The following example shows how to query the duration of a pipeline: 52 * |[<!-- language="C" --> 53 * GstQuery *query; 54 * gboolean res; 55 * query = gst_query_new_duration (GST_FORMAT_TIME); 56 * res = gst_element_query (pipeline, query); 57 * if (res) { 58 * gint64 duration; 59 * gst_query_parse_duration (query, NULL, &duration); 60 * g_print ("duration = %"GST_TIME_FORMAT, GST_TIME_ARGS (duration)); 61 * } else { 62 * g_print ("duration query failed..."); 63 * } 64 * gst_query_unref (query); 65 * ]| 66 */ 67 public class Query 68 { 69 /** the main Gtk struct */ 70 protected GstQuery* gstQuery; 71 protected bool ownedRef; 72 73 /** Get the main Gtk struct */ 74 public GstQuery* getQueryStruct(bool transferOwnership = false) 75 { 76 if (transferOwnership) 77 ownedRef = false; 78 return gstQuery; 79 } 80 81 /** the main Gtk struct as a void* */ 82 protected void* getStruct() 83 { 84 return cast(void*)gstQuery; 85 } 86 87 /** 88 * Sets our main struct and passes it to the parent class. 89 */ 90 public this (GstQuery* gstQuery, bool ownedRef = false) 91 { 92 this.gstQuery = gstQuery; 93 this.ownedRef = ownedRef; 94 } 95 96 /** 97 * Constructs a new query stream position query object. Use gst_query_unref() 98 * when done with it. A position query is used to query the current position 99 * of playback in the streams, in some format. 100 * Params: 101 * format = the default GstFormat for the new query 102 * Returns: 103 * A GstQuery 104 */ 105 public static Query newPosition(GstFormat format) 106 { 107 auto p = gst_query_new_position(format); 108 109 if(p is null) 110 { 111 throw new ConstructionException("null returned by gst_query_new_position"); 112 } 113 114 return new Query( cast(GstQuery*)p); //, true); 115 } 116 117 /** 118 * Constructs a new stream duration query object to query in the given format. 119 * Use gst_query_unref() when done with it. A duration query will give the 120 * total length of the stream. 121 * Params: 122 * format = the GstFormat for this duration query 123 * Returns: 124 * A GstQuery 125 */ 126 public static Query newDuration(GstFormat format) 127 { 128 auto p = gst_query_new_duration(format); 129 130 if(p is null) 131 { 132 throw new ConstructionException("null returned by gst_query_new_duration"); 133 } 134 135 return new Query( cast(GstQuery*)p); //, true); 136 } 137 138 /** 139 * Constructs a new query object for querying seeking properties of 140 * the stream. 141 * Params: 142 * format = the default GstFormat for the new query 143 * Returns: 144 * A GstQuery 145 */ 146 public static Query newSeeking(GstFormat format) 147 { 148 auto p = gst_query_new_seeking(format); 149 150 if(p is null) 151 { 152 throw new ConstructionException("null returned by gst_query_new_seeking"); 153 } 154 155 return new Query(cast(GstQuery*)p); //, true); 156 } 157 158 /** 159 * Constructs a new query object for querying formats of 160 * the stream. 161 * Returns: 162 * A GstQuery 163 */ 164 public static Query newFormats() 165 { 166 auto p = gst_query_new_formats(); 167 168 if(p is null) 169 { 170 throw new ConstructionException("null returned by gst_query_new_formats"); 171 } 172 173 return new Query(cast(GstQuery*)p); //, true); 174 } 175 176 /** 177 * Constructs a new segment query object. Use gst_query_unref() 178 * when done with it. A segment query is used to discover information about the 179 * currently configured segment for playback. 180 * Params: 181 * format = the GstFormat for the new query 182 * Returns: 183 * a GstQuery 184 */ 185 public static Query newSegment(GstFormat format) 186 { 187 auto p = gst_query_new_segment(format); 188 189 if(p is null) 190 { 191 throw new ConstructionException("null returned by gst_query_new_segment"); 192 } 193 194 return new Query(cast(GstQuery*)p); //, true); 195 } 196 197 /** 198 * Constructs a new latency query object. 199 * Use gst_query_unref() when done with it. A latency query is usually performed 200 * by sinks to compensate for additional latency introduced by elements in the 201 * pipeline. 202 * Free-function: gst_query_unref 203 */ 204 public static Query newLatency() 205 { 206 auto p = gst_query_new_latency(); 207 208 if(p is null) 209 { 210 throw new ConstructionException("null returned by gst_query_new_latency()"); 211 } 212 213 return new Query(cast(GstQuery*)p); //, true); 214 } 215 216 /** 217 * Constructs a new query URI query object. Use gst_query_unref() 218 * when done with it. An URI query is used to query the current URI 219 * that is used by the source or sink. 220 * Free-function: gst_query_unref 221 * Throws: ConstructionException GTK+ fails to create the object. 222 */ 223 public static Query newUri() 224 { 225 auto p = gst_query_new_uri(); 226 227 if(p is null) 228 { 229 throw new ConstructionException("null returned by gst_query_new_uri()"); 230 } 231 232 return new Query(cast(GstQuery*)p); //, true); 233 } 234 235 /** 236 * Constructs a new query object for querying the scheduling properties. 237 * Free-function: gst_query_unref 238 * Throws: ConstructionException GTK+ fails to create the object. 239 */ 240 public static Query newScheduling() 241 { 242 auto p = gst_query_new_scheduling(); 243 244 if(p is null) 245 { 246 throw new ConstructionException("null returned by gst_query_new_scheduling()"); 247 } 248 249 return new Query(cast(GstQuery*)p); //, true); 250 } 251 252 /** 253 * Constructs a new query object for querying the drain state. 254 * Free-function: gst_query_unref 255 * Throws: ConstructionException GTK+ fails to create the object. 256 */ 257 public static Query newDrain() 258 { 259 auto p = gst_query_new_drain(); 260 261 if(p is null) 262 { 263 throw new ConstructionException("null returned by gst_query_new_drain()"); 264 } 265 266 return new Query(cast(GstQuery*)p); //, true); 267 } 268 269 /** 270 * Constructs a new query object for querying if caps are accepted. 271 * Free-function: gst_query_unref 272 * Params: 273 * caps = a fixed GstCaps 274 * Throws: ConstructionException GTK+ fails to create the object. 275 */ 276 public static Query newAcceptCaps(Caps caps) 277 { 278 auto p = gst_query_new_accept_caps((caps is null) ? null : caps.getCapsStruct()); 279 280 if(p is null) 281 { 282 throw new ConstructionException("null returned by gst_query_new_accept_caps((caps is null) ? null : caps.getCapsStruct())"); 283 } 284 285 return new Query(cast(GstQuery*)p); //, true); 286 } 287 288 /** 289 */ 290 291 /** */ 292 public static GType getType() 293 { 294 return gst_query_get_type(); 295 } 296 297 /** 298 * Constructs a new query object for querying the allocation properties. 299 * 300 * Free-function: gst_query_unref() 301 * 302 * Params: 303 * caps = the negotiated caps 304 * needPool = return a pool 305 * 306 * Returns: a new #GstQuery 307 * 308 * Throws: ConstructionException GTK+ fails to create the object. 309 */ 310 public this(Caps caps, bool needPool) 311 { 312 auto __p = gst_query_new_allocation((caps is null) ? null : caps.getCapsStruct(), needPool); 313 314 if(__p is null) 315 { 316 throw new ConstructionException("null returned by new_allocation"); 317 } 318 319 this(cast(GstQuery*) __p); 320 } 321 322 /** 323 * Constructs a new query object for querying the bitrate. 324 * 325 * Free-function: gst_query_unref() 326 * 327 * Returns: a new #GstQuery 328 * 329 * Since: 1.16 330 * 331 * Throws: ConstructionException GTK+ fails to create the object. 332 */ 333 public this() 334 { 335 auto __p = gst_query_new_bitrate(); 336 337 if(__p is null) 338 { 339 throw new ConstructionException("null returned by new_bitrate"); 340 } 341 342 this(cast(GstQuery*) __p); 343 } 344 345 /** 346 * Constructs a new query object for querying the buffering status of 347 * a stream. 348 * 349 * Free-function: gst_query_unref() 350 * 351 * Params: 352 * format = the default #GstFormat for the new query 353 * 354 * Returns: a new #GstQuery 355 * 356 * Throws: ConstructionException GTK+ fails to create the object. 357 */ 358 public this(GstFormat format) 359 { 360 auto __p = gst_query_new_buffering(format); 361 362 if(__p is null) 363 { 364 throw new ConstructionException("null returned by new_buffering"); 365 } 366 367 this(cast(GstQuery*) __p); 368 } 369 370 /** 371 * Constructs a new query object for querying the caps. 372 * 373 * The CAPS query should return the allowable caps for a pad in the context 374 * of the element's state, its link to other elements, and the devices or files 375 * it has opened. These caps must be a subset of the pad template caps. In the 376 * NULL state with no links, the CAPS query should ideally return the same caps 377 * as the pad template. In rare circumstances, an object property can affect 378 * the caps returned by the CAPS query, but this is discouraged. 379 * 380 * For most filters, the caps returned by CAPS query is directly affected by the 381 * allowed caps on other pads. For demuxers and decoders, the caps returned by 382 * the srcpad's getcaps function is directly related to the stream data. Again, 383 * the CAPS query should return the most specific caps it reasonably can, since this 384 * helps with autoplugging. 385 * 386 * The @filter is used to restrict the result caps, only the caps matching 387 * @filter should be returned from the CAPS query. Specifying a filter might 388 * greatly reduce the amount of processing an element needs to do. 389 * 390 * Free-function: gst_query_unref() 391 * 392 * Params: 393 * filter = a filter 394 * 395 * Returns: a new #GstQuery 396 * 397 * Throws: ConstructionException GTK+ fails to create the object. 398 */ 399 public this(Caps filter) 400 { 401 auto __p = gst_query_new_caps((filter is null) ? null : filter.getCapsStruct()); 402 403 if(__p is null) 404 { 405 throw new ConstructionException("null returned by new_caps"); 406 } 407 408 this(cast(GstQuery*) __p); 409 } 410 411 /** 412 * Constructs a new query object for querying the pipeline-local context. 413 * 414 * Free-function: gst_query_unref() 415 * 416 * Params: 417 * contextType = Context type to query 418 * 419 * Returns: a new #GstQuery 420 * 421 * Since: 1.2 422 * 423 * Throws: ConstructionException GTK+ fails to create the object. 424 */ 425 public this(string contextType) 426 { 427 auto __p = gst_query_new_context(Str.toStringz(contextType)); 428 429 if(__p is null) 430 { 431 throw new ConstructionException("null returned by new_context"); 432 } 433 434 this(cast(GstQuery*) __p); 435 } 436 437 /** 438 * Constructs a new convert query object. Use gst_query_unref() 439 * when done with it. A convert query is used to ask for a conversion between 440 * one format and another. 441 * 442 * Free-function: gst_query_unref() 443 * 444 * Params: 445 * srcFormat = the source #GstFormat for the new query 446 * value = the value to convert 447 * destFormat = the target #GstFormat 448 * 449 * Returns: a #GstQuery 450 * 451 * Throws: ConstructionException GTK+ fails to create the object. 452 */ 453 public this(GstFormat srcFormat, long value, GstFormat destFormat) 454 { 455 auto __p = gst_query_new_convert(srcFormat, value, destFormat); 456 457 if(__p is null) 458 { 459 throw new ConstructionException("null returned by new_convert"); 460 } 461 462 this(cast(GstQuery*) __p); 463 } 464 465 /** 466 * Constructs a new custom query object. Use gst_query_unref() 467 * when done with it. 468 * 469 * Free-function: gst_query_unref() 470 * 471 * Params: 472 * type = the query type 473 * structure = a structure for the query 474 * 475 * Returns: a new #GstQuery 476 * 477 * Throws: ConstructionException GTK+ fails to create the object. 478 */ 479 public this(GstQueryType type, Structure structure) 480 { 481 auto __p = gst_query_new_custom(type, (structure is null) ? null : structure.getStructureStruct(true)); 482 483 if(__p is null) 484 { 485 throw new ConstructionException("null returned by new_custom"); 486 } 487 488 this(cast(GstQuery*) __p); 489 } 490 491 /** 492 * Add @api with @params as one of the supported metadata API to @query. 493 * 494 * Params: 495 * api = the metadata API 496 * params = API specific parameters 497 */ 498 public void addAllocationMeta(GType api, Structure params) 499 { 500 gst_query_add_allocation_meta(gstQuery, api, (params is null) ? null : params.getStructureStruct()); 501 } 502 503 /** 504 * Add @allocator and its @params as a supported memory allocator. 505 * 506 * Params: 507 * allocator = the memory allocator 508 * params = a #GstAllocationParams 509 */ 510 public void addAllocationParam(Allocator allocator, AllocationParams params) 511 { 512 gst_query_add_allocation_param(gstQuery, (allocator is null) ? null : allocator.getAllocatorStruct(), (params is null) ? null : params.getAllocationParamsStruct()); 513 } 514 515 /** 516 * Set the pool parameters in @query. 517 * 518 * Params: 519 * pool = the #GstBufferPool 520 * size = the buffer size 521 * minBuffers = the min buffers 522 * maxBuffers = the max buffers 523 */ 524 public void addAllocationPool(BufferPool pool, uint size, uint minBuffers, uint maxBuffers) 525 { 526 gst_query_add_allocation_pool(gstQuery, (pool is null) ? null : pool.getBufferPoolStruct(), size, minBuffers, maxBuffers); 527 } 528 529 /** 530 * Set the buffering-ranges array field in @query. The current last 531 * start position of the array should be inferior to @start. 532 * 533 * Params: 534 * start = start position of the range 535 * stop = stop position of the range 536 * 537 * Returns: a #gboolean indicating if the range was added or not. 538 */ 539 public bool addBufferingRange(long start, long stop) 540 { 541 return gst_query_add_buffering_range(gstQuery, start, stop) != 0; 542 } 543 544 /** 545 * Add @mode as one of the supported scheduling modes to @query. 546 * 547 * Params: 548 * mode = a #GstPadMode 549 */ 550 public void addSchedulingMode(GstPadMode mode) 551 { 552 gst_query_add_scheduling_mode(gstQuery, mode); 553 } 554 555 /** 556 * Check if @query has metadata @api set. When this function returns %TRUE, 557 * @index will contain the index where the requested API and the parameters 558 * can be found. 559 * 560 * Params: 561 * api = the metadata API 562 * index = the index 563 * 564 * Returns: %TRUE when @api is in the list of metadata. 565 */ 566 public bool findAllocationMeta(GType api, out uint index) 567 { 568 return gst_query_find_allocation_meta(gstQuery, api, &index) != 0; 569 } 570 571 /** 572 * Retrieve the number of values currently stored in the 573 * meta API array of the query's structure. 574 * 575 * Returns: the metadata API array size as a #guint. 576 */ 577 public uint getNAllocationMetas() 578 { 579 return gst_query_get_n_allocation_metas(gstQuery); 580 } 581 582 /** 583 * Retrieve the number of values currently stored in the 584 * allocator params array of the query's structure. 585 * 586 * If no memory allocator is specified, the downstream element can handle 587 * the default memory allocator. The first memory allocator in the query 588 * should be generic and allow mapping to system memory, all following 589 * allocators should be ordered by preference with the preferred one first. 590 * 591 * Returns: the allocator array size as a #guint. 592 */ 593 public uint getNAllocationParams() 594 { 595 return gst_query_get_n_allocation_params(gstQuery); 596 } 597 598 /** 599 * Retrieve the number of values currently stored in the 600 * pool array of the query's structure. 601 * 602 * Returns: the pool array size as a #guint. 603 */ 604 public uint getNAllocationPools() 605 { 606 return gst_query_get_n_allocation_pools(gstQuery); 607 } 608 609 /** 610 * Retrieve the number of values currently stored in the 611 * buffered-ranges array of the query's structure. 612 * 613 * Returns: the range array size as a #guint. 614 */ 615 public uint getNBufferingRanges() 616 { 617 return gst_query_get_n_buffering_ranges(gstQuery); 618 } 619 620 /** 621 * Retrieve the number of values currently stored in the 622 * scheduling mode array of the query's structure. 623 * 624 * Returns: the scheduling mode array size as a #guint. 625 */ 626 public uint getNSchedulingModes() 627 { 628 return gst_query_get_n_scheduling_modes(gstQuery); 629 } 630 631 /** 632 * Get the structure of a query. 633 * 634 * Returns: the #GstStructure of the query. The 635 * structure is still owned by the query and will therefore be freed when the 636 * query is unreffed. 637 */ 638 public Structure getStructure() 639 { 640 auto __p = gst_query_get_structure(gstQuery); 641 642 if(__p is null) 643 { 644 return null; 645 } 646 647 return ObjectG.getDObject!(Structure)(cast(GstStructure*) __p); 648 } 649 650 /** 651 * Check if @query has scheduling mode set. 652 * 653 * > When checking if upstream supports pull mode, it is usually not 654 * > enough to just check for GST_PAD_MODE_PULL with this function, you 655 * > also want to check whether the scheduling flags returned by 656 * > gst_query_parse_scheduling() have the seeking flag set (meaning 657 * > random access is supported, not only sequential pulls). 658 * 659 * Params: 660 * mode = the scheduling mode 661 * 662 * Returns: %TRUE when @mode is in the list of scheduling modes. 663 */ 664 public bool hasSchedulingMode(GstPadMode mode) 665 { 666 return gst_query_has_scheduling_mode(gstQuery, mode) != 0; 667 } 668 669 /** 670 * Check if @query has scheduling mode set and @flags is set in 671 * query scheduling flags. 672 * 673 * Params: 674 * mode = the scheduling mode 675 * flags = #GstSchedulingFlags 676 * 677 * Returns: %TRUE when @mode is in the list of scheduling modes 678 * and @flags are compatible with query flags. 679 */ 680 public bool hasSchedulingModeWithFlags(GstPadMode mode, GstSchedulingFlags flags) 681 { 682 return gst_query_has_scheduling_mode_with_flags(gstQuery, mode, flags) != 0; 683 } 684 685 /** 686 * Get the caps from @query. The caps remains valid as long as @query remains 687 * valid. 688 * 689 * Params: 690 * caps = A pointer to the caps 691 */ 692 public void parseAcceptCaps(out Caps caps) 693 { 694 GstCaps* outcaps = null; 695 696 gst_query_parse_accept_caps(gstQuery, &outcaps); 697 698 caps = ObjectG.getDObject!(Caps)(outcaps); 699 } 700 701 /** 702 * Parse the result from @query and store in @result. 703 * 704 * Params: 705 * result = location for the result 706 */ 707 public void parseAcceptCapsResult(ref bool result) 708 { 709 int outresult = (result ? 1 : 0); 710 711 gst_query_parse_accept_caps_result(gstQuery, &outresult); 712 713 result = (outresult == 1); 714 } 715 716 /** 717 * Parse an allocation query, writing the requested caps in @caps and 718 * whether a pool is needed in @need_pool, if the respective parameters 719 * are non-%NULL. 720 * 721 * Pool details can be retrieved using gst_query_get_n_allocation_pools() and 722 * gst_query_parse_nth_allocation_pool(). 723 * 724 * Params: 725 * caps = The #GstCaps 726 * needPool = Whether a #GstBufferPool is needed 727 */ 728 public void parseAllocation(out Caps caps, out bool needPool) 729 { 730 GstCaps* outcaps = null; 731 int outneedPool; 732 733 gst_query_parse_allocation(gstQuery, &outcaps, &outneedPool); 734 735 caps = ObjectG.getDObject!(Caps)(outcaps); 736 needPool = (outneedPool == 1); 737 } 738 739 /** 740 * Get the results of a bitrate query. See also gst_query_set_bitrate(). 741 * 742 * Params: 743 * nominalBitrate = The resulting bitrate in bits per second 744 * 745 * Since: 1.16 746 */ 747 public void parseBitrate(out uint nominalBitrate) 748 { 749 gst_query_parse_bitrate(gstQuery, &nominalBitrate); 750 } 751 752 /** 753 * Get the percentage of buffered data. This is a value between 0 and 100. 754 * The @busy indicator is %TRUE when the buffering is in progress. 755 * 756 * Params: 757 * busy = if buffering is busy, or %NULL 758 * percent = a buffering percent, or %NULL 759 */ 760 public void parseBufferingPercent(out bool busy, out int percent) 761 { 762 int outbusy; 763 764 gst_query_parse_buffering_percent(gstQuery, &outbusy, &percent); 765 766 busy = (outbusy == 1); 767 } 768 769 /** 770 * Parse an available query, writing the format into @format, and 771 * other results into the passed parameters, if the respective parameters 772 * are non-%NULL 773 * 774 * Params: 775 * format = the format to set for the @segment_start 776 * and @segment_end values, or %NULL 777 * start = the start to set, or %NULL 778 * stop = the stop to set, or %NULL 779 * estimatedTotal = estimated total amount of download 780 * time remaining in milliseconds, or %NULL 781 */ 782 public void parseBufferingRange(out GstFormat format, out long start, out long stop, out long estimatedTotal) 783 { 784 gst_query_parse_buffering_range(gstQuery, &format, &start, &stop, &estimatedTotal); 785 } 786 787 /** 788 * Extracts the buffering stats values from @query. 789 * 790 * Params: 791 * mode = a buffering mode, or %NULL 792 * avgIn = the average input rate, or %NULL 793 * avgOut = the average output rat, or %NULL 794 * bufferingLeft = amount of buffering time left in 795 * milliseconds, or %NULL 796 */ 797 public void parseBufferingStats(out GstBufferingMode mode, out int avgIn, out int avgOut, out long bufferingLeft) 798 { 799 gst_query_parse_buffering_stats(gstQuery, &mode, &avgIn, &avgOut, &bufferingLeft); 800 } 801 802 /** 803 * Get the filter from the caps @query. The caps remains valid as long as 804 * @query remains valid. 805 * 806 * Params: 807 * filter = A pointer to the caps filter 808 */ 809 public void parseCaps(out Caps filter) 810 { 811 GstCaps* outfilter = null; 812 813 gst_query_parse_caps(gstQuery, &outfilter); 814 815 filter = ObjectG.getDObject!(Caps)(outfilter); 816 } 817 818 /** 819 * Get the caps result from @query. The caps remains valid as long as 820 * @query remains valid. 821 * 822 * Params: 823 * caps = A pointer to the caps 824 */ 825 public void parseCapsResult(out Caps caps) 826 { 827 GstCaps* outcaps = null; 828 829 gst_query_parse_caps_result(gstQuery, &outcaps); 830 831 caps = ObjectG.getDObject!(Caps)(outcaps); 832 } 833 834 /** 835 * Get the context from the context @query. The context remains valid as long as 836 * @query remains valid. 837 * 838 * Params: 839 * context = A pointer to store the #GstContext 840 * 841 * Since: 1.2 842 */ 843 public void parseContext(out Context context) 844 { 845 GstContext* outcontext = null; 846 847 gst_query_parse_context(gstQuery, &outcontext); 848 849 context = ObjectG.getDObject!(Context)(outcontext); 850 } 851 852 /** 853 * Parse a context type from an existing GST_QUERY_CONTEXT query. 854 * 855 * Params: 856 * contextType = the context type, or %NULL 857 * 858 * Returns: a #gboolean indicating if the parsing succeeded. 859 * 860 * Since: 1.2 861 */ 862 public bool parseContextType(out string contextType) 863 { 864 char* outcontextType = null; 865 866 auto __p = gst_query_parse_context_type(gstQuery, &outcontextType) != 0; 867 868 contextType = Str.toString(outcontextType); 869 870 return __p; 871 } 872 873 /** 874 * Parse a convert query answer. Any of @src_format, @src_value, @dest_format, 875 * and @dest_value may be %NULL, in which case that value is omitted. 876 * 877 * Params: 878 * srcFormat = the storage for the #GstFormat of the 879 * source value, or %NULL 880 * srcValue = the storage for the source value, or %NULL 881 * destFormat = the storage for the #GstFormat of the 882 * destination value, or %NULL 883 * destValue = the storage for the destination value, 884 * or %NULL 885 */ 886 public void parseConvert(out GstFormat srcFormat, out long srcValue, out GstFormat destFormat, out long destValue) 887 { 888 gst_query_parse_convert(gstQuery, &srcFormat, &srcValue, &destFormat, &destValue); 889 } 890 891 /** 892 * Parse a duration query answer. Write the format of the duration into @format, 893 * and the value into @duration, if the respective variables are non-%NULL. 894 * 895 * Params: 896 * format = the storage for the #GstFormat of the duration 897 * value, or %NULL. 898 * duration = the storage for the total duration, or %NULL. 899 */ 900 public void parseDuration(out GstFormat format, out long duration) 901 { 902 gst_query_parse_duration(gstQuery, &format, &duration); 903 } 904 905 /** 906 * Parse a latency query answer. 907 * 908 * Params: 909 * live = storage for live or %NULL 910 * minLatency = the storage for the min latency or %NULL 911 * maxLatency = the storage for the max latency or %NULL 912 */ 913 public void parseLatency(out bool live, out GstClockTime minLatency, out GstClockTime maxLatency) 914 { 915 int outlive; 916 917 gst_query_parse_latency(gstQuery, &outlive, &minLatency, &maxLatency); 918 919 live = (outlive == 1); 920 } 921 922 /** 923 * Parse the number of formats in the formats @query. 924 * 925 * Params: 926 * nFormats = the number of formats in this query. 927 */ 928 public void parseNFormats(out uint nFormats) 929 { 930 gst_query_parse_n_formats(gstQuery, &nFormats); 931 } 932 933 /** 934 * Parse an available query and get the metadata API 935 * at @index of the metadata API array. 936 * 937 * Params: 938 * index = position in the metadata API array to read 939 * params = API specific parameters 940 * 941 * Returns: a #GType of the metadata API at @index. 942 */ 943 public GType parseNthAllocationMeta(uint index, out Structure params) 944 { 945 GstStructure* outparams = null; 946 947 auto __p = gst_query_parse_nth_allocation_meta(gstQuery, index, &outparams); 948 949 params = ObjectG.getDObject!(Structure)(outparams); 950 951 return __p; 952 } 953 954 /** 955 * Parse an available query and get the allocator and its params 956 * at @index of the allocator array. 957 * 958 * Params: 959 * index = position in the allocator array to read 960 * allocator = variable to hold the result 961 * params = parameters for the allocator 962 */ 963 public void parseNthAllocationParam(uint index, out Allocator allocator, out AllocationParams params) 964 { 965 GstAllocator* outallocator = null; 966 GstAllocationParams* outparams = sliceNew!GstAllocationParams(); 967 968 gst_query_parse_nth_allocation_param(gstQuery, index, &outallocator, outparams); 969 970 allocator = ObjectG.getDObject!(Allocator)(outallocator); 971 params = ObjectG.getDObject!(AllocationParams)(outparams, true); 972 } 973 974 /** 975 * Get the pool parameters in @query. 976 * 977 * Unref @pool with gst_object_unref() when it's not needed any more. 978 * 979 * Params: 980 * index = index to parse 981 * pool = the #GstBufferPool 982 * size = the buffer size 983 * minBuffers = the min buffers 984 * maxBuffers = the max buffers 985 */ 986 public void parseNthAllocationPool(uint index, out BufferPool pool, out uint size, out uint minBuffers, out uint maxBuffers) 987 { 988 GstBufferPool* outpool = null; 989 990 gst_query_parse_nth_allocation_pool(gstQuery, index, &outpool, &size, &minBuffers, &maxBuffers); 991 992 pool = ObjectG.getDObject!(BufferPool)(outpool); 993 } 994 995 /** 996 * Parse an available query and get the start and stop values stored 997 * at the @index of the buffered ranges array. 998 * 999 * Params: 1000 * index = position in the buffered-ranges array to read 1001 * start = the start position to set, or %NULL 1002 * stop = the stop position to set, or %NULL 1003 * 1004 * Returns: a #gboolean indicating if the parsing succeeded. 1005 */ 1006 public bool parseNthBufferingRange(uint index, out long start, out long stop) 1007 { 1008 return gst_query_parse_nth_buffering_range(gstQuery, index, &start, &stop) != 0; 1009 } 1010 1011 /** 1012 * Parse the format query and retrieve the @nth format from it into 1013 * @format. If the list contains less elements than @nth, @format will be 1014 * set to GST_FORMAT_UNDEFINED. 1015 * 1016 * Params: 1017 * nth = the nth format to retrieve. 1018 * format = a pointer to store the nth format 1019 */ 1020 public void parseNthFormat(uint nth, out GstFormat format) 1021 { 1022 gst_query_parse_nth_format(gstQuery, nth, &format); 1023 } 1024 1025 /** 1026 * Parse an available query and get the scheduling mode 1027 * at @index of the scheduling modes array. 1028 * 1029 * Params: 1030 * index = position in the scheduling modes array to read 1031 * 1032 * Returns: a #GstPadMode of the scheduling mode at @index. 1033 */ 1034 public GstPadMode parseNthSchedulingMode(uint index) 1035 { 1036 return gst_query_parse_nth_scheduling_mode(gstQuery, index); 1037 } 1038 1039 /** 1040 * Parse a position query, writing the format into @format, and the position 1041 * into @cur, if the respective parameters are non-%NULL. 1042 * 1043 * Params: 1044 * format = the storage for the #GstFormat of the 1045 * position values (may be %NULL) 1046 * cur = the storage for the current position (may be %NULL) 1047 */ 1048 public void parsePosition(out GstFormat format, out long cur) 1049 { 1050 gst_query_parse_position(gstQuery, &format, &cur); 1051 } 1052 1053 /** 1054 * Set the scheduling properties. 1055 * 1056 * Params: 1057 * flags = #GstSchedulingFlags 1058 * minsize = the suggested minimum size of pull requests 1059 * maxsize = the suggested maximum size of pull requests: 1060 * align_ = the suggested alignment of pull requests 1061 */ 1062 public void parseScheduling(out GstSchedulingFlags flags, out int minsize, out int maxsize, out int align_) 1063 { 1064 gst_query_parse_scheduling(gstQuery, &flags, &minsize, &maxsize, &align_); 1065 } 1066 1067 /** 1068 * Parse a seeking query, writing the format into @format, and 1069 * other results into the passed parameters, if the respective parameters 1070 * are non-%NULL 1071 * 1072 * Params: 1073 * format = the format to set for the @segment_start 1074 * and @segment_end values, or %NULL 1075 * seekable = the seekable flag to set, or %NULL 1076 * segmentStart = the segment_start to set, or %NULL 1077 * segmentEnd = the segment_end to set, or %NULL 1078 */ 1079 public void parseSeeking(out GstFormat format, out bool seekable, out long segmentStart, out long segmentEnd) 1080 { 1081 int outseekable; 1082 1083 gst_query_parse_seeking(gstQuery, &format, &outseekable, &segmentStart, &segmentEnd); 1084 1085 seekable = (outseekable == 1); 1086 } 1087 1088 /** 1089 * Parse a segment query answer. Any of @rate, @format, @start_value, and 1090 * @stop_value may be %NULL, which will cause this value to be omitted. 1091 * 1092 * See gst_query_set_segment() for an explanation of the function arguments. 1093 * 1094 * Params: 1095 * rate = the storage for the rate of the segment, or %NULL 1096 * format = the storage for the #GstFormat of the values, 1097 * or %NULL 1098 * startValue = the storage for the start value, or %NULL 1099 * stopValue = the storage for the stop value, or %NULL 1100 */ 1101 public void parseSegment(out double rate, out GstFormat format, out long startValue, out long stopValue) 1102 { 1103 gst_query_parse_segment(gstQuery, &rate, &format, &startValue, &stopValue); 1104 } 1105 1106 /** 1107 * Parse an URI query, writing the URI into @uri as a newly 1108 * allocated string, if the respective parameters are non-%NULL. 1109 * Free the string with g_free() after usage. 1110 * 1111 * Params: 1112 * uri = the storage for the current URI 1113 * (may be %NULL) 1114 */ 1115 public void parseUri(out string uri) 1116 { 1117 char* outuri = null; 1118 1119 gst_query_parse_uri(gstQuery, &outuri); 1120 1121 uri = Str.toString(outuri); 1122 } 1123 1124 /** 1125 * Parse an URI query, writing the URI into @uri as a newly 1126 * allocated string, if the respective parameters are non-%NULL. 1127 * Free the string with g_free() after usage. 1128 * 1129 * Params: 1130 * uri = the storage for the redirect URI 1131 * (may be %NULL) 1132 * 1133 * Since: 1.2 1134 */ 1135 public void parseUriRedirection(out string uri) 1136 { 1137 char* outuri = null; 1138 1139 gst_query_parse_uri_redirection(gstQuery, &outuri); 1140 1141 uri = Str.toString(outuri); 1142 } 1143 1144 /** 1145 * Parse an URI query, and set @permanent to %TRUE if there is a redirection 1146 * and it should be considered permanent. If a redirection is permanent, 1147 * applications should update their internal storage of the URI, otherwise 1148 * they should make all future requests to the original URI. 1149 * 1150 * Params: 1151 * permanent = if the URI redirection is permanent 1152 * (may be %NULL) 1153 * 1154 * Since: 1.4 1155 */ 1156 public void parseUriRedirectionPermanent(out bool permanent) 1157 { 1158 int outpermanent; 1159 1160 gst_query_parse_uri_redirection_permanent(gstQuery, &outpermanent); 1161 1162 permanent = (outpermanent == 1); 1163 } 1164 1165 /** 1166 * Remove the metadata API at @index of the metadata API array. 1167 * 1168 * Params: 1169 * index = position in the metadata API array to remove 1170 */ 1171 public void removeNthAllocationMeta(uint index) 1172 { 1173 gst_query_remove_nth_allocation_meta(gstQuery, index); 1174 } 1175 1176 /** 1177 * Remove the allocation param at @index of the allocation param array. 1178 * 1179 * Params: 1180 * index = position in the allocation param array to remove 1181 * 1182 * Since: 1.2 1183 */ 1184 public void removeNthAllocationParam(uint index) 1185 { 1186 gst_query_remove_nth_allocation_param(gstQuery, index); 1187 } 1188 1189 /** 1190 * Remove the allocation pool at @index of the allocation pool array. 1191 * 1192 * Params: 1193 * index = position in the allocation pool array to remove 1194 * 1195 * Since: 1.2 1196 */ 1197 public void removeNthAllocationPool(uint index) 1198 { 1199 gst_query_remove_nth_allocation_pool(gstQuery, index); 1200 } 1201 1202 /** 1203 * Set @result as the result for the @query. 1204 * 1205 * Params: 1206 * result = the result to set 1207 */ 1208 public void setAcceptCapsResult(bool result) 1209 { 1210 gst_query_set_accept_caps_result(gstQuery, result); 1211 } 1212 1213 /** 1214 * Set the results of a bitrate query. The nominal bitrate is the average 1215 * bitrate expected over the length of the stream as advertised in file 1216 * headers (or similar). 1217 * 1218 * Params: 1219 * nominalBitrate = the nominal bitrate in bits per second 1220 * 1221 * Since: 1.16 1222 */ 1223 public void setBitrate(uint nominalBitrate) 1224 { 1225 gst_query_set_bitrate(gstQuery, nominalBitrate); 1226 } 1227 1228 /** 1229 * Set the percentage of buffered data. This is a value between 0 and 100. 1230 * The @busy indicator is %TRUE when the buffering is in progress. 1231 * 1232 * Params: 1233 * busy = if buffering is busy 1234 * percent = a buffering percent 1235 */ 1236 public void setBufferingPercent(bool busy, int percent) 1237 { 1238 gst_query_set_buffering_percent(gstQuery, busy, percent); 1239 } 1240 1241 /** 1242 * Set the available query result fields in @query. 1243 * 1244 * Params: 1245 * format = the format to set for the @start and @stop values 1246 * start = the start to set 1247 * stop = the stop to set 1248 * estimatedTotal = estimated total amount of download time remaining in 1249 * milliseconds 1250 */ 1251 public void setBufferingRange(GstFormat format, long start, long stop, long estimatedTotal) 1252 { 1253 gst_query_set_buffering_range(gstQuery, format, start, stop, estimatedTotal); 1254 } 1255 1256 /** 1257 * Configures the buffering stats values in @query. 1258 * 1259 * Params: 1260 * mode = a buffering mode 1261 * avgIn = the average input rate 1262 * avgOut = the average output rate 1263 * bufferingLeft = amount of buffering time left in milliseconds 1264 */ 1265 public void setBufferingStats(GstBufferingMode mode, int avgIn, int avgOut, long bufferingLeft) 1266 { 1267 gst_query_set_buffering_stats(gstQuery, mode, avgIn, avgOut, bufferingLeft); 1268 } 1269 1270 /** 1271 * Set the @caps result in @query. 1272 * 1273 * Params: 1274 * caps = A pointer to the caps 1275 */ 1276 public void setCapsResult(Caps caps) 1277 { 1278 gst_query_set_caps_result(gstQuery, (caps is null) ? null : caps.getCapsStruct()); 1279 } 1280 1281 /** 1282 * Answer a context query by setting the requested context. 1283 * 1284 * Params: 1285 * context = the requested #GstContext 1286 * 1287 * Since: 1.2 1288 */ 1289 public void setContext(Context context) 1290 { 1291 gst_query_set_context(gstQuery, (context is null) ? null : context.getContextStruct()); 1292 } 1293 1294 /** 1295 * Answer a convert query by setting the requested values. 1296 * 1297 * Params: 1298 * srcFormat = the source #GstFormat 1299 * srcValue = the source value 1300 * destFormat = the destination #GstFormat 1301 * destValue = the destination value 1302 */ 1303 public void setConvert(GstFormat srcFormat, long srcValue, GstFormat destFormat, long destValue) 1304 { 1305 gst_query_set_convert(gstQuery, srcFormat, srcValue, destFormat, destValue); 1306 } 1307 1308 /** 1309 * Answer a duration query by setting the requested value in the given format. 1310 * 1311 * Params: 1312 * format = the #GstFormat for the duration 1313 * duration = the duration of the stream 1314 */ 1315 public void setDuration(GstFormat format, long duration) 1316 { 1317 gst_query_set_duration(gstQuery, format, duration); 1318 } 1319 1320 /** 1321 * Set the formats query result fields in @query. The number of formats passed 1322 * in the @formats array must be equal to @n_formats. 1323 * 1324 * Params: 1325 * formats = an array containing @n_formats 1326 * @GstFormat values. 1327 */ 1328 public void setFormatsv(GstFormat[] formats) 1329 { 1330 gst_query_set_formatsv(gstQuery, cast(int)formats.length, formats.ptr); 1331 } 1332 1333 /** 1334 * Answer a latency query by setting the requested values in the given format. 1335 * 1336 * Params: 1337 * live = if there is a live element upstream 1338 * minLatency = the minimal latency of the upstream elements 1339 * maxLatency = the maximal latency of the upstream elements 1340 */ 1341 public void setLatency(bool live, GstClockTime minLatency, GstClockTime maxLatency) 1342 { 1343 gst_query_set_latency(gstQuery, live, minLatency, maxLatency); 1344 } 1345 1346 /** 1347 * Parse an available query and get the allocator and its params 1348 * at @index of the allocator array. 1349 * 1350 * Params: 1351 * index = position in the allocator array to set 1352 * allocator = new allocator to set 1353 * params = parameters for the allocator 1354 */ 1355 public void setNthAllocationParam(uint index, Allocator allocator, AllocationParams params) 1356 { 1357 gst_query_set_nth_allocation_param(gstQuery, index, (allocator is null) ? null : allocator.getAllocatorStruct(), (params is null) ? null : params.getAllocationParamsStruct()); 1358 } 1359 1360 /** 1361 * Set the pool parameters in @query. 1362 * 1363 * Params: 1364 * index = index to modify 1365 * pool = the #GstBufferPool 1366 * size = the buffer size 1367 * minBuffers = the min buffers 1368 * maxBuffers = the max buffers 1369 */ 1370 public void setNthAllocationPool(uint index, BufferPool pool, uint size, uint minBuffers, uint maxBuffers) 1371 { 1372 gst_query_set_nth_allocation_pool(gstQuery, index, (pool is null) ? null : pool.getBufferPoolStruct(), size, minBuffers, maxBuffers); 1373 } 1374 1375 /** 1376 * Answer a position query by setting the requested value in the given format. 1377 * 1378 * Params: 1379 * format = the requested #GstFormat 1380 * cur = the position to set 1381 */ 1382 public void setPosition(GstFormat format, long cur) 1383 { 1384 gst_query_set_position(gstQuery, format, cur); 1385 } 1386 1387 /** 1388 * Set the scheduling properties. 1389 * 1390 * Params: 1391 * flags = #GstSchedulingFlags 1392 * minsize = the suggested minimum size of pull requests 1393 * maxsize = the suggested maximum size of pull requests 1394 * align_ = the suggested alignment of pull requests 1395 */ 1396 public void setScheduling(GstSchedulingFlags flags, int minsize, int maxsize, int align_) 1397 { 1398 gst_query_set_scheduling(gstQuery, flags, minsize, maxsize, align_); 1399 } 1400 1401 /** 1402 * Set the seeking query result fields in @query. 1403 * 1404 * Params: 1405 * format = the format to set for the @segment_start and @segment_end values 1406 * seekable = the seekable flag to set 1407 * segmentStart = the segment_start to set 1408 * segmentEnd = the segment_end to set 1409 */ 1410 public void setSeeking(GstFormat format, bool seekable, long segmentStart, long segmentEnd) 1411 { 1412 gst_query_set_seeking(gstQuery, format, seekable, segmentStart, segmentEnd); 1413 } 1414 1415 /** 1416 * Answer a segment query by setting the requested values. The normal 1417 * playback segment of a pipeline is 0 to duration at the default rate of 1418 * 1.0. If a seek was performed on the pipeline to play a different 1419 * segment, this query will return the range specified in the last seek. 1420 * 1421 * @start_value and @stop_value will respectively contain the configured 1422 * playback range start and stop values expressed in @format. 1423 * The values are always between 0 and the duration of the media and 1424 * @start_value <= @stop_value. @rate will contain the playback rate. For 1425 * negative rates, playback will actually happen from @stop_value to 1426 * @start_value. 1427 * 1428 * Params: 1429 * rate = the rate of the segment 1430 * format = the #GstFormat of the segment values (@start_value and @stop_value) 1431 * startValue = the start value 1432 * stopValue = the stop value 1433 */ 1434 public void setSegment(double rate, GstFormat format, long startValue, long stopValue) 1435 { 1436 gst_query_set_segment(gstQuery, rate, format, startValue, stopValue); 1437 } 1438 1439 /** 1440 * Answer a URI query by setting the requested URI. 1441 * 1442 * Params: 1443 * uri = the URI to set 1444 */ 1445 public void setUri(string uri) 1446 { 1447 gst_query_set_uri(gstQuery, Str.toStringz(uri)); 1448 } 1449 1450 /** 1451 * Answer a URI query by setting the requested URI redirection. 1452 * 1453 * Params: 1454 * uri = the URI to set 1455 * 1456 * Since: 1.2 1457 */ 1458 public void setUriRedirection(string uri) 1459 { 1460 gst_query_set_uri_redirection(gstQuery, Str.toStringz(uri)); 1461 } 1462 1463 /** 1464 * Answer a URI query by setting the requested URI redirection 1465 * to permanent or not. 1466 * 1467 * Params: 1468 * permanent = whether the redirect is permanent or not 1469 * 1470 * Since: 1.4 1471 */ 1472 public void setUriRedirectionPermanent(bool permanent) 1473 { 1474 gst_query_set_uri_redirection_permanent(gstQuery, permanent); 1475 } 1476 1477 /** 1478 * Get the structure of a query. This method should be called with a writable 1479 * @query so that the returned structure is guaranteed to be writable. 1480 * 1481 * Returns: the #GstStructure of the query. The structure is 1482 * still owned by the query and will therefore be freed when the query 1483 * is unreffed. 1484 */ 1485 public Structure writableStructure() 1486 { 1487 auto __p = gst_query_writable_structure(gstQuery); 1488 1489 if(__p is null) 1490 { 1491 return null; 1492 } 1493 1494 return ObjectG.getDObject!(Structure)(cast(GstStructure*) __p); 1495 } 1496 1497 /** 1498 * Gets the #GstQueryTypeFlags associated with @type. 1499 * 1500 * Params: 1501 * type = a #GstQueryType 1502 * 1503 * Returns: a #GstQueryTypeFlags. 1504 */ 1505 public static GstQueryTypeFlags typeGetFlags(GstQueryType type) 1506 { 1507 return gst_query_type_get_flags(type); 1508 } 1509 1510 /** 1511 * Get a printable name for the given query type. Do not modify or free. 1512 * 1513 * Params: 1514 * type = the query type 1515 * 1516 * Returns: a reference to the static name of the query. 1517 */ 1518 public static string typeGetName(GstQueryType type) 1519 { 1520 return Str.toString(gst_query_type_get_name(type)); 1521 } 1522 1523 /** 1524 * Get the unique quark for the given query type. 1525 * 1526 * Params: 1527 * type = the query type 1528 * 1529 * Returns: the quark associated with the query type 1530 */ 1531 public static GQuark typeToQuark(GstQueryType type) 1532 { 1533 return gst_query_type_to_quark(type); 1534 } 1535 }