]> git.sesse.net Git - vlc/blob - modules/access/mms/mms.c
8abf8be73877523da6a4de72064a1274c4f61f67
[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 VideoLAN (Centrale Réseaux) and its contributors
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., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
22  *****************************************************************************/
23
24
25 /*****************************************************************************
26  * Preamble
27  *****************************************************************************/
28 #include <stdlib.h>
29
30 #include <vlc/vlc.h>
31 #include <vlc/input.h>
32
33 #include "mms.h"
34
35 /****************************************************************************
36  * NOTES:
37  *  MMSProtocole documentation found at http://get.to/sdp
38  ****************************************************************************/
39
40 /*****************************************************************************
41  * Module descriptor
42  *****************************************************************************/
43 static int  Open ( vlc_object_t * );
44 static void Close( vlc_object_t * );
45
46 #define CACHING_TEXT N_("Caching value in ms")
47 #define CACHING_LONGTEXT N_( \
48     "Allows you to modify the default caching value for MMS streams. This " \
49     "value should be set in millisecond units." )
50
51 #define ALL_TEXT N_("Force selection of all streams")
52
53 #define BITRATE_TEXT N_("Select maximum bitrate stream")
54 #define BITRATE_LONGTEXT N_( \
55     "Always select the stream with the maximum bitrate." )
56
57 vlc_module_begin();
58     set_shortname( _("MMS") );
59     set_description( _("Microsoft Media Server (MMS) input") );
60     set_capability( "access2", -1 );
61     set_category( CAT_INPUT );
62     set_subcategory( SUBCAT_INPUT_ACCESS );
63
64     add_integer( "mms-caching", 12 * DEFAULT_PTS_DELAY / 1000, NULL,
65                  CACHING_TEXT, CACHING_LONGTEXT, VLC_TRUE );
66
67     add_bool( "mms-all", 0, NULL, ALL_TEXT, "", VLC_TRUE );
68     add_integer( "mms-maxbitrate", 0, NULL, BITRATE_TEXT, BITRATE_LONGTEXT ,
69                  VLC_FALSE );
70
71     add_shortcut( "mms" );
72     add_shortcut( "mmsu" );
73     add_shortcut( "mmst" );
74     add_shortcut( "mmsh" );
75     add_shortcut( "http" );
76     set_callbacks( Open, Close );
77 vlc_module_end();
78
79 /*****************************************************************************
80  * Local prototypes
81  *****************************************************************************/
82 struct access_sys_t
83 {
84     int i_proto;
85 };
86
87
88 /*****************************************************************************
89  * Open:
90  *****************************************************************************/
91 static int Open( vlc_object_t *p_this )
92 {
93     access_t *p_access = (access_t*)p_this;
94
95     /* First set ipv4/ipv6 */
96     var_Create( p_access, "ipv4", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
97     var_Create( p_access, "ipv6", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
98
99     /* mms-caching */
100     var_Create( p_access, "mms-caching", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
101
102     /* use specified method */
103     if( *p_access->psz_access )
104     {
105         if( !strncmp( p_access->psz_access, "mmsu", 4 ) )
106         {
107             return E_( MMSTUOpen )( p_access );
108         }
109         else if( !strncmp( p_access->psz_access, "mmst", 4 ) )
110         {
111             return E_( 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 E_( MMSHOpen )( p_access );
117         }
118     }
119
120     if( E_( MMSTUOpen )( p_access ) )
121     {
122         /* try mmsh if mmstu failed */
123         return E_( MMSHOpen )( p_access );
124     }
125     return VLC_SUCCESS;
126 }
127
128 /*****************************************************************************
129  * Close: free unused data structures
130  *****************************************************************************/
131 static void Close( vlc_object_t *p_this )
132 {
133     access_t     *p_access = (access_t*)p_this;
134     access_sys_t *p_sys = p_access->p_sys;
135
136     if( p_sys->i_proto == MMS_PROTO_TCP || p_sys->i_proto == MMS_PROTO_UDP )
137     {
138         E_( MMSTUClose )( p_access );
139     }
140     else if( p_sys->i_proto == MMS_PROTO_HTTP )
141     {
142         E_( MMSHClose )( p_access );
143     }
144 }