mms.c 5.31 KB
Newer Older
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 8 9 10 11 12
 *
 * Authors: Laurent Aimar <fenrir@via.ecp.fr>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
13
 *
14 15 16 17 18 19 20
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
dionoea's avatar
dionoea committed
21
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 23 24 25 26 27 28 29
 *****************************************************************************/


/*****************************************************************************
 * Preamble
 *****************************************************************************/

#include <vlc/vlc.h>
zorglub's avatar
zorglub committed
30
#include <vlc_access.h>
31 32

#include "mms.h"
33

34
/****************************************************************************
35
 * NOTES:
36 37 38 39 40 41
 *  MMSProtocole documentation found at http://get.to/sdp
 ****************************************************************************/

/*****************************************************************************
 * Module descriptor
 *****************************************************************************/
42 43 44
static int  Open ( vlc_object_t * );
static void Close( vlc_object_t * );

Christophe Massiot's avatar
Christophe Massiot committed
45
#define CACHING_TEXT N_("Caching value in ms")
gbazin's avatar
 
gbazin committed
46
#define CACHING_LONGTEXT N_( \
47
    "Caching value for MMS streams. This " \
zorglub's avatar
zorglub committed
48
    "value should be set in milliseconds." )
gbazin's avatar
 
gbazin committed
49

gbazin's avatar
 
gbazin committed
50
#define ALL_TEXT N_("Force selection of all streams")
zorglub's avatar
zorglub committed
51 52 53
#define ALL_LONGTEXT N_( \
    "MMS streams can contain several elementary streams, with different " \
    "bitrates. You can choose to select all of them." )
gbazin's avatar
 
gbazin committed
54

zorglub's avatar
zorglub committed
55
#define BITRATE_TEXT N_( "Maximum bitrate" )
gbazin's avatar
 
gbazin committed
56
#define BITRATE_LONGTEXT N_( \
zorglub's avatar
zorglub committed
57
    "Select the stream with the maximum bitrate under that limit."  )
gbazin's avatar
 
gbazin committed
58

59 60 61 62 63 64
#define PROXY_TEXT N_("HTTP proxy")
#define PROXY_LONGTEXT N_( \
    "HTTP proxy to be used It must be of the form " \
    "http://[user[:pass]@]myproxy.mydomain:myport/ ; " \
    "if empty, the http_proxy environment variable will be tried." )

65
vlc_module_begin();
Felix Paul Kühne's avatar
Felix Paul Kühne committed
66
    set_shortname( "MMS" );
gbazin's avatar
 
gbazin committed
67
    set_description( _("Microsoft Media Server (MMS) input") );
68
    set_capability( "access2", -1 );
zorglub's avatar
zorglub committed
69 70
    set_category( CAT_INPUT );
    set_subcategory( SUBCAT_INPUT_ACCESS );
gbazin's avatar
 
gbazin committed
71

72
    add_integer( "mms-caching", 19 * DEFAULT_PTS_DELAY / 1000, NULL,
gbazin's avatar
 
gbazin committed
73 74
                 CACHING_TEXT, CACHING_LONGTEXT, VLC_TRUE );

zorglub's avatar
zorglub committed
75
    add_bool( "mms-all", 0, NULL, ALL_TEXT, ALL_LONGTEXT, VLC_TRUE );
gbazin's avatar
 
gbazin committed
76 77
    add_integer( "mms-maxbitrate", 0, NULL, BITRATE_TEXT, BITRATE_LONGTEXT ,
                 VLC_FALSE );
78 79
    add_string( "mmsh-proxy", NULL, NULL, PROXY_TEXT, PROXY_LONGTEXT,
                    VLC_FALSE );
gbazin's avatar
 
gbazin committed
80

81 82 83
    add_shortcut( "mms" );
    add_shortcut( "mmsu" );
    add_shortcut( "mmst" );
84
    add_shortcut( "mmsh" );
85
    add_shortcut( "http" );
86 87 88
    set_callbacks( Open, Close );
vlc_module_end();

89 90 91 92 93 94 95 96 97
/*****************************************************************************
 * Local prototypes
 *****************************************************************************/
struct access_sys_t
{
    int i_proto;
};


gbazin's avatar
 
gbazin committed
98 99 100
/*****************************************************************************
 * Open:
 *****************************************************************************/
101 102
static int Open( vlc_object_t *p_this )
{
103
    access_t *p_access = (access_t*)p_this;
104

Laurent Aimar's avatar
Laurent Aimar committed
105
    /* First set ipv4/ipv6 */
106 107
    var_Create( p_access, "ipv4", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
    var_Create( p_access, "ipv6", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
108

Laurent Aimar's avatar
Laurent Aimar committed
109
    /* mms-caching */
110
    var_Create( p_access, "mms-caching", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
111

Laurent Aimar's avatar
Laurent Aimar committed
112
    /* use specified method */
113
    if( *p_access->psz_access )
114
    {
115
        if( !strncmp( p_access->psz_access, "mmsu", 4 ) )
116
        {
117
            return E_( MMSTUOpen )( p_access );
118
        }
119
        else if( !strncmp( p_access->psz_access, "mmst", 4 ) )
120
        {
121
            return E_( MMSTUOpen )( p_access );
122
        }
123 124
        else if( !strncmp( p_access->psz_access, "mmsh", 4 ) ||
                 !strncmp( p_access->psz_access, "http", 4 ) )
125
        {
126
            return E_( MMSHOpen )( p_access );
127 128 129
        }
    }

130
    if( E_( MMSTUOpen )( p_access ) )
131
    {
Laurent Aimar's avatar
Laurent Aimar committed
132
        /* try mmsh if mmstu failed */
133
        return E_( MMSHOpen )( p_access );
134
    }
Laurent Aimar's avatar
Laurent Aimar committed
135
    return VLC_SUCCESS;
136 137 138 139 140 141 142
}

/*****************************************************************************
 * Close: free unused data structures
 *****************************************************************************/
static void Close( vlc_object_t *p_this )
{
143 144
    access_t     *p_access = (access_t*)p_this;
    access_sys_t *p_sys = p_access->p_sys;
145

146
    if( p_sys->i_proto == MMS_PROTO_TCP || p_sys->i_proto == MMS_PROTO_UDP )
147
    {
148
        E_( MMSTUClose )( p_access );
149
    }
150
    else if( p_sys->i_proto == MMS_PROTO_HTTP )
151
    {
152
        E_( MMSHClose )( p_access );
153
    }
154
}