gl*mixer: Use propose_allocation from the GstAggregator base class

https://bugzilla.gnome.org/show_bug.cgi?id=782918
This commit is contained in:
Olivier Crête 2017-05-21 15:30:10 +02:00
parent 431dc9720a
commit 1a2df0400d
4 changed files with 34 additions and 80 deletions

View file

@ -58,11 +58,6 @@ struct _GstGLBaseMixerPrivate
gboolean negotiated; gboolean negotiated;
GstGLContext *other_context; GstGLContext *other_context;
GstBufferPool *pool;
GstAllocator *allocator;
GstAllocationParams params;
GstQuery *query;
}; };
G_DEFINE_TYPE (GstGLBaseMixerPad, gst_gl_base_mixer_pad, G_DEFINE_TYPE (GstGLBaseMixerPad, gst_gl_base_mixer_pad,
@ -105,13 +100,6 @@ gst_gl_base_mixer_pad_set_property (GObject * object, guint prop_id,
} }
} }
static gboolean
_default_propose_allocation (GstGLBaseMixer * mix, GstGLBaseMixerPad * pad,
GstQuery * decide_query, GstQuery * query)
{
return TRUE;
}
static gboolean static gboolean
gst_gl_base_mixer_sink_event (GstAggregator * agg, GstAggregatorPad * bpad, gst_gl_base_mixer_sink_event (GstAggregator * agg, GstAggregatorPad * bpad,
GstEvent * event) GstEvent * event)
@ -211,52 +199,26 @@ context_error:
} }
static gboolean static gboolean
gst_gl_base_mixer_sink_query (GstAggregator * agg, GstAggregatorPad * bpad, gst_gl_base_mixer_propose_allocation (GstAggregator * agg,
GstQuery * query) GstAggregatorPad * aggpad, GstQuery * decide_query, GstQuery * query)
{ {
gboolean ret = FALSE;
GstGLBaseMixer *mix = GST_GL_BASE_MIXER (agg); GstGLBaseMixer *mix = GST_GL_BASE_MIXER (agg);
GstGLBaseMixerClass *mix_class = GST_GL_BASE_MIXER_GET_CLASS (mix);
GstGLBaseMixerPad *pad = GST_GL_BASE_MIXER_PAD (bpad);
GST_TRACE ("QUERY %" GST_PTR_FORMAT, query);
switch (GST_QUERY_TYPE (query)) {
case GST_QUERY_ALLOCATION:
{
GstQuery *decide_query = NULL;
GST_OBJECT_LOCK (mix);
if (G_UNLIKELY (!pad->negotiated)) {
GST_DEBUG_OBJECT (mix,
"not negotiated yet, can't answer ALLOCATION query");
GST_OBJECT_UNLOCK (mix);
return FALSE;
}
if ((decide_query = mix->priv->query))
gst_query_ref (decide_query);
GST_OBJECT_UNLOCK (mix);
if (!_get_gl_context (mix)) if (!_get_gl_context (mix))
return FALSE; return FALSE;
GST_DEBUG_OBJECT (mix, return TRUE;
"calling propose allocation with query %" GST_PTR_FORMAT, }
decide_query);
/* pass the query to the propose_allocation vmethod if any */ static gboolean
if (mix_class->propose_allocation) gst_gl_base_mixer_sink_query (GstAggregator * agg, GstAggregatorPad * bpad,
ret = mix_class->propose_allocation (mix, pad, decide_query, query); GstQuery * query)
else {
ret = FALSE; GstGLBaseMixer *mix = GST_GL_BASE_MIXER (agg);
if (decide_query) GST_TRACE ("QUERY %" GST_PTR_FORMAT, query);
gst_query_unref (decide_query);
GST_DEBUG_OBJECT (mix, "ALLOCATION ret %d, %" GST_PTR_FORMAT, ret, query); switch (GST_QUERY_TYPE (query)) {
return ret;
}
case GST_QUERY_CONTEXT: case GST_QUERY_CONTEXT:
{ {
if (gst_gl_handle_context_query ((GstElement *) mix, query, if (gst_gl_handle_context_query ((GstElement *) mix, query,
@ -335,8 +297,7 @@ gst_gl_base_mixer_class_init (GstGLBaseMixerClass * klass)
agg_class->stop = gst_gl_base_mixer_stop; agg_class->stop = gst_gl_base_mixer_stop;
agg_class->start = gst_gl_base_mixer_start; agg_class->start = gst_gl_base_mixer_start;
agg_class->decide_allocation = gst_gl_base_mixer_decide_allocation; agg_class->decide_allocation = gst_gl_base_mixer_decide_allocation;
agg_class->propose_allocation = gst_gl_base_mixer_propose_allocation;
klass->propose_allocation = _default_propose_allocation;
g_object_class_install_property (gobject_class, PROP_CONTEXT, g_object_class_install_property (gobject_class, PROP_CONTEXT,
g_param_spec_object ("context", g_param_spec_object ("context",
@ -500,16 +461,6 @@ gst_gl_base_mixer_stop (GstAggregator * agg)
{ {
GstGLBaseMixer *mix = GST_GL_BASE_MIXER (agg); GstGLBaseMixer *mix = GST_GL_BASE_MIXER (agg);
if (mix->priv->query) {
gst_query_unref (mix->priv->query);
mix->priv->query = NULL;
}
if (mix->priv->pool) {
gst_object_unref (mix->priv->pool);
mix->priv->pool = NULL;
}
if (mix->context) { if (mix->context) {
gst_object_unref (mix->context); gst_object_unref (mix->context);
mix->context = NULL; mix->context = NULL;

View file

@ -91,8 +91,6 @@ struct _GstGLBaseMixerClass
GstVideoAggregatorClass parent_class; GstVideoAggregatorClass parent_class;
GstGLAPI supported_gl_api; GstGLAPI supported_gl_api;
gboolean (*propose_allocation) (GstGLBaseMixer * mix, GstGLBaseMixerPad * pad, GstQuery * decide_query, GstQuery *query);
gpointer _padding[GST_PADDING]; gpointer _padding[GST_PADDING];
}; };

View file

@ -131,17 +131,25 @@ _find_best_format (GstVideoAggregator * vagg, GstCaps * downstream_caps,
} }
static gboolean static gboolean
gst_gl_mixer_propose_allocation (GstGLBaseMixer * base_mix, gst_gl_mixer_propose_allocation (GstAggregator * agg,
GstGLBaseMixerPad * base_pad, GstQuery * decide_query, GstQuery * query) GstAggregatorPad * agg_pad, GstQuery * decide_query, GstQuery * query)
{ {
GstGLMixer *mix = GST_GL_MIXER (base_mix); GstGLMixer *mix = GST_GL_MIXER (agg);
GstGLContext *context = base_mix->context; GstGLBaseMixer *base_mix = GST_GL_BASE_MIXER (agg);
GstGLContext *context;
GstBufferPool *pool = NULL; GstBufferPool *pool = NULL;
GstStructure *config; GstStructure *config;
GstCaps *caps; GstCaps *caps;
guint size = 0; guint size = 0;
gboolean need_pool; gboolean need_pool;
if (!GST_AGGREGATOR_CLASS (gst_gl_mixer_parent_class)->propose_allocation
(agg, agg_pad, decide_query, query))
return FALSE;
context = base_mix->context;
gst_query_parse_allocation (query, &caps, &need_pool); gst_query_parse_allocation (query, &caps, &need_pool);
if (caps == NULL) if (caps == NULL)
@ -347,7 +355,6 @@ gst_gl_mixer_class_init (GstGLMixerClass * klass)
GstVideoAggregatorClass *videoaggregator_class = GstVideoAggregatorClass *videoaggregator_class =
(GstVideoAggregatorClass *) klass; (GstVideoAggregatorClass *) klass;
GstAggregatorClass *agg_class = (GstAggregatorClass *) klass; GstAggregatorClass *agg_class = (GstAggregatorClass *) klass;
GstGLBaseMixerClass *mix_class = GST_GL_BASE_MIXER_CLASS (klass);;
GST_DEBUG_CATEGORY_INIT (GST_CAT_DEFAULT, "glmixer", 0, "OpenGL mixer"); GST_DEBUG_CATEGORY_INIT (GST_CAT_DEFAULT, "glmixer", 0, "OpenGL mixer");
@ -368,11 +375,11 @@ gst_gl_mixer_class_init (GstGLMixerClass * klass)
agg_class->start = gst_gl_mixer_start; agg_class->start = gst_gl_mixer_start;
agg_class->negotiated_src_caps = _negotiated_caps; agg_class->negotiated_src_caps = _negotiated_caps;
agg_class->decide_allocation = gst_gl_mixer_decide_allocation; agg_class->decide_allocation = gst_gl_mixer_decide_allocation;
agg_class->propose_allocation = gst_gl_mixer_propose_allocation;
videoaggregator_class->aggregate_frames = gst_gl_mixer_aggregate_frames; videoaggregator_class->aggregate_frames = gst_gl_mixer_aggregate_frames;
videoaggregator_class->find_best_format = _find_best_format; videoaggregator_class->find_best_format = _find_best_format;
mix_class->propose_allocation = gst_gl_mixer_propose_allocation;
/* Register the pad class */ /* Register the pad class */
g_type_class_ref (GST_TYPE_GL_MIXER_PAD); g_type_class_ref (GST_TYPE_GL_MIXER_PAD);

View file

@ -455,9 +455,8 @@ static void gst_gl_video_mixer_get_property (GObject * object, guint prop_id,
static GstCaps *_update_caps (GstVideoAggregator * vagg, GstCaps * caps); static GstCaps *_update_caps (GstVideoAggregator * vagg, GstCaps * caps);
static GstCaps *_fixate_caps (GstAggregator * agg, GstCaps * caps); static GstCaps *_fixate_caps (GstAggregator * agg, GstCaps * caps);
static gboolean gst_gl_video_mixer_propose_allocation (GstGLBaseMixer * static gboolean gst_gl_video_mixer_propose_allocation (GstAggregator *
base_mix, GstGLBaseMixerPad * base_pad, GstQuery * decide_query, agg, GstAggregatorPad * agg_pad, GstQuery * decide_query, GstQuery * query);
GstQuery * query);
static void gst_gl_video_mixer_reset (GstGLMixer * mixer); static void gst_gl_video_mixer_reset (GstGLMixer * mixer);
static gboolean gst_gl_video_mixer_init_shader (GstGLMixer * mixer, static gboolean gst_gl_video_mixer_init_shader (GstGLMixer * mixer,
GstCaps * outcaps); GstCaps * outcaps);
@ -849,7 +848,6 @@ gst_gl_video_mixer_class_init (GstGLVideoMixerClass * klass)
GstElementClass *element_class; GstElementClass *element_class;
GstAggregatorClass *agg_class = (GstAggregatorClass *) klass; GstAggregatorClass *agg_class = (GstAggregatorClass *) klass;
GstVideoAggregatorClass *vagg_class = (GstVideoAggregatorClass *) klass; GstVideoAggregatorClass *vagg_class = (GstVideoAggregatorClass *) klass;
GstGLBaseMixerClass *mix_class = GST_GL_BASE_MIXER_CLASS (klass);
gobject_class = (GObjectClass *) klass; gobject_class = (GObjectClass *) klass;
element_class = GST_ELEMENT_CLASS (klass); element_class = GST_ELEMENT_CLASS (klass);
@ -872,12 +870,12 @@ gst_gl_video_mixer_class_init (GstGLVideoMixerClass * klass)
GST_GL_MIXER_CLASS (klass)->process_textures = GST_GL_MIXER_CLASS (klass)->process_textures =
gst_gl_video_mixer_process_textures; gst_gl_video_mixer_process_textures;
vagg_class->update_caps = _update_caps; vagg_class->update_caps = _update_caps;
agg_class->sinkpads_type = GST_TYPE_GL_VIDEO_MIXER_PAD; agg_class->sinkpads_type = GST_TYPE_GL_VIDEO_MIXER_PAD;
agg_class->fixate_src_caps = _fixate_caps; agg_class->fixate_src_caps = _fixate_caps;
agg_class->propose_allocation = gst_gl_video_mixer_propose_allocation;
mix_class->propose_allocation = gst_gl_video_mixer_propose_allocation;
GST_GL_BASE_MIXER_CLASS (klass)->supported_gl_api = GST_GL_BASE_MIXER_CLASS (klass)->supported_gl_api =
GST_GL_API_OPENGL | GST_GL_API_OPENGL3 | GST_GL_API_GLES2; GST_GL_API_OPENGL | GST_GL_API_OPENGL3 | GST_GL_API_GLES2;
@ -923,11 +921,11 @@ gst_gl_video_mixer_get_property (GObject * object, guint prop_id,
} }
static gboolean static gboolean
gst_gl_video_mixer_propose_allocation (GstGLBaseMixer * base_mix, gst_gl_video_mixer_propose_allocation (GstAggregator * agg,
GstGLBaseMixerPad * base_pad, GstQuery * decide_query, GstQuery * query) GstAggregatorPad * agg_pad, GstQuery * decide_query, GstQuery * query)
{ {
if (!GST_GL_BASE_MIXER_CLASS (parent_class)->propose_allocation (base_mix, if (!GST_AGGREGATOR_CLASS (parent_class)->propose_allocation (agg,
base_pad, decide_query, query)) agg_pad, decide_query, query))
return FALSE; return FALSE;
gst_query_add_allocation_meta (query, gst_query_add_allocation_meta (query,