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