1 /*****************************************************************************
2 * mms.c: MMS over tcp, udp and http access plug-in
3 *****************************************************************************
4 * Copyright (C) 2002-2004 the VideoLAN team
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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
25 /*****************************************************************************
27 *****************************************************************************/
30 #include <vlc_access.h>
34 /****************************************************************************
36 * MMSProtocole documentation found at http://get.to/sdp
37 ****************************************************************************/
39 /*****************************************************************************
41 *****************************************************************************/
42 static int Open ( vlc_object_t * );
43 static void Close( vlc_object_t * );
45 #define CACHING_TEXT N_("Caching value in ms")
46 #define CACHING_LONGTEXT N_( \
47 "Caching value for MMS streams. This " \
48 "value should be set in milliseconds." )
50 #define ALL_TEXT N_("Force selection of all streams")
51 #define ALL_LONGTEXT N_( \
52 "MMS streams can contain several elementary streams, with different " \
53 "bitrates. You can choose to select all of them." )
55 #define BITRATE_TEXT N_( "Maximum bitrate" )
56 #define BITRATE_LONGTEXT N_( \
57 "Select the stream with the maximum bitrate under that limit." )
59 #define PROXY_TEXT N_("HTTP proxy")
60 #define PROXY_LONGTEXT N_( \
61 "HTTP proxy to be used It must be of the form " \
62 "http://[user[:pass]@]myproxy.mydomain:myport/ ; " \
63 "if empty, the http_proxy environment variable will be tried." )
66 set_shortname( "MMS" );
67 set_description( _("Microsoft Media Server (MMS) input") );
68 set_capability( "access2", -1 );
69 set_category( CAT_INPUT );
70 set_subcategory( SUBCAT_INPUT_ACCESS );
72 add_integer( "mms-caching", 19 * DEFAULT_PTS_DELAY / 1000, NULL,
73 CACHING_TEXT, CACHING_LONGTEXT, VLC_TRUE );
75 add_bool( "mms-all", 0, NULL, ALL_TEXT, ALL_LONGTEXT, VLC_TRUE );
76 add_integer( "mms-maxbitrate", 0, NULL, BITRATE_TEXT, BITRATE_LONGTEXT ,
78 add_string( "mmsh-proxy", NULL, NULL, PROXY_TEXT, PROXY_LONGTEXT,
81 add_shortcut( "mms" );
82 add_shortcut( "mmsu" );
83 add_shortcut( "mmst" );
84 add_shortcut( "mmsh" );
85 add_shortcut( "http" );
86 set_callbacks( Open, Close );
89 /*****************************************************************************
91 *****************************************************************************/
98 /*****************************************************************************
100 *****************************************************************************/
101 static int Open( vlc_object_t *p_this )
103 access_t *p_access = (access_t*)p_this;
105 /* First set ipv4/ipv6 */
106 var_Create( p_access, "ipv4", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
107 var_Create( p_access, "ipv6", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
110 var_Create( p_access, "mms-caching", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
112 /* use specified method */
113 if( *p_access->psz_access )
115 if( !strncmp( p_access->psz_access, "mmsu", 4 ) )
117 return E_( MMSTUOpen )( p_access );
119 else if( !strncmp( p_access->psz_access, "mmst", 4 ) )
121 return E_( MMSTUOpen )( p_access );
123 else if( !strncmp( p_access->psz_access, "mmsh", 4 ) ||
124 !strncmp( p_access->psz_access, "http", 4 ) )
126 return E_( MMSHOpen )( p_access );
130 if( E_( MMSTUOpen )( p_access ) )
132 /* try mmsh if mmstu failed */
133 return E_( MMSHOpen )( p_access );
138 /*****************************************************************************
139 * Close: free unused data structures
140 *****************************************************************************/
141 static void Close( vlc_object_t *p_this )
143 access_t *p_access = (access_t*)p_this;
144 access_sys_t *p_sys = p_access->p_sys;
146 if( p_sys->i_proto == MMS_PROTO_TCP || p_sys->i_proto == MMS_PROTO_UDP )
148 E_( MMSTUClose )( p_access );
150 else if( p_sys->i_proto == MMS_PROTO_HTTP )
152 E_( MMSHClose )( p_access );