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