mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-28 03:00:35 +00:00
gl*mixer: Use propose_allocation from the GstAggregator base class
https://bugzilla.gnome.org/show_bug.cgi?id=782918
This commit is contained in:
parent
af28bcab13
commit
a2b0f2771a
4 changed files with 34 additions and 80 deletions
|
@ -58,11 +58,6 @@ struct _GstGLBaseMixerPrivate
|
|||
gboolean negotiated;
|
||||
|
||||
GstGLContext *other_context;
|
||||
|
||||
GstBufferPool *pool;
|
||||
GstAllocator *allocator;
|
||||
GstAllocationParams params;
|
||||
GstQuery *query;
|
||||
};
|
||||
|
||||
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
|
||||
gst_gl_base_mixer_sink_event (GstAggregator * agg, GstAggregatorPad * bpad,
|
||||
GstEvent * event)
|
||||
|
@ -210,53 +198,27 @@ context_error:
|
|||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_gl_base_mixer_propose_allocation (GstAggregator * agg,
|
||||
GstAggregatorPad * aggpad, GstQuery * decide_query, GstQuery * query)
|
||||
{
|
||||
GstGLBaseMixer *mix = GST_GL_BASE_MIXER (agg);
|
||||
|
||||
if (!_get_gl_context (mix))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_gl_base_mixer_sink_query (GstAggregator * agg, GstAggregatorPad * bpad,
|
||||
GstQuery * query)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
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))
|
||||
return FALSE;
|
||||
|
||||
GST_DEBUG_OBJECT (mix,
|
||||
"calling propose allocation with query %" GST_PTR_FORMAT,
|
||||
decide_query);
|
||||
|
||||
/* pass the query to the propose_allocation vmethod if any */
|
||||
if (mix_class->propose_allocation)
|
||||
ret = mix_class->propose_allocation (mix, pad, decide_query, query);
|
||||
else
|
||||
ret = FALSE;
|
||||
|
||||
if (decide_query)
|
||||
gst_query_unref (decide_query);
|
||||
|
||||
GST_DEBUG_OBJECT (mix, "ALLOCATION ret %d, %" GST_PTR_FORMAT, ret, query);
|
||||
return ret;
|
||||
}
|
||||
case GST_QUERY_CONTEXT:
|
||||
{
|
||||
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->start = gst_gl_base_mixer_start;
|
||||
agg_class->decide_allocation = gst_gl_base_mixer_decide_allocation;
|
||||
|
||||
klass->propose_allocation = _default_propose_allocation;
|
||||
agg_class->propose_allocation = gst_gl_base_mixer_propose_allocation;
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_CONTEXT,
|
||||
g_param_spec_object ("context",
|
||||
|
@ -500,16 +461,6 @@ gst_gl_base_mixer_stop (GstAggregator * 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) {
|
||||
gst_object_unref (mix->context);
|
||||
mix->context = NULL;
|
||||
|
|
|
@ -91,8 +91,6 @@ struct _GstGLBaseMixerClass
|
|||
GstVideoAggregatorClass parent_class;
|
||||
GstGLAPI supported_gl_api;
|
||||
|
||||
gboolean (*propose_allocation) (GstGLBaseMixer * mix, GstGLBaseMixerPad * pad, GstQuery * decide_query, GstQuery *query);
|
||||
|
||||
gpointer _padding[GST_PADDING];
|
||||
};
|
||||
|
||||
|
|
|
@ -131,17 +131,25 @@ _find_best_format (GstVideoAggregator * vagg, GstCaps * downstream_caps,
|
|||
}
|
||||
|
||||
static gboolean
|
||||
gst_gl_mixer_propose_allocation (GstGLBaseMixer * base_mix,
|
||||
GstGLBaseMixerPad * base_pad, GstQuery * decide_query, GstQuery * query)
|
||||
gst_gl_mixer_propose_allocation (GstAggregator * agg,
|
||||
GstAggregatorPad * agg_pad, GstQuery * decide_query, GstQuery * query)
|
||||
{
|
||||
GstGLMixer *mix = GST_GL_MIXER (base_mix);
|
||||
GstGLContext *context = base_mix->context;
|
||||
GstGLMixer *mix = GST_GL_MIXER (agg);
|
||||
GstGLBaseMixer *base_mix = GST_GL_BASE_MIXER (agg);
|
||||
GstGLContext *context;
|
||||
GstBufferPool *pool = NULL;
|
||||
GstStructure *config;
|
||||
GstCaps *caps;
|
||||
guint size = 0;
|
||||
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);
|
||||
|
||||
if (caps == NULL)
|
||||
|
@ -347,7 +355,6 @@ gst_gl_mixer_class_init (GstGLMixerClass * klass)
|
|||
GstVideoAggregatorClass *videoaggregator_class =
|
||||
(GstVideoAggregatorClass *) 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");
|
||||
|
||||
|
@ -368,11 +375,11 @@ gst_gl_mixer_class_init (GstGLMixerClass * klass)
|
|||
agg_class->start = gst_gl_mixer_start;
|
||||
agg_class->negotiated_src_caps = _negotiated_caps;
|
||||
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->find_best_format = _find_best_format;
|
||||
|
||||
mix_class->propose_allocation = gst_gl_mixer_propose_allocation;
|
||||
|
||||
/* Register the pad class */
|
||||
g_type_class_ref (GST_TYPE_GL_MIXER_PAD);
|
||||
|
|
|
@ -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 *_fixate_caps (GstAggregator * agg, GstCaps * caps);
|
||||
static gboolean gst_gl_video_mixer_propose_allocation (GstGLBaseMixer *
|
||||
base_mix, GstGLBaseMixerPad * base_pad, GstQuery * decide_query,
|
||||
GstQuery * query);
|
||||
static gboolean gst_gl_video_mixer_propose_allocation (GstAggregator *
|
||||
agg, GstAggregatorPad * agg_pad, GstQuery * decide_query, GstQuery * query);
|
||||
static void gst_gl_video_mixer_reset (GstGLMixer * mixer);
|
||||
static gboolean gst_gl_video_mixer_init_shader (GstGLMixer * mixer,
|
||||
GstCaps * outcaps);
|
||||
|
@ -849,7 +848,6 @@ gst_gl_video_mixer_class_init (GstGLVideoMixerClass * klass)
|
|||
GstElementClass *element_class;
|
||||
GstAggregatorClass *agg_class = (GstAggregatorClass *) klass;
|
||||
GstVideoAggregatorClass *vagg_class = (GstVideoAggregatorClass *) klass;
|
||||
GstGLBaseMixerClass *mix_class = GST_GL_BASE_MIXER_CLASS (klass);
|
||||
|
||||
gobject_class = (GObjectClass *) 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_video_mixer_process_textures;
|
||||
|
||||
|
||||
vagg_class->update_caps = _update_caps;
|
||||
|
||||
agg_class->sinkpads_type = GST_TYPE_GL_VIDEO_MIXER_PAD;
|
||||
agg_class->fixate_src_caps = _fixate_caps;
|
||||
|
||||
mix_class->propose_allocation = gst_gl_video_mixer_propose_allocation;
|
||||
agg_class->propose_allocation = gst_gl_video_mixer_propose_allocation;
|
||||
|
||||
GST_GL_BASE_MIXER_CLASS (klass)->supported_gl_api =
|
||||
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
|
||||
gst_gl_video_mixer_propose_allocation (GstGLBaseMixer * base_mix,
|
||||
GstGLBaseMixerPad * base_pad, GstQuery * decide_query, GstQuery * query)
|
||||
gst_gl_video_mixer_propose_allocation (GstAggregator * agg,
|
||||
GstAggregatorPad * agg_pad, GstQuery * decide_query, GstQuery * query)
|
||||
{
|
||||
if (!GST_GL_BASE_MIXER_CLASS (parent_class)->propose_allocation (base_mix,
|
||||
base_pad, decide_query, query))
|
||||
if (!GST_AGGREGATOR_CLASS (parent_class)->propose_allocation (agg,
|
||||
agg_pad, decide_query, query))
|
||||
return FALSE;
|
||||
|
||||
gst_query_add_allocation_meta (query,
|
||||
|
|
Loading…
Reference in a new issue