[FFmpeg-cvslog] lavf: Use av_gettime_relative

Martin Storsjö git at videolan.org
Fri Oct 24 12:47:02 CEST 2014


ffmpeg | branch: master | Martin Storsjö <martin at martin.st> | Wed Oct 22 12:40:46 2014 +0300| [6df9d9b55d3f56ee7782639a7678eeeaf77f14ea] | committer: Martin Storsjö

lavf: Use av_gettime_relative

The ones left using av_gettime are NTP timestamps (for RTCP,
which is specified to send the actual current realtime clock
in RTCP SR packets), and the NUT muxer timestamper, which is
documented as using wallclock time.

Signed-off-by: Martin Storsjö <martin at martin.st>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6df9d9b55d3f56ee7782639a7678eeeaf77f14ea
---

 libavformat/hls.c      |    6 +++---
 libavformat/hlsproto.c |    6 +++---
 libavformat/rtpdec.c   |   10 +++++-----
 libavformat/rtsp.c     |    8 ++++----
 libavformat/rtspdec.c  |    2 +-
 libavformat/sapenc.c   |    2 +-
 6 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/libavformat/hls.c b/libavformat/hls.c
index 290f12e..8b52a35 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -320,7 +320,7 @@ static int parse_playlist(HLSContext *c, const char *url,
         }
     }
     if (var)
-        var->last_load_time = av_gettime();
+        var->last_load_time = av_gettime_relative();
 
 fail:
     av_free(new_url);
@@ -392,7 +392,7 @@ restart:
 
 reload:
         if (!v->finished &&
-            av_gettime() - v->last_load_time >= reload_interval) {
+            av_gettime_relative() - v->last_load_time >= reload_interval) {
             if ((ret = parse_playlist(c, v->url, v, NULL)) < 0)
                 return ret;
             /* If we need to reload the playlist again below (if
@@ -409,7 +409,7 @@ reload:
         if (v->cur_seq_no >= v->start_seq_no + v->n_segments) {
             if (v->finished)
                 return AVERROR_EOF;
-            while (av_gettime() - v->last_load_time < reload_interval) {
+            while (av_gettime_relative() - v->last_load_time < reload_interval) {
                 if (ff_check_interrupt(c->interrupt_callback))
                     return AVERROR_EXIT;
                 av_usleep(100*1000);
diff --git a/libavformat/hlsproto.c b/libavformat/hlsproto.c
index ec357de..751fef2 100644
--- a/libavformat/hlsproto.c
+++ b/libavformat/hlsproto.c
@@ -169,7 +169,7 @@ static int parse_playlist(URLContext *h, const char *url)
             }
         }
     }
-    s->last_load_time = av_gettime();
+    s->last_load_time = av_gettime_relative();
 
 fail:
     avio_close(in);
@@ -273,7 +273,7 @@ start:
                       s->target_duration;
 retry:
     if (!s->finished) {
-        int64_t now = av_gettime();
+        int64_t now = av_gettime_relative();
         if (now - s->last_load_time >= reload_interval) {
             if ((ret = parse_playlist(h, s->playlisturl)) < 0)
                 return ret;
@@ -292,7 +292,7 @@ retry:
     if (s->cur_seq_no - s->start_seq_no >= s->n_segments) {
         if (s->finished)
             return AVERROR_EOF;
-        while (av_gettime() - s->last_load_time < reload_interval) {
+        while (av_gettime_relative() - s->last_load_time < reload_interval) {
             if (ff_check_interrupt(&h->interrupt_callback))
                 return AVERROR_EXIT;
             av_usleep(100*1000);
diff --git a/libavformat/rtpdec.c b/libavformat/rtpdec.c
index 76228be..b5e5200 100644
--- a/libavformat/rtpdec.c
+++ b/libavformat/rtpdec.c
@@ -135,7 +135,7 @@ static int rtcp_parse_packet(RTPDemuxContext *s, const unsigned char *buf,
                 return AVERROR_INVALIDDATA;
             }
 
-            s->last_rtcp_reception_time = av_gettime();
+            s->last_rtcp_reception_time = av_gettime_relative();
             s->last_rtcp_ntp_time  = AV_RB64(buf + 8);
             s->last_rtcp_timestamp = AV_RB32(buf + 16);
             if (s->first_rtcp_ntp_time == AV_NOPTS_VALUE) {
@@ -315,7 +315,7 @@ int ff_rtp_check_and_send_back_rr(RTPDemuxContext *s, URLContext *fd,
         avio_wb32(pb, 0); /* delay since last SR */
     } else {
         uint32_t middle_32_bits   = s->last_rtcp_ntp_time >> 16; // this is valid, right? do we need to handle 64 bit values special?
-        uint32_t delay_since_last = av_rescale(av_gettime() - s->last_rtcp_reception_time,
+        uint32_t delay_since_last = av_rescale(av_gettime_relative() - s->last_rtcp_reception_time,
                                                65536, AV_TIME_BASE);
 
         avio_wb32(pb, middle_32_bits); /* last SR timestamp */
@@ -440,7 +440,7 @@ int ff_rtp_send_rtcp_feedback(RTPDemuxContext *s, URLContext *fd,
     /* Send new feedback if enough time has elapsed since the last
      * feedback packet. */
 
-    now = av_gettime();
+    now = av_gettime_relative();
     if (s->last_feedback_time &&
         (now - s->last_feedback_time) < MIN_FEEDBACK_INTERVAL)
         return 0;
@@ -683,7 +683,7 @@ static void enqueue_packet(RTPDemuxContext *s, uint8_t *buf, int len)
     packet = av_mallocz(sizeof(*packet));
     if (!packet)
         return;
-    packet->recvtime = av_gettime();
+    packet->recvtime = av_gettime_relative();
     packet->seq      = seq;
     packet->len      = len;
     packet->buf      = buf;
@@ -761,7 +761,7 @@ static int rtp_parse_one_packet(RTPDemuxContext *s, AVPacket *pkt,
     }
 
     if (s->st) {
-        int64_t received = av_gettime();
+        int64_t received = av_gettime_relative();
         uint32_t arrival_ts = av_rescale_q(received, AV_TIME_BASE_Q,
                                            s->st->time_base);
         timestamp = AV_RB32(buf + 4);
diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index 52f52a1..123d543 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -1179,7 +1179,7 @@ start:
         }
         ffurl_write(rt->rtsp_hd_out, ptr, strlen(ptr));
 
-        rt->last_cmd_time = av_gettime();
+        rt->last_cmd_time = av_gettime_relative();
         /* Even if the request from the server had data, it is not the data
          * that the caller wants or expects. The memory could also be leaked
          * if the actual following reply has content data. */
@@ -1276,7 +1276,7 @@ static int rtsp_send_cmd_with_content_async(AVFormatContext *s,
         }
         ffurl_write(rt->rtsp_hd_out, send_content, send_content_length);
     }
-    rt->last_cmd_time = av_gettime();
+    rt->last_cmd_time = av_gettime_relative();
 
     return 0;
 }
@@ -1851,7 +1851,7 @@ static int udp_read_packet(AVFormatContext *s, RTSPStream **prtsp_st,
     for (;;) {
         if (ff_check_interrupt(&s->interrupt_callback))
             return AVERROR_EXIT;
-        if (wait_end && wait_end - av_gettime() < 0)
+        if (wait_end && wait_end - av_gettime_relative() < 0)
             return AVERROR(EAGAIN);
         max_p = 0;
         if (rt->rtsp_hd) {
@@ -2050,7 +2050,7 @@ redo:
         break;
     case RTSP_LOWER_TRANSPORT_CUSTOM:
         if (first_queue_st && rt->transport == RTSP_TRANSPORT_RTP &&
-            wait_end && wait_end < av_gettime())
+            wait_end && wait_end < av_gettime_relative())
             len = AVERROR(EAGAIN);
         else
             len = ffio_read_partial(s->pb, rt->recvbuf, RECVBUF_SIZE);
diff --git a/libavformat/rtspdec.c b/libavformat/rtspdec.c
index aa016c3..1f90590 100644
--- a/libavformat/rtspdec.c
+++ b/libavformat/rtspdec.c
@@ -885,7 +885,7 @@ retry:
 
     if (!(rt->rtsp_flags & RTSP_FLAG_LISTEN)) {
         /* send dummy request to keep TCP connection alive */
-        if ((av_gettime() - rt->last_cmd_time) / 1000000 >= rt->timeout / 2 ||
+        if ((av_gettime_relative() - rt->last_cmd_time) / 1000000 >= rt->timeout / 2 ||
             rt->auth_state.stale) {
             if (rt->server_type == RTSP_SERVER_WMS ||
                 (rt->server_type != RTSP_SERVER_REAL &&
diff --git a/libavformat/sapenc.c b/libavformat/sapenc.c
index 246b7cf..89f7f99 100644
--- a/libavformat/sapenc.c
+++ b/libavformat/sapenc.c
@@ -245,7 +245,7 @@ static int sap_write_packet(AVFormatContext *s, AVPacket *pkt)
 {
     AVFormatContext *rtpctx;
     struct SAPState *sap = s->priv_data;
-    int64_t now = av_gettime();
+    int64_t now = av_gettime_relative();
 
     if (!sap->last_time || now - sap->last_time > 5000000) {
         int ret = ffurl_write(sap->ann_fd, sap->ann, sap->ann_size);



More information about the ffmpeg-cvslog mailing list