);
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);
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;
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)
{
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;
+ }
+ }
- return GST_FLOW_OK;
+ 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 ret;
}
static gboolean
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;