annotate libmpdvdkit2/libdvdcss.c @ 8683:4abed18beccc

sync
author nicolas
date Tue, 31 Dec 2002 17:21:03 +0000
parents a2fa276b8ec7
children ddf6a9f4cc6a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7027
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1 /* libdvdcss.c: DVD reading library.
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
2 *
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
3 * Authors: Stéphane Borel <stef@via.ecp.fr>
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
4 * Samuel Hocevar <sam@zoy.org>
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
5 * Håkan Hjort <d95hjort@dtek.chalmers.se>
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
6 *
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
7 * Copyright (C) 1998-2002 VideoLAN
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
8 * $Id$
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
9 *
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
10 * This program is free software; you can redistribute it and/or modify
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
11 * it under the terms of the GNU General Public License as published by
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
12 * the Free Software Foundation; either version 2 of the License, or
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
13 * (at your option) any later version.
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
14 *
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
15 * This program is distributed in the hope that it will be useful,
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
18 * GNU General Public License for more details.
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
19 *
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
20 * You should have received a copy of the GNU General Public License
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
21 * along with this program; if not, write to the Free Software
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
23 */
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
24
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
25 /**
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
26 * \mainpage libdvdcss developer documentation
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
27 *
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
28 * \section intro Introduction
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
29 *
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
30 * \e libdvdcss is a simple library designed for accessing DVDs like a block
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
31 * device without having to bother about the decryption. The important features
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
32 * are:
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
33 * \li portability: currently supported platforms are GNU/Linux, FreeBSD,
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
34 * NetBSD, OpenBSD, BSD/OS, BeOS, Windows 95/98, Windows NT/2000, MacOS X,
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
35 * Solaris, HP-UX and OS/2.
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
36 * \li adaptability: unlike most similar projects, libdvdcss doesn't require
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
37 * the region of your drive to be set and will try its best to read from
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
38 * the disc even in the case of a region mismatch.
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
39 * \li simplicity: a DVD player can be built around the \e libdvdcss API using
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
40 * no more than 4 or 5 library calls.
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
41 *
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
42 * \e libdvdcss is free software, released under the General Public License.
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
43 * This ensures that \e libdvdcss remains free and used only with free
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
44 * software.
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
45 *
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
46 * \section api The libdvdcss API
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
47 *
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
48 * The complete \e libdvdcss programming interface is documented in the
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
49 * dvdcss.h file.
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
50 *
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
51 * \section env Environment variables
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
52 *
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
53 * Some environment variables can be used to change the behaviour of
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
54 * \e libdvdcss without having to modify the program which uses it. These
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
55 * variables are:
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
56 *
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
57 * \li \b DVDCSS_VERBOSE: sets the verbosity level.
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
58 * - \c 0 outputs no messages at all.
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
59 * - \c 1 outputs error messages to stderr.
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
60 * - \c 2 outputs error messages and debug messages to stderr.
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
61 *
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
62 * \li \b DVDCSS_METHOD: sets the authentication and decryption method
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
63 * that \e libdvdcss will use to read scrambled discs. Can be one
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
64 * of \c title, \c key or \c disc.
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
65 * - \c key is the default method. \e libdvdcss will use a set of
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
66 * calculated player keys to try and get the disc key. This can fail
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
67 * if the drive does not recognize any of the player keys.
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
68 * - \c disc is a fallback method when \c key has failed. Instead of
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
69 * using player keys, \e libdvdcss will crack the disc key using
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
70 * a brute force algorithm. This process is CPU intensive and requires
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
71 * 64 MB of memory to store temporary data.
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
72 * - \c title is the fallback when all other methods have failed. It does
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
73 * not rely on a key exchange with the DVD drive, but rather uses a
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
74 * crypto attack to guess the title key. On rare cases this may fail
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
75 * because there is not enough encrypted data on the disc to perform
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
76 * a statistical attack, but in the other hand it is the only way to
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
77 * decrypt a DVD stored on a hard disc, or a DVD with the wrong region
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
78 * on an RPC2 drive.
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
79 *
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
80 * \li \b DVDCSS_RAW_DEVICE: specify the raw device to use.
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
81 *
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
82 */
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
83
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
84 /*
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
85 * Preamble
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
86 */
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
87 #include "config.h"
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
88
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
89 #include <stdio.h>
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
90 #include <stdlib.h>
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
91 #include <string.h>
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
92 #include <sys/types.h>
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
93 #include <sys/stat.h>
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
94 #include <fcntl.h>
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
95
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
96 #ifdef HAVE_UNISTD_H
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
97 # include <unistd.h>
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
98 #endif
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
99
7033
596919e4f601 apply mplayer-specific patches
arpi
parents: 7032
diff changeset
100 #include "dvdcss.h"
7027
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
101
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
102 #include "common.h"
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
103 #include "css.h"
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
104 #include "libdvdcss.h"
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
105 #include "ioctl.h"
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
106 #include "device.h"
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
107
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
108 /**
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
109 * \brief Symbol for version checks.
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
110 *
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
111 * The name of this symbol contains the library major number, which makes it
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
112 * easy to check which \e libdvdcss development headers are installed on the
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
113 * system with tools such as autoconf.
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
114 *
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
115 * The variable itself contains the exact version number of the library,
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
116 * which can be useful for specific feature needs.
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
117 */
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
118 char * dvdcss_interface_2 = VERSION;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
119
7032
fd2d4be9ed6f applying css-key cache patch
arpi
parents: 7027
diff changeset
120 char * dvdcss_cache_dir = NULL;
fd2d4be9ed6f applying css-key cache patch
arpi
parents: 7027
diff changeset
121
7027
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
122 /**
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
123 * \brief Open a DVD device or directory and return a dvdcss instance.
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
124 *
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
125 * \param psz_target a string containing the target name, for instance
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
126 * "/dev/hdc" or "E:".
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
127 * \return a handle to a dvdcss instance or NULL on error.
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
128 *
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
129 * Initialize the \e libdvdcss library and open the requested DVD device or
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
130 * directory. \e libdvdcss checks whether ioctls can be performed on the disc,
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
131 * and when possible, the disc key is retrieved.
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
132 *
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
133 * dvdcss_open() returns a handle to be used for all subsequent \e libdvdcss
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
134 * calls. If an error occured, NULL is returned.
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
135 */
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
136 extern dvdcss_t dvdcss_open ( char *psz_target )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
137 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
138 int i_ret;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
139
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
140 char *psz_method = getenv( "DVDCSS_METHOD" );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
141 char *psz_verbose = getenv( "DVDCSS_VERBOSE" );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
142 #ifndef WIN32
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
143 char *psz_raw_device = getenv( "DVDCSS_RAW_DEVICE" );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
144 #endif
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
145
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
146 dvdcss_t dvdcss;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
147
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
148 /*
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
149 * Allocate the library structure
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
150 */
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
151 dvdcss = malloc( sizeof( struct dvdcss_s ) );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
152 if( dvdcss == NULL )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
153 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
154 return NULL;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
155 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
156
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
157 /*
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
158 * Initialize structure with default values
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
159 */
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
160 #ifndef WIN32
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
161 dvdcss->i_raw_fd = -1;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
162 #endif
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
163 dvdcss->p_titles = NULL;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
164 dvdcss->psz_device = (char *)strdup( psz_target );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
165 dvdcss->psz_error = "no error";
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
166 dvdcss->i_method = DVDCSS_METHOD_KEY;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
167 dvdcss->b_debug = 0;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
168 dvdcss->b_errors = 0;
7032
fd2d4be9ed6f applying css-key cache patch
arpi
parents: 7027
diff changeset
169 dvdcss->psz_cache = NULL;
7027
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
170
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
171 /*
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
172 * Find verbosity from DVDCSS_VERBOSE environment variable
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
173 */
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
174 if( psz_verbose != NULL )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
175 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
176 switch( atoi( psz_verbose ) )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
177 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
178 case 2:
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
179 dvdcss->b_debug = 1;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
180 case 1:
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
181 dvdcss->b_errors = 1;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
182 case 0:
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
183 break;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
184 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
185 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
186
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
187 /*
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
188 * Find method from DVDCSS_METHOD environment variable
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
189 */
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
190 if( psz_method != NULL )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
191 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
192 if( !strncmp( psz_method, "key", 4 ) )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
193 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
194 dvdcss->i_method = DVDCSS_METHOD_KEY;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
195 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
196 else if( !strncmp( psz_method, "disc", 5 ) )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
197 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
198 dvdcss->i_method = DVDCSS_METHOD_DISC;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
199 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
200 else if( !strncmp( psz_method, "title", 5 ) )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
201 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
202 dvdcss->i_method = DVDCSS_METHOD_TITLE;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
203 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
204 else
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
205 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
206 _dvdcss_error( dvdcss, "unknown decrypt method, please choose "
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
207 "from 'title', 'key' or 'disc'" );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
208 free( dvdcss->psz_device );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
209 free( dvdcss );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
210 return NULL;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
211 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
212 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
213
7032
fd2d4be9ed6f applying css-key cache patch
arpi
parents: 7027
diff changeset
214 if(!dvdcss_cache_dir) dvdcss_cache_dir = getenv( "DVDCSS_CACHE" );
fd2d4be9ed6f applying css-key cache patch
arpi
parents: 7027
diff changeset
215
7027
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
216 /*
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
217 * Open device
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
218 */
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
219 i_ret = _dvdcss_open( dvdcss );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
220 if( i_ret < 0 )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
221 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
222 free( dvdcss->psz_device );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
223 free( dvdcss );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
224 return NULL;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
225 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
226
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
227 dvdcss->b_scrambled = 1; /* Assume the worst */
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
228 dvdcss->b_ioctls = _dvdcss_use_ioctls( dvdcss );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
229
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
230 if( dvdcss->b_ioctls )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
231 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
232 i_ret = _dvdcss_test( dvdcss );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
233 if( i_ret < 0 )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
234 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
235 /* Disable the CSS ioctls and hope that it works? */
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
236 _dvdcss_debug( dvdcss,
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
237 "could not check whether the disc was scrambled" );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
238 dvdcss->b_ioctls = 0;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
239 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
240 else
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
241 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
242 _dvdcss_debug( dvdcss, i_ret ? "disc is scrambled"
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
243 : "disc is unscrambled" );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
244 dvdcss->b_scrambled = i_ret;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
245 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
246 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
247
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
248 /* If disc is CSS protected and the ioctls work, authenticate the drive */
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
249 if( dvdcss->b_scrambled && dvdcss->b_ioctls )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
250 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
251 i_ret = _dvdcss_disckey( dvdcss );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
252
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
253 if( i_ret < 0 )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
254 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
255 _dvdcss_close( dvdcss );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
256 free( dvdcss->psz_device );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
257 free( dvdcss );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
258 return NULL;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
259 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
260 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
261
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
262 #ifndef WIN32
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
263 if( psz_raw_device != NULL )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
264 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
265 _dvdcss_raw_open( dvdcss, psz_raw_device );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
266 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
267 #endif
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
268
7032
fd2d4be9ed6f applying css-key cache patch
arpi
parents: 7027
diff changeset
269 /* if the CACHE is enabled, extract some unique disc ID */
fd2d4be9ed6f applying css-key cache patch
arpi
parents: 7027
diff changeset
270 if(dvdcss_cache_dir){
fd2d4be9ed6f applying css-key cache patch
arpi
parents: 7027
diff changeset
271 char* disc_id=NULL;
8123
9fc45fe0d444 *HUGE* set of compiler warning fixes, unused variables removal
arpi
parents: 7033
diff changeset
272 /*char title_name[64];*/
7032
fd2d4be9ed6f applying css-key cache patch
arpi
parents: 7027
diff changeset
273 char sector[DVDCSS_BLOCK_SIZE];
fd2d4be9ed6f applying css-key cache patch
arpi
parents: 7027
diff changeset
274 // 32768+40 -> disc title (32 uppercase chars)
fd2d4be9ed6f applying css-key cache patch
arpi
parents: 7027
diff changeset
275 // 32768+813 -> disc manufacturing date + serial no (16 digit number)
8637
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 8123
diff changeset
276 dvdcss->pf_seek( dvdcss, 32768/DVDCSS_BLOCK_SIZE);
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 8123
diff changeset
277 if(dvdcss->pf_read( dvdcss, sector, 1) == 1){
7032
fd2d4be9ed6f applying css-key cache patch
arpi
parents: 7027
diff changeset
278 // check disc title first:
fd2d4be9ed6f applying css-key cache patch
arpi
parents: 7027
diff changeset
279 char* title_name=&sector[40];
fd2d4be9ed6f applying css-key cache patch
arpi
parents: 7027
diff changeset
280 int i=31;
fd2d4be9ed6f applying css-key cache patch
arpi
parents: 7027
diff changeset
281 while(i>=0 && title_name[i]<=32) i--;
fd2d4be9ed6f applying css-key cache patch
arpi
parents: 7027
diff changeset
282 title_name[i+1]=0;
fd2d4be9ed6f applying css-key cache patch
arpi
parents: 7027
diff changeset
283 if(strlen(title_name)>5){
fd2d4be9ed6f applying css-key cache patch
arpi
parents: 7027
diff changeset
284 disc_id=strdup(title_name);
fd2d4be9ed6f applying css-key cache patch
arpi
parents: 7027
diff changeset
285 } else {
fd2d4be9ed6f applying css-key cache patch
arpi
parents: 7027
diff changeset
286 // use disc date+serial:
fd2d4be9ed6f applying css-key cache patch
arpi
parents: 7027
diff changeset
287 title_name=&sector[813];
fd2d4be9ed6f applying css-key cache patch
arpi
parents: 7027
diff changeset
288 title_name[16]=0;
fd2d4be9ed6f applying css-key cache patch
arpi
parents: 7027
diff changeset
289 for ( i=0;i<16;i++ )
fd2d4be9ed6f applying css-key cache patch
arpi
parents: 7027
diff changeset
290 if ( ( title_name[i] < '0' )||( title_name[i] > '9' ) ){
fd2d4be9ed6f applying css-key cache patch
arpi
parents: 7027
diff changeset
291 disc_id=malloc(16+4);
8638
a2fa276b8ec7 The attached patch fixes a crash on *my* environment with certain DVD's.
arpi
parents: 8637
diff changeset
292 snprintf( disc_id,17,"%.2X%.2X%.2X%.2X%.2X%.2X%.2X%.2X",title_name[0],title_name[1],title_name[2],title_name[3],title_name[4],title_name[5],title_name[6],title_name[7] );
7032
fd2d4be9ed6f applying css-key cache patch
arpi
parents: 7027
diff changeset
293 break;
fd2d4be9ed6f applying css-key cache patch
arpi
parents: 7027
diff changeset
294 }
fd2d4be9ed6f applying css-key cache patch
arpi
parents: 7027
diff changeset
295 if(!disc_id) disc_id=strdup(title_name);
fd2d4be9ed6f applying css-key cache patch
arpi
parents: 7027
diff changeset
296 }
fd2d4be9ed6f applying css-key cache patch
arpi
parents: 7027
diff changeset
297 if(disc_id){
fd2d4be9ed6f applying css-key cache patch
arpi
parents: 7027
diff changeset
298 // yeah, we have a disc name/id, let's set up cache path:
8123
9fc45fe0d444 *HUGE* set of compiler warning fixes, unused variables removal
arpi
parents: 7033
diff changeset
299 /*char* dir;*/
7032
fd2d4be9ed6f applying css-key cache patch
arpi
parents: 7027
diff changeset
300 dvdcss->psz_cache = malloc(strlen(dvdcss_cache_dir)+strlen(disc_id)+4);
fd2d4be9ed6f applying css-key cache patch
arpi
parents: 7027
diff changeset
301 sprintf(dvdcss->psz_cache,"%s/%s",dvdcss_cache_dir,disc_id);
fd2d4be9ed6f applying css-key cache patch
arpi
parents: 7027
diff changeset
302 mkdir( dvdcss->psz_cache,493 );
fd2d4be9ed6f applying css-key cache patch
arpi
parents: 7027
diff changeset
303 free(disc_id);
fd2d4be9ed6f applying css-key cache patch
arpi
parents: 7027
diff changeset
304 fprintf(stderr,"Using CSS Key-cache dir: %s\n",dvdcss->psz_cache);
fd2d4be9ed6f applying css-key cache patch
arpi
parents: 7027
diff changeset
305 }
fd2d4be9ed6f applying css-key cache patch
arpi
parents: 7027
diff changeset
306 }
fd2d4be9ed6f applying css-key cache patch
arpi
parents: 7027
diff changeset
307 }
fd2d4be9ed6f applying css-key cache patch
arpi
parents: 7027
diff changeset
308
7027
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
309 return dvdcss;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
310 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
311
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
312 /**
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
313 * \brief Return a string containing the latest error that occured in the
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
314 * given \e libdvdcss instance.
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
315 *
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
316 * \param dvdcss a \e libdvdcss instance.
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
317 * \return a null-terminated string containing the latest error message.
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
318 *
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
319 * This function returns a constant string containing the latest error that
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
320 * occured in \e libdvdcss. It can be used to format error messages at your
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
321 * convenience in your application.
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
322 */
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
323 extern char * dvdcss_error ( dvdcss_t dvdcss )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
324 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
325 return dvdcss->psz_error;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
326 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
327
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
328 /**
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
329 * \brief Seek in the disc and change the current key if requested.
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
330 *
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
331 * \param dvdcss a \e libdvdcss instance.
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
332 * \param i_blocks an absolute block offset to seek to.
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
333 * \param i_flags #DVDCSS_NOFLAGS, optionally ored with one of #DVDCSS_SEEK_KEY
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
334 * or #DVDCSS_SEEK_MPEG.
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
335 * \return the new position in blocks, or a negative value in case an error
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
336 * happened.
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
337 *
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
338 * This function seeks to the requested position, in logical blocks.
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
339 *
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
340 * You typically set \p i_flags to #DVDCSS_NOFLAGS when seeking in a .IFO.
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
341 *
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
342 * If #DVDCSS_SEEK_MPEG is specified in \p i_flags and if \e libdvdcss finds it
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
343 * reasonable to do so (ie, if the dvdcss method is not "title"), the current
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
344 * title key will be checked and a new one will be calculated if necessary.
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
345 * This flag is typically used when reading data from a VOB.
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
346 *
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
347 * If #DVDCSS_SEEK_KEY is specified, the title key will be always checked,
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
348 * even with the "title" method. This is equivalent to using the now
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
349 * deprecated dvdcss_title() call. This flag is typically used when seeking
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
350 * in a new title.
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
351 */
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
352 extern int dvdcss_seek ( dvdcss_t dvdcss, int i_blocks, int i_flags )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
353 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
354 /* title cracking method is too slow to be used at each seek */
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
355 if( ( ( i_flags & DVDCSS_SEEK_MPEG )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
356 && ( dvdcss->i_method != DVDCSS_METHOD_TITLE ) )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
357 || ( i_flags & DVDCSS_SEEK_KEY ) )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
358 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
359 /* check the title key */
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
360 if( _dvdcss_title( dvdcss, i_blocks ) )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
361 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
362 return -1;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
363 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
364 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
365
8637
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 8123
diff changeset
366 return dvdcss->pf_seek( dvdcss, i_blocks );
7027
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
367 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
368
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
369 /**
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
370 * \brief Read from the disc and decrypt data if requested.
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
371 *
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
372 * \param dvdcss a \e libdvdcss instance.
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
373 * \param p_buffer a buffer that will contain the data read from the disc.
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
374 * \param i_blocks the amount of blocks to read.
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
375 * \param i_flags #DVDCSS_NOFLAGS, optionally ored with #DVDCSS_READ_DECRYPT.
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
376 * \return the amount of blocks read, or a negative value in case an
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
377 * error happened.
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
378 *
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
379 * This function reads \p i_blocks logical blocks from the DVD.
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
380 *
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
381 * You typically set \p i_flags to #DVDCSS_NOFLAGS when reading data from a
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
382 * .IFO file on the DVD.
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
383 *
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
384 * If #DVDCSS_READ_DECRYPT is specified in \p i_flags, dvdcss_read() will
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
385 * automatically decrypt scrambled sectors. This flag is typically used when
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
386 * reading data from a .VOB file on the DVD. It has no effect on unscrambled
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
387 * discs or unscrambled sectors, and can be safely used on those.
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
388 *
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
389 * \warning dvdcss_read() expects to be able to write \p i_blocks *
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
390 * #DVDCSS_BLOCK_SIZE bytes in \p p_buffer.
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
391 */
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
392 extern int dvdcss_read ( dvdcss_t dvdcss, void *p_buffer,
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
393 int i_blocks,
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
394 int i_flags )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
395 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
396 int i_ret, i_index;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
397
8637
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 8123
diff changeset
398 i_ret = dvdcss->pf_read( dvdcss, p_buffer, i_blocks );
7027
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
399
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
400 if( i_ret <= 0
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
401 || !dvdcss->b_scrambled
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
402 || !(i_flags & DVDCSS_READ_DECRYPT) )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
403 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
404 return i_ret;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
405 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
406
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
407 if( ! memcmp( dvdcss->css.p_title_key, "\0\0\0\0\0", 5 ) )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
408 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
409 /* For what we believe is an unencrypted title,
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
410 * check that there are no encrypted blocks */
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
411 for( i_index = i_ret; i_index; i_index-- )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
412 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
413 if( ((u8*)p_buffer)[0x14] & 0x30 )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
414 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
415 _dvdcss_error( dvdcss, "no key but found encrypted block" );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
416 /* Only return the initial range of unscrambled blocks? */
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
417 /* or fail completely? return 0; */
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
418 break;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
419 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
420 p_buffer = (void *) ((u8 *)p_buffer + DVDCSS_BLOCK_SIZE);
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
421 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
422 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
423 else
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
424 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
425 /* Decrypt the blocks we managed to read */
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
426 for( i_index = i_ret; i_index; i_index-- )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
427 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
428 _dvdcss_unscramble( dvdcss->css.p_title_key, p_buffer );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
429 ((u8*)p_buffer)[0x14] &= 0x8f;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
430 p_buffer = (void *) ((u8 *)p_buffer + DVDCSS_BLOCK_SIZE);
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
431 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
432 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
433
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
434 return i_ret;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
435 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
436
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
437 /**
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
438 * \brief Read from the disc into multiple buffers and decrypt data if
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
439 * requested.
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
440 *
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
441 * \param dvdcss a \e libdvdcss instance.
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
442 * \param p_iovec a pointer to an array of iovec structures that will contain
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
443 * the data read from the disc.
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
444 * \param i_blocks the amount of blocks to read.
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
445 * \param i_flags #DVDCSS_NOFLAGS, optionally ored with #DVDCSS_READ_DECRYPT.
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
446 * \return the amount of blocks read, or a negative value in case an
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
447 * error happened.
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
448 *
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
449 * This function reads \p i_blocks logical blocks from the DVD and writes them
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
450 * to an array of iovec structures.
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
451 *
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
452 * You typically set \p i_flags to #DVDCSS_NOFLAGS when reading data from a
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
453 * .IFO file on the DVD.
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
454 *
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
455 * If #DVDCSS_READ_DECRYPT is specified in \p i_flags, dvdcss_readv() will
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
456 * automatically decrypt scrambled sectors. This flag is typically used when
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
457 * reading data from a .VOB file on the DVD. It has no effect on unscrambled
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
458 * discs or unscrambled sectors, and can be safely used on those.
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
459 *
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
460 * \warning dvdcss_readv() expects to be able to write \p i_blocks *
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
461 * #DVDCSS_BLOCK_SIZE bytes in the buffers pointed by \p p_iovec.
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
462 * Moreover, all iov_len members of the iovec structures should be
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
463 * multiples of #DVDCSS_BLOCK_SIZE.
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
464 */
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
465 extern int dvdcss_readv ( dvdcss_t dvdcss, void *p_iovec,
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
466 int i_blocks,
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
467 int i_flags )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
468 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
469 struct iovec *_p_iovec = (struct iovec *)p_iovec;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
470 int i_ret, i_index;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
471 void *iov_base;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
472 size_t iov_len;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
473
8637
0211de3039eb update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents: 8123
diff changeset
474 i_ret = dvdcss->pf_readv( dvdcss, _p_iovec, i_blocks );
7027
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
475
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
476 if( i_ret <= 0
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
477 || !dvdcss->b_scrambled
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
478 || !(i_flags & DVDCSS_READ_DECRYPT) )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
479 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
480 return i_ret;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
481 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
482
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
483 /* Initialize loop for decryption */
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
484 iov_base = _p_iovec->iov_base;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
485 iov_len = _p_iovec->iov_len;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
486
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
487 /* Decrypt the blocks we managed to read */
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
488 for( i_index = i_ret; i_index; i_index-- )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
489 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
490 /* Check that iov_len is a multiple of 2048 */
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
491 if( iov_len & 0x7ff )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
492 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
493 return -1;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
494 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
495
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
496 while( iov_len == 0 )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
497 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
498 _p_iovec++;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
499 iov_base = _p_iovec->iov_base;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
500 iov_len = _p_iovec->iov_len;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
501 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
502
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
503 _dvdcss_unscramble( dvdcss->css.p_title_key, iov_base );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
504 ((u8*)iov_base)[0x14] &= 0x8f;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
505
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
506 iov_base = (void *) ((u8*)iov_base + DVDCSS_BLOCK_SIZE);
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
507 iov_len -= DVDCSS_BLOCK_SIZE;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
508 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
509
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
510 return i_ret;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
511 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
512
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
513 /**
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
514 * \brief Close the DVD and clean up the library.
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
515 *
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
516 * \param dvdcss a \e libdvdcss instance.
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
517 * \return zero in case of success, a negative value otherwise.
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
518 *
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
519 * This function closes the DVD device and frees all the memory allocated
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
520 * by \e libdvdcss. On return, the #dvdcss_t is invalidated and may not be
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
521 * used again.
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
522 */
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
523 extern int dvdcss_close ( dvdcss_t dvdcss )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
524 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
525 dvd_title_t *p_title;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
526 int i_ret;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
527
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
528 /* Free our list of keys */
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
529 p_title = dvdcss->p_titles;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
530 while( p_title )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
531 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
532 dvd_title_t *p_tmptitle = p_title->p_next;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
533 free( p_title );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
534 p_title = p_tmptitle;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
535 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
536
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
537 i_ret = _dvdcss_close( dvdcss );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
538
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
539 if( i_ret < 0 )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
540 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
541 return i_ret;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
542 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
543
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
544 free( dvdcss->psz_device );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
545 free( dvdcss );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
546
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
547 return 0;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
548 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
549
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
550 /*
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
551 * Deprecated. See dvdcss_seek().
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
552 */
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
553 #undef dvdcss_title
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
554 extern int dvdcss_title ( dvdcss_t dvdcss, int i_block )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
555 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
556 return _dvdcss_title( dvdcss, i_block );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
557 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
558