*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
*/
/**
{GST_QUERY_ACCEPT_CAPS, "accept-caps", 0},
{GST_QUERY_CAPS, "caps", 0},
{GST_QUERY_DRAIN, "drain", 0},
- {GST_QUERY_TOC, "toc", 0},
+ {GST_QUERY_CONTEXT, "context", 0},
{0, NULL, 0}
};
gst_structure_free (s);
}
- g_slice_free1 (GST_MINI_OBJECT_SIZE (query), query);
+ g_slice_free1 (sizeof (GstQueryImpl), query);
}
static GstQuery *
return copy;
}
-static void
-gst_query_init (GstQueryImpl * query, gsize size, GstQueryType type)
-{
- gst_mini_object_init (GST_MINI_OBJECT_CAST (query), _gst_query_type, size);
-
- query->query.mini_object.copy = (GstMiniObjectCopyFunction) _gst_query_copy;
- query->query.mini_object.free = (GstMiniObjectFreeFunction) _gst_query_free;
-
- GST_QUERY_TYPE (query) = type;
-}
-
/**
* gst_query_new_position:
* @format: the default #GstFormat for the new query
* Free-function: gst_query_unref
*
* Returns: (transfer full): a #GstQuery
- *
- * Since: 0.10.12
*/
GstQuery *
gst_query_new_latency (void)
* @max_latency: the maximal latency of the upstream elements
*
* Answer a latency query by setting the requested values in the given format.
- *
- * Since: 0.10.12
*/
void
gst_query_set_latency (GstQuery * query, gboolean live,
* @max_latency: (out) (allow-none): the storage for the max latency or NULL
*
* Parse a latency query answer.
- *
- * Since: 0.10.12
*/
void
gst_query_parse_latency (GstQuery * query, gboolean * live,
&query->query.mini_object.refcount))
goto had_parent;
}
- gst_query_init (query, sizeof (GstQueryImpl), type);
+ gst_mini_object_init (GST_MINI_OBJECT_CAST (query), 0, _gst_query_type,
+ (GstMiniObjectCopyFunction) _gst_query_copy, NULL,
+ (GstMiniObjectFreeFunction) _gst_query_free);
+
+ GST_QUERY_TYPE (query) = type;
GST_QUERY_STRUCTURE (query) = structure;
return GST_QUERY_CAST (query);
/* ERRORS */
had_parent:
{
- g_slice_free1 (GST_MINI_OBJECT_SIZE (query), query);
+ g_slice_free1 (sizeof (GstQueryImpl), query);
g_warning ("structure is already owned by another object");
return NULL;
}
* Free-function: gst_query_unref
*
* Returns: (transfer full): a new #GstQuery
- *
- * Since: 0.10.4
*/
GstQuery *
gst_query_new_formats (void)
*
* Set the formats query result fields in @query. The number of formats passed
* in the @formats array must be equal to @n_formats.
- *
- * Since: 0.10.4
*/
void
gst_query_set_formatsv (GstQuery * query, gint n_formats,
* @n_formats: (out) (allow-none): the number of formats in this query.
*
* Parse the number of formats in the formats @query.
- *
- * Since: 0.10.4
*/
void
gst_query_parse_n_formats (GstQuery * query, guint * n_formats)
* Free-function: gst_query_unref
*
* Returns: (transfer full): a new #GstQuery
- *
- * Since: 0.10.20
*/
GstQuery *
gst_query_new_buffering (GstFormat format)
*
* 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.
- *
- * Since: 0.10.20
*/
void
gst_query_set_buffering_percent (GstQuery * query, gboolean busy, gint 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.
- *
- * Since: 0.10.20
*/
void
gst_query_parse_buffering_percent (GstQuery * query, gboolean * busy,
* @mode: a buffering mode
* @avg_in: the average input rate
* @avg_out: the average output rate
- * @buffering_left: amount of buffering time left
+ * @buffering_left: amount of buffering time left in milliseconds
*
* Configures the buffering stats values in @query.
- *
- * Since: 0.10.20
*/
void
gst_query_set_buffering_stats (GstQuery * query, GstBufferingMode mode,
* @mode: (out) (allow-none): a buffering mode, or NULL
* @avg_in: (out) (allow-none): the average input rate, or NULL
* @avg_out: (out) (allow-none): the average output rat, or NULLe
- * @buffering_left: (out) (allow-none): amount of buffering time left, or NULL
+ * @buffering_left: (out) (allow-none): amount of buffering time left in
+ * milliseconds, or NULL
*
* Extracts the buffering stats values from @query.
- *
- * Since: 0.10.20
*/
void
gst_query_parse_buffering_stats (GstQuery * query,
* @estimated_total: estimated total amount of download time
*
* Set the available query result fields in @query.
- *
- * Since: 0.10.20
*/
void
gst_query_set_buffering_range (GstQuery * query, GstFormat format,
* Parse an available query, writing the format into @format, and
* other results into the passed parameters, if the respective parameters
* are non-NULL
- *
- * Since: 0.10.20
*/
void
gst_query_parse_buffering_range (GstQuery * query, GstFormat * format,
* start position of the array should be inferior to @start.
*
* Returns: a #gboolean indicating if the range was added or not.
- *
- * Since: 0.10.31
*/
gboolean
gst_query_add_buffering_range (GstQuery * query, gint64 start, gint64 stop)
* buffered-ranges array of the query's structure.
*
* Returns: the range array size as a #guint.
- *
- * Since: 0.10.31
*/
guint
gst_query_get_n_buffering_ranges (GstQuery * query)
* at the @index of the buffered ranges array.
*
* Returns: a #gboolean indicating if the parsing succeeded.
- *
- * Since: 0.10.31
*/
gboolean
gst_query_parse_nth_buffering_range (GstQuery * query, guint index,
* Free-function: gst_query_unref
*
* Returns: (transfer full): a new #GstQuery
- *
- * Since: 0.10.22
*/
GstQuery *
gst_query_new_uri (void)
* @uri: the URI to set
*
* Answer a URI query by setting the requested URI.
- *
- * Since: 0.10.22
*/
void
gst_query_set_uri (GstQuery * query, const gchar * 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.
- *
- * Since: 0.10.22
*/
void
gst_query_parse_uri (GstQuery * query, gchar ** uri)
* gst_query_parse_nth_allocation_pool:
* @query: A valid #GstQuery of type GST_QUERY_ALLOCATION.
* @index: index to parse
- * @pool: (out) (allow-none) (transfer none): the #GstBufferPool
+ * @pool: (out) (allow-none) (transfer full): the #GstBufferPool
* @size: (out) (allow-none): the size
* @min_buffers: (out) (allow-none): the min buffers
* @max_buffers: (out) (allow-none): the max buffers
*
* Get the pool parameters in @query.
+ *
+ * Unref @pool with gst_object_unref() when it's not needed any more.
*/
void
gst_query_parse_nth_allocation_pool (GstQuery * query, guint index,
}
/**
+ * gst_query_remove_nth_allocation_pool:
+ * @query: a GST_QUERY_ALLOCATION type query #GstQuery
+ * @index: position in the allocation pool array to remove
+ *
+ * Remove the allocation pool at @index of the allocation pool array.
+ *
+ * Since: 1.2
+ */
+void
+gst_query_remove_nth_allocation_pool (GstQuery * query, guint index)
+{
+ GArray *array;
+ GstStructure *structure;
+
+ g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_ALLOCATION);
+ g_return_if_fail (gst_query_is_writable (query));
+
+ structure = GST_QUERY_STRUCTURE (query);
+ array =
+ ensure_array (structure, GST_QUARK (POOL), sizeof (AllocationPool),
+ (GDestroyNotify) allocation_pool_free);
+ g_return_if_fail (index < array->len);
+
+ g_array_remove_index (array, index);
+}
+
+typedef struct
+{
+ GType api;
+ GstStructure *params;
+} AllocationMeta;
+
+static void
+allocation_meta_free (AllocationMeta * am)
+{
+ if (am->params)
+ gst_structure_free (am->params);
+}
+
+/**
* gst_query_add_allocation_meta:
* @query: a GST_QUERY_ALLOCATION type query #GstQuery
* @api: the metadata API
+ * @params: (transfer none) (allow-none): API specific parameters
*
- * Add @api as aone of the supported metadata API to @query.
+ * Add @api with @params as one of the supported metadata API to @query.
*/
void
-gst_query_add_allocation_meta (GstQuery * query, GType api)
+gst_query_add_allocation_meta (GstQuery * query, GType api,
+ const GstStructure * params)
{
GArray *array;
GstStructure *structure;
+ AllocationMeta am;
g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_ALLOCATION);
g_return_if_fail (api != 0);
g_return_if_fail (gst_query_is_writable (query));
structure = GST_QUERY_STRUCTURE (query);
- array = ensure_array (structure, GST_QUARK (META), sizeof (GType), NULL);
+ array =
+ ensure_array (structure, GST_QUARK (META), sizeof (AllocationMeta),
+ (GDestroyNotify) allocation_meta_free);
+
+ am.api = api;
+ am.params = (params ? gst_structure_copy (params) : NULL);
- g_array_append_val (array, api);
+ g_array_append_val (array, am);
}
/**
g_return_val_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_ALLOCATION, 0);
structure = GST_QUERY_STRUCTURE (query);
- array = ensure_array (structure, GST_QUARK (META), sizeof (GType), NULL);
+ array =
+ ensure_array (structure, GST_QUARK (META), sizeof (AllocationMeta),
+ (GDestroyNotify) allocation_meta_free);
return array->len;
}
* gst_query_parse_nth_allocation_meta:
* @query: a GST_QUERY_ALLOCATION type query #GstQuery
* @index: position in the metadata API array to read
+ * @params: (out) (allow-none): API specific flags
*
* Parse an available query and get the metadata API
* at @index of the metadata API array.
* Returns: a #GType of the metadata API at @index.
*/
GType
-gst_query_parse_nth_allocation_meta (GstQuery * query, guint index)
+gst_query_parse_nth_allocation_meta (GstQuery * query, guint index,
+ const GstStructure ** params)
{
GArray *array;
GstStructure *structure;
+ AllocationMeta *am;
g_return_val_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_ALLOCATION, 0);
structure = GST_QUERY_STRUCTURE (query);
- array = ensure_array (structure, GST_QUARK (META), sizeof (GType), NULL);
+ array =
+ ensure_array (structure, GST_QUARK (META), sizeof (AllocationMeta),
+ (GDestroyNotify) allocation_meta_free);
g_return_val_if_fail (index < array->len, 0);
- return g_array_index (array, GType, index);
+ am = &g_array_index (array, AllocationMeta, index);
+
+ if (params)
+ *params = am->params;
+
+ return am->api;
}
/**
g_return_if_fail (gst_query_is_writable (query));
structure = GST_QUERY_STRUCTURE (query);
- array = ensure_array (structure, GST_QUARK (META), sizeof (GType), NULL);
+ array =
+ ensure_array (structure, GST_QUARK (META), sizeof (AllocationMeta),
+ (GDestroyNotify) allocation_meta_free);
g_return_if_fail (index < array->len);
g_array_remove_index (array, index);
}
/**
- * gst_query_has_allocation_meta:
+ * gst_query_find_allocation_meta:
* @query: a GST_QUERY_ALLOCATION type query #GstQuery
* @api: the metadata API
+ * @index: (out) (allow-none): the index
*
- * Check if @query has metadata @api set.
+ * 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.
*
* Returns: TRUE when @api is in the list of metadata.
*/
gboolean
-gst_query_has_allocation_meta (GstQuery * query, GType api)
+gst_query_find_allocation_meta (GstQuery * query, GType api, guint * index)
{
GArray *array;
GstStructure *structure;
g_return_val_if_fail (api != 0, FALSE);
structure = GST_QUERY_STRUCTURE (query);
- array = ensure_array (structure, GST_QUARK (META), sizeof (GType), NULL);
+ array =
+ ensure_array (structure, GST_QUARK (META), sizeof (AllocationMeta),
+ (GDestroyNotify) allocation_meta_free);
len = array->len;
for (i = 0; i < len; i++) {
- if (g_array_index (array, GType, i) == api)
+ AllocationMeta *am = &g_array_index (array, AllocationMeta, i);
+ if (am->api == api) {
+ if (index)
+ *index = i;
return TRUE;
+ }
}
return FALSE;
}
allocation_param_free (AllocationParam * ap)
{
if (ap->allocator)
- gst_allocator_unref (ap->allocator);
+ gst_object_unref (ap->allocator);
}
/**
* gst_query_add_allocation_param:
* @query: a GST_QUERY_ALLOCATION type query #GstQuery
- * @allocator: the memory allocator
- * @params: a #GstAllocationParams
+ * @allocator: (transfer none) (allow-none): the memory allocator
+ * @params: (transfer none) (allow-none): a #GstAllocationParams
*
* Add @allocator and its @params as a supported memory allocator.
*/
sizeof (AllocationParam), (GDestroyNotify) allocation_param_free);
if ((ap.allocator = allocator))
- gst_allocator_ref (allocator);
+ gst_object_ref (allocator);
if (params)
ap.params = *params;
else
* allocator params array of the query's structure.
*
* If no memory allocator is specified, the downstream element can handle
- * the default memory allocator.
+ * 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.
*
* Returns: the allocator array size as a #guint.
*/
* gst_query_parse_nth_allocation_param:
* @query: a GST_QUERY_ALLOCATION type query #GstQuery
* @index: position in the allocator array to read
- * @allocator: (transfer none): variable to hold the result
- * @params: parameters for the allocator
+ * @allocator: (out) (transfer full) (allow-none): variable to hold the result
+ * @params: (out) (allow-none): parameters for the allocator
*
* Parse an available query and get the alloctor and its params
* at @index of the allocator array.
if (allocator)
if ((*allocator = ap->allocator))
- gst_allocator_ref (*allocator);
+ gst_object_ref (*allocator);
if (params)
*params = ap->params;
}
* gst_query_set_nth_allocation_param:
* @query: a GST_QUERY_ALLOCATION type query #GstQuery
* @index: position in the allocator array to set
- * @allocator: (transfer full): new allocator to set
- * @params: parameters for the allocator
+ * @allocator: (transfer none) (allow-none): new allocator to set
+ * @params: (transfer none) (allow-none): parameters for the allocator
*
* Parse an available query and get the alloctor and its params
* at @index of the allocator array.
allocation_param_free (old);
if ((ap.allocator = allocator))
- gst_allocator_ref (allocator);
+ gst_object_ref (allocator);
if (params)
ap.params = *params;
else
}
/**
+ * gst_query_remove_nth_allocation_param:
+ * @query: a GST_QUERY_ALLOCATION type query #GstQuery
+ * @index: position in the allocation param array to remove
+ *
+ * Remove the allocation param at @index of the allocation param array.
+ *
+ * Since: 1.2
+ */
+void
+gst_query_remove_nth_allocation_param (GstQuery * query, guint index)
+{
+ GArray *array;
+ GstStructure *structure;
+
+ g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_ALLOCATION);
+ g_return_if_fail (gst_query_is_writable (query));
+
+ structure = GST_QUERY_STRUCTURE (query);
+ array =
+ ensure_array (structure, GST_QUARK (ALLOCATOR), sizeof (AllocationParam),
+ (GDestroyNotify) allocation_param_free);
+ g_return_if_fail (index < array->len);
+
+ g_array_remove_index (array, index);
+}
+
+/**
* gst_query_new_scheduling:
*
* Constructs a new query object for querying the scheduling properties.
*
* Check if @query has scheduling mode set.
*
+ * <note>
+ * <para>
+ * 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).
+ * </para>
+ * </note>
+ *
* Returns: TRUE when @mode is in the list of scheduling modes.
*/
gboolean
}
/**
+ * gst_query_has_scheduling_mode_with_flags:
+ * @query: a GST_QUERY_SCHEDULING type query #GstQuery
+ * @mode: the scheduling mode
+ * @flags: #GstSchedulingFlags
+ *
+ * Check if @query has scheduling mode set and @flags is set in
+ * query scheduling flags.
+ *
+ * Returns: TRUE when @mode is in the list of scheduling modes
+ * and @flags are compatible with query flags.
+ */
+gboolean
+gst_query_has_scheduling_mode_with_flags (GstQuery * query, GstPadMode mode,
+ GstSchedulingFlags flags)
+{
+ GstSchedulingFlags sched_flags;
+
+ g_return_val_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_SCHEDULING, FALSE);
+
+ gst_query_parse_scheduling (query, &sched_flags, NULL, NULL, NULL);
+
+ return ((flags & sched_flags) == flags) &&
+ gst_query_has_scheduling_mode (query, mode);
+}
+
+/**
* gst_query_new_accept_caps:
* @caps: a fixed #GstCaps
*
GST_QUARK (CAPS)));
}
+/**
+ * gst_query_set_accept_caps_result:
+ * @query: a GST_QUERY_ACCEPT_CAPS type query #GstQuery
+ * @result: the result to set
+ *
+ * Set @result as the result for the @query.
+ */
void
gst_query_set_accept_caps_result (GstQuery * query, gboolean result)
{
GST_QUARK (RESULT), G_TYPE_BOOLEAN, result, NULL);
}
+/**
+ * gst_query_parse_accept_caps_result:
+ * @query: a GST_QUERY_ACCEPT_CAPS type query #GstQuery
+ * @result: location for the result
+ *
+ * Parse the result from @query and store in @result.
+ */
void
gst_query_parse_accept_caps_result (GstQuery * query, gboolean * result)
{
*
* Constructs a new query object for querying the caps.
*
- * The CAPS query should return the* allowable caps for a pad in the context
+ * 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
* 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
*
* Returns: (transfer full): a new #GstQuery
GST_QUARK (CAPS)));
}
+#if 0
void
gst_query_intersect_caps_result (GstQuery * query, GstCaps * filter,
GstCapsIntersectMode mode)
gst_query_set_caps_result (query, res);
gst_caps_unref (res);
}
+#endif
/**
* gst_query_new_drain:
}
/**
- * gst_query_new_toc:
+ * gst_query_new_context:
+ *
+ * Constructs a new query object for querying the pipeline-local context.
*
- * Constructs a new query TOC query object. Use gst_query_unref()
- * when done with it. A TOC query is used to query the full TOC with
- * the UID marker for TOC extending (to insert some new entries).
+ * Free-function: gst_query_unref
*
- * Returns: A #GstQuery.
+ * Returns: (transfer full): a new #GstQuery
+ *
+ * Since: 1.2
*/
GstQuery *
-gst_query_new_toc (void)
+gst_query_new_context (void)
{
GstQuery *query;
GstStructure *structure;
- structure = gst_structure_new_id_empty (GST_QUARK (QUERY_TOC));
- query = gst_query_new_custom (GST_QUERY_TOC, structure);
+ structure = gst_structure_new_id_empty (GST_QUARK (QUERY_CONTEXT));
+ query = gst_query_new_custom (GST_QUERY_CONTEXT, structure);
return query;
}
/**
- * gst_query_set_toc:
- * @query: a #GstQuery with query type GST_QUERY_TOC.
- * @toc: the GstToc to set.
- * @extend_uid: UID which can be used for TOC extending (may be NULL),
- * 0 means root TOC level.
+ * gst_query_set_context:
+ * @query: a #GstQuery with query type GST_QUERY_CONTEXT
+ * @context: the requested #GstContext
+ *
+ * Answer a context query by setting the requested context.
*
- * Answer a TOC query by setting appropriate #GstToc structure.
+ * Since: 1.2
*/
void
-gst_query_set_toc (GstQuery * query, GstToc * toc, const gchar * extend_uid)
+gst_query_set_context (GstQuery * query, GstContext * context)
{
- GstStructure *structure;
- GstStructure *old_structure;
+ GstStructure *s;
- g_return_if_fail (query != NULL);
- g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_TOC);
- g_return_if_fail (toc != NULL);
+ g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_CONTEXT);
- structure = __gst_toc_to_structure (toc);
+ s = GST_QUERY_STRUCTURE (query);
- g_return_if_fail (structure != NULL);
+ gst_structure_id_set (s,
+ GST_QUARK (CONTEXT), GST_TYPE_CONTEXT, context, NULL);
+}
- /* that shouldn't be happen in normal usage */
- old_structure = GST_QUERY_STRUCTURE (query);
- if (old_structure) {
- gst_structure_set_parent_refcount (old_structure, NULL);
- gst_structure_free (old_structure);
- }
+/**
+ * gst_query_parse_context:
+ * @query: The query to parse
+ * @context: (out): A pointer to store the #GstContext
+ *
+ * Get the context from the context @query. The context remains valid as long as
+ * @query remains valid.
+ *
+ * Since: 1.2
+ */
+void
+gst_query_parse_context (GstQuery * query, GstContext ** context)
+{
+ GstStructure *structure;
+ const GValue *v;
- if (extend_uid != NULL)
- __gst_toc_structure_set_extend_uid (structure, extend_uid);
+ g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_CONTEXT);
+ g_return_if_fail (context != NULL);
- gst_structure_set_parent_refcount (structure, &(query->mini_object.refcount));
- GST_QUERY_STRUCTURE (query) = structure;
+ structure = GST_QUERY_STRUCTURE (query);
+ v = gst_structure_id_get_value (structure, GST_QUARK (CONTEXT));
+ if (v)
+ *context = g_value_get_boxed (v);
+ else
+ *context = NULL;
+}
+
+static void
+free_array_string (gpointer ptr)
+{
+ gchar *str = *(gchar **) ptr;
+ g_free (str);
}
/**
- * gst_query_parse_toc:
- * @query: a #GstQuery.
- * @toc: (out): the storage for the received TOC (may be NULL).
- * @extend_uid: (out): the storage for the received extend UID marker (may be NULL),
- * 0 means root TOC level.
+ * gst_query_add_context_type:
+ * @query: a GST_QUERY_CONTEXT type query
+ * @context_type: a context type
+ *
+ * Add a new context type to @query.
*
- * Parse a TOC query, writing the TOC into @toc as a newly
- * allocated #GstToc and extend UID into @extend_uid, if the respective parameters
- * are non-NULL. Use @extend_uid value to insert new entries into the TOC (@extend_uid will
- * act as root entry for newly inserted entries).
- * Free @toc with gst_toc_free() and @extend_uid with g_free() after usage.
+ * Since: 1.2
*/
void
-gst_query_parse_toc (GstQuery * query, GstToc ** toc, gchar ** extend_uid)
+gst_query_add_context_type (GstQuery * query, const gchar * context_type)
{
- const GstStructure *structure;
+ GstStructure *structure;
+ GArray *array;
+ gchar *copy;
- g_return_if_fail (query != NULL);
- g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_TOC);
+ g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_CONTEXT);
+ g_return_if_fail (gst_query_is_writable (query));
- structure = gst_query_get_structure (query);
+ structure = GST_QUERY_STRUCTURE (query);
+ array = ensure_array (structure, GST_QUARK (CONTEXT_TYPES),
+ sizeof (gchar *), free_array_string);
- g_return_if_fail (structure != NULL);
+ copy = g_strdup (context_type);
+ g_array_append_val (array, copy);
+}
- if (toc != NULL)
- *toc = __gst_toc_from_structure (structure);
+/**
+ * gst_query_get_n_context_types:
+ * @query: a GST_QUERY_CONTEXT type query
+ *
+ * Retrieve the number of values currently stored in the
+ * context-types array of the query's structure.
+ *
+ * Returns: the context-types array size as a #guint.
+ *
+ * Since: 1.2
+ */
+guint
+gst_query_get_n_context_types (GstQuery * query)
+{
+ GstStructure *structure;
+ GArray *array;
+
+ g_return_val_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_CONTEXT, 0);
+
+ structure = GST_QUERY_STRUCTURE (query);
+ array = ensure_array (structure, GST_QUARK (CONTEXT_TYPES),
+ sizeof (gchar *), free_array_string);
+
+ return array->len;
+}
+
+/**
+ * gst_query_parse_nth_context_type:
+ * @query: a GST_QUERY_CONTEXT type query
+ * @context_type: (out) (allow-none): the context type, or NULL
+ *
+ * Parse a context type from an existing GST_QUERY_CONTEXT query
+ * from @index.
+ *
+ * Returns: a #gboolean indicating if the parsing succeeded.
+ *
+ * Since: 1.2
+ */
+gboolean
+gst_query_parse_nth_context_type (GstQuery * query, guint index,
+ const gchar ** context_type)
+{
+ GstStructure *structure;
+ GArray *array;
- if (extend_uid != NULL)
- *extend_uid = __gst_toc_structure_get_extend_uid (structure);
+ g_return_val_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_CONTEXT, FALSE);
+
+ structure = GST_QUERY_STRUCTURE (query);
+
+ array = ensure_array (structure, GST_QUARK (CONTEXT_TYPES),
+ sizeof (gchar *), free_array_string);
+ g_return_val_if_fail (index < array->len, FALSE);
+
+ if (context_type)
+ *context_type = g_array_index (array, gchar *, index);
+
+ return TRUE;
+}
+
+/**
+ * gst_query_has_context_type:
+ * @query: a GST_QUERY_CONTEXT type query
+ * @context_type: the context type
+ *
+ * Check if @query is asking for @context_type.
+ *
+ * Returns: %TRUE if @context_type is requested.
+ *
+ * Since: 1.2
+ */
+gboolean
+gst_query_has_context_type (GstQuery * query, const gchar * context_type)
+{
+ guint i, n;
+
+ g_return_val_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_CONTEXT, FALSE);
+ g_return_val_if_fail (context_type != NULL, FALSE);
+
+ n = gst_query_get_n_context_types (query);
+ for (i = 0; i < n; i++) {
+ const gchar *tmp;
+
+ if (gst_query_parse_nth_context_type (query, i, &tmp) &&
+ strcmp (tmp, context_type) == 0)
+ return TRUE;
+ }
+
+
+ return FALSE;
}