From 7f33db41594e740237030df05ab3d83f9531271f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Dzi=C4=99giel?= Date: Wed, 11 May 2022 16:39:59 +0200 Subject: [PATCH 1/3] plugin: Fix possible buffer and v_info mismatch --- lib/gst/plugin/gstclapperimporter.c | 20 ++++++++++++-------- lib/gst/plugin/gstclapperimporter.h | 1 + 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/lib/gst/plugin/gstclapperimporter.c b/lib/gst/plugin/gstclapperimporter.c index 9ee4fa5f..035b0e44 100644 --- a/lib/gst/plugin/gstclapperimporter.c +++ b/lib/gst/plugin/gstclapperimporter.c @@ -119,6 +119,8 @@ gst_clapper_importer_finalize (GObject *object) GST_TRACE ("Finalize"); + gst_clear_caps (&self->pending_caps); + gst_clear_buffer (&self->pending_buffer); gst_clear_buffer (&self->buffer); @@ -320,7 +322,7 @@ gst_clapper_importer_set_caps (GstClapperImporter *self, GstCaps *caps) GstClapperImporterClass *importer_class = GST_CLAPPER_IMPORTER_GET_CLASS (self); GST_OBJECT_LOCK (self); - self->has_pending_v_info = gst_video_info_from_caps (&self->pending_v_info, caps); + gst_caps_replace (&self->pending_caps, caps); GST_OBJECT_UNLOCK (self); if (importer_class->set_caps) @@ -330,10 +332,14 @@ gst_clapper_importer_set_caps (GstClapperImporter *self, GstCaps *caps) void gst_clapper_importer_set_buffer (GstClapperImporter *self, GstBuffer *buffer) { - /* Both overlays and pending buffer must be - * set within a single importer locking */ GST_OBJECT_LOCK (self); + /* Pending v_info, buffer and overlays must be + * set within a single importer locking */ + if (self->pending_caps) { + self->has_pending_v_info = gst_video_info_from_caps (&self->pending_v_info, self->pending_caps); + gst_clear_caps (&self->pending_caps); + } gst_buffer_replace (&self->pending_buffer, buffer); gst_clapper_importer_prepare_overlays_locked (self); @@ -380,15 +386,13 @@ gst_clapper_importer_snapshot (GstClapperImporter *self, GdkSnapshot *snapshot, * lock ourselves to make sure everything matches */ GST_OBJECT_LOCK (self); - buffer_changed = gst_buffer_replace (&self->buffer, self->pending_buffer); - - /* Only replace v_info when buffer changed, this way - * we still use old (correct) v_info when resizing */ - if (buffer_changed && self->has_pending_v_info) { + if (self->has_pending_v_info) { self->v_info = self->pending_v_info; self->has_pending_v_info = FALSE; } + buffer_changed = gst_buffer_replace (&self->buffer, self->pending_buffer); + /* Ref overlays associated with current buffer */ for (i = 0; i < self->pending_overlays->len; i++) { GstClapperGdkOverlay *overlay = g_ptr_array_index (self->pending_overlays, i); diff --git a/lib/gst/plugin/gstclapperimporter.h b/lib/gst/plugin/gstclapperimporter.h index 6477f441..1f797de7 100644 --- a/lib/gst/plugin/gstclapperimporter.h +++ b/lib/gst/plugin/gstclapperimporter.h @@ -49,6 +49,7 @@ struct _GstClapperImporter { GstObject parent; + GstCaps *pending_caps; GstBuffer *pending_buffer, *buffer; GPtrArray *pending_overlays, *overlays; GstVideoInfo pending_v_info, v_info; From 908a388f68bde412175732376a8d933a5eaa7556 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Dzi=C4=99giel?= Date: Wed, 11 May 2022 17:05:59 +0200 Subject: [PATCH 2/3] meson: Give up on building GL base without GL windowing We do not want to build GL-based importers when GTK GL windowing support is missing, which might happen because of missing deps or on unsupported platform --- lib/gst/plugin/importers/meson.build | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/gst/plugin/importers/meson.build b/lib/gst/plugin/importers/meson.build index 5f190b54..57283588 100644 --- a/lib/gst/plugin/importers/meson.build +++ b/lib/gst/plugin/importers/meson.build @@ -46,8 +46,11 @@ if gst_gl_have_window_wayland and gst_gl_have_platform_egl endif endif -if gl_support_required and not have_gtk_gl_windowing - error('GL-based importer was enabled, but support for current GL windowing is missing') +if not have_gtk_gl_windowing + if gl_support_required + error('GL-based importer was enabled, but support for current GL windowing is missing') + endif + build_glbase = false endif if gst_gl_have_platform_egl From 8f0ad1279515a8ef7f7852bcce107a1c1d527196 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Dzi=C4=99giel?= Date: Wed, 11 May 2022 17:35:00 +0200 Subject: [PATCH 3/3] meson: Make sink compile on Windows OS We cannot compile app as a whole on MS Windows yet, but with those changes it is now possible to compile and run our new video sink alone on Windows OS --- lib/gst/clapper/meson.build | 20 +++++++++++++++++--- lib/meson.build | 11 +++++++++-- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/lib/gst/clapper/meson.build b/lib/gst/clapper/meson.build index 168946b8..2ce5e78e 100644 --- a/lib/gst/clapper/meson.build +++ b/lib/gst/clapper/meson.build @@ -43,6 +43,10 @@ if not gtk4_dep.version().version_compare('>=4.0.0') error('GTK4 version on this system is too old') endif +if not gir.found() + error('Cannot build lib without GIR support') +endif + if gst_gl_have_window_x11 and (gst_gl_have_platform_egl or gst_gl_have_platform_glx) gtk_x11_dep = dependency('gtk4-x11', required: false) if gtk_x11_dep.found() @@ -76,6 +80,18 @@ gstclapper_mpris_gdbus = gnome.gdbus_codegen('gstclapper-mpris-gdbus', namespace: 'GstClapperMpris' ) +gstclapper_deps = [ + gtk4_dep, glib_dep, gio_dep, + gstbase_dep, gstvideo_dep, gstaudio_dep, + gsttag_dep, gstpbutils_dep, libm +] + gtk_deps + +if os_unix + gstclapper_deps += giounix_dep +else + gstclapper_deps += giowin_dep +endif + gstclapper = library('gstclapper-' + api_version, gstclapper_sources + gstclapper_mpris_gdbus, c_args: gstclapper_defines, @@ -84,9 +100,7 @@ gstclapper = library('gstclapper-' + api_version, version: libversion, install: true, install_dir: pkglibdir, - dependencies: [gtk4_dep, glib_dep, gio_dep, giounix_dep, - gstbase_dep, gstvideo_dep, gstaudio_dep, - gsttag_dep, gstpbutils_dep, libm] + gtk_deps, + dependencies: gstclapper_deps, ) clapper_gir = gnome.generate_gir(gstclapper, diff --git a/lib/meson.build b/lib/meson.build index 45b94330..c930620b 100644 --- a/lib/meson.build +++ b/lib/meson.build @@ -9,6 +9,8 @@ cxx = meson.get_compiler('cpp') cdata = configuration_data() +os_unix = host_machine.system() != 'windows' + if cc.get_id() == 'msvc' msvc_args = [ # Ignore several spurious warnings for things gstreamer does very commonly @@ -243,7 +245,12 @@ libm = cc.find_library('m', required: false) glib_dep = dependency('glib-2.0', version: glib_req, fallback: ['glib', 'libglib_dep']) gmodule_dep = dependency('gmodule-2.0', fallback: ['glib', 'libgmodule_dep']) gio_dep = dependency('gio-2.0', fallback: ['glib', 'libgio_dep']) -giounix_dep = dependency('gio-unix-2.0', version: glib_req, fallback: ['glib', 'libgiounix_dep']) + +if os_unix + giounix_dep = dependency('gio-unix-2.0', version: glib_req, fallback: ['glib', 'libgio_dep']) +else + giowin_dep = dependency('gio-windows-2.0', version: glib_req, fallback : ['glib', 'libgio_dep']) +endif cdata.set('DISABLE_ORC', 1) cdata.set('GST_ENABLE_EXTRA_CHECKS', get_option('devel-checks')) @@ -251,7 +258,7 @@ cdata.set('GST_ENABLE_EXTRA_CHECKS', get_option('devel-checks')) configinc = include_directories('.') libsinc = include_directories('gst') -gir = find_program('g-ir-scanner') +gir = find_program('g-ir-scanner', required: false) gir_init_section = ['--add-init-section=extern void gst_init(gint*,gchar**);' + \ 'g_setenv("GST_REGISTRY_1.0", "@0@", TRUE);'.format(meson.current_build_dir() + '/gir_empty_registry.reg') + \ 'g_setenv("GST_PLUGIN_PATH_1_0", "", TRUE);' + \