wpe: Use `about:blank` as default URL to support only using load-bytes
authorThibault Saunier <tsaunier@igalia.com>
Tue, 4 Jan 2022 18:49:35 +0000 (15:49 -0300)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Thu, 24 Mar 2022 00:01:20 +0000 (00:01 +0000)
WebKit is not going to render anything until a URI is set, leading to a
WPE posting a `WPE View did not render a buffer` error message. To avoid
requiring the user to know it if they only want to use
`wpesrc::load-bytes` we can just use `about:blank` as default and
everything will work as users would expect.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1492>

subprojects/gst-plugins-bad/ext/wpe/gstwpe.h
subprojects/gst-plugins-bad/ext/wpe/gstwpesrcbin.cpp
subprojects/gst-plugins-bad/ext/wpe/gstwpevideosrc.cpp
subprojects/gst-plugins-bad/ext/wpe/meson.build
subprojects/gst-plugins-bad/tests/validate/meson.build
subprojects/gst-plugins-bad/tests/validate/wpe/load_bytes_first.validatetest [new file with mode: 0644]

index a997e72..3ff1dc5 100644 (file)
@@ -21,4 +21,5 @@
 
 #include <gst/gst.h>
 
+#define DEFAULT_LOCATION "about:blank"
 const gchar *gst_wpe_get_devenv_extension_path (void);
index 0d5e6d8..ff71eb6 100644 (file)
@@ -500,7 +500,7 @@ gst_wpe_src_class_init (GstWpeSrcClass * klass)
   gobject_class->finalize = gst_wpe_src_finalize;
 
   g_object_class_install_property (gobject_class, PROP_LOCATION,
-      g_param_spec_string ("location", "location", "The URL to display", "",
+      g_param_spec_string ("location", "location", "The URL to display", DEFAULT_LOCATION,
           (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
   g_object_class_install_property (gobject_class, PROP_DRAW_BACKGROUND,
       g_param_spec_boolean ("draw-background", "Draws the background",
index 3d89f70..c1e452e 100644 (file)
@@ -84,6 +84,7 @@
 #include <config.h>
 #endif
 
+#include "gstwpe.h"
 #include "gstwpevideosrc.h"
 #include <gst/gl/gl.h>
 #include <gst/gl/egl/gstglmemoryegl.h>
@@ -752,6 +753,7 @@ static void
 gst_wpe_video_src_init (GstWpeVideoSrc * src)
 {
   src->draw_background = DEFAULT_DRAW_BACKGROUND;
+  src->location = g_strdup (DEFAULT_LOCATION);
 
   gst_base_src_set_live (GST_BASE_SRC_CAST (src), TRUE);
 
@@ -789,7 +791,7 @@ gst_wpe_video_src_class_init (GstWpeVideoSrcClass * klass)
   g_object_class_install_property (gobject_class, PROP_LOCATION,
       g_param_spec_string ("location", "location",
           "The URL to display",
-          "", (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+          DEFAULT_LOCATION, (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
   g_object_class_install_property (gobject_class, PROP_DRAW_BACKGROUND,
       g_param_spec_boolean ("draw-background", "Draws the background",
           "Whether to draw the WebView background", DEFAULT_DRAW_BACKGROUND,
index 7d7edcf..9dca6c2 100644 (file)
@@ -1,3 +1,4 @@
+building_wpe = false
 wpe_feat = get_option('wpe').require(gstgl_dep.found(),
   error_message : 'wpe plugin enabled but GL support was not detected')
 
@@ -22,6 +23,7 @@ giounix_dep = dependency('gio-unix-2.0', required: false)
 
 wpe_extension_install_dir = get_option('prefix') / get_option('libdir') / meson.project_name() / 'wpe-extension'
 
+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,
index 12f3d26..3a282a2 100644 (file)
@@ -4,7 +4,8 @@ if not gst_tester.found()
 endif
 
 tests = [
-    'opencv/cvtracker'
+    {'path': 'opencv/cvtracker'},
+    {'path': 'wpe/load_bytes_first', 'skip': not building_wpe},
 ]
 
 env = environment()
@@ -16,14 +17,16 @@ env.set('GST_PLUGIN_LOADING_WHITELIST', 'gstreamer', 'gst-validate', 'gst-plugin
     'gst-plugins-bad@' + meson.project_build_root())
 
 foreach t: tests
-    test_dir_name = t.split('/')
-    test_name = 'validate'
-    foreach c: test_dir_name
-        test_name += '.' + c
-    endforeach
-    test_env = env
-    test_env.set('GST_VALIDATE_LOGSDIR', join_paths(meson.current_build_dir(), test_name))
-    test_file = join_paths(meson.current_source_dir(), t + '.validatetest')
-    test(test_name, gst_tester, args: [test_file, '--use-fakesinks'],
-        env: test_env, timeout : 3 * 60, protocol: 'tap')
+    if not t.get('skip', false)
+        test_dir_name = t.get('path').split('/')
+        test_name = 'validate'
+        foreach c: test_dir_name
+            test_name += '.' + c
+        endforeach
+        test_env = env
+        test_env.set('GST_VALIDATE_LOGSDIR', join_paths(meson.current_build_dir(), test_name))
+        test_file = join_paths(meson.current_source_dir(), t.get('path') + '.validatetest')
+        test(test_name, gst_tester, args: [test_file, '--use-fakesinks'],
+            env: test_env, timeout : 3 * 60, protocol: 'tap')
+    endif
 endforeach
diff --git a/subprojects/gst-plugins-bad/tests/validate/wpe/load_bytes_first.validatetest b/subprojects/gst-plugins-bad/tests/validate/wpe/load_bytes_first.validatetest
new file mode 100644 (file)
index 0000000..29a39bc
--- /dev/null
@@ -0,0 +1,13 @@
+meta,
+    args = {
+        "wpesrc name=wpesrc ! queue ! video/x-raw,width=480,height=270 ! fakesink name=sink",
+    }
+
+check-last-sample, checksum=e16c8ac11b4ad92e26abab2743d609f4c3ac2e37, playback-time=0.1
+emit-signal,
+    signal-name="load-bytes",
+    target-element-name="wpesrc",
+    params=< "<h1>test<h1>", >
+
+check-last-sample, checksum=8c0eb7a26cf0cb4cb3095a2a6f2d28c97be15874, playback-time=1.0
+stop;