[vlc-commits] playlist/m3u: split HLS to separate function

Rémi Denis-Courmont git at videolan.org
Thu Jun 29 18:32:29 CEST 2017


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu Jun 29 19:24:20 2017 +0300| [6e87ce9dfda8d05b41cf6dd30b17c52bb9ebec56] | committer: Rémi Denis-Courmont

playlist/m3u: split HLS to separate function

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=6e87ce9dfda8d05b41cf6dd30b17c52bb9ebec56
---

 modules/demux/playlist/m3u.c | 32 +++++++++++++++++++-------------
 1 file changed, 19 insertions(+), 13 deletions(-)

diff --git a/modules/demux/playlist/m3u.c b/modules/demux/playlist/m3u.c
index ecd71b9e4e..ce5452695d 100644
--- a/modules/demux/playlist/m3u.c
+++ b/modules/demux/playlist/m3u.c
@@ -54,6 +54,23 @@ static char *CheckUnicode (const char *str)
     return IsUTF8 (str) ? strdup (str): NULL;
 }
 
+static bool IsHLS(const unsigned char *buf, size_t length)
+{
+    static const char *const hlsexts[] =
+    {
+        "#EXT-X-MEDIA:",
+        "#EXT-X-VERSION:",
+        "#EXT-X-TARGETDURATION:",
+        "#EXT-X-MEDIA-SEQUENCE:",
+    };
+
+    for (size_t i = 0; i < ARRAY_SIZE(hlsexts); i++)
+        if (strnstr((const char *)buf, hlsexts[i], length) != NULL)
+            return true;
+
+    return false;
+}
+
 /*****************************************************************************
  * Import_M3U: main import function
  *****************************************************************************/
@@ -122,19 +139,8 @@ int Import_M3U( vlc_object_t *p_this )
 
     free(type);
 
-    if( b_check_hls )
-    {
-        const char * ppsz_hlsexts[] =
-        {
-            "#EXT-X-MEDIA:",
-            "#EXT-X-VERSION:",
-            "#EXT-X-TARGETDURATION:",
-            "#EXT-X-MEDIA-SEQUENCE:",
-        };
-        for( size_t i=0; i<ARRAY_SIZE(ppsz_hlsexts); i++ )
-            if( strnstr( (const char *) p_peek, ppsz_hlsexts[i], i_peek - offset ) )
-                return VLC_EGENERIC;
-    }
+    if (b_check_hls && IsHLS(p_peek, i_peek - offset))
+        return VLC_EGENERIC;
 
     vlc_stream_Seek( p_stream->p_source, offset );
 



More information about the vlc-commits mailing list