query: add method to check for metadata

Add a method to check if a certain metadata is supported in the ALLOCATION
query.
This commit is contained in:
Wim Taymans 2011-06-23 18:03:22 +02:00
parent 1b381907b5
commit 0aa1465bbc
2 changed files with 37 additions and 0 deletions

View file

@ -1682,6 +1682,7 @@ gst_query_add_allocation_meta (GstQuery * query, const gchar * api)
GstStructure *structure;
g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_ALLOCATION);
g_return_if_fail (api != NULL);
g_return_if_fail (gst_query_is_writable (query));
structure = GST_QUERY_STRUCTURE (query);
@ -1767,6 +1768,41 @@ gst_query_parse_nth_allocation_meta (GstQuery * query, guint index)
return ret;
}
/**
* gst_query_has_allocation_meta
* @query: a GST_QUERY_ALLOCATION type query #GstQuery
* @api: the metadata API
*
* Check if @query has metadata @api set.
*
* Returns: TRUE when @api is in the list of metadata.
*/
gboolean
gst_query_has_allocation_meta (GstQuery * query, const gchar * api)
{
const GValue *value;
GstStructure *structure;
g_return_val_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_ALLOCATION, FALSE);
g_return_val_if_fail (api != NULL, FALSE);
structure = GST_QUERY_STRUCTURE (query);
value = gst_structure_id_get_value (structure, GST_QUARK (META));
if (value) {
GValueArray *array;
GValue *api_value;
guint i;
array = (GValueArray *) g_value_get_boxed (value);
for (i = 0; i < array->n_values; i++) {
api_value = g_value_array_get_nth (array, i);
if (!strcmp (api, g_value_get_string (api_value)))
return TRUE;
}
}
return FALSE;
}
/**
* gst_query_add_allocation_memory
* @query: a GST_QUERY_ALLOCATION type query #GstQuery

View file

@ -363,6 +363,7 @@ void gst_query_parse_allocation_params (GstQuery *query, guint *size,
void gst_query_add_allocation_meta (GstQuery *query, const gchar *api);
guint gst_query_get_n_allocation_metas (GstQuery *query);
const gchar * gst_query_parse_nth_allocation_meta (GstQuery *query, guint index);
gboolean gst_query_has_allocation_meta (GstQuery *query, const gchar *api);
void gst_query_add_allocation_memory (GstQuery *query, const gchar *alloc);
guint gst_query_get_n_allocation_memories (GstQuery *query);