]> git.sesse.net Git - vlc/blobdiff - modules/access/mms/mms.c
Update LGPL license blurb, choosing v2.1+.
[vlc] / modules / access / mms / mms.c
index 47f5d6e8188fa570a0adcf7f6de16c22ff874c36..18f198c4226eb489cfa9dc76e6d6daa71ddb62d1 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>
  *
  *
  * 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.
  *****************************************************************************/
 
-
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
-#include <stdlib.h>
 
-#include <vlc/vlc.h>
-#include <vlc/input.h>
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <vlc_common.h>
+#include <vlc_plugin.h>
+#include <vlc_access.h>
 
 #include "mms.h"
 
  ****************************************************************************/
 
 /*****************************************************************************
- * Local prototypes
+ * Module descriptor
  *****************************************************************************/
+static int  Open ( vlc_object_t * );
+static void Close( vlc_object_t * );
 
+#define CACHING_TEXT N_("Caching value in ms")
+#define CACHING_LONGTEXT N_( \
+    "Caching value for MMS streams. This " \
+    "value should be set in milliseconds." )
+
+#define ALL_TEXT N_("Force selection of all streams")
+#define ALL_LONGTEXT N_( \
+    "MMS streams can contain several elementary streams, with different " \
+    "bitrates. You can choose to select all of them." )
+
+#define BITRATE_TEXT N_( "Maximum bitrate" )
+#define BITRATE_LONGTEXT N_( \
+    "Select the stream with the maximum bitrate under that limit."  )
+
+#define PROXY_TEXT N_("HTTP proxy")
+#define PROXY_LONGTEXT N_( \
+    "HTTP proxy to be used It must be of the form " \
+    "http://[user[:pass]@]myproxy.mydomain:myport/ ; " \
+    "if empty, the http_proxy environment variable will be tried." )
+
+#define TIMEOUT_TEXT N_("TCP/UDP timeout (ms)")
+#define TIMEOUT_LONGTEXT N_("Amount of time (in ms) to wait before aborting network reception of data. Note that there will be 10 retries before completely giving up.")
+
+vlc_module_begin ()
+    set_shortname( "MMS" )
+    set_description( N_("Microsoft Media Server (MMS) input") )
+    set_capability( "access", -1 )
+    set_category( CAT_INPUT )
+    set_subcategory( SUBCAT_INPUT_ACCESS )
+
+    add_integer( "mms-caching", 19 * DEFAULT_PTS_DELAY / 1000, NULL,
+                 CACHING_TEXT, CACHING_LONGTEXT, true )
+
+    add_integer( "mms-timeout", 5000, NULL, TIMEOUT_TEXT, TIMEOUT_LONGTEXT,
+                 true )
+
+    add_bool( "mms-all", false, NULL, ALL_TEXT, ALL_LONGTEXT, true )
+    add_integer( "mms-maxbitrate", 0, NULL, BITRATE_TEXT, BITRATE_LONGTEXT ,
+                 false )
+    add_string( "mmsh-proxy", NULL, NULL, PROXY_TEXT, PROXY_LONGTEXT,
+                    false )
+
+    add_shortcut( "mms", "mmsu", "mmst", "mmsh", "http" )
+    set_callbacks( Open, Close )
+vlc_module_end ()
+
+/*****************************************************************************
+ * Local prototypes
+ *****************************************************************************/
 struct access_sys_t
 {
     int i_proto;
-
 };
 
-static int  Open        ( vlc_object_t * );
-static void Close       ( vlc_object_t * );
-
-
 /*****************************************************************************
- * Module descriptor
+ * Open:
  *****************************************************************************/
-#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." )
-
-vlc_module_begin();
-    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 );
-    add_shortcut( "mms" );
-    add_shortcut( "mmsu" );
-    add_shortcut( "mmst" );
-    add_shortcut( "mmsh" );
-    set_callbacks( Open, Close );
-vlc_module_end();
-
-
 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  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  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  MMSHOpen ( p_access );
         }
     }
 
-
-    i_err = E_( MMSTUOpen )( p_input );
-
-    if( i_err )
+    if( MMSTUOpen ( p_access ) )
     {
-        i_err = E_( MMSHOpen )( p_input );
-    }
+        if( p_access->b_die )
+            return VLC_EGENERIC;
 
-    return i_err;
+        /* try mmsh if mmstu failed */
+        return  MMSHOpen ( p_access );
+    }
+    return VLC_SUCCESS;
 }
 
 /*****************************************************************************
@@ -124,131 +148,16 @@ 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 )
+    if( ( p_sys->i_proto == MMS_PROTO_TCP ) ||
+        ( p_sys->i_proto == MMS_PROTO_UDP ) )
     {
-        E_( MMSTUClose )( p_input );
+         MMSTUClose ( p_access );
     }
     else if( p_sys->i_proto == MMS_PROTO_HTTP )
     {
-        E_( MMSHClose )( p_input );
+         MMSHClose ( p_access );
     }
 }
-
-/****************************************************************************
- * 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++;
-    }
-
-    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 );
-}