From: Wim Taymans Date: Thu, 23 Jun 2011 16:03:22 +0000 (+0200) Subject: query: add method to check for metadata X-Git-Tag: RELEASE-0.11.0~68 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0aa1465bbcecdc1320268966eea8437aaa1ae1f6;p=platform%2Fupstream%2Fgstreamer.git query: add method to check for metadata Add a method to check if a certain metadata is supported in the ALLOCATION query. --- diff --git a/gst/gstquery.c b/gst/gstquery.c index 9c308be..7fcbf2c 100644 --- a/gst/gstquery.c +++ b/gst/gstquery.c @@ -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); @@ -1768,6 +1769,41 @@ gst_query_parse_nth_allocation_meta (GstQuery * query, guint index) } /** + * 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 * @alloc: the memory allocator diff --git a/gst/gstquery.h b/gst/gstquery.h index 96c5506..7b83cbc 100644 --- a/gst/gstquery.h +++ b/gst/gstquery.h @@ -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);