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