X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;ds=sidebyside;f=modules%2Faccess%2Fmms%2Fmms.c;h=18f198c4226eb489cfa9dc76e6d6daa71ddb62d1;hb=c60652e38ac6afd74bd8225e9dae5406f13aaa4f;hp=7808e4c0a1449acf40113075740d54f1d8a02c9b;hpb=630d42d5a3771b4d841233b9b1f1a326225e2319;p=vlc diff --git a/modules/access/mms/mms.c b/modules/access/mms/mms.c index 7808e4c0a1..18f198c422 100644 --- a/modules/access/mms/mms.c +++ b/modules/access/mms/mms.c @@ -1,8 +1,8 @@ /***************************************************************************** * mms.c: MMS over tcp, udp and http access plug-in ***************************************************************************** - * Copyright (C) 2002-2004 VideoLAN - * $Id: mms.c,v 1.36 2004/01/25 17:31:22 gbazin Exp $ + * Copyright (C) 2002-2004 the VideoLAN team + * $Id$ * * Authors: Laurent Aimar * @@ -18,17 +18,20 @@ * * 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 -#include -#include +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include +#include +#include #include "mms.h" @@ -37,87 +40,105 @@ * MMSProtocole documentation found at http://get.to/sdp ****************************************************************************/ -/***************************************************************************** - * Local prototypes - *****************************************************************************/ - -struct access_sys_t -{ - int i_proto; - -}; - -static int Open ( vlc_object_t * ); -static void Close ( vlc_object_t * ); - - /***************************************************************************** * 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_( \ - "Allows you to modify the default caching value for mms streams. This " \ - "value should be set in miliseconds units." ) + "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_("Selct maximum bitrate stream") +#define BITRATE_TEXT N_( "Maximum bitrate" ) #define BITRATE_LONGTEXT N_( \ - "Always select the stream with the maximum bitrate." ) + "Select the stream with the maximum bitrate under that limit." ) -vlc_module_begin(); - set_description( _("Microsoft Media Server (MMS) input") ); - set_capability( "access", 0 ); +#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." ) - add_integer( "mms-caching", 4 * DEFAULT_PTS_DELAY / 1000, NULL, - CACHING_TEXT, CACHING_LONGTEXT, VLC_TRUE ); +#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.") - add_bool( "mms-all", 0, NULL, ALL_TEXT, "", VLC_TRUE ); +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 , - VLC_FALSE ); + false ) + add_string( "mmsh-proxy", NULL, NULL, PROXY_TEXT, PROXY_LONGTEXT, + false ) - add_shortcut( "mms" ); - add_shortcut( "mmsu" ); - add_shortcut( "mmst" ); - add_shortcut( "mmsh" ); - set_callbacks( Open, Close ); -vlc_module_end(); + add_shortcut( "mms", "mmsu", "mmst", "mmsh", "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; /* First set ipv4/ipv6 */ - var_Create( p_input, "ipv4", VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); - var_Create( p_input, "ipv6", VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); + 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_input, "mms-caching", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); + var_Create( p_access, "mms-caching", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); /* use specified method */ - if( *p_input->psz_access ) + 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 ); } } - if( E_( MMSTUOpen )( p_input ) ) + if( MMSTUOpen ( p_access ) ) { + if( p_access->b_die ) + return VLC_EGENERIC; + /* try mmsh if mmstu failed */ - return E_( MMSHOpen )( p_input ); + return MMSHOpen ( p_access ); } return VLC_SUCCESS; } @@ -127,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 ); - } -} - -/**************************************************************************** - * 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++; + 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 ); }