]> git.sesse.net Git - vlc/blobdiff - modules/access/http.c
* http.c: force nsv when using unsv:// and mime is misc/ultravox.
[vlc] / modules / access / http.c
index 3021e778be45a716ba2a0505a260d4a74156a6f1..05be675120a45af501474fc04ec7030dacc886dc 100644 (file)
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * http.c: HTTP input module
  *****************************************************************************
- * Copyright (C) 2001-2004 VideoLAN
+ * Copyright (C) 2001-2005 VideoLAN
  * $Id$
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
@@ -227,7 +227,21 @@ static int Open( vlc_object_t *p_this )
     p_sys->i_remaining = 0;
 
     /* Parse URI */
-    ParseURL( p_sys, p_access->psz_path );
+    if( vlc_UrlIsNotEncoded( p_access->psz_path ) )
+    {
+        psz = vlc_UrlEncode( p_access->psz_path );
+        if( psz == NULL )
+        {
+            free( p_sys );
+            return VLC_ENOMEM;
+        }
+
+        ParseURL( p_sys, psz );
+        free( psz );
+    }
+    else
+        ParseURL( p_sys, p_access->psz_path );
+
     if( p_sys->url.psz_host == NULL || *p_sys->url.psz_host == '\0' )
     {
         msg_Warn( p_access, "invalid host" );
@@ -370,25 +384,39 @@ static int Open( vlc_object_t *p_this )
 
     if( !strcmp( p_sys->psz_protocol, "ICY" ) || p_sys->b_icecast )
     {
-        if( p_sys->psz_mime && ( !strcasecmp( p_sys->psz_mime, "video/nsv" ) ||
-                                 !strcasecmp( p_sys->psz_mime, "video/nsa") ) )
-            p_access->psz_demux = strdup( "nsv" );
-        else if( p_sys->psz_mime &&
-                 ( !strcasecmp( p_sys->psz_mime, "audio/aac" ) ||
-                   !strcasecmp( p_sys->psz_mime, "audio/aacp" ) ) )
-            p_access->psz_demux = strdup( "m4a" );
-        else if( p_sys->psz_mime && !strcasecmp( p_sys->psz_mime, "audio/mpeg" ) )
-            p_access->psz_demux = strdup( "mp3" );
-        else /* assume mp3, though this is definetly not certain */
-            p_access->psz_demux = strdup( "mp3" );
-
-        msg_Info( p_access, "Raw-audio server found, %s demuxer selected",
-                  p_access->psz_demux );
-
-#if 0   /* Doesn't work really well because of the pre-buffering in shoutcast
-         * servers (the buffer content will be sent as fast as possible). */
-        p_sys->b_pace_control = VLC_FALSE;
+        if( p_sys->psz_mime && strcasecmp( p_sys->psz_mime, "application/ogg" ) )
+        {
+            if( !strcasecmp( p_sys->psz_mime, "video/nsv" ) ||
+                !strcasecmp( p_sys->psz_mime, "video/nsa" ) )
+                p_access->psz_demux = strdup( "nsv" );
+            else if( !strcasecmp( p_sys->psz_mime, "audio/aac" ) ||
+                     !strcasecmp( p_sys->psz_mime, "audio/aacp" ) )
+                p_access->psz_demux = strdup( "m4a" );
+            else if( !strcasecmp( p_sys->psz_mime, "audio/mpeg" ) )
+                p_access->psz_demux = strdup( "mp3" );
+
+            msg_Info( p_access, "Raw-audio server found, %s demuxer selected",
+                      p_access->psz_demux );
+
+#if 0       /* Doesn't work really well because of the pre-buffering in
+             * shoutcast servers (the buffer content will be sent as fast as
+             * possible). */
+            p_sys->b_pace_control = VLC_FALSE;
 #endif
+        }
+        else if( !p_sys->psz_mime )
+        {
+             /* Shoutcast */
+             p_access->psz_demux = strdup( "mp3" );
+        }
+        /* else probably Ogg Vorbis */
+    }
+    else if( !strcasecmp( p_access->psz_access, "unsv" ) &&
+             p_sys->psz_mime &&
+             !strcasecmp( p_sys->psz_mime, "misc/ultravox" ) )
+    {
+        /* Grrrr! detect ultravox server and force NSV demuxer */
+        p_access->psz_demux = strdup( "nsv" );
     }
 
     if( p_sys->b_reconnect ) msg_Dbg( p_access, "auto re-connect enabled" );
@@ -618,7 +646,7 @@ static int ReadICYMeta( access_t *p_access )
     if( i_read != buffer[0] * 16 )
         return VLC_EGENERIC;
 
-    psz_meta[buffer[0]*16 + 1] = '\0'; /* Just in case */
+    psz_meta[buffer[0]*16] = '\0'; /* Just in case */
 
     msg_Dbg( p_access, "icy-meta=%s", psz_meta );
 
@@ -699,7 +727,12 @@ static int Control( access_t *p_access, int i_query, va_list args )
         case ACCESS_CAN_PAUSE:
         case ACCESS_CAN_CONTROL_PACE:
             pb_bool = (vlc_bool_t*)va_arg( args, vlc_bool_t* );
+
+#if 0       /* Disable for now until we have a clock synchro algo
+             * which works with something else than MPEG over UDP */
             *pb_bool = p_sys->b_pace_control;
+#endif
+            *pb_bool = VLC_TRUE;
             break;
 
         /* */
@@ -723,13 +756,13 @@ static int Control( access_t *p_access, int i_query, va_list args )
             msg_Dbg( p_access, "GET META %s %s %s",
                      p_sys->psz_icy_name, p_sys->psz_icy_genre, p_sys->psz_icy_title );
             if( p_sys->psz_icy_name )
-                vlc_meta_Add( *pp_meta, VLC_META_DESCRIPTION,
+                vlc_meta_Add( *pp_meta, VLC_META_TITLE,
                               p_sys->psz_icy_name );
             if( p_sys->psz_icy_genre )
                 vlc_meta_Add( *pp_meta, VLC_META_GENRE,
                               p_sys->psz_icy_genre );
             if( p_sys->psz_icy_title )
-                vlc_meta_Add( *pp_meta, VLC_META_TITLE,
+                vlc_meta_Add( *pp_meta, VLC_META_NOW_PLAYING,
                               p_sys->psz_icy_title );
             break;
 
@@ -848,7 +881,7 @@ static int Connect( access_t *p_access, int64_t i_tell )
             return VLC_EGENERIC;
         }
 
-        p_sys->p_tls = tls_ClientCreate( VLC_OBJECT(p_access), NULL, p_sys->fd );
+        p_sys->p_tls = tls_ClientCreate( VLC_OBJECT(p_access), p_sys->fd, NULL );
         if( p_sys->p_tls == NULL )
         {
             msg_Err( p_access, "cannot establish HTTP/SSL session" );
@@ -926,6 +959,7 @@ static int Request( access_t *p_access, int64_t i_tell )
                    p_sys->psz_passwd ? p_sys->psz_passwd : "" );
 
         b64 = vlc_b64_encode( buf );
+        free( buf );
 
         net_Printf( VLC_OBJECT(p_access), p_sys->fd, pvs,
                     "Authorization: Basic %s\r\n", b64 );