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 buffer 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 * Pool details can be retrieved using gst_query_get_n_allocation_pools() and 699 * gst_query_parse_nth_allocation_pool(). 700 * 701 * Params: 702 * caps = The #GstCaps 703 * needPool = Whether a #GstBufferPool is needed 704 */ 705 public void parseAllocation(out Caps caps, out bool needPool) 706 { 707 GstCaps* outcaps = null; 708 int outneedPool; 709 710 gst_query_parse_allocation(gstQuery, &outcaps, &outneedPool); 711 712 caps = ObjectG.getDObject!(Caps)(outcaps); 713 needPool = (outneedPool == 1); 714 } 715 716 /** 717 * Get the percentage of buffered data. This is a value between 0 and 100. 718 * The @busy indicator is %TRUE when the buffering is in progress. 719 * 720 * Params: 721 * busy = if buffering is busy, or %NULL 722 * percent = a buffering percent, or %NULL 723 */ 724 public void parseBufferingPercent(out bool busy, out int percent) 725 { 726 int outbusy; 727 728 gst_query_parse_buffering_percent(gstQuery, &outbusy, &percent); 729 730 busy = (outbusy == 1); 731 } 732 733 /** 734 * Parse an available query, writing the format into @format, and 735 * other results into the passed parameters, if the respective parameters 736 * are non-%NULL 737 * 738 * Params: 739 * format = the format to set for the @segment_start 740 * and @segment_end values, or %NULL 741 * start = the start to set, or %NULL 742 * stop = the stop to set, or %NULL 743 * estimatedTotal = estimated total amount of download 744 * time remaining in milliseconds, or %NULL 745 */ 746 public void parseBufferingRange(out GstFormat format, out long start, out long stop, out long estimatedTotal) 747 { 748 gst_query_parse_buffering_range(gstQuery, &format, &start, &stop, &estimatedTotal); 749 } 750 751 /** 752 * Extracts the buffering stats values from @query. 753 * 754 * Params: 755 * mode = a buffering mode, or %NULL 756 * avgIn = the average input rate, or %NULL 757 * avgOut = the average output rat, or %NULL 758 * bufferingLeft = amount of buffering time left in 759 * milliseconds, or %NULL 760 */ 761 public void parseBufferingStats(out GstBufferingMode mode, out int avgIn, out int avgOut, out long bufferingLeft) 762 { 763 gst_query_parse_buffering_stats(gstQuery, &mode, &avgIn, &avgOut, &bufferingLeft); 764 } 765 766 /** 767 * Get the filter from the caps @query. The caps remains valid as long as 768 * @query remains valid. 769 * 770 * Params: 771 * filter = A pointer to the caps filter 772 */ 773 public void parseCaps(out Caps filter) 774 { 775 GstCaps* outfilter = null; 776 777 gst_query_parse_caps(gstQuery, &outfilter); 778 779 filter = ObjectG.getDObject!(Caps)(outfilter); 780 } 781 782 /** 783 * Get the caps result from @query. The caps remains valid as long as 784 * @query remains valid. 785 * 786 * Params: 787 * caps = A pointer to the caps 788 */ 789 public void parseCapsResult(out Caps caps) 790 { 791 GstCaps* outcaps = null; 792 793 gst_query_parse_caps_result(gstQuery, &outcaps); 794 795 caps = ObjectG.getDObject!(Caps)(outcaps); 796 } 797 798 /** 799 * Get the context from the context @query. The context remains valid as long as 800 * @query remains valid. 801 * 802 * Params: 803 * context = A pointer to store the #GstContext 804 * 805 * Since: 1.2 806 */ 807 public void parseContext(out Context context) 808 { 809 GstContext* outcontext = null; 810 811 gst_query_parse_context(gstQuery, &outcontext); 812 813 context = ObjectG.getDObject!(Context)(outcontext); 814 } 815 816 /** 817 * Parse a context type from an existing GST_QUERY_CONTEXT query. 818 * 819 * Params: 820 * contextType = the context type, or %NULL 821 * 822 * Return: a #gboolean indicating if the parsing succeeded. 823 * 824 * Since: 1.2 825 */ 826 public bool parseContextType(out string contextType) 827 { 828 char* outcontextType = null; 829 830 auto p = gst_query_parse_context_type(gstQuery, &outcontextType) != 0; 831 832 contextType = Str.toString(outcontextType); 833 834 return p; 835 } 836 837 /** 838 * Parse a convert query answer. Any of @src_format, @src_value, @dest_format, 839 * and @dest_value may be %NULL, in which case that value is omitted. 840 * 841 * Params: 842 * srcFormat = the storage for the #GstFormat of the 843 * source value, or %NULL 844 * srcValue = the storage for the source value, or %NULL 845 * destFormat = the storage for the #GstFormat of the 846 * destination value, or %NULL 847 * destValue = the storage for the destination value, 848 * or %NULL 849 */ 850 public void parseConvert(out GstFormat srcFormat, out long srcValue, out GstFormat destFormat, out long destValue) 851 { 852 gst_query_parse_convert(gstQuery, &srcFormat, &srcValue, &destFormat, &destValue); 853 } 854 855 /** 856 * Parse a duration query answer. Write the format of the duration into @format, 857 * and the value into @duration, if the respective variables are non-%NULL. 858 * 859 * Params: 860 * format = the storage for the #GstFormat of the duration 861 * value, or %NULL. 862 * duration = the storage for the total duration, or %NULL. 863 */ 864 public void parseDuration(out GstFormat format, out long duration) 865 { 866 gst_query_parse_duration(gstQuery, &format, &duration); 867 } 868 869 /** 870 * Parse a latency query answer. 871 * 872 * Params: 873 * live = storage for live or %NULL 874 * minLatency = the storage for the min latency or %NULL 875 * maxLatency = the storage for the max latency or %NULL 876 */ 877 public void parseLatency(out bool live, out GstClockTime minLatency, out GstClockTime maxLatency) 878 { 879 int outlive; 880 881 gst_query_parse_latency(gstQuery, &outlive, &minLatency, &maxLatency); 882 883 live = (outlive == 1); 884 } 885 886 /** 887 * Parse the number of formats in the formats @query. 888 * 889 * Params: 890 * nFormats = the number of formats in this query. 891 */ 892 public void parseNFormats(out uint nFormats) 893 { 894 gst_query_parse_n_formats(gstQuery, &nFormats); 895 } 896 897 /** 898 * Parse an available query and get the metadata API 899 * at @index of the metadata API array. 900 * 901 * Params: 902 * index = position in the metadata API array to read 903 * params = API specific parameters 904 * 905 * Return: a #GType of the metadata API at @index. 906 */ 907 public GType parseNthAllocationMeta(uint index, out Structure params) 908 { 909 GstStructure* outparams = null; 910 911 auto p = gst_query_parse_nth_allocation_meta(gstQuery, index, &outparams); 912 913 params = ObjectG.getDObject!(Structure)(outparams); 914 915 return p; 916 } 917 918 /** 919 * Parse an available query and get the allocator and its params 920 * at @index of the allocator array. 921 * 922 * Params: 923 * index = position in the allocator array to read 924 * allocator = variable to hold the result 925 * params = parameters for the allocator 926 */ 927 public void parseNthAllocationParam(uint index, out Allocator allocator, out AllocationParams params) 928 { 929 GstAllocator* outallocator = null; 930 GstAllocationParams* outparams = gMalloc!GstAllocationParams(); 931 932 gst_query_parse_nth_allocation_param(gstQuery, index, &outallocator, outparams); 933 934 allocator = ObjectG.getDObject!(Allocator)(outallocator); 935 params = ObjectG.getDObject!(AllocationParams)(outparams, true); 936 } 937 938 /** 939 * Get the pool parameters in @query. 940 * 941 * Unref @pool with gst_object_unref() when it's not needed any more. 942 * 943 * Params: 944 * index = index to parse 945 * pool = the #GstBufferPool 946 * size = the buffer size 947 * minBuffers = the min buffers 948 * maxBuffers = the max buffers 949 */ 950 public void parseNthAllocationPool(uint index, out BufferPool pool, out uint size, out uint minBuffers, out uint maxBuffers) 951 { 952 GstBufferPool* outpool = null; 953 954 gst_query_parse_nth_allocation_pool(gstQuery, index, &outpool, &size, &minBuffers, &maxBuffers); 955 956 pool = ObjectG.getDObject!(BufferPool)(outpool); 957 } 958 959 /** 960 * Parse an available query and get the start and stop values stored 961 * at the @index of the buffered ranges array. 962 * 963 * Params: 964 * index = position in the buffered-ranges array to read 965 * start = the start position to set, or %NULL 966 * stop = the stop position to set, or %NULL 967 * 968 * Return: a #gboolean indicating if the parsing succeeded. 969 */ 970 public bool parseNthBufferingRange(uint index, out long start, out long stop) 971 { 972 return gst_query_parse_nth_buffering_range(gstQuery, index, &start, &stop) != 0; 973 } 974 975 /** 976 * Parse the format query and retrieve the @nth format from it into 977 * @format. If the list contains less elements than @nth, @format will be 978 * set to GST_FORMAT_UNDEFINED. 979 * 980 * Params: 981 * nth = the nth format to retrieve. 982 * format = a pointer to store the nth format 983 */ 984 public void parseNthFormat(uint nth, out GstFormat format) 985 { 986 gst_query_parse_nth_format(gstQuery, nth, &format); 987 } 988 989 /** 990 * Parse an available query and get the scheduling mode 991 * at @index of the scheduling modes array. 992 * 993 * Params: 994 * index = position in the scheduling modes array to read 995 * 996 * Return: a #GstPadMode of the scheduling mode at @index. 997 */ 998 public GstPadMode parseNthSchedulingMode(uint index) 999 { 1000 return gst_query_parse_nth_scheduling_mode(gstQuery, index); 1001 } 1002 1003 /** 1004 * Parse a position query, writing the format into @format, and the position 1005 * into @cur, if the respective parameters are non-%NULL. 1006 * 1007 * Params: 1008 * format = the storage for the #GstFormat of the 1009 * position values (may be %NULL) 1010 * cur = the storage for the current position (may be %NULL) 1011 */ 1012 public void parsePosition(out GstFormat format, out long cur) 1013 { 1014 gst_query_parse_position(gstQuery, &format, &cur); 1015 } 1016 1017 /** 1018 * Set the scheduling properties. 1019 * 1020 * Params: 1021 * flags = #GstSchedulingFlags 1022 * minsize = the suggested minimum size of pull requests 1023 * maxsize = the suggested maximum size of pull requests: 1024 * alig = the suggested alignment of pull requests 1025 */ 1026 public void parseScheduling(out GstSchedulingFlags flags, out int minsize, out int maxsize, out int alig) 1027 { 1028 gst_query_parse_scheduling(gstQuery, &flags, &minsize, &maxsize, &alig); 1029 } 1030 1031 /** 1032 * Parse a seeking query, writing the format into @format, and 1033 * other results into the passed parameters, if the respective parameters 1034 * are non-%NULL 1035 * 1036 * Params: 1037 * format = the format to set for the @segment_start 1038 * and @segment_end values, or %NULL 1039 * seekable = the seekable flag to set, or %NULL 1040 * segmentStart = the segment_start to set, or %NULL 1041 * segmentEnd = the segment_end to set, or %NULL 1042 */ 1043 public void parseSeeking(out GstFormat format, out bool seekable, out long segmentStart, out long segmentEnd) 1044 { 1045 int outseekable; 1046 1047 gst_query_parse_seeking(gstQuery, &format, &outseekable, &segmentStart, &segmentEnd); 1048 1049 seekable = (outseekable == 1); 1050 } 1051 1052 /** 1053 * Parse a segment query answer. Any of @rate, @format, @start_value, and 1054 * @stop_value may be %NULL, which will cause this value to be omitted. 1055 * 1056 * See gst_query_set_segment() for an explanation of the function arguments. 1057 * 1058 * Params: 1059 * rate = the storage for the rate of the segment, or %NULL 1060 * format = the storage for the #GstFormat of the values, 1061 * or %NULL 1062 * startValue = the storage for the start value, or %NULL 1063 * stopValue = the storage for the stop value, or %NULL 1064 */ 1065 public void parseSegment(out double rate, out GstFormat format, out long startValue, out long stopValue) 1066 { 1067 gst_query_parse_segment(gstQuery, &rate, &format, &startValue, &stopValue); 1068 } 1069 1070 /** 1071 * Parse an URI query, writing the URI into @uri as a newly 1072 * allocated string, if the respective parameters are non-%NULL. 1073 * Free the string with g_free() after usage. 1074 * 1075 * Params: 1076 * uri = the storage for the current URI 1077 * (may be %NULL) 1078 */ 1079 public void parseUri(out string uri) 1080 { 1081 char* outuri = null; 1082 1083 gst_query_parse_uri(gstQuery, &outuri); 1084 1085 uri = Str.toString(outuri); 1086 } 1087 1088 /** 1089 * Parse an URI query, writing the URI into @uri as a newly 1090 * allocated string, if the respective parameters are non-%NULL. 1091 * Free the string with g_free() after usage. 1092 * 1093 * Params: 1094 * uri = the storage for the redirect URI 1095 * (may be %NULL) 1096 * 1097 * Since: 1.2 1098 */ 1099 public void parseUriRedirection(out string uri) 1100 { 1101 char* outuri = null; 1102 1103 gst_query_parse_uri_redirection(gstQuery, &outuri); 1104 1105 uri = Str.toString(outuri); 1106 } 1107 1108 /** 1109 * Parse an URI query, and set @permanent to %TRUE if there is a redirection 1110 * and it should be considered permanent. If a redirection is permanent, 1111 * applications should update their internal storage of the URI, otherwise 1112 * they should make all future requests to the original URI. 1113 * 1114 * Params: 1115 * permanent = if the URI redirection is permanent 1116 * (may be %NULL) 1117 * 1118 * Since: 1.4 1119 */ 1120 public void parseUriRedirectionPermanent(out bool permanent) 1121 { 1122 int outpermanent; 1123 1124 gst_query_parse_uri_redirection_permanent(gstQuery, &outpermanent); 1125 1126 permanent = (outpermanent == 1); 1127 } 1128 1129 /** 1130 * Remove the metadata API at @index of the metadata API array. 1131 * 1132 * Params: 1133 * index = position in the metadata API array to remove 1134 */ 1135 public void removeNthAllocationMeta(uint index) 1136 { 1137 gst_query_remove_nth_allocation_meta(gstQuery, index); 1138 } 1139 1140 /** 1141 * Remove the allocation param at @index of the allocation param array. 1142 * 1143 * Params: 1144 * index = position in the allocation param array to remove 1145 * 1146 * Since: 1.2 1147 */ 1148 public void removeNthAllocationParam(uint index) 1149 { 1150 gst_query_remove_nth_allocation_param(gstQuery, index); 1151 } 1152 1153 /** 1154 * Remove the allocation pool at @index of the allocation pool array. 1155 * 1156 * Params: 1157 * index = position in the allocation pool array to remove 1158 * 1159 * Since: 1.2 1160 */ 1161 public void removeNthAllocationPool(uint index) 1162 { 1163 gst_query_remove_nth_allocation_pool(gstQuery, index); 1164 } 1165 1166 /** 1167 * Set @result as the result for the @query. 1168 * 1169 * Params: 1170 * result = the result to set 1171 */ 1172 public void setAcceptCapsResult(bool result) 1173 { 1174 gst_query_set_accept_caps_result(gstQuery, result); 1175 } 1176 1177 /** 1178 * Set the percentage of buffered data. This is a value between 0 and 100. 1179 * The @busy indicator is %TRUE when the buffering is in progress. 1180 * 1181 * Params: 1182 * busy = if buffering is busy 1183 * percent = a buffering percent 1184 */ 1185 public void setBufferingPercent(bool busy, int percent) 1186 { 1187 gst_query_set_buffering_percent(gstQuery, busy, percent); 1188 } 1189 1190 /** 1191 * Set the available query result fields in @query. 1192 * 1193 * Params: 1194 * format = the format to set for the @start and @stop values 1195 * start = the start to set 1196 * stop = the stop to set 1197 * estimatedTotal = estimated total amount of download time remaining in 1198 * milliseconds 1199 */ 1200 public void setBufferingRange(GstFormat format, long start, long stop, long estimatedTotal) 1201 { 1202 gst_query_set_buffering_range(gstQuery, format, start, stop, estimatedTotal); 1203 } 1204 1205 /** 1206 * Configures the buffering stats values in @query. 1207 * 1208 * Params: 1209 * mode = a buffering mode 1210 * avgIn = the average input rate 1211 * avgOut = the average output rate 1212 * bufferingLeft = amount of buffering time left in milliseconds 1213 */ 1214 public void setBufferingStats(GstBufferingMode mode, int avgIn, int avgOut, long bufferingLeft) 1215 { 1216 gst_query_set_buffering_stats(gstQuery, mode, avgIn, avgOut, bufferingLeft); 1217 } 1218 1219 /** 1220 * Set the @caps result in @query. 1221 * 1222 * Params: 1223 * caps = A pointer to the caps 1224 */ 1225 public void setCapsResult(Caps caps) 1226 { 1227 gst_query_set_caps_result(gstQuery, (caps is null) ? null : caps.getCapsStruct()); 1228 } 1229 1230 /** 1231 * Answer a context query by setting the requested context. 1232 * 1233 * Params: 1234 * context = the requested #GstContext 1235 * 1236 * Since: 1.2 1237 */ 1238 public void setContext(Context context) 1239 { 1240 gst_query_set_context(gstQuery, (context is null) ? null : context.getContextStruct()); 1241 } 1242 1243 /** 1244 * Answer a convert query by setting the requested values. 1245 * 1246 * Params: 1247 * srcFormat = the source #GstFormat 1248 * srcValue = the source value 1249 * destFormat = the destination #GstFormat 1250 * destValue = the destination value 1251 */ 1252 public void setConvert(GstFormat srcFormat, long srcValue, GstFormat destFormat, long destValue) 1253 { 1254 gst_query_set_convert(gstQuery, srcFormat, srcValue, destFormat, destValue); 1255 } 1256 1257 /** 1258 * Answer a duration query by setting the requested value in the given format. 1259 * 1260 * Params: 1261 * format = the #GstFormat for the duration 1262 * duration = the duration of the stream 1263 */ 1264 public void setDuration(GstFormat format, long duration) 1265 { 1266 gst_query_set_duration(gstQuery, format, duration); 1267 } 1268 1269 /** 1270 * Set the formats query result fields in @query. The number of formats passed 1271 * in the @formats array must be equal to @n_formats. 1272 * 1273 * Params: 1274 * nFormats = the number of formats to set. 1275 * formats = an array containing @n_formats 1276 * @GstFormat values. 1277 */ 1278 public void setFormatsv(GstFormat[] formats) 1279 { 1280 gst_query_set_formatsv(gstQuery, cast(int)formats.length, formats.ptr); 1281 } 1282 1283 /** 1284 * Answer a latency query by setting the requested values in the given format. 1285 * 1286 * Params: 1287 * live = if there is a live element upstream 1288 * minLatency = the minimal latency of the upstream elements 1289 * maxLatency = the maximal latency of the upstream elements 1290 */ 1291 public void setLatency(bool live, GstClockTime minLatency, GstClockTime maxLatency) 1292 { 1293 gst_query_set_latency(gstQuery, live, minLatency, maxLatency); 1294 } 1295 1296 /** 1297 * Parse an available query and get the allocator and its params 1298 * at @index of the allocator array. 1299 * 1300 * Params: 1301 * index = position in the allocator array to set 1302 * allocator = new allocator to set 1303 * params = parameters for the allocator 1304 */ 1305 public void setNthAllocationParam(uint index, Allocator allocator, AllocationParams params) 1306 { 1307 gst_query_set_nth_allocation_param(gstQuery, index, (allocator is null) ? null : allocator.getAllocatorStruct(), (params is null) ? null : params.getAllocationParamsStruct()); 1308 } 1309 1310 /** 1311 * Set the pool parameters in @query. 1312 * 1313 * Params: 1314 * index = index to modify 1315 * pool = the #GstBufferPool 1316 * size = the size 1317 * minBuffers = the min buffers 1318 * maxBuffers = the max buffers 1319 */ 1320 public void setNthAllocationPool(uint index, BufferPool pool, uint size, uint minBuffers, uint maxBuffers) 1321 { 1322 gst_query_set_nth_allocation_pool(gstQuery, index, (pool is null) ? null : pool.getBufferPoolStruct(), size, minBuffers, maxBuffers); 1323 } 1324 1325 /** 1326 * Answer a position query by setting the requested value in the given format. 1327 * 1328 * Params: 1329 * format = the requested #GstFormat 1330 * cur = the position to set 1331 */ 1332 public void setPosition(GstFormat format, long cur) 1333 { 1334 gst_query_set_position(gstQuery, format, cur); 1335 } 1336 1337 /** 1338 * Set the scheduling properties. 1339 * 1340 * Params: 1341 * flags = #GstSchedulingFlags 1342 * minsize = the suggested minimum size of pull requests 1343 * maxsize = the suggested maximum size of pull requests 1344 * alig = the suggested alignment of pull requests 1345 */ 1346 public void setScheduling(GstSchedulingFlags flags, int minsize, int maxsize, int alig) 1347 { 1348 gst_query_set_scheduling(gstQuery, flags, minsize, maxsize, alig); 1349 } 1350 1351 /** 1352 * Set the seeking query result fields in @query. 1353 * 1354 * Params: 1355 * format = the format to set for the @segment_start and @segment_end values 1356 * seekable = the seekable flag to set 1357 * segmentStart = the segment_start to set 1358 * segmentEnd = the segment_end to set 1359 */ 1360 public void setSeeking(GstFormat format, bool seekable, long segmentStart, long segmentEnd) 1361 { 1362 gst_query_set_seeking(gstQuery, format, seekable, segmentStart, segmentEnd); 1363 } 1364 1365 /** 1366 * Answer a segment query by setting the requested values. The normal 1367 * playback segment of a pipeline is 0 to duration at the default rate of 1368 * 1.0. If a seek was performed on the pipeline to play a different 1369 * segment, this query will return the range specified in the last seek. 1370 * 1371 * @start_value and @stop_value will respectively contain the configured 1372 * playback range start and stop values expressed in @format. 1373 * The values are always between 0 and the duration of the media and 1374 * @start_value <= @stop_value. @rate will contain the playback rate. For 1375 * negative rates, playback will actually happen from @stop_value to 1376 * @start_value. 1377 * 1378 * Params: 1379 * rate = the rate of the segment 1380 * format = the #GstFormat of the segment values (@start_value and @stop_value) 1381 * startValue = the start value 1382 * stopValue = the stop value 1383 */ 1384 public void setSegment(double rate, GstFormat format, long startValue, long stopValue) 1385 { 1386 gst_query_set_segment(gstQuery, rate, format, startValue, stopValue); 1387 } 1388 1389 /** 1390 * Answer a URI query by setting the requested URI. 1391 * 1392 * Params: 1393 * uri = the URI to set 1394 */ 1395 public void setUri(string uri) 1396 { 1397 gst_query_set_uri(gstQuery, Str.toStringz(uri)); 1398 } 1399 1400 /** 1401 * Answer a URI query by setting the requested URI redirection. 1402 * 1403 * Params: 1404 * uri = the URI to set 1405 * 1406 * Since: 1.2 1407 */ 1408 public void setUriRedirection(string uri) 1409 { 1410 gst_query_set_uri_redirection(gstQuery, Str.toStringz(uri)); 1411 } 1412 1413 /** 1414 * Answer a URI query by setting the requested URI redirection 1415 * to permanent or not. 1416 * 1417 * Params: 1418 * permanent = whether the redirect is permanent or not 1419 * 1420 * Since: 1.4 1421 */ 1422 public void setUriRedirectionPermanent(bool permanent) 1423 { 1424 gst_query_set_uri_redirection_permanent(gstQuery, permanent); 1425 } 1426 1427 /** 1428 * Get the structure of a query. This method should be called with a writable 1429 * @query so that the returned structure is guaranteed to be writable. 1430 * 1431 * Return: the #GstStructure of the query. The structure is 1432 * still owned by the query and will therefore be freed when the query 1433 * is unreffed. 1434 */ 1435 public Structure writableStructure() 1436 { 1437 auto p = gst_query_writable_structure(gstQuery); 1438 1439 if(p is null) 1440 { 1441 return null; 1442 } 1443 1444 return ObjectG.getDObject!(Structure)(cast(GstStructure*) p); 1445 } 1446 1447 /** 1448 * Gets the #GstQueryTypeFlags associated with @type. 1449 * 1450 * Params: 1451 * type = a #GstQueryType 1452 * 1453 * Return: a #GstQueryTypeFlags. 1454 */ 1455 public static GstQueryTypeFlags typeGetFlags(GstQueryType type) 1456 { 1457 return gst_query_type_get_flags(type); 1458 } 1459 1460 /** 1461 * Get a printable name for the given query type. Do not modify or free. 1462 * 1463 * Params: 1464 * type = the query type 1465 * 1466 * Return: a reference to the static name of the query. 1467 */ 1468 public static string typeGetName(GstQueryType type) 1469 { 1470 return Str.toString(gst_query_type_get_name(type)); 1471 } 1472 1473 /** 1474 * Get the unique quark for the given query type. 1475 * 1476 * Params: 1477 * type = the query type 1478 * 1479 * Return: the quark associated with the query type 1480 */ 1481 public static GQuark typeToQuark(GstQueryType type) 1482 { 1483 return gst_query_type_to_quark(type); 1484 } 1485 }