rtpsource: Don't store invalid running times and calculate with it

If we end up with GST_CLOCK_TIME_NONE as running time for an RTP packet
then this can't be used for bitrate estimation, and also not for
constructing the next RTCP SR. Both would end up with completely wrong
values, and an RTCP SR with wrong values can easily break
synchronization in receivers.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5329>
This commit is contained in:
Sebastian Dröge 2023-09-14 01:35:10 +03:00 committed by GStreamer Marge Bot
parent 57bfbf51b2
commit 2a2ef23829

View file

@ -1415,7 +1415,8 @@ rtp_source_send_rtp (RTPSource * src, RTPPacketInfo * pinfo)
running_time = pinfo->running_time; running_time = pinfo->running_time;
do_bitrate_estimation (src, running_time, &src->bytes_sent); if (GST_CLOCK_TIME_IS_VALID (running_time))
do_bitrate_estimation (src, running_time, &src->bytes_sent);
rtptime = pinfo->rtptime; rtptime = pinfo->rtptime;
@ -1427,7 +1428,9 @@ rtp_source_send_rtp (RTPSource * src, RTPPacketInfo * pinfo)
if (ext_rtptime > src->last_rtptime) { if (ext_rtptime > src->last_rtptime) {
rtp_diff = ext_rtptime - src->last_rtptime; rtp_diff = ext_rtptime - src->last_rtptime;
rt_diff = running_time - src->last_rtime; rt_diff =
GST_CLOCK_TIME_IS_VALID (running_time) ? running_time -
src->last_rtime : GST_CLOCK_TIME_NONE;
/* calc the diff so we can detect drift at the sender. This can also be used /* calc the diff so we can detect drift at the sender. This can also be used
* to guestimate the clock rate if the NTP time is locked to the RTP * to guestimate the clock rate if the NTP time is locked to the RTP
@ -1436,10 +1439,12 @@ rtp_source_send_rtp (RTPSource * src, RTPPacketInfo * pinfo)
GST_TIME_FORMAT, src->ssrc, rtp_diff, GST_TIME_ARGS (rt_diff)); GST_TIME_FORMAT, src->ssrc, rtp_diff, GST_TIME_ARGS (rt_diff));
} }
/* we keep track of the last received RTP timestamp and the corresponding if (GST_CLOCK_TIME_IS_VALID (running_time)) {
* buffer running_time so that we can use this info when constructing SR reports */ /* we keep track of the last received RTP timestamp and the corresponding
src->last_rtime = running_time; * buffer running_time so that we can use this info when constructing SR reports */
src->last_rtptime = ext_rtptime; src->last_rtime = running_time;
src->last_rtptime = ext_rtptime;
}
/* push packet */ /* push packet */
if (!src->callbacks.push_rtp) if (!src->callbacks.push_rtp)