diff options
author | Philippe Normand <philn@igalia.com> | 2020-10-19 14:56:43 +0100 |
---|---|---|
committer | GStreamer Merge Bot <gitlab-merge-bot@gstreamer-foundation.org> | 2020-12-09 17:31:51 +0000 |
commit | 3bcb876c29bb9da233f1db71714da75d7abd8916 (patch) | |
tree | 60086965bfa4962532ec73666e19967b0329d42b /ext/wpe/WPEThreadedView.cpp | |
parent | 82dcb27401f897d9fbe561af17db37f54709bf39 (diff) | |
download | gstreamer-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/wpe/WPEThreadedView.cpp')
-rw-r--r-- | ext/wpe/WPEThreadedView.cpp | 15 |
1 files changed, 15 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); |