diff mbox

[FFmpeg-devel] avformat/hls: mark the playlist is broken when the reload times is over

Message ID 20190903024114.94705-1-lq@chinaffmpeg.org
State New
Headers show

Commit Message

Liu Steven Sept. 3, 2019, 2:41 a.m. UTC
when the playlist is master playlist, there have many playlist.
the workflow should continue if one of the playlist is broken.

Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
---
 libavformat/hls.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Liu Steven Sept. 9, 2019, 6:18 a.m. UTC | #1
> 在 2019年9月3日,上午10:41,Steven Liu <lq@chinaffmpeg.org> 写道:
> 
> when the playlist is master playlist, there have many playlist.
> the workflow should continue if one of the playlist is broken.
> 
> Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
> ---
> libavformat/hls.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/libavformat/hls.c b/libavformat/hls.c
> index 3aee7a19ae..d2fafe0302 100644
> --- a/libavformat/hls.c
> +++ b/libavformat/hls.c
> @@ -1408,8 +1408,11 @@ restart:
> 
> reload:
>         reload_count++;
> -        if (reload_count > c->max_reload)
> +        if (reload_count > c->max_reload) {
> +            v->broken = 1;
> +            v->needed = 0;
>             return AVERROR_EOF;
> +        }
>         if (!v->finished &&
>             av_gettime_relative() - v->last_load_time >= reload_interval) {
>             if ((ret = parse_playlist(c, v->url, v, NULL)) < 0) {
> @@ -1459,7 +1462,7 @@ reload:
>         if (ret < 0) {
>             if (ff_check_interrupt(c->interrupt_callback))
>                 return AVERROR_EXIT;
> -            av_log(v->parent, AV_LOG_WARNING, "Failed to open segment %d of playlist %d\n",
> +            av_log(v->parent, AV_LOG_WARNING, "Failed to open segment %d of playlist %d, will reload\n",
>                    v->cur_seq_no,
>                    v->index);
>             v->cur_seq_no += 1;
> @@ -1925,6 +1928,7 @@ static int hls_read_header(AVFormatContext *s)
>             av_log(s, AV_LOG_ERROR, "Error when loading first segment '%s'\n", pls->segments[0]->url);
>             avformat_free_context(pls->ctx);
>             pls->ctx = NULL;
> +            if (c->n_playlists > 1) continue;
>             goto fail;
>         }
>         pls->ctx->pb       = &pls->pb;
> -- 
> 2.17.2 (Apple Git-113)
> 

ping

This is base on the patch: https://patchwork.ffmpeg.org/patch/14879/

Thanks
Steven
diff mbox

Patch

diff --git a/libavformat/hls.c b/libavformat/hls.c
index 3aee7a19ae..d2fafe0302 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -1408,8 +1408,11 @@  restart:
 
 reload:
         reload_count++;
-        if (reload_count > c->max_reload)
+        if (reload_count > c->max_reload) {
+            v->broken = 1;
+            v->needed = 0;
             return AVERROR_EOF;
+        }
         if (!v->finished &&
             av_gettime_relative() - v->last_load_time >= reload_interval) {
             if ((ret = parse_playlist(c, v->url, v, NULL)) < 0) {
@@ -1459,7 +1462,7 @@  reload:
         if (ret < 0) {
             if (ff_check_interrupt(c->interrupt_callback))
                 return AVERROR_EXIT;
-            av_log(v->parent, AV_LOG_WARNING, "Failed to open segment %d of playlist %d\n",
+            av_log(v->parent, AV_LOG_WARNING, "Failed to open segment %d of playlist %d, will reload\n",
                    v->cur_seq_no,
                    v->index);
             v->cur_seq_no += 1;
@@ -1925,6 +1928,7 @@  static int hls_read_header(AVFormatContext *s)
             av_log(s, AV_LOG_ERROR, "Error when loading first segment '%s'\n", pls->segments[0]->url);
             avformat_free_context(pls->ctx);
             pls->ctx = NULL;
+            if (c->n_playlists > 1) continue;
             goto fail;
         }
         pls->ctx->pb       = &pls->pb;