diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2011-12-30 03:46:24 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2011-12-30 03:46:24 +0100 |
commit | 00c0465dbc5acd27c736d612bbad95fdbe2ef96c (patch) | |
tree | cf193c53844909c70470cf23c3b95c7f218b3547 /libavformat | |
parent | 6ed3565f08abf3b1c2a1d2d7fac768b18753530c (diff) | |
parent | 209c44526700b1bac04b9fe97c8a8fdcfbeeba00 (diff) | |
download | ffmpeg-00c0465dbc5acd27c736d612bbad95fdbe2ef96c.tar.gz |
Merge remote-tracking branch 'qatar/master'
* qatar/master:
fate: split off DPCM codec FATE tests into their own file
fate: split off PCM codec FATE tests into their own file
libvorbis: K&R reformatting cosmetics
libmp3lame: K&R formatting cosmetics
fate: Add a video test for xxan decoder
mpegvideo_enc: K&R cosmetics (line 1000-2000).
avconv: K&R cosmetics
qt-faststart: Fix up indentation
indeo4: remove two unused variables
doxygen: cleanup style to support older doxy
fate: add more tests for VC-1 decoder
applehttpproto: Apply the same reload interval changes as for the demuxer
applehttp: Use half the target duration as interval if the playlist didn't update
applehttp: Use the last segment duration as reload interval
lagarith: add decode support for arith rgb24 mode
Conflicts:
avconv.c
libavcodec/libmp3lame.c
libavcodec/mpegvideo_enc.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat')
-rw-r--r-- | libavformat/applehttp.c | 21 | ||||
-rw-r--r-- | libavformat/applehttpproto.c | 14 |
2 files changed, 27 insertions, 8 deletions
diff --git a/libavformat/applehttp.c b/libavformat/applehttp.c index 99febc6d95..5733f5fb27 100644 --- a/libavformat/applehttp.c +++ b/libavformat/applehttp.c @@ -376,13 +376,23 @@ 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; + +reload: if (!v->finished && - av_gettime() - v->last_load_time >= v->target_duration*1000000 && - (ret = parse_playlist(c, v->url, v, NULL)) < 0) + av_gettime() - 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 + * there's still no more segments), switch to a reload + * interval of half the target duration. */ + reload_interval = v->target_duration * 500000; + } if (v->cur_seq_no < v->start_seq_no) { av_log(NULL, AV_LOG_WARNING, "skipping %d segments ahead, expired from playlists\n", @@ -392,8 +402,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); diff --git a/libavformat/applehttpproto.c b/libavformat/applehttpproto.c index 8295ccc5f5..be04131642 100644 --- a/libavformat/applehttpproto.c +++ b/libavformat/applehttpproto.c @@ -244,6 +244,7 @@ static int applehttp_read(URLContext *h, uint8_t *buf, int size) AppleHTTPContext *s = h->priv_data; const char *url; int ret; + int64_t reload_interval; start: if (s->seg_hd) { @@ -256,12 +257,21 @@ start: s->seg_hd = NULL; s->cur_seq_no++; } + reload_interval = s->n_segments > 0 ? + s->segments[s->n_segments - 1]->duration : + s->target_duration; + reload_interval *= 1000000; retry: if (!s->finished) { int64_t now = av_gettime(); - if (now - s->last_load_time >= s->target_duration*1000000) + if (now - s->last_load_time >= reload_interval) { if ((ret = parse_playlist(h, s->playlisturl)) < 0) return ret; + /* If we need to reload the playlist again below (if + * there's still no more segments), switch to a reload + * interval of half the target duration. */ + reload_interval = s->target_duration * 500000; + } } if (s->cur_seq_no < s->start_seq_no) { av_log(h, AV_LOG_WARNING, @@ -272,7 +282,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 < s->target_duration*1000000) { + while (av_gettime() - s->last_load_time < reload_interval) { if (ff_check_interrupt(&h->interrupt_callback)) return AVERROR_EXIT; usleep(100*1000); |