summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Alexander Steffens (heftig) <jan.steffens@ltnglobal.com>2020-10-12 14:15:49 +0200
committerTim-Philipp Müller <tim@centricular.com>2020-10-12 23:50:12 +0100
commit48dc3070778b5a68d5e2692872a65b25cc28b473 (patch)
tree1b5088e33021e3d372889c5c86c331e40ba7bbc8
parent10bb429a087a1c4cbc9f9375cd4f92d566ff98b7 (diff)
downloadgstreamer-plugins-bad-48dc3070778b5a68d5e2692872a65b25cc28b473.tar.gz
srtsrc: Prevent `delay` from being negative
`delay` should be a GstClockTimeDiff since SRT time is int64_t. All values are in local time so we should never see a srctime that's in the future. If we do, clamp the delay to 0 and warn about it. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1690>
-rw-r--r--ext/srt/gstsrtsrc.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/ext/srt/gstsrtsrc.c b/ext/srt/gstsrtsrc.c
index c5e0a93d6..a6f2740eb 100644
--- a/ext/srt/gstsrtsrc.c
+++ b/ext/srt/gstsrtsrc.c
@@ -124,7 +124,7 @@ gst_srt_src_fill (GstPushSrc * src, GstBuffer * outbuf)
GstClock *clock;
GstClockTime base_time;
GstClockTime capture_time;
- GstClockTime delay;
+ GstClockTimeDiff delay;
int64_t srt_time;
SRT_MSGCTRL mctrl;
@@ -166,7 +166,7 @@ gst_srt_src_fill (GstPushSrc * src, GstBuffer * outbuf)
GST_LOG_OBJECT (src,
"recv_len:%" G_GSIZE_FORMAT " pktseq:%d msgno:%d srctime:%"
- G_GUINT64_FORMAT, recv_len, mctrl.pktseq, mctrl.msgno, mctrl.srctime);
+ G_GINT64_FORMAT, recv_len, mctrl.pktseq, mctrl.msgno, mctrl.srctime);
if (g_cancellable_is_cancelled (self->cancellable)) {
ret = GST_FLOW_FLUSHING;
@@ -198,6 +198,15 @@ gst_srt_src_fill (GstPushSrc * src, GstBuffer * outbuf)
else
delay = 0;
+ GST_LOG_OBJECT (src, "delay: %" GST_STIME_FORMAT, GST_STIME_ARGS (delay));
+
+ if (delay < 0) {
+ GST_WARNING_OBJECT (src,
+ "Calculated SRT delay %" GST_STIME_FORMAT " is negative, clamping to 0",
+ GST_STIME_ARGS (delay));
+ delay = 0;
+ }
+
/* Subtract the base_time (since the pipeline started) ... */
if (capture_time > base_time)
capture_time -= base_time;
@@ -210,8 +219,6 @@ gst_srt_src_fill (GstPushSrc * src, GstBuffer * outbuf)
capture_time = 0;
GST_BUFFER_TIMESTAMP (outbuf) = capture_time;
- GST_DEBUG_OBJECT (src, "delay:%" GST_TIME_FORMAT, GST_TIME_ARGS (delay));
-
gst_buffer_resize (outbuf, 0, recv_len);
GST_LOG_OBJECT (src,