Query

Queries can be performed on pads (gst_pad_query()) and elements (gst_element_query()). Please note that some queries might need a running pipeline to work.

Queries can be created using the gst_query_new_*() functions. Query values can be set using gst_query_set_*(), and parsed using gst_query_parse_*() helpers.

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

Last reviewed on 2012-03-29 (0.11.3)

class Query {}

Constructors

this
this(GstQuery* gstQuery)

Sets our main struct and passes it to the parent class

this
this(GstQueryType type, Structure structure)

Constructs a new custom query object. Use gst_query_unref() when done with it. Free-function: gst_query_unref

this
this(GstFormat srcFormat, long value, GstFormat destFormat)

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. Free-function: gst_query_unref

this
this(Caps filter)

Constructs a new query object for querying the caps. The CAPS query should return the allowable caps for a pad in the context of the element's state, its link to other elements, and the devices or files it has opened. These caps must be a subset of the pad template caps. In the NULL state with no links, the CAPS query should ideally return the same caps as the pad template. In rare circumstances, an object property can affect the caps returned by the CAPS query, but this is discouraged. For most filters, the caps returned by CAPS query is directly affected by the allowed caps on other pads. For demuxers and decoders, the caps returned by the srcpad's getcaps function is directly related to the stream data. Again, the CAPS query should return the most specific caps it reasonably can, since this helps with autoplugging. The filter is used to restrict the result caps, only the caps matching filter should be returned from the CAPS query. Specifying a filter might greatly reduce the amount of processing an element needs to do. Free-function: gst_query_unref

this
this(GstFormat format)

Constructs a new query object for querying the buffering status of a stream. Free-function: gst_query_unref

this
this(Caps caps, int needPool)

Constructs a new query object for querying the allocation properties. Free-function: gst_query_unref

this
this(string contextType)

Constructs a new query object for querying the pipeline-local context. Free-function: gst_query_unref Since 1.2

Members

Functions

addAllocationMeta
void addAllocationMeta(GType api, Structure params)

Add api with params as one of the supported metadata API to query.

addAllocationParam
void addAllocationParam(Allocator allocator, GstAllocationParams* params)

Add allocator and its params as a supported memory allocator.

addAllocationPool
void addAllocationPool(BufferPool pool, uint size, uint minBuffers, uint maxBuffers)

Set the pool parameters in query.

addBufferingRange
int addBufferingRange(long start, long stop)

Set the buffering-ranges array field in query. The current last start position of the array should be inferior to start.

addSchedulingMode
void addSchedulingMode(GstPadMode mode)

Add mode as aone of the supported scheduling modes to query.

copy
Query copy()

Copies the given query using the copy function of the parent GstStructure. Free-function: gst_query_unref

doref
Query doref()

Increases the refcount of the given query by one.

findAllocationMeta
int findAllocationMeta(GType api, uint index)

Check if query has metadata api set. When this function returns TRUE, index will contain the index where the requested API and the flags can be found.

getNAllocationMetas
uint getNAllocationMetas()

Retrieve the number of values currently stored in the meta API array of the query's structure.

getNAllocationParams
uint getNAllocationParams()

Retrieve the number of values currently stored in the allocator params array of the query's structure. If no memory allocator is specified, the downstream element can handle the default memory allocator. The first memory allocator in the query should be generic and allow mapping to system memory, all following allocators should be ordered by preference with the preferred one first.

getNAllocationPools
uint getNAllocationPools()

Retrieve the number of values currently stored in the pool array of the query's structure.

getNBufferingRanges
uint getNBufferingRanges()

Retrieve the number of values currently stored in the buffered-ranges array of the query's structure.

getNSchedulingModes
uint getNSchedulingModes()

Retrieve the number of values currently stored in the scheduling mode array of the query's structure.

getQueryStruct
GstQuery* getQueryStruct()

Get the main Gtk struct

getStruct
void* getStruct()

the main Gtk struct as a void*

getStructure
Structure getStructure()

Get the structure of a query.

hasSchedulingMode
int hasSchedulingMode(GstPadMode mode)

Check if query has scheduling mode set. Note When checking if upstream supports pull mode, it is usually not enough to just check for GST_PAD_MODE_PULL with this function, you also want to check whether the scheduling flags returned by gst_query_parse_scheduling() have the seeking flag set (meaning random access is supported, not only sequential pulls).

hasSchedulingModeWithFlags
int hasSchedulingModeWithFlags(GstPadMode mode, GstSchedulingFlags flags)

Check if query has scheduling mode set and flags is set in query scheduling flags.

parseAcceptCaps
void parseAcceptCaps(Caps caps)

Get the caps from query. The caps remains valid as long as query remains valid.

parseAcceptCapsResult
void parseAcceptCapsResult(int result)

Parse the result from query and store in result.

parseAllocation
void parseAllocation(Caps caps, int needPool)

Parse an allocation query, writing the requested caps in caps and whether a pool is needed in need_pool, if the respective parameters are non-NULL.

parseBufferingPercent
void parseBufferingPercent(int busy, int percent)

Get the percentage of buffered data. This is a value between 0 and 100. The busy indicator is TRUE when the buffering is in progress.

parseBufferingRange
void parseBufferingRange(GstFormat format, long start, long stop, long estimatedTotal)

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

parseBufferingStats
void parseBufferingStats(GstBufferingMode mode, int avgIn, int avgOut, long bufferingLeft)

Extracts the buffering stats values from query.

parseCaps
void parseCaps(Caps filter)

Get the filter from the caps query. The caps remains valid as long as query remains valid.

parseCapsResult
void parseCapsResult(Caps caps)

Get the caps result from query. The caps remains valid as long as query remains valid.

parseContext
void parseContext(Context context)

Get the context from the context query. The context remains valid as long as query remains valid. Since 1.2

parseContextType
int parseContextType(string contextType)

Parse a context type from an existing GST_QUERY_CONTEXT query. Since 1.2

parseConvert
void parseConvert(GstFormat srcFormat, long srcValue, GstFormat destFormat, long destValue)

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.

parseDuration
void parseDuration(GstFormat format, long 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.

parseLatency
void parseLatency(int live, GstClockTime minLatency, GstClockTime maxLatency)

Parse a latency query answer.

parseNFormats
void parseNFormats(uint nFormats)

Parse the number of formats in the formats query.

parseNthAllocationMeta
GType parseNthAllocationMeta(uint index, Structure params)

Parse an available query and get the metadata API at index of the metadata API array.

parseNthAllocationParam
void parseNthAllocationParam(uint index, Allocator allocator, GstAllocationParams params)

Parse an available query and get the alloctor and its params at index of the allocator array.

parseNthAllocationPool
void parseNthAllocationPool(uint index, BufferPool pool, uint size, uint minBuffers, uint maxBuffers)

Get the pool parameters in query. Unref pool with gst_object_unref() when it's not needed any more.

parseNthBufferingRange
int parseNthBufferingRange(uint index, long start, long stop)

Parse an available query and get the start and stop values stored at the index of the buffered ranges array.

parseNthFormat
void parseNthFormat(uint 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.

parseNthSchedulingMode
GstPadMode parseNthSchedulingMode(uint index)

Parse an available query and get the scheduling mode at index of the scheduling modes array.

parsePosition
void parsePosition(GstFormat format, long cur)

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

parseScheduling
void parseScheduling(GstSchedulingFlags flags, int minsize, int maxsize, int alig)

Set the scheduling properties.

parseSeeking
void parseSeeking(GstFormat format, int seekable, long segmentStart, long segmentEnd)

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

parseSegment
void parseSegment(double rate, GstFormat format, long startValue, long stopValue)

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.

parseUri
void parseUri(string uri)

Parse an URI query, writing the URI into uri as a newly allocated string, if the respective parameters are non-NULL. Free the string with g_free() after usage.

removeNthAllocationMeta
void removeNthAllocationMeta(uint index)

Remove the metadata API at index of the metadata API array.

removeNthAllocationParam
void removeNthAllocationParam(uint index)

Remove the allocation param at index of the allocation param array. Since 1.2

removeNthAllocationPool
void removeNthAllocationPool(uint index)

Remove the allocation pool at index of the allocation pool array. Since 1.2

setAcceptCapsResult
void setAcceptCapsResult(int result)

Set result as the result for the query.

setBufferingPercent
void setBufferingPercent(int busy, int percent)

Set the percentage of buffered data. This is a value between 0 and 100. The busy indicator is TRUE when the buffering is in progress.

setBufferingRange
void setBufferingRange(GstFormat format, long start, long stop, long estimatedTotal)

Set the available query result fields in query.

setBufferingStats
void setBufferingStats(GstBufferingMode mode, int avgIn, int avgOut, long bufferingLeft)

Configures the buffering stats values in query.

setCapsResult
void setCapsResult(Caps caps)

Set the caps result in query.

setContext
void setContext(Context context)

Answer a context query by setting the requested context. Since 1.2

setConvert
void setConvert(GstFormat srcFormat, long srcValue, GstFormat destFormat, long destValue)

Answer a convert query by setting the requested values.

setDuration
void setDuration(GstFormat format, long duration)

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

setFormatsv
void setFormatsv(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.

setLatency
void setLatency(int live, GstClockTime minLatency, GstClockTime maxLatency)

Answer a latency query by setting the requested values in the given format.

setNthAllocationParam
void setNthAllocationParam(uint index, GstAllocator allocator, GstAllocationParams params)

Parse an available query and get the alloctor and its params at index of the allocator array.

setNthAllocationPool
void setNthAllocationPool(uint index, BufferPool pool, uint size, uint minBuffers, uint maxBuffers)

Set the pool parameters in query.

setPosition
void setPosition(GstFormat format, long cur)

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

setScheduling
void setScheduling(GstSchedulingFlags flags, int minsize, int maxsize, int alig)

Set the scheduling properties.

setSeeking
void setSeeking(GstFormat format, int seekable, long segmentStart, long segmentEnd)

Set the seeking query result fields in query.

setSegment
void setSegment(double rate, GstFormat format, long startValue, long stopValue)

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.

setUri
void setUri(string uri)

Answer a URI query by setting the requested URI.

unref
void unref()

Decreases the refcount of the query. If the refcount reaches 0, the query will be freed.

writableStructure
Structure writableStructure()

Get the structure of a query. This method should be called with a writable query so that the returned structure is guranteed to be writable.

Static functions

newAcceptCaps
Query newAcceptCaps(Caps caps)
Undocumented in source. Be warned that the author may not have intended to support it.
newDrain
Query newDrain()
Undocumented in source. Be warned that the author may not have intended to support it.
newDuration
Query newDuration(GstFormat format)
Undocumented in source. Be warned that the author may not have intended to support it.
newFormats
Query newFormats()
Undocumented in source. Be warned that the author may not have intended to support it.
newLatency
Query newLatency()
Undocumented in source. Be warned that the author may not have intended to support it.
newPosition
Query newPosition(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.

newScheduling
Query newScheduling()
Undocumented in source. Be warned that the author may not have intended to support it.
newSeeking
Query newSeeking(GstFormat format)
Undocumented in source. Be warned that the author may not have intended to support it.
newSegment
Query newSegment(GstFormat format)
Undocumented in source. Be warned that the author may not have intended to support it.
newUri
Query newUri()
Undocumented in source. Be warned that the author may not have intended to support it.
replace
int replace(Query oldQuery, Query newQuery)

Modifies a pointer to a GstQuery to point to a different GstQuery. The modification is done atomically (so this is useful for ensuring thread safety in some cases), and the reference counts are updated appropriately (the old query is unreffed, the new one is reffed). Either new_query or the GstQuery pointed to by old_query may be NULL.

typeGetFlags
GstQueryTypeFlags typeGetFlags(GstQueryType type)

Gets the GstQueryTypeFlags associated with type.

typeGetName
string typeGetName(GstQueryType type)

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

typeToQuark
GQuark typeToQuark(GstQueryType type)

Get the unique quark for the given query type.

Variables

gstQuery
GstQuery* gstQuery;

the main Gtk struct

Meta