query: use more generic structure for meta params
authorWim Taymans <wim.taymans@collabora.co.uk>
Fri, 6 Jul 2012 09:49:47 +0000 (11:49 +0200)
committerWim Taymans <wim.taymans@collabora.co.uk>
Fri, 6 Jul 2012 09:49:47 +0000 (11:49 +0200)
gst/gstquery.c
gst/gstquery.h
libs/gst/base/gstbasetransform.c
libs/gst/base/gstbasetransform.h

index c610b05..17d4e6b 100644 (file)
@@ -1661,19 +1661,27 @@ gst_query_set_nth_allocation_pool (GstQuery * query, guint index,
 typedef struct
 {
   GType api;
-  guint flags;
+  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
- * @flags: API specific flags
+ * @params: (transfer full) (allow-none): API specific parameters
  *
- * Add @api with @flags as one 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, guint flags)
+gst_query_add_allocation_meta (GstQuery * query, GType api,
+    GstStructure * params)
 {
   GArray *array;
   GstStructure *structure;
@@ -1685,10 +1693,11 @@ gst_query_add_allocation_meta (GstQuery * query, GType api, guint flags)
 
   structure = GST_QUERY_STRUCTURE (query);
   array =
-      ensure_array (structure, GST_QUARK (META), sizeof (AllocationMeta), NULL);
+      ensure_array (structure, GST_QUARK (META), sizeof (AllocationMeta),
+      (GDestroyNotify) allocation_meta_free);
 
   am.api = api;
-  am.flags = flags;
+  am.params = params;
 
   g_array_append_val (array, am);
 }
@@ -1712,7 +1721,8 @@ gst_query_get_n_allocation_metas (GstQuery * query)
 
   structure = GST_QUERY_STRUCTURE (query);
   array =
-      ensure_array (structure, GST_QUARK (META), sizeof (AllocationMeta), NULL);
+      ensure_array (structure, GST_QUARK (META), sizeof (AllocationMeta),
+      (GDestroyNotify) allocation_meta_free);
 
   return array->len;
 }
@@ -1721,7 +1731,7 @@ gst_query_get_n_allocation_metas (GstQuery * query)
  * gst_query_parse_nth_allocation_meta:
  * @query: a GST_QUERY_ALLOCATION type query #GstQuery
  * @index: position in the metadata API array to read
- * @flags: (out) (allow-none): API specific flags
+ * @params: (out) (allow-none): API specific flags
  *
  * Parse an available query and get the metadata API
  * at @index of the metadata API array.
@@ -1730,7 +1740,7 @@ gst_query_get_n_allocation_metas (GstQuery * query)
  */
 GType
 gst_query_parse_nth_allocation_meta (GstQuery * query, guint index,
-    guint * flags)
+    const GstStructure ** params)
 {
   GArray *array;
   GstStructure *structure;
@@ -1740,14 +1750,15 @@ gst_query_parse_nth_allocation_meta (GstQuery * query, guint index,
 
   structure = GST_QUERY_STRUCTURE (query);
   array =
-      ensure_array (structure, GST_QUARK (META), sizeof (AllocationMeta), NULL);
+      ensure_array (structure, GST_QUARK (META), sizeof (AllocationMeta),
+      (GDestroyNotify) allocation_meta_free);
 
   g_return_val_if_fail (index < array->len, 0);
 
   am = &g_array_index (array, AllocationMeta, index);
 
-  if (flags)
-    *flags = am->flags;
+  if (params)
+    *params = am->params;
 
   return am->api;
 }
@@ -1770,7 +1781,8 @@ gst_query_remove_nth_allocation_meta (GstQuery * query, guint index)
 
   structure = GST_QUERY_STRUCTURE (query);
   array =
-      ensure_array (structure, GST_QUARK (META), sizeof (AllocationMeta), NULL);
+      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);
@@ -1800,7 +1812,8 @@ gst_query_find_allocation_meta (GstQuery * query, GType api, guint * index)
 
   structure = GST_QUERY_STRUCTURE (query);
   array =
-      ensure_array (structure, GST_QUARK (META), sizeof (AllocationMeta), NULL);
+      ensure_array (structure, GST_QUARK (META), sizeof (AllocationMeta),
+      (GDestroyNotify) allocation_meta_free);
 
   len = array->len;
   for (i = 0; i < len; i++) {
@@ -1830,8 +1843,8 @@ allocation_param_free (AllocationParam * ap)
 /**
  * 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.
  */
@@ -1892,8 +1905,8 @@ gst_query_get_n_allocation_params (GstQuery * query)
  * 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 none) (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.
@@ -1926,8 +1939,8 @@ gst_query_parse_nth_allocation_param (GstQuery * query, guint index,
  * 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.
index ec05e42..28e893e 100644 (file)
@@ -427,9 +427,10 @@ void            gst_query_set_nth_allocation_param   (GstQuery *query, guint ind
                                                       const GstAllocationParams *params);
 
 /* metadata */
-void            gst_query_add_allocation_meta        (GstQuery *query, GType api, guint flags);
+void            gst_query_add_allocation_meta        (GstQuery *query, GType api, GstStructure *params);
 guint           gst_query_get_n_allocation_metas     (GstQuery *query);
-GType           gst_query_parse_nth_allocation_meta  (GstQuery *query, guint index, guint *flags);
+GType           gst_query_parse_nth_allocation_meta  (GstQuery *query, guint index,
+                                                      const GstStructure **params);
 void            gst_query_remove_nth_allocation_meta (GstQuery *query, guint index);
 gboolean        gst_query_find_allocation_meta       (GstQuery *query, GType api, guint *index);
 
index 9b15768..391114b 100644 (file)
@@ -813,10 +813,10 @@ gst_base_transform_default_decide_allocation (GstBaseTransform * trans,
   n_metas = gst_query_get_n_allocation_metas (query);
   for (i = 0; i < n_metas; i++) {
     GType api;
-    guint flags;
+    const GstStructure *params;
     gboolean remove;
 
-    api = gst_query_parse_nth_allocation_meta (query, i, &flags);
+    api = gst_query_parse_nth_allocation_meta (query, i, &params);
 
     /* by default we remove all metadata, subclasses should implement a
      * filter_meta function */
@@ -828,7 +828,7 @@ gst_base_transform_default_decide_allocation (GstBaseTransform * trans,
       remove = TRUE;
     } else if (G_LIKELY (klass->filter_meta)) {
       /* remove if the subclass said so */
-      remove = !klass->filter_meta (trans, query, api, flags);
+      remove = !klass->filter_meta (trans, query, api, params);
       GST_LOG_OBJECT (trans, "filter_meta for api %s returned: %s",
           g_type_name (api), (remove ? "remove" : "keep"));
     } else {
@@ -1369,11 +1369,11 @@ gst_base_transform_default_propose_allocation (GstBaseTransform * trans,
     n_metas = gst_query_get_n_allocation_metas (decide_query);
     for (i = 0; i < n_metas; i++) {
       GType api;
-      guint flags;
+      const GstStructure *params;
 
-      api = gst_query_parse_nth_allocation_meta (decide_query, i, &flags);
+      api = gst_query_parse_nth_allocation_meta (decide_query, i, &params);
       GST_DEBUG_OBJECT (trans, "proposing metadata %s", g_type_name (api));
-      gst_query_add_allocation_meta (query, api, flags);
+      gst_query_add_allocation_meta (query, api, gst_structure_copy (params));
     }
     ret = TRUE;
   }
index 2ec3910..58a795d 100644 (file)
@@ -226,7 +226,7 @@ struct _GstBaseTransformClass {
   /* decide allocation query for output buffers */
   gboolean      (*decide_allocation)  (GstBaseTransform *trans, GstQuery *query);
   gboolean      (*filter_meta)        (GstBaseTransform *trans, GstQuery *query,
-                                       GType api, guint flags);
+                                       GType api, const GstStructure *params);
 
   /* propose allocation query parameters for input buffers */
   gboolean      (*propose_allocation) (GstBaseTransform *trans, GstQuery *decide_query,