2 Commits

Author SHA1 Message Date
Rafał Dzięgiel
881941200f clapper-gtk: video: Use GtkGraphicsOffload
Place our widget inside GtkGraphicsOffload when possible. For now we place
it always except Windows OS where it does not do anything currently.
2025-01-22 21:10:12 +01:00
Rafał Dzięgiel
4016da96d5 clapper-gtk: video: Fix sink property type checks
Sometimes property might return a subclass type when object is subclassed.
This especially happens with custom GdkPaintable implementations.
For this reason instead of comparing object type, check if it inherits what we want.
2025-01-22 20:45:51 +01:00
2 changed files with 24 additions and 7 deletions

View File

@@ -10,7 +10,7 @@ project('clapper', 'c',
glib_req = '>= 2.76.0' glib_req = '>= 2.76.0'
gst_req = '>= 1.24.0' gst_req = '>= 1.24.0'
gtk4_req = '>= 4.10.0' gtk4_req = '>= 4.16.0'
adw_req = '>= 1.4.0' adw_req = '>= 1.4.0'
clapper_version = meson.project_version().split('-')[0] clapper_version = meson.project_version().split('-')[0]

View File

@@ -977,20 +977,24 @@ _get_widget_from_video_sink (GstElement *vsink)
GParamSpec *pspec; GParamSpec *pspec;
if ((pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (vsink), "widget")) if ((pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (vsink), "widget"))
&& pspec->value_type == GTK_TYPE_WIDGET) { && g_type_is_a (pspec->value_type, GTK_TYPE_WIDGET)) {
GST_DEBUG ("Video sink provides a widget"); GST_DEBUG ("Video sink provides a widget");
g_object_get (vsink, "widget", &widget, NULL); g_object_get (vsink, "widget", &widget, NULL);
} else if ((pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (vsink), "paintable")) } else if ((pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (vsink), "paintable"))
&& pspec->value_type == GDK_TYPE_PAINTABLE) { && g_type_is_a (pspec->value_type, G_TYPE_OBJECT)) {
GdkPaintable *paintable = NULL; GObject *paintable = NULL;
GST_DEBUG ("Video sink provides a paintable"); GST_DEBUG ("Video sink provides a paintable");
g_object_get (vsink, "paintable", &paintable, NULL); g_object_get (vsink, "paintable", &paintable, NULL);
widget = g_object_ref_sink (gtk_picture_new ()); if (G_LIKELY (paintable != NULL)) {
gtk_picture_set_paintable (GTK_PICTURE (widget), paintable); if (GDK_IS_PAINTABLE (paintable)) {
widget = g_object_ref_sink (gtk_picture_new ());
gtk_picture_set_paintable (GTK_PICTURE (widget), GDK_PAINTABLE (paintable));
}
g_object_unref (paintable); g_object_unref (paintable);
}
} }
return widget; return widget;
@@ -1032,6 +1036,19 @@ _video_sink_changed_cb (ClapperPlayer *player,
gst_object_unref (vsink); gst_object_unref (vsink);
} }
#ifndef G_OS_WIN32
if (widget) {
GtkWidget *offload = gtk_graphics_offload_new (widget);
gtk_graphics_offload_set_black_background (GTK_GRAPHICS_OFFLOAD (offload), TRUE);
GST_DEBUG_OBJECT (self, "Sink widget is placed within graphics offload");
g_object_unref (widget);
widget = g_object_ref_sink (offload);
}
#endif
if (!widget) { if (!widget) {
GST_DEBUG_OBJECT (self, "No widget from video sink, using placeholder"); GST_DEBUG_OBJECT (self, "No widget from video sink, using placeholder");
widget = g_object_ref_sink (clapper_gtk_video_placeholder_new ()); widget = g_object_ref_sink (clapper_gtk_video_placeholder_new ());