]> git.sesse.net Git - vlc/blob - modules/access/mms/mms.c
Remove WPL module
[vlc] / modules / access / mms / mms.c
1 /*****************************************************************************
2  * mms.c: MMS over tcp, udp and http access plug-in
3  *****************************************************************************
4  * Copyright (C) 2002-2004 VLC authors and VideoLAN
5  * $Id$
6  *
7  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
8  *
9  * This program is free software; you can redistribute it and/or modify it
10  * under the terms of the GNU Lesser General Public License as published by
11  * the Free Software Foundation; either version 2.1 of the License, or
12  * (at your option) any later version.
13  *
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 Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public License
20  * along with this program; if not, write to the Free Software Foundation,
21  * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22  *****************************************************************************/
23
24 /*****************************************************************************
25  * Preamble
26  *****************************************************************************/
27
28 #ifdef HAVE_CONFIG_H
29 # include "config.h"
30 #endif
31
32 #include <vlc_common.h>
33 #include <vlc_plugin.h>
34 #include <vlc_access.h>
35
36 #include "mms.h"
37
38 /****************************************************************************
39  * NOTES:
40  *  MMSProtocole documentation found at http://get.to/sdp
41  ****************************************************************************/
42
43 /*****************************************************************************
44  * Module descriptor
45  *****************************************************************************/
46 static int  Open ( vlc_object_t * );
47 static void Close( vlc_object_t * );
48
49 #define ALL_TEXT N_("Force selection of all streams")
50 #define ALL_LONGTEXT N_( \
51     "MMS streams can contain several elementary streams, with different " \
52     "bitrates. You can choose to select all of them." )
53
54 #define BITRATE_TEXT N_( "Maximum bitrate" )
55 #define BITRATE_LONGTEXT N_( \
56     "Select the stream with the maximum bitrate under that limit."  )
57
58 #define PROXY_TEXT N_("HTTP proxy")
59 #define PROXY_LONGTEXT N_( \
60     "HTTP proxy to be used It must be of the form " \
61     "http://[user[:pass]@]myproxy.mydomain:myport/ ; " \
62     "if empty, the http_proxy environment variable will be tried." )
63
64 #define TIMEOUT_TEXT N_("TCP/UDP timeout (ms)")
65 #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.")
66
67 vlc_module_begin ()
68     set_shortname( "MMS" )
69     set_description( N_("Microsoft Media Server (MMS) input") )
70     set_capability( "access", -1 )
71     set_category( CAT_INPUT )
72     set_subcategory( SUBCAT_INPUT_ACCESS )
73
74     add_integer( "mms-timeout", 5000, TIMEOUT_TEXT, TIMEOUT_LONGTEXT,
75                  true )
76
77     add_bool( "mms-all", false, ALL_TEXT, ALL_LONGTEXT, true )
78     add_integer( "mms-maxbitrate", 0, BITRATE_TEXT, BITRATE_LONGTEXT ,
79                  false )
80     add_string( "mmsh-proxy", NULL, PROXY_TEXT, PROXY_LONGTEXT,
81                     false )
82
83     add_shortcut( "mms", "mmsu", "mmst", "mmsh", "http" )
84     set_callbacks( Open, Close )
85 vlc_module_end ()
86
87 /*****************************************************************************
88  * Local prototypes
89  *****************************************************************************/
90 struct access_sys_t
91 {
92     int i_proto;
93 };
94
95 /*****************************************************************************
96  * Open:
97  *****************************************************************************/
98 static int Open( vlc_object_t *p_this )
99 {
100     access_t *p_access = (access_t*)p_this;
101
102     /* use specified method */
103     if( *p_access->psz_access )
104     {
105         if( !strncmp( p_access->psz_access, "mmsu", 4 ) )
106         {
107             return  MMSTUOpen ( p_access );
108         }
109         else if( !strncmp( p_access->psz_access, "mmst", 4 ) )
110         {
111             return  MMSTUOpen ( p_access );
112         }
113         else if( !strncmp( p_access->psz_access, "mmsh", 4 ) ||
114                  !strncmp( p_access->psz_access, "http", 4 ) )
115         {
116             return  MMSHOpen ( p_access );
117         }
118     }
119
120     if( MMSTUOpen ( p_access ) )
121     {
122         if( !vlc_object_alive(p_access) )
123             return VLC_EGENERIC;
124
125         /* try mmsh if mmstu failed */
126         return  MMSHOpen ( p_access );
127     }
128     return VLC_SUCCESS;
129 }
130
131 /*****************************************************************************
132  * Close: free unused data structures
133  *****************************************************************************/
134 static void Close( vlc_object_t *p_this )
135 {
136     access_t     *p_access = (access_t*)p_this;
137     access_sys_t *p_sys = p_access->p_sys;
138
139     if( ( p_sys->i_proto == MMS_PROTO_TCP ) ||
140         ( p_sys->i_proto == MMS_PROTO_UDP ) )
141     {
142          MMSTUClose ( p_access );
143     }
144     else if( p_sys->i_proto == MMS_PROTO_HTTP )
145     {
146          MMSHClose ( p_access );
147     }
148 }