Changeset f2f15f46eca071e5118bd115fc298cb507872fe4

Show
Ignore:
Timestamp:
06/15/08 15:16:18 (3 months ago)
Author:
Rémi Denis-Courmont <rdenis@simphalempin.com>
git-committer:
Rémi Denis-Courmont <rdenis@simphalempin.com> 1213535778 +0300
git-parent:

[8c032439f9efb3cc5bcadb05cd12b770b1459bf6]

git-author:
bl4 <bl4@playker.info> 1213534720 +0200
Message:

M3U playlist detection

Signed-off-by: Rémi Denis-Courmont <rdenis@simphalempin.com>

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/demux/playlist/m3u.c

    r5dd166a rf2f15f4  
    4848static int Control( demux_t *p_demux, int i_query, va_list args ); 
    4949static void parseEXTINF( char *psz_string, char **ppsz_artist, char **ppsz_name, int *pi_duration ); 
     50static bool ContainsURL( demux_t *p_demux ); 
    5051 
    5152/***************************************************************************** 
     
    6263           /* A .ram file can contain a single rtsp link */ 
    6364           demux_IsPathExtension( p_demux, ".ram" ) || demux_IsPathExtension( p_demux, ".rm" ) || 
    64            demux_IsForced( p_demux,  "m3u" ) ) ) 
     65           demux_IsForced( p_demux,  "m3u" ) || ContainsURL( p_demux ) ) ) 
    6566        return VLC_EGENERIC; 
    6667 
     
    6970 
    7071    return VLC_SUCCESS; 
     72} 
     73 
     74static bool ContainsURL( demux_t *p_demux ) 
     75{ 
     76    uint8_t *p_peek; 
     77    int i_peek; 
     78    uint8_t *p_peek_end; 
     79 
     80    i_peek = stream_Peek( p_demux->s, &p_peek, 1024 ); 
     81    if( i_peek <= 0 ) return false; 
     82    p_peek_end = p_peek + i_peek; 
     83 
     84    while( p_peek + sizeof( "https://" ) < p_peek_end ) 
     85    { 
     86        /* One line starting with an URL is enough */ 
     87        if( !strncasecmp( p_peek, "http://", sizeof( "http://" ) - 1 ) || 
     88            !strncasecmp( p_peek, "mms://", sizeof( "mms://" ) - 1 ) || 
     89            !strncasecmp( p_peek, "rtsp://", sizeof( "rtsp://" ) - 1 ) || 
     90            !strncasecmp( p_peek, "https://", sizeof( "https://" ) - 1 ) || 
     91            !strncasecmp( p_peek, "ftp://", sizeof( "ftp://" ) - 1 ) ) 
     92        { 
     93            return true; 
     94        } 
     95        /* Comments and blank lines are ignored */ 
     96        else if( *p_peek != '#' && *p_peek != '\n' && *p_peek != '\r') 
     97        { 
     98            return false; 
     99        } 
     100 
     101        while( p_peek < p_peek_end && *p_peek != '\n' ) 
     102            p_peek++; 
     103        if ( *p_peek == '\n' ) 
     104            p_peek++; 
     105    } 
     106    return false; 
    71107} 
    72108