[FFmpeg-cvslog] r22438 - in trunk/libavformat: internal.h rtpenc.c utils.c

mstorsjo subversion
Wed Mar 10 23:21:39 CET 2010


Author: mstorsjo
Date: Wed Mar 10 23:21:39 2010
New Revision: 22438

Log:
Make the ntp_time function available to other parts of libavformat, as ff_ntp_time

Modified:
   trunk/libavformat/internal.h
   trunk/libavformat/rtpenc.c
   trunk/libavformat/utils.c

Modified: trunk/libavformat/internal.h
==============================================================================
--- trunk/libavformat/internal.h	Wed Mar 10 22:39:58 2010	(r22437)
+++ trunk/libavformat/internal.h	Wed Mar 10 23:21:39 2010	(r22438)
@@ -37,4 +37,7 @@ void ff_interleave_add_packet(AVFormatCo
 
 void av_read_frame_flush(AVFormatContext *s);
 
+/** Gets the current time since NTP epoch in microseconds. */
+uint64_t ff_ntp_time(void);
+
 #endif /* AVFORMAT_INTERNAL_H */

Modified: trunk/libavformat/rtpenc.c
==============================================================================
--- trunk/libavformat/rtpenc.c	Wed Mar 10 22:39:58 2010	(r22437)
+++ trunk/libavformat/rtpenc.c	Wed Mar 10 23:21:39 2010	(r22438)
@@ -21,6 +21,7 @@
 
 #include "avformat.h"
 #include "mpegts.h"
+#include "internal.h"
 
 #include <unistd.h>
 
@@ -29,13 +30,6 @@
 //#define DEBUG
 
 #define RTCP_SR_SIZE 28
-#define NTP_OFFSET 2208988800ULL
-#define NTP_OFFSET_US (NTP_OFFSET * 1000000ULL)
-
-static uint64_t ntp_time(void)
-{
-  return (av_gettime() / 1000) * 1000 + NTP_OFFSET_US;
-}
 
 static int is_supported(enum CodecID id)
 {
@@ -91,7 +85,7 @@ static int rtp_write_header(AVFormatCont
     s->cur_timestamp = 0;
     s->ssrc = 0; /* FIXME: was random(), what should this be? */
     s->first_packet = 1;
-    s->first_rtcp_ntp_time = ntp_time();
+    s->first_rtcp_ntp_time = ff_ntp_time();
 
     max_packet_size = url_fget_max_packet_size(s1->pb);
     if (max_packet_size <= 12)
@@ -346,8 +340,8 @@ static int rtp_write_packet(AVFormatCont
     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) &&
-                           (ntp_time() - s->last_rtcp_ntp_time > 5000000))) {
-        rtcp_send_sr(s1, ntp_time());
+                           (ff_ntp_time() - s->last_rtcp_ntp_time > 5000000))) {
+        rtcp_send_sr(s1, ff_ntp_time());
         s->last_octet_count = s->octet_count;
         s->first_packet = 0;
     }

Modified: trunk/libavformat/utils.c
==============================================================================
--- trunk/libavformat/utils.c	Wed Mar 10 22:39:58 2010	(r22437)
+++ trunk/libavformat/utils.c	Wed Mar 10 23:21:39 2010	(r22438)
@@ -3073,6 +3073,14 @@ int64_t av_gettime(void)
     return (int64_t)tv.tv_sec * 1000000 + tv.tv_usec;
 }
 
+#define NTP_OFFSET 2208988800ULL
+#define NTP_OFFSET_US (NTP_OFFSET * 1000000ULL)
+
+uint64_t ff_ntp_time(void)
+{
+  return (av_gettime() / 1000) * 1000 + NTP_OFFSET_US;
+}
+
 int64_t parse_date(const char *datestr, int duration)
 {
     const char *p;



More information about the ffmpeg-cvslog mailing list