Next: , Previous: GstPlugin, Up: Top


30 GstQuery

Dynamically register new query types. Provide functions to create queries, and to set and parse values in them.

30.1 Overview

GstQuery functions are used to register a new query types to the gstreamer core. Query types can be used to perform queries on pads and elements.

Queries can be created using the gst-query-new-xxx functions. Query values can be set using gst-query-set-xxx, and parsed using gst-query-parse-xxx helpers.

The following example shows how to query the duration of a pipeline:

     
      GstQuery *query;
      gboolean res;
      query = gst_query_new_duration (GST_FORMAT_TIME);
      res = gst_element_query (pipeline, query);
      if (res) {
        gint64 duration;
        gst_query_parse_duration (query, NULL, &duration);
        g_print ("duration = %"GST_TIME_FORMAT, GST_TIME_ARGS (duration));
      }
      else {
        g_print ("duration query failed...");
      }
      gst_query_unref (query);
     

Last reviewed on 2006-02-14 (0.10.4)

30.2 Usage

— Class: <gst-query>
— Function: gst-query-type-get-name (self <gst-query-type*>)   (ret mchars)

Get a printable name for the given query type. Do not modify or free.

query
the query type
ret
a reference to the static name of the query.
— Function: gst-query-type-to-quark (self <gst-query-type*>)   (ret unsigned-int)

Get the unique quark for the given query type.

query
the query type
ret
the quark associated with the query type
— Function: gst-query-type-register (nick mchars) (description mchars)   (ret <gst-query-type>)

Create a new GstQueryType based on the nick or return an already registered query with that nick

nick
The nick of the new query
description
The description of the new query
ret
A new GstQueryType or an already registered query with the same nick.
— Function: gst-query-type-get-by-nick (nick mchars)   (ret <gst-query-type>)

Get the query type registered with nick.

nick
The nick of the query
ret
The query registered with nick or <gst-query-none> if the query was not registered.
— Function: gst-query-types-contains (self <gst-query-type*>) (type <gst-query-type>)   (ret bool)

See if the given <gst-query-type> is inside the types query types array.

types
The query array to search
type
the <gst-query-type> to find
ret
TRUE if the type is found inside the array
— Function: gst-query-type-iterate-definitions   (ret <gst-iterator*>)

Get a <gst-iterator> of all the registered query types. The definitions iterated over are read only.

ret
A <gst-iterator> of <gst-query-type-definition>.
— Function: gst-query-new-application (type <gst-query-type>) (structure <gst-structure>)   (ret <gst-query>)

Constructs a new custom application query object. Use gst-query-unref when done with it.

type
the query type
structure
a structure for the query
ret
a <gst-query>
— Function: gst-query-get-structure (self <gst-query>)   (ret <gst-structure>)
— Method: get-structure

Get the structure of a query.

query
a <gst-query>
ret
The <gst-structure> of the query. The structure is still owned by the query and will therefore be freed when the query is unreffed.
— Function: gst-query-new-convert (src_format <gst-format>) (value int64) (dest_format <gst-format>)   (ret <gst-query>)

Constructs a new convert query object. Use gst-query-unref when done with it. A convert query is used to ask for a conversion between one format and another.

src-format
the source <gst-format> for the new query
value
the value to convert
dest-format
the target <gst-format>
ret
A <gst-query>
— Function: gst-query-set-convert (self <gst-query>) (src_format <gst-format>) (src_value int64) (dest_format <gst-format>) (dest_value int64)
— Method: set-convert

Answer a convert query by setting the requested values.

query
a <gst-query>
src-format
the source <gst-format>
src-value
the source value
dest-format
the destination <gst-format>
dest-value
the destination value
— Function: gst-query-parse-convert (self <gst-query>) (src_format <gst-format*>) (dest_format <gst-format*>)   (src_value int64) (dest_value int64)
— Method: parse-convert

Parse a convert query answer. Any of src-format, src-value, dest-format, and dest-value may be NULL, in which case that value is omitted.

query
a <gst-query>
src-format
the storage for the <gst-format> of the source value, or NULL
src-value
the storage for the source value, or NULL
dest-format
the storage for the <gst-format> of the destination value, or NULL
dest-value
the storage for the destination value, or NULL
— Function: gst-query-new-position (format <gst-format>)   (ret <gst-query>)

Constructs a new query stream position query object. Use gst-query-unref when done with it. A position query is used to query the current position of playback in the streams, in some format.

format
the default <gst-format> for the new query
ret
A <gst-query>
— Function: gst-query-set-position (self <gst-query>) (format <gst-format>) (cur int64)
— Method: set-position

Answer a position query by setting the requested value in the given format.

query
a <gst-query> with query type GST_QUERY_POSITION
format
the requested <gst-format>
cur
the position to set
— Function: gst-query-parse-position (self <gst-query>) (format <gst-format*>)   (cur int64)
— Method: parse-position

Parse a position query, writing the format into format, and the position into cur, if the respective parameters are non-NULL.

query
a <gst-query>
format
the storage for the <gst-format> of the position values (may be NULL)
cur
the storage for the current position (may be NULL)
— Function: gst-query-new-duration (format <gst-format>)   (ret <gst-query>)

Constructs a new stream duration query object to query in the given format. Use gst-query-unref when done with it. A duration query will give the total length of the stream.

format
the <gst-format> for this duration query
ret
A <gst-query>
— Function: gst-query-set-duration (self <gst-query>) (format <gst-format>) (duration int64)
— Method: set-duration

Answer a duration query by setting the requested value in the given format.

query
a <gst-query>
format
the <gst-format> for the duration
duration
the duration of the stream
— Function: gst-query-parse-duration (self <gst-query>) (format <gst-format*>)   (duration int64)
— Method: parse-duration

Parse a duration query answer. Write the format of the duration into format, and the value into duration, if the respective variables are non-NULL.

query
a <gst-query>
format
the storage for the <gst-format> of the duration value, or NULL.
duration
the storage for the total duration, or NULL.
— Function: gst-query-new-seeking (format <gst-format>)   (ret <gst-query>)

Constructs a new query object for querying seeking properties of the stream.

format
the default <gst-format> for the new query
ret
A <gst-query>
— Function: gst-query-set-seeking (self <gst-query>) (format <gst-format>) (seekable bool) (segment_start int64) (segment_end int64)
— Method: set-seeking

Set the seeking query result fields in query.

query
a <gst-query>
format
the format to set for the segment-start and segment-end values
seekable
the seekable flag to set
segment-start
the segment_start to set
segment-end
the segment_end to set
— Function: gst-query-parse-seeking (self <gst-query>) (format <gst-format*>)   (seekable bool) (segment_start int64) (segment_end int64)
— Method: parse-seeking

Parse a seeking query, writing the format into format, and other results into the passed parameters, if the respective parameters are non-NULL

query
a GST_QUERY_SEEKING type query <gst-query>
format
the format to set for the segment-start and segment-end values
seekable
the seekable flag to set
segment-start
the segment_start to set
segment-end
the segment_end to set
— Function: gst-query-new-formats   (ret <gst-query>)

Constructs a new query object for querying formats of the stream.

ret
A <gst-query>

Since 0.10.4

— Function: gst-query-set-formatsv (self <gst-query>) (n_formats int) (formats <gst-format*>)
— Method: set-formatsv

Set the formats query result fields in query. The number of formats passed in the formats array must be equal to n-formats.

query
a <gst-query>
n-formats
the number of formats to set.
formats
An array containing n-formatsgst-format values.

Since 0.10.4

— Function: gst-query-parse-formats-length (self <gst-query>)   (n_formats unsigned-int)
— Method: parse-formats-length

Parse the number of formats in the formats query.

query
a <gst-query>
n-formats
the number of formats in this query.

Since 0.10.4

— Function: gst-query-parse-formats-nth (self <gst-query>) (nth unsigned-int) (format <gst-format*>)
— Method: parse-formats-nth

Parse the format query and retrieve the nth format from it into format. If the list contains less elements than nth, format will be set to GST_FORMAT_UNDEFINED.

query
a <gst-query>
nth
the nth format to retrieve.
format
a pointer to store the nth format

Since 0.10.4

— Function: gst-query-new-segment (format <gst-format>)   (ret <gst-query>)

Constructs a new segment query object. Use gst-query-unref when done with it. A segment query is used to discover information about the currently configured segment for playback.

format
the <gst-format> for the new query
ret
a <gst-query>
— Function: gst-query-set-segment (self <gst-query>) (rate double) (format <gst-format>) (start_value int64) (stop_value int64)
— Method: set-segment

Answer a segment query by setting the requested values. The normal playback segment of a pipeline is 0 to duration at the default rate of 1.0. If a seek was performed on the pipeline to play a different segment, this query will return the range specified in the last seek.

start-value and stop-value will respectively contain the configured playback range start and stop values expressed in format. The values are always between 0 and the duration of the media and start-value <= stop-value. rate will contain the playback rate. For negative rates, playback will actually happen from stop-value to start-value.

query
a <gst-query>
rate
the rate of the segment
format
the <gst-format> of the segment values (start-value and stop-value)
start-value
the start value
stop-value
the stop value
— Function: gst-query-parse-segment (self <gst-query>) (format <gst-format*>)   (rate double) (start_value int64) (stop_value int64)
— Method: parse-segment

Parse a segment query answer. Any of rate, format, start-value, and stop-value may be NULL, which will cause this value to be omitted.

See gst-query-set-segment for an explanation of the function arguments.

query
a <gst-query>
rate
the storage for the rate of the segment, or NULL
format
the storage for the <gst-format> of the values, or NULL
start-value
the storage for the start value, or NULL
stop-value
the storage for the stop value, or NULL