Skip to content

Commit

Permalink
avformat/rtpdec: Fix prft wallclock time.
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
alokpr authored and jamrial committed Mar 30, 2021
1 parent e7cbbd9 commit 62f486e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions libavformat/rtpdec.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 62f486e

Please sign in to comment.