2 * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
3 * 2000 Wim Taymans <wim.taymans@chello.be>
4 * 2005 Wim Taymans <wim@fluendo.com>
6 * gstquery.c: GstQueryType registration and Query parsing/creation
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
18 * You should have received a copy of the GNU Library General Public
19 * License along with this library; if not, write to the
20 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 * Boston, MA 02111-1307, USA.
26 * @short_description: Provide functions to create queries, and to set and parse
28 * @see_also: #GstPad, #GstElement
30 * Queries can be performed on pads (gst_pad_query()) and elements
31 * (gst_element_query()). Please note that some queries might need a running
34 * Queries can be created using the gst_query_new_*() functions.
35 * Query values can be set using gst_query_set_*(), and parsed using
36 * gst_query_parse_*() helpers.
38 * The following example shows how to query the duration of a pipeline:
41 * <title>Query duration on a pipeline</title>
45 * query = gst_query_new_duration (GST_FORMAT_TIME);
46 * res = gst_element_query (pipeline, query);
49 * gst_query_parse_duration (query, NULL, &duration);
50 * g_print ("duration = %"GST_TIME_FORMAT, GST_TIME_ARGS (duration));
53 * g_print ("duration query failed...");
55 * gst_query_unref (query);
59 * Last reviewed on 2012-03-29 (0.11.3)
63 #include "gst_private.h"
67 #include "gstenumtypes.h"
70 #include "gstbufferpool.h"
72 GST_DEBUG_CATEGORY_STATIC (gst_query_debug);
73 #define GST_CAT_DEFAULT gst_query_debug
75 static GType _gst_query_type = 0;
82 GstStructure *structure;
85 #define GST_QUERY_SLICE_SIZE(q) (((GstQueryImpl *)(q))->slice_size)
86 #define GST_QUERY_STRUCTURE(q) (((GstQueryImpl *)(q))->structure)
96 static GstQueryQuarks query_quarks[] = {
97 {GST_QUERY_UNKNOWN, "unknown", 0},
98 {GST_QUERY_POSITION, "position", 0},
99 {GST_QUERY_DURATION, "duration", 0},
100 {GST_QUERY_LATENCY, "latency", 0},
101 {GST_QUERY_JITTER, "jitter", 0},
102 {GST_QUERY_RATE, "rate", 0},
103 {GST_QUERY_SEEKING, "seeking", 0},
104 {GST_QUERY_SEGMENT, "segment", 0},
105 {GST_QUERY_CONVERT, "convert", 0},
106 {GST_QUERY_FORMATS, "formats", 0},
107 {GST_QUERY_BUFFERING, "buffering", 0},
108 {GST_QUERY_CUSTOM, "custom", 0},
109 {GST_QUERY_URI, "uri", 0},
110 {GST_QUERY_ALLOCATION, "allocation", 0},
111 {GST_QUERY_SCHEDULING, "scheduling", 0},
112 {GST_QUERY_ACCEPT_CAPS, "accept-caps", 0},
113 {GST_QUERY_CAPS, "caps", 0},
114 {GST_QUERY_DRAIN, "drain", 0},
115 {GST_QUERY_TOC, "toc", 0},
120 GST_DEFINE_MINI_OBJECT_TYPE (GstQuery, gst_query);
123 _priv_gst_query_initialize (void)
127 _gst_query_type = gst_query_get_type ();
129 GST_DEBUG_CATEGORY_INIT (gst_query_debug, "query", 0, "query system");
131 for (i = 0; query_quarks[i].name; i++) {
132 query_quarks[i].quark = g_quark_from_static_string (query_quarks[i].name);
137 * gst_query_type_get_name:
138 * @type: the query type
140 * Get a printable name for the given query type. Do not modify or free.
142 * Returns: a reference to the static name of the query.
145 gst_query_type_get_name (GstQueryType type)
149 for (i = 0; query_quarks[i].name; i++) {
150 if (type == query_quarks[i].type)
151 return query_quarks[i].name;
157 * gst_query_type_to_quark:
158 * @type: the query type
160 * Get the unique quark for the given query type.
162 * Returns: the quark associated with the query type
165 gst_query_type_to_quark (GstQueryType type)
169 for (i = 0; query_quarks[i].name; i++) {
170 if (type == query_quarks[i].type)
171 return query_quarks[i].quark;
177 * gst_query_type_get_flags:
178 * @type: a #GstQueryType
180 * Gets the #GstQueryTypeFlags associated with @type.
182 * Returns: a #GstQueryTypeFlags.
185 gst_query_type_get_flags (GstQueryType type)
187 GstQueryTypeFlags ret;
189 ret = type & ((1 << GST_QUERY_NUM_SHIFT) - 1);
195 _gst_query_free (GstQuery * query)
199 g_return_if_fail (query != NULL);
201 s = GST_QUERY_STRUCTURE (query);
203 gst_structure_set_parent_refcount (s, NULL);
204 gst_structure_free (s);
207 g_slice_free1 (GST_QUERY_SLICE_SIZE (query), query);
211 _gst_query_copy (GstQuery * query)
216 s = GST_QUERY_STRUCTURE (query);
218 s = gst_structure_copy (s);
220 copy = gst_query_new_custom (query->type, s);
226 gst_query_init (GstQueryImpl * query, gsize size, GstQueryType type)
228 gst_mini_object_init (GST_MINI_OBJECT_CAST (query), _gst_query_type);
230 query->query.mini_object.copy = (GstMiniObjectCopyFunction) _gst_query_copy;
231 query->query.mini_object.free = (GstMiniObjectFreeFunction) _gst_query_free;
233 GST_QUERY_SLICE_SIZE (query) = size;
234 GST_QUERY_TYPE (query) = type;
238 * gst_query_new_position:
239 * @format: the default #GstFormat for the new query
241 * Constructs a new query stream position query object. Use gst_query_unref()
242 * when done with it. A position query is used to query the current position
243 * of playback in the streams, in some format.
245 * Free-function: gst_query_unref
247 * Returns: (transfer full): a new #GstQuery
250 gst_query_new_position (GstFormat format)
253 GstStructure *structure;
255 structure = gst_structure_new_id (GST_QUARK (QUERY_POSITION),
256 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
257 GST_QUARK (CURRENT), G_TYPE_INT64, G_GINT64_CONSTANT (-1), NULL);
259 query = gst_query_new_custom (GST_QUERY_POSITION, structure);
265 * gst_query_set_position:
266 * @query: a #GstQuery with query type GST_QUERY_POSITION
267 * @format: the requested #GstFormat
268 * @cur: the position to set
270 * Answer a position query by setting the requested value in the given format.
273 gst_query_set_position (GstQuery * query, GstFormat format, gint64 cur)
277 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_POSITION);
279 s = GST_QUERY_STRUCTURE (query);
280 g_return_if_fail (format == g_value_get_enum (gst_structure_id_get_value (s,
281 GST_QUARK (FORMAT))));
283 gst_structure_id_set (s,
284 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
285 GST_QUARK (CURRENT), G_TYPE_INT64, cur, NULL);
289 * gst_query_parse_position:
290 * @query: a #GstQuery
291 * @format: (out) (allow-none): the storage for the #GstFormat of the
292 * position values (may be NULL)
293 * @cur: (out) (allow-none): the storage for the current position (may be NULL)
295 * Parse a position query, writing the format into @format, and the position
296 * into @cur, if the respective parameters are non-NULL.
299 gst_query_parse_position (GstQuery * query, GstFormat * format, gint64 * cur)
301 GstStructure *structure;
303 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_POSITION);
305 structure = GST_QUERY_STRUCTURE (query);
308 (GstFormat) g_value_get_enum (gst_structure_id_get_value (structure,
309 GST_QUARK (FORMAT)));
311 *cur = g_value_get_int64 (gst_structure_id_get_value (structure,
312 GST_QUARK (CURRENT)));
317 * gst_query_new_duration:
318 * @format: the #GstFormat for this duration query
320 * Constructs a new stream duration query object to query in the given format.
321 * Use gst_query_unref() when done with it. A duration query will give the
322 * total length of the stream.
324 * Free-function: gst_query_unref
326 * Returns: (transfer full): a new #GstQuery
329 gst_query_new_duration (GstFormat format)
332 GstStructure *structure;
334 structure = gst_structure_new_id (GST_QUARK (QUERY_DURATION),
335 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
336 GST_QUARK (DURATION), G_TYPE_INT64, G_GINT64_CONSTANT (-1), NULL);
338 query = gst_query_new_custom (GST_QUERY_DURATION, structure);
344 * gst_query_set_duration:
345 * @query: a #GstQuery
346 * @format: the #GstFormat for the duration
347 * @duration: the duration of the stream
349 * Answer a duration query by setting the requested value in the given format.
352 gst_query_set_duration (GstQuery * query, GstFormat format, gint64 duration)
356 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_DURATION);
358 s = GST_QUERY_STRUCTURE (query);
359 g_return_if_fail (format == g_value_get_enum (gst_structure_id_get_value (s,
360 GST_QUARK (FORMAT))));
361 gst_structure_id_set (s, GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
362 GST_QUARK (DURATION), G_TYPE_INT64, duration, NULL);
366 * gst_query_parse_duration:
367 * @query: a #GstQuery
368 * @format: (out) (allow-none): the storage for the #GstFormat of the duration
370 * @duration: (out) (allow-none): the storage for the total duration, or NULL.
372 * Parse a duration query answer. Write the format of the duration into @format,
373 * and the value into @duration, if the respective variables are non-NULL.
376 gst_query_parse_duration (GstQuery * query, GstFormat * format,
379 GstStructure *structure;
381 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_DURATION);
383 structure = GST_QUERY_STRUCTURE (query);
386 (GstFormat) g_value_get_enum (gst_structure_id_get_value (structure,
387 GST_QUARK (FORMAT)));
389 *duration = g_value_get_int64 (gst_structure_id_get_value (structure,
390 GST_QUARK (DURATION)));
394 * gst_query_new_latency:
396 * Constructs a new latency query object.
397 * Use gst_query_unref() when done with it. A latency query is usually performed
398 * by sinks to compensate for additional latency introduced by elements in the
401 * Free-function: gst_query_unref
403 * Returns: (transfer full): a #GstQuery
408 gst_query_new_latency (void)
411 GstStructure *structure;
413 structure = gst_structure_new_id (GST_QUARK (QUERY_LATENCY),
414 GST_QUARK (LIVE), G_TYPE_BOOLEAN, FALSE,
415 GST_QUARK (MIN_LATENCY), G_TYPE_UINT64, G_GUINT64_CONSTANT (0),
416 GST_QUARK (MAX_LATENCY), G_TYPE_UINT64, G_GUINT64_CONSTANT (-1), NULL);
418 query = gst_query_new_custom (GST_QUERY_LATENCY, structure);
424 * gst_query_set_latency:
425 * @query: a #GstQuery
426 * @live: if there is a live element upstream
427 * @min_latency: the minimal latency of the upstream elements
428 * @max_latency: the maximal latency of the upstream elements
430 * Answer a latency query by setting the requested values in the given format.
435 gst_query_set_latency (GstQuery * query, gboolean live,
436 GstClockTime min_latency, GstClockTime max_latency)
438 GstStructure *structure;
440 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_LATENCY);
442 structure = GST_QUERY_STRUCTURE (query);
443 gst_structure_id_set (structure,
444 GST_QUARK (LIVE), G_TYPE_BOOLEAN, live,
445 GST_QUARK (MIN_LATENCY), G_TYPE_UINT64, min_latency,
446 GST_QUARK (MAX_LATENCY), G_TYPE_UINT64, max_latency, NULL);
450 * gst_query_parse_latency:
451 * @query: a #GstQuery
452 * @live: (out) (allow-none): storage for live or NULL
453 * @min_latency: (out) (allow-none): the storage for the min latency or NULL
454 * @max_latency: (out) (allow-none): the storage for the max latency or NULL
456 * Parse a latency query answer.
461 gst_query_parse_latency (GstQuery * query, gboolean * live,
462 GstClockTime * min_latency, GstClockTime * max_latency)
464 GstStructure *structure;
466 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_LATENCY);
468 structure = GST_QUERY_STRUCTURE (query);
471 g_value_get_boolean (gst_structure_id_get_value (structure,
474 *min_latency = g_value_get_uint64 (gst_structure_id_get_value (structure,
475 GST_QUARK (MIN_LATENCY)));
477 *max_latency = g_value_get_uint64 (gst_structure_id_get_value (structure,
478 GST_QUARK (MAX_LATENCY)));
482 * gst_query_new_convert:
483 * @src_format: the source #GstFormat for the new query
484 * @value: the value to convert
485 * @dest_format: the target #GstFormat
487 * Constructs a new convert query object. Use gst_query_unref()
488 * when done with it. A convert query is used to ask for a conversion between
489 * one format and another.
491 * Free-function: gst_query_unref
493 * Returns: (transfer full): a #GstQuery
496 gst_query_new_convert (GstFormat src_format, gint64 value,
497 GstFormat dest_format)
500 GstStructure *structure;
502 structure = gst_structure_new_id (GST_QUARK (QUERY_CONVERT),
503 GST_QUARK (SRC_FORMAT), GST_TYPE_FORMAT, src_format,
504 GST_QUARK (SRC_VALUE), G_TYPE_INT64, value,
505 GST_QUARK (DEST_FORMAT), GST_TYPE_FORMAT, dest_format,
506 GST_QUARK (DEST_VALUE), G_TYPE_INT64, G_GINT64_CONSTANT (-1), NULL);
508 query = gst_query_new_custom (GST_QUERY_CONVERT, structure);
514 * gst_query_set_convert:
515 * @query: a #GstQuery
516 * @src_format: the source #GstFormat
517 * @src_value: the source value
518 * @dest_format: the destination #GstFormat
519 * @dest_value: the destination value
521 * Answer a convert query by setting the requested values.
524 gst_query_set_convert (GstQuery * query, GstFormat src_format, gint64 src_value,
525 GstFormat dest_format, gint64 dest_value)
527 GstStructure *structure;
529 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_CONVERT);
531 structure = GST_QUERY_STRUCTURE (query);
532 gst_structure_id_set (structure,
533 GST_QUARK (SRC_FORMAT), GST_TYPE_FORMAT, src_format,
534 GST_QUARK (SRC_VALUE), G_TYPE_INT64, src_value,
535 GST_QUARK (DEST_FORMAT), GST_TYPE_FORMAT, dest_format,
536 GST_QUARK (DEST_VALUE), G_TYPE_INT64, dest_value, NULL);
540 * gst_query_parse_convert:
541 * @query: a #GstQuery
542 * @src_format: (out) (allow-none): the storage for the #GstFormat of the
543 * source value, or NULL
544 * @src_value: (out) (allow-none): the storage for the source value, or NULL
545 * @dest_format: (out) (allow-none): the storage for the #GstFormat of the
546 * destination value, or NULL
547 * @dest_value: (out) (allow-none): the storage for the destination value,
550 * Parse a convert query answer. Any of @src_format, @src_value, @dest_format,
551 * and @dest_value may be NULL, in which case that value is omitted.
554 gst_query_parse_convert (GstQuery * query, GstFormat * src_format,
555 gint64 * src_value, GstFormat * dest_format, gint64 * dest_value)
557 GstStructure *structure;
559 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_CONVERT);
561 structure = GST_QUERY_STRUCTURE (query);
564 (GstFormat) g_value_get_enum (gst_structure_id_get_value (structure,
565 GST_QUARK (SRC_FORMAT)));
567 *src_value = g_value_get_int64 (gst_structure_id_get_value (structure,
568 GST_QUARK (SRC_VALUE)));
571 (GstFormat) g_value_get_enum (gst_structure_id_get_value (structure,
572 GST_QUARK (DEST_FORMAT)));
574 *dest_value = g_value_get_int64 (gst_structure_id_get_value (structure,
575 GST_QUARK (DEST_VALUE)));
579 * gst_query_new_segment:
580 * @format: the #GstFormat for the new query
582 * Constructs a new segment query object. Use gst_query_unref()
583 * when done with it. A segment query is used to discover information about the
584 * currently configured segment for playback.
586 * Free-function: gst_query_unref
588 * Returns: (transfer full): a new #GstQuery
591 gst_query_new_segment (GstFormat format)
594 GstStructure *structure;
596 structure = gst_structure_new_id (GST_QUARK (QUERY_SEGMENT),
597 GST_QUARK (RATE), G_TYPE_DOUBLE, (gdouble) 0.0,
598 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
599 GST_QUARK (START_VALUE), G_TYPE_INT64, G_GINT64_CONSTANT (-1),
600 GST_QUARK (STOP_VALUE), G_TYPE_INT64, G_GINT64_CONSTANT (-1), NULL);
602 query = gst_query_new_custom (GST_QUERY_SEGMENT, structure);
608 * gst_query_set_segment:
609 * @query: a #GstQuery
610 * @rate: the rate of the segment
611 * @format: the #GstFormat of the segment values (@start_value and @stop_value)
612 * @start_value: the start value
613 * @stop_value: the stop value
615 * Answer a segment query by setting the requested values. The normal
616 * playback segment of a pipeline is 0 to duration at the default rate of
617 * 1.0. If a seek was performed on the pipeline to play a different
618 * segment, this query will return the range specified in the last seek.
620 * @start_value and @stop_value will respectively contain the configured
621 * playback range start and stop values expressed in @format.
622 * The values are always between 0 and the duration of the media and
623 * @start_value <= @stop_value. @rate will contain the playback rate. For
624 * negative rates, playback will actually happen from @stop_value to
628 gst_query_set_segment (GstQuery * query, gdouble rate, GstFormat format,
629 gint64 start_value, gint64 stop_value)
631 GstStructure *structure;
633 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_SEGMENT);
635 structure = GST_QUERY_STRUCTURE (query);
636 gst_structure_id_set (structure,
637 GST_QUARK (RATE), G_TYPE_DOUBLE, rate,
638 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
639 GST_QUARK (START_VALUE), G_TYPE_INT64, start_value,
640 GST_QUARK (STOP_VALUE), G_TYPE_INT64, stop_value, NULL);
644 * gst_query_parse_segment:
645 * @query: a #GstQuery
646 * @rate: (out) (allow-none): the storage for the rate of the segment, or NULL
647 * @format: (out) (allow-none): the storage for the #GstFormat of the values,
649 * @start_value: (out) (allow-none): the storage for the start value, or NULL
650 * @stop_value: (out) (allow-none): the storage for the stop value, or NULL
652 * Parse a segment query answer. Any of @rate, @format, @start_value, and
653 * @stop_value may be NULL, which will cause this value to be omitted.
655 * See gst_query_set_segment() for an explanation of the function arguments.
658 gst_query_parse_segment (GstQuery * query, gdouble * rate, GstFormat * format,
659 gint64 * start_value, gint64 * stop_value)
661 GstStructure *structure;
663 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_SEGMENT);
665 structure = GST_QUERY_STRUCTURE (query);
667 *rate = g_value_get_double (gst_structure_id_get_value (structure,
671 (GstFormat) g_value_get_enum (gst_structure_id_get_value (structure,
672 GST_QUARK (FORMAT)));
674 *start_value = g_value_get_int64 (gst_structure_id_get_value (structure,
675 GST_QUARK (START_VALUE)));
677 *stop_value = g_value_get_int64 (gst_structure_id_get_value (structure,
678 GST_QUARK (STOP_VALUE)));
682 * gst_query_new_custom:
683 * @type: the query type
684 * @structure: a structure for the query
686 * Constructs a new custom query object. Use gst_query_unref()
689 * Free-function: gst_query_unref
691 * Returns: (transfer full): a new #GstQuery
694 gst_query_new_custom (GstQueryType type, GstStructure * structure)
698 query = g_slice_new0 (GstQueryImpl);
700 GST_DEBUG ("creating new query %p %s", query, gst_query_type_get_name (type));
703 /* structure must not have a parent */
704 if (!gst_structure_set_parent_refcount (structure,
705 &query->query.mini_object.refcount))
708 gst_query_init (query, sizeof (GstQueryImpl), type);
710 GST_QUERY_STRUCTURE (query) = structure;
712 return GST_QUERY_CAST (query);
717 g_slice_free1 (GST_QUERY_SLICE_SIZE (query), query);
718 g_warning ("structure is already owned by another object");
724 * gst_query_get_structure:
725 * @query: a #GstQuery
727 * Get the structure of a query.
729 * Returns: (transfer none): the #GstStructure of the query. The structure is
730 * still owned by the query and will therefore be freed when the query
734 gst_query_get_structure (GstQuery * query)
736 g_return_val_if_fail (GST_IS_QUERY (query), NULL);
738 return GST_QUERY_STRUCTURE (query);
742 * gst_query_writable_structure:
743 * @query: a #GstQuery
745 * Get the structure of a query. This method should be called with a writable
746 * @query so that the returned structure is guranteed to be writable.
748 * Returns: (transfer none): the #GstStructure of the query. The structure is
749 * still owned by the query and will therefore be freed when the query
753 gst_query_writable_structure (GstQuery * query)
755 g_return_val_if_fail (GST_IS_QUERY (query), NULL);
756 g_return_val_if_fail (gst_query_is_writable (query), NULL);
758 return GST_QUERY_STRUCTURE (query);
762 * gst_query_new_seeking:
763 * @format: the default #GstFormat for the new query
765 * Constructs a new query object for querying seeking properties of
768 * Free-function: gst_query_unref
770 * Returns: (transfer full): a new #GstQuery
773 gst_query_new_seeking (GstFormat format)
776 GstStructure *structure;
778 structure = gst_structure_new_id (GST_QUARK (QUERY_SEEKING),
779 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
780 GST_QUARK (SEEKABLE), G_TYPE_BOOLEAN, FALSE,
781 GST_QUARK (SEGMENT_START), G_TYPE_INT64, G_GINT64_CONSTANT (-1),
782 GST_QUARK (SEGMENT_END), G_TYPE_INT64, G_GINT64_CONSTANT (-1), NULL);
784 query = gst_query_new_custom (GST_QUERY_SEEKING, structure);
790 * gst_query_set_seeking:
791 * @query: a #GstQuery
792 * @format: the format to set for the @segment_start and @segment_end values
793 * @seekable: the seekable flag to set
794 * @segment_start: the segment_start to set
795 * @segment_end: the segment_end to set
797 * Set the seeking query result fields in @query.
800 gst_query_set_seeking (GstQuery * query, GstFormat format,
801 gboolean seekable, gint64 segment_start, gint64 segment_end)
803 GstStructure *structure;
805 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_SEEKING);
806 g_return_if_fail (gst_query_is_writable (query));
808 structure = GST_QUERY_STRUCTURE (query);
809 gst_structure_id_set (structure,
810 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
811 GST_QUARK (SEEKABLE), G_TYPE_BOOLEAN, seekable,
812 GST_QUARK (SEGMENT_START), G_TYPE_INT64, segment_start,
813 GST_QUARK (SEGMENT_END), G_TYPE_INT64, segment_end, NULL);
817 * gst_query_parse_seeking:
818 * @query: a GST_QUERY_SEEKING type query #GstQuery
819 * @format: (out) (allow-none): the format to set for the @segment_start
820 * and @segment_end values, or NULL
821 * @seekable: (out) (allow-none): the seekable flag to set, or NULL
822 * @segment_start: (out) (allow-none): the segment_start to set, or NULL
823 * @segment_end: (out) (allow-none): the segment_end to set, or NULL
825 * Parse a seeking query, writing the format into @format, and
826 * other results into the passed parameters, if the respective parameters
830 gst_query_parse_seeking (GstQuery * query, GstFormat * format,
831 gboolean * seekable, gint64 * segment_start, gint64 * segment_end)
833 GstStructure *structure;
835 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_SEEKING);
837 structure = GST_QUERY_STRUCTURE (query);
840 (GstFormat) g_value_get_enum (gst_structure_id_get_value (structure,
841 GST_QUARK (FORMAT)));
843 *seekable = g_value_get_boolean (gst_structure_id_get_value (structure,
844 GST_QUARK (SEEKABLE)));
846 *segment_start = g_value_get_int64 (gst_structure_id_get_value (structure,
847 GST_QUARK (SEGMENT_START)));
849 *segment_end = g_value_get_int64 (gst_structure_id_get_value (structure,
850 GST_QUARK (SEGMENT_END)));
854 ensure_array (GstStructure * s, GQuark quark, gsize element_size,
855 GDestroyNotify clear_func)
860 value = gst_structure_id_get_value (s, quark);
862 array = (GArray *) g_value_get_boxed (value);
864 GValue new_array_val = { 0, };
866 array = g_array_new (FALSE, TRUE, element_size);
868 g_array_set_clear_func (array, clear_func);
870 g_value_init (&new_array_val, G_TYPE_ARRAY);
871 g_value_take_boxed (&new_array_val, array);
873 gst_structure_id_take_value (s, quark, &new_array_val);
879 * gst_query_new_formats:
881 * Constructs a new query object for querying formats of
884 * Free-function: gst_query_unref
886 * Returns: (transfer full): a new #GstQuery
891 gst_query_new_formats (void)
894 GstStructure *structure;
896 structure = gst_structure_new_id_empty (GST_QUARK (QUERY_FORMATS));
897 query = gst_query_new_custom (GST_QUERY_FORMATS, structure);
903 gst_query_list_add_format (GValue * list, GstFormat format)
905 GValue item = { 0, };
907 g_value_init (&item, GST_TYPE_FORMAT);
908 g_value_set_enum (&item, format);
909 gst_value_list_append_value (list, &item);
910 g_value_unset (&item);
914 * gst_query_set_formats:
915 * @query: a #GstQuery
916 * @n_formats: the number of formats to set.
917 * @...: A number of @GstFormats equal to @n_formats.
919 * Set the formats query result fields in @query. The number of formats passed
920 * must be equal to @n_formats.
923 gst_query_set_formats (GstQuery * query, gint n_formats, ...)
926 GValue list = { 0, };
928 GstStructure *structure;
930 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_FORMATS);
931 g_return_if_fail (gst_query_is_writable (query));
933 g_value_init (&list, GST_TYPE_LIST);
935 va_start (ap, n_formats);
936 for (i = 0; i < n_formats; i++) {
937 gst_query_list_add_format (&list, va_arg (ap, GstFormat));
941 structure = GST_QUERY_STRUCTURE (query);
942 gst_structure_set_value (structure, "formats", &list);
944 g_value_unset (&list);
949 * gst_query_set_formatsv:
950 * @query: a #GstQuery
951 * @n_formats: the number of formats to set.
952 * @formats: (in) (array length=n_formats): an array containing @n_formats
955 * Set the formats query result fields in @query. The number of formats passed
956 * in the @formats array must be equal to @n_formats.
961 gst_query_set_formatsv (GstQuery * query, gint n_formats,
962 const GstFormat * formats)
964 GValue list = { 0, };
966 GstStructure *structure;
968 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_FORMATS);
969 g_return_if_fail (gst_query_is_writable (query));
971 g_value_init (&list, GST_TYPE_LIST);
972 for (i = 0; i < n_formats; i++) {
973 gst_query_list_add_format (&list, formats[i]);
975 structure = GST_QUERY_STRUCTURE (query);
976 gst_structure_set_value (structure, "formats", &list);
978 g_value_unset (&list);
982 * gst_query_parse_n_formats:
983 * @query: a #GstQuery
984 * @n_formats: (out) (allow-none): the number of formats in this query.
986 * Parse the number of formats in the formats @query.
991 gst_query_parse_n_formats (GstQuery * query, guint * n_formats)
993 GstStructure *structure;
995 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_FORMATS);
1000 structure = GST_QUERY_STRUCTURE (query);
1001 list = gst_structure_get_value (structure, "formats");
1005 *n_formats = gst_value_list_get_size (list);
1010 * gst_query_parse_nth_format:
1011 * @query: a #GstQuery
1012 * @nth: (out): the nth format to retrieve.
1013 * @format: (out) (allow-none): a pointer to store the nth format
1015 * Parse the format query and retrieve the @nth format from it into
1016 * @format. If the list contains less elements than @nth, @format will be
1017 * set to GST_FORMAT_UNDEFINED.
1020 gst_query_parse_nth_format (GstQuery * query, guint nth, GstFormat * format)
1022 GstStructure *structure;
1024 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_FORMATS);
1029 structure = GST_QUERY_STRUCTURE (query);
1030 list = gst_structure_get_value (structure, "formats");
1032 *format = GST_FORMAT_UNDEFINED;
1034 if (nth < gst_value_list_get_size (list)) {
1036 (GstFormat) g_value_get_enum (gst_value_list_get_value (list, nth));
1038 *format = GST_FORMAT_UNDEFINED;
1044 * gst_query_new_buffering:
1045 * @format: the default #GstFormat for the new query
1047 * Constructs a new query object for querying the buffering status of
1050 * Free-function: gst_query_unref
1052 * Returns: (transfer full): a new #GstQuery
1057 gst_query_new_buffering (GstFormat format)
1060 GstStructure *structure;
1062 /* by default, we configure the answer as no buffering with a 100% buffering
1064 structure = gst_structure_new_id (GST_QUARK (QUERY_BUFFERING),
1065 GST_QUARK (BUSY), G_TYPE_BOOLEAN, FALSE,
1066 GST_QUARK (BUFFER_PERCENT), G_TYPE_INT, 100,
1067 GST_QUARK (BUFFERING_MODE), GST_TYPE_BUFFERING_MODE, GST_BUFFERING_STREAM,
1068 GST_QUARK (AVG_IN_RATE), G_TYPE_INT, -1,
1069 GST_QUARK (AVG_OUT_RATE), G_TYPE_INT, -1,
1070 GST_QUARK (BUFFERING_LEFT), G_TYPE_INT64, G_GINT64_CONSTANT (0),
1071 GST_QUARK (ESTIMATED_TOTAL), G_TYPE_INT64, G_GINT64_CONSTANT (-1),
1072 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1073 GST_QUARK (START_VALUE), G_TYPE_INT64, G_GINT64_CONSTANT (-1),
1074 GST_QUARK (STOP_VALUE), G_TYPE_INT64, G_GINT64_CONSTANT (-1), NULL);
1076 query = gst_query_new_custom (GST_QUERY_BUFFERING, structure);
1082 * gst_query_set_buffering_percent:
1083 * @query: A valid #GstQuery of type GST_QUERY_BUFFERING.
1084 * @busy: if buffering is busy
1085 * @percent: a buffering percent
1087 * Set the percentage of buffered data. This is a value between 0 and 100.
1088 * The @busy indicator is %TRUE when the buffering is in progress.
1093 gst_query_set_buffering_percent (GstQuery * query, gboolean busy, gint percent)
1095 GstStructure *structure;
1097 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_BUFFERING);
1098 g_return_if_fail (gst_query_is_writable (query));
1099 g_return_if_fail (percent >= 0 && percent <= 100);
1101 structure = GST_QUERY_STRUCTURE (query);
1102 gst_structure_id_set (structure,
1103 GST_QUARK (BUSY), G_TYPE_BOOLEAN, busy,
1104 GST_QUARK (BUFFER_PERCENT), G_TYPE_INT, percent, NULL);
1108 * gst_query_parse_buffering_percent:
1109 * @query: A valid #GstQuery of type GST_QUERY_BUFFERING.
1110 * @busy: (out) (allow-none): if buffering is busy, or NULL
1111 * @percent: (out) (allow-none): a buffering percent, or NULL
1113 * Get the percentage of buffered data. This is a value between 0 and 100.
1114 * The @busy indicator is %TRUE when the buffering is in progress.
1119 gst_query_parse_buffering_percent (GstQuery * query, gboolean * busy,
1122 GstStructure *structure;
1124 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_BUFFERING);
1126 structure = GST_QUERY_STRUCTURE (query);
1128 *busy = g_value_get_boolean (gst_structure_id_get_value (structure,
1131 *percent = g_value_get_int (gst_structure_id_get_value (structure,
1132 GST_QUARK (BUFFER_PERCENT)));
1136 * gst_query_set_buffering_stats:
1137 * @query: A valid #GstQuery of type GST_QUERY_BUFFERING.
1138 * @mode: a buffering mode
1139 * @avg_in: the average input rate
1140 * @avg_out: the average output rate
1141 * @buffering_left: amount of buffering time left
1143 * Configures the buffering stats values in @query.
1148 gst_query_set_buffering_stats (GstQuery * query, GstBufferingMode mode,
1149 gint avg_in, gint avg_out, gint64 buffering_left)
1151 GstStructure *structure;
1153 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_BUFFERING);
1154 g_return_if_fail (gst_query_is_writable (query));
1156 structure = GST_QUERY_STRUCTURE (query);
1157 gst_structure_id_set (structure,
1158 GST_QUARK (BUFFERING_MODE), GST_TYPE_BUFFERING_MODE, mode,
1159 GST_QUARK (AVG_IN_RATE), G_TYPE_INT, avg_in,
1160 GST_QUARK (AVG_OUT_RATE), G_TYPE_INT, avg_out,
1161 GST_QUARK (BUFFERING_LEFT), G_TYPE_INT64, buffering_left, NULL);
1165 * gst_query_parse_buffering_stats:
1166 * @query: A valid #GstQuery of type GST_QUERY_BUFFERING.
1167 * @mode: (out) (allow-none): a buffering mode, or NULL
1168 * @avg_in: (out) (allow-none): the average input rate, or NULL
1169 * @avg_out: (out) (allow-none): the average output rat, or NULLe
1170 * @buffering_left: (out) (allow-none): amount of buffering time left, or NULL
1172 * Extracts the buffering stats values from @query.
1177 gst_query_parse_buffering_stats (GstQuery * query,
1178 GstBufferingMode * mode, gint * avg_in, gint * avg_out,
1179 gint64 * buffering_left)
1181 GstStructure *structure;
1183 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_BUFFERING);
1185 structure = GST_QUERY_STRUCTURE (query);
1187 *mode = (GstBufferingMode)
1188 g_value_get_enum (gst_structure_id_get_value (structure,
1189 GST_QUARK (BUFFERING_MODE)));
1191 *avg_in = g_value_get_int (gst_structure_id_get_value (structure,
1192 GST_QUARK (AVG_IN_RATE)));
1194 *avg_out = g_value_get_int (gst_structure_id_get_value (structure,
1195 GST_QUARK (AVG_OUT_RATE)));
1198 g_value_get_int64 (gst_structure_id_get_value (structure,
1199 GST_QUARK (BUFFERING_LEFT)));
1203 * gst_query_set_buffering_range:
1204 * @query: a #GstQuery
1205 * @format: the format to set for the @start and @stop values
1206 * @start: the start to set
1207 * @stop: the stop to set
1208 * @estimated_total: estimated total amount of download time
1210 * Set the available query result fields in @query.
1215 gst_query_set_buffering_range (GstQuery * query, GstFormat format,
1216 gint64 start, gint64 stop, gint64 estimated_total)
1218 GstStructure *structure;
1220 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_BUFFERING);
1221 g_return_if_fail (gst_query_is_writable (query));
1223 structure = GST_QUERY_STRUCTURE (query);
1224 gst_structure_id_set (structure,
1225 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1226 GST_QUARK (START_VALUE), G_TYPE_INT64, start,
1227 GST_QUARK (STOP_VALUE), G_TYPE_INT64, stop,
1228 GST_QUARK (ESTIMATED_TOTAL), G_TYPE_INT64, estimated_total, NULL);
1232 * gst_query_parse_buffering_range:
1233 * @query: a GST_QUERY_BUFFERING type query #GstQuery
1234 * @format: (out) (allow-none): the format to set for the @segment_start
1235 * and @segment_end values, or NULL
1236 * @start: (out) (allow-none): the start to set, or NULL
1237 * @stop: (out) (allow-none): the stop to set, or NULL
1238 * @estimated_total: (out) (allow-none): estimated total amount of download
1241 * Parse an available query, writing the format into @format, and
1242 * other results into the passed parameters, if the respective parameters
1248 gst_query_parse_buffering_range (GstQuery * query, GstFormat * format,
1249 gint64 * start, gint64 * stop, gint64 * estimated_total)
1251 GstStructure *structure;
1253 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_BUFFERING);
1255 structure = GST_QUERY_STRUCTURE (query);
1258 (GstFormat) g_value_get_enum (gst_structure_id_get_value (structure,
1259 GST_QUARK (FORMAT)));
1261 *start = g_value_get_int64 (gst_structure_id_get_value (structure,
1262 GST_QUARK (START_VALUE)));
1264 *stop = g_value_get_int64 (gst_structure_id_get_value (structure,
1265 GST_QUARK (STOP_VALUE)));
1266 if (estimated_total)
1268 g_value_get_int64 (gst_structure_id_get_value (structure,
1269 GST_QUARK (ESTIMATED_TOTAL)));
1272 /* GstQueryBufferingRange: internal struct for GArray */
1277 } GstQueryBufferingRange;
1280 * gst_query_add_buffering_range:
1281 * @query: a GST_QUERY_BUFFERING type query #GstQuery
1282 * @start: start position of the range
1283 * @stop: stop position of the range
1285 * Set the buffering-ranges array field in @query. The current last
1286 * start position of the array should be inferior to @start.
1288 * Returns: a #gboolean indicating if the range was added or not.
1293 gst_query_add_buffering_range (GstQuery * query, gint64 start, gint64 stop)
1295 GstQueryBufferingRange range;
1296 GstStructure *structure;
1299 g_return_val_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_BUFFERING, FALSE);
1300 g_return_val_if_fail (gst_query_is_writable (query), FALSE);
1302 if (G_UNLIKELY (start >= stop))
1305 structure = GST_QUERY_STRUCTURE (query);
1306 array = ensure_array (structure, GST_QUARK (BUFFERING_RANGES),
1307 sizeof (GstQueryBufferingRange), NULL);
1309 if (array->len > 1) {
1310 GstQueryBufferingRange *last;
1312 last = &g_array_index (array, GstQueryBufferingRange, array->len - 1);
1314 if (G_UNLIKELY (start <= last->start))
1318 range.start = start;
1320 g_array_append_val (array, range);
1326 * gst_query_get_n_buffering_ranges:
1327 * @query: a GST_QUERY_BUFFERING type query #GstQuery
1329 * Retrieve the number of values currently stored in the
1330 * buffered-ranges array of the query's structure.
1332 * Returns: the range array size as a #guint.
1337 gst_query_get_n_buffering_ranges (GstQuery * query)
1339 GstStructure *structure;
1342 g_return_val_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_BUFFERING, 0);
1344 structure = GST_QUERY_STRUCTURE (query);
1345 array = ensure_array (structure, GST_QUARK (BUFFERING_RANGES),
1346 sizeof (GstQueryBufferingRange), NULL);
1353 * gst_query_parse_nth_buffering_range:
1354 * @query: a GST_QUERY_BUFFERING type query #GstQuery
1355 * @index: position in the buffered-ranges array to read
1356 * @start: (out) (allow-none): the start position to set, or NULL
1357 * @stop: (out) (allow-none): the stop position to set, or NULL
1359 * Parse an available query and get the start and stop values stored
1360 * at the @index of the buffered ranges array.
1362 * Returns: a #gboolean indicating if the parsing succeeded.
1367 gst_query_parse_nth_buffering_range (GstQuery * query, guint index,
1368 gint64 * start, gint64 * stop)
1370 GstQueryBufferingRange *range;
1371 GstStructure *structure;
1374 g_return_val_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_BUFFERING, FALSE);
1376 structure = GST_QUERY_STRUCTURE (query);
1378 array = ensure_array (structure, GST_QUARK (BUFFERING_RANGES),
1379 sizeof (GstQueryBufferingRange), NULL);
1380 g_return_val_if_fail (index < array->len, FALSE);
1382 range = &g_array_index (array, GstQueryBufferingRange, index);
1385 *start = range->start;
1387 *stop = range->stop;
1394 * gst_query_new_uri:
1396 * Constructs a new query URI query object. Use gst_query_unref()
1397 * when done with it. An URI query is used to query the current URI
1398 * that is used by the source or sink.
1400 * Free-function: gst_query_unref
1402 * Returns: (transfer full): a new #GstQuery
1407 gst_query_new_uri (void)
1410 GstStructure *structure;
1412 structure = gst_structure_new_id (GST_QUARK (QUERY_URI),
1413 GST_QUARK (URI), G_TYPE_STRING, NULL, NULL);
1415 query = gst_query_new_custom (GST_QUERY_URI, structure);
1421 * gst_query_set_uri:
1422 * @query: a #GstQuery with query type GST_QUERY_URI
1423 * @uri: the URI to set
1425 * Answer a URI query by setting the requested URI.
1430 gst_query_set_uri (GstQuery * query, const gchar * uri)
1432 GstStructure *structure;
1434 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_URI);
1435 g_return_if_fail (gst_query_is_writable (query));
1436 g_return_if_fail (gst_uri_is_valid (uri));
1438 structure = GST_QUERY_STRUCTURE (query);
1439 gst_structure_id_set (structure, GST_QUARK (URI), G_TYPE_STRING, uri, NULL);
1443 * gst_query_parse_uri:
1444 * @query: a #GstQuery
1445 * @uri: (out callee-allocates) (allow-none): the storage for the current URI
1448 * Parse an URI query, writing the URI into @uri as a newly
1449 * allocated string, if the respective parameters are non-NULL.
1450 * Free the string with g_free() after usage.
1455 gst_query_parse_uri (GstQuery * query, gchar ** uri)
1457 GstStructure *structure;
1459 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_URI);
1461 structure = GST_QUERY_STRUCTURE (query);
1463 *uri = g_value_dup_string (gst_structure_id_get_value (structure,
1468 * gst_query_new_allocation:
1469 * @caps: the negotiated caps
1470 * @need_pool: return a pool
1472 * Constructs a new query object for querying the allocation properties.
1474 * Free-function: gst_query_unref
1476 * Returns: (transfer full): a new #GstQuery
1479 gst_query_new_allocation (GstCaps * caps, gboolean need_pool)
1482 GstStructure *structure;
1484 structure = gst_structure_new_id (GST_QUARK (QUERY_ALLOCATION),
1485 GST_QUARK (CAPS), GST_TYPE_CAPS, caps,
1486 GST_QUARK (NEED_POOL), G_TYPE_BOOLEAN, need_pool, NULL);
1488 query = gst_query_new_custom (GST_QUERY_ALLOCATION, structure);
1494 * gst_query_parse_allocation:
1495 * @query: a #GstQuery
1496 * @caps: (out) (transfer none) (allow-none): The #GstCaps
1497 * @need_pool: (out) (allow-none): Whether a #GstBufferPool is needed
1499 * Parse an allocation query, writing the requested caps in @caps and
1500 * whether a pool is needed in @need_pool, if the respective parameters
1504 gst_query_parse_allocation (GstQuery * query, GstCaps ** caps,
1505 gboolean * need_pool)
1507 GstStructure *structure;
1509 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_ALLOCATION);
1511 structure = GST_QUERY_STRUCTURE (query);
1513 *caps = g_value_get_boxed (gst_structure_id_get_value (structure,
1516 gst_structure_id_get (structure,
1517 GST_QUARK (NEED_POOL), G_TYPE_BOOLEAN, need_pool, NULL);
1522 GstBufferPool *pool;
1529 allocation_pool_free (AllocationPool * ap)
1532 gst_object_unref (ap->pool);
1536 * gst_query_add_allocation_pool:
1537 * @query: A valid #GstQuery of type GST_QUERY_ALLOCATION.
1538 * @pool: the #GstBufferPool
1540 * @min_buffers: the min buffers
1541 * @max_buffers: the max buffers
1543 * Set the pool parameters in @query.
1546 gst_query_add_allocation_pool (GstQuery * query, GstBufferPool * pool,
1547 guint size, guint min_buffers, guint max_buffers)
1550 GstStructure *structure;
1553 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_ALLOCATION);
1554 g_return_if_fail (gst_query_is_writable (query));
1555 g_return_if_fail (size != 0);
1557 structure = GST_QUERY_STRUCTURE (query);
1558 array = ensure_array (structure, GST_QUARK (POOL),
1559 sizeof (AllocationPool), (GDestroyNotify) allocation_pool_free);
1561 if ((ap.pool = pool))
1562 gst_object_ref (pool);
1564 ap.min_buffers = min_buffers;
1565 ap.max_buffers = max_buffers;
1567 g_array_append_val (array, ap);
1572 * gst_query_get_n_allocation_pools:
1573 * @query: a GST_QUERY_ALLOCATION type query #GstQuery
1575 * Retrieve the number of values currently stored in the
1576 * pool array of the query's structure.
1578 * Returns: the pool array size as a #guint.
1581 gst_query_get_n_allocation_pools (GstQuery * query)
1584 GstStructure *structure;
1586 g_return_val_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_ALLOCATION, 0);
1588 structure = GST_QUERY_STRUCTURE (query);
1589 array = ensure_array (structure, GST_QUARK (POOL),
1590 sizeof (AllocationPool), (GDestroyNotify) allocation_pool_free);
1596 * gst_query_parse_nth_allocation_pool:
1597 * @query: A valid #GstQuery of type GST_QUERY_ALLOCATION.
1598 * @index: index to parse
1599 * @pool: (out) (allow-none) (transfer none): the #GstBufferPool
1600 * @size: (out) (allow-none): the size
1601 * @min_buffers: (out) (allow-none): the min buffers
1602 * @max_buffers: (out) (allow-none): the max buffers
1604 * Get the pool parameters in @query.
1607 gst_query_parse_nth_allocation_pool (GstQuery * query, guint index,
1608 GstBufferPool ** pool, guint * size, guint * min_buffers,
1609 guint * max_buffers)
1612 GstStructure *structure;
1615 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_ALLOCATION);
1617 structure = GST_QUERY_STRUCTURE (query);
1618 array = ensure_array (structure, GST_QUARK (POOL),
1619 sizeof (AllocationPool), (GDestroyNotify) allocation_pool_free);
1620 g_return_if_fail (index < array->len);
1622 ap = &g_array_index (array, AllocationPool, index);
1625 if ((*pool = ap->pool))
1626 gst_object_ref (*pool);
1630 *min_buffers = ap->min_buffers;
1632 *max_buffers = ap->max_buffers;
1636 * gst_query_set_nth_allocation_pool:
1637 * @index: index to modify
1638 * @query: A valid #GstQuery of type GST_QUERY_ALLOCATION.
1639 * @pool: the #GstBufferPool
1641 * @min_buffers: the min buffers
1642 * @max_buffers: the max buffers
1644 * Set the pool parameters in @query.
1647 gst_query_set_nth_allocation_pool (GstQuery * query, guint index,
1648 GstBufferPool * pool, guint size, guint min_buffers, guint max_buffers)
1651 GstStructure *structure;
1652 AllocationPool *oldap, ap;
1654 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_ALLOCATION);
1656 structure = GST_QUERY_STRUCTURE (query);
1657 array = ensure_array (structure, GST_QUARK (POOL),
1658 sizeof (AllocationPool), (GDestroyNotify) allocation_pool_free);
1659 g_return_if_fail (index < array->len);
1661 oldap = &g_array_index (array, AllocationPool, index);
1662 allocation_pool_free (oldap);
1664 if ((ap.pool = pool))
1665 gst_object_ref (pool);
1667 ap.min_buffers = min_buffers;
1668 ap.max_buffers = max_buffers;
1669 g_array_index (array, AllocationPool, index) = ap;
1673 * gst_query_add_allocation_meta:
1674 * @query: a GST_QUERY_ALLOCATION type query #GstQuery
1675 * @api: the metadata API
1677 * Add @api as aone of the supported metadata API to @query.
1680 gst_query_add_allocation_meta (GstQuery * query, GType api)
1683 GstStructure *structure;
1685 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_ALLOCATION);
1686 g_return_if_fail (api != 0);
1687 g_return_if_fail (gst_query_is_writable (query));
1689 structure = GST_QUERY_STRUCTURE (query);
1690 array = ensure_array (structure, GST_QUARK (META), sizeof (GType), NULL);
1692 g_array_append_val (array, api);
1696 * gst_query_get_n_allocation_metas:
1697 * @query: a GST_QUERY_ALLOCATION type query #GstQuery
1699 * Retrieve the number of values currently stored in the
1700 * meta API array of the query's structure.
1702 * Returns: the metadata API array size as a #guint.
1705 gst_query_get_n_allocation_metas (GstQuery * query)
1708 GstStructure *structure;
1710 g_return_val_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_ALLOCATION, 0);
1712 structure = GST_QUERY_STRUCTURE (query);
1713 array = ensure_array (structure, GST_QUARK (META), sizeof (GType), NULL);
1719 * gst_query_parse_nth_allocation_meta:
1720 * @query: a GST_QUERY_ALLOCATION type query #GstQuery
1721 * @index: position in the metadata API array to read
1723 * Parse an available query and get the metadata API
1724 * at @index of the metadata API array.
1726 * Returns: a #GType of the metadata API at @index.
1729 gst_query_parse_nth_allocation_meta (GstQuery * query, guint index)
1732 GstStructure *structure;
1734 g_return_val_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_ALLOCATION, 0);
1736 structure = GST_QUERY_STRUCTURE (query);
1737 array = ensure_array (structure, GST_QUARK (META), sizeof (GType), NULL);
1739 g_return_val_if_fail (index < array->len, 0);
1741 return g_array_index (array, GType, index);
1745 * gst_query_remove_nth_allocation_meta:
1746 * @query: a GST_QUERY_ALLOCATION type query #GstQuery
1747 * @index: position in the metadata API array to remove
1749 * Remove the metadata API at @index of the metadata API array.
1752 gst_query_remove_nth_allocation_meta (GstQuery * query, guint index)
1755 GstStructure *structure;
1757 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_ALLOCATION);
1758 g_return_if_fail (gst_query_is_writable (query));
1760 structure = GST_QUERY_STRUCTURE (query);
1761 array = ensure_array (structure, GST_QUARK (META), sizeof (GType), NULL);
1762 g_return_if_fail (index < array->len);
1764 g_array_remove_index (array, index);
1768 * gst_query_has_allocation_meta:
1769 * @query: a GST_QUERY_ALLOCATION type query #GstQuery
1770 * @api: the metadata API
1772 * Check if @query has metadata @api set.
1774 * Returns: TRUE when @api is in the list of metadata.
1777 gst_query_has_allocation_meta (GstQuery * query, GType api)
1780 GstStructure *structure;
1783 g_return_val_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_ALLOCATION, FALSE);
1784 g_return_val_if_fail (api != 0, FALSE);
1786 structure = GST_QUERY_STRUCTURE (query);
1787 array = ensure_array (structure, GST_QUARK (META), sizeof (GType), NULL);
1790 for (i = 0; i < len; i++) {
1791 if (g_array_index (array, GType, i) == api)
1799 GstAllocator *allocator;
1800 GstAllocationParams params;
1804 allocation_param_free (AllocationParam * ap)
1807 gst_allocator_unref (ap->allocator);
1811 * gst_query_add_allocation_param:
1812 * @query: a GST_QUERY_ALLOCATION type query #GstQuery
1813 * @allocator: the memory allocator
1814 * @params: a #GstAllocationParams
1816 * Add @allocator and its @params as a supported memory allocator.
1819 gst_query_add_allocation_param (GstQuery * query, GstAllocator * allocator,
1820 const GstAllocationParams * params)
1823 GstStructure *structure;
1826 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_ALLOCATION);
1827 g_return_if_fail (gst_query_is_writable (query));
1828 g_return_if_fail (allocator != NULL || params != NULL);
1830 structure = GST_QUERY_STRUCTURE (query);
1831 array = ensure_array (structure, GST_QUARK (ALLOCATOR),
1832 sizeof (AllocationParam), (GDestroyNotify) allocation_param_free);
1834 if ((ap.allocator = allocator))
1835 gst_allocator_ref (allocator);
1837 ap.params = *params;
1839 gst_allocation_params_init (&ap.params);
1841 g_array_append_val (array, ap);
1845 * gst_query_get_n_allocation_params:
1846 * @query: a GST_QUERY_ALLOCATION type query #GstQuery
1848 * Retrieve the number of values currently stored in the
1849 * allocator params array of the query's structure.
1851 * If no memory allocator is specified, the downstream element can handle
1852 * the default memory allocator.
1854 * Returns: the allocator array size as a #guint.
1857 gst_query_get_n_allocation_params (GstQuery * query)
1860 GstStructure *structure;
1862 g_return_val_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_ALLOCATION, 0);
1864 structure = GST_QUERY_STRUCTURE (query);
1865 array = ensure_array (structure, GST_QUARK (ALLOCATOR),
1866 sizeof (AllocationParam), (GDestroyNotify) allocation_param_free);
1872 * gst_query_parse_nth_allocation_param:
1873 * @query: a GST_QUERY_ALLOCATION type query #GstQuery
1874 * @index: position in the allocator array to read
1875 * @allocator: (transfer none): variable to hold the result
1876 * @params: parameters for the allocator
1878 * Parse an available query and get the alloctor and its params
1879 * at @index of the allocator array.
1882 gst_query_parse_nth_allocation_param (GstQuery * query, guint index,
1883 GstAllocator ** allocator, GstAllocationParams * params)
1886 GstStructure *structure;
1887 AllocationParam *ap;
1889 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_ALLOCATION);
1891 structure = GST_QUERY_STRUCTURE (query);
1892 array = ensure_array (structure, GST_QUARK (ALLOCATOR),
1893 sizeof (AllocationParam), (GDestroyNotify) allocation_param_free);
1894 g_return_if_fail (index < array->len);
1896 ap = &g_array_index (array, AllocationParam, index);
1899 if ((*allocator = ap->allocator))
1900 gst_allocator_ref (*allocator);
1902 *params = ap->params;
1906 * gst_query_set_nth_allocation_param:
1907 * @query: a GST_QUERY_ALLOCATION type query #GstQuery
1908 * @index: position in the allocator array to set
1909 * @allocator: (transfer full): new allocator to set
1910 * @params: parameters for the allocator
1912 * Parse an available query and get the alloctor and its params
1913 * at @index of the allocator array.
1916 gst_query_set_nth_allocation_param (GstQuery * query, guint index,
1917 GstAllocator * allocator, const GstAllocationParams * params)
1920 GstStructure *structure;
1921 AllocationParam *old, ap;
1923 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_ALLOCATION);
1925 structure = GST_QUERY_STRUCTURE (query);
1926 array = ensure_array (structure, GST_QUARK (ALLOCATOR),
1927 sizeof (AllocationParam), (GDestroyNotify) allocation_param_free);
1928 g_return_if_fail (index < array->len);
1930 old = &g_array_index (array, AllocationParam, index);
1931 allocation_param_free (old);
1933 if ((ap.allocator = allocator))
1934 gst_allocator_ref (allocator);
1936 ap.params = *params;
1938 gst_allocation_params_init (&ap.params);
1940 g_array_index (array, AllocationParam, index) = ap;
1944 * gst_query_new_scheduling:
1946 * Constructs a new query object for querying the scheduling properties.
1948 * Free-function: gst_query_unref
1950 * Returns: (transfer full): a new #GstQuery
1953 gst_query_new_scheduling (void)
1956 GstStructure *structure;
1958 structure = gst_structure_new_id (GST_QUARK (QUERY_SCHEDULING),
1959 GST_QUARK (FLAGS), GST_TYPE_SCHEDULING_FLAGS, 0,
1960 GST_QUARK (MINSIZE), G_TYPE_INT, 1,
1961 GST_QUARK (MAXSIZE), G_TYPE_INT, -1,
1962 GST_QUARK (ALIGN), G_TYPE_INT, 0, NULL);
1963 query = gst_query_new_custom (GST_QUERY_SCHEDULING, structure);
1969 * gst_query_set_scheduling:
1970 * @query: A valid #GstQuery of type GST_QUERY_SCHEDULING.
1971 * @flags: #GstSchedulingFlags
1972 * @minsize: the suggested minimum size of pull requests
1973 * @maxsize: the suggested maximum size of pull requests
1974 * @align: the suggested alignment of pull requests
1976 * Set the scheduling properties.
1979 gst_query_set_scheduling (GstQuery * query, GstSchedulingFlags flags,
1980 gint minsize, gint maxsize, gint align)
1982 GstStructure *structure;
1984 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_SCHEDULING);
1985 g_return_if_fail (gst_query_is_writable (query));
1987 structure = GST_QUERY_STRUCTURE (query);
1988 gst_structure_id_set (structure,
1989 GST_QUARK (FLAGS), GST_TYPE_SCHEDULING_FLAGS, flags,
1990 GST_QUARK (MINSIZE), G_TYPE_INT, minsize,
1991 GST_QUARK (MAXSIZE), G_TYPE_INT, maxsize,
1992 GST_QUARK (ALIGN), G_TYPE_INT, align, NULL);
1996 * gst_query_parse_scheduling:
1997 * @query: A valid #GstQuery of type GST_QUERY_SCHEDULING.
1998 * @flags: (out) (allow-none): #GstSchedulingFlags
1999 * @minsize: (out) (allow-none): the suggested minimum size of pull requests
2000 * @maxsize: (out) (allow-none): the suggested maximum size of pull requests:
2001 * @align: (out) (allow-none): the suggested alignment of pull requests
2003 * Set the scheduling properties.
2006 gst_query_parse_scheduling (GstQuery * query, GstSchedulingFlags * flags,
2007 gint * minsize, gint * maxsize, gint * align)
2009 GstStructure *structure;
2011 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_SCHEDULING);
2013 structure = GST_QUERY_STRUCTURE (query);
2014 gst_structure_id_get (structure,
2015 GST_QUARK (FLAGS), GST_TYPE_SCHEDULING_FLAGS, flags,
2016 GST_QUARK (MINSIZE), G_TYPE_INT, minsize,
2017 GST_QUARK (MAXSIZE), G_TYPE_INT, maxsize,
2018 GST_QUARK (ALIGN), G_TYPE_INT, align, NULL);
2022 * gst_query_add_scheduling_mode:
2023 * @query: a GST_QUERY_SCHEDULING type query #GstQuery
2024 * @mode: a #GstPadMode
2026 * Add @mode as aone of the supported scheduling modes to @query.
2029 gst_query_add_scheduling_mode (GstQuery * query, GstPadMode mode)
2031 GstStructure *structure;
2034 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_SCHEDULING);
2035 g_return_if_fail (gst_query_is_writable (query));
2037 structure = GST_QUERY_STRUCTURE (query);
2039 ensure_array (structure, GST_QUARK (MODES), sizeof (GstPadMode), NULL);
2041 g_array_append_val (array, mode);
2045 * gst_query_get_n_scheduling_modes:
2046 * @query: a GST_QUERY_SCHEDULING type query #GstQuery
2048 * Retrieve the number of values currently stored in the
2049 * scheduling mode array of the query's structure.
2051 * Returns: the scheduling mode array size as a #guint.
2054 gst_query_get_n_scheduling_modes (GstQuery * query)
2057 GstStructure *structure;
2059 g_return_val_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_SCHEDULING, 0);
2061 structure = GST_QUERY_STRUCTURE (query);
2063 ensure_array (structure, GST_QUARK (MODES), sizeof (GstPadMode), NULL);
2069 * gst_query_parse_nth_scheduling_mode:
2070 * @query: a GST_QUERY_SCHEDULING type query #GstQuery
2071 * @index: position in the scheduling modes array to read
2073 * Parse an available query and get the scheduling mode
2074 * at @index of the scheduling modes array.
2076 * Returns: a #GstPadMode of the scheduling mode at @index.
2079 gst_query_parse_nth_scheduling_mode (GstQuery * query, guint index)
2081 GstStructure *structure;
2084 g_return_val_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_SCHEDULING,
2087 structure = GST_QUERY_STRUCTURE (query);
2089 ensure_array (structure, GST_QUARK (MODES), sizeof (GstPadMode), NULL);
2090 g_return_val_if_fail (index < array->len, GST_PAD_MODE_NONE);
2092 return g_array_index (array, GstPadMode, index);
2096 * gst_query_has_scheduling_mode:
2097 * @query: a GST_QUERY_SCHEDULING type query #GstQuery
2098 * @mode: the scheduling mode
2100 * Check if @query has scheduling mode set.
2102 * Returns: TRUE when @mode is in the list of scheduling modes.
2105 gst_query_has_scheduling_mode (GstQuery * query, GstPadMode mode)
2107 GstStructure *structure;
2111 g_return_val_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_SCHEDULING, FALSE);
2113 structure = GST_QUERY_STRUCTURE (query);
2115 ensure_array (structure, GST_QUARK (MODES), sizeof (GstPadMode), NULL);
2118 for (i = 0; i < len; i++) {
2119 if (mode == g_array_index (array, GstPadMode, i))
2126 * gst_query_new_accept_caps:
2127 * @caps: a fixed #GstCaps
2129 * Constructs a new query object for querying if @caps are accepted.
2131 * Free-function: gst_query_unref
2133 * Returns: (transfer full): a new #GstQuery
2136 gst_query_new_accept_caps (GstCaps * caps)
2139 GstStructure *structure;
2141 g_return_val_if_fail (gst_caps_is_fixed (caps), NULL);
2143 structure = gst_structure_new_id (GST_QUARK (QUERY_ACCEPT_CAPS),
2144 GST_QUARK (CAPS), GST_TYPE_CAPS, caps,
2145 GST_QUARK (RESULT), G_TYPE_BOOLEAN, FALSE, NULL);
2146 query = gst_query_new_custom (GST_QUERY_ACCEPT_CAPS, structure);
2152 * gst_query_parse_accept_caps:
2153 * @query: The query to parse
2154 * @caps: (out): A pointer to the caps
2156 * Get the caps from @query. The caps remains valid as long as @query remains
2160 gst_query_parse_accept_caps (GstQuery * query, GstCaps ** caps)
2162 GstStructure *structure;
2164 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_ACCEPT_CAPS);
2165 g_return_if_fail (caps != NULL);
2167 structure = GST_QUERY_STRUCTURE (query);
2168 *caps = g_value_get_boxed (gst_structure_id_get_value (structure,
2173 gst_query_set_accept_caps_result (GstQuery * query, gboolean result)
2175 GstStructure *structure;
2177 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_ACCEPT_CAPS);
2178 g_return_if_fail (gst_query_is_writable (query));
2180 structure = GST_QUERY_STRUCTURE (query);
2181 gst_structure_id_set (structure,
2182 GST_QUARK (RESULT), G_TYPE_BOOLEAN, result, NULL);
2186 gst_query_parse_accept_caps_result (GstQuery * query, gboolean * result)
2188 GstStructure *structure;
2190 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_ACCEPT_CAPS);
2192 structure = GST_QUERY_STRUCTURE (query);
2193 gst_structure_id_get (structure,
2194 GST_QUARK (RESULT), G_TYPE_BOOLEAN, result, NULL);
2198 * gst_query_new_caps:
2201 * Constructs a new query object for querying the caps.
2203 * The CAPS query should return the allowable caps for a pad in the context
2204 * of the element's state, its link to other elements, and the devices or files
2205 * it has opened. These caps must be a subset of the pad template caps. In the
2206 * NULL state with no links, the CAPS query should ideally return the same caps
2207 * as the pad template. In rare circumstances, an object property can affect
2208 * the caps returned by the CAPS query, but this is discouraged.
2210 * For most filters, the caps returned by CAPS query is directly affected by the
2211 * allowed caps on other pads. For demuxers and decoders, the caps returned by
2212 * the srcpad's getcaps function is directly related to the stream data. Again,
2213 * the CAPS query should return the most specific caps it reasonably can, since this
2214 * helps with autoplugging.
2216 * The @filter is used to restrict the result caps, only the caps matching
2217 * @filter should be returned from the CAPS query. Specifying a filter might
2218 * greatly reduce the amount of processing an element needs to do.
2220 * Free-function: gst_query_unref
2222 * Returns: (transfer full): a new #GstQuery
2225 gst_query_new_caps (GstCaps * filter)
2228 GstStructure *structure;
2230 structure = gst_structure_new_id (GST_QUARK (QUERY_CAPS),
2231 GST_QUARK (FILTER), GST_TYPE_CAPS, filter,
2232 GST_QUARK (CAPS), GST_TYPE_CAPS, NULL, NULL);
2233 query = gst_query_new_custom (GST_QUERY_CAPS, structure);
2239 * gst_query_parse_caps:
2240 * @query: The query to parse
2241 * @filter: (out): A pointer to the caps filter
2243 * Get the filter from the caps @query. The caps remains valid as long as
2244 * @query remains valid.
2247 gst_query_parse_caps (GstQuery * query, GstCaps ** filter)
2249 GstStructure *structure;
2251 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_CAPS);
2252 g_return_if_fail (filter != NULL);
2254 structure = GST_QUERY_STRUCTURE (query);
2255 *filter = g_value_get_boxed (gst_structure_id_get_value (structure,
2256 GST_QUARK (FILTER)));
2260 * gst_query_set_caps_result:
2261 * @query: The query to use
2262 * @caps: (in): A pointer to the caps
2264 * Set the @caps result in @query.
2267 gst_query_set_caps_result (GstQuery * query, GstCaps * caps)
2269 GstStructure *structure;
2271 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_CAPS);
2272 g_return_if_fail (gst_query_is_writable (query));
2274 structure = GST_QUERY_STRUCTURE (query);
2275 gst_structure_id_set (structure, GST_QUARK (CAPS), GST_TYPE_CAPS, caps, NULL);
2279 * gst_query_parse_caps_result:
2280 * @query: The query to parse
2281 * @caps: (out): A pointer to the caps
2283 * Get the caps result from @query. The caps remains valid as long as
2284 * @query remains valid.
2287 gst_query_parse_caps_result (GstQuery * query, GstCaps ** caps)
2289 GstStructure *structure;
2291 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_CAPS);
2292 g_return_if_fail (caps != NULL);
2294 structure = GST_QUERY_STRUCTURE (query);
2295 *caps = g_value_get_boxed (gst_structure_id_get_value (structure,
2300 gst_query_intersect_caps_result (GstQuery * query, GstCaps * filter,
2301 GstCapsIntersectMode mode)
2303 GstCaps *res, *caps = NULL;
2305 gst_query_parse_caps_result (query, &caps);
2306 res = gst_caps_intersect_full (filter, caps, GST_CAPS_INTERSECT_FIRST);
2307 gst_query_set_caps_result (query, res);
2308 gst_caps_unref (res);
2312 * gst_query_new_drain:
2314 * Constructs a new query object for querying the drain state.
2316 * Free-function: gst_query_unref
2318 * Returns: (transfer full): a new #GstQuery
2321 gst_query_new_drain (void)
2324 GstStructure *structure;
2326 structure = gst_structure_new_id_empty (GST_QUARK (QUERY_DRAIN));
2327 query = gst_query_new_custom (GST_QUERY_DRAIN, structure);
2333 * gst_query_new_toc:
2335 * Constructs a new query TOC query object. Use gst_query_unref()
2336 * when done with it. A TOC query is used to query the full TOC with
2337 * the UID marker for TOC extending (to insert some new entries).
2339 * Returns: A #GstQuery.
2342 gst_query_new_toc (void)
2345 GstStructure *structure;
2347 structure = gst_structure_new_id_empty (GST_QUARK (QUERY_TOC));
2348 query = gst_query_new_custom (GST_QUERY_TOC, structure);
2354 * gst_query_set_toc:
2355 * @query: a #GstQuery with query type GST_QUERY_TOC.
2356 * @toc: the GstToc to set.
2357 * @extend_uid: UID which can be used for TOC extending (may be NULL),
2358 * 0 means root TOC level.
2360 * Answer a TOC query by setting appropriate #GstToc structure.
2363 gst_query_set_toc (GstQuery * query, GstToc * toc, const gchar * extend_uid)
2365 GstStructure *structure;
2366 GstStructure *old_structure;
2368 g_return_if_fail (query != NULL);
2369 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_TOC);
2370 g_return_if_fail (toc != NULL);
2372 structure = __gst_toc_to_structure (toc);
2374 g_return_if_fail (structure != NULL);
2376 /* that shouldn't be happen in normal usage */
2377 old_structure = GST_QUERY_STRUCTURE (query);
2378 if (old_structure) {
2379 gst_structure_set_parent_refcount (old_structure, NULL);
2380 gst_structure_free (old_structure);
2383 if (extend_uid != NULL)
2384 __gst_toc_structure_set_extend_uid (structure, extend_uid);
2386 gst_structure_set_parent_refcount (structure, &(query->mini_object.refcount));
2387 GST_QUERY_STRUCTURE (query) = structure;
2391 * gst_query_parse_toc:
2392 * @query: a #GstQuery.
2393 * @toc: (out): the storage for the received TOC (may be NULL).
2394 * @extend_uid: (out): the storage for the received extend UID marker (may be NULL),
2395 * 0 means root TOC level.
2397 * Parse a TOC query, writing the TOC into @toc as a newly
2398 * allocated #GstToc and extend UID into @extend_uid, if the respective parameters
2399 * are non-NULL. Use @extend_uid value to insert new entries into the TOC (@extend_uid will
2400 * act as root entry for newly inserted entries).
2401 * Free @toc with gst_toc_free() and @extend_uid with g_free() after usage.
2404 gst_query_parse_toc (GstQuery * query, GstToc ** toc, gchar ** extend_uid)
2406 const GstStructure *structure;
2408 g_return_if_fail (query != NULL);
2409 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_TOC);
2411 structure = gst_query_get_structure (query);
2413 g_return_if_fail (structure != NULL);
2416 *toc = __gst_toc_from_structure (structure);
2418 if (extend_uid != NULL)
2419 *extend_uid = __gst_toc_structure_get_extend_uid (structure);