Commit 74c432a3 authored by Francois Cartegnie's avatar Francois Cartegnie

demux: playlist: asx: handle common mime type for asx playlist and asf

http://gonze.com/playlists/playlist-format-survey.html#ASX
parent 2652d1bc
...@@ -134,6 +134,13 @@ static void ReadElement( xml_reader_t *p_xml_reader, char **ppsz_txt ) ...@@ -134,6 +134,13 @@ static void ReadElement( xml_reader_t *p_xml_reader, char **ppsz_txt )
*/ */
} }
static bool PeekASX( demux_t *p_demux )
{
const uint8_t *p_peek;
return ( stream_Peek( p_demux->s, &p_peek, 12 ) == 12
&& !memcmp( p_peek, "<asx version", 12 ) );
}
/***************************************************************************** /*****************************************************************************
* Import_ASX: main import function * Import_ASX: main import function
*****************************************************************************/ *****************************************************************************/
...@@ -145,6 +152,9 @@ int Import_ASX( vlc_object_t *p_this ) ...@@ -145,6 +152,9 @@ int Import_ASX( vlc_object_t *p_this )
if( demux_IsPathExtension( p_demux, ".asx" ) || if( demux_IsPathExtension( p_demux, ".asx" ) ||
demux_IsPathExtension( p_demux, ".wax" ) || demux_IsPathExtension( p_demux, ".wax" ) ||
demux_IsPathExtension( p_demux, ".wvx" ) || demux_IsPathExtension( p_demux, ".wvx" ) ||
(
CheckContentType( p_demux->s, "video/x-ms-asf" ) && PeekASX( p_demux )
) ||
demux_IsForced( p_demux, "asx-open" ) ) demux_IsForced( p_demux, "asx-open" ) )
{ {
STANDARD_DEMUX_INIT_MSG( "found valid ASX playlist" ); STANDARD_DEMUX_INIT_MSG( "found valid ASX playlist" );
......
...@@ -48,7 +48,6 @@ struct demux_sys_t ...@@ -48,7 +48,6 @@ struct demux_sys_t
static int Demux( demux_t *p_demux); static int Demux( demux_t *p_demux);
static void parseEXTINF( char *psz_string, char **ppsz_artist, char **ppsz_name, int *pi_duration ); static void parseEXTINF( char *psz_string, char **ppsz_artist, char **ppsz_name, int *pi_duration );
static bool ContainsURL( demux_t *p_demux ); static bool ContainsURL( demux_t *p_demux );
static bool CheckContentType( stream_t * p_stream, const char * psz_ctype );
static char *GuessEncoding (const char *str) static char *GuessEncoding (const char *str)
{ {
...@@ -149,24 +148,6 @@ static bool ContainsURL( demux_t *p_demux ) ...@@ -149,24 +148,6 @@ static bool ContainsURL( demux_t *p_demux )
return false; 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_len = strlen( psz_check );
if ( i_len == 0 )
{
free( psz_check );
return false;
}
int i_res = strncasecmp( psz_check, psz_ctype, i_len );
free( psz_check );
return ( i_res == 0 ) ? true : false;
}
/***************************************************************************** /*****************************************************************************
* Deactivate: frees unused data * Deactivate: frees unused data
*****************************************************************************/ *****************************************************************************/
......
...@@ -224,3 +224,29 @@ char *ProcessMRL( const char *psz_mrl, const char *psz_prefix ) ...@@ -224,3 +224,29 @@ char *ProcessMRL( const char *psz_mrl, const char *psz_prefix )
uri: uri:
return vlc_path2uri( psz_mrl, NULL ); return vlc_path2uri( psz_mrl, NULL );
} }
/**
* Checks stream Content-Type against a known one
*/
bool CheckContentType( stream_t * p_stream, const char * psz_ctype )
{
char *psz_check = stream_ContentType( p_stream );
if( !psz_check ) return false;
int i_len = strlen( psz_check );
if ( i_len == 0 )
{
free( psz_check );
return false;
}
/* check for Content-Type: foo-type; charset=... */
const char * psz_sep = index( psz_check, ';' );
if ( psz_sep )
i_len = __MIN( i_len, psz_sep - psz_check );
int i_res = strncasecmp( psz_check, psz_ctype, i_len );
free( psz_check );
return ( i_res == 0 ) ? true : false;
}
...@@ -81,6 +81,8 @@ void Close_ZPL ( vlc_object_t * ); ...@@ -81,6 +81,8 @@ void Close_ZPL ( vlc_object_t * );
extern input_item_t * GetCurrentItem(demux_t *p_demux); extern input_item_t * GetCurrentItem(demux_t *p_demux);
bool CheckContentType( stream_t * p_stream, const char * psz_ctype );
#define STANDARD_DEMUX_INIT_MSG( msg ) do { \ #define STANDARD_DEMUX_INIT_MSG( msg ) do { \
DEMUX_INIT_COMMON(); \ DEMUX_INIT_COMMON(); \
msg_Dbg( p_demux, "%s", msg ); } while(0) msg_Dbg( p_demux, "%s", msg ); } while(0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment