mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-29 05:01:23 +00:00
rtpbin: Don't re-use a variable for a completely different purpose temporarily
During RTP-Info synchronization, clock_base was temporarily switched from the actual clock-base to the base RTP time and then back some lines later. Instead directly work with the base RTP time. The comment about using a signed variable for convenience doesn't make any sense because all calculations done with the value are unsigned. Similarly, rtp_clock_base was overridden with the rtp_delta when calculating it, which was fine because it is not used anymore afterwards. Instead, introduce a new variable `rtp_delta` to make this calculation clearer. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6575>
This commit is contained in:
parent
72c6cac8db
commit
17db91c7c1
1 changed files with 11 additions and 12 deletions
|
@ -1567,7 +1567,7 @@ gst_rtp_bin_associate (GstRtpBin * bin, GstRtpBinStream * stream, guint8 len,
|
||||||
stream_set_ts_offset (bin, stream, stream->rt_delta, bin->max_ts_offset,
|
stream_set_ts_offset (bin, stream, stream->rt_delta, bin->max_ts_offset,
|
||||||
bin->min_ts_offset, FALSE);
|
bin->min_ts_offset, FALSE);
|
||||||
} else {
|
} else {
|
||||||
gint64 min, rtp_min, clock_base = stream->clock_base;
|
gint64 min, rtp_min, clock_base;
|
||||||
gboolean all_sync, use_rtp;
|
gboolean all_sync, use_rtp;
|
||||||
gboolean rtcp_sync = g_atomic_int_get (&bin->rtcp_sync);
|
gboolean rtcp_sync = g_atomic_int_get (&bin->rtcp_sync);
|
||||||
|
|
||||||
|
@ -1594,25 +1594,24 @@ gst_rtp_bin_associate (GstRtpBin * bin, GstRtpBinStream * stream, guint8 len,
|
||||||
use_rtp = FALSE;
|
use_rtp = FALSE;
|
||||||
if (rtcp_sync == GST_RTP_BIN_RTCP_SYNC_RTP) {
|
if (rtcp_sync == GST_RTP_BIN_RTCP_SYNC_RTP) {
|
||||||
guint64 ext_base = -1;
|
guint64 ext_base = -1;
|
||||||
|
gint64 rtp_delta = 0;
|
||||||
|
|
||||||
use_rtp = TRUE;
|
use_rtp = TRUE;
|
||||||
/* signed version for convenience */
|
|
||||||
clock_base = base_rtptime;
|
|
||||||
/* convert to extended RTP time */
|
/* convert to extended RTP time */
|
||||||
rtp_clock_base = gst_rtp_buffer_ext_timestamp (&ext_base, rtp_clock_base);
|
rtp_clock_base = gst_rtp_buffer_ext_timestamp (&ext_base, rtp_clock_base);
|
||||||
/* sanity check; base rtp and provided clock_base should be close */
|
/* sanity check; base rtp and provided clock_base should be close */
|
||||||
if (rtp_clock_base >= clock_base) {
|
if (rtp_clock_base >= base_rtptime) {
|
||||||
if (rtp_clock_base - clock_base < 10 * clock_rate) {
|
if (rtp_clock_base - base_rtptime < 10 * clock_rate) {
|
||||||
rtp_clock_base = base_time +
|
rtp_delta = base_time +
|
||||||
gst_util_uint64_scale_int (rtp_clock_base - clock_base,
|
gst_util_uint64_scale_int (rtp_clock_base - base_rtptime,
|
||||||
GST_SECOND, clock_rate);
|
GST_SECOND, clock_rate);
|
||||||
} else {
|
} else {
|
||||||
use_rtp = FALSE;
|
use_rtp = FALSE;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (clock_base - rtp_clock_base < 10 * clock_rate) {
|
if (base_rtptime - rtp_clock_base < 10 * clock_rate) {
|
||||||
rtp_clock_base = base_time -
|
rtp_delta = base_time -
|
||||||
gst_util_uint64_scale_int (clock_base - rtp_clock_base,
|
gst_util_uint64_scale_int (base_rtptime - rtp_clock_base,
|
||||||
GST_SECOND, clock_rate);
|
GST_SECOND, clock_rate);
|
||||||
} else {
|
} else {
|
||||||
use_rtp = FALSE;
|
use_rtp = FALSE;
|
||||||
|
@ -1624,11 +1623,11 @@ gst_rtp_bin_associate (GstRtpBin * bin, GstRtpBinStream * stream, guint8 len,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/* store to track changes */
|
/* store to track changes */
|
||||||
clock_base = rtp_clock_base;
|
clock_base = rtp_delta;
|
||||||
/* generate a fake as before,
|
/* generate a fake as before,
|
||||||
* now equating rtptime obtained from RTP-Info,
|
* now equating rtptime obtained from RTP-Info,
|
||||||
* where the large time represent the otherwise irrelevant npt/ntp time */
|
* where the large time represent the otherwise irrelevant npt/ntp time */
|
||||||
stream->rtp_delta = (GST_SECOND << 28) - rtp_clock_base;
|
stream->rtp_delta = (GST_SECOND << 28) - rtp_delta;
|
||||||
} else {
|
} else {
|
||||||
clock_base = rtp_clock_base;
|
clock_base = rtp_clock_base;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue