]> git.sesse.net Git - vlc/blob - modules/access/mms/mms.c
update module LIST file.
[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 the VideoLAN team
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
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.
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 General Public License for more details.
18  *
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  *****************************************************************************/
23
24 /*****************************************************************************
25  * Preamble
26  *****************************************************************************/
27
28 #ifdef HAVE_CONFIG_H
29 # include "config.h"
30 #endif
31
32 #include <vlc/vlc.h>
33 #include <vlc_access.h>
34
35 #include "mms.h"
36
37 /****************************************************************************
38  * NOTES:
39  *  MMSProtocole documentation found at http://get.to/sdp
40  ****************************************************************************/
41
42 /*****************************************************************************
43  * Module descriptor
44  *****************************************************************************/
45 static int  Open ( vlc_object_t * );
46 static void Close( vlc_object_t * );
47
48 #define CACHING_TEXT N_("Caching value in ms")
49 #define CACHING_LONGTEXT N_( \
50     "Caching value for MMS streams. This " \
51     "value should be set in milliseconds." )
52
53 #define ALL_TEXT N_("Force selection of all streams")
54 #define ALL_LONGTEXT N_( \
55     "MMS streams can contain several elementary streams, with different " \
56     "bitrates. You can choose to select all of them." )
57
58 #define BITRATE_TEXT N_( "Maximum bitrate" )
59 #define BITRATE_LONGTEXT N_( \
60     "Select the stream with the maximum bitrate under that limit."  )
61
62 #define PROXY_TEXT N_("HTTP proxy")
63 #define PROXY_LONGTEXT N_( \
64     "HTTP proxy to be used It must be of the form " \
65     "http://[user[:pass]@]myproxy.mydomain:myport/ ; " \
66     "if empty, the http_proxy environment variable will be tried." )
67
68 #define TIMEOUT_TEXT N_("TCP/UDP timeout (ms)")
69 #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.")
70
71 vlc_module_begin();
72     set_shortname( "MMS" );
73     set_description( _("Microsoft Media Server (MMS) input") );
74     set_capability( "access2", -1 );
75     set_category( CAT_INPUT );
76     set_subcategory( SUBCAT_INPUT_ACCESS );
77
78     add_integer( "mms-caching", 19 * DEFAULT_PTS_DELAY / 1000, NULL,
79                  CACHING_TEXT, CACHING_LONGTEXT, VLC_TRUE );
80
81     add_integer( "mms-timeout", 5000, NULL, TIMEOUT_TEXT, TIMEOUT_LONGTEXT,
82                  VLC_TRUE );
83
84     add_bool( "mms-all", 0, NULL, ALL_TEXT, ALL_LONGTEXT, VLC_TRUE );
85     add_integer( "mms-maxbitrate", 0, NULL, BITRATE_TEXT, BITRATE_LONGTEXT ,
86                  VLC_FALSE );
87     add_string( "mmsh-proxy", NULL, NULL, PROXY_TEXT, PROXY_LONGTEXT,
88                     VLC_FALSE );
89
90     add_shortcut( "mms" );
91     add_shortcut( "mmsu" );
92     add_shortcut( "mmst" );
93     add_shortcut( "mmsh" );
94     add_shortcut( "http" );
95     set_callbacks( Open, Close );
96 vlc_module_end();
97
98 /*****************************************************************************
99  * Local prototypes
100  *****************************************************************************/
101 struct access_sys_t
102 {
103     int i_proto;
104 };
105
106 /*****************************************************************************
107  * Open:
108  *****************************************************************************/
109 static int Open( vlc_object_t *p_this )
110 {
111     access_t *p_access = (access_t*)p_this;
112
113     /* First set ipv4/ipv6 */
114     var_Create( p_access, "ipv4", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
115     var_Create( p_access, "ipv6", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
116
117     /* mms-caching */
118     var_Create( p_access, "mms-caching", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
119
120     /* use specified method */
121     if( *p_access->psz_access )
122     {
123         if( !strncmp( p_access->psz_access, "mmsu", 4 ) )
124         {
125             return E_( MMSTUOpen )( p_access );
126         }
127         else if( !strncmp( p_access->psz_access, "mmst", 4 ) )
128         {
129             return E_( MMSTUOpen )( p_access );
130         }
131         else if( !strncmp( p_access->psz_access, "mmsh", 4 ) ||
132                  !strncmp( p_access->psz_access, "http", 4 ) )
133         {
134             return E_( MMSHOpen )( p_access );
135         }
136     }
137
138     if( E_( MMSTUOpen )( p_access ) )
139     {
140         /* try mmsh if mmstu failed */
141         return E_( MMSHOpen )( p_access );
142     }
143     return VLC_SUCCESS;
144 }
145
146 /*****************************************************************************
147  * Close: free unused data structures
148  *****************************************************************************/
149 static void Close( vlc_object_t *p_this )
150 {
151     access_t     *p_access = (access_t*)p_this;
152     access_sys_t *p_sys = p_access->p_sys;
153
154     if( ( p_sys->i_proto == MMS_PROTO_TCP ) ||
155         ( p_sys->i_proto == MMS_PROTO_UDP ) )
156     {
157         E_( MMSTUClose )( p_access );
158     }
159     else if( p_sys->i_proto == MMS_PROTO_HTTP )
160     {
161         E_( MMSHClose )( p_access );
162     }
163 }