[FFmpeg-devel] [PATCH] libavformat/hls.c: if avio_open2 failed, retry it several times.
luckliuyuxin
luckliuyuxin at 163.com
Fri Nov 6 10:27:21 CET 2015
From 6705d9c9e4ded00075b4d8b23cb05ea2c65146ee Mon Sep 17 00:00:00 2001
From: liuyuxin <liuyuxin at 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;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Network-environment-or-video-websites-maybe-lead-to-.patch
Type: application/octet-stream
Size: 1425 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20151106/9d597a84/attachment.obj>
More information about the ffmpeg-devel
mailing list