diff options
author | Alok Priyadarshi <alokpr@gmail.com> | 2021-03-23 14:29:48 -0700 |
---|---|---|
committer | James Almer <jamrial@gmail.com> | 2021-03-23 19:02:47 -0300 |
commit | adff25412a2929de67e44da1abaf67f9a267bdf4 (patch) | |
tree | b9872591f50e9d0257a4fe8e99940c0ade55701d /libavformat/rtpdec.c | |
parent | 3220a908ca3c9e2d4108464f2127fdbb7479e69a (diff) | |
download | ffmpeg-adff25412a2929de67e44da1abaf67f9a267bdf4.tar.gz |
avformat/rtpdec: attach producer reference time if available
This produces true wallclock time at rtp source instead of the
local wallclock time at rtp client.
Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavformat/rtpdec.c')
-rw-r--r-- | libavformat/rtpdec.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/libavformat/rtpdec.c b/libavformat/rtpdec.c index fd4601e654..1edb64b9bf 100644 --- a/libavformat/rtpdec.c +++ b/libavformat/rtpdec.c @@ -622,6 +622,19 @@ void ff_rtp_parse_set_crypto(RTPDemuxContext *s, const char *suite, s->srtp_enabled = 1; } +static int rtp_set_prft(RTPDemuxContext *s, AVPacket *pkt, uint32_t timestamp) { + 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; + prft->flags = 24; + return 0; +} + /** * This was the second switch in rtp_parse packet. * Normalizes time, if required, sets stream_index, etc. @@ -633,6 +646,12 @@ static void finalize_packet(RTPDemuxContext *s, AVPacket *pkt, uint32_t timestam if (timestamp == RTP_NOTS_VALUE) return; + if (s->last_rtcp_ntp_time != AV_NOPTS_VALUE) { + if (rtp_set_prft(s, pkt, timestamp) < 0) { + av_log(s->ic, AV_LOG_WARNING, "rtpdec: failed to set prft"); + } + } + if (s->last_rtcp_ntp_time != AV_NOPTS_VALUE && s->ic->nb_streams > 1) { int64_t addend; int delta_timestamp; |