summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlok Priyadarshi <alokpr@gmail.com>2021-03-24 21:46:36 -0700
committerJames Almer <jamrial@gmail.com>2021-03-30 11:59:15 -0300
commit62f486e7930c5f1c8e4bfe342eb6a2bbd8cfd177 (patch)
treeed2d2fde4901095fd6baf58e87abfaade47f90eb
parente7cbbd90267de2a0ad1b5fa8ccb29ab7bf8a26b8 (diff)
avformat/rtpdec: Fix prft wallclock time.
Timestamp difference is available in media timebase (1/90K) where as rtcp time is in the default microseconds timebase. This patch fixes the calculated prft wallclock time by rescaling the timestamp delta to the microseconds timebase. Signed-off-by: James Almer <jamrial@gmail.com>
-rw-r--r--libavformat/rtpdec.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/libavformat/rtpdec.c b/libavformat/rtpdec.c
index 1edb64b9bf..6b0da9e636 100644
--- a/libavformat/rtpdec.c
+++ b/libavformat/rtpdec.c
@@ -623,14 +623,19 @@ void ff_rtp_parse_set_crypto(RTPDemuxContext *s, const char *suite,
}
static int rtp_set_prft(RTPDemuxContext *s, AVPacket *pkt, uint32_t timestamp) {
+ int64_t rtcp_time, delta_timestamp, delta_time;
+
AVProducerReferenceTime *prft =
(AVProducerReferenceTime *) av_packet_new_side_data(
pkt, AV_PKT_DATA_PRFT, sizeof(AVProducerReferenceTime));
if (!prft)
return AVERROR(ENOMEM);
- prft->wallclock = ff_parse_ntp_time(s->last_rtcp_ntp_time) - NTP_OFFSET_US +
- timestamp - s->last_rtcp_timestamp;
+ rtcp_time = ff_parse_ntp_time(s->last_rtcp_ntp_time) - NTP_OFFSET_US;
+ delta_timestamp = (int64_t)timestamp - (int64_t)s->last_rtcp_timestamp;
+ delta_time = av_rescale_q(delta_timestamp, s->st->time_base, AV_TIME_BASE_Q);
+
+ prft->wallclock = rtcp_time + delta_time;
prft->flags = 24;
return 0;
}