query: make find_allocation_meta method
authorWim Taymans <wim.taymans@collabora.co.uk>
Fri, 6 Jul 2012 09:22:43 +0000 (11:22 +0200)
committerWim Taymans <wim.taymans@collabora.co.uk>
Fri, 6 Jul 2012 09:22:43 +0000 (11:22 +0200)
Make gst_query_find_allocation_meta() that also return the index of the metadata
and replaces gst_query_has_allocation_meta().

docs/gst/gstreamer-sections.txt
gst/gstquery.c
gst/gstquery.h

index 22f4667..467a66f 100644 (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
index a831d63..c610b05 100644 (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;
 }
index be43a90..ec05e42 100644 (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 */