summaryrefslogtreecommitdiff
path: root/ext/wpe/WPEThreadedView.cpp
diff options
context:
space:
mode:
authorPhilippe Normand <philn@igalia.com>2019-09-24 16:57:54 -0700
committerThibault Saunier <tsaunier@gnome.org>2019-10-17 08:15:44 +0000
commita40476914d4cbc944b56d919538afa751fc3d813 (patch)
tree8fc6830e1fba20dfc67c3103a19a48fe8f3f78bc /ext/wpe/WPEThreadedView.cpp
parentd7778e6a7cd703089835d3b275c1915a82b47e1f (diff)
downloadgstreamer-plugins-bad-a40476914d4cbc944b56d919538afa751fc3d813.tar.gz
wpesrc: Implement load-bytes action signal
Diffstat (limited to 'ext/wpe/WPEThreadedView.cpp')
-rw-r--r--ext/wpe/WPEThreadedView.cpp43
1 files changed, 37 insertions, 6 deletions
diff --git a/ext/wpe/WPEThreadedView.cpp b/ext/wpe/WPEThreadedView.cpp
index 2406e4db9..a380ed39c 100644
--- a/ext/wpe/WPEThreadedView.cpp
+++ b/ext/wpe/WPEThreadedView.cpp
@@ -241,12 +241,9 @@ bool WPEThreadedView::initialize(GstWpeSrc* src, GstGLContext* context, GstGLDis
const gchar* location;
gboolean drawBackground = TRUE;
g_object_get(initializeContext.src, "location", &location, "draw-background", &drawBackground, nullptr);
- if (!location)
- g_warning("Invalid location");
- else {
- view.setDrawBackground(drawBackground);
+ view.setDrawBackground(drawBackground);
+ if (location)
view.loadUriUnlocked(location);
- }
g_cond_signal(&view.threading.cond);
return G_SOURCE_REMOVE;
},
@@ -261,7 +258,7 @@ bool WPEThreadedView::initialize(GstWpeSrc* src, GstGLContext* context, GstGLDis
g_source_unref(source);
- if (initializeContext.result) {
+ if (initializeContext.result && webkit.uri) {
GST_DEBUG("waiting load to finish");
GMutexHolder lock(threading.ready_mutex);
g_cond_wait(&threading.ready_cond, &threading.ready_mutex);
@@ -399,6 +396,40 @@ void WPEThreadedView::loadUri(const gchar* uri)
g_source_unref(source);
}
+void WPEThreadedView::loadData(GBytes* bytes)
+{
+ struct DataContext {
+ WPEThreadedView& view;
+ GBytes* bytes;
+ } dataContext { *this, g_bytes_ref(bytes) };
+
+ GSource* source = g_idle_source_new();
+ g_source_set_callback(source,
+ [](gpointer data) -> gboolean {
+ GST_DEBUG("on view thread");
+ auto& dataContext = *static_cast<DataContext*>(data);
+ auto& view = dataContext.view;
+ GMutexHolder lock(view.threading.mutex);
+
+ webkit_web_view_load_bytes(view.webkit.view, dataContext.bytes, nullptr, nullptr, nullptr);
+ g_bytes_unref(dataContext.bytes);
+
+ g_cond_signal(&view.threading.cond);
+ return G_SOURCE_REMOVE;
+ },
+ &dataContext, nullptr);
+ g_source_set_priority(source, WPE_GLIB_SOURCE_PRIORITY);
+
+ {
+ GMutexHolder lock(threading.mutex);
+ g_source_attach(source, glib.context);
+ g_cond_wait(&threading.cond, &threading.mutex);
+ GST_DEBUG("done");
+ }
+
+ g_source_unref(source);
+}
+
void WPEThreadedView::setDrawBackground(gboolean drawsBackground)
{
#if WEBKIT_CHECK_VERSION(2, 24, 0)