query: make find_allocation_meta method

Make gst_query_find_allocation_meta() that also return the index of the metadata
and replaces gst_query_has_allocation_meta().
This commit is contained in:
Wim Taymans 2012-07-06 11:22:43 +02:00
parent 8173622844
commit 8bca7537e6
3 changed files with 12 additions and 6 deletions

View file

@ -2245,7 +2245,7 @@ gst_query_add_allocation_meta
gst_query_get_n_allocation_metas
gst_query_parse_nth_allocation_meta
gst_query_remove_nth_allocation_meta
gst_query_has_allocation_meta
gst_query_find_allocation_meta
GstSchedulingFlags
gst_query_new_scheduling

View file

@ -1777,16 +1777,19 @@ gst_query_remove_nth_allocation_meta (GstQuery * query, guint 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;
@ -1802,8 +1805,11 @@ gst_query_has_allocation_meta (GstQuery * query, GType api)
len = array->len;
for (i = 0; i < len; i++) {
AllocationMeta *am = &g_array_index (array, AllocationMeta, i);
if (am->api == api)
if (am->api == api) {
if (index)
*index = i;
return TRUE;
}
}
return FALSE;
}

View file

@ -431,7 +431,7 @@ void gst_query_add_allocation_meta (GstQuery *query, GType api
guint gst_query_get_n_allocation_metas (GstQuery *query);
GType gst_query_parse_nth_allocation_meta (GstQuery *query, guint index, guint *flags);
void gst_query_remove_nth_allocation_meta (GstQuery *query, guint index);
gboolean gst_query_has_allocation_meta (GstQuery *query, GType api);
gboolean gst_query_find_allocation_meta (GstQuery *query, GType api, guint *index);
/* scheduling query */