gstreamer: Simplify

Add a uses-gl property to our sink implementation, and use
it in the paintable code. This avoids juggling a second gl
context, with the risk of leaking it.
This commit is contained in:
Matthias Clasen 2024-10-03 15:07:15 -04:00
parent d70c005021
commit 79bb805a02
3 changed files with 19 additions and 9 deletions

View File

@ -134,7 +134,7 @@ gtk_gst_paintable_video_renderer_create_video_sink (GstPlayerVideoRenderer *rend
{
GtkGstPaintable *self = GTK_GST_PAINTABLE (renderer);
GstElement *sink;
GdkGLContext *ctx = NULL;
gboolean uses_gl;
GdkDisplay *display;
if (self->surface)
@ -148,21 +148,19 @@ gtk_gst_paintable_video_renderer_create_video_sink (GstPlayerVideoRenderer *rend
"display", display,
NULL);
g_object_get (GTK_GST_SINK (sink), "gl-context", &ctx, NULL);
g_object_get (GTK_GST_SINK (sink), "uses-gl", &uses_gl, NULL);
if (ctx != NULL)
if (uses_gl)
{
GstElement *glsinkbin;
glsinkbin = gst_element_factory_make ("glsinkbin", NULL);
if (glsinkbin)
g_object_set (glsinkbin, "sink", sink, NULL);
g_object_unref (sink);
sink = glsinkbin;
g_object_unref (ctx);
{
g_object_set (glsinkbin, "sink", sink, NULL);
sink = glsinkbin;
}
}
else
{

View File

@ -59,6 +59,7 @@ enum {
PROP_0,
PROP_PAINTABLE,
PROP_GL_CONTEXT,
PROP_USES_GL,
PROP_DISPLAY,
N_PROPS,
@ -779,6 +780,7 @@ gtk_gst_sink_set_property (GObject *object,
self->gdk_context = g_value_dup_object (value);
if (self->gdk_context != NULL && !gtk_gst_sink_initialize_gl (self))
g_clear_object (&self->gdk_context);
self->uses_gl = self->gdk_context != NULL;
break;
case PROP_DISPLAY:
@ -813,6 +815,10 @@ gtk_gst_sink_get_property (GObject *object,
g_value_set_object (value, self->gdk_display);
break;
case PROP_USES_GL:
g_value_set_boolean (value, self->uses_gl);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@ -879,6 +885,11 @@ gtk_gst_sink_class_init (GtkGstSinkClass * klass)
GDK_TYPE_DISPLAY,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
properties[PROP_USES_GL] =
g_param_spec_boolean ("uses-gl", NULL, NULL,
TRUE,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (gobject_class, N_PROPS, properties);
gst_element_class_set_metadata (gstelement_class,

View File

@ -56,6 +56,7 @@ struct _GtkGstSink
GstGLContext *gst_gdk_context;
GstGLContext *gst_context;
GdkColorState *color_state;
gboolean uses_gl;
};
struct _GtkGstSinkClass