[FFmpeg-cvslog] applehttp: Use the last segment duration as reload interval

Andrey Utkin git at videolan.org
Fri Dec 30 03:54:02 CET 2011


ffmpeg | branch: master | Andrey Utkin <andrey.krieger.utkin at gmail.com> | Mon Dec 26 21:25:52 2011 +0200| [356ae5f65bd351923e6eda6f35a12bb5f362c6ab] | committer: Martin Storsjö

applehttp: Use the last segment duration as reload interval

According to draft-pantos-http-live-streaming-07, 6.3.4,
the duration of the last media segment in the playlist
should be used as initial minimum reload delay.

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

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

 libavformat/applehttp.c |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/libavformat/applehttp.c b/libavformat/applehttp.c
index 6c4d56d..9ab5927 100644
--- a/libavformat/applehttp.c
+++ b/libavformat/applehttp.c
@@ -377,10 +377,15 @@ static int read_data(void *opaque, uint8_t *buf, int buf_size)
 restart:
     if (!v->input) {
 reload:
-        /* If this is a live stream and target_duration has elapsed since
+        /* If this is a live stream and the reload interval has elapsed since
          * the last playlist reload, reload the variant playlists now. */
+        int64_t reload_interval = v->n_segments > 0 ?
+                                  v->segments[v->n_segments - 1]->duration :
+                                  v->target_duration;
+        reload_interval *= 1000000;
+
         if (!v->finished &&
-            av_gettime() - v->last_load_time >= v->target_duration*1000000 &&
+            av_gettime() - v->last_load_time >= reload_interval &&
             (ret = parse_playlist(c, v->url, v, NULL)) < 0)
                 return ret;
         if (v->cur_seq_no < v->start_seq_no) {
@@ -392,8 +397,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 <
-                   v->target_duration*1000000) {
+            while (av_gettime() - v->last_load_time < reload_interval) {
                 if (ff_check_interrupt(c->interrupt_callback))
                     return AVERROR_EXIT;
                 usleep(100*1000);



More information about the ffmpeg-cvslog mailing list