diff --git a/ext/gl/gstglbasemixer.c b/ext/gl/gstglbasemixer.c index 317d339ed4..d37e55c96a 100644 --- a/ext/gl/gstglbasemixer.c +++ b/ext/gl/gstglbasemixer.c @@ -580,20 +580,6 @@ no_decide_allocation: } } -GstBufferPool * -gst_gl_base_mixer_get_buffer_pool (GstGLBaseMixer * mix) -{ - GstBufferPool *pool; - - GST_OBJECT_LOCK (mix); - pool = mix->priv->pool; - if (pool) - gst_object_ref (pool); - GST_OBJECT_UNLOCK (mix); - - return pool; -} - static void gst_gl_base_mixer_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec) diff --git a/ext/gl/gstglbasemixer.h b/ext/gl/gstglbasemixer.h index cba8184792..91bd8ef902 100644 --- a/ext/gl/gstglbasemixer.h +++ b/ext/gl/gstglbasemixer.h @@ -99,7 +99,5 @@ struct _GstGLBaseMixerClass GType gst_gl_base_mixer_get_type(void); -GstBufferPool *gst_gl_base_mixer_get_buffer_pool (GstGLBaseMixer * mix); - G_END_DECLS #endif /* __GST_GL_BASE_MIXER_H__ */ diff --git a/ext/gl/gstglmixer.c b/ext/gl/gstglmixer.c index d2ce49da8a..f1aa0b1028 100644 --- a/ext/gl/gstglmixer.c +++ b/ext/gl/gstglmixer.c @@ -322,8 +322,6 @@ static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink_%u", ); static gboolean gst_gl_mixer_src_query (GstAggregator * agg, GstQuery * query); -static GstFlowReturn gst_gl_mixer_get_output_buffer (GstVideoAggregator * - videoaggregator, GstBuffer ** outbuf); static gboolean gst_gl_mixer_stop (GstAggregator * agg); static gboolean gst_gl_mixer_start (GstAggregator * agg); @@ -371,7 +369,6 @@ gst_gl_mixer_class_init (GstGLMixerClass * klass) agg_class->negotiated_src_caps = _negotiated_caps; videoaggregator_class->aggregate_frames = gst_gl_mixer_aggregate_frames; - videoaggregator_class->get_output_buffer = gst_gl_mixer_get_output_buffer; videoaggregator_class->find_best_format = _find_best_format; mix_class->propose_allocation = gst_gl_mixer_propose_allocation; @@ -465,34 +462,6 @@ gst_gl_mixer_src_query (GstAggregator * agg, GstQuery * query) return res; } -static GstFlowReturn -gst_gl_mixer_get_output_buffer (GstVideoAggregator * videoaggregator, - GstBuffer ** outbuf) -{ - GstGLMixer *mix = GST_GL_MIXER (videoaggregator); - GstBufferPool *pool; - GstFlowReturn ret; - - pool = - gst_gl_base_mixer_get_buffer_pool (GST_GL_BASE_MIXER (videoaggregator)); - - if (!pool) - return GST_FLOW_NOT_NEGOTIATED; - - if (!gst_buffer_pool_is_active (pool)) { - if (!gst_buffer_pool_set_active (pool, TRUE)) { - GST_ELEMENT_ERROR (mix, RESOURCE, SETTINGS, - ("failed to activate bufferpool"), ("failed to activate bufferpool")); - return GST_FLOW_ERROR; - } - } - - ret = gst_buffer_pool_acquire_buffer (pool, outbuf, NULL); - gst_object_unref (pool); - - return ret; -} - static void _mixer_create_fbo (GstGLContext * context, GstGLMixer * mix) { diff --git a/gst-libs/gst/video/gstvideoaggregator.c b/gst-libs/gst/video/gstvideoaggregator.c index c731f92f1a..88f9a69a8b 100644 --- a/gst-libs/gst/video/gstvideoaggregator.c +++ b/gst-libs/gst/video/gstvideoaggregator.c @@ -1897,22 +1897,68 @@ gst_video_aggregator_release_pad (GstElement * element, GstPad * pad) return; } +static gboolean +gst_video_aggregator_decide_allocation (GstAggregator * self, GstQuery * query) +{ + GstAllocationParams params = { 0, 15, 0, 0 }; + guint i; + + if (gst_query_get_n_allocation_params (query) == 0) + gst_query_add_allocation_param (query, NULL, ¶ms); + else + for (i = 0; i < gst_query_get_n_allocation_params (query); i++) { + GstAllocator *allocator; + + gst_query_parse_nth_allocation_param (query, i, &allocator, ¶ms); + params.align = MAX (params.align, 15); + gst_query_set_nth_allocation_param (query, i, allocator, ¶ms); + } + + return TRUE; +} + static GstFlowReturn gst_video_aggregator_get_output_buffer (GstVideoAggregator * videoaggregator, GstBuffer ** outbuf) { - guint outsize; - static GstAllocationParams params = { 0, 15, 0, 0, }; + GstAggregator *aggregator = GST_AGGREGATOR (videoaggregator); + GstBufferPool *pool; + GstFlowReturn ret = GST_FLOW_OK; - outsize = GST_VIDEO_INFO_SIZE (&videoaggregator->info); - *outbuf = gst_buffer_new_allocate (NULL, outsize, ¶ms); + pool = gst_aggregator_get_buffer_pool (aggregator); - if (*outbuf == NULL) { - GST_ERROR_OBJECT (videoaggregator, - "Could not instantiate buffer of size: %d", outsize); + if (pool) { + if (!gst_buffer_pool_is_active (pool)) { + if (!gst_buffer_pool_set_active (pool, TRUE)) { + GST_ELEMENT_ERROR (videoaggregator, RESOURCE, SETTINGS, + ("failed to activate bufferpool"), + ("failed to activate bufferpool")); + return GST_FLOW_ERROR; + } + } + + ret = gst_buffer_pool_acquire_buffer (pool, outbuf, NULL); + gst_object_unref (pool); + } else { + guint outsize; + GstAllocator *allocator; + GstAllocationParams params; + + gst_aggregator_get_allocator (aggregator, &allocator, ¶ms); + + outsize = GST_VIDEO_INFO_SIZE (&videoaggregator->info); + *outbuf = gst_buffer_new_allocate (allocator, outsize, ¶ms); + + if (allocator) + gst_object_unref (allocator); + + if (*outbuf == NULL) { + GST_ELEMENT_ERROR (videoaggregator, RESOURCE, NO_SPACE_LEFT, + (NULL), ("Could not acquire buffer of size: %d", outsize)); + ret = GST_FLOW_ERROR; + } } - - return GST_FLOW_OK; + return ret; } static gboolean @@ -2090,6 +2136,7 @@ gst_video_aggregator_class_init (GstVideoAggregatorClass * klass) agg_class->fixate_src_caps = gst_video_aggregator_default_fixate_src_caps; agg_class->negotiated_src_caps = gst_video_aggregator_default_negotiated_src_caps; + agg_class->decide_allocation = gst_video_aggregator_decide_allocation; klass->find_best_format = gst_video_aggregator_find_best_format; klass->get_output_buffer = gst_video_aggregator_get_output_buffer;