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