aggregator: Implement propose allocation
authorOlivier Crête <olivier.crete@collabora.com>
Sun, 21 May 2017 13:19:17 +0000 (15:19 +0200)
committerTim-Philipp Müller <tim@centricular.com>
Sat, 2 Dec 2017 15:10:27 +0000 (15:10 +0000)
https://bugzilla.gnome.org/show_bug.cgi?id=782918

libs/gst/base/gstaggregator.c
libs/gst/base/gstaggregator.h

index abc0077..ce2c94f 100644 (file)
@@ -2088,6 +2088,45 @@ gst_aggregator_default_sink_query (GstAggregator * self,
 {
   GstPad *pad = GST_PAD (aggpad);
 
+  if (GST_QUERY_TYPE (query) == GST_QUERY_ALLOCATION) {
+    GstQuery *decide_query = NULL;
+    GstAggregatorClass *agg_class;
+    gboolean ret;
+
+    GST_OBJECT_LOCK (self);
+    PAD_LOCK (aggpad);
+    if (G_UNLIKELY (!aggpad->priv->negotiated)) {
+      GST_DEBUG_OBJECT (self,
+          "not negotiated yet, can't answer ALLOCATION query");
+      PAD_UNLOCK (aggpad);
+      GST_OBJECT_UNLOCK (self);
+
+      return FALSE;
+    }
+
+    if ((decide_query = self->priv->allocation_query))
+      gst_query_ref (decide_query);
+    PAD_UNLOCK (aggpad);
+    GST_OBJECT_UNLOCK (self);
+
+    GST_DEBUG_OBJECT (self,
+        "calling propose allocation with query %" GST_PTR_FORMAT, decide_query);
+
+    agg_class = GST_AGGREGATOR_GET_CLASS (self);
+
+    /* pass the query to the propose_allocation vmethod if any */
+    if (agg_class->propose_allocation)
+      ret = agg_class->propose_allocation (self, aggpad, decide_query, query);
+    else
+      ret = FALSE;
+
+    if (decide_query)
+      gst_query_unref (decide_query);
+
+    GST_DEBUG_OBJECT (self, "ALLOCATION ret %d, %" GST_PTR_FORMAT, ret, query);
+    return ret;
+  }
+
   return gst_pad_query_default (pad, GST_OBJECT (self), query);
 }
 
index e6f6b07..f2e712d 100644 (file)
@@ -276,7 +276,10 @@ struct _GstAggregatorClass {
                                             GstCaps      *  caps);
   gboolean          (*decide_allocation) (GstAggregator * self,
                                           GstQuery * query);
-
+  gboolean          (*propose_allocation) (GstAggregator * self,
+                                           GstAggregatorPad * pad,
+                                           GstQuery * decide_query,
+                                           GstQuery * query);
   /*< private >*/
   gpointer          _gst_reserved[GST_PADDING_LARGE];
 };