wpe: Rename WPEView to GstWPEThreadedView

WebKit commit b12e7ed2ad3a ("[WPE] Upstream the new WPE platform API
https://bugs.webkit.org/show_bug.cgi?id=265286")[1] added a `WPEView` typedef
which clashes with our `WPEView` class.

Rename the `WPEView` class to `GstWPEThreadedView` to avoid the collision.
Also prefix the `WPEContextThread` class with `Gst` and rename the
source files to reflect the new class name and use lowercase while at it
for consistency

[1] b12e7ed2ad

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6096>
This commit is contained in:
Marvin Schmidt 2024-01-19 14:35:05 +01:00 committed by GStreamer Marge Bot
parent da03d2f2a0
commit 750de28e7a
5 changed files with 59 additions and 59 deletions

View file

@ -92,7 +92,7 @@
#include "gstwpesrcbin.h"
#include "gstwpevideosrc.h"
#include "gstwpe.h"
#include "WPEThreadedView.h"
#include "gstwpethreadedview.h"
#include <gst/allocators/allocators.h>
#include <gst/base/gstflowcombiner.h>

View file

@ -21,9 +21,9 @@
#include <config.h>
#endif
#include "WPEThreadedView.h"
#include "gstwpe.h"
#include "gstwpesrcbin.h"
#include "gstwpethreadedview.h"
#include <gst/gl/gl.h>
#include <gst/gl/egl/gsteglimage.h>
@ -54,14 +54,14 @@ private:
GMutex& m;
};
static WPEContextThread *s_view = NULL;
static GstWPEContextThread *s_view = NULL;
WPEContextThread& WPEContextThread::singleton()
GstWPEContextThread& GstWPEContextThread::singleton()
{
static gsize initialized = 0;
if (g_once_init_enter (&initialized)) {
s_view = new WPEContextThread;
s_view = new GstWPEContextThread;
g_once_init_leave (&initialized, 1);
}
@ -69,14 +69,14 @@ WPEContextThread& WPEContextThread::singleton()
return *s_view;
}
WPEContextThread::WPEContextThread()
GstWPEContextThread::GstWPEContextThread()
{
g_mutex_init(&threading.mutex);
g_cond_init(&threading.cond);
{
GMutexHolder lock(threading.mutex);
threading.thread = g_thread_new("WPEContextThread", s_viewThread, this);
threading.thread = g_thread_new("GstWPEContextThread", s_viewThread, this);
while (!threading.ready) {
g_cond_wait(&threading.cond, &threading.mutex);
}
@ -84,7 +84,7 @@ WPEContextThread::WPEContextThread()
}
}
WPEContextThread::~WPEContextThread()
GstWPEContextThread::~GstWPEContextThread()
{
if (threading.thread) {
g_thread_unref(threading.thread);
@ -96,7 +96,7 @@ WPEContextThread::~WPEContextThread()
}
template<typename Function>
void WPEContextThread::dispatch(Function func)
void GstWPEContextThread::dispatch(Function func)
{
struct Job {
Job(Function& f)
@ -144,9 +144,9 @@ void WPEContextThread::dispatch(Function func)
g_source_unref(source);
}
gpointer WPEContextThread::s_viewThread(gpointer data)
gpointer GstWPEContextThread::s_viewThread(gpointer data)
{
auto& view = *static_cast<WPEContextThread*>(data);
auto& view = *static_cast<GstWPEContextThread*>(data);
view.glib.context = g_main_context_new();
view.glib.loop = g_main_loop_new(view.glib.context, FALSE);
@ -157,7 +157,7 @@ gpointer WPEContextThread::s_viewThread(gpointer data)
GSource* source = g_idle_source_new();
g_source_set_callback(source,
[](gpointer data) -> gboolean {
auto& view = *static_cast<WPEContextThread*>(data);
auto& view = *static_cast<GstWPEContextThread*>(data);
GMutexHolder lock(view.threading.mutex);
view.threading.ready = TRUE;
g_cond_signal(&view.threading.cond);
@ -335,7 +335,7 @@ webkit_extension_msg_received (WebKitWebContext *context,
}
#endif
WPEView* WPEContextThread::createWPEView(GstWpeVideoSrc* src, GstGLContext* context, GstGLDisplay* display, int width, int height)
GstWPEThreadedView* GstWPEContextThread::createWPEView(GstWpeVideoSrc* src, GstGLContext* context, GstGLDisplay* display, int width, int height)
{
GST_DEBUG("context %p display %p, size (%d,%d)", context, display, width, height);
@ -345,7 +345,7 @@ WPEView* WPEContextThread::createWPEView(GstWpeVideoSrc* src, GstGLContext* cont
wpe_loader_init("libWPEBackend-fdo-1.0.so");
});
WPEView* view = nullptr;
GstWPEThreadedView* view = nullptr;
dispatch([&]() mutable {
if (!glib.web_context) {
auto *manager = webkit_website_data_manager_new_ephemeral();
@ -353,7 +353,7 @@ WPEView* WPEContextThread::createWPEView(GstWpeVideoSrc* src, GstGLContext* cont
webkit_web_context_new_with_website_data_manager(manager);
g_object_unref(manager);
}
view = new WPEView(glib.web_context, src, context, display, width, height);
view = new GstWPEThreadedView(glib.web_context, src, context, display, width, height);
});
if (view && view->hasUri()) {
@ -399,7 +399,7 @@ static void s_loadProgressChaned(GObject* object, GParamSpec*, gpointer data)
gst_object_unref (bus);
}
WPEView::WPEView(WebKitWebContext* web_context, GstWpeVideoSrc* src, GstGLContext* context, GstGLDisplay* display, int width, int height)
GstWPEThreadedView::GstWPEThreadedView(WebKitWebContext* web_context, GstWpeVideoSrc* src, GstGLContext* context, GstGLDisplay* display, int width, int height)
{
#ifdef G_OS_UNIX
{
@ -490,7 +490,7 @@ WPEView::WPEView(WebKitWebContext* web_context, GstWpeVideoSrc* src, GstGLContex
}
}
WPEView::~WPEView()
GstWPEThreadedView::~GstWPEThreadedView()
{
GstEGLImage *egl_pending = NULL;
GstEGLImage *egl_committed = NULL;
@ -542,7 +542,7 @@ WPEView::~WPEView()
audio.extension_msg_sigid = 0;
}
WPEContextThread::singleton().dispatch([&]() {
GstWPEContextThread::singleton().dispatch([&]() {
if (webkit.view) {
g_object_unref(webkit.view);
webkit.view = nullptr;
@ -572,7 +572,7 @@ WPEView::~WPEView()
GST_TRACE ("%p destroyed", this);
}
void WPEView::notifyLoadFinished()
void GstWPEThreadedView::notifyLoadFinished()
{
GMutexHolder lock(threading.ready_mutex);
if (!threading.ready) {
@ -581,14 +581,14 @@ void WPEView::notifyLoadFinished()
}
}
void WPEView::waitLoadCompletion()
void GstWPEThreadedView::waitLoadCompletion()
{
GMutexHolder lock(threading.ready_mutex);
while (!threading.ready)
g_cond_wait(&threading.ready_cond, &threading.ready_mutex);
}
GstEGLImage* WPEView::image()
GstEGLImage* GstWPEThreadedView::image()
{
GstEGLImage* ret = nullptr;
bool dispatchFrameComplete = false;
@ -623,7 +623,7 @@ GstEGLImage* WPEView::image()
return ret;
}
GstBuffer* WPEView::buffer()
GstBuffer* GstWPEThreadedView::buffer()
{
GstBuffer* ret = nullptr;
bool dispatchFrameComplete = false;
@ -658,7 +658,7 @@ GstBuffer* WPEView::buffer()
return ret;
}
void WPEView::resize(int width, int height)
void GstWPEThreadedView::resize(int width, int height)
{
GST_DEBUG("resize to %dx%d", width, height);
wpe.width = width;
@ -670,7 +670,7 @@ void WPEView::resize(int width, int height)
});
}
void WPEView::frameComplete()
void GstWPEThreadedView::frameComplete()
{
GST_TRACE("frame complete");
s_view->dispatch([&]() {
@ -679,7 +679,7 @@ void WPEView::frameComplete()
});
}
void WPEView::loadUriUnlocked(const gchar* uri)
void GstWPEThreadedView::loadUriUnlocked(const gchar* uri)
{
if (webkit.uri)
g_free(webkit.uri);
@ -689,7 +689,7 @@ void WPEView::loadUriUnlocked(const gchar* uri)
webkit_web_view_load_uri(webkit.view, webkit.uri);
}
void WPEView::loadUri(const gchar* uri)
void GstWPEThreadedView::loadUri(const gchar* uri)
{
s_view->dispatch([&]() {
loadUriUnlocked(uri);
@ -710,14 +710,14 @@ static void s_runJavascriptFinished(GObject* object, GAsyncResult* result, gpoin
webkit_javascript_result_unref(js_result);
}
void WPEView::runJavascript(const char* script)
void GstWPEThreadedView::runJavascript(const char* script)
{
s_view->dispatch([&]() {
webkit_web_view_run_javascript(webkit.view, script, nullptr, s_runJavascriptFinished, nullptr);
});
}
void WPEView::loadData(GBytes* bytes)
void GstWPEThreadedView::loadData(GBytes* bytes)
{
s_view->dispatch([this, bytes = g_bytes_ref(bytes)]() {
webkit_web_view_load_bytes(webkit.view, bytes, nullptr, nullptr, nullptr);
@ -725,7 +725,7 @@ void WPEView::loadData(GBytes* bytes)
});
}
void WPEView::setDrawBackground(gboolean drawsBackground)
void GstWPEThreadedView::setDrawBackground(gboolean drawsBackground)
{
GST_DEBUG("%s background rendering", drawsBackground ? "Enabling" : "Disabling");
WebKitColor color;
@ -733,7 +733,7 @@ void WPEView::setDrawBackground(gboolean drawsBackground)
webkit_web_view_set_background_color(webkit.view, &color);
}
void WPEView::releaseImage(gpointer imagePointer)
void GstWPEThreadedView::releaseImage(gpointer imagePointer)
{
s_view->dispatch([&]() {
GST_TRACE("Dispatch release exported image %p", imagePointer);
@ -743,11 +743,11 @@ void WPEView::releaseImage(gpointer imagePointer)
}
struct ImageContext {
WPEView* view;
GstWPEThreadedView* view;
gpointer image;
};
void WPEView::handleExportedImage(gpointer image)
void GstWPEThreadedView::handleExportedImage(gpointer image)
{
ImageContext* imageContext = g_slice_new(ImageContext);
imageContext->view = this;
@ -767,11 +767,11 @@ void WPEView::handleExportedImage(gpointer image)
}
struct SHMBufferContext {
WPEView* view;
GstWPEThreadedView* view;
struct wpe_fdo_shm_exported_buffer* buffer;
};
void WPEView::releaseSHMBuffer(gpointer data)
void GstWPEThreadedView::releaseSHMBuffer(gpointer data)
{
SHMBufferContext* context = static_cast<SHMBufferContext*>(data);
s_view->dispatch([&]() {
@ -781,14 +781,14 @@ void WPEView::releaseSHMBuffer(gpointer data)
});
}
void WPEView::s_releaseSHMBuffer(gpointer data)
void GstWPEThreadedView::s_releaseSHMBuffer(gpointer data)
{
SHMBufferContext* context = static_cast<SHMBufferContext*>(data);
context->view->releaseSHMBuffer(data);
g_slice_free(SHMBufferContext, context);
}
void WPEView::handleExportedBuffer(struct wpe_fdo_shm_exported_buffer* buffer)
void GstWPEThreadedView::handleExportedBuffer(struct wpe_fdo_shm_exported_buffer* buffer)
{
struct wl_shm_buffer* shmBuffer = wpe_fdo_shm_exported_buffer_get_shm_buffer(buffer);
auto format = wl_shm_buffer_get_format(shmBuffer);
@ -823,11 +823,11 @@ void WPEView::handleExportedBuffer(struct wpe_fdo_shm_exported_buffer* buffer)
}
}
struct wpe_view_backend_exportable_fdo_egl_client WPEView::s_exportableEGLClient = {
struct wpe_view_backend_exportable_fdo_egl_client GstWPEThreadedView::s_exportableEGLClient = {
// export_egl_image
nullptr,
[](void* data, struct wpe_fdo_egl_exported_image* image) {
auto& view = *static_cast<WPEView*>(data);
auto& view = *static_cast<GstWPEThreadedView*>(data);
view.handleExportedImage(static_cast<gpointer>(image));
},
nullptr,
@ -835,52 +835,52 @@ struct wpe_view_backend_exportable_fdo_egl_client WPEView::s_exportableEGLClient
nullptr, nullptr
};
struct wpe_view_backend_exportable_fdo_client WPEView::s_exportableClient = {
struct wpe_view_backend_exportable_fdo_client GstWPEThreadedView::s_exportableClient = {
nullptr,
nullptr,
// export_shm_buffer
[](void* data, struct wpe_fdo_shm_exported_buffer* buffer) {
auto& view = *static_cast<WPEView*>(data);
auto& view = *static_cast<GstWPEThreadedView*>(data);
view.handleExportedBuffer(buffer);
},
nullptr,
nullptr,
};
void WPEView::s_releaseImage(GstEGLImage* image, gpointer data)
void GstWPEThreadedView::s_releaseImage(GstEGLImage* image, gpointer data)
{
ImageContext* context = static_cast<ImageContext*>(data);
context->view->releaseImage(context->image);
g_slice_free(ImageContext, context);
}
struct wpe_view_backend* WPEView::backend() const
struct wpe_view_backend* GstWPEThreadedView::backend() const
{
return wpe.exportable ? wpe_view_backend_exportable_fdo_get_view_backend(wpe.exportable) : nullptr;
}
void WPEView::dispatchKeyboardEvent(struct wpe_input_keyboard_event& wpe_event)
void GstWPEThreadedView::dispatchKeyboardEvent(struct wpe_input_keyboard_event& wpe_event)
{
s_view->dispatch([&]() {
wpe_view_backend_dispatch_keyboard_event(backend(), &wpe_event);
});
}
void WPEView::dispatchPointerEvent(struct wpe_input_pointer_event& wpe_event)
void GstWPEThreadedView::dispatchPointerEvent(struct wpe_input_pointer_event& wpe_event)
{
s_view->dispatch([&]() {
wpe_view_backend_dispatch_pointer_event(backend(), &wpe_event);
});
}
void WPEView::dispatchAxisEvent(struct wpe_input_axis_event& wpe_event)
void GstWPEThreadedView::dispatchAxisEvent(struct wpe_input_axis_event& wpe_event)
{
s_view->dispatch([&]() {
wpe_view_backend_dispatch_axis_event(backend(), &wpe_event);
});
}
void WPEView::dispatchTouchEvent(struct wpe_input_touch_event& wpe_event)
void GstWPEThreadedView::dispatchTouchEvent(struct wpe_input_touch_event& wpe_event)
{
s_view->dispatch([&]() {
wpe_view_backend_dispatch_touch_event(backend(), &wpe_event);

View file

@ -32,10 +32,10 @@ typedef struct _GstGLContext GstGLContext;
typedef struct _GstGLDisplay GstGLDisplay;
typedef struct _GstEGLImage GstEGLImage;
class WPEView {
class GstWPEThreadedView {
public:
WPEView(WebKitWebContext*, GstWpeVideoSrc*, GstGLContext*, GstGLDisplay*, int width, int height);
~WPEView();
GstWPEThreadedView(WebKitWebContext*, GstWpeVideoSrc*, GstGLContext*, GstGLDisplay*, int width, int height);
~GstWPEThreadedView();
bool operator!() const { return m_isValid; }
@ -54,7 +54,7 @@ public:
void dispatchAxisEvent(struct wpe_input_axis_event&);
void dispatchTouchEvent(struct wpe_input_touch_event&);
/* Used by WPEContextThread */
/* Used by GstWPEContextThread */
bool hasUri() const { return webkit.uri; }
void disconnectLoadFailedSignal();
void waitLoadCompletion();
@ -123,14 +123,14 @@ private:
};
class WPEContextThread {
class GstWPEContextThread {
public:
static WPEContextThread& singleton();
static GstWPEContextThread& singleton();
WPEContextThread();
~WPEContextThread();
GstWPEContextThread();
~GstWPEContextThread();
WPEView* createWPEView(GstWpeVideoSrc*, GstGLContext*, GstGLDisplay*, int width, int height);
GstWPEThreadedView* createWPEView(GstWpeVideoSrc*, GstGLContext*, GstGLDisplay*, int width, int height);
template<typename Function>
void dispatch(Function);

View file

@ -92,7 +92,7 @@
#include <gst/video/video.h>
#include <xkbcommon/xkbcommon.h>
#include "WPEThreadedView.h"
#include "gstwpethreadedview.h"
#define DEFAULT_WIDTH 1920
#define DEFAULT_HEIGHT 1080
@ -129,7 +129,7 @@ struct _GstWpeVideoSrc
gint64 n_frames; /* total frames sent */
WPEView *view;
GstWPEThreadedView *view;
GArray *touch_points;
struct wpe_input_touch_event_raw *last_touch;
@ -289,7 +289,7 @@ gst_wpe_video_src_start (GstWpeVideoSrc * src)
GST_DEBUG_OBJECT (src, "Will %sfill GLMemories",
src->gl_enabled ? "" : "NOT ");
auto & thread = WPEContextThread::singleton ();
auto & thread = GstWPEContextThread::singleton ();
if (!src->view) {
src->view = thread.createWPEView (src, context, display,

View file

@ -25,7 +25,7 @@ wpe_extension_install_dir = get_option('prefix') / get_option('libdir') / meson.
building_wpe = true
gstwpe = library('gstwpe',
['WPEThreadedView.cpp', 'gstwpe.cpp', 'gstwpevideosrc.cpp', 'gstwpesrcbin.cpp'],
['gstwpethreadedview.cpp', 'gstwpe.cpp', 'gstwpevideosrc.cpp', 'gstwpesrcbin.cpp'],
dependencies : [egl_dep, wpe_dep, wpe_fdo_dep, gstallocators_dep, gstaudio_dep, gstvideo_dep,
gstbase_dep, gstgl_dep, xkbcommon_dep, wl_server_dep, giounix_dep],
cpp_args : gst_plugins_bad_args + ['-DHAVE_CONFIG_H=1',