contrib: cargo: use cargo/vendored-openssl if needed
[vlc.git] / modules / access / mms / mms.c
blob8aea7d4cf35f092d96fbac9cab479c81f71be760
1 /*****************************************************************************
2 * mms.c: MMS over tcp, udp and http access plug-in
3 *****************************************************************************
4 * Copyright (C) 2002-2004 VLC authors and VideoLAN
6 * Authors: Laurent Aimar <fenrir@via.ecp.fr>
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU Lesser General Public License as published by
10 * the Free Software Foundation; either version 2.1 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with this program; if not, write to the Free Software Foundation,
20 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
21 *****************************************************************************/
23 /*****************************************************************************
24 * Preamble
25 *****************************************************************************/
27 #ifdef HAVE_CONFIG_H
28 # include "config.h"
29 #endif
31 #include <vlc_common.h>
32 #include <vlc_plugin.h>
33 #include <vlc_access.h>
35 #include "mms.h"
37 /****************************************************************************
38 * NOTES:
39 * MMSProtocole documentation found at http://get.to/sdp
40 ****************************************************************************/
42 /*****************************************************************************
43 * Module descriptor
44 *****************************************************************************/
45 static int Open ( vlc_object_t * );
46 static void Close( vlc_object_t * );
48 #define ALL_TEXT N_("Force selection of all streams")
49 #define ALL_LONGTEXT N_( \
50 "MMS streams can contain several elementary streams, with different " \
51 "bitrates. You can choose to select all of them." )
53 #define BITRATE_TEXT N_( "Maximum bitrate" )
54 #define BITRATE_LONGTEXT N_( \
55 "Select the stream with the maximum bitrate under that limit." )
57 #define TIMEOUT_TEXT N_("TCP/UDP timeout (ms)")
58 #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.")
60 vlc_module_begin ()
61 set_shortname( "MMS" )
62 set_description( N_("Microsoft Media Server (MMS) input") )
63 set_capability( "access", -1 )
64 set_category( CAT_INPUT )
65 set_subcategory( SUBCAT_INPUT_ACCESS )
67 add_integer( "mms-timeout", 5000, TIMEOUT_TEXT, TIMEOUT_LONGTEXT,
68 true )
70 add_bool( "mms-all", false, ALL_TEXT, ALL_LONGTEXT, true )
71 add_integer( "mms-maxbitrate", 0, BITRATE_TEXT, BITRATE_LONGTEXT ,
72 false )
73 add_obsolete_string( "mmsh-proxy" ) /* since 3.0.0 */
75 add_shortcut( "mms", "mmsu", "mmst", "mmsh" )
76 set_callbacks( Open, Close )
77 vlc_module_end ()
79 /*****************************************************************************
80 * Local prototypes
81 *****************************************************************************/
82 typedef struct
84 int i_proto;
85 } access_sys_t;
87 /*****************************************************************************
88 * Open:
89 *****************************************************************************/
90 static int Open( vlc_object_t *p_this )
92 stream_t *p_access = (stream_t*)p_this;
94 /* use specified method */
95 if( !strncmp( p_access->psz_name, "mmsu", 4 ) )
96 return MMSTUOpen ( p_access );
97 else if( !strncmp( p_access->psz_name, "mmst", 4 ) )
98 return MMSTUOpen ( p_access );
99 else if( !strncmp( p_access->psz_name, "mmsh", 4 ) )
100 return MMSHOpen ( p_access );
102 if( MMSTUOpen ( p_access ) )
103 { /* try mmsh if mmstu failed */
104 return MMSHOpen ( p_access );
106 return VLC_SUCCESS;
109 /*****************************************************************************
110 * Close: free unused data structures
111 *****************************************************************************/
112 static void Close( vlc_object_t *p_this )
114 stream_t *p_access = (stream_t*)p_this;
115 access_sys_t *p_sys = p_access->p_sys;
117 if( ( p_sys->i_proto == MMS_PROTO_TCP ) ||
118 ( p_sys->i_proto == MMS_PROTO_UDP ) )
120 MMSTUClose ( p_access );
122 else if( p_sys->i_proto == MMS_PROTO_HTTP )
124 MMSHClose ( p_access );