[FFmpeg-cvslog] Revert "avformat/utils: make ff_ntp_time() accept a timestamp as input argument"
James Almer
git at videolan.org
Fri Jan 17 03:29:47 EET 2020
ffmpeg | branch: master | James Almer <jamrial at gmail.com> | Thu Jan 16 16:25:26 2020 -0300| [ab9627223e630390a8a99c052de2fb82abde2746] | committer: James Almer
Revert "avformat/utils: make ff_ntp_time() accept a timestamp as input argument"
Signed-off-by: James Almer <jamrial at gmail.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ab9627223e630390a8a99c052de2fb82abde2746
---
libavformat/internal.h | 2 +-
libavformat/movenc.c | 6 ++++--
libavformat/rtpenc.c | 8 ++++----
libavformat/rtpenc.h | 1 -
libavformat/utils.c | 4 ++--
5 files changed, 11 insertions(+), 10 deletions(-)
diff --git a/libavformat/internal.h b/libavformat/internal.h
index 4d04a21871..ec9a29907a 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -243,7 +243,7 @@ void ff_read_frame_flush(AVFormatContext *s);
#define NTP_OFFSET_US (NTP_OFFSET * 1000000ULL)
/** Get the current time since NTP epoch in microseconds. */
-uint64_t ff_ntp_time(int64_t timestamp);
+uint64_t ff_ntp_time(void);
/**
* Get the NTP time stamp formatted as per the RFC-5905.
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index a2cfc59b89..9111ac300c 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -4657,10 +4657,12 @@ static int mov_write_prft_tag(AVIOContext *pb, MOVMuxContext *mov, int tracks)
if (mov->write_prft == MOV_PRFT_SRC_WALLCLOCK) {
if (first_track->cluster[0].prft.wallclock) {
- ntp_ts = ff_get_formatted_ntp_time(ff_ntp_time(first_track->cluster[0].prft.wallclock));
+ /* Round the NTP time to whole milliseconds. */
+ ntp_ts = ff_get_formatted_ntp_time((first_track->cluster[0].prft.wallclock / 1000) * 1000 +
+ NTP_OFFSET_US);
flags = first_track->cluster[0].prft.flags;
} else
- ntp_ts = ff_get_formatted_ntp_time(ff_ntp_time(av_gettime()));
+ ntp_ts = ff_get_formatted_ntp_time(ff_ntp_time());
} else if (mov->write_prft == MOV_PRFT_SRC_PTS) {
pts_us = av_rescale_q(first_track->cluster[0].pts,
first_track->st->time_base, AV_TIME_BASE_Q);
diff --git a/libavformat/rtpenc.c b/libavformat/rtpenc.c
index b4f2504123..63047beccc 100644
--- a/libavformat/rtpenc.c
+++ b/libavformat/rtpenc.c
@@ -124,7 +124,7 @@ static int rtp_write_header(AVFormatContext *s1)
if (!s->ssrc)
s->ssrc = av_get_random_seed();
s->first_packet = 1;
- s->first_rtcp_ntp_time = ff_ntp_time(av_gettime());
+ s->first_rtcp_ntp_time = ff_ntp_time();
if (s1->start_time_realtime != 0 && s1->start_time_realtime != AV_NOPTS_VALUE)
/* Round the NTP time to whole milliseconds. */
s->first_rtcp_ntp_time = (s1->start_time_realtime / 1000) * 1000 +
@@ -526,9 +526,9 @@ static int rtp_write_packet(AVFormatContext *s1, AVPacket *pkt)
rtcp_bytes = ((s->octet_count - s->last_octet_count) * RTCP_TX_RATIO_NUM) /
RTCP_TX_RATIO_DEN;
if ((s->first_packet || ((rtcp_bytes >= RTCP_SR_SIZE) &&
- (ff_ntp_time(av_gettime()) - s->last_rtcp_ntp_time > 5000000))) &&
+ (ff_ntp_time() - s->last_rtcp_ntp_time > 5000000))) &&
!(s->flags & FF_RTP_FLAG_SKIP_RTCP)) {
- rtcp_send_sr(s1, ff_ntp_time(av_gettime()), 0);
+ rtcp_send_sr(s1, ff_ntp_time(), 0);
s->last_octet_count = s->octet_count;
s->first_packet = 0;
}
@@ -642,7 +642,7 @@ static int rtp_write_trailer(AVFormatContext *s1)
/* If the caller closes and recreates ->pb, this might actually
* be NULL here even if it was successfully allocated at the start. */
if (s1->pb && (s->flags & FF_RTP_FLAG_SEND_BYE))
- rtcp_send_sr(s1, ff_ntp_time(av_gettime()), 1);
+ rtcp_send_sr(s1, ff_ntp_time(), 1);
av_freep(&s->buf);
return 0;
diff --git a/libavformat/rtpenc.h b/libavformat/rtpenc.h
index e67ce665f1..62dc9ab10a 100644
--- a/libavformat/rtpenc.h
+++ b/libavformat/rtpenc.h
@@ -21,7 +21,6 @@
#ifndef AVFORMAT_RTPENC_H
#define AVFORMAT_RTPENC_H
-#include "libavutil/time.h"
#include "avformat.h"
#include "rtp.h"
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 674757a63f..f3d71642c3 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -4684,9 +4684,9 @@ void av_program_add_stream_index(AVFormatContext *ac, int progid, unsigned idx)
}
}
-uint64_t ff_ntp_time(int64_t timestamp)
+uint64_t ff_ntp_time(void)
{
- return (timestamp / 1000) * 1000 + NTP_OFFSET_US;
+ return (av_gettime() / 1000) * 1000 + NTP_OFFSET_US;
}
uint64_t ff_get_formatted_ntp_time(uint64_t ntp_time_us)
More information about the ffmpeg-cvslog
mailing list