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