From 6705d9c9e4ded00075b4d8b23cb05ea2c65146ee Mon Sep 17 00:00:00 2001 From: liuyuxin <liuyu...@xiaomi.com> Date: Fri, 6 Nov 2015 16:17:40 +0800 Subject: [PATCH] Network environment or video websites maybe lead to avio_open2 failed, but if we try avio_open2 several times, it will return success.
--- libavformat/hls.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/libavformat/hls.c b/libavformat/hls.c index ccae270..5d55197 100644 --- a/libavformat/hls.c +++ b/libavformat/hls.c @@ -41,6 +41,7 @@ #define INITIAL_BUFFER_SIZE 32768 +#define MAX_RETRY_COUNT 5 #define MAX_FIELD_LEN 64 #define MAX_CHARACTERISTICS_LEN 512 @@ -655,8 +656,17 @@ static int parse_playlist(HLSContext *c, const char *url, av_dict_set(&opts, "cookies", c->cookies, 0); av_dict_set(&opts, "headers", c->headers, 0); - ret = avio_open2(&in, url, AVIO_FLAG_READ, - c->interrupt_callback, &opts); + int try_count = MAX_RETRY_COUNT; + + ret = AVERROR_EXIT; + while (try_count-- && !ff_check_interrupt(c->interrupt_callback)) { + if ((ret = avio_open2(&in, url, AVIO_FLAG_READ, + c->interrupt_callback, &opts)) >= 0) { + break; + } + av_usleep(100*1000); + } + av_dict_free(&opts); if (ret < 0) return ret;
0001-Network-environment-or-video-websites-maybe-lead-to-.patch
Description: Binary data
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel