[vlc-commits] m3u: Check Content-type if available.

Konstantin Pavlov git at videolan.org
Thu May 31 17:18:40 CEST 2012


vlc/vlc-2.0 | branch: master | Konstantin Pavlov <thresh at videolan.org> | Wed May 30 11:50:00 2012 +0400| [cd7ab6ee4c2affc20c0eecb3957b6f12c7ff41cd] | committer: Jean-Baptiste Kempf

m3u: Check Content-type if available.
(cherry picked from commit 0e3e2b84b9c0891f9496b39184d2adea9fff4117)

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

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

 modules/demux/playlist/m3u.c |   18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/modules/demux/playlist/m3u.c b/modules/demux/playlist/m3u.c
index fa3640e..388e8a9 100644
--- a/modules/demux/playlist/m3u.c
+++ b/modules/demux/playlist/m3u.c
@@ -49,6 +49,7 @@ static int Demux( demux_t *p_demux);
 static int Control( demux_t *p_demux, int i_query, va_list args );
 static void parseEXTINF( char *psz_string, char **ppsz_artist, char **ppsz_name, int *pi_duration );
 static bool ContainsURL( demux_t *p_demux );
+static bool CheckContentType( stream_t * p_stream, const char * psz_ctype );
 
 static char *GuessEncoding (const char *str)
 {
@@ -73,14 +74,16 @@ int Import_M3U( vlc_object_t *p_this )
     if( POKE( p_peek, "RTSPtext", 8 ) /* QuickTime */
      || POKE( p_peek, "\xef\xbb\xbf" "#EXTM3U", 10) /* BOM at start */
      || demux_IsPathExtension( p_demux, ".m3u8" )
-     || demux_IsForced( p_demux, "m3u8" ) )
+     || demux_IsForced( p_demux, "m3u8" )
+     || CheckContentType( p_demux->s, "application/vnd.apple.mpegurl" ) )
         pf_dup = CheckUnicode; /* UTF-8 */
     else
     if( POKE( p_peek, "#EXTM3U", 7 )
      || demux_IsPathExtension( p_demux, ".m3u" )
      || demux_IsPathExtension( p_demux, ".vlc" )
      || demux_IsForced( p_demux, "m3u" )
-     || ContainsURL( p_demux ) )
+     || ContainsURL( p_demux )
+     || CheckContentType( p_demux->s, "audio/x-mpegurl") )
         pf_dup = GuessEncoding;
     else
         return VLC_EGENERIC;
@@ -126,6 +129,17 @@ static bool ContainsURL( demux_t *p_demux )
     return false;
 }
 
+static bool CheckContentType( stream_t * p_stream, const char * psz_ctype )
+{
+    char *psz_check = stream_ContentType( p_stream );
+    if( !psz_check ) return false;
+
+    int i_res = strncasecmp( psz_check, psz_ctype, strlen( psz_check ) );
+    free( psz_check );
+
+    return ( i_res == 0 ) ? true : false;
+}
+
 /*****************************************************************************
  * Deactivate: frees unused data
  *****************************************************************************/



More information about the vlc-commits mailing list