gldisplay: implement runtime GL api filtering

Needed so that the pipeline/application can limit the choice of GL api
to what it supports
This commit is contained in:
Matthew Waters 2014-11-27 21:05:45 +11:00
parent 8f86923b00
commit c90f7001b1
4 changed files with 28 additions and 2 deletions

View file

@ -152,6 +152,7 @@ static gboolean
gst_gl_mixer_propose_allocation (GstGLMixer * mix,
GstQuery * decide_query, GstQuery * query)
{
GstGLMixerClass *mix_class = GST_GL_MIXER_GET_CLASS (mix);
GstBufferPool *pool;
GstStructure *config;
GstCaps *caps;
@ -192,6 +193,8 @@ gst_gl_mixer_propose_allocation (GstGLMixer * mix,
if (!gst_gl_ensure_element_data (mix, &mix->display, &mix->other_context))
return FALSE;
gst_gl_display_filter_gl_api (mix->display, mix_class->supported_gl_api);
if (!mix->context) {
mix->context = gst_gl_context_new (mix->display);
if (!gst_gl_context_create (mix->context, mix->other_context, &error))
@ -428,6 +431,7 @@ gst_gl_mixer_sink_query (GstAggregator * agg, GstAggregatorPad * bpad,
{
gboolean ret = FALSE;
GstGLMixer *mix = GST_GL_MIXER (agg);
GstGLMixerClass *mix_class = GST_GL_MIXER_GET_CLASS (mix);
GST_TRACE ("QUERY %" GST_PTR_FORMAT, query);
@ -485,6 +489,9 @@ gst_gl_mixer_sink_query (GstAggregator * agg, GstAggregatorPad * bpad,
{
ret = gst_gl_handle_context_query ((GstElement *) mix, query,
&mix->display, &mix->other_context);
if (mix->display)
gst_gl_display_filter_gl_api (mix->display,
mix_class->supported_gl_api);
break;
}
default:
@ -615,7 +622,7 @@ gst_gl_mixer_class_init (GstGLMixerClass * klass)
g_type_class_ref (GST_TYPE_GL_MIXER_PAD);
klass->set_caps = NULL;
klass->supported_gl_api = GST_GL_API_ANY;
}
static void
@ -661,19 +668,26 @@ static void
gst_gl_mixer_set_context (GstElement * element, GstContext * context)
{
GstGLMixer *mix = GST_GL_MIXER (element);
GstGLMixerClass *mix_class = GST_GL_MIXER_GET_CLASS (mix);
gst_gl_handle_set_context (element, context, &mix->display,
&mix->other_context);
if (mix->display)
gst_gl_display_filter_gl_api (mix->display, mix_class->supported_gl_api);
}
static gboolean
gst_gl_mixer_activate (GstGLMixer * mix, gboolean active)
{
GstGLMixerClass *mix_class = GST_GL_MIXER_GET_CLASS (mix);
gboolean result = TRUE;
if (active) {
if (!gst_gl_ensure_element_data (mix, &mix->display, &mix->other_context))
result = FALSE;
return FALSE;
gst_gl_display_filter_gl_api (mix->display, mix_class->supported_gl_api);
}
return result;
@ -729,12 +743,16 @@ gst_gl_mixer_src_query (GstAggregator * agg, GstQuery * query)
{
gboolean res = FALSE;
GstGLMixer *mix = GST_GL_MIXER (agg);
GstGLMixerClass *mix_class = GST_GL_MIXER_GET_CLASS (mix);
switch (GST_QUERY_TYPE (query)) {
case GST_QUERY_CONTEXT:
{
res = gst_gl_handle_context_query ((GstElement *) mix, query,
&mix->display, &mix->other_context);
if (mix->display)
gst_gl_display_filter_gl_api (mix->display,
mix_class->supported_gl_api);
break;
}
case GST_QUERY_CAPS:
@ -785,6 +803,8 @@ gst_gl_mixer_decide_allocation (GstGLMixer * mix, GstQuery * query)
if (!gst_gl_ensure_element_data (mix, &mix->display, &mix->other_context))
return FALSE;
gst_gl_display_filter_gl_api (mix->display, mixer_class->supported_gl_api);
if (gst_query_find_allocation_meta (query,
GST_VIDEO_GL_TEXTURE_UPLOAD_META_API_TYPE, &idx)) {
GstGLContext *context;

View file

@ -76,6 +76,7 @@ struct _GstGLMixer
struct _GstGLMixerClass
{
GstVideoAggregatorClass parent_class;
GstGLAPI supported_gl_api;
GstGLMixerSetCaps set_caps;
GstGLMixerReset reset;

View file

@ -134,6 +134,8 @@ gst_gl_mosaic_class_init (GstGLMosaicClass * klass)
GST_GL_MIXER_CLASS (klass)->set_caps = gst_gl_mosaic_init_shader;
GST_GL_MIXER_CLASS (klass)->reset = gst_gl_mosaic_reset;
GST_GL_MIXER_CLASS (klass)->process_textures = gst_gl_mosaic_process_textures;
GST_GL_MIXER_CLASS (klass)->supported_gl_api = GST_GL_API_OPENGL;
}
static void

View file

@ -345,6 +345,9 @@ gst_gl_video_mixer_class_init (GstGLVideoMixerClass * klass)
vagg_class->update_caps = _update_caps;
agg_class->sinkpads_type = GST_TYPE_GL_VIDEO_MIXER_PAD;
GST_GL_MIXER_CLASS (klass)->supported_gl_api =
GST_GL_API_OPENGL | GST_GL_API_OPENGL3 | GST_GL_API_GLES2;
}
static void