mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-23 08:46:40 +00:00
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>
This commit is contained in:
parent
82dcb27401
commit
3bcb876c29
2 changed files with 24 additions and 0 deletions
|
@ -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);
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue