![]() |
![]() |
![]() |
GStreamer 0.10 Core Reference Manual | ![]() |
---|---|---|---|---|
GstQueryGstQuery — Dynamically register new query types. Provide functions to create queries, and to set and parse values in them. |
#include <gst/gst.h> GstQuery; enum GstQueryType; #define GST_QUERY_TYPE (query) #define GST_QUERY_TYPE_NAME (query) GstQueryTypeDefinition; const gchar* gst_query_type_get_name (GstQueryType query); GQuark gst_query_type_to_quark (GstQueryType query); GstQueryType gst_query_type_register (const gchar *nick, const gchar *description); GstQueryType gst_query_type_get_by_nick (const gchar *nick); gboolean gst_query_types_contains (const GstQueryType *types, GstQueryType type); const GstQueryTypeDefinition* gst_query_type_get_details (GstQueryType type); GstIterator* gst_query_type_iterate_definitions (void); #define gst_query_ref (q) #define gst_query_unref (q) #define gst_query_copy (q) #define gst_query_make_writable (q) GstQuery* gst_query_new_application (GstQueryType type, GstStructure *structure); GstStructure* gst_query_get_structure (GstQuery *query); GstQuery* gst_query_new_convert (GstFormat src_format, gint64 value, GstFormat dest_format); void gst_query_set_convert (GstQuery *query, GstFormat src_format, gint64 src_value, GstFormat dest_format, gint64 dest_value); void gst_query_parse_convert (GstQuery *query, GstFormat *src_format, gint64 *src_value, GstFormat *dest_format, gint64 *dest_value); GstQuery* gst_query_new_position (GstFormat format); void gst_query_set_position (GstQuery *query, GstFormat format, gint64 cur); void gst_query_parse_position (GstQuery *query, GstFormat *format, gint64 *cur); GstQuery* gst_query_new_duration (GstFormat format); void gst_query_set_duration (GstQuery *query, GstFormat format, gint64 duration); void gst_query_parse_duration (GstQuery *query, GstFormat *format, gint64 *duration); GstQuery* gst_query_new_seeking (GstFormat format); void gst_query_set_seeking (GstQuery *query, GstFormat format, gboolean seekable, gint64 segment_start, gint64 segment_end); void gst_query_parse_seeking (GstQuery *query, GstFormat *format, gboolean *seekable, gint64 *segment_start, gint64 *segment_end); GstQuery* gst_query_new_formats (void); void gst_query_set_formats (GstQuery *query, gint n_formats, ...); void gst_query_set_formatsv (GstQuery *query, gint n_formats, GstFormat *formats); void gst_query_parse_formats_length (GstQuery *query, guint *n_formats); void gst_query_parse_formats_nth (GstQuery *query, guint nth, GstFormat *format); GstQuery* gst_query_new_segment (GstFormat format); void gst_query_set_segment (GstQuery *query, gdouble rate, GstFormat format, gint64 start_value, gint64 stop_value); void gst_query_parse_segment (GstQuery *query, gdouble *rate, GstFormat *format, gint64 *start_value, gint64 *stop_value);
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:
Example 13. Query duration on 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)
typedef struct { GstMiniObject mini_object; GstQueryType type; GstStructure *structure; } GstQuery;
The GstQuery structure.
mini_object
;GstMiniObjectmini_object
The parent GstMiniObject type
The parent GstMiniObject type
GstMiniObjectGstMiniObjectGstQueryType type
;GstQueryTypetype
the GstQueryType
the GstQueryType
GstQueryTypeGstQueryTypeGstStructure *structure
;GstStructurestructure
the GstStructure containing the query details.
the GstStructure containing the query details.
GstStructureGstStructure
GstMiniObject mini_object ; |
The parent GstMiniObject type |
GstQueryType type ; |
the GstQueryType |
GstStructure *structure ; |
the GstStructure containing the query details. |
typedef enum { GST_QUERY_NONE = 0, GST_QUERY_POSITION, GST_QUERY_DURATION, GST_QUERY_LATENCY, GST_QUERY_JITTER, /* not in draft-query, necessary? */ GST_QUERY_RATE, GST_QUERY_SEEKING, GST_QUERY_SEGMENT, GST_QUERY_CONVERT, GST_QUERY_FORMATS } GstQueryType;
Standard predefined Query types
GST_QUERY_NONE
GST_QUERY_NONE
invalid query type
invalid query type
GST_QUERY_POSITION
GST_QUERY_POSITION
current position in stream
current position in stream
GST_QUERY_DURATION
GST_QUERY_DURATION
total duration of the stream
total duration of the stream
GST_QUERY_LATENCY
GST_QUERY_LATENCY
latency of stream
latency of stream
GST_QUERY_JITTER
GST_QUERY_JITTER
current jitter of stream
current jitter of stream
GST_QUERY_RATE
GST_QUERY_RATE
current rate of the stream
current rate of the stream
GST_QUERY_SEEKING
GST_QUERY_SEEKING
seeking capabilities
seeking capabilities
GST_QUERY_SEGMENT
GST_QUERY_SEGMENT
segment start/stop positions
segment start/stop positions
GST_QUERY_CONVERT
GST_QUERY_CONVERT
convert values between formats
convert values between formats
GST_QUERY_FORMATS
GST_QUERY_FORMATS
query supported formats for convert
query supported formats for convert
#define GST_QUERY_TYPE(query) (((GstQuery*)(query))->type)
Get the GstQueryType of the query.
query
:query
the query to query
the query to query
query : |
the query to query |
#define GST_QUERY_TYPE_NAME(query) (gst_query_type_get_name(GST_QUERY_TYPE(query)))
Get a constant string representation of the GstQueryType of the query.
query
:query
the query to query
the query to query
query : |
the query to query |
Since 0.10.4
typedef struct { GstQueryType value; gchar *nick; gchar *description; GQuark quark; } GstQueryTypeDefinition;
A Query Type definition
value
;GstQueryTypevalue
the unique id of the Query type
the unique id of the Query type
gchar *nick
;gcharnick
a short nick
a short nick
gchar *description
;gchardescription
a longer description of the query type
a longer description of the query type
GQuark quark
;GQuarkquark
the quark for the nick
the quark for the nick
GstQueryType value ; |
the unique id of the Query type |
gchar *nick ; |
a short nick |
gchar *description ; |
a longer description of the query type |
GQuark quark ; |
the quark for the nick |
const gchar* gst_query_type_get_name (GstQueryType query);
Get a printable name for the given query type. Do not modify or free.
query
:query
the query type
the query type
Returns :Returns a reference to the static name of the query.
a reference to the static name of the query.
query : |
the query type |
Returns : | a reference to the static name of the query. |
GQuark gst_query_type_to_quark (GstQueryType query);
Get the unique quark for the given query type.
query
:query
the query type
the query type
Returns :Returns the quark associated with the query type
the quark associated with the query type
query : |
the query type |
Returns : | the quark associated with the query type |
GstQueryType gst_query_type_register (const gchar *nick, const gchar *description);
Create a new GstQueryType based on the nick or return an already registered query with that nick
nick
:nick
The nick of the new query
The nick of the new query
description
:description
The description of the new query
The description of the new query
Returns :Returns A new GstQueryType or an already registered query
with the same nick.
A new GstQueryType or an already registered query
with the same nick.
nick : |
The nick of the new query |
description : |
The description of the new query |
Returns : | A new GstQueryType or an already registered query with the same nick. |
GstQueryType gst_query_type_get_by_nick (const gchar *nick);
Get the query type registered with nick
.
nick
:nick
The nick of the query
The nick of the query
Returns :Returns The query registered with nick
or GST_QUERY_NONE
if the query was not registered.
The query registered with nick
or GST_QUERY_NONE
if the query was not registered.
nick
GST_QUERY_NONEGST_QUERY_NONE
nick : |
The nick of the query |
Returns : | The query registered with nick or GST_QUERY_NONE
if the query was not registered.
|
gboolean gst_query_types_contains (const GstQueryType *types, GstQueryType type);
See if the given GstQueryType is inside the types
query types array.
types
:types
The query array to search
The query array to search
type
:type
the GstQueryType to find
the GstQueryType to find
GstQueryTypeGstQueryTypeReturns :Returns TRUE if the type is found inside the array
TRUE if the type is found inside the array
types : |
The query array to search |
type : |
the GstQueryType to find |
Returns : | TRUE if the type is found inside the array |
const GstQueryTypeDefinition* gst_query_type_get_details (GstQueryType type);
Get details about the given GstQueryType.
type
:type
a GstQueryType
a GstQueryType
GstQueryTypeGstQueryTypeReturns :Returns The GstQueryTypeDefinition for type
or NULL on failure.
The GstQueryTypeDefinition for type
or NULL on failure.
GstQueryTypeDefinitionGstQueryTypeDefinitiontype
type : |
a GstQueryType |
Returns : | The GstQueryTypeDefinition for type or NULL on failure.
|
GstIterator* gst_query_type_iterate_definitions (void);
Get a GstIterator of all the registered query types. The definitions iterated over are read only.
Returns : | A GstIterator of GstQueryTypeDefinition. |
#define gst_query_ref(q) GST_QUERY (gst_mini_object_ref (GST_MINI_OBJECT (q)))
Increases the refcount of the given query by one.
#define gst_query_unref(q) gst_mini_object_unref (GST_MINI_OBJECT (q))
Decreases the refcount of the query. If the refcount reaches 0, the query will be freed.
#define gst_query_copy(q) GST_QUERY (gst_mini_object_copy (GST_MINI_OBJECT (q)))
Copies the given query using the copy function of the parent GstData structure.
#define gst_query_make_writable(q) GST_QUERY (gst_mini_object_make_writable (GST_MINI_OBJECT (q)))
Makes a writable query from the given query.
GstQuery* gst_query_new_application (GstQueryType type, GstStructure *structure);
Constructs a new custom application query object. Use gst_query_unref()
when done with it.
GstStructure* gst_query_get_structure (GstQuery *query);
Get the structure of a query.
query
:query
a GstQuery
a GstQuery
GstQueryGstQueryReturns :Returns The GstStructure of the query. The structure is still owned
by the query and will therefore be freed when the query is unreffed.
The GstStructure of the query. The structure is still owned
by the query and will therefore be freed when the query is unreffed.
GstStructureGstStructure
query : |
a GstQuery |
Returns : | The GstStructure of the query. The structure is still owned by the query and will therefore be freed when the query is unreffed. |
GstQuery* gst_query_new_convert (GstFormat src_format, gint64 value, GstFormat dest_format);
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
:src_format
the source GstFormat for the new query
the source GstFormat for the new query
GstFormatGstFormatvalue
:value
the value to convert
the value to convert
dest_format
:dest_format
the target GstFormat
the target GstFormat
GstFormatGstFormatReturns :Returns A GstQuery
A GstQuery
GstQueryGstQuery
src_format : |
the source GstFormat for the new query |
value : |
the value to convert |
dest_format : |
the target GstFormat |
Returns : | A GstQuery |
void gst_query_set_convert (GstQuery *query, GstFormat src_format, gint64 src_value, GstFormat dest_format, gint64 dest_value);
Answer a convert query by setting the requested values.
query
:query
a GstQuery
a GstQuery
GstQueryGstQuerysrc_format
:src_format
the source GstFormat
the source GstFormat
GstFormatGstFormatsrc_value
:src_value
the source value
the source value
dest_format
:dest_format
the destination GstFormat
the destination GstFormat
GstFormatGstFormatdest_value
:dest_value
the destination value
the destination value
query : |
a GstQuery |
src_format : |
the source GstFormat |
src_value : |
the source value |
dest_format : |
the destination GstFormat |
dest_value : |
the destination value |
void gst_query_parse_convert (GstQuery *query, GstFormat *src_format, gint64 *src_value, GstFormat *dest_format, gint64 *dest_value);
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
:query
a GstQuery
a GstQuery
GstQueryGstQuerysrc_format
:src_format
the storage for the GstFormat of the source value, or NULL
the storage for the GstFormat of the source value, or NULL
GstFormatGstFormatsrc_value
:src_value
the storage for the source value, or NULL
the storage for the source value, or NULL
dest_format
:dest_format
the storage for the GstFormat of the destination value, or NULL
the storage for the GstFormat of the destination value, or NULL
GstFormatGstFormatdest_value
:dest_value
the storage for the destination value, or NULL
the storage for the destination value, or NULL
query : |
a GstQuery |
src_format : |
the storage for the GstFormat of the source value, or NULL |
src_value : |
the storage for the source value, or NULL |
dest_format : |
the storage for the GstFormat of the destination value, or NULL |
dest_value : |
the storage for the destination value, or NULL |
GstQuery* gst_query_new_position (GstFormat format);
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.
void gst_query_set_position (GstQuery *query, GstFormat format, gint64 cur);
Answer a position query by setting the requested value in the given format.
query
:query
a GstQuery with query type GST_QUERY_POSITION
a GstQuery with query type GST_QUERY_POSITION
GstQueryGstQueryformat
:format
the requested GstFormat
the requested GstFormat
GstFormatGstFormatcur
:cur
the position to set
the position to set
query : |
a GstQuery with query type GST_QUERY_POSITION |
format : |
the requested GstFormat |
cur : |
the position to set |
void gst_query_parse_position (GstQuery *query, GstFormat *format, gint64 *cur);
Parse a position query, writing the format into format
, and the position
into cur
, if the respective parameters are non-NULL.
query
:query
a GstQuery
a GstQuery
GstQueryGstQueryformat
:format
the storage for the GstFormat of the position values (may be NULL)
the storage for the GstFormat of the position values (may be NULL)
GstFormatGstFormatcur
:cur
the storage for the current position (may be NULL)
the storage for the current position (may be NULL)
query : |
a GstQuery |
format : |
the storage for the GstFormat of the position values (may be NULL) |
cur : |
the storage for the current position (may be NULL) |
GstQuery* gst_query_new_duration (GstFormat format);
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.
void gst_query_set_duration (GstQuery *query, GstFormat format, gint64 duration);
Answer a duration query by setting the requested value in the given format.
query
:query
a GstQuery
a GstQuery
GstQueryGstQueryformat
:format
the GstFormat for the duration
the GstFormat for the duration
GstFormatGstFormatduration
:duration
the duration of the stream
the duration of the stream
query : |
a GstQuery |
format : |
the GstFormat for the duration |
duration : |
the duration of the stream |
void gst_query_parse_duration (GstQuery *query, GstFormat *format, gint64 *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
:query
a GstQuery
a GstQuery
GstQueryGstQueryformat
:format
the storage for the GstFormat of the duration value, or NULL.
the storage for the GstFormat of the duration value, or NULL.
GstFormatGstFormatduration
:duration
the storage for the total duration, or NULL.
the storage for the total duration, or NULL.
query : |
a GstQuery |
format : |
the storage for the GstFormat of the duration value, or NULL. |
duration : |
the storage for the total duration, or NULL. |
GstQuery* gst_query_new_seeking (GstFormat format);
Constructs a new query object for querying seeking properties of the stream.
void gst_query_set_seeking (GstQuery *query, GstFormat format, gboolean seekable, gint64 segment_start, gint64 segment_end);
Set the seeking query result fields in query
.
query
:query
a GstQuery
a GstQuery
GstQueryGstQueryformat
:format
the format to set for the segment_start
and segment_end
values
the format to set for the segment_start
and segment_end
values
segment_start
segment_end
seekable
:seekable
the seekable flag to set
the seekable flag to set
segment_start
:segment_start
the segment_start to set
the segment_start to set
segment_end
:segment_end
the segment_end to set
the segment_end to set
query : |
a GstQuery |
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 |
void gst_query_parse_seeking (GstQuery *query, GstFormat *format, gboolean *seekable, gint64 *segment_start, gint64 *segment_end);
Parse a seeking query, writing the format into format
, and
other results into the passed parameters, if the respective parameters
are non-NULL
query
:query
a GST_QUERY_SEEKING type query GstQuery
a GST_QUERY_SEEKING type query GstQuery
GstQueryGstQueryformat
:format
the format to set for the segment_start
and segment_end
values
the format to set for the segment_start
and segment_end
values
segment_start
segment_end
seekable
:seekable
the seekable flag to set
the seekable flag to set
segment_start
:segment_start
the segment_start to set
the segment_start to set
segment_end
:segment_end
the segment_end to set
the segment_end to set
query : |
a GST_QUERY_SEEKING type query GstQuery |
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 |
GstQuery* gst_query_new_formats (void);
Constructs a new query object for querying formats of the stream.
Since 0.10.4
void gst_query_set_formats (GstQuery *query, gint n_formats, ...);
Set the formats query result fields in query
. The number of formats passed
must be equal to n_formats
.
query
:query
a GstQuery
a GstQuery
GstQueryGstQueryn_formats
:n_formats
the number of formats to set.
the number of formats to set.
...
:...
A number of GstFormats
equal to n_formats
.
A number of GstFormats
equal to n_formats
.
GstFormats
n_formats
query : |
a GstQuery |
n_formats : |
the number of formats to set. |
... : |
A number of GstFormats equal to n_formats .
|
void gst_query_set_formatsv (GstQuery *query, gint n_formats, GstFormat *formats);
Set the formats query result fields in query
. The number of formats passed
in the formats
array must be equal to n_formats
.
query
:query
a GstQuery
a GstQuery
GstQueryGstQueryn_formats
:n_formats
the number of formats to set.
the number of formats to set.
formats
:formats
An array containing n_formats
GstFormat
values.
An array containing n_formats
GstFormat
values.
n_formats
GstFormat
query : |
a GstQuery |
n_formats : |
the number of formats to set. |
formats : |
An array containing n_formats GstFormat values.
|
Since 0.10.4
void gst_query_parse_formats_length (GstQuery *query, guint *n_formats);
Parse the number of formats in the formats query
.
query
:query
a GstQuery
a GstQuery
GstQueryGstQueryn_formats
:n_formats
the number of formats in this query.
the number of formats in this query.
query : |
a GstQuery |
n_formats : |
the number of formats in this query. |
Since 0.10.4
void gst_query_parse_formats_nth (GstQuery *query, guint nth, GstFormat *format);
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
:query
a GstQuery
a GstQuery
GstQueryGstQuerynth
:nth
the nth format to retrieve.
the nth format to retrieve.
format
:format
a pointer to store the nth format
a pointer to store the nth format
query : |
a GstQuery |
nth : |
the nth format to retrieve. |
format : |
a pointer to store the nth format |
Since 0.10.4
GstQuery* gst_query_new_segment (GstFormat format);
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.
void gst_query_set_segment (GstQuery *query, gdouble rate, GstFormat format, gint64 start_value, gint64 stop_value);
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
:query
a GstQuery
a GstQuery
GstQueryGstQueryrate
:rate
the rate of the segment
the rate of the segment
format
:format
the GstFormat of the segment values (start_value
and stop_value
)
the GstFormat of the segment values (start_value
and stop_value
)
GstFormatGstFormatstart_value
stop_value
start_value
:start_value
the start value
the start value
stop_value
:stop_value
the stop value
the stop value
query : |
a GstQuery |
rate : |
the rate of the segment |
format : |
the GstFormat of the segment values (start_value and stop_value )
|
start_value : |
the start value |
stop_value : |
the stop value |
void gst_query_parse_segment (GstQuery *query, gdouble *rate, GstFormat *format, gint64 *start_value, gint64 *stop_value);
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
:query
a GstQuery
a GstQuery
GstQueryGstQueryrate
:rate
the storage for the rate of the segment, or NULL
the storage for the rate of the segment, or NULL
format
:format
the storage for the GstFormat of the values, or NULL
the storage for the GstFormat of the values, or NULL
GstFormatGstFormatstart_value
:start_value
the storage for the start value, or NULL
the storage for the start value, or NULL
stop_value
:stop_value
the storage for the stop value, or NULL
the storage for the stop value, or NULL
query : |
a GstQuery |
rate : |
the storage for the rate of the segment, or NULL |
format : |
the storage for the GstFormat 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 |