2018-12-05 13:10:11 +00:00
|
|
|
/* Copyright (C) <2018> Philippe Normand <philn@igalia.com>
|
|
|
|
* Copyright (C) <2018> Žan Doberšek <zdobersek@igalia.com>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2021-03-10 20:27:52 +00:00
|
|
|
* SECTION:element-wpevideosrc
|
|
|
|
* @title: wpevideosrc
|
2018-12-05 13:10:11 +00:00
|
|
|
*
|
2021-03-10 20:27:52 +00:00
|
|
|
* The wpevideosrc element is used to produce a video texture representing a web page
|
2018-12-05 13:10:11 +00:00
|
|
|
* rendered off-screen by WPE.
|
|
|
|
*
|
2020-02-08 12:05:03 +00:00
|
|
|
* Starting from WPEBackend-FDO 1.6.x, software rendering support is available. This
|
2021-03-10 20:27:52 +00:00
|
|
|
* features allows wpevideosrc to be used on machines without GPU, and/or for testing
|
2020-02-08 12:05:03 +00:00
|
|
|
* purpose. To enable it, set the `LIBGL_ALWAYS_SOFTWARE=true` environment
|
|
|
|
* variable and make sure `video/x-raw, format=BGRA` caps are negotiated by the
|
2021-03-10 20:27:52 +00:00
|
|
|
* wpevideosrc element.
|
2020-02-08 12:05:03 +00:00
|
|
|
*
|
2021-03-10 20:27:52 +00:00
|
|
|
* As the webview loading is usually not instantaneous, the wpevideosrc element emits
|
2020-10-19 13:56:43 +00:00
|
|
|
* 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`.
|
|
|
|
*
|
2020-02-08 12:05:03 +00:00
|
|
|
* ## Example launch lines
|
2018-12-05 13:10:11 +00:00
|
|
|
*
|
2020-10-16 14:46:20 +00:00
|
|
|
* ```shell
|
2021-03-10 20:27:52 +00:00
|
|
|
* gst-launch-1.0 -v wpevideosrc location="https://gstreamer.freedesktop.org" ! queue ! glimagesink
|
2020-10-16 14:46:20 +00:00
|
|
|
* ```
|
2018-12-05 13:10:11 +00:00
|
|
|
* Shows the GStreamer website homepage
|
|
|
|
*
|
2020-10-16 14:46:20 +00:00
|
|
|
* ```shell
|
2021-03-10 20:27:52 +00:00
|
|
|
* LIBGL_ALWAYS_SOFTWARE=true gst-launch-1.0 -v wpevideosrc num-buffers=50 location="https://gstreamer.freedesktop.org" \
|
2020-10-16 14:46:20 +00:00
|
|
|
* videoconvert ! pngenc ! multifilesink location=/tmp/snapshot-%05d.png
|
|
|
|
* ```
|
2020-02-08 12:05:03 +00:00
|
|
|
* Saves the first 50 video frames generated for the GStreamer website as PNG files in /tmp.
|
|
|
|
*
|
2020-10-16 14:46:20 +00:00
|
|
|
* ```shell
|
2018-12-05 13:10:11 +00:00
|
|
|
* gst-play-1.0 --videosink gtkglsink wpe://https://gstreamer.freedesktop.org
|
2020-10-16 14:46:20 +00:00
|
|
|
* ```
|
2018-12-05 13:10:11 +00:00
|
|
|
* Shows the GStreamer website homepage as played with GstPlayer in a GTK+ window.
|
|
|
|
*
|
2020-10-16 14:46:20 +00:00
|
|
|
* ```shell
|
2021-03-10 20:27:52 +00:00
|
|
|
* gst-launch-1.0 glvideomixer name=m sink_1::zorder=0 ! glimagesink wpevideosrc location="file:///tmp/asset.html" draw-background=0 \
|
2020-10-16 14:46:20 +00:00
|
|
|
* ! m. videotestsrc ! queue ! glupload ! glcolorconvert ! m.
|
|
|
|
* ```
|
2018-12-05 13:10:11 +00:00
|
|
|
* Composite WPE with a video stream in a single OpenGL scene.
|
|
|
|
*
|
2020-10-16 14:46:20 +00:00
|
|
|
* ```shell
|
|
|
|
* gst-launch-1.0 glvideomixer name=m sink_1::zorder=0 sink_0::height=818 sink_0::width=1920 ! gtkglsink \
|
2021-03-10 20:27:52 +00:00
|
|
|
* wpevideosrc location="file:///tmp/asset.html" draw-background=0 ! m.
|
2020-10-16 14:46:20 +00:00
|
|
|
* uridecodebin uri="http://example.com/Sintel.2010.1080p.mkv" name=d d. ! queue ! glupload ! glcolorconvert ! m.
|
|
|
|
* ```
|
2018-12-05 13:10:11 +00:00
|
|
|
* Composite WPE with a video stream, sink_0 pad properties have to match the video dimensions.
|
2020-10-16 14:46:20 +00:00
|
|
|
*
|
|
|
|
* Since: 1.16
|
2018-12-05 13:10:11 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* TODO:
|
|
|
|
* - DMABuf support (requires changes in WPEBackend-fdo to expose DMABuf planes and fds)
|
|
|
|
* - Custom EGLMemory allocator
|
|
|
|
* - Better navigation events handling (would require a new GstNavigation API)
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include <config.h>
|
|
|
|
#endif
|
|
|
|
|
2021-03-10 20:27:52 +00:00
|
|
|
#include "gstwpevideosrc.h"
|
2018-12-05 13:10:11 +00:00
|
|
|
#include <gst/gl/gl.h>
|
|
|
|
#include <gst/gl/egl/gstglmemoryegl.h>
|
|
|
|
#include <gst/gl/wayland/gstgldisplay_wayland.h>
|
2019-06-05 11:47:16 +00:00
|
|
|
#include <gst/video/video.h>
|
2018-12-05 13:10:11 +00:00
|
|
|
#include <xkbcommon/xkbcommon.h>
|
|
|
|
|
|
|
|
#include "WPEThreadedView.h"
|
|
|
|
|
|
|
|
#define DEFAULT_WIDTH 1920
|
|
|
|
#define DEFAULT_HEIGHT 1080
|
|
|
|
#define DEFAULT_FPS_N 30
|
|
|
|
#define DEFAULT_FPS_D 1
|
2021-08-29 10:04:17 +00:00
|
|
|
#define DEFAULT_DRAW_BACKGROUND TRUE
|
2018-12-05 13:10:11 +00:00
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
|
|
|
PROP_LOCATION,
|
|
|
|
PROP_DRAW_BACKGROUND
|
|
|
|
};
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
SIGNAL_CONFIGURE_WEB_VIEW,
|
2019-09-24 23:57:54 +00:00
|
|
|
SIGNAL_LOAD_BYTES,
|
2018-12-05 13:10:11 +00:00
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
2021-03-10 20:27:52 +00:00
|
|
|
static guint gst_wpe_video_src_signals[LAST_SIGNAL] = { 0 };
|
2018-12-05 13:10:11 +00:00
|
|
|
|
2021-03-10 20:27:52 +00:00
|
|
|
struct _GstWpeVideoSrc
|
2018-12-05 13:10:11 +00:00
|
|
|
{
|
2019-08-07 16:07:21 +00:00
|
|
|
GstGLBaseSrc parent;
|
|
|
|
|
|
|
|
/* properties */
|
2018-12-05 13:10:11 +00:00
|
|
|
gchar *location;
|
|
|
|
gboolean draw_background;
|
2019-09-24 23:57:54 +00:00
|
|
|
|
|
|
|
GBytes *bytes;
|
2020-02-08 12:05:03 +00:00
|
|
|
gboolean gl_enabled;
|
2020-07-28 22:04:40 +00:00
|
|
|
|
|
|
|
gint64 n_frames; /* total frames sent */
|
2020-08-05 17:41:45 +00:00
|
|
|
|
|
|
|
WPEView *view;
|
2021-01-04 08:34:40 +00:00
|
|
|
|
|
|
|
GMutex lock;
|
2018-12-05 13:10:11 +00:00
|
|
|
};
|
|
|
|
|
2021-01-04 08:34:40 +00:00
|
|
|
#define WPE_LOCK(o) g_mutex_lock(&(o)->lock)
|
|
|
|
#define WPE_UNLOCK(o) g_mutex_unlock(&(o)->lock)
|
|
|
|
|
2021-08-29 09:28:57 +00:00
|
|
|
GST_DEBUG_CATEGORY_EXTERN (wpe_video_src_debug);
|
|
|
|
#define GST_CAT_DEFAULT wpe_video_src_debug
|
|
|
|
|
2021-03-10 20:27:52 +00:00
|
|
|
#define gst_wpe_video_src_parent_class parent_class
|
2021-11-16 12:53:35 +00:00
|
|
|
G_DEFINE_TYPE (GstWpeVideoSrc, gst_wpe_video_src, GST_TYPE_GL_BASE_SRC);
|
2018-12-05 13:10:11 +00:00
|
|
|
|
2021-08-29 09:30:53 +00:00
|
|
|
#define WPE_RAW_CAPS "video/x-raw, " \
|
2020-07-01 08:00:41 +00:00
|
|
|
"format = (string) BGRA, " \
|
|
|
|
"width = " GST_VIDEO_SIZE_RANGE ", " \
|
|
|
|
"height = " GST_VIDEO_SIZE_RANGE ", " \
|
|
|
|
"framerate = " GST_VIDEO_FPS_RANGE ", " \
|
|
|
|
"pixel-aspect-ratio = (fraction)1/1"
|
|
|
|
|
2021-08-29 09:30:53 +00:00
|
|
|
#define WPE_GL_CAPS "video/x-raw(memory:GLMemory), " \
|
2020-07-01 08:00:41 +00:00
|
|
|
"format = (string) RGBA, " \
|
|
|
|
"width = " GST_VIDEO_SIZE_RANGE ", " \
|
|
|
|
"height = " GST_VIDEO_SIZE_RANGE ", " \
|
|
|
|
"framerate = " GST_VIDEO_FPS_RANGE ", " \
|
|
|
|
"pixel-aspect-ratio = (fraction)1/1, texture-target = (string)2D"
|
|
|
|
|
2021-08-29 09:30:53 +00:00
|
|
|
#define WPE_VIDEO_SRC_CAPS WPE_GL_CAPS "; " WPE_RAW_CAPS
|
|
|
|
#define WPE_VIDEO_SRC_DOC_CAPS WPE_GL_CAPS "; video/x-raw, format = (string) BGRA"
|
2020-07-01 08:00:41 +00:00
|
|
|
|
2018-12-05 13:10:11 +00:00
|
|
|
static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
|
|
|
|
GST_PAD_SRC,
|
|
|
|
GST_PAD_ALWAYS,
|
2021-03-10 20:27:52 +00:00
|
|
|
GST_STATIC_CAPS (WPE_VIDEO_SRC_CAPS));
|
2018-12-05 13:10:11 +00:00
|
|
|
|
2020-02-08 12:05:03 +00:00
|
|
|
static GstFlowReturn
|
2021-11-16 12:53:35 +00:00
|
|
|
gst_wpe_video_src_create (GstBaseSrc * bsrc, guint64 offset, guint length,
|
|
|
|
GstBuffer ** buf)
|
2020-02-08 12:05:03 +00:00
|
|
|
{
|
2020-07-28 22:04:40 +00:00
|
|
|
GstGLBaseSrc *gl_src = GST_GL_BASE_SRC (bsrc);
|
2021-03-10 20:27:52 +00:00
|
|
|
GstWpeVideoSrc *src = GST_WPE_VIDEO_SRC (bsrc);
|
2020-02-08 12:05:03 +00:00
|
|
|
GstFlowReturn ret = GST_FLOW_ERROR;
|
|
|
|
GstBuffer *locked_buffer;
|
2020-07-28 22:04:40 +00:00
|
|
|
GstClockTime next_time;
|
|
|
|
gint64 ts_offset = 0;
|
2020-02-08 12:05:03 +00:00
|
|
|
|
2021-01-04 08:34:40 +00:00
|
|
|
WPE_LOCK (src);
|
2020-02-08 12:05:03 +00:00
|
|
|
if (src->gl_enabled) {
|
2021-01-04 08:34:40 +00:00
|
|
|
WPE_UNLOCK (src);
|
2021-11-16 12:53:35 +00:00
|
|
|
return GST_CALL_PARENT_WITH_DEFAULT (GST_BASE_SRC_CLASS, create, (bsrc,
|
|
|
|
offset, length, buf), ret);
|
2020-02-08 12:05:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
locked_buffer = src->view->buffer ();
|
2020-08-24 15:57:55 +00:00
|
|
|
if (locked_buffer == NULL) {
|
2021-01-04 08:34:40 +00:00
|
|
|
WPE_UNLOCK (src);
|
2020-08-24 15:57:55 +00:00
|
|
|
GST_ELEMENT_ERROR (src, RESOURCE, FAILED,
|
|
|
|
("WPE View did not render a buffer"), (NULL));
|
|
|
|
return ret;
|
2020-02-08 12:05:03 +00:00
|
|
|
}
|
2020-08-24 15:57:55 +00:00
|
|
|
*buf = gst_buffer_copy_deep (locked_buffer);
|
2020-07-28 22:04:40 +00:00
|
|
|
|
2021-11-16 12:53:35 +00:00
|
|
|
g_object_get (gl_src, "timestamp-offset", &ts_offset, NULL);
|
2020-07-28 22:04:40 +00:00
|
|
|
|
|
|
|
/* The following code mimics the behaviour of GLBaseSrc::fill */
|
|
|
|
GST_BUFFER_TIMESTAMP (*buf) = ts_offset + gl_src->running_time;
|
|
|
|
GST_BUFFER_OFFSET (*buf) = src->n_frames;
|
|
|
|
src->n_frames++;
|
|
|
|
GST_BUFFER_OFFSET_END (*buf) = src->n_frames;
|
|
|
|
if (gl_src->out_info.fps_n) {
|
|
|
|
next_time = gst_util_uint64_scale_int (src->n_frames * GST_SECOND,
|
|
|
|
gl_src->out_info.fps_d, gl_src->out_info.fps_n);
|
|
|
|
GST_BUFFER_DURATION (*buf) = next_time - gl_src->running_time;
|
|
|
|
} else {
|
|
|
|
next_time = ts_offset;
|
|
|
|
GST_BUFFER_DURATION (*buf) = GST_CLOCK_TIME_NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_LOG_OBJECT (src, "Created buffer from SHM %" GST_PTR_FORMAT, *buf);
|
|
|
|
|
|
|
|
gl_src->running_time = next_time;
|
|
|
|
|
2020-08-24 15:57:55 +00:00
|
|
|
ret = GST_FLOW_OK;
|
2021-01-04 08:34:40 +00:00
|
|
|
WPE_UNLOCK (src);
|
2020-02-08 12:05:03 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2021-11-16 12:56:38 +00:00
|
|
|
static GQuark
|
|
|
|
_egl_image_quark (void)
|
|
|
|
{
|
|
|
|
static GQuark quark = 0;
|
|
|
|
|
|
|
|
if (!quark)
|
|
|
|
quark = g_quark_from_static_string ("GstWPEEGLImage");
|
|
|
|
return quark;
|
|
|
|
}
|
|
|
|
|
2018-12-05 13:10:11 +00:00
|
|
|
static gboolean
|
2021-03-10 20:27:52 +00:00
|
|
|
gst_wpe_video_src_fill_memory (GstGLBaseSrc * bsrc, GstGLMemory * memory)
|
2018-12-05 13:10:11 +00:00
|
|
|
{
|
2021-03-10 20:27:52 +00:00
|
|
|
GstWpeVideoSrc *src = GST_WPE_VIDEO_SRC (bsrc);
|
2019-08-07 16:07:21 +00:00
|
|
|
const GstGLFuncs *gl;
|
|
|
|
guint tex_id;
|
|
|
|
GstEGLImage *locked_image;
|
|
|
|
|
|
|
|
if (!gst_gl_context_check_feature (GST_GL_CONTEXT (bsrc->context),
|
|
|
|
"EGL_KHR_image_base")) {
|
|
|
|
GST_ERROR_OBJECT (src, "EGL_KHR_image_base is not supported");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2018-12-05 13:10:11 +00:00
|
|
|
|
2021-01-04 08:34:40 +00:00
|
|
|
WPE_LOCK (src);
|
2018-12-05 13:10:11 +00:00
|
|
|
|
2019-08-07 16:07:21 +00:00
|
|
|
gl = bsrc->context->gl_vtable;
|
|
|
|
tex_id = gst_gl_memory_get_texture_id (memory);
|
|
|
|
locked_image = src->view->image ();
|
|
|
|
|
|
|
|
if (!locked_image) {
|
2021-01-04 08:34:40 +00:00
|
|
|
WPE_UNLOCK (src);
|
2019-08-07 16:07:21 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
2018-12-05 13:10:11 +00:00
|
|
|
|
2021-11-16 12:56:38 +00:00
|
|
|
// The EGLImage is implicitely associated with the memory we're filling, so we
|
|
|
|
// need to ensure their life cycles are tied.
|
|
|
|
gst_mini_object_set_qdata (GST_MINI_OBJECT_CAST (memory), _egl_image_quark (),
|
|
|
|
gst_egl_image_ref (locked_image), (GDestroyNotify) gst_egl_image_unref);
|
|
|
|
|
2019-08-07 16:07:21 +00:00
|
|
|
gl->ActiveTexture (GL_TEXTURE0 + memory->plane);
|
|
|
|
gl->BindTexture (GL_TEXTURE_2D, tex_id);
|
|
|
|
gl->EGLImageTargetTexture2D (GL_TEXTURE_2D,
|
|
|
|
gst_egl_image_get_image (locked_image));
|
|
|
|
gl->Flush ();
|
2021-01-04 08:34:40 +00:00
|
|
|
WPE_UNLOCK (src);
|
2018-12-05 13:10:11 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2021-03-10 20:27:52 +00:00
|
|
|
gst_wpe_video_src_start (GstWpeVideoSrc * src)
|
2018-12-05 13:10:11 +00:00
|
|
|
{
|
2020-02-08 12:05:03 +00:00
|
|
|
GstGLContext *context = NULL;
|
|
|
|
GstGLDisplay *display = NULL;
|
2020-08-22 13:38:38 +00:00
|
|
|
GstGLBaseSrc *base_src = GST_GL_BASE_SRC (src);
|
2020-10-06 11:19:21 +00:00
|
|
|
gboolean created_view = FALSE;
|
2021-05-06 17:17:29 +00:00
|
|
|
GBytes *bytes;
|
2018-12-05 13:10:11 +00:00
|
|
|
|
2019-08-07 16:07:21 +00:00
|
|
|
GST_INFO_OBJECT (src, "Starting up");
|
2021-01-04 08:34:40 +00:00
|
|
|
WPE_LOCK (src);
|
2020-02-08 12:05:03 +00:00
|
|
|
|
2020-08-22 13:38:38 +00:00
|
|
|
if (src->gl_enabled) {
|
2020-02-08 12:05:03 +00:00
|
|
|
context = base_src->context;
|
|
|
|
display = base_src->display;
|
|
|
|
}
|
|
|
|
|
2021-11-16 12:53:35 +00:00
|
|
|
GST_DEBUG_OBJECT (src, "Will %sfill GLMemories",
|
|
|
|
src->gl_enabled ? "" : "NOT ");
|
2020-02-08 12:05:03 +00:00
|
|
|
|
2020-08-05 17:41:45 +00:00
|
|
|
auto & thread = WPEContextThread::singleton ();
|
2020-10-06 11:19:21 +00:00
|
|
|
|
|
|
|
if (!src->view) {
|
|
|
|
src->view = thread.createWPEView (src, context, display,
|
|
|
|
GST_VIDEO_INFO_WIDTH (&base_src->out_info),
|
|
|
|
GST_VIDEO_INFO_HEIGHT (&base_src->out_info));
|
|
|
|
created_view = TRUE;
|
2020-10-07 10:13:09 +00:00
|
|
|
GST_DEBUG_OBJECT (src, "created view %p", src->view);
|
2020-10-06 11:19:21 +00:00
|
|
|
}
|
2020-08-05 17:41:45 +00:00
|
|
|
|
|
|
|
if (!src->view) {
|
2021-01-04 08:34:40 +00:00
|
|
|
WPE_UNLOCK (src);
|
2020-08-05 17:41:45 +00:00
|
|
|
GST_ELEMENT_ERROR (src, RESOURCE, FAILED,
|
|
|
|
("WPEBackend-FDO EGL display initialisation failed"), (NULL));
|
|
|
|
return FALSE;
|
|
|
|
}
|
2019-09-24 23:57:54 +00:00
|
|
|
|
2021-05-06 17:17:29 +00:00
|
|
|
GST_OBJECT_LOCK (src);
|
|
|
|
bytes = src->bytes;
|
|
|
|
src->bytes = NULL;
|
|
|
|
GST_OBJECT_UNLOCK (src);
|
|
|
|
|
|
|
|
if (bytes != NULL) {
|
|
|
|
src->view->loadData (bytes);
|
|
|
|
g_bytes_unref (bytes);
|
2019-09-24 23:57:54 +00:00
|
|
|
}
|
|
|
|
|
2020-10-06 11:19:21 +00:00
|
|
|
if (created_view) {
|
|
|
|
src->n_frames = 0;
|
|
|
|
}
|
2021-01-04 08:34:40 +00:00
|
|
|
WPE_UNLOCK (src);
|
2020-08-05 17:41:45 +00:00
|
|
|
return TRUE;
|
2018-12-05 13:10:11 +00:00
|
|
|
}
|
|
|
|
|
2020-08-22 13:38:38 +00:00
|
|
|
static gboolean
|
2021-03-10 20:27:52 +00:00
|
|
|
gst_wpe_video_src_decide_allocation (GstBaseSrc * base_src, GstQuery * query)
|
2018-12-05 13:10:11 +00:00
|
|
|
{
|
2020-08-22 13:38:38 +00:00
|
|
|
GstGLBaseSrc *gl_src = GST_GL_BASE_SRC (base_src);
|
2021-03-10 20:27:52 +00:00
|
|
|
GstWpeVideoSrc *src = GST_WPE_VIDEO_SRC (base_src);
|
2020-08-22 13:38:38 +00:00
|
|
|
GstCapsFeatures *caps_features;
|
|
|
|
|
2021-01-04 08:34:40 +00:00
|
|
|
WPE_LOCK (src);
|
2020-08-22 13:38:38 +00:00
|
|
|
caps_features = gst_caps_get_features (gl_src->out_caps, 0);
|
2021-11-16 12:53:35 +00:00
|
|
|
if (caps_features != NULL
|
|
|
|
&& gst_caps_features_contains (caps_features,
|
|
|
|
GST_CAPS_FEATURE_MEMORY_GL_MEMORY)) {
|
2020-08-22 13:38:38 +00:00
|
|
|
src->gl_enabled = TRUE;
|
|
|
|
} else {
|
|
|
|
src->gl_enabled = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (src->gl_enabled) {
|
2021-01-04 08:34:40 +00:00
|
|
|
WPE_UNLOCK (src);
|
2021-11-16 12:53:35 +00:00
|
|
|
return GST_CALL_PARENT_WITH_DEFAULT (GST_BASE_SRC_CLASS, decide_allocation,
|
|
|
|
(base_src, query), FALSE);
|
2020-08-22 13:38:38 +00:00
|
|
|
}
|
2021-01-04 08:34:40 +00:00
|
|
|
WPE_UNLOCK (src);
|
2021-03-10 20:27:52 +00:00
|
|
|
return gst_wpe_video_src_start (src);
|
2020-08-22 13:38:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2021-03-10 20:27:52 +00:00
|
|
|
gst_wpe_video_src_gl_start (GstGLBaseSrc * base_src)
|
2020-08-22 13:38:38 +00:00
|
|
|
{
|
2021-03-10 20:27:52 +00:00
|
|
|
GstWpeVideoSrc *src = GST_WPE_VIDEO_SRC (base_src);
|
|
|
|
return gst_wpe_video_src_start (src);
|
2020-08-22 13:38:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2021-03-10 20:27:52 +00:00
|
|
|
gst_wpe_video_src_stop_unlocked (GstWpeVideoSrc * src)
|
2020-08-22 13:38:38 +00:00
|
|
|
{
|
2019-08-07 16:07:21 +00:00
|
|
|
if (src->view) {
|
2020-10-07 10:13:09 +00:00
|
|
|
GST_DEBUG_OBJECT (src, "deleting view %p", src->view);
|
2019-08-07 16:07:21 +00:00
|
|
|
delete src->view;
|
|
|
|
src->view = NULL;
|
2018-12-05 13:10:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-22 13:38:38 +00:00
|
|
|
static void
|
2021-03-10 20:27:52 +00:00
|
|
|
gst_wpe_video_src_gl_stop (GstGLBaseSrc * base_src)
|
2020-08-22 13:38:38 +00:00
|
|
|
{
|
2021-03-10 20:27:52 +00:00
|
|
|
GstWpeVideoSrc *src = GST_WPE_VIDEO_SRC (base_src);
|
2020-08-22 13:38:38 +00:00
|
|
|
|
2021-01-04 08:34:40 +00:00
|
|
|
WPE_LOCK (src);
|
2021-03-10 20:27:52 +00:00
|
|
|
gst_wpe_video_src_stop_unlocked (src);
|
2021-01-04 08:34:40 +00:00
|
|
|
WPE_UNLOCK (src);
|
2020-08-22 13:38:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2021-03-10 20:27:52 +00:00
|
|
|
gst_wpe_video_src_stop (GstBaseSrc * base_src)
|
2020-08-22 13:38:38 +00:00
|
|
|
{
|
2021-03-10 20:27:52 +00:00
|
|
|
GstWpeVideoSrc *src = GST_WPE_VIDEO_SRC (base_src);
|
2020-08-22 13:38:38 +00:00
|
|
|
|
2020-09-29 13:46:00 +00:00
|
|
|
/* we can call this always, GstGLBaseSrc is smart enough to not crash if
|
|
|
|
* gst_gl_base_src_gl_start() has not been called from chaining up
|
2021-03-10 20:27:52 +00:00
|
|
|
* gst_wpe_video_src_decide_allocation() */
|
2021-11-16 12:53:35 +00:00
|
|
|
if (!GST_CALL_PARENT_WITH_DEFAULT (GST_BASE_SRC_CLASS, stop, (base_src),
|
|
|
|
FALSE))
|
2020-09-29 13:46:00 +00:00
|
|
|
return FALSE;
|
|
|
|
|
2021-01-04 08:34:40 +00:00
|
|
|
WPE_LOCK (src);
|
2020-08-22 13:38:38 +00:00
|
|
|
|
2021-03-10 20:27:52 +00:00
|
|
|
/* if gl-enabled, gst_wpe_video_src_stop_unlocked() would have already been called
|
|
|
|
* inside gst_wpe_video_src_gl_stop() from the base class stopping the OpenGL
|
2020-09-29 13:46:00 +00:00
|
|
|
* context */
|
|
|
|
if (!src->gl_enabled)
|
2021-03-10 20:27:52 +00:00
|
|
|
gst_wpe_video_src_stop_unlocked (src);
|
2020-08-22 13:38:38 +00:00
|
|
|
|
2021-01-04 08:34:40 +00:00
|
|
|
WPE_UNLOCK (src);
|
2020-08-22 13:38:38 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2018-12-05 13:10:11 +00:00
|
|
|
static GstCaps *
|
2021-08-29 09:30:53 +00:00
|
|
|
gst_wpe_video_src_fixate (GstBaseSrc * base_src, GstCaps * combined_caps)
|
2018-12-05 13:10:11 +00:00
|
|
|
{
|
2021-03-10 20:27:52 +00:00
|
|
|
GstWpeVideoSrc *src = GST_WPE_VIDEO_SRC (base_src);
|
2018-12-05 13:10:11 +00:00
|
|
|
GstStructure *structure;
|
2019-08-07 16:07:21 +00:00
|
|
|
gint width, height;
|
2021-08-29 09:30:53 +00:00
|
|
|
GstCaps *caps;
|
|
|
|
|
|
|
|
/* In situation where software GL support is explicitly requested, select raw
|
|
|
|
* caps, otherwise perform default caps negotiation. Unfortunately at this
|
|
|
|
* point we don't know yet if a GL context will be usable or not, so we can't
|
|
|
|
* check the element GstContext.
|
|
|
|
*/
|
|
|
|
if (!g_strcmp0 (g_getenv ("LIBGL_ALWAYS_SOFTWARE"), "true")) {
|
|
|
|
caps = gst_caps_from_string (WPE_RAW_CAPS);
|
|
|
|
} else {
|
|
|
|
caps = gst_caps_make_writable (combined_caps);
|
|
|
|
}
|
2018-12-05 13:10:11 +00:00
|
|
|
|
|
|
|
structure = gst_caps_get_structure (caps, 0);
|
|
|
|
|
|
|
|
gst_structure_fixate_field_nearest_int (structure, "width", DEFAULT_WIDTH);
|
|
|
|
gst_structure_fixate_field_nearest_int (structure, "height", DEFAULT_HEIGHT);
|
|
|
|
|
|
|
|
if (gst_structure_has_field (structure, "framerate"))
|
|
|
|
gst_structure_fixate_field_nearest_fraction (structure, "framerate",
|
|
|
|
DEFAULT_FPS_N, DEFAULT_FPS_D);
|
|
|
|
else
|
|
|
|
gst_structure_set (structure, "framerate", GST_TYPE_FRACTION, DEFAULT_FPS_N,
|
|
|
|
DEFAULT_FPS_D, NULL);
|
|
|
|
|
|
|
|
caps = GST_BASE_SRC_CLASS (parent_class)->fixate (base_src, caps);
|
|
|
|
GST_INFO_OBJECT (base_src, "Fixated caps to %" GST_PTR_FORMAT, caps);
|
|
|
|
|
|
|
|
if (src->view) {
|
2021-11-16 12:53:35 +00:00
|
|
|
gst_structure_get (structure, "width", G_TYPE_INT, &width, "height",
|
|
|
|
G_TYPE_INT, &height, NULL);
|
2019-08-07 16:07:21 +00:00
|
|
|
src->view->resize (width, height);
|
2018-12-05 13:10:11 +00:00
|
|
|
}
|
2019-08-07 16:07:21 +00:00
|
|
|
return caps;
|
2018-12-05 13:10:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2021-11-16 12:53:35 +00:00
|
|
|
gst_wpe_video_src_configure_web_view (GstWpeVideoSrc * src,
|
|
|
|
WebKitWebView * webview)
|
2018-12-05 13:10:11 +00:00
|
|
|
{
|
|
|
|
GValue args[2] = { {0}, {0} };
|
|
|
|
|
|
|
|
g_value_init (&args[0], GST_TYPE_ELEMENT);
|
|
|
|
g_value_set_object (&args[0], src);
|
|
|
|
g_value_init (&args[1], G_TYPE_OBJECT);
|
|
|
|
g_value_set_object (&args[1], webview);
|
|
|
|
|
2021-03-10 20:27:52 +00:00
|
|
|
g_signal_emitv (args, gst_wpe_video_src_signals[SIGNAL_CONFIGURE_WEB_VIEW], 0,
|
2018-12-05 13:10:11 +00:00
|
|
|
NULL);
|
|
|
|
|
|
|
|
g_value_unset (&args[0]);
|
|
|
|
g_value_unset (&args[1]);
|
|
|
|
}
|
|
|
|
|
2019-09-24 23:57:54 +00:00
|
|
|
static void
|
2021-03-10 20:27:52 +00:00
|
|
|
gst_wpe_video_src_load_bytes (GstWpeVideoSrc * src, GBytes * bytes)
|
2019-09-24 23:57:54 +00:00
|
|
|
{
|
2020-10-07 10:14:55 +00:00
|
|
|
if (src->view && GST_STATE (GST_ELEMENT_CAST (src)) > GST_STATE_NULL) {
|
2019-09-24 23:57:54 +00:00
|
|
|
src->view->loadData (bytes);
|
2020-10-07 10:14:55 +00:00
|
|
|
} else {
|
2021-05-06 17:17:29 +00:00
|
|
|
GST_OBJECT_LOCK (src);
|
2020-10-07 10:14:55 +00:00
|
|
|
if (src->bytes)
|
|
|
|
g_bytes_unref (src->bytes);
|
2019-09-24 23:57:54 +00:00
|
|
|
src->bytes = g_bytes_ref (bytes);
|
2021-05-06 17:17:29 +00:00
|
|
|
GST_OBJECT_UNLOCK (src);
|
2020-10-07 10:14:55 +00:00
|
|
|
}
|
2019-09-24 23:57:54 +00:00
|
|
|
}
|
|
|
|
|
2018-12-05 13:10:11 +00:00
|
|
|
static gboolean
|
2021-03-10 20:27:52 +00:00
|
|
|
gst_wpe_video_src_set_location (GstWpeVideoSrc * src, const gchar * location,
|
2018-12-05 13:10:11 +00:00
|
|
|
GError ** error)
|
|
|
|
{
|
2021-05-06 17:17:29 +00:00
|
|
|
GST_OBJECT_LOCK (src);
|
2018-12-05 13:10:11 +00:00
|
|
|
g_free (src->location);
|
|
|
|
src->location = g_strdup (location);
|
2021-05-06 17:17:29 +00:00
|
|
|
GST_OBJECT_UNLOCK (src);
|
|
|
|
|
2018-12-05 13:10:11 +00:00
|
|
|
if (src->view)
|
2021-05-06 17:17:29 +00:00
|
|
|
src->view->loadUri (location);
|
2018-12-05 13:10:11 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2021-11-16 12:53:35 +00:00
|
|
|
gst_wpe_video_src_set_draw_background (GstWpeVideoSrc * src,
|
|
|
|
gboolean draw_background)
|
2018-12-05 13:10:11 +00:00
|
|
|
{
|
2021-05-06 17:17:29 +00:00
|
|
|
GST_OBJECT_LOCK (src);
|
|
|
|
src->draw_background = draw_background;
|
|
|
|
GST_OBJECT_UNLOCK (src);
|
|
|
|
|
2018-12-05 13:10:11 +00:00
|
|
|
if (src->view)
|
|
|
|
src->view->setDrawBackground (draw_background);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2021-11-16 12:53:35 +00:00
|
|
|
gst_wpe_video_src_set_property (GObject * object, guint prop_id,
|
|
|
|
const GValue * value, GParamSpec * pspec)
|
2018-12-05 13:10:11 +00:00
|
|
|
{
|
2021-03-10 20:27:52 +00:00
|
|
|
GstWpeVideoSrc *src = GST_WPE_VIDEO_SRC (object);
|
2018-12-05 13:10:11 +00:00
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
case PROP_LOCATION:
|
|
|
|
{
|
|
|
|
const gchar *location;
|
|
|
|
|
|
|
|
location = g_value_get_string (value);
|
|
|
|
if (location == NULL) {
|
|
|
|
GST_WARNING_OBJECT (src, "location property cannot be NULL");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-03-10 20:27:52 +00:00
|
|
|
if (!gst_wpe_video_src_set_location (src, location, NULL)) {
|
2018-12-05 13:10:11 +00:00
|
|
|
GST_WARNING_OBJECT (src, "badly formatted location");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case PROP_DRAW_BACKGROUND:
|
2021-03-10 20:27:52 +00:00
|
|
|
gst_wpe_video_src_set_draw_background (src, g_value_get_boolean (value));
|
2018-12-05 13:10:11 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2021-03-10 20:27:52 +00:00
|
|
|
gst_wpe_video_src_get_property (GObject * object, guint prop_id, GValue * value,
|
2018-12-05 13:10:11 +00:00
|
|
|
GParamSpec * pspec)
|
|
|
|
{
|
2021-03-10 20:27:52 +00:00
|
|
|
GstWpeVideoSrc *src = GST_WPE_VIDEO_SRC (object);
|
2018-12-05 13:10:11 +00:00
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
case PROP_LOCATION:
|
2021-05-06 17:17:29 +00:00
|
|
|
GST_OBJECT_LOCK (src);
|
2018-12-05 13:10:11 +00:00
|
|
|
g_value_set_string (value, src->location);
|
2021-05-06 17:17:29 +00:00
|
|
|
GST_OBJECT_UNLOCK (src);
|
2018-12-05 13:10:11 +00:00
|
|
|
break;
|
|
|
|
case PROP_DRAW_BACKGROUND:
|
2021-05-06 17:17:29 +00:00
|
|
|
GST_OBJECT_LOCK (src);
|
2018-12-05 13:10:11 +00:00
|
|
|
g_value_set_boolean (value, src->draw_background);
|
2021-05-06 17:17:29 +00:00
|
|
|
GST_OBJECT_UNLOCK (src);
|
2018-12-05 13:10:11 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2021-12-06 16:47:14 +00:00
|
|
|
gst_wpe_video_src_event (GstBaseSrc * base_src, GstEvent * event)
|
2018-12-05 13:10:11 +00:00
|
|
|
{
|
|
|
|
gboolean ret = FALSE;
|
2021-12-06 16:47:14 +00:00
|
|
|
GstWpeVideoSrc *src = GST_WPE_VIDEO_SRC (base_src);
|
2018-12-05 13:10:11 +00:00
|
|
|
|
2021-12-06 16:47:14 +00:00
|
|
|
if (src->view && GST_EVENT_TYPE (event) == GST_EVENT_NAVIGATION) {
|
2018-12-05 13:10:11 +00:00
|
|
|
const gchar *key;
|
|
|
|
gint button;
|
2020-02-10 18:28:05 +00:00
|
|
|
gdouble x, y, delta_x, delta_y;
|
2018-12-05 13:10:11 +00:00
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (src, "Processing event %" GST_PTR_FORMAT, event);
|
|
|
|
switch (gst_navigation_event_get_type (event)) {
|
|
|
|
case GST_NAVIGATION_EVENT_KEY_PRESS:
|
|
|
|
case GST_NAVIGATION_EVENT_KEY_RELEASE:
|
|
|
|
if (gst_navigation_event_parse_key_event (event, &key)) {
|
|
|
|
/* FIXME: This is wrong... The GstNavigation API should pass
|
2019-09-02 19:08:44 +00:00
|
|
|
hardware-level information, not high-level keysym strings */
|
2018-12-05 13:10:11 +00:00
|
|
|
uint32_t keysym =
|
|
|
|
(uint32_t) xkb_keysym_from_name (key, XKB_KEYSYM_NO_FLAGS);
|
|
|
|
struct wpe_input_keyboard_event wpe_event;
|
|
|
|
wpe_event.key_code = keysym;
|
|
|
|
wpe_event.pressed =
|
|
|
|
gst_navigation_event_get_type (event) ==
|
|
|
|
GST_NAVIGATION_EVENT_KEY_PRESS;
|
2020-08-05 17:41:45 +00:00
|
|
|
src->view->dispatchKeyboardEvent (wpe_event);
|
2018-12-05 13:10:11 +00:00
|
|
|
ret = TRUE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GST_NAVIGATION_EVENT_MOUSE_BUTTON_PRESS:
|
|
|
|
case GST_NAVIGATION_EVENT_MOUSE_BUTTON_RELEASE:
|
|
|
|
if (gst_navigation_event_parse_mouse_button_event (event, &button, &x,
|
|
|
|
&y)) {
|
|
|
|
struct wpe_input_pointer_event wpe_event;
|
2020-02-10 18:28:05 +00:00
|
|
|
wpe_event.time = GST_TIME_AS_MSECONDS (GST_EVENT_TIMESTAMP (event));
|
2018-12-05 13:10:11 +00:00
|
|
|
wpe_event.type = wpe_input_pointer_event_type_button;
|
|
|
|
wpe_event.x = (int) x;
|
|
|
|
wpe_event.y = (int) y;
|
|
|
|
if (button == 1) {
|
|
|
|
wpe_event.modifiers = wpe_input_pointer_modifier_button1;
|
|
|
|
} else if (button == 2) {
|
|
|
|
wpe_event.modifiers = wpe_input_pointer_modifier_button2;
|
|
|
|
} else if (button == 3) {
|
|
|
|
wpe_event.modifiers = wpe_input_pointer_modifier_button3;
|
|
|
|
} else if (button == 4) {
|
|
|
|
wpe_event.modifiers = wpe_input_pointer_modifier_button4;
|
|
|
|
} else if (button == 5) {
|
|
|
|
wpe_event.modifiers = wpe_input_pointer_modifier_button5;
|
|
|
|
}
|
|
|
|
wpe_event.button = button;
|
|
|
|
wpe_event.state =
|
|
|
|
gst_navigation_event_get_type (event) ==
|
|
|
|
GST_NAVIGATION_EVENT_MOUSE_BUTTON_PRESS;
|
2020-08-05 17:41:45 +00:00
|
|
|
src->view->dispatchPointerEvent (wpe_event);
|
2018-12-05 13:10:11 +00:00
|
|
|
ret = TRUE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GST_NAVIGATION_EVENT_MOUSE_MOVE:
|
|
|
|
if (gst_navigation_event_parse_mouse_move_event (event, &x, &y)) {
|
|
|
|
struct wpe_input_pointer_event wpe_event;
|
2020-02-10 18:28:05 +00:00
|
|
|
wpe_event.time = GST_TIME_AS_MSECONDS (GST_EVENT_TIMESTAMP (event));
|
2018-12-05 13:10:11 +00:00
|
|
|
wpe_event.type = wpe_input_pointer_event_type_motion;
|
|
|
|
wpe_event.x = (int) x;
|
|
|
|
wpe_event.y = (int) y;
|
2020-08-05 17:41:45 +00:00
|
|
|
src->view->dispatchPointerEvent (wpe_event);
|
2018-12-05 13:10:11 +00:00
|
|
|
ret = TRUE;
|
|
|
|
}
|
|
|
|
break;
|
2020-02-10 18:28:05 +00:00
|
|
|
case GST_NAVIGATION_EVENT_MOUSE_SCROLL:
|
|
|
|
if (gst_navigation_event_parse_mouse_scroll_event (event, &x, &y,
|
|
|
|
&delta_x, &delta_y)) {
|
|
|
|
struct wpe_input_axis_event wpe_event;
|
|
|
|
if (delta_x) {
|
|
|
|
wpe_event.axis = 1;
|
|
|
|
wpe_event.value = delta_x;
|
|
|
|
} else {
|
|
|
|
wpe_event.axis = 0;
|
|
|
|
wpe_event.value = delta_y;
|
|
|
|
}
|
|
|
|
wpe_event.time = GST_TIME_AS_MSECONDS (GST_EVENT_TIMESTAMP (event));
|
|
|
|
wpe_event.type = wpe_input_axis_event_type_motion;
|
|
|
|
wpe_event.x = (int) x;
|
|
|
|
wpe_event.y = (int) y;
|
2020-08-05 17:41:45 +00:00
|
|
|
src->view->dispatchAxisEvent (wpe_event);
|
2020-02-10 18:28:05 +00:00
|
|
|
ret = TRUE;
|
|
|
|
}
|
|
|
|
break;
|
2018-12-05 13:10:11 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* FIXME: No touch events handling support in GstNavigation */
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!ret) {
|
2021-12-06 16:47:14 +00:00
|
|
|
ret =
|
|
|
|
GST_CALL_PARENT_WITH_DEFAULT (GST_BASE_SRC_CLASS, event, (base_src,
|
|
|
|
event), FALSE);
|
2018-12-05 13:10:11 +00:00
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2021-03-10 20:27:52 +00:00
|
|
|
gst_wpe_video_src_init (GstWpeVideoSrc * src)
|
2018-12-05 13:10:11 +00:00
|
|
|
{
|
2021-08-29 10:04:17 +00:00
|
|
|
src->draw_background = DEFAULT_DRAW_BACKGROUND;
|
2018-12-05 13:10:11 +00:00
|
|
|
|
2019-08-07 16:07:21 +00:00
|
|
|
gst_base_src_set_live (GST_BASE_SRC_CAST (src), TRUE);
|
2021-01-04 08:34:40 +00:00
|
|
|
|
|
|
|
g_mutex_init (&src->lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2021-03-10 20:27:52 +00:00
|
|
|
gst_wpe_video_src_finalize (GObject * object)
|
2021-01-04 08:34:40 +00:00
|
|
|
{
|
2021-03-10 20:27:52 +00:00
|
|
|
GstWpeVideoSrc *src = GST_WPE_VIDEO_SRC (object);
|
2021-01-04 08:34:40 +00:00
|
|
|
|
2021-05-06 16:37:45 +00:00
|
|
|
g_free (src->location);
|
|
|
|
g_clear_pointer (&src->bytes, g_bytes_unref);
|
2021-01-04 08:34:40 +00:00
|
|
|
g_mutex_clear (&src->lock);
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
2018-12-05 13:10:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2021-03-10 20:27:52 +00:00
|
|
|
gst_wpe_video_src_class_init (GstWpeVideoSrcClass * klass)
|
2018-12-05 13:10:11 +00:00
|
|
|
{
|
|
|
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
|
|
|
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
|
2019-08-07 16:07:21 +00:00
|
|
|
GstGLBaseSrcClass *gl_base_src_class = GST_GL_BASE_SRC_CLASS (klass);
|
2018-12-05 13:10:11 +00:00
|
|
|
GstBaseSrcClass *base_src_class = GST_BASE_SRC_CLASS (klass);
|
2020-07-01 08:00:41 +00:00
|
|
|
GstPadTemplate *tmpl;
|
|
|
|
GstCaps *doc_caps;
|
2018-12-05 13:10:11 +00:00
|
|
|
|
2021-03-10 20:27:52 +00:00
|
|
|
gobject_class->set_property = gst_wpe_video_src_set_property;
|
|
|
|
gobject_class->get_property = gst_wpe_video_src_get_property;
|
|
|
|
gobject_class->finalize = gst_wpe_video_src_finalize;
|
2018-12-05 13:10:11 +00:00
|
|
|
|
|
|
|
g_object_class_install_property (gobject_class, PROP_LOCATION,
|
|
|
|
g_param_spec_string ("location", "location",
|
|
|
|
"The URL to display",
|
|
|
|
"", (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
|
|
|
g_object_class_install_property (gobject_class, PROP_DRAW_BACKGROUND,
|
|
|
|
g_param_spec_boolean ("draw-background", "Draws the background",
|
2021-08-29 10:04:17 +00:00
|
|
|
"Whether to draw the WebView background", DEFAULT_DRAW_BACKGROUND,
|
2018-12-05 13:10:11 +00:00
|
|
|
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
|
|
|
|
|
|
|
gst_element_class_set_static_metadata (gstelement_class,
|
|
|
|
"WPE source", "Source/Video",
|
|
|
|
"Creates a video stream from a WPE browser",
|
|
|
|
"Philippe Normand <philn@igalia.com>, Žan Doberšek <zdobersek@igalia.com>");
|
|
|
|
|
2020-07-01 08:00:41 +00:00
|
|
|
tmpl = gst_static_pad_template_get (&src_factory);
|
|
|
|
gst_element_class_add_pad_template (gstelement_class, tmpl);
|
2018-12-05 13:10:11 +00:00
|
|
|
|
2021-03-10 20:27:52 +00:00
|
|
|
base_src_class->fixate = GST_DEBUG_FUNCPTR (gst_wpe_video_src_fixate);
|
|
|
|
base_src_class->create = GST_DEBUG_FUNCPTR (gst_wpe_video_src_create);
|
2021-11-16 12:53:35 +00:00
|
|
|
base_src_class->decide_allocation =
|
|
|
|
GST_DEBUG_FUNCPTR (gst_wpe_video_src_decide_allocation);
|
2021-03-10 20:27:52 +00:00
|
|
|
base_src_class->stop = GST_DEBUG_FUNCPTR (gst_wpe_video_src_stop);
|
2021-12-06 16:47:14 +00:00
|
|
|
base_src_class->event = GST_DEBUG_FUNCPTR (gst_wpe_video_src_event);
|
2019-08-07 16:07:21 +00:00
|
|
|
|
|
|
|
gl_base_src_class->supported_gl_api =
|
|
|
|
static_cast < GstGLAPI >
|
|
|
|
(GST_GL_API_OPENGL | GST_GL_API_OPENGL3 | GST_GL_API_GLES2);
|
2021-03-10 20:27:52 +00:00
|
|
|
gl_base_src_class->gl_start = GST_DEBUG_FUNCPTR (gst_wpe_video_src_gl_start);
|
|
|
|
gl_base_src_class->gl_stop = GST_DEBUG_FUNCPTR (gst_wpe_video_src_gl_stop);
|
2019-08-07 16:07:21 +00:00
|
|
|
gl_base_src_class->fill_gl_memory =
|
2021-03-10 20:27:52 +00:00
|
|
|
GST_DEBUG_FUNCPTR (gst_wpe_video_src_fill_memory);
|
2018-12-05 13:10:11 +00:00
|
|
|
|
2021-03-10 20:27:52 +00:00
|
|
|
doc_caps = gst_caps_from_string (WPE_VIDEO_SRC_DOC_CAPS);
|
2020-07-01 08:00:41 +00:00
|
|
|
gst_pad_template_set_documentation_caps (tmpl, doc_caps);
|
|
|
|
gst_clear_caps (&doc_caps);
|
|
|
|
|
2018-12-05 13:10:11 +00:00
|
|
|
/**
|
2021-03-10 20:27:52 +00:00
|
|
|
* GstWpeVideoSrc::configure-web-view:
|
2018-12-05 13:10:11 +00:00
|
|
|
* @src: the object which received the signal
|
|
|
|
* @webview: the webView
|
|
|
|
*
|
|
|
|
* Allow application to configure the webView settings.
|
|
|
|
*/
|
2021-03-10 20:27:52 +00:00
|
|
|
gst_wpe_video_src_signals[SIGNAL_CONFIGURE_WEB_VIEW] =
|
2018-12-05 13:10:11 +00:00
|
|
|
g_signal_new ("configure-web-view", G_TYPE_FROM_CLASS (klass),
|
2019-08-27 05:59:27 +00:00
|
|
|
G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL, G_TYPE_NONE, 1, G_TYPE_OBJECT);
|
2019-09-24 23:57:54 +00:00
|
|
|
|
|
|
|
/**
|
2021-03-10 20:27:52 +00:00
|
|
|
* GstWpeVideoSrc::load-bytes:
|
2019-09-24 23:57:54 +00:00
|
|
|
* @src: the object which received the signal
|
|
|
|
* @bytes: the GBytes data to load
|
|
|
|
*
|
|
|
|
* Load the specified bytes into the internal webView.
|
|
|
|
*/
|
2021-03-10 20:27:52 +00:00
|
|
|
gst_wpe_video_src_signals[SIGNAL_LOAD_BYTES] =
|
2019-09-24 23:57:54 +00:00
|
|
|
g_signal_new_class_handler ("load-bytes", G_TYPE_FROM_CLASS (klass),
|
|
|
|
static_cast < GSignalFlags > (G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
|
2021-03-10 20:27:52 +00:00
|
|
|
G_CALLBACK (gst_wpe_video_src_load_bytes), NULL, NULL, NULL,
|
2019-08-27 05:59:27 +00:00
|
|
|
G_TYPE_NONE, 1, G_TYPE_BYTES);
|
2021-05-22 17:05:18 +00:00
|
|
|
}
|