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., 51 Franklin St, Fifth Floor,
21 * Boston, MA 02110-1301, 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;
81 GstStructure *structure;
84 #define GST_QUERY_STRUCTURE(q) (((GstQueryImpl *)(q))->structure)
94 static GstQueryQuarks query_quarks[] = {
95 {GST_QUERY_UNKNOWN, "unknown", 0},
96 {GST_QUERY_POSITION, "position", 0},
97 {GST_QUERY_DURATION, "duration", 0},
98 {GST_QUERY_LATENCY, "latency", 0},
99 {GST_QUERY_JITTER, "jitter", 0},
100 {GST_QUERY_RATE, "rate", 0},
101 {GST_QUERY_SEEKING, "seeking", 0},
102 {GST_QUERY_SEGMENT, "segment", 0},
103 {GST_QUERY_CONVERT, "convert", 0},
104 {GST_QUERY_FORMATS, "formats", 0},
105 {GST_QUERY_BUFFERING, "buffering", 0},
106 {GST_QUERY_CUSTOM, "custom", 0},
107 {GST_QUERY_URI, "uri", 0},
108 {GST_QUERY_ALLOCATION, "allocation", 0},
109 {GST_QUERY_SCHEDULING, "scheduling", 0},
110 {GST_QUERY_ACCEPT_CAPS, "accept-caps", 0},
111 {GST_QUERY_CAPS, "caps", 0},
112 {GST_QUERY_DRAIN, "drain", 0},
117 GST_DEFINE_MINI_OBJECT_TYPE (GstQuery, gst_query);
120 _priv_gst_query_initialize (void)
124 _gst_query_type = gst_query_get_type ();
126 GST_DEBUG_CATEGORY_INIT (gst_query_debug, "query", 0, "query system");
128 for (i = 0; query_quarks[i].name; i++) {
129 query_quarks[i].quark = g_quark_from_static_string (query_quarks[i].name);
134 * gst_query_type_get_name:
135 * @type: the query type
137 * Get a printable name for the given query type. Do not modify or free.
139 * Returns: a reference to the static name of the query.
142 gst_query_type_get_name (GstQueryType type)
146 for (i = 0; query_quarks[i].name; i++) {
147 if (type == query_quarks[i].type)
148 return query_quarks[i].name;
154 * gst_query_type_to_quark:
155 * @type: the query type
157 * Get the unique quark for the given query type.
159 * Returns: the quark associated with the query type
162 gst_query_type_to_quark (GstQueryType type)
166 for (i = 0; query_quarks[i].name; i++) {
167 if (type == query_quarks[i].type)
168 return query_quarks[i].quark;
174 * gst_query_type_get_flags:
175 * @type: a #GstQueryType
177 * Gets the #GstQueryTypeFlags associated with @type.
179 * Returns: a #GstQueryTypeFlags.
182 gst_query_type_get_flags (GstQueryType type)
184 GstQueryTypeFlags ret;
186 ret = type & ((1 << GST_QUERY_NUM_SHIFT) - 1);
192 _gst_query_free (GstQuery * query)
196 g_return_if_fail (query != NULL);
198 s = GST_QUERY_STRUCTURE (query);
200 gst_structure_set_parent_refcount (s, NULL);
201 gst_structure_free (s);
204 g_slice_free1 (sizeof (GstQueryImpl), query);
208 _gst_query_copy (GstQuery * query)
213 s = GST_QUERY_STRUCTURE (query);
215 s = gst_structure_copy (s);
217 copy = gst_query_new_custom (query->type, s);
223 * gst_query_new_position:
224 * @format: the default #GstFormat for the new query
226 * Constructs a new query stream position query object. Use gst_query_unref()
227 * when done with it. A position query is used to query the current position
228 * of playback in the streams, in some format.
230 * Free-function: gst_query_unref
232 * Returns: (transfer full): a new #GstQuery
235 gst_query_new_position (GstFormat format)
238 GstStructure *structure;
240 structure = gst_structure_new_id (GST_QUARK (QUERY_POSITION),
241 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
242 GST_QUARK (CURRENT), G_TYPE_INT64, G_GINT64_CONSTANT (-1), NULL);
244 query = gst_query_new_custom (GST_QUERY_POSITION, structure);
250 * gst_query_set_position:
251 * @query: a #GstQuery with query type GST_QUERY_POSITION
252 * @format: the requested #GstFormat
253 * @cur: the position to set
255 * Answer a position query by setting the requested value in the given format.
258 gst_query_set_position (GstQuery * query, GstFormat format, gint64 cur)
262 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_POSITION);
264 s = GST_QUERY_STRUCTURE (query);
265 g_return_if_fail (format == g_value_get_enum (gst_structure_id_get_value (s,
266 GST_QUARK (FORMAT))));
268 gst_structure_id_set (s,
269 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
270 GST_QUARK (CURRENT), G_TYPE_INT64, cur, NULL);
274 * gst_query_parse_position:
275 * @query: a #GstQuery
276 * @format: (out) (allow-none): the storage for the #GstFormat of the
277 * position values (may be NULL)
278 * @cur: (out) (allow-none): the storage for the current position (may be NULL)
280 * Parse a position query, writing the format into @format, and the position
281 * into @cur, if the respective parameters are non-NULL.
284 gst_query_parse_position (GstQuery * query, GstFormat * format, gint64 * cur)
286 GstStructure *structure;
288 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_POSITION);
290 structure = GST_QUERY_STRUCTURE (query);
293 (GstFormat) g_value_get_enum (gst_structure_id_get_value (structure,
294 GST_QUARK (FORMAT)));
296 *cur = g_value_get_int64 (gst_structure_id_get_value (structure,
297 GST_QUARK (CURRENT)));
302 * gst_query_new_duration:
303 * @format: the #GstFormat for this duration query
305 * Constructs a new stream duration query object to query in the given format.
306 * Use gst_query_unref() when done with it. A duration query will give the
307 * total length of the stream.
309 * Free-function: gst_query_unref
311 * Returns: (transfer full): a new #GstQuery
314 gst_query_new_duration (GstFormat format)
317 GstStructure *structure;
319 structure = gst_structure_new_id (GST_QUARK (QUERY_DURATION),
320 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
321 GST_QUARK (DURATION), G_TYPE_INT64, G_GINT64_CONSTANT (-1), NULL);
323 query = gst_query_new_custom (GST_QUERY_DURATION, structure);
329 * gst_query_set_duration:
330 * @query: a #GstQuery
331 * @format: the #GstFormat for the duration
332 * @duration: the duration of the stream
334 * Answer a duration query by setting the requested value in the given format.
337 gst_query_set_duration (GstQuery * query, GstFormat format, gint64 duration)
341 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_DURATION);
343 s = GST_QUERY_STRUCTURE (query);
344 g_return_if_fail (format == g_value_get_enum (gst_structure_id_get_value (s,
345 GST_QUARK (FORMAT))));
346 gst_structure_id_set (s, GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
347 GST_QUARK (DURATION), G_TYPE_INT64, duration, NULL);
351 * gst_query_parse_duration:
352 * @query: a #GstQuery
353 * @format: (out) (allow-none): the storage for the #GstFormat of the duration
355 * @duration: (out) (allow-none): the storage for the total duration, or NULL.
357 * Parse a duration query answer. Write the format of the duration into @format,
358 * and the value into @duration, if the respective variables are non-NULL.
361 gst_query_parse_duration (GstQuery * query, GstFormat * format,
364 GstStructure *structure;
366 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_DURATION);
368 structure = GST_QUERY_STRUCTURE (query);
371 (GstFormat) g_value_get_enum (gst_structure_id_get_value (structure,
372 GST_QUARK (FORMAT)));
374 *duration = g_value_get_int64 (gst_structure_id_get_value (structure,
375 GST_QUARK (DURATION)));
379 * gst_query_new_latency:
381 * Constructs a new latency query object.
382 * Use gst_query_unref() when done with it. A latency query is usually performed
383 * by sinks to compensate for additional latency introduced by elements in the
386 * Free-function: gst_query_unref
388 * Returns: (transfer full): a #GstQuery
391 gst_query_new_latency (void)
394 GstStructure *structure;
396 structure = gst_structure_new_id (GST_QUARK (QUERY_LATENCY),
397 GST_QUARK (LIVE), G_TYPE_BOOLEAN, FALSE,
398 GST_QUARK (MIN_LATENCY), G_TYPE_UINT64, G_GUINT64_CONSTANT (0),
399 GST_QUARK (MAX_LATENCY), G_TYPE_UINT64, G_GUINT64_CONSTANT (-1), NULL);
401 query = gst_query_new_custom (GST_QUERY_LATENCY, structure);
407 * gst_query_set_latency:
408 * @query: a #GstQuery
409 * @live: if there is a live element upstream
410 * @min_latency: the minimal latency of the upstream elements
411 * @max_latency: the maximal latency of the upstream elements
413 * Answer a latency query by setting the requested values in the given format.
416 gst_query_set_latency (GstQuery * query, gboolean live,
417 GstClockTime min_latency, GstClockTime max_latency)
419 GstStructure *structure;
421 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_LATENCY);
423 structure = GST_QUERY_STRUCTURE (query);
424 gst_structure_id_set (structure,
425 GST_QUARK (LIVE), G_TYPE_BOOLEAN, live,
426 GST_QUARK (MIN_LATENCY), G_TYPE_UINT64, min_latency,
427 GST_QUARK (MAX_LATENCY), G_TYPE_UINT64, max_latency, NULL);
431 * gst_query_parse_latency:
432 * @query: a #GstQuery
433 * @live: (out) (allow-none): storage for live or NULL
434 * @min_latency: (out) (allow-none): the storage for the min latency or NULL
435 * @max_latency: (out) (allow-none): the storage for the max latency or NULL
437 * Parse a latency query answer.
440 gst_query_parse_latency (GstQuery * query, gboolean * live,
441 GstClockTime * min_latency, GstClockTime * max_latency)
443 GstStructure *structure;
445 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_LATENCY);
447 structure = GST_QUERY_STRUCTURE (query);
450 g_value_get_boolean (gst_structure_id_get_value (structure,
453 *min_latency = g_value_get_uint64 (gst_structure_id_get_value (structure,
454 GST_QUARK (MIN_LATENCY)));
456 *max_latency = g_value_get_uint64 (gst_structure_id_get_value (structure,
457 GST_QUARK (MAX_LATENCY)));
461 * gst_query_new_convert:
462 * @src_format: the source #GstFormat for the new query
463 * @value: the value to convert
464 * @dest_format: the target #GstFormat
466 * Constructs a new convert query object. Use gst_query_unref()
467 * when done with it. A convert query is used to ask for a conversion between
468 * one format and another.
470 * Free-function: gst_query_unref
472 * Returns: (transfer full): a #GstQuery
475 gst_query_new_convert (GstFormat src_format, gint64 value,
476 GstFormat dest_format)
479 GstStructure *structure;
481 structure = gst_structure_new_id (GST_QUARK (QUERY_CONVERT),
482 GST_QUARK (SRC_FORMAT), GST_TYPE_FORMAT, src_format,
483 GST_QUARK (SRC_VALUE), G_TYPE_INT64, value,
484 GST_QUARK (DEST_FORMAT), GST_TYPE_FORMAT, dest_format,
485 GST_QUARK (DEST_VALUE), G_TYPE_INT64, G_GINT64_CONSTANT (-1), NULL);
487 query = gst_query_new_custom (GST_QUERY_CONVERT, structure);
493 * gst_query_set_convert:
494 * @query: a #GstQuery
495 * @src_format: the source #GstFormat
496 * @src_value: the source value
497 * @dest_format: the destination #GstFormat
498 * @dest_value: the destination value
500 * Answer a convert query by setting the requested values.
503 gst_query_set_convert (GstQuery * query, GstFormat src_format, gint64 src_value,
504 GstFormat dest_format, gint64 dest_value)
506 GstStructure *structure;
508 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_CONVERT);
510 structure = GST_QUERY_STRUCTURE (query);
511 gst_structure_id_set (structure,
512 GST_QUARK (SRC_FORMAT), GST_TYPE_FORMAT, src_format,
513 GST_QUARK (SRC_VALUE), G_TYPE_INT64, src_value,
514 GST_QUARK (DEST_FORMAT), GST_TYPE_FORMAT, dest_format,
515 GST_QUARK (DEST_VALUE), G_TYPE_INT64, dest_value, NULL);
519 * gst_query_parse_convert:
520 * @query: a #GstQuery
521 * @src_format: (out) (allow-none): the storage for the #GstFormat of the
522 * source value, or NULL
523 * @src_value: (out) (allow-none): the storage for the source value, or NULL
524 * @dest_format: (out) (allow-none): the storage for the #GstFormat of the
525 * destination value, or NULL
526 * @dest_value: (out) (allow-none): the storage for the destination value,
529 * Parse a convert query answer. Any of @src_format, @src_value, @dest_format,
530 * and @dest_value may be NULL, in which case that value is omitted.
533 gst_query_parse_convert (GstQuery * query, GstFormat * src_format,
534 gint64 * src_value, GstFormat * dest_format, gint64 * dest_value)
536 GstStructure *structure;
538 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_CONVERT);
540 structure = GST_QUERY_STRUCTURE (query);
543 (GstFormat) g_value_get_enum (gst_structure_id_get_value (structure,
544 GST_QUARK (SRC_FORMAT)));
546 *src_value = g_value_get_int64 (gst_structure_id_get_value (structure,
547 GST_QUARK (SRC_VALUE)));
550 (GstFormat) g_value_get_enum (gst_structure_id_get_value (structure,
551 GST_QUARK (DEST_FORMAT)));
553 *dest_value = g_value_get_int64 (gst_structure_id_get_value (structure,
554 GST_QUARK (DEST_VALUE)));
558 * gst_query_new_segment:
559 * @format: the #GstFormat for the new query
561 * Constructs a new segment query object. Use gst_query_unref()
562 * when done with it. A segment query is used to discover information about the
563 * currently configured segment for playback.
565 * Free-function: gst_query_unref
567 * Returns: (transfer full): a new #GstQuery
570 gst_query_new_segment (GstFormat format)
573 GstStructure *structure;
575 structure = gst_structure_new_id (GST_QUARK (QUERY_SEGMENT),
576 GST_QUARK (RATE), G_TYPE_DOUBLE, (gdouble) 0.0,
577 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
578 GST_QUARK (START_VALUE), G_TYPE_INT64, G_GINT64_CONSTANT (-1),
579 GST_QUARK (STOP_VALUE), G_TYPE_INT64, G_GINT64_CONSTANT (-1), NULL);
581 query = gst_query_new_custom (GST_QUERY_SEGMENT, structure);
587 * gst_query_set_segment:
588 * @query: a #GstQuery
589 * @rate: the rate of the segment
590 * @format: the #GstFormat of the segment values (@start_value and @stop_value)
591 * @start_value: the start value
592 * @stop_value: the stop value
594 * Answer a segment query by setting the requested values. The normal
595 * playback segment of a pipeline is 0 to duration at the default rate of
596 * 1.0. If a seek was performed on the pipeline to play a different
597 * segment, this query will return the range specified in the last seek.
599 * @start_value and @stop_value will respectively contain the configured
600 * playback range start and stop values expressed in @format.
601 * The values are always between 0 and the duration of the media and
602 * @start_value <= @stop_value. @rate will contain the playback rate. For
603 * negative rates, playback will actually happen from @stop_value to
607 gst_query_set_segment (GstQuery * query, gdouble rate, GstFormat format,
608 gint64 start_value, gint64 stop_value)
610 GstStructure *structure;
612 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_SEGMENT);
614 structure = GST_QUERY_STRUCTURE (query);
615 gst_structure_id_set (structure,
616 GST_QUARK (RATE), G_TYPE_DOUBLE, rate,
617 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
618 GST_QUARK (START_VALUE), G_TYPE_INT64, start_value,
619 GST_QUARK (STOP_VALUE), G_TYPE_INT64, stop_value, NULL);
623 * gst_query_parse_segment:
624 * @query: a #GstQuery
625 * @rate: (out) (allow-none): the storage for the rate of the segment, or NULL
626 * @format: (out) (allow-none): the storage for the #GstFormat of the values,
628 * @start_value: (out) (allow-none): the storage for the start value, or NULL
629 * @stop_value: (out) (allow-none): the storage for the stop value, or NULL
631 * Parse a segment query answer. Any of @rate, @format, @start_value, and
632 * @stop_value may be NULL, which will cause this value to be omitted.
634 * See gst_query_set_segment() for an explanation of the function arguments.
637 gst_query_parse_segment (GstQuery * query, gdouble * rate, GstFormat * format,
638 gint64 * start_value, gint64 * stop_value)
640 GstStructure *structure;
642 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_SEGMENT);
644 structure = GST_QUERY_STRUCTURE (query);
646 *rate = g_value_get_double (gst_structure_id_get_value (structure,
650 (GstFormat) g_value_get_enum (gst_structure_id_get_value (structure,
651 GST_QUARK (FORMAT)));
653 *start_value = g_value_get_int64 (gst_structure_id_get_value (structure,
654 GST_QUARK (START_VALUE)));
656 *stop_value = g_value_get_int64 (gst_structure_id_get_value (structure,
657 GST_QUARK (STOP_VALUE)));
661 * gst_query_new_custom:
662 * @type: the query type
663 * @structure: a structure for the query
665 * Constructs a new custom query object. Use gst_query_unref()
668 * Free-function: gst_query_unref
670 * Returns: (transfer full): a new #GstQuery
673 gst_query_new_custom (GstQueryType type, GstStructure * structure)
677 query = g_slice_new0 (GstQueryImpl);
679 GST_DEBUG ("creating new query %p %s", query, gst_query_type_get_name (type));
682 /* structure must not have a parent */
683 if (!gst_structure_set_parent_refcount (structure,
684 &query->query.mini_object.refcount))
688 gst_mini_object_init (GST_MINI_OBJECT_CAST (query), 0, _gst_query_type,
689 (GstMiniObjectCopyFunction) _gst_query_copy, NULL,
690 (GstMiniObjectFreeFunction) _gst_query_free);
692 GST_QUERY_TYPE (query) = type;
693 GST_QUERY_STRUCTURE (query) = structure;
695 return GST_QUERY_CAST (query);
700 g_slice_free1 (sizeof (GstQueryImpl), query);
701 g_warning ("structure is already owned by another object");
707 * gst_query_get_structure:
708 * @query: a #GstQuery
710 * Get the structure of a query.
712 * Returns: (transfer none): the #GstStructure of the query. The structure is
713 * still owned by the query and will therefore be freed when the query
717 gst_query_get_structure (GstQuery * query)
719 g_return_val_if_fail (GST_IS_QUERY (query), NULL);
721 return GST_QUERY_STRUCTURE (query);
725 * gst_query_writable_structure:
726 * @query: a #GstQuery
728 * Get the structure of a query. This method should be called with a writable
729 * @query so that the returned structure is guranteed to be writable.
731 * Returns: (transfer none): the #GstStructure of the query. The structure is
732 * still owned by the query and will therefore be freed when the query
736 gst_query_writable_structure (GstQuery * query)
738 g_return_val_if_fail (GST_IS_QUERY (query), NULL);
739 g_return_val_if_fail (gst_query_is_writable (query), NULL);
741 return GST_QUERY_STRUCTURE (query);
745 * gst_query_new_seeking:
746 * @format: the default #GstFormat for the new query
748 * Constructs a new query object for querying seeking properties of
751 * Free-function: gst_query_unref
753 * Returns: (transfer full): a new #GstQuery
756 gst_query_new_seeking (GstFormat format)
759 GstStructure *structure;
761 structure = gst_structure_new_id (GST_QUARK (QUERY_SEEKING),
762 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
763 GST_QUARK (SEEKABLE), G_TYPE_BOOLEAN, FALSE,
764 GST_QUARK (SEGMENT_START), G_TYPE_INT64, G_GINT64_CONSTANT (-1),
765 GST_QUARK (SEGMENT_END), G_TYPE_INT64, G_GINT64_CONSTANT (-1), NULL);
767 query = gst_query_new_custom (GST_QUERY_SEEKING, structure);
773 * gst_query_set_seeking:
774 * @query: a #GstQuery
775 * @format: the format to set for the @segment_start and @segment_end values
776 * @seekable: the seekable flag to set
777 * @segment_start: the segment_start to set
778 * @segment_end: the segment_end to set
780 * Set the seeking query result fields in @query.
783 gst_query_set_seeking (GstQuery * query, GstFormat format,
784 gboolean seekable, gint64 segment_start, gint64 segment_end)
786 GstStructure *structure;
788 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_SEEKING);
789 g_return_if_fail (gst_query_is_writable (query));
791 structure = GST_QUERY_STRUCTURE (query);
792 gst_structure_id_set (structure,
793 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
794 GST_QUARK (SEEKABLE), G_TYPE_BOOLEAN, seekable,
795 GST_QUARK (SEGMENT_START), G_TYPE_INT64, segment_start,
796 GST_QUARK (SEGMENT_END), G_TYPE_INT64, segment_end, NULL);
800 * gst_query_parse_seeking:
801 * @query: a GST_QUERY_SEEKING type query #GstQuery
802 * @format: (out) (allow-none): the format to set for the @segment_start
803 * and @segment_end values, or NULL
804 * @seekable: (out) (allow-none): the seekable flag to set, or NULL
805 * @segment_start: (out) (allow-none): the segment_start to set, or NULL
806 * @segment_end: (out) (allow-none): the segment_end to set, or NULL
808 * Parse a seeking query, writing the format into @format, and
809 * other results into the passed parameters, if the respective parameters
813 gst_query_parse_seeking (GstQuery * query, GstFormat * format,
814 gboolean * seekable, gint64 * segment_start, gint64 * segment_end)
816 GstStructure *structure;
818 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_SEEKING);
820 structure = GST_QUERY_STRUCTURE (query);
823 (GstFormat) g_value_get_enum (gst_structure_id_get_value (structure,
824 GST_QUARK (FORMAT)));
826 *seekable = g_value_get_boolean (gst_structure_id_get_value (structure,
827 GST_QUARK (SEEKABLE)));
829 *segment_start = g_value_get_int64 (gst_structure_id_get_value (structure,
830 GST_QUARK (SEGMENT_START)));
832 *segment_end = g_value_get_int64 (gst_structure_id_get_value (structure,
833 GST_QUARK (SEGMENT_END)));
837 ensure_array (GstStructure * s, GQuark quark, gsize element_size,
838 GDestroyNotify clear_func)
843 value = gst_structure_id_get_value (s, quark);
845 array = (GArray *) g_value_get_boxed (value);
847 GValue new_array_val = { 0, };
849 array = g_array_new (FALSE, TRUE, element_size);
851 g_array_set_clear_func (array, clear_func);
853 g_value_init (&new_array_val, G_TYPE_ARRAY);
854 g_value_take_boxed (&new_array_val, array);
856 gst_structure_id_take_value (s, quark, &new_array_val);
862 * gst_query_new_formats:
864 * Constructs a new query object for querying formats of
867 * Free-function: gst_query_unref
869 * Returns: (transfer full): a new #GstQuery
872 gst_query_new_formats (void)
875 GstStructure *structure;
877 structure = gst_structure_new_id_empty (GST_QUARK (QUERY_FORMATS));
878 query = gst_query_new_custom (GST_QUERY_FORMATS, structure);
884 gst_query_list_add_format (GValue * list, GstFormat format)
886 GValue item = { 0, };
888 g_value_init (&item, GST_TYPE_FORMAT);
889 g_value_set_enum (&item, format);
890 gst_value_list_append_value (list, &item);
891 g_value_unset (&item);
895 * gst_query_set_formats:
896 * @query: a #GstQuery
897 * @n_formats: the number of formats to set.
898 * @...: A number of @GstFormats equal to @n_formats.
900 * Set the formats query result fields in @query. The number of formats passed
901 * must be equal to @n_formats.
904 gst_query_set_formats (GstQuery * query, gint n_formats, ...)
907 GValue list = { 0, };
909 GstStructure *structure;
911 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_FORMATS);
912 g_return_if_fail (gst_query_is_writable (query));
914 g_value_init (&list, GST_TYPE_LIST);
916 va_start (ap, n_formats);
917 for (i = 0; i < n_formats; i++) {
918 gst_query_list_add_format (&list, va_arg (ap, GstFormat));
922 structure = GST_QUERY_STRUCTURE (query);
923 gst_structure_set_value (structure, "formats", &list);
925 g_value_unset (&list);
930 * gst_query_set_formatsv:
931 * @query: a #GstQuery
932 * @n_formats: the number of formats to set.
933 * @formats: (in) (array length=n_formats): an array containing @n_formats
936 * Set the formats query result fields in @query. The number of formats passed
937 * in the @formats array must be equal to @n_formats.
940 gst_query_set_formatsv (GstQuery * query, gint n_formats,
941 const GstFormat * formats)
943 GValue list = { 0, };
945 GstStructure *structure;
947 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_FORMATS);
948 g_return_if_fail (gst_query_is_writable (query));
950 g_value_init (&list, GST_TYPE_LIST);
951 for (i = 0; i < n_formats; i++) {
952 gst_query_list_add_format (&list, formats[i]);
954 structure = GST_QUERY_STRUCTURE (query);
955 gst_structure_set_value (structure, "formats", &list);
957 g_value_unset (&list);
961 * gst_query_parse_n_formats:
962 * @query: a #GstQuery
963 * @n_formats: (out) (allow-none): the number of formats in this query.
965 * Parse the number of formats in the formats @query.
968 gst_query_parse_n_formats (GstQuery * query, guint * n_formats)
970 GstStructure *structure;
972 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_FORMATS);
977 structure = GST_QUERY_STRUCTURE (query);
978 list = gst_structure_get_value (structure, "formats");
982 *n_formats = gst_value_list_get_size (list);
987 * gst_query_parse_nth_format:
988 * @query: a #GstQuery
989 * @nth: (out): the nth format to retrieve.
990 * @format: (out) (allow-none): a pointer to store the nth format
992 * Parse the format query and retrieve the @nth format from it into
993 * @format. If the list contains less elements than @nth, @format will be
994 * set to GST_FORMAT_UNDEFINED.
997 gst_query_parse_nth_format (GstQuery * query, guint nth, GstFormat * format)
999 GstStructure *structure;
1001 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_FORMATS);
1006 structure = GST_QUERY_STRUCTURE (query);
1007 list = gst_structure_get_value (structure, "formats");
1009 *format = GST_FORMAT_UNDEFINED;
1011 if (nth < gst_value_list_get_size (list)) {
1013 (GstFormat) g_value_get_enum (gst_value_list_get_value (list, nth));
1015 *format = GST_FORMAT_UNDEFINED;
1021 * gst_query_new_buffering:
1022 * @format: the default #GstFormat for the new query
1024 * Constructs a new query object for querying the buffering status of
1027 * Free-function: gst_query_unref
1029 * Returns: (transfer full): a new #GstQuery
1032 gst_query_new_buffering (GstFormat format)
1035 GstStructure *structure;
1037 /* by default, we configure the answer as no buffering with a 100% buffering
1039 structure = gst_structure_new_id (GST_QUARK (QUERY_BUFFERING),
1040 GST_QUARK (BUSY), G_TYPE_BOOLEAN, FALSE,
1041 GST_QUARK (BUFFER_PERCENT), G_TYPE_INT, 100,
1042 GST_QUARK (BUFFERING_MODE), GST_TYPE_BUFFERING_MODE, GST_BUFFERING_STREAM,
1043 GST_QUARK (AVG_IN_RATE), G_TYPE_INT, -1,
1044 GST_QUARK (AVG_OUT_RATE), G_TYPE_INT, -1,
1045 GST_QUARK (BUFFERING_LEFT), G_TYPE_INT64, G_GINT64_CONSTANT (0),
1046 GST_QUARK (ESTIMATED_TOTAL), G_TYPE_INT64, G_GINT64_CONSTANT (-1),
1047 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1048 GST_QUARK (START_VALUE), G_TYPE_INT64, G_GINT64_CONSTANT (-1),
1049 GST_QUARK (STOP_VALUE), G_TYPE_INT64, G_GINT64_CONSTANT (-1), NULL);
1051 query = gst_query_new_custom (GST_QUERY_BUFFERING, structure);
1057 * gst_query_set_buffering_percent:
1058 * @query: A valid #GstQuery of type GST_QUERY_BUFFERING.
1059 * @busy: if buffering is busy
1060 * @percent: a buffering percent
1062 * Set the percentage of buffered data. This is a value between 0 and 100.
1063 * The @busy indicator is %TRUE when the buffering is in progress.
1066 gst_query_set_buffering_percent (GstQuery * query, gboolean busy, gint percent)
1068 GstStructure *structure;
1070 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_BUFFERING);
1071 g_return_if_fail (gst_query_is_writable (query));
1072 g_return_if_fail (percent >= 0 && percent <= 100);
1074 structure = GST_QUERY_STRUCTURE (query);
1075 gst_structure_id_set (structure,
1076 GST_QUARK (BUSY), G_TYPE_BOOLEAN, busy,
1077 GST_QUARK (BUFFER_PERCENT), G_TYPE_INT, percent, NULL);
1081 * gst_query_parse_buffering_percent:
1082 * @query: A valid #GstQuery of type GST_QUERY_BUFFERING.
1083 * @busy: (out) (allow-none): if buffering is busy, or NULL
1084 * @percent: (out) (allow-none): a buffering percent, or NULL
1086 * Get the percentage of buffered data. This is a value between 0 and 100.
1087 * The @busy indicator is %TRUE when the buffering is in progress.
1090 gst_query_parse_buffering_percent (GstQuery * query, gboolean * busy,
1093 GstStructure *structure;
1095 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_BUFFERING);
1097 structure = GST_QUERY_STRUCTURE (query);
1099 *busy = g_value_get_boolean (gst_structure_id_get_value (structure,
1102 *percent = g_value_get_int (gst_structure_id_get_value (structure,
1103 GST_QUARK (BUFFER_PERCENT)));
1107 * gst_query_set_buffering_stats:
1108 * @query: A valid #GstQuery of type GST_QUERY_BUFFERING.
1109 * @mode: a buffering mode
1110 * @avg_in: the average input rate
1111 * @avg_out: the average output rate
1112 * @buffering_left: amount of buffering time left in milliseconds
1114 * Configures the buffering stats values in @query.
1117 gst_query_set_buffering_stats (GstQuery * query, GstBufferingMode mode,
1118 gint avg_in, gint avg_out, gint64 buffering_left)
1120 GstStructure *structure;
1122 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_BUFFERING);
1123 g_return_if_fail (gst_query_is_writable (query));
1125 structure = GST_QUERY_STRUCTURE (query);
1126 gst_structure_id_set (structure,
1127 GST_QUARK (BUFFERING_MODE), GST_TYPE_BUFFERING_MODE, mode,
1128 GST_QUARK (AVG_IN_RATE), G_TYPE_INT, avg_in,
1129 GST_QUARK (AVG_OUT_RATE), G_TYPE_INT, avg_out,
1130 GST_QUARK (BUFFERING_LEFT), G_TYPE_INT64, buffering_left, NULL);
1134 * gst_query_parse_buffering_stats:
1135 * @query: A valid #GstQuery of type GST_QUERY_BUFFERING.
1136 * @mode: (out) (allow-none): a buffering mode, or NULL
1137 * @avg_in: (out) (allow-none): the average input rate, or NULL
1138 * @avg_out: (out) (allow-none): the average output rat, or NULLe
1139 * @buffering_left: (out) (allow-none): amount of buffering time left in
1140 * milliseconds, or NULL
1142 * Extracts the buffering stats values from @query.
1145 gst_query_parse_buffering_stats (GstQuery * query,
1146 GstBufferingMode * mode, gint * avg_in, gint * avg_out,
1147 gint64 * buffering_left)
1149 GstStructure *structure;
1151 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_BUFFERING);
1153 structure = GST_QUERY_STRUCTURE (query);
1155 *mode = (GstBufferingMode)
1156 g_value_get_enum (gst_structure_id_get_value (structure,
1157 GST_QUARK (BUFFERING_MODE)));
1159 *avg_in = g_value_get_int (gst_structure_id_get_value (structure,
1160 GST_QUARK (AVG_IN_RATE)));
1162 *avg_out = g_value_get_int (gst_structure_id_get_value (structure,
1163 GST_QUARK (AVG_OUT_RATE)));
1166 g_value_get_int64 (gst_structure_id_get_value (structure,
1167 GST_QUARK (BUFFERING_LEFT)));
1171 * gst_query_set_buffering_range:
1172 * @query: a #GstQuery
1173 * @format: the format to set for the @start and @stop values
1174 * @start: the start to set
1175 * @stop: the stop to set
1176 * @estimated_total: estimated total amount of download time
1178 * Set the available query result fields in @query.
1181 gst_query_set_buffering_range (GstQuery * query, GstFormat format,
1182 gint64 start, gint64 stop, gint64 estimated_total)
1184 GstStructure *structure;
1186 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_BUFFERING);
1187 g_return_if_fail (gst_query_is_writable (query));
1189 structure = GST_QUERY_STRUCTURE (query);
1190 gst_structure_id_set (structure,
1191 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1192 GST_QUARK (START_VALUE), G_TYPE_INT64, start,
1193 GST_QUARK (STOP_VALUE), G_TYPE_INT64, stop,
1194 GST_QUARK (ESTIMATED_TOTAL), G_TYPE_INT64, estimated_total, NULL);
1198 * gst_query_parse_buffering_range:
1199 * @query: a GST_QUERY_BUFFERING type query #GstQuery
1200 * @format: (out) (allow-none): the format to set for the @segment_start
1201 * and @segment_end values, or NULL
1202 * @start: (out) (allow-none): the start to set, or NULL
1203 * @stop: (out) (allow-none): the stop to set, or NULL
1204 * @estimated_total: (out) (allow-none): estimated total amount of download
1207 * Parse an available query, writing the format into @format, and
1208 * other results into the passed parameters, if the respective parameters
1212 gst_query_parse_buffering_range (GstQuery * query, GstFormat * format,
1213 gint64 * start, gint64 * stop, gint64 * estimated_total)
1215 GstStructure *structure;
1217 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_BUFFERING);
1219 structure = GST_QUERY_STRUCTURE (query);
1222 (GstFormat) g_value_get_enum (gst_structure_id_get_value (structure,
1223 GST_QUARK (FORMAT)));
1225 *start = g_value_get_int64 (gst_structure_id_get_value (structure,
1226 GST_QUARK (START_VALUE)));
1228 *stop = g_value_get_int64 (gst_structure_id_get_value (structure,
1229 GST_QUARK (STOP_VALUE)));
1230 if (estimated_total)
1232 g_value_get_int64 (gst_structure_id_get_value (structure,
1233 GST_QUARK (ESTIMATED_TOTAL)));
1236 /* GstQueryBufferingRange: internal struct for GArray */
1241 } GstQueryBufferingRange;
1244 * gst_query_add_buffering_range:
1245 * @query: a GST_QUERY_BUFFERING type query #GstQuery
1246 * @start: start position of the range
1247 * @stop: stop position of the range
1249 * Set the buffering-ranges array field in @query. The current last
1250 * start position of the array should be inferior to @start.
1252 * Returns: a #gboolean indicating if the range was added or not.
1255 gst_query_add_buffering_range (GstQuery * query, gint64 start, gint64 stop)
1257 GstQueryBufferingRange range;
1258 GstStructure *structure;
1261 g_return_val_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_BUFFERING, FALSE);
1262 g_return_val_if_fail (gst_query_is_writable (query), FALSE);
1264 if (G_UNLIKELY (start >= stop))
1267 structure = GST_QUERY_STRUCTURE (query);
1268 array = ensure_array (structure, GST_QUARK (BUFFERING_RANGES),
1269 sizeof (GstQueryBufferingRange), NULL);
1271 if (array->len > 1) {
1272 GstQueryBufferingRange *last;
1274 last = &g_array_index (array, GstQueryBufferingRange, array->len - 1);
1276 if (G_UNLIKELY (start <= last->start))
1280 range.start = start;
1282 g_array_append_val (array, range);
1288 * gst_query_get_n_buffering_ranges:
1289 * @query: a GST_QUERY_BUFFERING type query #GstQuery
1291 * Retrieve the number of values currently stored in the
1292 * buffered-ranges array of the query's structure.
1294 * Returns: the range array size as a #guint.
1297 gst_query_get_n_buffering_ranges (GstQuery * query)
1299 GstStructure *structure;
1302 g_return_val_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_BUFFERING, 0);
1304 structure = GST_QUERY_STRUCTURE (query);
1305 array = ensure_array (structure, GST_QUARK (BUFFERING_RANGES),
1306 sizeof (GstQueryBufferingRange), NULL);
1313 * gst_query_parse_nth_buffering_range:
1314 * @query: a GST_QUERY_BUFFERING type query #GstQuery
1315 * @index: position in the buffered-ranges array to read
1316 * @start: (out) (allow-none): the start position to set, or NULL
1317 * @stop: (out) (allow-none): the stop position to set, or NULL
1319 * Parse an available query and get the start and stop values stored
1320 * at the @index of the buffered ranges array.
1322 * Returns: a #gboolean indicating if the parsing succeeded.
1325 gst_query_parse_nth_buffering_range (GstQuery * query, guint index,
1326 gint64 * start, gint64 * stop)
1328 GstQueryBufferingRange *range;
1329 GstStructure *structure;
1332 g_return_val_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_BUFFERING, FALSE);
1334 structure = GST_QUERY_STRUCTURE (query);
1336 array = ensure_array (structure, GST_QUARK (BUFFERING_RANGES),
1337 sizeof (GstQueryBufferingRange), NULL);
1338 g_return_val_if_fail (index < array->len, FALSE);
1340 range = &g_array_index (array, GstQueryBufferingRange, index);
1343 *start = range->start;
1345 *stop = range->stop;
1352 * gst_query_new_uri:
1354 * Constructs a new query URI query object. Use gst_query_unref()
1355 * when done with it. An URI query is used to query the current URI
1356 * that is used by the source or sink.
1358 * Free-function: gst_query_unref
1360 * Returns: (transfer full): a new #GstQuery
1363 gst_query_new_uri (void)
1366 GstStructure *structure;
1368 structure = gst_structure_new_id (GST_QUARK (QUERY_URI),
1369 GST_QUARK (URI), G_TYPE_STRING, NULL, NULL);
1371 query = gst_query_new_custom (GST_QUERY_URI, structure);
1377 * gst_query_set_uri:
1378 * @query: a #GstQuery with query type GST_QUERY_URI
1379 * @uri: the URI to set
1381 * Answer a URI query by setting the requested URI.
1384 gst_query_set_uri (GstQuery * query, const gchar * uri)
1386 GstStructure *structure;
1388 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_URI);
1389 g_return_if_fail (gst_query_is_writable (query));
1390 g_return_if_fail (gst_uri_is_valid (uri));
1392 structure = GST_QUERY_STRUCTURE (query);
1393 gst_structure_id_set (structure, GST_QUARK (URI), G_TYPE_STRING, uri, NULL);
1397 * gst_query_parse_uri:
1398 * @query: a #GstQuery
1399 * @uri: (out callee-allocates) (allow-none): the storage for the current URI
1402 * Parse an URI query, writing the URI into @uri as a newly
1403 * allocated string, if the respective parameters are non-NULL.
1404 * Free the string with g_free() after usage.
1407 gst_query_parse_uri (GstQuery * query, gchar ** uri)
1409 GstStructure *structure;
1411 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_URI);
1413 structure = GST_QUERY_STRUCTURE (query);
1415 *uri = g_value_dup_string (gst_structure_id_get_value (structure,
1420 * gst_query_new_allocation:
1421 * @caps: the negotiated caps
1422 * @need_pool: return a pool
1424 * Constructs a new query object for querying the allocation properties.
1426 * Free-function: gst_query_unref
1428 * Returns: (transfer full): a new #GstQuery
1431 gst_query_new_allocation (GstCaps * caps, gboolean need_pool)
1434 GstStructure *structure;
1436 structure = gst_structure_new_id (GST_QUARK (QUERY_ALLOCATION),
1437 GST_QUARK (CAPS), GST_TYPE_CAPS, caps,
1438 GST_QUARK (NEED_POOL), G_TYPE_BOOLEAN, need_pool, NULL);
1440 query = gst_query_new_custom (GST_QUERY_ALLOCATION, structure);
1446 * gst_query_parse_allocation:
1447 * @query: a #GstQuery
1448 * @caps: (out) (transfer none) (allow-none): The #GstCaps
1449 * @need_pool: (out) (allow-none): Whether a #GstBufferPool is needed
1451 * Parse an allocation query, writing the requested caps in @caps and
1452 * whether a pool is needed in @need_pool, if the respective parameters
1456 gst_query_parse_allocation (GstQuery * query, GstCaps ** caps,
1457 gboolean * need_pool)
1459 GstStructure *structure;
1461 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_ALLOCATION);
1463 structure = GST_QUERY_STRUCTURE (query);
1465 *caps = g_value_get_boxed (gst_structure_id_get_value (structure,
1468 gst_structure_id_get (structure,
1469 GST_QUARK (NEED_POOL), G_TYPE_BOOLEAN, need_pool, NULL);
1474 GstBufferPool *pool;
1481 allocation_pool_free (AllocationPool * ap)
1484 gst_object_unref (ap->pool);
1488 * gst_query_add_allocation_pool:
1489 * @query: A valid #GstQuery of type GST_QUERY_ALLOCATION.
1490 * @pool: the #GstBufferPool
1492 * @min_buffers: the min buffers
1493 * @max_buffers: the max buffers
1495 * Set the pool parameters in @query.
1498 gst_query_add_allocation_pool (GstQuery * query, GstBufferPool * pool,
1499 guint size, guint min_buffers, guint max_buffers)
1502 GstStructure *structure;
1505 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_ALLOCATION);
1506 g_return_if_fail (gst_query_is_writable (query));
1507 g_return_if_fail (size != 0);
1509 structure = GST_QUERY_STRUCTURE (query);
1510 array = ensure_array (structure, GST_QUARK (POOL),
1511 sizeof (AllocationPool), (GDestroyNotify) allocation_pool_free);
1513 if ((ap.pool = pool))
1514 gst_object_ref (pool);
1516 ap.min_buffers = min_buffers;
1517 ap.max_buffers = max_buffers;
1519 g_array_append_val (array, ap);
1524 * gst_query_get_n_allocation_pools:
1525 * @query: a GST_QUERY_ALLOCATION type query #GstQuery
1527 * Retrieve the number of values currently stored in the
1528 * pool array of the query's structure.
1530 * Returns: the pool array size as a #guint.
1533 gst_query_get_n_allocation_pools (GstQuery * query)
1536 GstStructure *structure;
1538 g_return_val_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_ALLOCATION, 0);
1540 structure = GST_QUERY_STRUCTURE (query);
1541 array = ensure_array (structure, GST_QUARK (POOL),
1542 sizeof (AllocationPool), (GDestroyNotify) allocation_pool_free);
1548 * gst_query_parse_nth_allocation_pool:
1549 * @query: A valid #GstQuery of type GST_QUERY_ALLOCATION.
1550 * @index: index to parse
1551 * @pool: (out) (allow-none) (transfer full): the #GstBufferPool
1552 * @size: (out) (allow-none): the size
1553 * @min_buffers: (out) (allow-none): the min buffers
1554 * @max_buffers: (out) (allow-none): the max buffers
1556 * Get the pool parameters in @query.
1558 * Unref @pool with gst_object_unref() when it's not needed any more.
1561 gst_query_parse_nth_allocation_pool (GstQuery * query, guint index,
1562 GstBufferPool ** pool, guint * size, guint * min_buffers,
1563 guint * max_buffers)
1566 GstStructure *structure;
1569 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_ALLOCATION);
1571 structure = GST_QUERY_STRUCTURE (query);
1572 array = ensure_array (structure, GST_QUARK (POOL),
1573 sizeof (AllocationPool), (GDestroyNotify) allocation_pool_free);
1574 g_return_if_fail (index < array->len);
1576 ap = &g_array_index (array, AllocationPool, index);
1579 if ((*pool = ap->pool))
1580 gst_object_ref (*pool);
1584 *min_buffers = ap->min_buffers;
1586 *max_buffers = ap->max_buffers;
1590 * gst_query_set_nth_allocation_pool:
1591 * @index: index to modify
1592 * @query: A valid #GstQuery of type GST_QUERY_ALLOCATION.
1593 * @pool: the #GstBufferPool
1595 * @min_buffers: the min buffers
1596 * @max_buffers: the max buffers
1598 * Set the pool parameters in @query.
1601 gst_query_set_nth_allocation_pool (GstQuery * query, guint index,
1602 GstBufferPool * pool, guint size, guint min_buffers, guint max_buffers)
1605 GstStructure *structure;
1606 AllocationPool *oldap, ap;
1608 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_ALLOCATION);
1610 structure = GST_QUERY_STRUCTURE (query);
1611 array = ensure_array (structure, GST_QUARK (POOL),
1612 sizeof (AllocationPool), (GDestroyNotify) allocation_pool_free);
1613 g_return_if_fail (index < array->len);
1615 oldap = &g_array_index (array, AllocationPool, index);
1616 allocation_pool_free (oldap);
1618 if ((ap.pool = pool))
1619 gst_object_ref (pool);
1621 ap.min_buffers = min_buffers;
1622 ap.max_buffers = max_buffers;
1623 g_array_index (array, AllocationPool, index) = ap;
1627 * gst_query_remove_nth_allocation_pool:
1628 * @query: a GST_QUERY_ALLOCATION type query #GstQuery
1629 * @index: position in the allocation pool array to remove
1631 * Remove the allocation pool at @index of the allocation pool array.
1634 gst_query_remove_nth_allocation_pool (GstQuery * query, guint index)
1637 GstStructure *structure;
1639 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_ALLOCATION);
1640 g_return_if_fail (gst_query_is_writable (query));
1642 structure = GST_QUERY_STRUCTURE (query);
1644 ensure_array (structure, GST_QUARK (POOL), sizeof (AllocationPool),
1645 (GDestroyNotify) allocation_pool_free);
1646 g_return_if_fail (index < array->len);
1648 g_array_remove_index (array, index);
1654 GstStructure *params;
1658 allocation_meta_free (AllocationMeta * am)
1661 gst_structure_free (am->params);
1665 * gst_query_add_allocation_meta:
1666 * @query: a GST_QUERY_ALLOCATION type query #GstQuery
1667 * @api: the metadata API
1668 * @params: (transfer none) (allow-none): API specific parameters
1670 * Add @api with @params as one of the supported metadata API to @query.
1673 gst_query_add_allocation_meta (GstQuery * query, GType api,
1674 const GstStructure * params)
1677 GstStructure *structure;
1680 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_ALLOCATION);
1681 g_return_if_fail (api != 0);
1682 g_return_if_fail (gst_query_is_writable (query));
1684 structure = GST_QUERY_STRUCTURE (query);
1686 ensure_array (structure, GST_QUARK (META), sizeof (AllocationMeta),
1687 (GDestroyNotify) allocation_meta_free);
1690 am.params = (params ? gst_structure_copy (params) : NULL);
1692 g_array_append_val (array, am);
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);
1714 ensure_array (structure, GST_QUARK (META), sizeof (AllocationMeta),
1715 (GDestroyNotify) allocation_meta_free);
1721 * gst_query_parse_nth_allocation_meta:
1722 * @query: a GST_QUERY_ALLOCATION type query #GstQuery
1723 * @index: position in the metadata API array to read
1724 * @params: (out) (allow-none): API specific flags
1726 * Parse an available query and get the metadata API
1727 * at @index of the metadata API array.
1729 * Returns: a #GType of the metadata API at @index.
1732 gst_query_parse_nth_allocation_meta (GstQuery * query, guint index,
1733 const GstStructure ** params)
1736 GstStructure *structure;
1739 g_return_val_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_ALLOCATION, 0);
1741 structure = GST_QUERY_STRUCTURE (query);
1743 ensure_array (structure, GST_QUARK (META), sizeof (AllocationMeta),
1744 (GDestroyNotify) allocation_meta_free);
1746 g_return_val_if_fail (index < array->len, 0);
1748 am = &g_array_index (array, AllocationMeta, index);
1751 *params = am->params;
1757 * gst_query_remove_nth_allocation_meta:
1758 * @query: a GST_QUERY_ALLOCATION type query #GstQuery
1759 * @index: position in the metadata API array to remove
1761 * Remove the metadata API at @index of the metadata API array.
1764 gst_query_remove_nth_allocation_meta (GstQuery * query, guint index)
1767 GstStructure *structure;
1769 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_ALLOCATION);
1770 g_return_if_fail (gst_query_is_writable (query));
1772 structure = GST_QUERY_STRUCTURE (query);
1774 ensure_array (structure, GST_QUARK (META), sizeof (AllocationMeta),
1775 (GDestroyNotify) allocation_meta_free);
1776 g_return_if_fail (index < array->len);
1778 g_array_remove_index (array, index);
1782 * gst_query_find_allocation_meta:
1783 * @query: a GST_QUERY_ALLOCATION type query #GstQuery
1784 * @api: the metadata API
1785 * @index: (out) (allow-none): the index
1787 * Check if @query has metadata @api set. When this function returns TRUE,
1788 * @index will contain the index where the requested API and the flags can be
1791 * Returns: TRUE when @api is in the list of metadata.
1794 gst_query_find_allocation_meta (GstQuery * query, GType api, guint * index)
1797 GstStructure *structure;
1800 g_return_val_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_ALLOCATION, FALSE);
1801 g_return_val_if_fail (api != 0, FALSE);
1803 structure = GST_QUERY_STRUCTURE (query);
1805 ensure_array (structure, GST_QUARK (META), sizeof (AllocationMeta),
1806 (GDestroyNotify) allocation_meta_free);
1809 for (i = 0; i < len; i++) {
1810 AllocationMeta *am = &g_array_index (array, AllocationMeta, i);
1811 if (am->api == api) {
1822 GstAllocator *allocator;
1823 GstAllocationParams params;
1827 allocation_param_free (AllocationParam * ap)
1830 gst_object_unref (ap->allocator);
1834 * gst_query_add_allocation_param:
1835 * @query: a GST_QUERY_ALLOCATION type query #GstQuery
1836 * @allocator: (transfer none) (allow-none): the memory allocator
1837 * @params: (transfer none) (allow-none): a #GstAllocationParams
1839 * Add @allocator and its @params as a supported memory allocator.
1842 gst_query_add_allocation_param (GstQuery * query, GstAllocator * allocator,
1843 const GstAllocationParams * params)
1846 GstStructure *structure;
1849 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_ALLOCATION);
1850 g_return_if_fail (gst_query_is_writable (query));
1851 g_return_if_fail (allocator != NULL || params != NULL);
1853 structure = GST_QUERY_STRUCTURE (query);
1854 array = ensure_array (structure, GST_QUARK (ALLOCATOR),
1855 sizeof (AllocationParam), (GDestroyNotify) allocation_param_free);
1857 if ((ap.allocator = allocator))
1858 gst_object_ref (allocator);
1860 ap.params = *params;
1862 gst_allocation_params_init (&ap.params);
1864 g_array_append_val (array, ap);
1868 * gst_query_get_n_allocation_params:
1869 * @query: a GST_QUERY_ALLOCATION type query #GstQuery
1871 * Retrieve the number of values currently stored in the
1872 * allocator params array of the query's structure.
1874 * If no memory allocator is specified, the downstream element can handle
1875 * the default memory allocator. The first memory allocator in the query
1876 * should be generic and allow mapping to system memory, all following
1877 * allocators should be ordered by preference with the preferred one first.
1879 * Returns: the allocator array size as a #guint.
1882 gst_query_get_n_allocation_params (GstQuery * query)
1885 GstStructure *structure;
1887 g_return_val_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_ALLOCATION, 0);
1889 structure = GST_QUERY_STRUCTURE (query);
1890 array = ensure_array (structure, GST_QUARK (ALLOCATOR),
1891 sizeof (AllocationParam), (GDestroyNotify) allocation_param_free);
1897 * gst_query_parse_nth_allocation_param:
1898 * @query: a GST_QUERY_ALLOCATION type query #GstQuery
1899 * @index: position in the allocator array to read
1900 * @allocator: (out) (transfer full) (allow-none): variable to hold the result
1901 * @params: (out) (allow-none): parameters for the allocator
1903 * Parse an available query and get the alloctor and its params
1904 * at @index of the allocator array.
1907 gst_query_parse_nth_allocation_param (GstQuery * query, guint index,
1908 GstAllocator ** allocator, GstAllocationParams * params)
1911 GstStructure *structure;
1912 AllocationParam *ap;
1914 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_ALLOCATION);
1916 structure = GST_QUERY_STRUCTURE (query);
1917 array = ensure_array (structure, GST_QUARK (ALLOCATOR),
1918 sizeof (AllocationParam), (GDestroyNotify) allocation_param_free);
1919 g_return_if_fail (index < array->len);
1921 ap = &g_array_index (array, AllocationParam, index);
1924 if ((*allocator = ap->allocator))
1925 gst_object_ref (*allocator);
1927 *params = ap->params;
1931 * gst_query_set_nth_allocation_param:
1932 * @query: a GST_QUERY_ALLOCATION type query #GstQuery
1933 * @index: position in the allocator array to set
1934 * @allocator: (transfer none) (allow-none): new allocator to set
1935 * @params: (transfer none) (allow-none): parameters for the allocator
1937 * Parse an available query and get the alloctor and its params
1938 * at @index of the allocator array.
1941 gst_query_set_nth_allocation_param (GstQuery * query, guint index,
1942 GstAllocator * allocator, const GstAllocationParams * params)
1945 GstStructure *structure;
1946 AllocationParam *old, ap;
1948 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_ALLOCATION);
1950 structure = GST_QUERY_STRUCTURE (query);
1951 array = ensure_array (structure, GST_QUARK (ALLOCATOR),
1952 sizeof (AllocationParam), (GDestroyNotify) allocation_param_free);
1953 g_return_if_fail (index < array->len);
1955 old = &g_array_index (array, AllocationParam, index);
1956 allocation_param_free (old);
1958 if ((ap.allocator = allocator))
1959 gst_object_ref (allocator);
1961 ap.params = *params;
1963 gst_allocation_params_init (&ap.params);
1965 g_array_index (array, AllocationParam, index) = ap;
1969 * gst_query_remove_nth_allocation_param:
1970 * @query: a GST_QUERY_ALLOCATION type query #GstQuery
1971 * @index: position in the allocation param array to remove
1973 * Remove the allocation param at @index of the allocation param array.
1976 gst_query_remove_nth_allocation_param (GstQuery * query, guint index)
1979 GstStructure *structure;
1981 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_ALLOCATION);
1982 g_return_if_fail (gst_query_is_writable (query));
1984 structure = GST_QUERY_STRUCTURE (query);
1986 ensure_array (structure, GST_QUARK (ALLOCATOR), sizeof (AllocationParam),
1987 (GDestroyNotify) allocation_param_free);
1988 g_return_if_fail (index < array->len);
1990 g_array_remove_index (array, index);
1994 * gst_query_new_scheduling:
1996 * Constructs a new query object for querying the scheduling properties.
1998 * Free-function: gst_query_unref
2000 * Returns: (transfer full): a new #GstQuery
2003 gst_query_new_scheduling (void)
2006 GstStructure *structure;
2008 structure = gst_structure_new_id (GST_QUARK (QUERY_SCHEDULING),
2009 GST_QUARK (FLAGS), GST_TYPE_SCHEDULING_FLAGS, 0,
2010 GST_QUARK (MINSIZE), G_TYPE_INT, 1,
2011 GST_QUARK (MAXSIZE), G_TYPE_INT, -1,
2012 GST_QUARK (ALIGN), G_TYPE_INT, 0, NULL);
2013 query = gst_query_new_custom (GST_QUERY_SCHEDULING, structure);
2019 * gst_query_set_scheduling:
2020 * @query: A valid #GstQuery of type GST_QUERY_SCHEDULING.
2021 * @flags: #GstSchedulingFlags
2022 * @minsize: the suggested minimum size of pull requests
2023 * @maxsize: the suggested maximum size of pull requests
2024 * @align: the suggested alignment of pull requests
2026 * Set the scheduling properties.
2029 gst_query_set_scheduling (GstQuery * query, GstSchedulingFlags flags,
2030 gint minsize, gint maxsize, gint align)
2032 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);
2038 gst_structure_id_set (structure,
2039 GST_QUARK (FLAGS), GST_TYPE_SCHEDULING_FLAGS, flags,
2040 GST_QUARK (MINSIZE), G_TYPE_INT, minsize,
2041 GST_QUARK (MAXSIZE), G_TYPE_INT, maxsize,
2042 GST_QUARK (ALIGN), G_TYPE_INT, align, NULL);
2046 * gst_query_parse_scheduling:
2047 * @query: A valid #GstQuery of type GST_QUERY_SCHEDULING.
2048 * @flags: (out) (allow-none): #GstSchedulingFlags
2049 * @minsize: (out) (allow-none): the suggested minimum size of pull requests
2050 * @maxsize: (out) (allow-none): the suggested maximum size of pull requests:
2051 * @align: (out) (allow-none): the suggested alignment of pull requests
2053 * Set the scheduling properties.
2056 gst_query_parse_scheduling (GstQuery * query, GstSchedulingFlags * flags,
2057 gint * minsize, gint * maxsize, gint * align)
2059 GstStructure *structure;
2061 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_SCHEDULING);
2063 structure = GST_QUERY_STRUCTURE (query);
2064 gst_structure_id_get (structure,
2065 GST_QUARK (FLAGS), GST_TYPE_SCHEDULING_FLAGS, flags,
2066 GST_QUARK (MINSIZE), G_TYPE_INT, minsize,
2067 GST_QUARK (MAXSIZE), G_TYPE_INT, maxsize,
2068 GST_QUARK (ALIGN), G_TYPE_INT, align, NULL);
2072 * gst_query_add_scheduling_mode:
2073 * @query: a GST_QUERY_SCHEDULING type query #GstQuery
2074 * @mode: a #GstPadMode
2076 * Add @mode as aone of the supported scheduling modes to @query.
2079 gst_query_add_scheduling_mode (GstQuery * query, GstPadMode mode)
2081 GstStructure *structure;
2084 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_SCHEDULING);
2085 g_return_if_fail (gst_query_is_writable (query));
2087 structure = GST_QUERY_STRUCTURE (query);
2089 ensure_array (structure, GST_QUARK (MODES), sizeof (GstPadMode), NULL);
2091 g_array_append_val (array, mode);
2095 * gst_query_get_n_scheduling_modes:
2096 * @query: a GST_QUERY_SCHEDULING type query #GstQuery
2098 * Retrieve the number of values currently stored in the
2099 * scheduling mode array of the query's structure.
2101 * Returns: the scheduling mode array size as a #guint.
2104 gst_query_get_n_scheduling_modes (GstQuery * query)
2107 GstStructure *structure;
2109 g_return_val_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_SCHEDULING, 0);
2111 structure = GST_QUERY_STRUCTURE (query);
2113 ensure_array (structure, GST_QUARK (MODES), sizeof (GstPadMode), NULL);
2119 * gst_query_parse_nth_scheduling_mode:
2120 * @query: a GST_QUERY_SCHEDULING type query #GstQuery
2121 * @index: position in the scheduling modes array to read
2123 * Parse an available query and get the scheduling mode
2124 * at @index of the scheduling modes array.
2126 * Returns: a #GstPadMode of the scheduling mode at @index.
2129 gst_query_parse_nth_scheduling_mode (GstQuery * query, guint index)
2131 GstStructure *structure;
2134 g_return_val_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_SCHEDULING,
2137 structure = GST_QUERY_STRUCTURE (query);
2139 ensure_array (structure, GST_QUARK (MODES), sizeof (GstPadMode), NULL);
2140 g_return_val_if_fail (index < array->len, GST_PAD_MODE_NONE);
2142 return g_array_index (array, GstPadMode, index);
2146 * gst_query_has_scheduling_mode:
2147 * @query: a GST_QUERY_SCHEDULING type query #GstQuery
2148 * @mode: the scheduling mode
2150 * Check if @query has scheduling mode set.
2154 * When checking if upstream supports pull mode, it is usually not
2155 * enough to just check for GST_PAD_MODE_PULL with this function, you
2156 * also want to check whether the scheduling flags returned by
2157 * gst_query_parse_scheduling() have the seeking flag set (meaning
2158 * random access is supported, not only sequential pulls).
2162 * Returns: TRUE when @mode is in the list of scheduling modes.
2165 gst_query_has_scheduling_mode (GstQuery * query, GstPadMode mode)
2167 GstStructure *structure;
2171 g_return_val_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_SCHEDULING, FALSE);
2173 structure = GST_QUERY_STRUCTURE (query);
2175 ensure_array (structure, GST_QUARK (MODES), sizeof (GstPadMode), NULL);
2178 for (i = 0; i < len; i++) {
2179 if (mode == g_array_index (array, GstPadMode, i))
2186 * gst_query_has_scheduling_mode_with_flags:
2187 * @query: a GST_QUERY_SCHEDULING type query #GstQuery
2188 * @mode: the scheduling mode
2189 * @flags: #GstSchedulingFlags
2191 * Check if @query has scheduling mode set and @flags is set in
2192 * query scheduling flags.
2194 * Returns: TRUE when @mode is in the list of scheduling modes
2195 * and @flags are compatible with query flags.
2198 gst_query_has_scheduling_mode_with_flags (GstQuery * query, GstPadMode mode,
2199 GstSchedulingFlags flags)
2201 GstSchedulingFlags sched_flags;
2203 g_return_val_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_SCHEDULING, FALSE);
2205 gst_query_parse_scheduling (query, &sched_flags, NULL, NULL, NULL);
2207 return ((flags & sched_flags) == flags) &&
2208 gst_query_has_scheduling_mode (query, mode);
2212 * gst_query_new_accept_caps:
2213 * @caps: a fixed #GstCaps
2215 * Constructs a new query object for querying if @caps are accepted.
2217 * Free-function: gst_query_unref
2219 * Returns: (transfer full): a new #GstQuery
2222 gst_query_new_accept_caps (GstCaps * caps)
2225 GstStructure *structure;
2227 g_return_val_if_fail (gst_caps_is_fixed (caps), NULL);
2229 structure = gst_structure_new_id (GST_QUARK (QUERY_ACCEPT_CAPS),
2230 GST_QUARK (CAPS), GST_TYPE_CAPS, caps,
2231 GST_QUARK (RESULT), G_TYPE_BOOLEAN, FALSE, NULL);
2232 query = gst_query_new_custom (GST_QUERY_ACCEPT_CAPS, structure);
2238 * gst_query_parse_accept_caps:
2239 * @query: The query to parse
2240 * @caps: (out): A pointer to the caps
2242 * Get the caps from @query. The caps remains valid as long as @query remains
2246 gst_query_parse_accept_caps (GstQuery * query, GstCaps ** caps)
2248 GstStructure *structure;
2250 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_ACCEPT_CAPS);
2251 g_return_if_fail (caps != NULL);
2253 structure = GST_QUERY_STRUCTURE (query);
2254 *caps = g_value_get_boxed (gst_structure_id_get_value (structure,
2259 * gst_query_set_accept_caps_result:
2260 * @query: a GST_QUERY_ACCEPT_CAPS type query #GstQuery
2261 * @result: the result to set
2263 * Set @result as the result for the @query.
2266 gst_query_set_accept_caps_result (GstQuery * query, gboolean result)
2268 GstStructure *structure;
2270 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_ACCEPT_CAPS);
2271 g_return_if_fail (gst_query_is_writable (query));
2273 structure = GST_QUERY_STRUCTURE (query);
2274 gst_structure_id_set (structure,
2275 GST_QUARK (RESULT), G_TYPE_BOOLEAN, result, NULL);
2279 * gst_query_parse_accept_caps_result:
2280 * @query: a GST_QUERY_ACCEPT_CAPS type query #GstQuery
2281 * @result: location for the result
2283 * Parse the result from @query and store in @result.
2286 gst_query_parse_accept_caps_result (GstQuery * query, gboolean * result)
2288 GstStructure *structure;
2290 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_ACCEPT_CAPS);
2292 structure = GST_QUERY_STRUCTURE (query);
2293 gst_structure_id_get (structure,
2294 GST_QUARK (RESULT), G_TYPE_BOOLEAN, result, NULL);
2298 * gst_query_new_caps:
2301 * Constructs a new query object for querying the caps.
2303 * The CAPS query should return the allowable caps for a pad in the context
2304 * of the element's state, its link to other elements, and the devices or files
2305 * it has opened. These caps must be a subset of the pad template caps. In the
2306 * NULL state with no links, the CAPS query should ideally return the same caps
2307 * as the pad template. In rare circumstances, an object property can affect
2308 * the caps returned by the CAPS query, but this is discouraged.
2310 * For most filters, the caps returned by CAPS query is directly affected by the
2311 * allowed caps on other pads. For demuxers and decoders, the caps returned by
2312 * the srcpad's getcaps function is directly related to the stream data. Again,
2313 * the CAPS query should return the most specific caps it reasonably can, since this
2314 * helps with autoplugging.
2316 * The @filter is used to restrict the result caps, only the caps matching
2317 * @filter should be returned from the CAPS query. Specifying a filter might
2318 * greatly reduce the amount of processing an element needs to do.
2320 * Free-function: gst_query_unref
2322 * Returns: (transfer full): a new #GstQuery
2325 gst_query_new_caps (GstCaps * filter)
2328 GstStructure *structure;
2330 structure = gst_structure_new_id (GST_QUARK (QUERY_CAPS),
2331 GST_QUARK (FILTER), GST_TYPE_CAPS, filter,
2332 GST_QUARK (CAPS), GST_TYPE_CAPS, NULL, NULL);
2333 query = gst_query_new_custom (GST_QUERY_CAPS, structure);
2339 * gst_query_parse_caps:
2340 * @query: The query to parse
2341 * @filter: (out): A pointer to the caps filter
2343 * Get the filter from the caps @query. The caps remains valid as long as
2344 * @query remains valid.
2347 gst_query_parse_caps (GstQuery * query, GstCaps ** filter)
2349 GstStructure *structure;
2351 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_CAPS);
2352 g_return_if_fail (filter != NULL);
2354 structure = GST_QUERY_STRUCTURE (query);
2355 *filter = g_value_get_boxed (gst_structure_id_get_value (structure,
2356 GST_QUARK (FILTER)));
2360 * gst_query_set_caps_result:
2361 * @query: The query to use
2362 * @caps: (in): A pointer to the caps
2364 * Set the @caps result in @query.
2367 gst_query_set_caps_result (GstQuery * query, GstCaps * caps)
2369 GstStructure *structure;
2371 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_CAPS);
2372 g_return_if_fail (gst_query_is_writable (query));
2374 structure = GST_QUERY_STRUCTURE (query);
2375 gst_structure_id_set (structure, GST_QUARK (CAPS), GST_TYPE_CAPS, caps, NULL);
2379 * gst_query_parse_caps_result:
2380 * @query: The query to parse
2381 * @caps: (out): A pointer to the caps
2383 * Get the caps result from @query. The caps remains valid as long as
2384 * @query remains valid.
2387 gst_query_parse_caps_result (GstQuery * query, GstCaps ** caps)
2389 GstStructure *structure;
2391 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_CAPS);
2392 g_return_if_fail (caps != NULL);
2394 structure = GST_QUERY_STRUCTURE (query);
2395 *caps = g_value_get_boxed (gst_structure_id_get_value (structure,
2401 gst_query_intersect_caps_result (GstQuery * query, GstCaps * filter,
2402 GstCapsIntersectMode mode)
2404 GstCaps *res, *caps = NULL;
2406 gst_query_parse_caps_result (query, &caps);
2407 res = gst_caps_intersect_full (filter, caps, GST_CAPS_INTERSECT_FIRST);
2408 gst_query_set_caps_result (query, res);
2409 gst_caps_unref (res);
2414 * gst_query_new_drain:
2416 * Constructs a new query object for querying the drain state.
2418 * Free-function: gst_query_unref
2420 * Returns: (transfer full): a new #GstQuery
2423 gst_query_new_drain (void)
2426 GstStructure *structure;
2428 structure = gst_structure_new_id_empty (GST_QUARK (QUERY_DRAIN));
2429 query = gst_query_new_custom (GST_QUERY_DRAIN, structure);