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