[vlc-commits] httplive: ignore failed stream in meta list

Rui Zhang git at videolan.org
Sun Sep 30 17:03:18 CEST 2012


vlc/vlc-2.0 | branch: master | Rui Zhang <bbcallen at gmail.com> | Wed May 30 17:41:35 2012 +0800| [5ecc28ae8ff0d2e390fb6e4dfdf77ba94703577a] | committer: Jean-Baptiste Kempf

httplive: ignore failed stream in meta list

So we have chance to try other streams instead of just fail.
Fixes #6898

Signed-off-by: Hugo Beauzée-Luyssen <beauze.h at gmail.com>
(cherry picked from commit e71bbc493deae0a2f1c01ea06dbb5e51a555edbe)

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc/vlc-2.0.git/?a=commit;h=5ecc28ae8ff0d2e390fb6e4dfdf77ba94703577a
---

 modules/stream_filter/httplive.c |   25 ++++++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/modules/stream_filter/httplive.c b/modules/stream_filter/httplive.c
index f22e5af..98e6db2 100644
--- a/modules/stream_filter/httplive.c
+++ b/modules/stream_filter/httplive.c
@@ -954,6 +954,8 @@ static int parse_M3U8(stream_t *s, vlc_array_t *streams, uint8_t *buffer, const
 
         /* M3U8 Meta Index file */
         do {
+            bool failed_to_download_stream_m3u8 = false;
+
             /* Next line */
             line = ReadLine(p_begin, &p_read, p_end - p_begin);
             if (line == NULL)
@@ -976,15 +978,29 @@ static int parse_M3U8(stream_t *s, vlc_array_t *streams, uint8_t *buffer, const
                     }
                     else
                     {
+                        bool new_stream_added = false;
                         hls_stream_t *hls = NULL;
                         err = parse_StreamInformation(s, &streams, &hls, line, uri);
+                        if (err == VLC_SUCCESS)
+                            new_stream_added = true;
+
                         free(uri);
 
                         /* Download playlist file from server */
                         uint8_t *buf = NULL;
                         ssize_t len = read_M3U8_from_url(s, hls->url, &buf);
                         if (len < 0)
-                            err = VLC_EGENERIC;
+                        {
+                            msg_Warn(s, "failed to read %s, continue for other streams", hls->url);
+                            failed_to_download_stream_m3u8 = true;
+
+                            /* remove stream just added */
+                            if (new_stream_added)
+                                vlc_array_remove(streams, vlc_array_count(streams) - 1);
+
+                            /* ignore download error, so we have chance to try other streams */
+                            err = VLC_SUCCESS;
+                        }
                         else
                         {
                             /* Parse HLS m3u8 content. */
@@ -1011,6 +1027,13 @@ static int parse_M3U8(stream_t *s, vlc_array_t *streams, uint8_t *buffer, const
 
         } while (err == VLC_SUCCESS);
 
+        size_t stream_count = vlc_array_count(streams);
+        msg_Dbg(s, "%d streams loaded in Meta playlist", (int)stream_count);
+        if (stream_count == 0)
+        {
+            msg_Err(s, "No playable streams found in Meta playlist");
+            err = VLC_EGENERIC;
+        }
     }
     else
     {



More information about the vlc-commits mailing list