[FFmpeg-devel] [PATCH] avformat/rtpdec: Fix prft wallclock time.
James Almer
jamrial at gmail.com
Tue Mar 30 18:01:44 EEST 2021
On 3/25/2021 1:46 AM, Alok Priyadarshi wrote:
> 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.
> ---
> libavformat/rtpdec.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/libavformat/rtpdec.c b/libavformat/rtpdec.c
> index b935dba1b8..21c1d01785 100644
> --- a/libavformat/rtpdec.c
> +++ b/libavformat/rtpdec.c
> @@ -585,14 +585,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;
> }
Applied, thanks.
More information about the ffmpeg-devel
mailing list