]> git.sesse.net Git - vlc/blobdiff - modules/access/mms/mmsh.c
Make Zorglub less unhappy
[vlc] / modules / access / mms / mmsh.c
index a78b3beb0339f16ef786d20509b9fc243591d557..696352ec88573c973fd1f4cd8eea33468643fef8 100644 (file)
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * mmsh.c:
  *****************************************************************************
- * Copyright (C) 2001, 2002 VideoLAN
+ * Copyright (C) 2001, 2002 the VideoLAN team
  * $Id$
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
@@ -66,7 +66,6 @@ int E_(MMSHOpen)( access_t *p_access )
 {
     access_sys_t    *p_sys;
     char            *psz_location = NULL;
-    vlc_value_t     val;
 
     /* init p_sys */
 
@@ -145,9 +144,6 @@ int E_(MMSHOpen)( access_t *p_access )
         p_access->info.i_size = p_sys->asfh.i_file_size;
     }
 
-    /* Update default_pts to a suitable value for mms access */
-    var_Get( p_access, "mms-caching", &val );
-
     return VLC_SUCCESS;
 }
 
@@ -171,7 +167,7 @@ static int Control( access_t *p_access, int i_query, va_list args )
     vlc_bool_t   *pb_bool;
     int          *pi_int;
     int64_t      *pi_64;
-    vlc_value_t  val;
+    int          i_int;
 
     switch( i_query )
     {
@@ -180,11 +176,21 @@ static int Control( access_t *p_access, int i_query, va_list args )
             pb_bool = (vlc_bool_t*)va_arg( args, vlc_bool_t* );
             *pb_bool = !p_sys->b_broadcast;
             break;
+
         case ACCESS_CAN_FASTSEEK:
         case ACCESS_CAN_PAUSE:
+            pb_bool = (vlc_bool_t*)va_arg( args, vlc_bool_t* );
+            *pb_bool = VLC_FALSE;
+            break;
+
         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 = VLC_FALSE;
+#endif
+            *pb_bool = VLC_TRUE;
             break;
 
         /* */
@@ -195,8 +201,16 @@ static int Control( access_t *p_access, int i_query, va_list args )
 
         case ACCESS_GET_PTS_DELAY:
             pi_64 = (int64_t*)va_arg( args, int64_t * );
-            var_Get( p_access, "mms-caching", &val );
-            *pi_64 = val.i_int * 1000;
+            *pi_64 = (int64_t)var_GetInteger( p_access, "mms-caching" ) * I64C(1000);
+            break;
+
+        case ACCESS_GET_PRIVATE_ID_STATE:
+            i_int = (int)va_arg( args, int );
+            pb_bool = (vlc_bool_t*)va_arg( args, vlc_bool_t );
+
+            if( i_int < 0 || i_int > 127 )
+                return VLC_EGENERIC;
+            *pb_bool =  p_sys->asfh.stream[i_int].i_selected ? VLC_TRUE : VLC_FALSE;
             break;
 
         /* */
@@ -204,10 +218,11 @@ static int Control( access_t *p_access, int i_query, va_list args )
         case ACCESS_GET_TITLE_INFO:
         case ACCESS_SET_TITLE:
         case ACCESS_SET_SEEKPOINT:
+        case ACCESS_SET_PRIVATE_ID_STATE:
             return VLC_EGENERIC;
 
         default:
-            msg_Err( p_access, "unimplemented query in control" );
+            msg_Warn( p_access, "unimplemented query in control" );
             return VLC_EGENERIC;
 
     }
@@ -374,12 +389,12 @@ static int Describe( access_t  *p_access, char **ppsz_location )
     if( ( p_sys->fd = net_OpenTCP( p_access, p_sys->url.psz_host,
                                             p_sys->url.i_port ) ) < 0 )
     {
-        msg_Err( p_access, "cannot connect to%s:%d", p_sys->url.psz_host, p_sys->url.i_port );
+        msg_Err( p_access, "cannot connect to %s:%d", p_sys->url.psz_host, p_sys->url.i_port );
         goto error;
     }
 
     /* send first request */
-    net_Printf( VLC_OBJECT(p_access), p_sys->fd,
+    net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL,
                 "GET %s HTTP/1.0\r\n"
                 "Accept: */*\r\n"
                 "User-Agent: NSPlayer/4.1.0.3856\r\n"
@@ -392,14 +407,14 @@ static int Describe( access_t  *p_access, char **ppsz_location )
                 p_sys->i_request_context++,
                 GUID_PRINT( p_sys->guid ) );
 
-    if( net_Printf( VLC_OBJECT(p_access), p_sys->fd, "\r\n" ) < 0 )
+    if( net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL, "\r\n" ) < 0 )
     {
         msg_Err( p_access, "failed to send request" );
         goto error;
     }
 
     /* Receive the http header */
-    if( ( psz = net_Gets( VLC_OBJECT(p_access), p_sys->fd ) ) == NULL )
+    if( ( psz = net_Gets( VLC_OBJECT(p_access), p_sys->fd, NULL ) ) == NULL )
     {
         msg_Err( p_access, "failed to read answer" );
         goto error;
@@ -422,7 +437,7 @@ static int Describe( access_t  *p_access, char **ppsz_location )
     free( psz );
     for( ;; )
     {
-        char *psz = net_Gets( p_access, p_sys->fd );
+        char *psz = net_Gets( p_access, p_sys->fd, NULL );
         char *p;
 
         if( psz == NULL )
@@ -531,10 +546,10 @@ static int Describe( access_t  *p_access, char **ppsz_location )
              p_sys->asfh.i_min_data_packet_size );
 
     E_( asf_StreamSelect)( &p_sys->asfh,
-                           config_GetInt( p_access, "mms-maxbitrate" ),
-                           config_GetInt( p_access, "mms-all" ),
-                           config_GetInt( p_access, "audio" ),
-                           config_GetInt( p_access, "video" ) );
+                           var_CreateGetInteger( p_access, "mms-maxbitrate" ),
+                           var_CreateGetInteger( p_access, "mms-all" ),
+                           var_CreateGetInteger( p_access, "audio" ),
+                           var_CreateGetInteger( p_access, "video" ) );
 
     return VLC_SUCCESS;
 
@@ -580,7 +595,7 @@ static int Start( access_t *p_access, off_t i_pos )
         msg_Err( p_access, "no stream selected" );
         return VLC_EGENERIC;
     }
-    net_Printf( VLC_OBJECT(p_access), p_sys->fd,
+    net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL,
                 "GET %s HTTP/1.0\r\n"
                 "Accept: */*\r\n"
                 "User-Agent: NSPlayer/4.1.0.3856\r\n"
@@ -589,19 +604,19 @@ static int Start( access_t *p_access, off_t i_pos )
                 p_sys->url.psz_host, p_sys->url.i_port );
     if( p_sys->b_broadcast )
     {
-        net_Printf( VLC_OBJECT(p_access), p_sys->fd,
+        net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL,
                     "Pragma: no-cache,rate=1.000000,request-context=%d\r\n",
                     p_sys->i_request_context++ );
     }
     else
     {
-        net_Printf( VLC_OBJECT(p_access), p_sys->fd,
+        net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL,
                     "Pragma: no-cache,rate=1.000000,stream-time=0,stream-offset=%u:%u,request-context=%d,max-duration=0\r\n",
                     (uint32_t)((i_pos >> 32)&0xffffffff),
                     (uint32_t)(i_pos&0xffffffff),
                     p_sys->i_request_context++ );
     }
-    net_Printf( VLC_OBJECT(p_access), p_sys->fd,
+    net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL,
                 "Pragma: xPlayStrm=1\r\n"
                 "Pragma: xClientGUID={"GUID_FMT"}\r\n"
                 "Pragma: stream-switch-count=%d\r\n"
@@ -619,20 +634,21 @@ static int Start( access_t *p_access, off_t i_pos )
                 i_select = 0;
             }
 
-            net_Printf( VLC_OBJECT(p_access), p_sys->fd,
+            net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL,
                         "ffff:%d:%d ", i, i_select );
         }
     }
-    net_Printf( VLC_OBJECT(p_access), p_sys->fd, "\r\n" );
-    net_Printf( VLC_OBJECT(p_access), p_sys->fd, "Connection: Close\r\n" );
+    net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL, "\r\n" );
+    net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL,
+                "Connection: Close\r\n" );
 
-    if( net_Printf( VLC_OBJECT(p_access), p_sys->fd, "\r\n" ) < 0 )
+    if( net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL, "\r\n" ) < 0 )
     {
         msg_Err( p_access, "failed to send request" );
         return VLC_EGENERIC;
     }
 
-    if( ( psz = net_Gets( VLC_OBJECT(p_access), p_sys->fd ) ) == NULL )
+    if( ( psz = net_Gets( VLC_OBJECT(p_access), p_sys->fd, NULL ) ) == NULL )
     {
         msg_Err( p_access, "cannot read data" );
         return VLC_EGENERIC;
@@ -649,7 +665,7 @@ static int Start( access_t *p_access, off_t i_pos )
     /* FIXME check HTTP code */
     for( ;; )
     {
-        char *psz = net_Gets( p_access, p_sys->fd );
+        char *psz = net_Gets( p_access, p_sys->fd, NULL );
         if( psz == NULL )
         {
             msg_Err( p_access, "cannot read data" );
@@ -696,7 +712,7 @@ static int GetPacket( access_t * p_access, chunk_t *p_ck )
     memset( p_ck, 0, sizeof( chunk_t ) );
 
     /* Read the chunk header */
-    if( net_Read( p_access, p_sys->fd, p_sys->buffer, 12, VLC_TRUE ) < 12 )
+    if( net_Read( p_access, p_sys->fd, NULL, p_sys->buffer, 12, VLC_TRUE ) < 12 )
     {
         /* msg_Err( p_access, "cannot read data" ); */
         return VLC_EGENERIC;
@@ -730,7 +746,7 @@ static int GetPacket( access_t * p_access, chunk_t *p_ck )
     }
 
     if( p_ck->i_data > 0 &&
-        net_Read( p_access, p_sys->fd, &p_sys->buffer[12], p_ck->i_data, VLC_TRUE ) < p_ck->i_data )
+        net_Read( p_access, p_sys->fd, NULL, &p_sys->buffer[12], p_ck->i_data, VLC_TRUE ) < p_ck->i_data )
     {
         msg_Err( p_access, "cannot read data" );
         return VLC_EGENERIC;