1
/*****************************************************************************
2
* mms.c: MMS over tcp, udp and http access plug-in
3
*****************************************************************************
4
* Copyright (C) 2002-2004 VideoLAN
5
* $Id: mms.c 7522 2004-04-27 16:35:15Z sam $
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 millisecond units." )
62
#define ALL_TEXT N_("Force selection of all streams")
64
#define BITRATE_TEXT N_("Select maximum bitrate stream")
65
#define BITRATE_LONGTEXT N_( \
66
"Always select the stream with the maximum bitrate." )
69
set_description( _("Microsoft Media Server (MMS) input") );
70
set_capability( "access", 0 );
72
add_integer( "mms-caching", 4 * DEFAULT_PTS_DELAY / 1000, NULL,
73
CACHING_TEXT, CACHING_LONGTEXT, VLC_TRUE );
75
add_bool( "mms-all", 0, NULL, ALL_TEXT, "", VLC_TRUE );
76
add_integer( "mms-maxbitrate", 0, NULL, BITRATE_TEXT, BITRATE_LONGTEXT ,
79
add_shortcut( "mms" );
80
add_shortcut( "mmsu" );
81
add_shortcut( "mmst" );
82
add_shortcut( "mmsh" );
83
set_callbacks( Open, Close );
86
/*****************************************************************************
88
*****************************************************************************/
89
static int Open( vlc_object_t *p_this )
91
input_thread_t *p_input = (input_thread_t*)p_this;
93
/* First set ipv4/ipv6 */
94
var_Create( p_input, "ipv4", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
95
var_Create( p_input, "ipv6", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
98
var_Create( p_input, "mms-caching", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
100
/* use specified method */
101
if( *p_input->psz_access )
103
if( !strncmp( p_input->psz_access, "mmsu", 4 ) )
105
return E_( MMSTUOpen )( p_input );
107
else if( !strncmp( p_input->psz_access, "mmst", 4 ) )
109
return E_( MMSTUOpen )( p_input );
111
else if( !strncmp( p_input->psz_access, "mmsh", 4 ) )
113
return E_( MMSHOpen )( p_input );
117
if( E_( MMSTUOpen )( p_input ) )
119
/* try mmsh if mmstu failed */
120
return E_( MMSHOpen )( p_input );
125
/*****************************************************************************
126
* Close: free unused data structures
127
*****************************************************************************/
128
static void Close( vlc_object_t *p_this )
130
input_thread_t * p_input = (input_thread_t *)p_this;
131
access_sys_t * p_sys = p_input->p_access_data;
133
if( p_sys->i_proto == MMS_PROTO_TCP || p_sys->i_proto == MMS_PROTO_UDP )
135
E_( MMSTUClose )( p_input );
137
else if( p_sys->i_proto == MMS_PROTO_HTTP )
139
E_( MMSHClose )( p_input );
143
/****************************************************************************
144
* parse hostname:port/path@username:password
145
* FIXME ipv6 ip will be baddly parsed (contain ':' )
146
****************************************************************************/
147
url_t *E_( url_new ) ( char * psz_url )
149
url_t *p_url = malloc( sizeof( url_t ) );
151
char *psz_dup = strdup( psz_url );
152
char *psz_parser = psz_dup;
156
/* 1: get hostname:port */
157
while( *psz_parser == '/' )
162
psz_tmp = psz_parser;
164
while( *psz_parser &&
165
*psz_parser != ':' && *psz_parser != '/' && *psz_parser != '@' )
170
p_url->psz_host = strndup( psz_tmp, psz_parser - psz_tmp );
172
if( *psz_parser == ':' )
175
psz_tmp = psz_parser;
177
while( *psz_parser && *psz_parser != '/' && *psz_parser != '@' )
181
p_url->i_port = atoi( psz_tmp );
189
if( *psz_parser == '/' )
193
psz_tmp = psz_parser;
195
while( *psz_parser && *psz_parser != '@' )
200
p_url->psz_path = strndup( psz_tmp, psz_parser - psz_tmp );
204
p_url->psz_path = strdup( "" );
207
/* 3: usrname and password */
208
if( *psz_parser == '@' )
212
psz_tmp = psz_parser;
214
while( *psz_parser && *psz_parser != ':' )
219
p_url->psz_username = strndup( psz_tmp, psz_parser - psz_tmp );
221
if( *psz_parser == ':' )
225
p_url->psz_password = strdup( psz_parser );
229
p_url->psz_password = strdup( "" );
234
p_url->psz_username = strdup( "" );
235
p_url->psz_password = strdup( "" );
239
"host=`%s' port=%d path=`%s' username=`%s' password=`%s'\n",
244
p_url->psz_password );
250
void E_( url_free ) ( url_t * p_url )
252
free( p_url->psz_host );
253
free( p_url->psz_path );
254
free( p_url->psz_username );
255
free( p_url->psz_password );