Source: gst-plugins-bad1.0
Version: 1.22.3-1
Severity: normal
Tags: patch

Hi,

the new 2.40.x branch of the WPE WebKit engine introduced a new 2.0
API. The GStreamer WPE plugin uses the 1.1 API, which upstream would
like to remove sooner or later.

The wpewebkit-2.0 packages have already been uploaded to experimental.

Since WPE WebKit in Debian only has two reverse dependencies I would
like to make the transition, move wpewebkit-2.0 to unstable and get
rid of wpewebkit-1.1.

One of the reverse dependencies (cog) is ready and also available in
experimental.

The other one is gstreamer1.0-wpe. This has been updated upstream to
support the 2.0 API but it hasn't been released yet (it will likely
happen after summer if I'm not wrong). However the patch can be cherry
picked to the stable branch.

I'm attaching the debdiff in case you want to consider switching the
gst-wpe plugin to the 2.0 API in experimental. Once that is done I'm
ready to move the wpewebkit-2.0 packages to unstable.

Thanks,

Berto
diff -Nru gst-plugins-bad1.0-1.22.3/debian/changelog 
gst-plugins-bad1.0-1.22.3/debian/changelog
--- gst-plugins-bad1.0-1.22.3/debian/changelog  2023-05-21 14:31:50.000000000 
+0200
+++ gst-plugins-bad1.0-1.22.3/debian/changelog  2023-06-06 11:05:15.000000000 
+0200
@@ -1,3 +1,13 @@
+gst-plugins-bad1.0 (1.22.3-2) experimental; urgency=medium
+
+  [ Alberto Garcia ]
+  * Build the gst-wpe plugin using the 2.0 WPE API.
+    - debian/patches/wpe-2.0-api.patch: Cherry pick the corresponding
+      upstream commit (fe4f034c8a).
+    - debian/control: Build depend on libwpewebkit-2.0-dev.
+
+ -- Alberto Garcia <be...@igalia.com>  Tue, 06 Jun 2023 11:05:15 +0200
+
 gst-plugins-bad1.0 (1.22.3-1) experimental; urgency=medium
 
   * Team upload
diff -Nru gst-plugins-bad1.0-1.22.3/debian/control 
gst-plugins-bad1.0-1.22.3/debian/control
--- gst-plugins-bad1.0-1.22.3/debian/control    2023-05-21 14:31:50.000000000 
+0200
+++ gst-plugins-bad1.0-1.22.3/debian/control    2023-06-06 11:04:47.000000000 
+0200
@@ -57,7 +57,7 @@
                libopencv-dev (>= 3.0.0) [amd64 arm64 armel armhf i386 mips64el 
mipsel ppc64el s390x alpha hppa hurd-i386 m68k powerpc ppc64 riscv64],
                opencv-data [amd64 arm64 armel armhf i386 mips64el mipsel 
ppc64el s390x alpha hppa hurd-i386 m68k powerpc ppc64 riscv64],
                libwpebackend-fdo-1.0-dev (>= 1.8.0) [linux-any],
-               libwpewebkit-1.1-dev (>= 2.28.0) [linux-any],
+               libwpewebkit-2.0-dev [linux-any],
                libopenexr-dev,
                libopenh264-dev (>= 1.3.0),
                libopenjp2-7-dev (>= 2.2),
diff -Nru gst-plugins-bad1.0-1.22.3/debian/patches/series 
gst-plugins-bad1.0-1.22.3/debian/patches/series
--- gst-plugins-bad1.0-1.22.3/debian/patches/series     2023-05-21 
14:31:50.000000000 +0200
+++ gst-plugins-bad1.0-1.22.3/debian/patches/series     2023-06-06 
11:03:23.000000000 +0200
@@ -1,2 +1,3 @@
 02_opencv-data-path.patch
 Skip-failing-tests.patch
+wpe-2.0-api.patch
diff -Nru gst-plugins-bad1.0-1.22.3/debian/patches/wpe-2.0-api.patch 
gst-plugins-bad1.0-1.22.3/debian/patches/wpe-2.0-api.patch
--- gst-plugins-bad1.0-1.22.3/debian/patches/wpe-2.0-api.patch  1970-01-01 
01:00:00.000000000 +0100
+++ gst-plugins-bad1.0-1.22.3/debian/patches/wpe-2.0-api.patch  2023-06-06 
11:05:15.000000000 +0200
@@ -0,0 +1,246 @@
+From: Philippe Normand <ph...@igalia.com>
+Subject: wpe: Add support for the WPEWebKit 2.0 API version
+Origin: 
https://gitlab.freedesktop.org/gstreamer/gstreamer/-/commit/fe4f034c8a2a569c1530a3e98622b0ea1d96a0cb
+Index: gst-plugins-bad1.0-1.22.3/ext/wpe/WPEThreadedView.cpp
+===================================================================
+--- gst-plugins-bad1.0-1.22.3.orig/ext/wpe/WPEThreadedView.cpp
++++ gst-plugins-bad1.0-1.22.3/ext/wpe/WPEThreadedView.cpp
+@@ -186,7 +186,11 @@ initialize_web_extensions (WebKitWebCont
+     const gchar *local_path = gst_wpe_get_devenv_extension_path ();
+     const gchar *path = g_file_test (local_path, G_FILE_TEST_IS_DIR) ? 
local_path : G_STRINGIFY (WPE_EXTENSION_INSTALL_DIR);
+     GST_INFO ("Loading WebExtension from %s", path);
++#if USE_WPE2
++    webkit_web_context_set_web_process_extensions_directory (context, path);
++#else
+     webkit_web_context_set_web_extensions_directory (context, path);
++#endif
+ }
+ 
+ static void
+@@ -348,10 +352,14 @@ WPEView* WPEContextThread::createWPEView
+     WPEView* view = nullptr;
+     dispatch([&]() mutable {
+         if (!glib.web_context) {
++#if USE_WPE2
++            glib.web_context = 
WEBKIT_WEB_CONTEXT(g_object_new(WEBKIT_TYPE_WEB_CONTEXT, nullptr));
++#else
+             auto *manager = webkit_website_data_manager_new_ephemeral();
+             glib.web_context =
+                 webkit_web_context_new_with_website_data_manager(manager);
+             g_object_unref(manager);
++#endif
+         }
+         view = new WPEView(glib.web_context, src, context, display, width, 
height);
+     });
+@@ -407,7 +415,11 @@ WPEView::WPEView(WebKitWebContext* web_c
+ 
+         if (parent && GST_IS_WPE_SRC (parent)) {
+             audio.init_ext_sigid = g_signal_connect (web_context,
++#if USE_WPE2
++                              "initialize-web-process-extensions",
++#else
+                               "initialize-web-extensions",
++#endif
+                               G_CALLBACK (initialize_web_extensions),
+                               NULL);
+             audio.extension_msg_sigid = g_signal_connect (web_context,
+@@ -698,22 +710,32 @@ void WPEView::loadUri(const gchar* uri)
+ 
+ static void s_runJavascriptFinished(GObject* object, GAsyncResult* result, 
gpointer user_data)
+ {
+-    WebKitJavascriptResult* js_result;
+-    GError* error = NULL;
++    GError *error = NULL;
++#if USE_WPE2
++    g_autoptr(JSCValue) js_result = 
webkit_web_view_evaluate_javascript_finish(
++#else
++    g_autoptr(WebKitJavascriptResult) js_result = 
webkit_web_view_run_javascript_finish(
++#endif
++        WEBKIT_WEB_VIEW(object), result, &error);
+ 
+-    js_result = 
webkit_web_view_run_javascript_finish(WEBKIT_WEB_VIEW(object), result, &error);
+-    if (!js_result) {
++    // TODO: Pass result back to signal call site using a GstPromise?
++    (void) js_result;
++
++    if (error) {
+         GST_WARNING("Error running javascript: %s", error->message);
+         g_error_free(error);
+-        return;
+     }
+-    webkit_javascript_result_unref(js_result);
+ }
+ 
+ void WPEView::runJavascript(const char* script)
+ {
+     s_view->dispatch([&]() {
++#if USE_WPE2
++        webkit_web_view_evaluate_javascript(webkit.view, script, -1, nullptr, 
nullptr, nullptr,
++                                            s_runJavascriptFinished, nullptr);
++#else
+         webkit_web_view_run_javascript(webkit.view, script, nullptr, 
s_runJavascriptFinished, nullptr);
++#endif
+     });
+ }
+ 
+Index: gst-plugins-bad1.0-1.22.3/ext/wpe/meson.build
+===================================================================
+--- gst-plugins-bad1.0-1.22.3.orig/ext/wpe/meson.build
++++ gst-plugins-bad1.0-1.22.3/ext/wpe/meson.build
+@@ -6,16 +6,47 @@ if not wpe_feat.allowed()
+   subdir_done()
+ endif
+ 
+-wpe_dep = dependency('wpe-webkit-1.1', version : '>= 2.28', required : false)
+-if not wpe_dep.found()
+-  wpe_dep = dependency('wpe-webkit-1.0', version : '>= 2.28', required : 
wpe_feat)
++# Version checks copied from Cog, licensed under MIT.
++# https://github.com/Igalia/cog. The difference is that for the 2.0 API we
++# require version 2.40.1, the first one without strict Application ID
++# requirement for the WebProcess sandbox.
++wpe_target_api_version_required = {
++  '2.0': '>=2.40.1',
++  '1.1': '>=2.33.1',
++  '1.0': '>=2.28.0',
++}
++
++wpe_target_api = get_option('wpe_api')
++if wpe_target_api == 'auto'
++  foreach try_api : ['2.0', '1.1', '1.0']
++    wpewebkit_dep = dependency('wpe-webkit-' + try_api,
++                               version: 
wpe_target_api_version_required[try_api],
++                               required: false)
++    if wpewebkit_dep.found()
++      wpe_target_api = try_api
++      break
++    endif
++  endforeach
++else
++  wpewebkit_dep = dependency('wpe-webkit-' + wpe_target_api,
++                             version: 
wpe_target_api_version_required[wpe_target_api])
++endif
++if wpe_target_api == 'auto' or not wpewebkit_dep.found()
++  subdir_done()
+ endif
++
++use_wpe2 = 0
++if wpe_target_api == '2.0'
++  use_wpe2 = 1
++endif
++gst_wpe_c_args = ['-DUSE_WPE2=@0@'.format(use_wpe2)]
++
+ wpe_fdo_dep = dependency('wpebackend-fdo-1.0', version : '>= 1.8', required : 
wpe_feat)
+ egl_dep = dependency('egl', required : wpe_feat)
+ xkbcommon_dep = dependency('xkbcommon', version : '>= 0.8', required : 
wpe_feat)
+ wl_server_dep = dependency('wayland-server', required : wpe_feat)
+ 
+-if not (wpe_dep.found() and wpe_fdo_dep.found() and egl_dep.found() and 
xkbcommon_dep.found())
++if not (wpe_fdo_dep.found() and egl_dep.found() and xkbcommon_dep.found())
+   subdir_done()
+ endif
+ 
+@@ -26,10 +57,10 @@ wpe_extension_install_dir = get_option('
+ building_wpe = true
+ gstwpe = library('gstwpe',
+   ['WPEThreadedView.cpp', 'gstwpe.cpp', 'gstwpevideosrc.cpp', 
'gstwpesrcbin.cpp'],
+-  dependencies : [egl_dep, wpe_dep, wpe_fdo_dep, gstallocators_dep, 
gstaudio_dep, gstvideo_dep,
++  dependencies : [egl_dep, wpewebkit_dep, wpe_fdo_dep, gstallocators_dep, 
gstaudio_dep, gstvideo_dep,
+     gstbase_dep, gstgl_dep, xkbcommon_dep, wl_server_dep, giounix_dep],
+   cpp_args : gst_plugins_bad_args + ['-DHAVE_CONFIG_H=1',
+-    '-DWPE_EXTENSION_INSTALL_DIR=' + wpe_extension_install_dir],
++    '-DWPE_EXTENSION_INSTALL_DIR=' + wpe_extension_install_dir] + 
gst_wpe_c_args,
+   include_directories : [configinc],
+   install : true,
+   install_dir : plugins_install_dir)
+Index: gst-plugins-bad1.0-1.22.3/ext/wpe/wpe-extension/gstwpeextension.c
+===================================================================
+--- gst-plugins-bad1.0-1.22.3.orig/ext/wpe/wpe-extension/gstwpeextension.c
++++ gst-plugins-bad1.0-1.22.3/ext/wpe/wpe-extension/gstwpeextension.c
+@@ -28,18 +28,25 @@
+ #include <gst/gst.h>
+ #include <gmodule.h>
+ #include <gio/gunixfdlist.h>
+-#include <wpe/webkit-web-extension.h>
+ 
+ GST_DEBUG_CATEGORY_STATIC (wpe_extension_debug);
+ #define GST_CAT_DEFAULT wpe_extension_debug
+ 
+-G_MODULE_EXPORT void webkit_web_extension_initialize (WebKitWebExtension *
+-    extension);
++#if USE_WPE2
++#define WebKitWebExtension WebKitWebProcessExtension
++#define extension_initialize webkit_web_process_extension_initialize
++#define extension_send_message_to_context 
webkit_web_process_extension_send_message_to_context
++#else
++#define extension_initialize webkit_web_extension_initialize
++#define extension_send_message_to_context 
webkit_web_extension_send_message_to_context
++#endif
++
++G_MODULE_EXPORT void extension_initialize (WebKitWebExtension * extension);
+ 
+ static WebKitWebExtension *global_extension = NULL;
+ 
+ void
+-webkit_web_extension_initialize (WebKitWebExtension * extension)
++extension_initialize (WebKitWebExtension * extension)
+ {
+   g_return_if_fail (!global_extension);
+ 
+@@ -61,6 +68,6 @@ void
+ gst_wpe_extension_send_message (WebKitUserMessage * msg,
+     GCancellable * cancellable, GAsyncReadyCallback cb, gpointer udata)
+ {
+-  webkit_web_extension_send_message_to_context (global_extension, msg,
+-      cancellable, cb, udata);
++  extension_send_message_to_context (global_extension, msg, cancellable, cb,
++      udata);
+ }
+Index: gst-plugins-bad1.0-1.22.3/ext/wpe/wpe-extension/gstwpeextension.h
+===================================================================
+--- gst-plugins-bad1.0-1.22.3.orig/ext/wpe/wpe-extension/gstwpeextension.h
++++ gst-plugins-bad1.0-1.22.3/ext/wpe/wpe-extension/gstwpeextension.h
+@@ -15,7 +15,11 @@
+ 
+ #pragma once
+ 
++#if USE_WPE2
++#include <wpe/webkit-web-process-extension.h>
++#else
+ #include <wpe/webkit-web-extension.h>
++#endif
+ #include <gio/gunixfdlist.h>
+ #include <gst/gst.h>
+ #include <gst/base/gstbasesink.h>
+Index: gst-plugins-bad1.0-1.22.3/ext/wpe/wpe-extension/meson.build
+===================================================================
+--- gst-plugins-bad1.0-1.22.3.orig/ext/wpe/wpe-extension/meson.build
++++ gst-plugins-bad1.0-1.22.3/ext/wpe/wpe-extension/meson.build
+@@ -1,7 +1,7 @@
+ library('gstwpeextension',
+   ['gstwpeextension.c', 'gstwpeaudiosink.c', 'gstwpebusmsgforwarder.c'],
+-  dependencies : [wpe_dep, gst_dep, gstbase_dep, giounix_dep],
+-  c_args : ['-DHAVE_CONFIG_H=1'],
++  dependencies : [wpewebkit_dep, gst_dep, gstbase_dep, giounix_dep],
++  c_args : ['-DHAVE_CONFIG_H=1'] + gst_wpe_c_args,
+   include_directories : [configinc],
+   install : true,
+   install_dir : wpe_extension_install_dir)
+Index: gst-plugins-bad1.0-1.22.3/meson_options.txt
+===================================================================
+--- gst-plugins-bad1.0-1.22.3.orig/meson_options.txt
++++ gst-plugins-bad1.0-1.22.3/meson_options.txt
+@@ -181,6 +181,14 @@ option('x265', type : 'feature', value :
+ option('zbar', type : 'feature', value : 'auto', description : 'Barcode image 
scanner plugin using zbar library')
+ option('zxing', type : 'feature', value : 'auto', description : 'Barcode 
image scanner plugin using zxing-cpp library')
+ option('wpe', type : 'feature', value : 'auto', description : 'WPE Web 
browser plugin')
++option(
++  'wpe_api',
++  type: 'combo',
++  value: 'auto',
++  choices: ['auto', '1.0', '1.1', '2.0'],
++  description: 'WPE WebKit API to target (1.0 = soup2, 1.1/2.0 = soup3)'
++)
++
+ option('magicleap', type : 'feature', value : 'auto', description : 'Magic 
Leap platform support')
+ option('v4l2codecs', type : 'feature', value : 'auto', description : 
'Video4Linux Stateless CODECs support')
+ option('isac', type : 'feature', value : 'auto', description : 'iSAC plugin')

Reply via email to