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>
This commit is contained in:
Alok Priyadarshi 2021-03-24 21:46:36 -07:00 committed by James Almer
parent e7cbbd9026
commit 62f486e793
1 changed files with 7 additions and 2 deletions

View File

@ -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) { static int rtp_set_prft(RTPDemuxContext *s, AVPacket *pkt, uint32_t timestamp) {
int64_t rtcp_time, delta_timestamp, delta_time;
AVProducerReferenceTime *prft = AVProducerReferenceTime *prft =
(AVProducerReferenceTime *) av_packet_new_side_data( (AVProducerReferenceTime *) av_packet_new_side_data(
pkt, AV_PKT_DATA_PRFT, sizeof(AVProducerReferenceTime)); pkt, AV_PKT_DATA_PRFT, sizeof(AVProducerReferenceTime));
if (!prft) if (!prft)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
prft->wallclock = ff_parse_ntp_time(s->last_rtcp_ntp_time) - NTP_OFFSET_US + rtcp_time = ff_parse_ntp_time(s->last_rtcp_ntp_time) - NTP_OFFSET_US;
timestamp - s->last_rtcp_timestamp; 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; prft->flags = 24;
return 0; return 0;
} }