Applied for applehttpproto same changes that are in my and Martin's patches.
---
libavformat/applehttpproto.c | 20 ++++++++++++++------
1 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/libavformat/applehttpproto.c b/libavformat/applehttpproto.c
index 2b15709..eb96b0a 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,19 @@ 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;
retry:
- if (!s->finished) {
- int64_t now = av_gettime();
- if (now - s->last_load_time >= s->target_duration*1000000)
- if ((ret = parse_playlist(h, s->playlisturl)) < 0)
- return ret;
+ reload_interval *= 1000000;
+ if (!s->finished &&
+ av_gettime() - 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 +280,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);
--
Andrey Utkin
From 9fd57137f5f023d12bdcdade7586c5af3bc3ce2d Mon Sep 17 00:00:00 2001
From: Andrey Utkin <[email protected]>
Date: Wed, 28 Dec 2011 16:55:46 +0200
Subject: [PATCH] applehttpproto: the same reload interval fix
---
libavformat/applehttpproto.c | 20 ++++++++++++++------
1 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/libavformat/applehttpproto.c b/libavformat/applehttpproto.c
index 2b15709..eb96b0a 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,19 @@ 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;
retry:
- if (!s->finished) {
- int64_t now = av_gettime();
- if (now - s->last_load_time >= s->target_duration*1000000)
- if ((ret = parse_playlist(h, s->playlisturl)) < 0)
- return ret;
+ reload_interval *= 1000000;
+ if (!s->finished &&
+ av_gettime() - 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 +280,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);
--
1.7.7
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel