summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorPhilippe Normand <philn@igalia.com>2020-10-19 14:56:43 +0100
committerGStreamer Merge Bot <gitlab-merge-bot@gstreamer-foundation.org>2020-12-09 17:31:51 +0000
commit3bcb876c29bb9da233f1db71714da75d7abd8916 (patch)
tree60086965bfa4962532ec73666e19967b0329d42b /ext
parent82dcb27401f897d9fbe561af17db37f54709bf39 (diff)
downloadgstreamer-plugins-bad-3bcb876c29bb9da233f1db71714da75d7abd8916.tar.gz
wpe: Emit load-progress messages
The estimated-load-progress value can be used on application side to display a progress bar for instance. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1710>
Diffstat (limited to 'ext')
-rw-r--r--ext/wpe/WPEThreadedView.cpp15
-rw-r--r--ext/wpe/gstwpesrc.cpp9
2 files changed, 24 insertions, 0 deletions
diff --git a/ext/wpe/WPEThreadedView.cpp b/ext/wpe/WPEThreadedView.cpp
index d95c29869..9af1e2db4 100644
--- a/ext/wpe/WPEThreadedView.cpp
+++ b/ext/wpe/WPEThreadedView.cpp
@@ -205,6 +205,20 @@ static gboolean s_loadFailedWithTLSErrors(WebKitWebView*, gchar* failing_uri, G
return FALSE;
}
+static void s_loadProgressChaned(GObject* object, GParamSpec*, gpointer data)
+{
+ GstElement* src = GST_ELEMENT_CAST (data);
+ // The src element is locked already so we can't call
+ // gst_element_post_message(). Instead retrieve the bus manually and use it
+ // directly.
+ GstBus* bus = GST_ELEMENT_BUS (src);
+ double estimatedProgress;
+ g_object_get(object, "estimated-load-progress", &estimatedProgress, nullptr);
+ gst_object_ref (bus);
+ gst_bus_post (bus, gst_message_new_element(GST_OBJECT_CAST(src), gst_structure_new("wpe-stats", "estimated-load-progress", G_TYPE_DOUBLE, estimatedProgress * 100, nullptr)));
+ gst_object_unref (bus);
+}
+
WPEView::WPEView(WebKitWebContext* web_context, GstWpeSrc* src, GstGLContext* context, GstGLDisplay* display, int width, int height)
{
g_mutex_init(&threading.ready_mutex);
@@ -264,6 +278,7 @@ WPEView::WPEView(WebKitWebContext* web_context, GstWpeSrc* src, GstGLContext* co
g_signal_connect(webkit.view, "load-failed", G_CALLBACK(s_loadFailed), src);
g_signal_connect(webkit.view, "load-failed-with-tls-errors", G_CALLBACK(s_loadFailedWithTLSErrors), src);
+ g_signal_connect(webkit.view, "notify::estimated-load-progress", G_CALLBACK(s_loadProgressChaned), src);
gst_wpe_src_configure_web_view(src, webkit.view);
diff --git a/ext/wpe/gstwpesrc.cpp b/ext/wpe/gstwpesrc.cpp
index 6ee15cb55..9b824cf0a 100644
--- a/ext/wpe/gstwpesrc.cpp
+++ b/ext/wpe/gstwpesrc.cpp
@@ -30,6 +30,15 @@
* variable and make sure `video/x-raw, format=BGRA` caps are negotiated by the
* wpesrc element.
*
+ * As the webview loading is usually not instantaneous, the wpesrc element emits
+ * messages indicating the load progress, in percent. The value is an estimate
+ * based on the total number of bytes expected to be received for a document,
+ * including all its possible subresources and child documents. The application
+ * can handle these `element` messages synchronously for instance, in order to
+ * display a progress bar or other visual load indicator. The load percent value
+ * is stored in the message structure as a double value named
+ * `estimated-load-progress` and the structure name is `wpe-stats`.
+ *
* ## Example launch lines
*
* ```shell