[FFmpeg-cvslog] avformat/utils: function to get the formatted ntp time
Vishwanath Dixit
git at videolan.org
Tue May 29 07:57:04 EEST 2018
ffmpeg | branch: master | Vishwanath Dixit <vdixit at akamai.com> | Mon May 7 15:45:36 2018 +0530| [f09635f2a2e653ab5f790b1e9d7a15794745ca30] | committer: Karthick Jeyapal
avformat/utils: function to get the formatted ntp time
This utility function creates 64-bit NTP time format as per the RFC
5905.
A simple explaination of 64-bit NTP time format is here
http://www.beaglesoft.com/Manual/page53.htm
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f09635f2a2e653ab5f790b1e9d7a15794745ca30
---
libavformat/internal.h | 8 ++++++++
libavformat/utils.c | 22 ++++++++++++++++++++++
2 files changed, 30 insertions(+)
diff --git a/libavformat/internal.h b/libavformat/internal.h
index 3582682925..0b8120b842 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -240,6 +240,14 @@ void ff_read_frame_flush(AVFormatContext *s);
uint64_t ff_ntp_time(void);
/**
+ * Get the NTP time stamp formatted as per the RFC-5905.
+ *
+ * @param ntp_time NTP time in micro seconds (since NTP epoch)
+ * @return the formatted NTP time stamp
+ */
+uint64_t ff_get_formatted_ntp_time(uint64_t ntp_time_us);
+
+/**
* Append the media-specific SDP fragment for the media stream c
* to the buffer buff.
*
diff --git a/libavformat/utils.c b/libavformat/utils.c
index a4aa4e10b1..c9cdd2b470 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -4644,6 +4644,28 @@ uint64_t ff_ntp_time(void)
return (av_gettime() / 1000) * 1000 + NTP_OFFSET_US;
}
+uint64_t ff_get_formatted_ntp_time(uint64_t ntp_time_us)
+{
+ uint64_t ntp_ts, frac_part, sec;
+ uint32_t usec;
+
+ //current ntp time in seconds and micro seconds
+ sec = ntp_time_us / 1000000;
+ usec = ntp_time_us % 1000000;
+
+ //encoding in ntp timestamp format
+ frac_part = usec * 0xFFFFFFFFULL;
+ frac_part /= 1000000;
+
+ if (sec > 0xFFFFFFFFULL)
+ av_log(NULL, AV_LOG_WARNING, "NTP time format roll over detected\n");
+
+ ntp_ts = sec << 32;
+ ntp_ts |= frac_part;
+
+ return ntp_ts;
+}
+
int av_get_frame_filename2(char *buf, int buf_size, const char *path, int number, int flags)
{
const char *p;
More information about the ffmpeg-cvslog
mailing list