m3u: retrieve Content-Type only once
authorRémi Denis-Courmont <remi@remlab.net>
Mon, 17 Apr 2017 20:13:12 +0000 (23:13 +0300)
committerRémi Denis-Courmont <remi@remlab.net>
Tue, 18 Apr 2017 18:54:12 +0000 (21:54 +0300)
modules/demux/playlist/m3u.c

index d719350..8a84d9a 100644 (file)
@@ -77,19 +77,26 @@ int Import_M3U( vlc_object_t *p_this )
         offset = 3;
     }
 
+    char *type = stream_MimeType(p_demux->s);
+
     if( demux_IsPathExtension( p_demux, ".m3u8" )
      || demux_IsForced( p_demux, "m3u8" )
-     || CheckMimeType( p_demux->s, "application/vnd.apple.mpegurl" ) )
+     || (type != NULL && strcasecmp(type, "application/vnd.apple.mpegurl")))
+    {
         pf_dup = CheckUnicode; /* UTF-8 file type */
+        free(type);
+    }
     else
     if( demux_IsPathExtension( p_demux, ".m3u" )
      || demux_IsPathExtension( p_demux, ".vlc" )
      || demux_IsForced( p_demux, "m3u" )
      || ContainsURL( p_demux )
-     || CheckMimeType( p_demux->s, "audio/x-mpegurl") )
-        ; /* Guess encoding */
+     || (type != NULL && strcasecmp(type, "audio/x-mpegurl")))
+        free(type); /* Guess encoding */
     else
     {
+        free(type);
+
         if( vlc_stream_Peek( p_demux->s, &p_peek, 8 + offset ) < (8 + offset) )
             return VLC_EGENERIC;