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

Steven Liu lq at chinaffmpeg.org
Tue Sep 3 05:41:14 EEST 2019


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 at 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)





More information about the ffmpeg-devel mailing list