[2/2] applehttp: Use half the target duration as interval if the playlist didn't update

Message ID 1324985946-53152-2-git-send-email-martin@martin.st
State Committed
Commit 617475a95c70efc6fae7c037915851daea9145cc
Headers show

Commit Message

Martin Storsjö Dec. 27, 2011, 11:39 a.m.
This is mandated in draft-pantos-http-live-streaming-07, section
6.3.4.
---
 libavformat/applehttp.c |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

Comments

Andrey Utkin Dec. 28, 2011, 3:03 p.m. | #1
Tested both of your patches during last couple of days, no issues.
Please consider committing.

2011/12/27 Martin Storsjö <martin@martin.st>:
> This is mandated in draft-pantos-http-live-streaming-07, section
> 6.3.4.
> ---
>  libavformat/applehttp.c |   11 ++++++++---
>  1 files changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/libavformat/applehttp.c b/libavformat/applehttp.c
> index 9ab5927..f62e2d0 100644
> --- a/libavformat/applehttp.c
> +++ b/libavformat/applehttp.c
> @@ -376,7 +376,6 @@ static int read_data(void *opaque, uint8_t *buf, int buf_size)
>
>  restart:
>     if (!v->input) {
> -reload:
>         /* 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 ?
> @@ -384,10 +383,16 @@ reload:
>                                   v->target_duration;
>         reload_interval *= 1000000;
>
> +reload:
>         if (!v->finished &&
> -            av_gettime() - v->last_load_time >= reload_interval &&
> -            (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",
> --
> 1.7.3.1
>
> _______________________________________________
> libav-devel mailing list
> libav-devel@libav.org
> https://lists.libav.org/mailman/listinfo/libav-devel
Martin Storsjö Dec. 29, 2011, 9:45 a.m. | #2
On Wed, 28 Dec 2011, Andrey Utkin wrote:

> Tested both of your patches during last couple of days, no issues.
> Please consider committing.

Pushed these two, and the touched up version of your applehttpproto patch.

// Martin

Patch

diff --git a/libavformat/applehttp.c b/libavformat/applehttp.c
index 9ab5927..f62e2d0 100644
--- a/libavformat/applehttp.c
+++ b/libavformat/applehttp.c
@@ -376,7 +376,6 @@  static int read_data(void *opaque, uint8_t *buf, int buf_size)
 
 restart:
     if (!v->input) {
-reload:
         /* 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 ?
@@ -384,10 +383,16 @@  reload:
                                   v->target_duration;
         reload_interval *= 1000000;
 
+reload:
         if (!v->finished &&
-            av_gettime() - v->last_load_time >= reload_interval &&
-            (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",