mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 04:01:08 +00:00
srtsrc: Don't calculate a delay if the srctime is 0
A zero srctime is a missing srctime. Apparently this can happen when ["the connection is not between SRT peers or if Timestamp-Based Packet Delivery mode (TSBPDMODE) is not enabled"][1] so it may not apply to us, but it's best to be defensive. [1]: https://github.com/Haivision/srt/blob/v1.4.2/docs/API.md#sending-and-receiving Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1674>
This commit is contained in:
parent
6b2fcb52e5
commit
ec11ad9d55
1 changed files with 9 additions and 2 deletions
|
@ -125,6 +125,7 @@ gst_srt_src_fill (GstPushSrc * src, GstBuffer * outbuf)
|
||||||
GstClockTime base_time;
|
GstClockTime base_time;
|
||||||
GstClockTime capture_time;
|
GstClockTime capture_time;
|
||||||
GstClockTime delay;
|
GstClockTime delay;
|
||||||
|
int64_t srt_time;
|
||||||
SRT_MSGCTRL mctrl;
|
SRT_MSGCTRL mctrl;
|
||||||
|
|
||||||
if (g_cancellable_is_cancelled (self->cancellable)) {
|
if (g_cancellable_is_cancelled (self->cancellable)) {
|
||||||
|
@ -154,10 +155,10 @@ gst_srt_src_fill (GstPushSrc * src, GstBuffer * outbuf)
|
||||||
capture_time = gst_clock_get_time (clock);
|
capture_time = gst_clock_get_time (clock);
|
||||||
#if SRT_VERSION_VALUE >= 0x10402
|
#if SRT_VERSION_VALUE >= 0x10402
|
||||||
/* Use SRT clock value if available (SRT > 1.4.2) */
|
/* Use SRT clock value if available (SRT > 1.4.2) */
|
||||||
delay = (srt_time_now () - mctrl.srctime) * GST_USECOND;
|
srt_time = srt_time_now ();
|
||||||
#else
|
#else
|
||||||
/* Else use the unix epoch monotonic clock */
|
/* Else use the unix epoch monotonic clock */
|
||||||
delay = (g_get_real_time () - mctrl.srctime) * GST_USECOND;
|
srt_time = g_get_real_time ();
|
||||||
#endif
|
#endif
|
||||||
gst_object_unref (clock);
|
gst_object_unref (clock);
|
||||||
|
|
||||||
|
@ -191,6 +192,12 @@ gst_srt_src_fill (GstPushSrc * src, GstBuffer * outbuf)
|
||||||
/* pktseq is a 31bit field */
|
/* pktseq is a 31bit field */
|
||||||
self->next_pktseq = (mctrl.pktseq + 1) % G_MAXINT32;
|
self->next_pktseq = (mctrl.pktseq + 1) % G_MAXINT32;
|
||||||
|
|
||||||
|
/* 0 means we do not have a srctime */
|
||||||
|
if (mctrl.srctime != 0)
|
||||||
|
delay = (srt_time - mctrl.srctime) * GST_USECOND;
|
||||||
|
else
|
||||||
|
delay = 0;
|
||||||
|
|
||||||
/* Subtract the base_time (since the pipeline started) ... */
|
/* Subtract the base_time (since the pipeline started) ... */
|
||||||
if (capture_time > base_time)
|
if (capture_time > base_time)
|
||||||
capture_time -= base_time;
|
capture_time -= base_time;
|
||||||
|
|
Loading…
Reference in a new issue