add_integer: remove callback parameter
[vlc/asuraparaju-public.git] / modules / access / mms / mms.c
blob733d0dcd6a0e8347046006ecf4e13e018d9c9865
1 /*****************************************************************************
2 * mms.c: MMS over tcp, udp and http access plug-in
3 *****************************************************************************
4 * Copyright (C) 2002-2004 the VideoLAN team
5 * $Id$
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 *****************************************************************************/
24 /*****************************************************************************
25 * Preamble
26 *****************************************************************************/
28 #ifdef HAVE_CONFIG_H
29 # include "config.h"
30 #endif
32 #include <vlc_common.h>
33 #include <vlc_plugin.h>
34 #include <vlc_access.h>
36 #include "mms.h"
38 /****************************************************************************
39 * NOTES:
40 * MMSProtocole documentation found at http://get.to/sdp
41 ****************************************************************************/
43 /*****************************************************************************
44 * Module descriptor
45 *****************************************************************************/
46 static int Open ( vlc_object_t * );
47 static void Close( vlc_object_t * );
49 #define CACHING_TEXT N_("Caching value in ms")
50 #define CACHING_LONGTEXT N_( \
51 "Caching value for MMS streams. This " \
52 "value should be set in milliseconds." )
54 #define ALL_TEXT N_("Force selection of all streams")
55 #define ALL_LONGTEXT N_( \
56 "MMS streams can contain several elementary streams, with different " \
57 "bitrates. You can choose to select all of them." )
59 #define BITRATE_TEXT N_( "Maximum bitrate" )
60 #define BITRATE_LONGTEXT N_( \
61 "Select the stream with the maximum bitrate under that limit." )
63 #define PROXY_TEXT N_("HTTP proxy")
64 #define PROXY_LONGTEXT N_( \
65 "HTTP proxy to be used It must be of the form " \
66 "http://[user[:pass]@]myproxy.mydomain:myport/ ; " \
67 "if empty, the http_proxy environment variable will be tried." )
69 #define TIMEOUT_TEXT N_("TCP/UDP timeout (ms)")
70 #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.")
72 vlc_module_begin ()
73 set_shortname( "MMS" )
74 set_description( N_("Microsoft Media Server (MMS) input") )
75 set_capability( "access", -1 )
76 set_category( CAT_INPUT )
77 set_subcategory( SUBCAT_INPUT_ACCESS )
79 add_integer( "mms-caching", 19 * DEFAULT_PTS_DELAY / 1000,
80 CACHING_TEXT, CACHING_LONGTEXT, true )
82 add_integer( "mms-timeout", 5000, TIMEOUT_TEXT, TIMEOUT_LONGTEXT,
83 true )
85 add_bool( "mms-all", false, NULL, ALL_TEXT, ALL_LONGTEXT, true )
86 add_integer( "mms-maxbitrate", 0, BITRATE_TEXT, BITRATE_LONGTEXT ,
87 false )
88 add_string( "mmsh-proxy", NULL, PROXY_TEXT, PROXY_LONGTEXT,
89 false )
91 add_shortcut( "mms", "mmsu", "mmst", "mmsh", "http" )
92 set_callbacks( Open, Close )
93 vlc_module_end ()
95 /*****************************************************************************
96 * Local prototypes
97 *****************************************************************************/
98 struct access_sys_t
100 int i_proto;
103 /*****************************************************************************
104 * Open:
105 *****************************************************************************/
106 static int Open( vlc_object_t *p_this )
108 access_t *p_access = (access_t*)p_this;
110 /* First set ipv4/ipv6 */
111 var_Create( p_access, "ipv4", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
112 var_Create( p_access, "ipv6", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
114 /* mms-caching */
115 var_Create( p_access, "mms-caching", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
117 /* use specified method */
118 if( *p_access->psz_access )
120 if( !strncmp( p_access->psz_access, "mmsu", 4 ) )
122 return MMSTUOpen ( p_access );
124 else if( !strncmp( p_access->psz_access, "mmst", 4 ) )
126 return MMSTUOpen ( p_access );
128 else if( !strncmp( p_access->psz_access, "mmsh", 4 ) ||
129 !strncmp( p_access->psz_access, "http", 4 ) )
131 return MMSHOpen ( p_access );
135 if( MMSTUOpen ( p_access ) )
137 if( p_access->b_die )
138 return VLC_EGENERIC;
140 /* try mmsh if mmstu failed */
141 return MMSHOpen ( p_access );
143 return VLC_SUCCESS;
146 /*****************************************************************************
147 * Close: free unused data structures
148 *****************************************************************************/
149 static void Close( vlc_object_t *p_this )
151 access_t *p_access = (access_t*)p_this;
152 access_sys_t *p_sys = p_access->p_sys;
154 if( ( p_sys->i_proto == MMS_PROTO_TCP ) ||
155 ( p_sys->i_proto == MMS_PROTO_UDP ) )
157 MMSTUClose ( p_access );
159 else if( p_sys->i_proto == MMS_PROTO_HTTP )
161 MMSHClose ( p_access );