glviewconvert: remove set_format

We need the caps to be able to
1. check the caps features
2. get the requested texture-target on input/output
This commit is contained in:
Matthew Waters 2015-11-10 13:52:30 +11:00 committed by Tim-Philipp Müller
parent bb1ae9042b
commit b8c1ecf268
5 changed files with 36 additions and 15 deletions

View file

@ -1005,6 +1005,10 @@ gst_glimage_sink_change_state (GstElement * element, GstStateChange transition)
gst_caps_unref (glimage_sink->out_caps);
glimage_sink->out_caps = NULL;
}
if (glimage_sink->in_caps) {
gst_caps_unref (glimage_sink->in_caps);
glimage_sink->in_caps = NULL;
}
break;
}
case GST_STATE_CHANGE_READY_TO_NULL:
@ -1172,6 +1176,7 @@ update_output_format (GstGLImageSink * glimage_sink)
gboolean input_is_mono = FALSE;
GstVideoMultiviewMode mv_mode;
GstGLWindow *window = NULL;
GstCaps *out_caps;
gboolean ret;
*out_info = glimage_sink->in_info;
@ -1213,15 +1218,28 @@ update_output_format (GstGLImageSink * glimage_sink)
glimage_sink->out_info.height = MAX (1, glimage_sink->display_rect.h);
GST_LOG_OBJECT (glimage_sink, "Set 3D output scale to %d,%d",
glimage_sink->display_rect.w, glimage_sink->display_rect.h);
}
out_caps = gst_video_info_to_caps (out_info);
gst_caps_set_features (out_caps, 0,
gst_caps_features_from_string (GST_CAPS_FEATURE_MEMORY_GL_MEMORY));
if (glimage_sink->convert_views) {
gst_caps_set_simple (out_caps, "texture-target", G_TYPE_STRING,
GST_GL_TEXTURE_TARGET_2D_STR, NULL);
GST_GLIMAGE_SINK_UNLOCK (glimage_sink);
gst_gl_view_convert_set_format (glimage_sink->convert_views,
&glimage_sink->in_info, &glimage_sink->out_info);
gst_gl_view_convert_set_caps (glimage_sink->convert_views,
glimage_sink->in_caps, out_caps);
g_object_set (glimage_sink->convert_views, "downmix-mode",
glimage_sink->mview_downmix_mode, NULL);
GST_GLIMAGE_SINK_LOCK (glimage_sink);
}
if (glimage_sink->out_caps)
gst_caps_unref (glimage_sink->out_caps);
glimage_sink->out_caps = out_caps;
glimage_sink->output_mode_changed = FALSE;
if (glimage_sink->context)
@ -1231,10 +1249,6 @@ update_output_format (GstGLImageSink * glimage_sink)
gst_object_unref (window);
}
if (glimage_sink->out_caps)
gst_caps_unref (glimage_sink->out_caps);
glimage_sink->out_caps = gst_video_info_to_caps (out_info);
return ret;
}
@ -1257,6 +1271,9 @@ gst_glimage_sink_set_caps (GstBaseSink * bsink, GstCaps * caps)
return FALSE;
GST_GLIMAGE_SINK_LOCK (glimage_sink);
if (glimage_sink->in_caps)
gst_caps_unref (glimage_sink->in_caps);
glimage_sink->in_caps = gst_caps_ref (caps);
glimage_sink->in_info = vinfo;
ok = update_output_format (glimage_sink);

View file

@ -64,6 +64,7 @@ struct _GstGLImageSink
/* Input info before 3d stereo output conversion, if any */
GstVideoInfo in_info;
GstCaps *in_caps;
/* format/caps we actually hand off to the app */
GstVideoInfo out_info;

View file

@ -483,6 +483,7 @@ static gboolean
_negotiated_caps (GstVideoAggregator * vagg, GstCaps * caps)
{
GstGLStereoMix *mix = GST_GL_STEREO_MIX (vagg);
GstCaps *in_caps;
GST_LOG_OBJECT (mix, "Configured output caps %" GST_PTR_FORMAT, caps);
@ -498,11 +499,16 @@ _negotiated_caps (GstVideoAggregator * vagg, GstCaps * caps)
/* We can configure the view_converter now */
gst_gl_view_convert_set_context (mix->viewconvert,
GST_GL_BASE_MIXER (mix)->context);
gst_gl_view_convert_set_format (mix->viewconvert, &mix->mix_info,
&mix->out_info);
in_caps = gst_video_info_to_caps (&mix->mix_info);
gst_caps_set_features (in_caps, 0,
gst_caps_features_from_string (GST_CAPS_FEATURE_MEMORY_GL_MEMORY));
gst_caps_set_simple (in_caps, "texture-target", G_TYPE_STRING,
GST_GL_TEXTURE_TARGET_2D_STR, NULL);
gst_gl_view_convert_set_caps (mix->viewconvert, in_caps, caps);
return TRUE;
}
static gboolean

View file

@ -351,8 +351,8 @@ gst_gl_view_convert_set_context (GstGLViewConvert * viewconvert,
gst_gl_view_convert_reset (viewconvert);
}
gboolean
gst_gl_view_convert_set_format (GstGLViewConvert * viewconvert,
static gboolean
_view_convert_set_format (GstGLViewConvert * viewconvert,
GstVideoInfo * in_info, GstVideoInfo * out_info)
{
g_return_val_if_fail (GST_IS_GL_VIEW_CONVERT (viewconvert), FALSE);
@ -422,7 +422,7 @@ gst_gl_view_convert_set_caps (GstGLViewConvert * viewconvert,
if (!gst_video_info_from_caps (&out_info, out_caps))
return FALSE;
return gst_gl_view_convert_set_format (viewconvert, &in_info, &out_info);
return _view_convert_set_format (viewconvert, &in_info, &out_info);
}
/* Function that can halve the value
@ -1586,7 +1586,6 @@ _init_view_convert (GstGLViewConvert * viewconvert)
gl->BindBuffer (GL_ELEMENT_ARRAY_BUFFER, 0);
}
gl->BindTexture (GL_TEXTURE_2D, 0);
viewconvert->initted = TRUE;
return TRUE;
error:

View file

@ -78,8 +78,6 @@ struct _GstGLViewConvertClass
GType gst_gl_view_convert_get_type (void);
GstGLViewConvert * gst_gl_view_convert_new (void);
gboolean gst_gl_view_convert_set_format (GstGLViewConvert *viewconvert, GstVideoInfo *in_info,
GstVideoInfo *out_info);
gboolean gst_gl_view_convert_set_caps (GstGLViewConvert * viewconvert, GstCaps * in_caps, GstCaps * out_caps);
GstCaps * gst_gl_view_convert_transform_caps (GstGLViewConvert * viewconvert,
GstPadDirection direction, GstCaps * caps, GstCaps * filter);