1 /*****************************************************************************
2 * mms.c: MMS over tcp, udp and http access plug-in
3 *****************************************************************************
4 * Copyright (C) 2001, 2002 VideoLAN
5 * $Id: mms.c,v 1.34 2003/05/15 22:27:36 massiot Exp $
7 * Authors: Laurent Aimar <fenrir@via.ecp.fr>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
22 *****************************************************************************/
25 /*****************************************************************************
27 *****************************************************************************/
31 #include <vlc/input.h>
35 /****************************************************************************
37 * MMSProtocole documentation found at http://get.to/sdp
38 ****************************************************************************/
40 /*****************************************************************************
42 *****************************************************************************/
50 static int Open ( vlc_object_t * );
51 static void Close ( vlc_object_t * );
54 /*****************************************************************************
56 *****************************************************************************/
57 #define CACHING_TEXT N_("Caching value in ms")
58 #define CACHING_LONGTEXT N_( \
59 "Allows you to modify the default caching value for mms streams. This " \
60 "value should be set in miliseconds units." )
63 set_description( _("Microsoft Media Server (MMS) input") );
64 set_capability( "access", 0 );
65 add_category_hint( "stream", NULL, VLC_TRUE );
66 add_integer( "mms-caching", 4 * DEFAULT_PTS_DELAY / 1000, NULL,
67 CACHING_TEXT, CACHING_LONGTEXT, VLC_TRUE );
69 add_bool( "mms-all", 0, NULL,
70 "force selection of all streams",
71 "force selection of all streams", VLC_TRUE );
73 add_string( "mms-stream", NULL, NULL,
75 "force this stream selection", VLC_TRUE );
77 add_integer( "mms-maxbitrate", 0, NULL,
79 "set max bitrate for auto streams selections", VLC_FALSE );
80 add_shortcut( "mms" );
81 add_shortcut( "mmsu" );
82 add_shortcut( "mmst" );
83 add_shortcut( "mmsh" );
84 set_callbacks( Open, Close );
88 static int Open( vlc_object_t *p_this )
90 input_thread_t *p_input = (input_thread_t*)p_this;
95 if( *p_input->psz_access )
97 if( !strncmp( p_input->psz_access, "mmsu", 4 ) )
99 return E_( MMSTUOpen )( p_input );
101 else if( !strncmp( p_input->psz_access, "mmst", 4 ) )
103 return E_( MMSTUOpen )( p_input );
105 else if( !strncmp( p_input->psz_access, "mmsh", 4 ) )
107 return E_( MMSHOpen )( p_input );
112 i_err = E_( MMSTUOpen )( p_input );
116 i_err = E_( MMSHOpen )( p_input );
122 /*****************************************************************************
123 * Close: free unused data structures
124 *****************************************************************************/
125 static void Close( vlc_object_t *p_this )
127 input_thread_t * p_input = (input_thread_t *)p_this;
128 access_sys_t * p_sys = p_input->p_access_data;
130 if( p_sys->i_proto == MMS_PROTO_TCP || p_sys->i_proto == MMS_PROTO_UDP )
132 E_( MMSTUClose )( p_input );
134 else if( p_sys->i_proto == MMS_PROTO_HTTP )
136 E_( MMSHClose )( p_input );
140 /****************************************************************************
141 * parse hostname:port/path@username:password
142 * FIXME ipv6 ip will be baddly parsed (contain ':' )
143 ****************************************************************************/
144 url_t *E_( url_new ) ( char * psz_url )
146 url_t *p_url = malloc( sizeof( url_t ) );
148 char *psz_dup = strdup( psz_url );
149 char *psz_parser = psz_dup;
153 /* 1: get hostname:port */
154 while( *psz_parser == '/' )
159 psz_tmp = psz_parser;
161 while( *psz_parser &&
162 *psz_parser != ':' && *psz_parser != '/' && *psz_parser != '@' )
167 p_url->psz_host = strndup( psz_tmp, psz_parser - psz_tmp );
169 if( *psz_parser == ':' )
172 psz_tmp = psz_parser;
174 while( *psz_parser && *psz_parser != '/' && *psz_parser != '@' )
178 p_url->i_port = atoi( psz_tmp );
186 if( *psz_parser == '/' )
190 psz_tmp = psz_parser;
192 while( *psz_parser && *psz_parser != '@' )
197 p_url->psz_path = strndup( psz_tmp, psz_parser - psz_tmp );
201 p_url->psz_path = strdup( "" );
204 /* 3: usrname and password */
205 if( *psz_parser == '@' )
209 psz_tmp = psz_parser;
211 while( *psz_parser && *psz_parser != ':' )
216 p_url->psz_username = strndup( psz_tmp, psz_parser - psz_tmp );
218 if( *psz_parser == ':' )
222 p_url->psz_password = strdup( psz_parser );
226 p_url->psz_password = strdup( "" );
231 p_url->psz_username = strdup( "" );
232 p_url->psz_password = strdup( "" );
236 "host=`%s' port=%d path=`%s' username=`%s' password=`%s'\n",
241 p_url->psz_password );
247 void E_( url_free ) ( url_t * p_url )
249 free( p_url->psz_host );
250 free( p_url->psz_path );
251 free( p_url->psz_username );
252 free( p_url->psz_password );