summaryrefslogtreecommitdiff
path: root/ext/wpe
diff options
context:
space:
mode:
authorMathieu Duponchelle <mathieu@centricular.com>2020-07-29 00:04:40 +0200
committerGStreamer Merge Bot <gitlab-merge-bot@gstreamer-foundation.org>2020-07-30 08:09:47 +0000
commit480ede1aa772500867bf8c51a8e2ad7fd5fc0a08 (patch)
treeca2ca34b093fc4b1b9067da07053d2a323327119 /ext/wpe
parentad57b8040f3161728c9ad41e39597a844d997510 (diff)
downloadgstreamer-plugins-bad-480ede1aa772500867bf8c51a8e2ad7fd5fc0a08.tar.gz
wpesrc: timestamp buffers when working with SHM buffers
GLBaseSrc::fill() will take care of that when dealing with images, but as we don't chain up when dealing with SHM buffers this needs to be done in order for GLBaseSrc::get_times() to work appropriately. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1476>
Diffstat (limited to 'ext/wpe')
-rw-r--r--ext/wpe/gstwpesrc.cpp30
1 files changed, 29 insertions, 1 deletions
diff --git a/ext/wpe/gstwpesrc.cpp b/ext/wpe/gstwpesrc.cpp
index 201a2f8de..0670983d3 100644
--- a/ext/wpe/gstwpesrc.cpp
+++ b/ext/wpe/gstwpesrc.cpp
@@ -116,6 +116,8 @@ struct _GstWpeSrc
GBytes *bytes;
gboolean gl_enabled;
+
+ gint64 n_frames; /* total frames sent */
};
static void gst_wpe_src_uri_handler_init (gpointer iface, gpointer data);
@@ -153,9 +155,12 @@ static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
static GstFlowReturn
gst_wpe_src_create (GstBaseSrc * bsrc, guint64 offset, guint length, GstBuffer ** buf)
{
+ GstGLBaseSrc *gl_src = GST_GL_BASE_SRC (bsrc);
GstWpeSrc *src = GST_WPE_SRC (bsrc);
GstFlowReturn ret = GST_FLOW_ERROR;
GstBuffer *locked_buffer;
+ GstClockTime next_time;
+ gint64 ts_offset = 0;
GST_OBJECT_LOCK (src);
if (src->gl_enabled) {
@@ -166,9 +171,30 @@ gst_wpe_src_create (GstBaseSrc * bsrc, guint64 offset, guint length, GstBuffer *
locked_buffer = src->view->buffer ();
if (locked_buffer != NULL) {
- *buf = gst_buffer_ref (locked_buffer);
+ *buf = gst_buffer_copy_deep (locked_buffer);
ret = GST_FLOW_OK;
}
+
+ g_object_get(gl_src, "timestamp-offset", &ts_offset, NULL);
+
+ /* 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;
+
GST_OBJECT_UNLOCK (src);
return ret;
}
@@ -241,6 +267,8 @@ gst_wpe_src_gl_start (GstGLBaseSrc * base_src)
src->bytes = NULL;
}
+ src->n_frames = 0;
+
GST_OBJECT_UNLOCK (src);
if (!result) {
GST_ELEMENT_ERROR (src, RESOURCE, FAILED,