133 lines
4.7 KiB
Diff
133 lines
4.7 KiB
Diff
From 18bd53043435f3d32d6eee871dcd23017239ef70 Mon Sep 17 00:00:00 2001
|
|
From: Wim Taymans <wtaymans@redhat.com>
|
|
Date: Fri, 19 Jan 2024 12:53:39 +0100
|
|
Subject: [PATCH] Revert "gst/pipewiresrc: Let GstBaseSrc handle pseudo-live
|
|
calculations"
|
|
|
|
This reverts commit 004206db370f4244411ffc16135d51d021809df8.
|
|
---
|
|
src/gst/gstpipewiresrc.c | 66 +++++++++++++++-------------------------
|
|
1 file changed, 24 insertions(+), 42 deletions(-)
|
|
|
|
diff --git a/src/gst/gstpipewiresrc.c b/src/gst/gstpipewiresrc.c
|
|
index d95e99620..753bf760a 100644
|
|
--- a/src/gst/gstpipewiresrc.c
|
|
+++ b/src/gst/gstpipewiresrc.c
|
|
@@ -91,8 +91,6 @@ static gboolean gst_pipewire_src_start (GstBaseSrc * basesrc);
|
|
static gboolean gst_pipewire_src_stop (GstBaseSrc * basesrc);
|
|
static gboolean gst_pipewire_src_event (GstBaseSrc * src, GstEvent * event);
|
|
static gboolean gst_pipewire_src_query (GstBaseSrc * src, GstQuery * query);
|
|
-static void gst_pipewire_src_get_times (GstBaseSrc * basesrc, GstBuffer * buffer,
|
|
- GstClockTime * start, GstClockTime * end);
|
|
|
|
static void
|
|
gst_pipewire_src_set_property (GObject * object, guint prop_id,
|
|
@@ -415,7 +413,6 @@ gst_pipewire_src_class_init (GstPipeWireSrcClass * klass)
|
|
gstbasesrc_class->stop = gst_pipewire_src_stop;
|
|
gstbasesrc_class->event = gst_pipewire_src_event;
|
|
gstbasesrc_class->query = gst_pipewire_src_query;
|
|
- gstbasesrc_class->get_times = gst_pipewire_src_get_times;
|
|
gstpushsrc_class->create = gst_pipewire_src_create;
|
|
|
|
GST_DEBUG_CATEGORY_INIT (pipewire_src_debug, "pipewiresrc", 0,
|
|
@@ -581,7 +578,7 @@ static GstBuffer *dequeue_buffer(GstPipeWireSrc *pwsrc)
|
|
GST_LOG_OBJECT (pwsrc, "pts %" G_GUINT64_FORMAT ", dts_offset %" G_GUINT64_FORMAT, h->pts, h->dts_offset);
|
|
|
|
if (GST_CLOCK_TIME_IS_VALID (h->pts)) {
|
|
- GST_BUFFER_PTS (buf) = h->pts;
|
|
+ GST_BUFFER_PTS (buf) = h->pts + GST_PIPEWIRE_CLOCK (pwsrc->clock)->time_offset;
|
|
if (GST_BUFFER_PTS (buf) + h->dts_offset > 0)
|
|
GST_BUFFER_DTS (buf) = GST_BUFFER_PTS (buf) + h->dts_offset;
|
|
}
|
|
@@ -1136,39 +1133,11 @@ gst_pipewire_src_query (GstBaseSrc * src, GstQuery * query)
|
|
return res;
|
|
}
|
|
|
|
-static void
|
|
-gst_pipewire_src_get_times (GstBaseSrc * basesrc, GstBuffer * buffer,
|
|
- GstClockTime * start, GstClockTime * end)
|
|
-{
|
|
- GstPipeWireSrc *pwsrc = GST_PIPEWIRE_SRC (basesrc);
|
|
-
|
|
- /* for live sources, sync on the timestamp of the buffer */
|
|
- if (gst_base_src_is_live (basesrc)) {
|
|
- GstClockTime timestamp = GST_BUFFER_PTS (buffer);
|
|
-
|
|
- if (GST_CLOCK_TIME_IS_VALID (timestamp)) {
|
|
- /* get duration to calculate end time */
|
|
- GstClockTime duration = GST_BUFFER_DURATION (buffer);
|
|
-
|
|
- if (GST_CLOCK_TIME_IS_VALID (duration)) {
|
|
- *end = timestamp + duration;
|
|
- }
|
|
- *start = timestamp;
|
|
- }
|
|
- } else {
|
|
- *start = GST_CLOCK_TIME_NONE;
|
|
- *end = GST_CLOCK_TIME_NONE;
|
|
- }
|
|
-
|
|
- GST_LOG_OBJECT (pwsrc, "start %" GST_TIME_FORMAT " (%" G_GUINT64_FORMAT
|
|
- "), end %" GST_TIME_FORMAT " (%" G_GUINT64_FORMAT ")",
|
|
- GST_TIME_ARGS (*start), *start, GST_TIME_ARGS (*end), *end);
|
|
-}
|
|
-
|
|
static GstFlowReturn
|
|
gst_pipewire_src_create (GstPushSrc * psrc, GstBuffer ** buffer)
|
|
{
|
|
GstPipeWireSrc *pwsrc;
|
|
+ GstClockTime pts, dts, base_time;
|
|
const char *error = NULL;
|
|
GstBuffer *buf;
|
|
gboolean update_time = FALSE, timeout = FALSE;
|
|
@@ -1247,24 +1216,37 @@ gst_pipewire_src_create (GstPushSrc * psrc, GstBuffer ** buffer)
|
|
|
|
*buffer = buf;
|
|
|
|
- if (update_time) {
|
|
- GstClock *clock;
|
|
- GstClockTime pts, dts;
|
|
+ if (pwsrc->is_live)
|
|
+ base_time = GST_ELEMENT_CAST (psrc)->base_time;
|
|
+ else
|
|
+ base_time = 0;
|
|
|
|
- clock = gst_element_get_clock (GST_ELEMENT_CAST (pwsrc));
|
|
+ if (update_time) {
|
|
+ GstClock *clock = gst_element_get_clock (GST_ELEMENT_CAST (pwsrc));
|
|
if (clock != NULL) {
|
|
pts = dts = gst_clock_get_time (clock);
|
|
gst_object_unref (clock);
|
|
} else {
|
|
pts = dts = GST_CLOCK_TIME_NONE;
|
|
}
|
|
+ } else {
|
|
+ pts = GST_BUFFER_PTS (*buffer);
|
|
+ dts = GST_BUFFER_DTS (*buffer);
|
|
+ }
|
|
|
|
- GST_BUFFER_PTS (*buffer) = pts;
|
|
- GST_BUFFER_DTS (*buffer) = dts;
|
|
+ if (GST_CLOCK_TIME_IS_VALID (pts))
|
|
+ pts = (pts >= base_time ? pts - base_time : 0);
|
|
+ if (GST_CLOCK_TIME_IS_VALID (dts))
|
|
+ dts = (dts >= base_time ? dts - base_time : 0);
|
|
|
|
- GST_LOG_OBJECT (pwsrc, "Sending keepalive buffer pts/dts: %" GST_TIME_FORMAT
|
|
- " (%" G_GUINT64_FORMAT ")", GST_TIME_ARGS (pts), pts);
|
|
- }
|
|
+ GST_LOG_OBJECT (pwsrc,
|
|
+ "pts %" G_GUINT64_FORMAT ", dts %" G_GUINT64_FORMAT
|
|
+ ", base-time %" GST_TIME_FORMAT " -> %" GST_TIME_FORMAT ", %" GST_TIME_FORMAT,
|
|
+ GST_BUFFER_PTS (*buffer), GST_BUFFER_DTS (*buffer), GST_TIME_ARGS (base_time),
|
|
+ GST_TIME_ARGS (pts), GST_TIME_ARGS (dts));
|
|
+
|
|
+ GST_BUFFER_PTS (*buffer) = pts;
|
|
+ GST_BUFFER_DTS (*buffer) = dts;
|
|
|
|
return GST_FLOW_OK;
|
|
|
|
--
|
|
2.43.0
|
|
|