1
/*****************************************************************************
2
* dvd.c : DVD input module for vlc
3
*****************************************************************************
4
* Copyright (C) 2000-2001 VideoLAN
5
* $Id: dvd.c,v 1.15 2001/11/28 15:08:05 massiot Exp $
7
* Authors: Samuel Hocevar <sam@zoy.org>
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.
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.
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
*****************************************************************************/
24
#define MODULE_NAME dvd
25
#include "modules_inner.h"
27
/*****************************************************************************
29
*****************************************************************************/
32
#include <stdlib.h> /* malloc(), free() */
33
#include <string.h> /* strdup() */
37
# include "dummy_dvdcss.h"
41
#include "common.h" /* boolean_t, byte_t */
47
#include "modules_export.h"
49
/*****************************************************************************
50
* Capabilities defined in the other files.
51
*****************************************************************************/
52
void _M( input_getfunctions )( function_list_t * p_function_list );
54
/*****************************************************************************
56
*****************************************************************************/
58
static void *p_libdvdcss;
59
static void ProbeLibDVDCSS ( void );
60
static void UnprobeLibDVDCSS( void );
63
/*****************************************************************************
64
* Build configuration tree.
65
*****************************************************************************/
67
ADD_WINDOW( "Configuration for DVD module" )
68
ADD_COMMENT( "foobar !" )
72
p_module->i_capabilities = MODULE_CAPABILITY_NULL
73
| MODULE_CAPABILITY_INPUT;
75
p_module->psz_longname = "DVD input module, uses libdvdcss if present";
77
p_module->psz_longname = "DVD input module, linked with libdvdcss";
82
_M( input_getfunctions )( &p_module->p_functions->input );
88
MODULE_DEACTIVATE_START
92
MODULE_DEACTIVATE_STOP
95
/* Following functions are local */
98
/*****************************************************************************
99
* ProbeLibDVDCSS: look for a libdvdcss object.
100
*****************************************************************************
101
* This functions looks for libdvdcss, using dlopen(), and fills function
102
* pointers with what it finds. On failure, uses the dummy libdvdcss
103
* replacement provided by vlc.
104
*****************************************************************************/
105
static void ProbeLibDVDCSS( void )
107
char *pp_filelist[4] = { "libdvdcss.so.1",
109
"./lib/libdvdcss.so.1",
111
char **pp_file = pp_filelist;
113
/* Try to open the dynamic object */
116
p_libdvdcss = dlopen( *pp_file, RTLD_LAZY );
117
if( p_libdvdcss != NULL )
119
intf_WarnMsg( 2, "module: builtin module `dvd' found libdvdcss "
120
"in `%s'", *pp_file );
125
} while( *pp_file != NULL );
127
/* If libdvdcss.so was found, check that it's valid */
128
if( p_libdvdcss == NULL )
130
intf_ErrMsg( "dvd warning: libdvdcss.so.1 not present" );
134
dvdcss_open = dlsym( p_libdvdcss, "dvdcss_open" );
135
dvdcss_close = dlsym( p_libdvdcss, "dvdcss_close" );
136
dvdcss_title = dlsym( p_libdvdcss, "dvdcss_title" );
137
dvdcss_seek = dlsym( p_libdvdcss, "dvdcss_seek" );
138
dvdcss_read = dlsym( p_libdvdcss, "dvdcss_read" );
139
dvdcss_readv = dlsym( p_libdvdcss, "dvdcss_readv" );
140
dvdcss_error = dlsym( p_libdvdcss, "dvdcss_error" );
142
if( dvdcss_open == NULL || dvdcss_close == NULL
143
|| dvdcss_title == NULL || dvdcss_seek == NULL
144
|| dvdcss_read == NULL || dvdcss_readv == NULL
145
|| dvdcss_error == NULL )
147
intf_ErrMsg( "dvd warning: missing symbols in libdvdcss.so.1, "
148
"this shouldn't happen !" );
149
dlclose( p_libdvdcss );
154
/* If libdvdcss was not found or was not valid, use the dummy
155
* replacement functions. */
156
if( p_libdvdcss == NULL )
158
intf_ErrMsg( "dvd warning: no valid libdvdcss found, "
159
"I will only play unencrypted DVDs" );
160
intf_ErrMsg( "dvd warning: get libdvdcss at "
161
"http://www.videolan.org/libdvdcss/" );
163
dvdcss_open = dummy_dvdcss_open;
164
dvdcss_close = dummy_dvdcss_close;
165
dvdcss_title = dummy_dvdcss_title;
166
dvdcss_seek = dummy_dvdcss_seek;
167
dvdcss_read = dummy_dvdcss_read;
168
dvdcss_readv = dummy_dvdcss_readv;
169
dvdcss_error = dummy_dvdcss_error;
173
/*****************************************************************************
174
* UnprobeLibDVDCSS: free resources allocated by ProbeLibDVDCSS, if any.
175
*****************************************************************************/
176
static void UnprobeLibDVDCSS( void )
178
if( p_libdvdcss != NULL )
180
dlclose( p_libdvdcss );