]> git.sesse.net Git - vlc/blobdiff - modules/access/mms/mms.c
FSF address change.
[vlc] / modules / access / mms / mms.c
index 47f5d6e8188fa570a0adcf7f6de16c22ff874c36..28489b96bdf7d32589c3359bad1dce618cb98a50 100644 (file)
@@ -1,8 +1,8 @@
 /*****************************************************************************
  * mms.c: MMS over tcp, udp and http access plug-in
  *****************************************************************************
- * Copyright (C) 2001, 2002 VideoLAN
- * $Id: mms.c,v 1.33 2003/05/06 02:01:35 fenrir Exp $
+ * Copyright (C) 2002-2004 the VideoLAN team
+ * $Id$
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  *
@@ -18,7 +18,7 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
 
  ****************************************************************************/
 
 /*****************************************************************************
- * Local prototypes
+ * Module descriptor
  *****************************************************************************/
+static int  Open ( vlc_object_t * );
+static void Close( vlc_object_t * );
 
-struct access_sys_t
-{
-    int i_proto;
-
-};
+#define CACHING_TEXT N_("Caching value in ms")
+#define CACHING_LONGTEXT N_( \
+    "Allows you to modify the default caching value for MMS streams. This " \
+    "value should be set in millisecond units." )
 
-static int  Open        ( vlc_object_t * );
-static void Close       ( vlc_object_t * );
+#define ALL_TEXT N_("Force selection of all streams")
 
-
-/*****************************************************************************
- * Module descriptor
- *****************************************************************************/
-#define CACHING_TEXT N_("caching value in ms")
-#define CACHING_LONGTEXT N_( \
-    "Allows you to modify the default caching value for mms streams. This " \
-    "value should be set in miliseconds units." )
+#define BITRATE_TEXT N_( "Maximum bitrate" )
+#define BITRATE_LONGTEXT N_( \
+    "If this is set, the stream with the maximum bitrate under that limit \
+     will be selected" )
 
 vlc_module_begin();
+    set_shortname( "MMS" );
     set_description( _("Microsoft Media Server (MMS) input") );
-    set_capability( "access", 0 );
-    add_category_hint( "stream", NULL, VLC_TRUE );
-        add_integer( "mms-caching", 4 * DEFAULT_PTS_DELAY / 1000, NULL,
-                     CACHING_TEXT, CACHING_LONGTEXT, VLC_TRUE );
-
-        add_bool( "mms-all", 0, NULL,
-                  "force selection of all streams",
-                  "force selection of all streams", VLC_TRUE );
-#if 0
-        add_string( "mms-stream", NULL, NULL,
-                    "streams selection",
-                    "force this stream selection", VLC_TRUE );
-#endif
-        add_integer( "mms-maxbitrate", 0, NULL,
-                     "max bitrate",
-                     "set max bitrate for auto streams selections", VLC_FALSE );
+    set_capability( "access2", -1 );
+    set_category( CAT_INPUT );
+    set_subcategory( SUBCAT_INPUT_ACCESS );
+
+    add_integer( "mms-caching", 19 * DEFAULT_PTS_DELAY / 1000, NULL,
+                 CACHING_TEXT, CACHING_LONGTEXT, VLC_TRUE );
+
+    add_bool( "mms-all", 0, NULL, ALL_TEXT, "", VLC_TRUE );
+    add_integer( "mms-maxbitrate", 0, NULL, BITRATE_TEXT, BITRATE_LONGTEXT ,
+                 VLC_FALSE );
+
     add_shortcut( "mms" );
     add_shortcut( "mmsu" );
     add_shortcut( "mmst" );
     add_shortcut( "mmsh" );
+    add_shortcut( "http" );
     set_callbacks( Open, Close );
 vlc_module_end();
 
+/*****************************************************************************
+ * Local prototypes
+ *****************************************************************************/
+struct access_sys_t
+{
+    int i_proto;
+};
+
 
+/*****************************************************************************
+ * Open:
+ *****************************************************************************/
 static int Open( vlc_object_t *p_this )
 {
-    input_thread_t  *p_input = (input_thread_t*)p_this;
+    access_t *p_access = (access_t*)p_this;
 
-    int i_err;
+    /* First set ipv4/ipv6 */
+    var_Create( p_access, "ipv4", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
+    var_Create( p_access, "ipv6", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
 
+    /* mms-caching */
+    var_Create( p_access, "mms-caching", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
 
-    if( *p_input->psz_access )
+    /* use specified method */
+    if( *p_access->psz_access )
     {
-        if( !strncmp( p_input->psz_access, "mmsu", 4 ) )
+        if( !strncmp( p_access->psz_access, "mmsu", 4 ) )
         {
-            return E_( MMSTUOpen )( p_input );
+            return E_( MMSTUOpen )( p_access );
         }
-        else if( !strncmp( p_input->psz_access, "mmst", 4 ) )
+        else if( !strncmp( p_access->psz_access, "mmst", 4 ) )
         {
-            return E_( MMSTUOpen )( p_input );
+            return E_( MMSTUOpen )( p_access );
         }
-        else if( !strncmp( p_input->psz_access, "mmsh", 4 ) )
+        else if( !strncmp( p_access->psz_access, "mmsh", 4 ) ||
+                 !strncmp( p_access->psz_access, "http", 4 ) )
         {
-            return E_( MMSHOpen )( p_input );
+            return E_( MMSHOpen )( p_access );
         }
     }
 
-
-    i_err = E_( MMSTUOpen )( p_input );
-
-    if( i_err )
+    if( E_( MMSTUOpen )( p_access ) )
     {
-        i_err = E_( MMSHOpen )( p_input );
+        /* try mmsh if mmstu failed */
+        return E_( MMSHOpen )( p_access );
     }
-
-    return i_err;
+    return VLC_SUCCESS;
 }
 
 /*****************************************************************************
@@ -124,131 +131,15 @@ static int Open( vlc_object_t *p_this )
  *****************************************************************************/
 static void Close( vlc_object_t *p_this )
 {
-    input_thread_t *  p_input = (input_thread_t *)p_this;
-    access_sys_t   *  p_sys   = p_input->p_access_data;
+    access_t     *p_access = (access_t*)p_this;
+    access_sys_t *p_sys = p_access->p_sys;
 
     if( p_sys->i_proto == MMS_PROTO_TCP || p_sys->i_proto == MMS_PROTO_UDP )
     {
-        E_( MMSTUClose )( p_input );
+        E_( MMSTUClose )( p_access );
     }
     else if( p_sys->i_proto == MMS_PROTO_HTTP )
     {
-        E_( MMSHClose )( p_input );
-    }
-}
-
-/****************************************************************************
- * parse hostname:port/path@username:password
- * FIXME ipv6 ip will be baddly parsed (contain ':' )
- ****************************************************************************/
-url_t *E_( url_new )  ( char * psz_url )
-{
-    url_t *p_url = malloc( sizeof( url_t ) );
-
-    char  *psz_dup    = strdup( psz_url );
-    char  *psz_parser = psz_dup;
-
-    char  *psz_tmp;
-
-    /* 1: get hostname:port */
-    while( *psz_parser == '/' )
-    {
-        psz_parser++;
+        E_( MMSHClose )( p_access );
     }
-
-    psz_tmp = psz_parser;
-
-    while( *psz_parser &&
-           *psz_parser != ':' &&  *psz_parser != '/' && *psz_parser != '@' )
-    {
-        psz_parser++;
-    }
-
-    p_url->psz_host     = strndup( psz_tmp, psz_parser - psz_tmp );
-
-    if( *psz_parser == ':' )
-    {
-        psz_parser++;
-        psz_tmp = psz_parser;
-
-        while( *psz_parser && *psz_parser != '/' && *psz_parser != '@' )
-        {
-            psz_parser++;
-        }
-        p_url->i_port = atoi( psz_tmp );
-    }
-    else
-    {
-        p_url->i_port = 0;
-    }
-
-    /* 2: get path */
-    if( *psz_parser == '/' )
-    {
-        //psz_parser++;
-
-        psz_tmp = psz_parser;
-
-        while( *psz_parser && *psz_parser != '@' )
-        {
-            psz_parser++;
-        }
-
-        p_url->psz_path = strndup( psz_tmp, psz_parser - psz_tmp );
-    }
-    else
-    {
-        p_url->psz_path = strdup( "" );
-    }
-
-    /* 3: usrname and password */
-    if( *psz_parser == '@' )
-    {
-        psz_parser++;
-
-        psz_tmp = psz_parser;
-
-        while( *psz_parser && *psz_parser != ':' )
-        {
-            psz_parser++;
-        }
-
-        p_url->psz_username = strndup( psz_tmp, psz_parser - psz_tmp );
-
-        if( *psz_parser == ':' )
-        {
-            psz_parser++;
-
-            p_url->psz_password = strdup( psz_parser );
-        }
-        else
-        {
-            p_url->psz_password = strdup( "" );
-        }
-    }
-    else
-    {
-        p_url->psz_username = strdup( "" );
-        p_url->psz_password = strdup( "" );
-    }
-#if 0
-    fprintf( stderr,
-             "host=`%s' port=%d path=`%s' username=`%s' password=`%s'\n",
-             p_url->psz_host,
-             p_url->i_port,
-             p_url->psz_path,
-             p_url->psz_username,
-             p_url->psz_password );
-#endif
-    free( psz_dup );
-    return p_url;
-}
-
-void   E_( url_free ) ( url_t * p_url )
-{
-    free( p_url->psz_host );
-    free( p_url->psz_path );
-    free( p_url->psz_username );
-    free( p_url->psz_password );
-    free( p_url );
 }