Mercurial > mplayer.hg
annotate libmpdvdkit2/ioctl.c @ 13832:2f8cfe66dbfd
Different buffering scheme, avoiding possible races (SDL is using threads!).
author | reimar |
---|---|
date | Sun, 31 Oct 2004 21:02:47 +0000 |
parents | 7b0bc557987b |
children | c2ddedd0619e |
rev | line source |
---|---|
7027 | 1 /***************************************************************************** |
2 * ioctl.c: DVD ioctl replacement function | |
3 ***************************************************************************** | |
4 * Copyright (C) 1999-2001 VideoLAN | |
5 * $Id$ | |
6 * | |
7 * Authors: Markus Kuespert <ltlBeBoy@beosmail.com> | |
8 * Samuel Hocevar <sam@zoy.org> | |
9 * Jon Lech Johansen <jon-vl@nanocrew.net> | |
10 * Håkan Hjort <d95hjort@dtek.chalmers.se> | |
11 * Eugenio Jarosiewicz <ej0@cise.ufl.edu> | |
12 * David Siebörger <drs-videolan@rucus.ru.ac.za> | |
13 * Alex Strelnikov <lelik@os2.ru> | |
8637
0211de3039eb
update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents:
8575
diff
changeset
|
14 * Gildas Bazin <gbazin@netcourrier.com> |
7027 | 15 * |
16 * This program is free software; you can redistribute it and/or modify | |
17 * it under the terms of the GNU General Public License as published by | |
18 * the Free Software Foundation; either version 2 of the License, or | |
19 * (at your option) any later version. | |
20 * | |
21 * This program is distributed in the hope that it will be useful, | |
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
24 * GNU General Public License for more details. | |
25 * | |
26 * You should have received a copy of the GNU General Public License | |
27 * along with this program; if not, write to the Free Software | |
28 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. | |
29 *****************************************************************************/ | |
30 | |
31 /***************************************************************************** | |
32 * Preamble | |
33 *****************************************************************************/ | |
34 #include "config.h" | |
35 | |
36 #include <stdio.h> | |
37 | |
38 #include <string.h> /* memcpy(), memset() */ | |
39 #include <sys/types.h> | |
40 | |
41 #if defined( WIN32 ) | |
42 # include <windows.h> | |
43 # include <winioctl.h> | |
44 #elif defined ( SYS_OS2 ) | |
45 # define INCL_DOSFILEMGR | |
46 # define INCL_DOSDEVICES | |
47 # define INCL_DOSDEVIOCTL | |
48 # define INCL_DOSERRORS | |
49 # include <os2.h> | |
50 # include <sys/ioctl.h> | |
51 #else | |
52 # include <netinet/in.h> | |
53 # include <sys/ioctl.h> | |
54 #endif | |
55 | |
56 #ifdef DVD_STRUCT_IN_SYS_CDIO_H | |
57 # include <sys/cdio.h> | |
58 #endif | |
59 #ifdef DVD_STRUCT_IN_SYS_DVDIO_H | |
60 # include <sys/dvdio.h> | |
61 #endif | |
62 #ifdef DVD_STRUCT_IN_LINUX_CDROM_H | |
63 # include <linux/cdrom.h> | |
64 #endif | |
65 #ifdef DVD_STRUCT_IN_DVD_H | |
66 # include <dvd.h> | |
67 #endif | |
68 #ifdef DVD_STRUCT_IN_BSDI_DVDIOCTL_DVD_H | |
69 # include "bsdi_dvd.h" | |
70 #endif | |
71 #ifdef SYS_BEOS | |
72 # include <malloc.h> | |
73 # include <scsi.h> | |
74 #endif | |
75 #ifdef HPUX_SCTL_IO | |
76 # include <sys/scsi.h> | |
77 #endif | |
78 #ifdef SOLARIS_USCSI | |
8575 | 79 # include <dlfcn.h> |
7027 | 80 # include <unistd.h> |
81 # include <stropts.h> | |
82 # include <sys/scsi/scsi_types.h> | |
83 # include <sys/scsi/impl/uscsi.h> | |
84 #endif | |
85 #ifdef DARWIN_DVD_IOCTL | |
86 # include <IOKit/storage/IODVDMediaBSDClient.h> | |
87 #endif | |
88 #ifdef __QNXNTO__ | |
89 # include <sys/mman.h> | |
90 # include <sys/dcmd_cam.h> | |
91 #endif | |
92 | |
93 #include "common.h" | |
94 | |
95 #include "ioctl.h" | |
96 | |
97 /***************************************************************************** | |
98 * Local prototypes, BeOS specific | |
99 *****************************************************************************/ | |
100 #if defined( SYS_BEOS ) | |
101 static void BeInitRDC ( raw_device_command *, int ); | |
102 #endif | |
103 | |
104 /***************************************************************************** | |
105 * Local prototypes, HP-UX specific | |
106 *****************************************************************************/ | |
107 #if defined( HPUX_SCTL_IO ) | |
108 static void HPUXInitSCTL ( struct sctl_io *sctl_io, int i_type ); | |
109 #endif | |
110 | |
111 /***************************************************************************** | |
112 * Local prototypes, Solaris specific | |
113 *****************************************************************************/ | |
114 #if defined( SOLARIS_USCSI ) | |
115 static void SolarisInitUSCSI( struct uscsi_cmd *p_sc, int i_type ); | |
8575 | 116 static int SolarisSendUSCSI( int fd, struct uscsi_cmd *p_sc ); |
7027 | 117 #endif |
118 | |
119 /***************************************************************************** | |
120 * Local prototypes, win32 (aspi) specific | |
121 *****************************************************************************/ | |
122 #if defined( WIN32 ) | |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
123 static void WinInitSPTD ( SCSI_PASS_THROUGH_DIRECT *, int ); |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
124 static void WinInitSSC ( struct SRB_ExecSCSICmd *, int ); |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
125 static int WinSendSSC ( int, struct SRB_ExecSCSICmd * ); |
7027 | 126 #endif |
127 | |
128 /***************************************************************************** | |
129 * Local prototypes, QNX specific | |
130 *****************************************************************************/ | |
131 #if defined( __QNXNTO__ ) | |
132 static void QNXInitCPT ( CAM_PASS_THRU *, int ); | |
133 #endif | |
134 | |
135 /***************************************************************************** | |
136 * Local prototypes, OS2 specific | |
137 *****************************************************************************/ | |
138 #if defined( SYS_OS2 ) | |
139 static void OS2InitSDC( struct OS2_ExecSCSICmd *, int ); | |
140 #endif | |
141 | |
142 /***************************************************************************** | |
143 * ioctl_ReadCopyright: check whether the disc is encrypted or not | |
144 *****************************************************************************/ | |
145 int ioctl_ReadCopyright( int i_fd, int i_layer, int *pi_copyright ) | |
146 { | |
147 int i_ret; | |
148 | |
149 #if defined( HAVE_LINUX_DVD_STRUCT ) | |
150 dvd_struct dvd; | |
151 | |
152 memset( &dvd, 0, sizeof( dvd ) ); | |
153 dvd.type = DVD_STRUCT_COPYRIGHT; | |
154 dvd.copyright.layer_num = i_layer; | |
155 | |
156 i_ret = ioctl( i_fd, DVD_READ_STRUCT, &dvd ); | |
157 | |
158 *pi_copyright = dvd.copyright.cpst; | |
159 | |
160 #elif defined( HAVE_BSD_DVD_STRUCT ) | |
161 struct dvd_struct dvd; | |
162 | |
163 memset( &dvd, 0, sizeof( dvd ) ); | |
164 dvd.format = DVD_STRUCT_COPYRIGHT; | |
165 dvd.layer_num = i_layer; | |
166 | |
167 i_ret = ioctl( i_fd, DVDIOCREADSTRUCTURE, &dvd ); | |
168 | |
169 *pi_copyright = dvd.cpst; | |
170 | |
171 #elif defined( SYS_BEOS ) | |
172 INIT_RDC( GPCMD_READ_DVD_STRUCTURE, 8 ); | |
173 | |
174 rdc.command[ 6 ] = i_layer; | |
175 rdc.command[ 7 ] = DVD_STRUCT_COPYRIGHT; | |
176 | |
177 i_ret = ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) ); | |
178 | |
179 *pi_copyright = p_buffer[ 4 ]; | |
180 | |
181 #elif defined( HPUX_SCTL_IO ) | |
182 INIT_SCTL_IO( GPCMD_READ_DVD_STRUCTURE, 8 ); | |
183 | |
184 sctl_io.cdb[ 6 ] = i_layer; | |
185 sctl_io.cdb[ 7 ] = DVD_STRUCT_COPYRIGHT; | |
186 | |
187 i_ret = ioctl( i_fd, SIOC_IO, &sctl_io ); | |
188 | |
189 *pi_copyright = p_buffer[ 4 ]; | |
190 | |
191 #elif defined( SOLARIS_USCSI ) | |
192 INIT_USCSI( GPCMD_READ_DVD_STRUCTURE, 8 ); | |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
193 |
7027 | 194 rs_cdb.cdb_opaque[ 6 ] = i_layer; |
195 rs_cdb.cdb_opaque[ 7 ] = DVD_STRUCT_COPYRIGHT; | |
196 | |
8575 | 197 i_ret = SolarisSendUSCSI(i_fd, &sc); |
7027 | 198 |
199 if( i_ret < 0 || sc.uscsi_status ) { | |
200 i_ret = -1; | |
201 } | |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
202 |
7027 | 203 *pi_copyright = p_buffer[ 4 ]; |
204 /* s->copyright.rmi = p_buffer[ 5 ]; */ | |
205 | |
206 #elif defined( DARWIN_DVD_IOCTL ) | |
207 INIT_DVDIOCTL( dk_dvd_read_structure_t, DVDCopyrightInfo, | |
208 kDVDStructureFormatCopyrightInfo ); | |
209 | |
210 dvd.layer = i_layer; | |
211 | |
212 i_ret = ioctl( i_fd, DKIOCDVDREADSTRUCTURE, &dvd ); | |
213 | |
214 *pi_copyright = dvdbs.copyrightProtectionSystemType; | |
215 | |
216 #elif defined( WIN32 ) | |
8637
0211de3039eb
update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents:
8575
diff
changeset
|
217 if( WIN2K ) /* NT/2k/XP */ |
7027 | 218 { |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
219 INIT_SPTD( GPCMD_READ_DVD_STRUCTURE, 8 ); |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
220 |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
221 /* When using IOCTL_DVD_READ_STRUCTURE and |
8637
0211de3039eb
update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents:
8575
diff
changeset
|
222 DVD_COPYRIGHT_DESCRIPTOR, CopyrightProtectionType |
0211de3039eb
update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents:
8575
diff
changeset
|
223 seems to be always 6 ??? |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
224 To work around this MS bug we try to send a raw scsi command |
8637
0211de3039eb
update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents:
8575
diff
changeset
|
225 instead (if we've got enough privileges to do so). */ |
0211de3039eb
update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents:
8575
diff
changeset
|
226 |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
227 sptd.Cdb[ 6 ] = i_layer; |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
228 sptd.Cdb[ 7 ] = DVD_STRUCT_COPYRIGHT; |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
229 |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
230 i_ret = SEND_SPTD( i_fd, &sptd, &tmp ); |
7027 | 231 |
8637
0211de3039eb
update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents:
8575
diff
changeset
|
232 if( i_ret == 0 ) |
0211de3039eb
update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents:
8575
diff
changeset
|
233 { |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
234 *pi_copyright = p_buffer[ 4 ]; |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
235 } |
8637
0211de3039eb
update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents:
8575
diff
changeset
|
236 } |
7027 | 237 else |
238 { | |
239 INIT_SSC( GPCMD_READ_DVD_STRUCTURE, 8 ); | |
240 | |
241 ssc.CDBByte[ 6 ] = i_layer; | |
242 ssc.CDBByte[ 7 ] = DVD_STRUCT_COPYRIGHT; | |
243 | |
244 i_ret = WinSendSSC( i_fd, &ssc ); | |
245 | |
246 *pi_copyright = p_buffer[ 4 ]; | |
247 } | |
248 | |
249 #elif defined( __QNXNTO__ ) | |
250 | |
251 INIT_CPT( GPCMD_READ_DVD_STRUCTURE, 8 ); | |
252 | |
253 p_cpt->cam_cdb[ 6 ] = i_layer; | |
254 p_cpt->cam_cdb[ 7 ] = DVD_STRUCT_COPYRIGHT; | |
255 | |
256 i_ret = devctl(i_fd, DCMD_CAM_PASS_THRU, p_cpt, structSize, NULL); | |
257 | |
258 *pi_copyright = p_buffer[4]; | |
259 | |
260 #elif defined( SYS_OS2 ) | |
261 INIT_SSC( GPCMD_READ_DVD_STRUCTURE, 8 ); | |
262 | |
263 sdc.command[ 6 ] = i_layer; | |
264 sdc.command[ 7 ] = DVD_STRUCT_COPYRIGHT; | |
265 | |
266 i_ret = DosDevIOCtl(i_fd, IOCTL_CDROMDISK, CDROMDISK_EXECMD, | |
267 &sdc, sizeof(sdc), &ulParamLen, | |
268 p_buffer, sizeof(p_buffer), &ulDataLen); | |
269 | |
270 *pi_copyright = p_buffer[ 4 ]; | |
271 | |
272 #else | |
273 # error "DVD ioctls are unavailable on this system" | |
274 | |
275 #endif | |
276 return i_ret; | |
277 } | |
278 | |
279 /***************************************************************************** | |
280 * ioctl_ReadDiscKey: get the disc key | |
281 *****************************************************************************/ | |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
282 int ioctl_ReadDiscKey( int i_fd, int *pi_agid, uint8_t *p_key ) |
7027 | 283 { |
284 int i_ret; | |
285 | |
286 #if defined( HAVE_LINUX_DVD_STRUCT ) | |
287 dvd_struct dvd; | |
288 | |
289 memset( &dvd, 0, sizeof( dvd ) ); | |
290 dvd.type = DVD_STRUCT_DISCKEY; | |
291 dvd.disckey.agid = *pi_agid; | |
292 memset( dvd.disckey.value, 0, DVD_DISCKEY_SIZE ); | |
293 | |
294 i_ret = ioctl( i_fd, DVD_READ_STRUCT, &dvd ); | |
295 | |
296 if( i_ret < 0 ) | |
297 { | |
298 return i_ret; | |
299 } | |
300 | |
301 memcpy( p_key, dvd.disckey.value, DVD_DISCKEY_SIZE ); | |
302 | |
303 #elif defined( HAVE_BSD_DVD_STRUCT ) | |
304 struct dvd_struct dvd; | |
305 | |
306 memset( &dvd, 0, sizeof( dvd ) ); | |
307 dvd.format = DVD_STRUCT_DISCKEY; | |
308 dvd.agid = *pi_agid; | |
309 memset( dvd.data, 0, DVD_DISCKEY_SIZE ); | |
310 | |
311 i_ret = ioctl( i_fd, DVDIOCREADSTRUCTURE, &dvd ); | |
312 | |
313 if( i_ret < 0 ) | |
314 { | |
315 return i_ret; | |
316 } | |
317 | |
318 memcpy( p_key, dvd.data, DVD_DISCKEY_SIZE ); | |
319 | |
320 #elif defined( SYS_BEOS ) | |
321 INIT_RDC( GPCMD_READ_DVD_STRUCTURE, DVD_DISCKEY_SIZE + 4 ); | |
322 | |
323 rdc.command[ 7 ] = DVD_STRUCT_DISCKEY; | |
324 rdc.command[ 10 ] = *pi_agid << 6; | |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
325 |
7027 | 326 i_ret = ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) ); |
327 | |
328 if( i_ret < 0 ) | |
329 { | |
330 return i_ret; | |
331 } | |
332 | |
333 memcpy( p_key, p_buffer + 4, DVD_DISCKEY_SIZE ); | |
334 | |
335 #elif defined( HPUX_SCTL_IO ) | |
336 INIT_SCTL_IO( GPCMD_READ_DVD_STRUCTURE, DVD_DISCKEY_SIZE + 4 ); | |
337 | |
338 sctl_io.cdb[ 7 ] = DVD_STRUCT_DISCKEY; | |
339 sctl_io.cdb[ 10 ] = *pi_agid << 6; | |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
340 |
7027 | 341 i_ret = ioctl( i_fd, SIOC_IO, &sctl_io ); |
342 | |
343 if( i_ret < 0 ) | |
344 { | |
345 return i_ret; | |
346 } | |
347 | |
348 memcpy( p_key, p_buffer + 4, DVD_DISCKEY_SIZE ); | |
349 | |
350 #elif defined( SOLARIS_USCSI ) | |
351 INIT_USCSI( GPCMD_READ_DVD_STRUCTURE, DVD_DISCKEY_SIZE + 4 ); | |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
352 |
7027 | 353 rs_cdb.cdb_opaque[ 7 ] = DVD_STRUCT_DISCKEY; |
354 rs_cdb.cdb_opaque[ 10 ] = *pi_agid << 6; | |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
355 |
8575 | 356 i_ret = SolarisSendUSCSI( i_fd, &sc ); |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
357 |
7027 | 358 if( i_ret < 0 || sc.uscsi_status ) |
359 { | |
360 i_ret = -1; | |
361 return i_ret; | |
362 } | |
363 | |
364 memcpy( p_key, p_buffer + 4, DVD_DISCKEY_SIZE ); | |
365 | |
366 #elif defined( DARWIN_DVD_IOCTL ) | |
367 INIT_DVDIOCTL( dk_dvd_read_structure_t, DVDDiscKeyInfo, | |
368 kDVDStructureFormatDiscKeyInfo ); | |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
369 |
7027 | 370 dvd.grantID = *pi_agid; |
371 | |
372 i_ret = ioctl( i_fd, DKIOCDVDREADSTRUCTURE, &dvd ); | |
373 | |
374 memcpy( p_key, dvdbs.discKeyStructures, DVD_DISCKEY_SIZE ); | |
375 | |
376 #elif defined( WIN32 ) | |
8637
0211de3039eb
update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents:
8575
diff
changeset
|
377 if( WIN2K ) /* NT/2k/XP */ |
7027 | 378 { |
379 DWORD tmp; | |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
380 uint8_t buffer[DVD_DISK_KEY_LENGTH]; |
7027 | 381 PDVD_COPY_PROTECT_KEY key = (PDVD_COPY_PROTECT_KEY) &buffer; |
382 | |
383 memset( &buffer, 0, sizeof( buffer ) ); | |
384 | |
385 key->KeyLength = DVD_DISK_KEY_LENGTH; | |
386 key->SessionId = *pi_agid; | |
387 key->KeyType = DvdDiskKey; | |
388 key->KeyFlags = 0; | |
389 | |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
390 i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_READ_KEY, key, |
7027 | 391 key->KeyLength, key, key->KeyLength, &tmp, NULL ) ? 0 : -1; |
392 | |
393 if( i_ret < 0 ) | |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
394 { |
7027 | 395 return i_ret; |
396 } | |
397 | |
398 memcpy( p_key, key->KeyData, DVD_DISCKEY_SIZE ); | |
399 } | |
400 else | |
401 { | |
402 INIT_SSC( GPCMD_READ_DVD_STRUCTURE, DVD_DISCKEY_SIZE + 4 ); | |
403 | |
404 ssc.CDBByte[ 7 ] = DVD_STRUCT_DISCKEY; | |
405 ssc.CDBByte[ 10 ] = *pi_agid << 6; | |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
406 |
7027 | 407 i_ret = WinSendSSC( i_fd, &ssc ); |
408 | |
409 if( i_ret < 0 ) | |
410 { | |
411 return i_ret; | |
412 } | |
413 | |
414 memcpy( p_key, p_buffer + 4, DVD_DISCKEY_SIZE ); | |
415 } | |
416 | |
417 #elif defined( __QNXNTO__ ) | |
418 | |
419 INIT_CPT( GPCMD_READ_DVD_STRUCTURE, DVD_DISCKEY_SIZE + 4 ); | |
420 | |
421 p_cpt->cam_cdb[ 7 ] = DVD_STRUCT_DISCKEY; | |
422 p_cpt->cam_cdb[ 10 ] = *pi_agid << 6; | |
423 | |
424 i_ret = devctl(i_fd, DCMD_CAM_PASS_THRU, p_cpt, structSize, NULL); | |
425 | |
426 memcpy( p_key, p_buffer + 4, DVD_DISCKEY_SIZE ); | |
427 | |
428 #elif defined ( SYS_OS2 ) | |
429 INIT_SSC( GPCMD_READ_DVD_STRUCTURE, DVD_DISCKEY_SIZE + 4 ); | |
430 | |
431 sdc.command[ 7 ] = DVD_STRUCT_DISCKEY; | |
432 sdc.command[ 10 ] = *pi_agid << 6; | |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
433 |
7027 | 434 i_ret = DosDevIOCtl(i_fd, IOCTL_CDROMDISK, CDROMDISK_EXECMD, |
435 &sdc, sizeof(sdc), &ulParamLen, | |
436 p_buffer, sizeof(p_buffer), &ulDataLen); | |
437 | |
438 if( i_ret < 0 ) | |
439 { | |
440 return i_ret; | |
441 } | |
442 | |
443 memcpy( p_key, p_buffer + 4, DVD_DISCKEY_SIZE ); | |
444 | |
445 #else | |
446 # error "DVD ioctls are unavailable on this system" | |
447 | |
448 #endif | |
449 return i_ret; | |
450 } | |
451 | |
452 /***************************************************************************** | |
453 * ioctl_ReadTitleKey: get the title key | |
454 *****************************************************************************/ | |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
455 int ioctl_ReadTitleKey( int i_fd, int *pi_agid, int i_pos, uint8_t *p_key ) |
7027 | 456 { |
457 int i_ret; | |
458 | |
459 #if defined( HAVE_LINUX_DVD_STRUCT ) | |
460 dvd_authinfo auth_info; | |
461 | |
462 memset( &auth_info, 0, sizeof( auth_info ) ); | |
463 auth_info.type = DVD_LU_SEND_TITLE_KEY; | |
464 auth_info.lstk.agid = *pi_agid; | |
465 auth_info.lstk.lba = i_pos; | |
466 | |
467 i_ret = ioctl( i_fd, DVD_AUTH, &auth_info ); | |
468 | |
469 memcpy( p_key, auth_info.lstk.title_key, DVD_KEY_SIZE ); | |
470 | |
471 #elif defined( HAVE_BSD_DVD_STRUCT ) | |
472 struct dvd_authinfo auth_info; | |
473 | |
474 memset( &auth_info, 0, sizeof( auth_info ) ); | |
475 auth_info.format = DVD_REPORT_TITLE_KEY; | |
476 auth_info.agid = *pi_agid; | |
477 auth_info.lba = i_pos; | |
478 | |
479 i_ret = ioctl( i_fd, DVDIOCREPORTKEY, &auth_info ); | |
480 | |
481 memcpy( p_key, auth_info.keychal, DVD_KEY_SIZE ); | |
482 | |
483 #elif defined( SYS_BEOS ) | |
484 INIT_RDC( GPCMD_REPORT_KEY, 12 ); | |
485 | |
486 rdc.command[ 2 ] = ( i_pos >> 24 ) & 0xff; | |
487 rdc.command[ 3 ] = ( i_pos >> 16 ) & 0xff; | |
488 rdc.command[ 4 ] = ( i_pos >> 8 ) & 0xff; | |
489 rdc.command[ 5 ] = ( i_pos ) & 0xff; | |
490 rdc.command[ 10 ] = DVD_REPORT_TITLE_KEY | (*pi_agid << 6); | |
491 | |
492 i_ret = ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) ); | |
493 | |
494 memcpy( p_key, p_buffer + 5, DVD_KEY_SIZE ); | |
495 | |
496 #elif defined( HPUX_SCTL_IO ) | |
497 INIT_SCTL_IO( GPCMD_REPORT_KEY, 12 ); | |
498 | |
499 sctl_io.cdb[ 2 ] = ( i_pos >> 24 ) & 0xff; | |
500 sctl_io.cdb[ 3 ] = ( i_pos >> 16 ) & 0xff; | |
501 sctl_io.cdb[ 4 ] = ( i_pos >> 8 ) & 0xff; | |
502 sctl_io.cdb[ 5 ] = ( i_pos ) & 0xff; | |
503 sctl_io.cdb[ 10 ] = DVD_REPORT_TITLE_KEY | (*pi_agid << 6); | |
504 | |
505 i_ret = ioctl( i_fd, SIOC_IO, &sctl_io ); | |
506 | |
507 memcpy( p_key, p_buffer + 5, DVD_KEY_SIZE ); | |
508 | |
509 #elif defined( SOLARIS_USCSI ) | |
510 INIT_USCSI( GPCMD_REPORT_KEY, 12 ); | |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
511 |
7027 | 512 rs_cdb.cdb_opaque[ 2 ] = ( i_pos >> 24 ) & 0xff; |
513 rs_cdb.cdb_opaque[ 3 ] = ( i_pos >> 16 ) & 0xff; | |
514 rs_cdb.cdb_opaque[ 4 ] = ( i_pos >> 8 ) & 0xff; | |
515 rs_cdb.cdb_opaque[ 5 ] = ( i_pos ) & 0xff; | |
516 rs_cdb.cdb_opaque[ 10 ] = DVD_REPORT_TITLE_KEY | (*pi_agid << 6); | |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
517 |
8575 | 518 i_ret = SolarisSendUSCSI( i_fd, &sc ); |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
519 |
7027 | 520 if( i_ret < 0 || sc.uscsi_status ) |
521 { | |
522 i_ret = -1; | |
523 } | |
524 | |
525 /* Do we want to return the cp_sec flag perhaps? */ | |
526 /* a->lstk.cpm = (buf[ 4 ] >> 7) & 1; */ | |
527 /* a->lstk.cp_sec = (buf[ 4 ] >> 6) & 1; */ | |
528 /* a->lstk.cgms = (buf[ 4 ] >> 4) & 3; */ | |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
529 |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
530 memcpy( p_key, p_buffer + 5, DVD_KEY_SIZE ); |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
531 |
7027 | 532 #elif defined( DARWIN_DVD_IOCTL ) |
533 INIT_DVDIOCTL( dk_dvd_report_key_t, DVDTitleKeyInfo, | |
534 kDVDKeyFormatTitleKey ); | |
535 | |
536 dvd.address = i_pos; | |
537 dvd.grantID = *pi_agid; | |
538 dvd.keyClass = kDVDKeyClassCSS_CPPM_CPRM; | |
539 | |
540 i_ret = ioctl( i_fd, DKIOCDVDREPORTKEY, &dvd ); | |
541 | |
542 memcpy( p_key, dvdbs.titleKeyValue, DVD_KEY_SIZE ); | |
543 | |
544 #elif defined( WIN32 ) | |
8637
0211de3039eb
update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents:
8575
diff
changeset
|
545 if( WIN2K ) /* NT/2k/XP */ |
7027 | 546 { |
547 DWORD tmp; | |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
548 uint8_t buffer[DVD_TITLE_KEY_LENGTH]; |
7027 | 549 PDVD_COPY_PROTECT_KEY key = (PDVD_COPY_PROTECT_KEY) &buffer; |
550 | |
551 memset( &buffer, 0, sizeof( buffer ) ); | |
552 | |
553 key->KeyLength = DVD_TITLE_KEY_LENGTH; | |
554 key->SessionId = *pi_agid; | |
555 key->KeyType = DvdTitleKey; | |
556 key->KeyFlags = 0; | |
8637
0211de3039eb
update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents:
8575
diff
changeset
|
557 key->Parameters.TitleOffset.QuadPart = (LONGLONG) i_pos * |
0211de3039eb
update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents:
8575
diff
changeset
|
558 2048 /*DVDCSS_BLOCK_SIZE*/; |
7027 | 559 |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
560 i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_READ_KEY, key, |
7027 | 561 key->KeyLength, key, key->KeyLength, &tmp, NULL ) ? 0 : -1; |
562 | |
563 memcpy( p_key, key->KeyData, DVD_KEY_SIZE ); | |
564 } | |
565 else | |
566 { | |
567 INIT_SSC( GPCMD_REPORT_KEY, 12 ); | |
568 | |
569 ssc.CDBByte[ 2 ] = ( i_pos >> 24 ) & 0xff; | |
570 ssc.CDBByte[ 3 ] = ( i_pos >> 16 ) & 0xff; | |
571 ssc.CDBByte[ 4 ] = ( i_pos >> 8 ) & 0xff; | |
572 ssc.CDBByte[ 5 ] = ( i_pos ) & 0xff; | |
573 ssc.CDBByte[ 10 ] = DVD_REPORT_TITLE_KEY | (*pi_agid << 6); | |
574 | |
575 i_ret = WinSendSSC( i_fd, &ssc ); | |
576 | |
577 memcpy( p_key, p_buffer + 5, DVD_KEY_SIZE ); | |
578 } | |
579 | |
580 #elif defined( __QNXNTO__ ) | |
581 | |
582 INIT_CPT( GPCMD_REPORT_KEY, 12 ); | |
583 | |
584 p_cpt->cam_cdb[ 2 ] = ( i_pos >> 24 ) & 0xff; | |
585 p_cpt->cam_cdb[ 3 ] = ( i_pos >> 16 ) & 0xff; | |
586 p_cpt->cam_cdb[ 4 ] = ( i_pos >> 8 ) & 0xff; | |
587 p_cpt->cam_cdb[ 5 ] = ( i_pos ) & 0xff; | |
588 p_cpt->cam_cdb[ 10 ] = DVD_REPORT_TITLE_KEY | (*pi_agid << 6); | |
589 | |
590 i_ret = devctl(i_fd, DCMD_CAM_PASS_THRU, p_cpt, structSize, NULL); | |
591 | |
592 memcpy( p_key, p_buffer + 5, DVD_KEY_SIZE ); | |
593 | |
594 #elif defined( SYS_OS2 ) | |
595 INIT_SSC( GPCMD_REPORT_KEY, 12 ); | |
596 | |
597 sdc.command[ 2 ] = ( i_pos >> 24 ) & 0xff; | |
598 sdc.command[ 3 ] = ( i_pos >> 16 ) & 0xff; | |
599 sdc.command[ 4 ] = ( i_pos >> 8 ) & 0xff; | |
600 sdc.command[ 5 ] = ( i_pos ) & 0xff; | |
601 sdc.command[ 10 ] = DVD_REPORT_TITLE_KEY | (*pi_agid << 6); | |
602 | |
603 i_ret = DosDevIOCtl(i_fd, IOCTL_CDROMDISK, CDROMDISK_EXECMD, | |
604 &sdc, sizeof(sdc), &ulParamLen, | |
605 p_buffer, sizeof(p_buffer), &ulDataLen); | |
606 | |
607 memcpy( p_key, p_buffer + 5, DVD_KEY_SIZE ); | |
608 | |
609 #else | |
610 # error "DVD ioctls are unavailable on this system" | |
611 | |
612 #endif | |
613 | |
614 return i_ret; | |
615 } | |
616 | |
617 | |
618 /***************************************************************************** | |
619 * ioctl_ReportAgid: get AGID from the drive | |
620 *****************************************************************************/ | |
621 int ioctl_ReportAgid( int i_fd, int *pi_agid ) | |
622 { | |
623 int i_ret; | |
624 | |
625 #if defined( HAVE_LINUX_DVD_STRUCT ) | |
626 dvd_authinfo auth_info; | |
627 | |
628 memset( &auth_info, 0, sizeof( auth_info ) ); | |
629 auth_info.type = DVD_LU_SEND_AGID; | |
630 auth_info.lsa.agid = *pi_agid; | |
631 | |
632 i_ret = ioctl( i_fd, DVD_AUTH, &auth_info ); | |
633 | |
634 *pi_agid = auth_info.lsa.agid; | |
635 | |
636 #elif defined( HAVE_BSD_DVD_STRUCT ) | |
637 struct dvd_authinfo auth_info; | |
638 | |
639 memset( &auth_info, 0, sizeof( auth_info ) ); | |
640 auth_info.format = DVD_REPORT_AGID; | |
641 auth_info.agid = *pi_agid; | |
642 | |
643 i_ret = ioctl( i_fd, DVDIOCREPORTKEY, &auth_info ); | |
644 | |
645 *pi_agid = auth_info.agid; | |
646 | |
647 #elif defined( SYS_BEOS ) | |
648 INIT_RDC( GPCMD_REPORT_KEY, 8 ); | |
649 | |
650 rdc.command[ 10 ] = DVD_REPORT_AGID | (*pi_agid << 6); | |
651 | |
652 i_ret = ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) ); | |
653 | |
654 *pi_agid = p_buffer[ 7 ] >> 6; | |
655 | |
656 #elif defined( HPUX_SCTL_IO ) | |
657 INIT_SCTL_IO( GPCMD_REPORT_KEY, 8 ); | |
658 | |
659 sctl_io.cdb[ 10 ] = DVD_REPORT_AGID | (*pi_agid << 6); | |
660 | |
661 i_ret = ioctl( i_fd, SIOC_IO, &sctl_io ); | |
662 | |
663 *pi_agid = p_buffer[ 7 ] >> 6; | |
664 | |
665 #elif defined( SOLARIS_USCSI ) | |
666 INIT_USCSI( GPCMD_REPORT_KEY, 8 ); | |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
667 |
7027 | 668 rs_cdb.cdb_opaque[ 10 ] = DVD_REPORT_AGID | (*pi_agid << 6); |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
669 |
8575 | 670 i_ret = SolarisSendUSCSI( i_fd, &sc ); |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
671 |
7027 | 672 if( i_ret < 0 || sc.uscsi_status ) |
673 { | |
674 i_ret = -1; | |
675 } | |
676 | |
677 *pi_agid = p_buffer[ 7 ] >> 6; | |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
678 |
7027 | 679 #elif defined( DARWIN_DVD_IOCTL ) |
680 INIT_DVDIOCTL( dk_dvd_report_key_t, DVDAuthenticationGrantIDInfo, | |
681 kDVDKeyFormatAGID_CSS ); | |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
682 |
7027 | 683 dvd.grantID = *pi_agid; |
684 dvd.keyClass = kDVDKeyClassCSS_CPPM_CPRM; | |
685 | |
686 i_ret = ioctl( i_fd, DKIOCDVDREPORTKEY, &dvd ); | |
687 | |
688 *pi_agid = dvdbs.grantID; | |
689 | |
690 #elif defined( WIN32 ) | |
8637
0211de3039eb
update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents:
8575
diff
changeset
|
691 if( WIN2K ) /* NT/2k/XP */ |
7027 | 692 { |
693 ULONG id; | |
694 DWORD tmp; | |
695 | |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
696 i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_START_SESSION, |
7027 | 697 &tmp, 4, &id, sizeof( id ), &tmp, NULL ) ? 0 : -1; |
698 | |
699 *pi_agid = id; | |
700 } | |
701 else | |
702 { | |
703 INIT_SSC( GPCMD_REPORT_KEY, 8 ); | |
704 | |
705 ssc.CDBByte[ 10 ] = DVD_REPORT_AGID | (*pi_agid << 6); | |
706 | |
707 i_ret = WinSendSSC( i_fd, &ssc ); | |
708 | |
709 *pi_agid = p_buffer[ 7 ] >> 6; | |
710 } | |
711 | |
712 #elif defined( __QNXNTO__ ) | |
713 | |
714 INIT_CPT( GPCMD_REPORT_KEY, 8 ); | |
715 | |
716 p_cpt->cam_cdb[ 10 ] = DVD_REPORT_AGID | (*pi_agid << 6); | |
717 | |
718 i_ret = devctl(i_fd, DCMD_CAM_PASS_THRU, p_cpt, structSize, NULL); | |
719 | |
720 *pi_agid = p_buffer[ 7 ] >> 6; | |
721 | |
722 #elif defined( SYS_OS2 ) | |
723 INIT_SSC( GPCMD_REPORT_KEY, 8 ); | |
724 | |
725 sdc.command[ 10 ] = DVD_REPORT_AGID | (*pi_agid << 6); | |
726 | |
727 i_ret = DosDevIOCtl(i_fd, IOCTL_CDROMDISK, CDROMDISK_EXECMD, | |
728 &sdc, sizeof(sdc), &ulParamLen, | |
729 p_buffer, sizeof(p_buffer), &ulDataLen); | |
730 | |
731 *pi_agid = p_buffer[ 7 ] >> 6; | |
732 | |
733 #else | |
734 # error "DVD ioctls are unavailable on this system" | |
735 | |
736 #endif | |
737 return i_ret; | |
738 } | |
739 | |
740 /***************************************************************************** | |
741 * ioctl_ReportChallenge: get challenge from the drive | |
742 *****************************************************************************/ | |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
743 int ioctl_ReportChallenge( int i_fd, int *pi_agid, uint8_t *p_challenge ) |
7027 | 744 { |
745 int i_ret; | |
746 | |
747 #if defined( HAVE_LINUX_DVD_STRUCT ) | |
748 dvd_authinfo auth_info; | |
749 | |
750 memset( &auth_info, 0, sizeof( auth_info ) ); | |
751 auth_info.type = DVD_LU_SEND_CHALLENGE; | |
752 auth_info.lsc.agid = *pi_agid; | |
753 | |
754 i_ret = ioctl( i_fd, DVD_AUTH, &auth_info ); | |
755 | |
756 memcpy( p_challenge, auth_info.lsc.chal, DVD_CHALLENGE_SIZE ); | |
757 | |
758 #elif defined( HAVE_BSD_DVD_STRUCT ) | |
759 struct dvd_authinfo auth_info; | |
760 | |
761 memset( &auth_info, 0, sizeof( auth_info ) ); | |
762 auth_info.format = DVD_REPORT_CHALLENGE; | |
763 auth_info.agid = *pi_agid; | |
764 | |
765 i_ret = ioctl( i_fd, DVDIOCREPORTKEY, &auth_info ); | |
766 | |
767 memcpy( p_challenge, auth_info.keychal, DVD_CHALLENGE_SIZE ); | |
768 | |
769 #elif defined( SYS_BEOS ) | |
770 INIT_RDC( GPCMD_REPORT_KEY, 16 ); | |
771 | |
772 rdc.command[ 10 ] = DVD_REPORT_CHALLENGE | (*pi_agid << 6); | |
773 | |
774 i_ret = ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) ); | |
775 | |
776 memcpy( p_challenge, p_buffer + 4, DVD_CHALLENGE_SIZE ); | |
777 | |
778 #elif defined( HPUX_SCTL_IO ) | |
779 INIT_SCTL_IO( GPCMD_REPORT_KEY, 16 ); | |
780 | |
781 sctl_io.cdb[ 10 ] = DVD_REPORT_CHALLENGE | (*pi_agid << 6); | |
782 | |
783 i_ret = ioctl( i_fd, SIOC_IO, &sctl_io ); | |
784 | |
785 memcpy( p_challenge, p_buffer + 4, DVD_CHALLENGE_SIZE ); | |
786 | |
787 #elif defined( SOLARIS_USCSI ) | |
788 INIT_USCSI( GPCMD_REPORT_KEY, 16 ); | |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
789 |
7027 | 790 rs_cdb.cdb_opaque[ 10 ] = DVD_REPORT_CHALLENGE | (*pi_agid << 6); |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
791 |
8575 | 792 i_ret = SolarisSendUSCSI( i_fd, &sc ); |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
793 |
7027 | 794 if( i_ret < 0 || sc.uscsi_status ) |
795 { | |
796 i_ret = -1; | |
797 } | |
798 | |
799 memcpy( p_challenge, p_buffer + 4, DVD_CHALLENGE_SIZE ); | |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
800 |
7027 | 801 #elif defined( DARWIN_DVD_IOCTL ) |
802 INIT_DVDIOCTL( dk_dvd_report_key_t, DVDChallengeKeyInfo, | |
803 kDVDKeyFormatChallengeKey ); | |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
804 |
7027 | 805 dvd.grantID = *pi_agid; |
806 | |
807 i_ret = ioctl( i_fd, DKIOCDVDREPORTKEY, &dvd ); | |
808 | |
809 memcpy( p_challenge, dvdbs.challengeKeyValue, DVD_CHALLENGE_SIZE ); | |
810 | |
811 #elif defined( WIN32 ) | |
8637
0211de3039eb
update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents:
8575
diff
changeset
|
812 if( WIN2K ) /* NT/2k/XP */ |
7027 | 813 { |
814 DWORD tmp; | |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
815 uint8_t buffer[DVD_CHALLENGE_KEY_LENGTH]; |
7027 | 816 PDVD_COPY_PROTECT_KEY key = (PDVD_COPY_PROTECT_KEY) &buffer; |
817 | |
818 memset( &buffer, 0, sizeof( buffer ) ); | |
819 | |
820 key->KeyLength = DVD_CHALLENGE_KEY_LENGTH; | |
821 key->SessionId = *pi_agid; | |
822 key->KeyType = DvdChallengeKey; | |
823 key->KeyFlags = 0; | |
824 | |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
825 i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_READ_KEY, key, |
7027 | 826 key->KeyLength, key, key->KeyLength, &tmp, NULL ) ? 0 : -1; |
827 | |
828 if( i_ret < 0 ) | |
829 { | |
830 return i_ret; | |
831 } | |
832 | |
833 memcpy( p_challenge, key->KeyData, DVD_CHALLENGE_SIZE ); | |
834 } | |
835 else | |
836 { | |
837 INIT_SSC( GPCMD_REPORT_KEY, 16 ); | |
838 | |
839 ssc.CDBByte[ 10 ] = DVD_REPORT_CHALLENGE | (*pi_agid << 6); | |
840 | |
841 i_ret = WinSendSSC( i_fd, &ssc ); | |
842 | |
843 memcpy( p_challenge, p_buffer + 4, DVD_CHALLENGE_SIZE ); | |
844 } | |
845 | |
846 #elif defined( __QNXNTO__ ) | |
847 | |
848 INIT_CPT( GPCMD_REPORT_KEY, 16 ); | |
849 | |
850 p_cpt->cam_cdb[ 10 ] = DVD_REPORT_CHALLENGE | (*pi_agid << 6); | |
851 | |
852 i_ret = devctl(i_fd, DCMD_CAM_PASS_THRU, p_cpt, structSize, NULL); | |
853 | |
854 memcpy( p_challenge, p_buffer + 4, DVD_CHALLENGE_SIZE ); | |
855 | |
856 #elif defined( SYS_OS2 ) | |
857 INIT_SSC( GPCMD_REPORT_KEY, 16 ); | |
858 | |
859 sdc.command[ 10 ] = DVD_REPORT_CHALLENGE | (*pi_agid << 6); | |
860 | |
861 i_ret = DosDevIOCtl(i_fd, IOCTL_CDROMDISK, CDROMDISK_EXECMD, | |
862 &sdc, sizeof(sdc), &ulParamLen, | |
863 p_buffer, sizeof(p_buffer), &ulDataLen); | |
864 | |
865 memcpy( p_challenge, p_buffer + 4, DVD_CHALLENGE_SIZE ); | |
866 | |
867 #else | |
868 # error "DVD ioctls are unavailable on this system" | |
869 | |
870 #endif | |
871 return i_ret; | |
872 } | |
873 | |
874 /***************************************************************************** | |
875 * ioctl_ReportASF: get ASF from the drive | |
876 *****************************************************************************/ | |
877 int ioctl_ReportASF( int i_fd, int *pi_remove_me, int *pi_asf ) | |
878 { | |
879 int i_ret; | |
880 | |
881 #if defined( HAVE_LINUX_DVD_STRUCT ) | |
882 dvd_authinfo auth_info; | |
883 | |
884 memset( &auth_info, 0, sizeof( auth_info ) ); | |
885 auth_info.type = DVD_LU_SEND_ASF; | |
886 auth_info.lsasf.asf = *pi_asf; | |
887 | |
888 i_ret = ioctl( i_fd, DVD_AUTH, &auth_info ); | |
889 | |
890 *pi_asf = auth_info.lsasf.asf; | |
891 | |
892 #elif defined( HAVE_BSD_DVD_STRUCT ) | |
893 struct dvd_authinfo auth_info; | |
894 | |
895 memset( &auth_info, 0, sizeof( auth_info ) ); | |
896 auth_info.format = DVD_REPORT_ASF; | |
897 auth_info.asf = *pi_asf; | |
898 | |
899 i_ret = ioctl( i_fd, DVDIOCREPORTKEY, &auth_info ); | |
900 | |
901 *pi_asf = auth_info.asf; | |
902 | |
903 #elif defined( SYS_BEOS ) | |
904 INIT_RDC( GPCMD_REPORT_KEY, 8 ); | |
905 | |
906 rdc.command[ 10 ] = DVD_REPORT_ASF; | |
907 | |
908 i_ret = ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) ); | |
909 | |
910 *pi_asf = p_buffer[ 7 ] & 1; | |
911 | |
912 #elif defined( HPUX_SCTL_IO ) | |
913 INIT_SCTL_IO( GPCMD_REPORT_KEY, 8 ); | |
914 | |
915 sctl_io.cdb[ 10 ] = DVD_REPORT_ASF; | |
916 | |
917 i_ret = ioctl( i_fd, SIOC_IO, &sctl_io ); | |
918 | |
919 *pi_asf = p_buffer[ 7 ] & 1; | |
920 | |
921 #elif defined( SOLARIS_USCSI ) | |
922 INIT_USCSI( GPCMD_REPORT_KEY, 8 ); | |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
923 |
7027 | 924 rs_cdb.cdb_opaque[ 10 ] = DVD_REPORT_ASF; |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
925 |
8575 | 926 i_ret = SolarisSendUSCSI( i_fd, &sc ); |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
927 |
7027 | 928 if( i_ret < 0 || sc.uscsi_status ) |
929 { | |
930 i_ret = -1; | |
931 } | |
932 | |
933 *pi_asf = p_buffer[ 7 ] & 1; | |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
934 |
7027 | 935 #elif defined( DARWIN_DVD_IOCTL ) |
936 INIT_DVDIOCTL( dk_dvd_report_key_t, DVDAuthenticationSuccessFlagInfo, | |
937 kDVDKeyFormatASF ); | |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
938 |
7027 | 939 i_ret = ioctl( i_fd, DKIOCDVDREPORTKEY, &dvd ); |
940 | |
941 *pi_asf = dvdbs.successFlag; | |
942 | |
943 #elif defined( WIN32 ) | |
8637
0211de3039eb
update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents:
8575
diff
changeset
|
944 if( WIN2K ) /* NT/2k/XP */ |
7027 | 945 { |
946 DWORD tmp; | |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
947 uint8_t buffer[DVD_ASF_LENGTH]; |
7027 | 948 PDVD_COPY_PROTECT_KEY key = (PDVD_COPY_PROTECT_KEY) &buffer; |
949 | |
950 memset( &buffer, 0, sizeof( buffer ) ); | |
951 | |
952 key->KeyLength = DVD_ASF_LENGTH; | |
953 key->KeyType = DvdAsf; | |
954 key->KeyFlags = 0; | |
955 | |
956 ((PDVD_ASF)key->KeyData)->SuccessFlag = *pi_asf; | |
957 | |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
958 i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_READ_KEY, key, |
7027 | 959 key->KeyLength, key, key->KeyLength, &tmp, NULL ) ? 0 : -1; |
960 | |
961 if( i_ret < 0 ) | |
962 { | |
963 return i_ret; | |
964 } | |
965 | |
966 *pi_asf = ((PDVD_ASF)key->KeyData)->SuccessFlag; | |
967 } | |
968 else | |
969 { | |
970 INIT_SSC( GPCMD_REPORT_KEY, 8 ); | |
971 | |
972 ssc.CDBByte[ 10 ] = DVD_REPORT_ASF; | |
973 | |
974 i_ret = WinSendSSC( i_fd, &ssc ); | |
975 | |
976 *pi_asf = p_buffer[ 7 ] & 1; | |
977 } | |
978 | |
979 #elif defined( __QNXNTO__ ) | |
980 | |
981 INIT_CPT( GPCMD_REPORT_KEY, 8 ); | |
982 | |
983 p_cpt->cam_cdb[ 10 ] = DVD_REPORT_ASF; | |
984 | |
985 i_ret = devctl(i_fd, DCMD_CAM_PASS_THRU, p_cpt, structSize, NULL); | |
986 | |
987 *pi_asf = p_buffer[ 7 ] & 1; | |
988 | |
989 #elif defined( SYS_OS2 ) | |
990 INIT_SSC( GPCMD_REPORT_KEY, 8 ); | |
991 | |
992 sdc.command[ 10 ] = DVD_REPORT_ASF; | |
993 | |
994 i_ret = DosDevIOCtl(i_fd, IOCTL_CDROMDISK, CDROMDISK_EXECMD, | |
995 &sdc, sizeof(sdc), &ulParamLen, | |
996 p_buffer, sizeof(p_buffer), &ulDataLen); | |
997 | |
998 *pi_asf = p_buffer[ 7 ] & 1; | |
999 | |
1000 #else | |
1001 # error "DVD ioctls are unavailable on this system" | |
1002 | |
1003 #endif | |
1004 return i_ret; | |
1005 } | |
1006 | |
1007 /***************************************************************************** | |
1008 * ioctl_ReportKey1: get the first key from the drive | |
1009 *****************************************************************************/ | |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1010 int ioctl_ReportKey1( int i_fd, int *pi_agid, uint8_t *p_key ) |
7027 | 1011 { |
1012 int i_ret; | |
1013 | |
1014 #if defined( HAVE_LINUX_DVD_STRUCT ) | |
1015 dvd_authinfo auth_info; | |
1016 | |
1017 memset( &auth_info, 0, sizeof( auth_info ) ); | |
1018 auth_info.type = DVD_LU_SEND_KEY1; | |
1019 auth_info.lsk.agid = *pi_agid; | |
1020 | |
1021 i_ret = ioctl( i_fd, DVD_AUTH, &auth_info ); | |
1022 | |
1023 memcpy( p_key, auth_info.lsk.key, DVD_KEY_SIZE ); | |
1024 | |
1025 #elif defined( HAVE_BSD_DVD_STRUCT ) | |
1026 struct dvd_authinfo auth_info; | |
1027 | |
1028 memset( &auth_info, 0, sizeof( auth_info ) ); | |
1029 auth_info.format = DVD_REPORT_KEY1; | |
1030 auth_info.agid = *pi_agid; | |
1031 | |
1032 i_ret = ioctl( i_fd, DVDIOCREPORTKEY, &auth_info ); | |
1033 | |
1034 memcpy( p_key, auth_info.keychal, DVD_KEY_SIZE ); | |
1035 | |
1036 #elif defined( SYS_BEOS ) | |
1037 INIT_RDC( GPCMD_REPORT_KEY, 12 ); | |
1038 | |
1039 rdc.command[ 10 ] = DVD_REPORT_KEY1 | (*pi_agid << 6); | |
1040 | |
1041 i_ret = ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) ); | |
1042 | |
1043 memcpy( p_key, p_buffer + 4, DVD_KEY_SIZE ); | |
1044 | |
1045 #elif defined( HPUX_SCTL_IO ) | |
1046 INIT_SCTL_IO( GPCMD_REPORT_KEY, 12 ); | |
1047 | |
1048 sctl_io.cdb[ 10 ] = DVD_REPORT_KEY1 | (*pi_agid << 6); | |
1049 | |
1050 i_ret = ioctl( i_fd, SIOC_IO, &sctl_io ); | |
1051 | |
1052 memcpy( p_key, p_buffer + 4, DVD_KEY_SIZE ); | |
1053 | |
1054 #elif defined( SOLARIS_USCSI ) | |
1055 INIT_USCSI( GPCMD_REPORT_KEY, 12 ); | |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1056 |
7027 | 1057 rs_cdb.cdb_opaque[ 10 ] = DVD_REPORT_KEY1 | (*pi_agid << 6); |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1058 |
8575 | 1059 i_ret = SolarisSendUSCSI( i_fd, &sc ); |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1060 |
7027 | 1061 if( i_ret < 0 || sc.uscsi_status ) |
1062 { | |
1063 i_ret = -1; | |
1064 } | |
1065 | |
1066 memcpy( p_key, p_buffer + 4, DVD_KEY_SIZE ); | |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1067 |
7027 | 1068 #elif defined( DARWIN_DVD_IOCTL ) |
1069 INIT_DVDIOCTL( dk_dvd_report_key_t, DVDKey1Info, | |
1070 kDVDKeyFormatKey1 ); | |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1071 |
7027 | 1072 dvd.grantID = *pi_agid; |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1073 |
7027 | 1074 i_ret = ioctl( i_fd, DKIOCDVDREPORTKEY, &dvd ); |
1075 | |
1076 memcpy( p_key, dvdbs.key1Value, DVD_KEY_SIZE ); | |
1077 | |
1078 #elif defined( WIN32 ) | |
8637
0211de3039eb
update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents:
8575
diff
changeset
|
1079 if( WIN2K ) /* NT/2k/XP */ |
7027 | 1080 { |
1081 DWORD tmp; | |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1082 uint8_t buffer[DVD_BUS_KEY_LENGTH]; |
7027 | 1083 PDVD_COPY_PROTECT_KEY key = (PDVD_COPY_PROTECT_KEY) &buffer; |
1084 | |
1085 memset( &buffer, 0, sizeof( buffer ) ); | |
1086 | |
1087 key->KeyLength = DVD_BUS_KEY_LENGTH; | |
1088 key->SessionId = *pi_agid; | |
1089 key->KeyType = DvdBusKey1; | |
1090 key->KeyFlags = 0; | |
1091 | |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1092 i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_READ_KEY, key, |
7027 | 1093 key->KeyLength, key, key->KeyLength, &tmp, NULL ) ? 0 : -1; |
1094 | |
1095 memcpy( p_key, key->KeyData, DVD_KEY_SIZE ); | |
1096 } | |
1097 else | |
1098 { | |
1099 INIT_SSC( GPCMD_REPORT_KEY, 12 ); | |
1100 | |
1101 ssc.CDBByte[ 10 ] = DVD_REPORT_KEY1 | (*pi_agid << 6); | |
1102 | |
1103 i_ret = WinSendSSC( i_fd, &ssc ); | |
1104 | |
1105 memcpy( p_key, p_buffer + 4, DVD_KEY_SIZE ); | |
1106 } | |
1107 | |
1108 #elif defined( __QNXNTO__ ) | |
1109 | |
1110 INIT_CPT( GPCMD_REPORT_KEY, 12 ); | |
1111 | |
1112 p_cpt->cam_cdb[ 10 ] = DVD_REPORT_KEY1 | (*pi_agid << 6); | |
1113 | |
1114 i_ret = devctl(i_fd, DCMD_CAM_PASS_THRU, p_cpt, structSize, NULL); | |
1115 | |
1116 memcpy( p_key, p_buffer + 4, DVD_KEY_SIZE ); | |
1117 | |
1118 #elif defined( SYS_OS2 ) | |
1119 INIT_SSC( GPCMD_REPORT_KEY, 12 ); | |
1120 | |
1121 sdc.command[ 10 ] = DVD_REPORT_KEY1 | (*pi_agid << 6); | |
1122 | |
1123 i_ret = DosDevIOCtl(i_fd, IOCTL_CDROMDISK, CDROMDISK_EXECMD, | |
1124 &sdc, sizeof(sdc), &ulParamLen, | |
1125 p_buffer, sizeof(p_buffer), &ulDataLen); | |
1126 | |
1127 memcpy( p_key, p_buffer + 4, DVD_KEY_SIZE ); | |
1128 | |
1129 #else | |
1130 # error "DVD ioctls are unavailable on this system" | |
1131 | |
1132 #endif | |
1133 return i_ret; | |
1134 } | |
1135 | |
1136 /***************************************************************************** | |
1137 * ioctl_InvalidateAgid: invalidate the current AGID | |
1138 *****************************************************************************/ | |
1139 int ioctl_InvalidateAgid( int i_fd, int *pi_agid ) | |
1140 { | |
1141 int i_ret; | |
1142 | |
1143 #if defined( HAVE_LINUX_DVD_STRUCT ) | |
1144 dvd_authinfo auth_info; | |
1145 | |
1146 memset( &auth_info, 0, sizeof( auth_info ) ); | |
1147 auth_info.type = DVD_INVALIDATE_AGID; | |
1148 auth_info.lsa.agid = *pi_agid; | |
1149 | |
1150 i_ret = ioctl( i_fd, DVD_AUTH, &auth_info ); | |
1151 | |
1152 #elif defined( HAVE_BSD_DVD_STRUCT ) | |
1153 struct dvd_authinfo auth_info; | |
1154 | |
1155 memset( &auth_info, 0, sizeof( auth_info ) ); | |
1156 auth_info.format = DVD_INVALIDATE_AGID; | |
1157 auth_info.agid = *pi_agid; | |
1158 | |
1159 i_ret = ioctl( i_fd, DVDIOCREPORTKEY, &auth_info ); | |
1160 | |
1161 #elif defined( SYS_BEOS ) | |
1162 INIT_RDC( GPCMD_REPORT_KEY, 0 ); | |
1163 | |
1164 rdc.command[ 10 ] = DVD_INVALIDATE_AGID | (*pi_agid << 6); | |
1165 | |
1166 i_ret = ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) ); | |
1167 | |
1168 #elif defined( HPUX_SCTL_IO ) | |
1169 INIT_SCTL_IO( GPCMD_REPORT_KEY, 0 ); | |
1170 | |
1171 sctl_io.cdb[ 10 ] = DVD_INVALIDATE_AGID | (*pi_agid << 6); | |
1172 | |
1173 i_ret = ioctl( i_fd, SIOC_IO, &sctl_io ); | |
1174 | |
1175 #elif defined( SOLARIS_USCSI ) | |
1176 INIT_USCSI( GPCMD_REPORT_KEY, 0 ); | |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1177 |
7027 | 1178 rs_cdb.cdb_opaque[ 10 ] = DVD_INVALIDATE_AGID | (*pi_agid << 6); |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1179 |
8575 | 1180 i_ret = SolarisSendUSCSI( i_fd, &sc ); |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1181 |
7027 | 1182 if( i_ret < 0 || sc.uscsi_status ) |
1183 { | |
1184 i_ret = -1; | |
1185 } | |
1186 | |
1187 #elif defined( DARWIN_DVD_IOCTL ) | |
1188 INIT_DVDIOCTL( dk_dvd_send_key_t, DVDAuthenticationGrantIDInfo, | |
1189 kDVDKeyFormatAGID_Invalidate ); | |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1190 |
7027 | 1191 dvd.grantID = *pi_agid; |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1192 |
7027 | 1193 i_ret = ioctl( i_fd, DKIOCDVDSENDKEY, &dvd ); |
1194 | |
1195 #elif defined( WIN32 ) | |
8637
0211de3039eb
update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents:
8575
diff
changeset
|
1196 if( WIN2K ) /* NT/2k/XP */ |
7027 | 1197 { |
1198 DWORD tmp; | |
1199 | |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1200 i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_END_SESSION, |
7027 | 1201 pi_agid, sizeof( *pi_agid ), NULL, 0, &tmp, NULL ) ? 0 : -1; |
1202 } | |
1203 else | |
1204 { | |
1205 #if defined( __MINGW32__ ) | |
1206 INIT_SSC( GPCMD_REPORT_KEY, 0 ); | |
1207 #else | |
1208 INIT_SSC( GPCMD_REPORT_KEY, 1 ); | |
1209 | |
1210 ssc.SRB_BufLen = 0; | |
1211 ssc.CDBByte[ 8 ] = 0; | |
1212 ssc.CDBByte[ 9 ] = 0; | |
1213 #endif | |
1214 | |
1215 ssc.CDBByte[ 10 ] = DVD_INVALIDATE_AGID | (*pi_agid << 6); | |
1216 | |
1217 i_ret = WinSendSSC( i_fd, &ssc ); | |
1218 } | |
1219 | |
1220 #elif defined( __QNXNTO__ ) | |
1221 | |
1222 INIT_CPT( GPCMD_REPORT_KEY, 0 ); | |
1223 | |
1224 p_cpt->cam_cdb[ 10 ] = DVD_INVALIDATE_AGID | (*pi_agid << 6); | |
1225 | |
1226 i_ret = devctl(i_fd, DCMD_CAM_PASS_THRU, p_cpt, structSize, NULL); | |
1227 | |
1228 #elif defined( SYS_OS2 ) | |
1229 INIT_SSC( GPCMD_REPORT_KEY, 1 ); | |
1230 | |
1231 sdc.data_length = 0; | |
1232 sdc.command[ 8 ] = 0; | |
1233 sdc.command[ 9 ] = 0; | |
1234 | |
1235 sdc.command[ 10 ] = DVD_INVALIDATE_AGID | (*pi_agid << 6); | |
1236 | |
1237 i_ret = DosDevIOCtl(i_fd, IOCTL_CDROMDISK, CDROMDISK_EXECMD, | |
1238 &sdc, sizeof(sdc), &ulParamLen, | |
1239 NULL, 0, &ulDataLen); | |
1240 #else | |
1241 # error "DVD ioctls are unavailable on this system" | |
1242 | |
1243 #endif | |
1244 return i_ret; | |
1245 } | |
1246 | |
1247 /***************************************************************************** | |
1248 * ioctl_SendChallenge: send challenge to the drive | |
1249 *****************************************************************************/ | |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1250 int ioctl_SendChallenge( int i_fd, int *pi_agid, uint8_t *p_challenge ) |
7027 | 1251 { |
1252 int i_ret; | |
1253 | |
1254 #if defined( HAVE_LINUX_DVD_STRUCT ) | |
1255 dvd_authinfo auth_info; | |
1256 | |
1257 memset( &auth_info, 0, sizeof( auth_info ) ); | |
1258 auth_info.type = DVD_HOST_SEND_CHALLENGE; | |
1259 auth_info.hsc.agid = *pi_agid; | |
1260 | |
1261 memcpy( auth_info.hsc.chal, p_challenge, DVD_CHALLENGE_SIZE ); | |
1262 | |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1263 i_ret = ioctl( i_fd, DVD_AUTH, &auth_info ); |
7027 | 1264 |
1265 #elif defined( HAVE_BSD_DVD_STRUCT ) | |
1266 struct dvd_authinfo auth_info; | |
1267 | |
1268 memset( &auth_info, 0, sizeof( auth_info ) ); | |
1269 auth_info.format = DVD_SEND_CHALLENGE; | |
1270 auth_info.agid = *pi_agid; | |
1271 | |
1272 memcpy( auth_info.keychal, p_challenge, DVD_CHALLENGE_SIZE ); | |
1273 | |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1274 i_ret = ioctl( i_fd, DVDIOCSENDKEY, &auth_info ); |
7027 | 1275 |
1276 #elif defined( SYS_BEOS ) | |
1277 INIT_RDC( GPCMD_SEND_KEY, 16 ); | |
1278 | |
1279 rdc.command[ 10 ] = DVD_SEND_CHALLENGE | (*pi_agid << 6); | |
1280 | |
1281 p_buffer[ 1 ] = 0xe; | |
1282 memcpy( p_buffer + 4, p_challenge, DVD_CHALLENGE_SIZE ); | |
1283 | |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1284 i_ret = ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) ); |
7027 | 1285 |
1286 #elif defined( HPUX_SCTL_IO ) | |
1287 INIT_SCTL_IO( GPCMD_SEND_KEY, 16 ); | |
1288 | |
1289 sctl_io.cdb[ 10 ] = DVD_SEND_CHALLENGE | (*pi_agid << 6); | |
1290 | |
1291 p_buffer[ 1 ] = 0xe; | |
1292 memcpy( p_buffer + 4, p_challenge, DVD_CHALLENGE_SIZE ); | |
1293 | |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1294 i_ret = ioctl( i_fd, SIOC_IO, &sctl_io ); |
7027 | 1295 |
1296 #elif defined( SOLARIS_USCSI ) | |
1297 INIT_USCSI( GPCMD_SEND_KEY, 16 ); | |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1298 |
7027 | 1299 rs_cdb.cdb_opaque[ 10 ] = DVD_SEND_CHALLENGE | (*pi_agid << 6); |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1300 |
7027 | 1301 p_buffer[ 1 ] = 0xe; |
1302 memcpy( p_buffer + 4, p_challenge, DVD_CHALLENGE_SIZE ); | |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1303 |
8575 | 1304 if( SolarisSendUSCSI( i_fd, &sc ) < 0 || sc.uscsi_status ) |
7027 | 1305 { |
1306 return -1; | |
1307 } | |
1308 | |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1309 i_ret = 0; |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1310 |
7027 | 1311 #elif defined( DARWIN_DVD_IOCTL ) |
1312 INIT_DVDIOCTL( dk_dvd_send_key_t, DVDChallengeKeyInfo, | |
1313 kDVDKeyFormatChallengeKey ); | |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1314 |
7027 | 1315 dvd.grantID = *pi_agid; |
1316 dvd.keyClass = kDVDKeyClassCSS_CPPM_CPRM; | |
1317 | |
1318 dvdbs.dataLength[ 1 ] = 0xe; | |
1319 memcpy( dvdbs.challengeKeyValue, p_challenge, DVD_CHALLENGE_SIZE ); | |
1320 | |
1321 i_ret = ioctl( i_fd, DKIOCDVDSENDKEY, &dvd ); | |
1322 | |
1323 #elif defined( WIN32 ) | |
8637
0211de3039eb
update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents:
8575
diff
changeset
|
1324 if( WIN2K ) /* NT/2k/XP */ |
7027 | 1325 { |
1326 DWORD tmp; | |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1327 uint8_t buffer[DVD_CHALLENGE_KEY_LENGTH]; |
7027 | 1328 PDVD_COPY_PROTECT_KEY key = (PDVD_COPY_PROTECT_KEY) &buffer; |
1329 | |
1330 memset( &buffer, 0, sizeof( buffer ) ); | |
1331 | |
1332 key->KeyLength = DVD_CHALLENGE_KEY_LENGTH; | |
1333 key->SessionId = *pi_agid; | |
1334 key->KeyType = DvdChallengeKey; | |
1335 key->KeyFlags = 0; | |
1336 | |
1337 memcpy( key->KeyData, p_challenge, DVD_CHALLENGE_SIZE ); | |
1338 | |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1339 i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_SEND_KEY, key, |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1340 key->KeyLength, key, key->KeyLength, &tmp, NULL ) ? 0 : -1; |
7027 | 1341 } |
1342 else | |
1343 { | |
1344 INIT_SSC( GPCMD_SEND_KEY, 16 ); | |
1345 | |
1346 ssc.CDBByte[ 10 ] = DVD_SEND_CHALLENGE | (*pi_agid << 6); | |
1347 | |
1348 p_buffer[ 1 ] = 0xe; | |
1349 memcpy( p_buffer + 4, p_challenge, DVD_CHALLENGE_SIZE ); | |
1350 | |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1351 i_ret = WinSendSSC( i_fd, &ssc ); |
7027 | 1352 } |
1353 | |
1354 #elif defined( __QNXNTO__ ) | |
1355 | |
1356 INIT_CPT( GPCMD_SEND_KEY, 16 ); | |
1357 | |
1358 p_cpt->cam_cdb[ 10 ] = DVD_SEND_CHALLENGE | (*pi_agid << 6); | |
1359 | |
1360 p_buffer[ 1 ] = 0xe; | |
1361 memcpy( p_buffer + 4, p_challenge, DVD_CHALLENGE_SIZE ); | |
1362 | |
1363 i_ret = devctl(i_fd, DCMD_CAM_PASS_THRU, p_cpt, structSize, NULL); | |
1364 | |
1365 #elif defined( SYS_OS2 ) | |
1366 INIT_SSC( GPCMD_SEND_KEY, 16 ); | |
1367 | |
1368 sdc.command[ 10 ] = DVD_SEND_CHALLENGE | (*pi_agid << 6); | |
1369 | |
1370 p_buffer[ 1 ] = 0xe; | |
1371 memcpy( p_buffer + 4, p_challenge, DVD_CHALLENGE_SIZE ); | |
1372 | |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1373 i_ret = DosDevIOCtl( i_fd, IOCTL_CDROMDISK, CDROMDISK_EXECMD, |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1374 &sdc, sizeof(sdc), &ulParamLen, |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1375 p_buffer, sizeof(p_buffer), &ulDataLen ); |
7027 | 1376 |
1377 #else | |
1378 # error "DVD ioctls are unavailable on this system" | |
1379 | |
1380 #endif | |
1381 return i_ret; | |
1382 } | |
1383 | |
1384 /***************************************************************************** | |
1385 * ioctl_SendKey2: send the second key to the drive | |
1386 *****************************************************************************/ | |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1387 int ioctl_SendKey2( int i_fd, int *pi_agid, uint8_t *p_key ) |
7027 | 1388 { |
1389 int i_ret; | |
1390 | |
1391 #if defined( HAVE_LINUX_DVD_STRUCT ) | |
1392 dvd_authinfo auth_info; | |
1393 | |
1394 memset( &auth_info, 0, sizeof( auth_info ) ); | |
1395 auth_info.type = DVD_HOST_SEND_KEY2; | |
1396 auth_info.hsk.agid = *pi_agid; | |
1397 | |
1398 memcpy( auth_info.hsk.key, p_key, DVD_KEY_SIZE ); | |
1399 | |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1400 i_ret = ioctl( i_fd, DVD_AUTH, &auth_info ); |
7027 | 1401 |
1402 #elif defined( HAVE_BSD_DVD_STRUCT ) | |
1403 struct dvd_authinfo auth_info; | |
1404 | |
1405 memset( &auth_info, 0, sizeof( auth_info ) ); | |
1406 auth_info.format = DVD_SEND_KEY2; | |
1407 auth_info.agid = *pi_agid; | |
1408 | |
1409 memcpy( auth_info.keychal, p_key, DVD_KEY_SIZE ); | |
1410 | |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1411 i_ret = ioctl( i_fd, DVDIOCSENDKEY, &auth_info ); |
7027 | 1412 |
1413 #elif defined( SYS_BEOS ) | |
1414 INIT_RDC( GPCMD_SEND_KEY, 12 ); | |
1415 | |
1416 rdc.command[ 10 ] = DVD_SEND_KEY2 | (*pi_agid << 6); | |
1417 | |
1418 p_buffer[ 1 ] = 0xa; | |
1419 memcpy( p_buffer + 4, p_key, DVD_KEY_SIZE ); | |
1420 | |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1421 i_ret = ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) ); |
7027 | 1422 |
1423 #elif defined( HPUX_SCTL_IO ) | |
1424 INIT_SCTL_IO( GPCMD_SEND_KEY, 12 ); | |
1425 | |
1426 sctl_io.cdb[ 10 ] = DVD_SEND_KEY2 | (*pi_agid << 6); | |
1427 | |
1428 p_buffer[ 1 ] = 0xa; | |
1429 memcpy( p_buffer + 4, p_key, DVD_KEY_SIZE ); | |
1430 | |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1431 i_ret = ioctl( i_fd, SIOC_IO, &sctl_io ); |
7027 | 1432 |
1433 #elif defined( SOLARIS_USCSI ) | |
1434 INIT_USCSI( GPCMD_SEND_KEY, 12 ); | |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1435 |
7027 | 1436 rs_cdb.cdb_opaque[ 10 ] = DVD_SEND_KEY2 | (*pi_agid << 6); |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1437 |
7027 | 1438 p_buffer[ 1 ] = 0xa; |
1439 memcpy( p_buffer + 4, p_key, DVD_KEY_SIZE ); | |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1440 |
8575 | 1441 if( SolarisSendUSCSI( i_fd, &sc ) < 0 || sc.uscsi_status ) |
7027 | 1442 { |
1443 return -1; | |
1444 } | |
1445 | |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1446 i_ret = 0; |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1447 |
7027 | 1448 #elif defined( DARWIN_DVD_IOCTL ) |
1449 INIT_DVDIOCTL( dk_dvd_send_key_t, DVDKey2Info, | |
1450 kDVDKeyFormatKey2 ); | |
1451 | |
1452 dvd.grantID = *pi_agid; | |
1453 dvd.keyClass = kDVDKeyClassCSS_CPPM_CPRM; | |
1454 | |
1455 dvdbs.dataLength[ 1 ] = 0xa; | |
1456 memcpy( dvdbs.key2Value, p_key, DVD_KEY_SIZE ); | |
1457 | |
1458 i_ret = ioctl( i_fd, DKIOCDVDSENDKEY, &dvd ); | |
1459 | |
1460 #elif defined( WIN32 ) | |
8637
0211de3039eb
update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents:
8575
diff
changeset
|
1461 if( WIN2K ) /* NT/2k/XP */ |
7027 | 1462 { |
1463 DWORD tmp; | |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1464 uint8_t buffer[DVD_BUS_KEY_LENGTH]; |
7027 | 1465 PDVD_COPY_PROTECT_KEY key = (PDVD_COPY_PROTECT_KEY) &buffer; |
1466 | |
1467 memset( &buffer, 0, sizeof( buffer ) ); | |
1468 | |
1469 key->KeyLength = DVD_BUS_KEY_LENGTH; | |
1470 key->SessionId = *pi_agid; | |
1471 key->KeyType = DvdBusKey2; | |
1472 key->KeyFlags = 0; | |
1473 | |
1474 memcpy( key->KeyData, p_key, DVD_KEY_SIZE ); | |
1475 | |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1476 i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_SEND_KEY, key, |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1477 key->KeyLength, key, key->KeyLength, &tmp, NULL ) ? 0 : -1; |
7027 | 1478 } |
1479 else | |
1480 { | |
1481 INIT_SSC( GPCMD_SEND_KEY, 12 ); | |
1482 | |
1483 ssc.CDBByte[ 10 ] = DVD_SEND_KEY2 | (*pi_agid << 6); | |
1484 | |
1485 p_buffer[ 1 ] = 0xa; | |
1486 memcpy( p_buffer + 4, p_key, DVD_KEY_SIZE ); | |
1487 | |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1488 i_ret = WinSendSSC( i_fd, &ssc ); |
7027 | 1489 } |
1490 | |
1491 #elif defined( __QNXNTO__ ) | |
1492 | |
1493 INIT_CPT( GPCMD_SEND_KEY, 12 ); | |
1494 | |
1495 p_cpt->cam_cdb[ 10 ] = DVD_SEND_KEY2 | (*pi_agid << 6); | |
1496 | |
1497 p_buffer[ 1 ] = 0xa; | |
1498 memcpy( p_buffer + 4, p_key, DVD_KEY_SIZE ); | |
1499 | |
1500 i_ret = devctl(i_fd, DCMD_CAM_PASS_THRU, p_cpt, structSize, NULL); | |
1501 | |
1502 #elif defined( SYS_OS2 ) | |
1503 INIT_SSC( GPCMD_SEND_KEY, 12 ); | |
1504 | |
1505 sdc.command[ 10 ] = DVD_SEND_KEY2 | (*pi_agid << 6); | |
1506 | |
1507 p_buffer[ 1 ] = 0xa; | |
1508 memcpy( p_buffer + 4, p_key, DVD_KEY_SIZE ); | |
1509 | |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1510 i_ret = DosDevIOCtl( i_fd, IOCTL_CDROMDISK, CDROMDISK_EXECMD, |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1511 &sdc, sizeof(sdc), &ulParamLen, |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1512 p_buffer, sizeof(p_buffer), &ulDataLen ); |
7027 | 1513 |
1514 #else | |
1515 # error "DVD ioctls are unavailable on this system" | |
1516 | |
1517 #endif | |
1518 return i_ret; | |
1519 } | |
1520 | |
1521 /***************************************************************************** | |
1522 * ioctl_ReportRPC: get RPC status for the drive | |
1523 *****************************************************************************/ | |
1524 int ioctl_ReportRPC( int i_fd, int *p_type, int *p_mask, int *p_scheme ) | |
1525 { | |
1526 int i_ret; | |
1527 | |
1528 #if defined( HAVE_LINUX_DVD_STRUCT ) && defined( DVD_LU_SEND_RPC_STATE ) | |
1529 dvd_authinfo auth_info; | |
1530 | |
1531 memset( &auth_info, 0, sizeof( auth_info ) ); | |
1532 auth_info.type = DVD_LU_SEND_RPC_STATE; | |
1533 | |
1534 i_ret = ioctl( i_fd, DVD_AUTH, &auth_info ); | |
1535 | |
1536 *p_type = auth_info.lrpcs.type; | |
1537 *p_mask = auth_info.lrpcs.region_mask; | |
1538 *p_scheme = auth_info.lrpcs.rpc_scheme; | |
1539 | |
1540 #elif defined( HAVE_LINUX_DVD_STRUCT ) | |
1541 /* FIXME: OpenBSD doesn't know this */ | |
1542 i_ret = -1; | |
1543 | |
1544 #elif defined( HAVE_BSD_DVD_STRUCT ) | |
1545 struct dvd_authinfo auth_info; | |
1546 | |
1547 memset( &auth_info, 0, sizeof( auth_info ) ); | |
1548 auth_info.format = DVD_REPORT_RPC; | |
1549 | |
1550 i_ret = ioctl( i_fd, DVDIOCREPORTKEY, &auth_info ); | |
1551 | |
1552 *p_type = auth_info.reg_type; | |
1553 *p_mask = auth_info.region; // ?? | |
1554 *p_scheme = auth_info.rpc_scheme; | |
1555 | |
1556 #elif defined( SYS_BEOS ) | |
1557 INIT_RDC( GPCMD_REPORT_KEY, 8 ); | |
1558 | |
1559 rdc.command[ 10 ] = DVD_REPORT_RPC; | |
1560 | |
1561 i_ret = ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) ); | |
1562 | |
1563 *p_type = p_buffer[ 4 ] >> 6; | |
1564 *p_mask = p_buffer[ 5 ]; | |
1565 *p_scheme = p_buffer[ 6 ]; | |
1566 | |
1567 #elif defined( HPUX_SCTL_IO ) | |
1568 INIT_SCTL_IO( GPCMD_REPORT_KEY, 8 ); | |
1569 | |
1570 sctl_io.cdb[ 10 ] = DVD_REPORT_RPC; | |
1571 | |
1572 i_ret = ioctl( i_fd, SIOC_IO, &sctl_io ); | |
1573 | |
1574 *p_type = p_buffer[ 4 ] >> 6; | |
1575 *p_mask = p_buffer[ 5 ]; | |
1576 *p_scheme = p_buffer[ 6 ]; | |
1577 | |
1578 #elif defined( SOLARIS_USCSI ) | |
1579 INIT_USCSI( GPCMD_REPORT_KEY, 8 ); | |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1580 |
7027 | 1581 rs_cdb.cdb_opaque[ 10 ] = DVD_REPORT_RPC; |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1582 |
8575 | 1583 i_ret = SolarisSendUSCSI( i_fd, &sc ); |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1584 |
7027 | 1585 if( i_ret < 0 || sc.uscsi_status ) |
1586 { | |
1587 i_ret = -1; | |
1588 } | |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1589 |
7027 | 1590 *p_type = p_buffer[ 4 ] >> 6; |
1591 *p_mask = p_buffer[ 5 ]; | |
1592 *p_scheme = p_buffer[ 6 ]; | |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1593 |
7027 | 1594 #elif defined( DARWIN_DVD_IOCTL ) |
1595 INIT_DVDIOCTL( dk_dvd_report_key_t, DVDRegionPlaybackControlInfo, | |
1596 kDVDKeyFormatRegionState ); | |
1597 | |
1598 dvd.keyClass = kDVDKeyClassCSS_CPPM_CPRM; | |
1599 | |
1600 i_ret = ioctl( i_fd, DKIOCDVDREPORTKEY, &dvd ); | |
1601 | |
1602 *p_type = dvdbs.typeCode; | |
1603 *p_mask = dvdbs.driveRegion; | |
1604 *p_scheme = dvdbs.rpcScheme; | |
1605 | |
1606 #elif defined( WIN32 ) | |
8637
0211de3039eb
update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents:
8575
diff
changeset
|
1607 if( WIN2K ) /* NT/2k/XP */ |
7027 | 1608 { |
1609 DWORD tmp; | |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1610 uint8_t buffer[DVD_RPC_KEY_LENGTH]; |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1611 PDVD_COPY_PROTECT_KEY key = (PDVD_COPY_PROTECT_KEY) &buffer; |
7027 | 1612 |
1613 memset( &buffer, 0, sizeof( buffer ) ); | |
1614 | |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1615 key->KeyLength = DVD_RPC_KEY_LENGTH; |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1616 key->KeyType = DvdGetRpcKey; |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1617 key->KeyFlags = 0; |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1618 |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1619 i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_READ_KEY, key, |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1620 key->KeyLength, key, key->KeyLength, &tmp, NULL ) ? 0 : -1; |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1621 |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1622 if( i_ret < 0 ) |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1623 { |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1624 return i_ret; |
8637
0211de3039eb
update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents:
8575
diff
changeset
|
1625 } |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1626 |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1627 *p_type = ((PDVD_RPC_KEY)key->KeyData)->TypeCode; |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1628 *p_mask = ((PDVD_RPC_KEY)key->KeyData)->RegionMask; |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1629 *p_scheme = ((PDVD_RPC_KEY)key->KeyData)->RpcScheme; |
7027 | 1630 } |
1631 else | |
1632 { | |
1633 INIT_SSC( GPCMD_REPORT_KEY, 8 ); | |
1634 | |
1635 ssc.CDBByte[ 10 ] = DVD_REPORT_RPC; | |
1636 | |
1637 i_ret = WinSendSSC( i_fd, &ssc ); | |
1638 | |
1639 *p_type = p_buffer[ 4 ] >> 6; | |
1640 *p_mask = p_buffer[ 5 ]; | |
1641 *p_scheme = p_buffer[ 6 ]; | |
1642 } | |
1643 | |
1644 #elif defined( __QNXNTO__ ) | |
1645 | |
1646 INIT_CPT( GPCMD_REPORT_KEY, 8 ); | |
1647 | |
1648 p_cpt->cam_cdb[ 10 ] = DVD_REPORT_RPC; | |
1649 | |
1650 i_ret = devctl(i_fd, DCMD_CAM_PASS_THRU, p_cpt, structSize, NULL); | |
1651 | |
1652 *p_type = p_buffer[ 4 ] >> 6; | |
1653 *p_mask = p_buffer[ 5 ]; | |
1654 *p_scheme = p_buffer[ 6 ]; | |
1655 | |
1656 #elif defined( SYS_OS2 ) | |
1657 INIT_SSC( GPCMD_REPORT_KEY, 8 ); | |
1658 | |
1659 sdc.command[ 10 ] = DVD_REPORT_RPC; | |
1660 | |
1661 i_ret = DosDevIOCtl(i_fd, IOCTL_CDROMDISK, CDROMDISK_EXECMD, | |
1662 &sdc, sizeof(sdc), &ulParamLen, | |
1663 p_buffer, sizeof(p_buffer), &ulDataLen); | |
1664 | |
1665 *p_type = p_buffer[ 4 ] >> 6; | |
1666 *p_mask = p_buffer[ 5 ]; | |
1667 *p_scheme = p_buffer[ 6 ]; | |
1668 | |
1669 #else | |
1670 # error "DVD ioctls are unavailable on this system" | |
1671 | |
1672 #endif | |
1673 return i_ret; | |
1674 } | |
1675 | |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1676 /***************************************************************************** |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1677 * ioctl_SendRPC: set RPC status for the drive |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1678 *****************************************************************************/ |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1679 int ioctl_SendRPC( int i_fd, int i_pdrc ) |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1680 { |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1681 int i_ret; |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1682 |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1683 #if defined( HAVE_LINUX_DVD_STRUCT ) && defined( DVD_HOST_SEND_RPC_STATE ) |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1684 dvd_authinfo auth_info; |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1685 |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1686 memset( &auth_info, 0, sizeof( auth_info ) ); |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1687 auth_info.type = DVD_HOST_SEND_RPC_STATE; |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1688 auth_info.hrpcs.pdrc = i_pdrc; |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1689 |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1690 i_ret = ioctl( i_fd, DVD_AUTH, &auth_info ); |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1691 |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1692 #elif defined( HAVE_LINUX_DVD_STRUCT ) |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1693 /* FIXME: OpenBSD doesn't know this */ |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1694 i_ret = -1; |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1695 |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1696 #elif defined( HAVE_BSD_DVD_STRUCT ) |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1697 struct dvd_authinfo auth_info; |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1698 |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1699 memset( &auth_info, 0, sizeof( auth_info ) ); |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1700 auth_info.format = DVD_SEND_RPC; |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1701 auth_info.region = i_pdrc; |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1702 |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1703 i_ret = ioctl( i_fd, DVDIOCSENDKEY, &auth_info ); |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1704 |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1705 #elif defined( SYS_BEOS ) |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1706 INIT_RDC( GPCMD_SEND_KEY, 8 ); |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1707 |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1708 rdc.command[ 10 ] = DVD_SEND_RPC; |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1709 |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1710 p_buffer[ 1 ] = 6; |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1711 p_buffer[ 4 ] = i_pdrc; |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1712 |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1713 i_ret = ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) ); |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1714 |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1715 #elif defined( HPUX_SCTL_IO ) |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1716 INIT_SCTL_IO( GPCMD_SEND_KEY, 8 ); |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1717 |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1718 sctl_io.cdb[ 10 ] = DVD_SEND_RPC; |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1719 |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1720 p_buffer[ 1 ] = 6; |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1721 p_buffer[ 4 ] = i_pdrc; |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1722 |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1723 i_ret = ioctl( i_fd, SIOC_IO, &sctl_io ); |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1724 |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1725 #elif defined( SOLARIS_USCSI ) |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1726 INIT_USCSI( GPCMD_SEND_KEY, 8 ); |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1727 |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1728 rs_cdb.cdb_opaque[ 10 ] = DVD_SEND_RPC; |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1729 |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1730 p_buffer[ 1 ] = 6; |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1731 p_buffer[ 4 ] = i_pdrc; |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1732 |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1733 i_ret = SolarisSendUSCSI( i_fd, &sc ); |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1734 |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1735 if( i_ret < 0 || sc.uscsi_status ) |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1736 { |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1737 i_ret = -1; |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1738 } |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1739 |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1740 #elif defined( DARWIN_DVD_IOCTL ) |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1741 INIT_DVDIOCTL( dk_dvd_send_key_t, DVDRegionPlaybackControlInfo, |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1742 kDVDKeyFormatSetRegion ); |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1743 |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1744 dvd.keyClass = kDVDKeyClassCSS_CPPM_CPRM; |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1745 dvdbs.driveRegion = i_pdrc; |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1746 |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1747 i_ret = ioctl( i_fd, DKIOCDVDSENDKEY, &dvd ); |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1748 |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1749 #elif defined( WIN32 ) |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1750 if( WIN2K ) /* NT/2k/XP */ |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1751 { |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1752 INIT_SPTD( GPCMD_SEND_KEY, 8 ); |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1753 |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1754 sptd.Cdb[ 10 ] = DVD_SEND_RPC; |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1755 |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1756 p_buffer[ 1 ] = 6; |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1757 p_buffer[ 4 ] = i_pdrc; |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1758 |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1759 i_ret = SEND_SPTD( i_fd, &sptd, &tmp ); |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1760 } |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1761 else |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1762 { |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1763 INIT_SSC( GPCMD_SEND_KEY, 8 ); |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1764 |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1765 ssc.CDBByte[ 10 ] = DVD_SEND_RPC; |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1766 |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1767 p_buffer[ 1 ] = 6; |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1768 p_buffer[ 4 ] = i_pdrc; |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1769 |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1770 i_ret = WinSendSSC( i_fd, &ssc ); |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1771 } |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1772 |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1773 #elif defined( __QNXNTO__ ) |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1774 |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1775 INIT_CPT( GPCMD_SEND_KEY, 8 ); |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1776 |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1777 p_cpt->cam_cdb[ 10 ] = DVD_SEND_RPC; |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1778 |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1779 p_buffer[ 1 ] = 6; |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1780 p_buffer[ 4 ] = i_pdrc; |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1781 |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1782 i_ret = devctl(i_fd, DCMD_CAM_PASS_THRU, p_cpt, structSize, NULL); |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1783 |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1784 #elif defined( SYS_OS2 ) |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1785 INIT_SSC( GPCMD_SEND_KEY, 8 ); |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1786 |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1787 sdc.command[ 10 ] = DVD_SEND_RPC; |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1788 |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1789 p_buffer[ 1 ] = 6; |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1790 p_buffer[ 4 ] = i_pdrc; |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1791 |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1792 i_ret = DosDevIOCtl( i_fd, IOCTL_CDROMDISK, CDROMDISK_EXECMD, |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1793 &sdc, sizeof(sdc), &ulParamLen, |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1794 p_buffer, sizeof(p_buffer), &ulDataLen ); |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1795 |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1796 #else |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1797 # error "DVD ioctls are unavailable on this system" |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1798 |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1799 #endif |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1800 return i_ret; |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1801 } |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1802 |
7027 | 1803 /* Local prototypes */ |
1804 | |
1805 #if defined( SYS_BEOS ) | |
1806 /***************************************************************************** | |
1807 * BeInitRDC: initialize a RDC structure for the BeOS kernel | |
1808 ***************************************************************************** | |
1809 * This function initializes a BeOS raw device command structure for future | |
1810 * use, either a read command or a write command. | |
1811 *****************************************************************************/ | |
1812 static void BeInitRDC( raw_device_command *p_rdc, int i_type ) | |
1813 { | |
1814 memset( p_rdc->data, 0, p_rdc->data_length ); | |
1815 | |
1816 switch( i_type ) | |
1817 { | |
1818 case GPCMD_SEND_KEY: | |
1819 /* leave the flags to 0 */ | |
1820 break; | |
1821 | |
1822 case GPCMD_READ_DVD_STRUCTURE: case GPCMD_REPORT_KEY: | |
1823 p_rdc->flags = B_RAW_DEVICE_DATA_IN; break; } | |
1824 | |
1825 p_rdc->command[ 0 ] = i_type; | |
1826 | |
1827 p_rdc->command[ 8 ] = (p_rdc->data_length >> 8) & 0xff; | |
1828 p_rdc->command[ 9 ] = p_rdc->data_length & 0xff; | |
1829 p_rdc->command_length = 12; | |
1830 | |
1831 p_rdc->sense_data = NULL; | |
1832 p_rdc->sense_data_length = 0; | |
1833 | |
1834 p_rdc->timeout = 1000000; | |
1835 } | |
1836 #endif | |
1837 | |
1838 #if defined( HPUX_SCTL_IO ) | |
1839 /***************************************************************************** | |
1840 * HPUXInitSCTL: initialize a sctl_io structure for the HP-UX kernel | |
1841 ***************************************************************************** | |
1842 * This function initializes a HP-UX command structure for future | |
1843 * use, either a read command or a write command. | |
1844 *****************************************************************************/ | |
1845 static void HPUXInitSCTL( struct sctl_io *sctl_io, int i_type ) | |
1846 { | |
1847 memset( sctl_io->data, 0, sctl_io->data_length ); | |
1848 | |
1849 switch( i_type ) | |
1850 { | |
1851 case GPCMD_SEND_KEY: | |
1852 /* leave the flags to 0 */ | |
1853 break; | |
1854 | |
1855 case GPCMD_READ_DVD_STRUCTURE: | |
1856 case GPCMD_REPORT_KEY: | |
1857 sctl_io->flags = SCTL_READ; | |
1858 break; | |
1859 } | |
1860 | |
1861 sctl_io->cdb[ 0 ] = i_type; | |
1862 | |
1863 sctl_io->cdb[ 8 ] = (sctl_io->data_length >> 8) & 0xff; | |
1864 sctl_io->cdb[ 9 ] = sctl_io->data_length & 0xff; | |
1865 sctl_io->cdb_length = 12; | |
1866 | |
1867 sctl_io->max_msecs = 1000000; | |
1868 } | |
1869 #endif | |
1870 | |
1871 #if defined( SOLARIS_USCSI ) | |
1872 /***************************************************************************** | |
1873 * SolarisInitUSCSI: initialize a USCSICMD structure for the Solaris kernel | |
1874 ***************************************************************************** | |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1875 * This function initializes a Solaris userspace scsi command structure for |
7027 | 1876 * future use, either a read command or a write command. |
1877 *****************************************************************************/ | |
1878 static void SolarisInitUSCSI( struct uscsi_cmd *p_sc, int i_type ) | |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1879 { |
7027 | 1880 union scsi_cdb *rs_cdb; |
1881 memset( p_sc->uscsi_cdb, 0, sizeof( union scsi_cdb ) ); | |
1882 memset( p_sc->uscsi_bufaddr, 0, p_sc->uscsi_buflen ); | |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1883 |
7027 | 1884 switch( i_type ) |
1885 { | |
1886 case GPCMD_SEND_KEY: | |
1887 p_sc->uscsi_flags = USCSI_ISOLATE | USCSI_WRITE; | |
1888 break; | |
1889 | |
1890 case GPCMD_READ_DVD_STRUCTURE: | |
1891 case GPCMD_REPORT_KEY: | |
1892 p_sc->uscsi_flags = USCSI_ISOLATE | USCSI_READ; | |
1893 break; | |
1894 } | |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1895 |
7027 | 1896 rs_cdb = (union scsi_cdb *)p_sc->uscsi_cdb; |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1897 |
7027 | 1898 rs_cdb->scc_cmd = i_type; |
1899 | |
1900 rs_cdb->cdb_opaque[ 8 ] = (p_sc->uscsi_buflen >> 8) & 0xff; | |
1901 rs_cdb->cdb_opaque[ 9 ] = p_sc->uscsi_buflen & 0xff; | |
1902 p_sc->uscsi_cdblen = 12; | |
1903 | |
1904 USCSI_TIMEOUT( p_sc, 15 ); | |
1905 } | |
8575 | 1906 |
1907 /***************************************************************************** | |
1908 * SolarisSendUSCSI: send a USCSICMD structure to the Solaris kernel | |
1909 * for execution | |
1910 ***************************************************************************** | |
1911 * When available, this function uses the function smedia_uscsi_cmd() | |
1912 * from solaris' libsmedia library (solaris 9 or newer) to execute the | |
1913 * USCSI command. smedia_uscsi_cmd() allows USCSI commands for | |
1914 * non-root users on removable media devices on solaris 9; sending the | |
1915 * USCSI command directly to the device using the USCSICMD ioctl fails | |
1916 * with an EPERM error on solaris 9. | |
1917 * | |
1918 * The code will fall back to the USCSICMD ioctl method, when | |
1919 * libsmedia.so is not available or does not export the | |
1920 * smedia_uscsi_cmd() function (on solaris releases upto and including | |
1921 * solaris 8). Fortunatelly, on these old releases non-root users are | |
1922 * allowed to perform USCSICMD ioctls on removable media devices. | |
1923 *****************************************************************************/ | |
1924 static int SolarisSendUSCSI( int i_fd, struct uscsi_cmd *p_sc ) { | |
1925 void *sm_hdl; | |
1926 static int initialized; | |
1927 static void* (*sm_get_handle)(int32_t); | |
1928 static int (*sm_release_handle)(void*); | |
1929 static int (*sm_uscsi_cmd)(void*, struct uscsi_cmd *); | |
1930 | |
1931 if (!initialized) | |
1932 { | |
1933 void *smedia_lib; | |
1934 | |
1935 smedia_lib = dlopen("libsmedia.so", RTLD_NOW); | |
1936 if (smedia_lib) { | |
1937 sm_get_handle = dlsym(smedia_lib, "smedia_get_handle"); | |
1938 sm_release_handle = dlsym(smedia_lib, "smedia_release_handle"); | |
1939 sm_uscsi_cmd = dlsym(smedia_lib, "smedia_uscsi_cmd"); | |
1940 } | |
1941 initialized = 1; | |
1942 } | |
1943 | |
1944 if (sm_get_handle && sm_uscsi_cmd && sm_release_handle | |
1945 && (sm_hdl = sm_get_handle(i_fd))) | |
1946 { | |
1947 int i_ret = sm_uscsi_cmd(sm_hdl, p_sc); | |
1948 sm_release_handle(sm_hdl); | |
1949 return i_ret; | |
1950 } | |
1951 | |
1952 return ioctl( i_fd, USCSICMD, p_sc ); | |
1953 } | |
7027 | 1954 #endif |
1955 | |
1956 #if defined( WIN32 ) | |
1957 /***************************************************************************** | |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1958 * WinInitSPTD: initialize a sptd structure |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1959 ***************************************************************************** |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1960 * This function initializes a SCSI pass through command structure for future |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1961 * use, either a read command or a write command. |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1962 *****************************************************************************/ |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1963 static void WinInitSPTD( SCSI_PASS_THROUGH_DIRECT *p_sptd, int i_type ) |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1964 { |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1965 memset( p_sptd->DataBuffer, 0, p_sptd->DataTransferLength ); |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1966 |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1967 switch( i_type ) |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1968 { |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1969 case GPCMD_SEND_KEY: |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1970 p_sptd->DataIn = SCSI_IOCTL_DATA_OUT; |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1971 break; |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1972 |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1973 case GPCMD_READ_DVD_STRUCTURE: |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1974 case GPCMD_REPORT_KEY: |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1975 p_sptd->DataIn = SCSI_IOCTL_DATA_IN; |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1976 break; |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1977 } |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1978 |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1979 p_sptd->Cdb[ 0 ] = i_type; |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1980 p_sptd->Cdb[ 8 ] = (uint8_t)(p_sptd->DataTransferLength >> 8) & 0xff; |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1981 p_sptd->Cdb[ 9 ] = (uint8_t) p_sptd->DataTransferLength & 0xff; |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1982 p_sptd->CdbLength = 12; |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1983 |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1984 p_sptd->TimeOutValue = 2; |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1985 } |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1986 |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
1987 /***************************************************************************** |
7027 | 1988 * WinInitSSC: initialize a ssc structure for the win32 aspi layer |
1989 ***************************************************************************** | |
1990 * This function initializes a ssc raw device command structure for future | |
1991 * use, either a read command or a write command. | |
1992 *****************************************************************************/ | |
1993 static void WinInitSSC( struct SRB_ExecSCSICmd *p_ssc, int i_type ) | |
1994 { | |
1995 memset( p_ssc->SRB_BufPointer, 0, p_ssc->SRB_BufLen ); | |
1996 | |
1997 switch( i_type ) | |
1998 { | |
1999 case GPCMD_SEND_KEY: | |
2000 p_ssc->SRB_Flags = SRB_DIR_OUT; | |
2001 break; | |
2002 | |
2003 case GPCMD_READ_DVD_STRUCTURE: | |
2004 case GPCMD_REPORT_KEY: | |
2005 p_ssc->SRB_Flags = SRB_DIR_IN; | |
2006 break; | |
2007 } | |
2008 | |
2009 p_ssc->SRB_Cmd = SC_EXEC_SCSI_CMD; | |
2010 p_ssc->SRB_Flags |= SRB_EVENT_NOTIFY; | |
2011 | |
2012 p_ssc->CDBByte[ 0 ] = i_type; | |
2013 | |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
2014 p_ssc->CDBByte[ 8 ] = (uint8_t)(p_ssc->SRB_BufLen >> 8) & 0xff; |
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
2015 p_ssc->CDBByte[ 9 ] = (uint8_t) p_ssc->SRB_BufLen & 0xff; |
7027 | 2016 p_ssc->SRB_CDBLen = 12; |
2017 | |
2018 p_ssc->SRB_SenseLen = SENSE_LEN; | |
2019 } | |
2020 | |
2021 /***************************************************************************** | |
2022 * WinSendSSC: send a ssc structure to the aspi layer | |
2023 *****************************************************************************/ | |
2024 static int WinSendSSC( int i_fd, struct SRB_ExecSCSICmd *p_ssc ) | |
2025 { | |
2026 HANDLE hEvent = NULL; | |
2027 struct w32_aspidev *fd = (struct w32_aspidev *) i_fd; | |
2028 | |
2029 hEvent = CreateEvent( NULL, TRUE, FALSE, NULL ); | |
2030 if( hEvent == NULL ) | |
2031 { | |
2032 return -1; | |
2033 } | |
2034 | |
2035 p_ssc->SRB_PostProc = hEvent; | |
2036 p_ssc->SRB_HaId = LOBYTE( fd->i_sid ); | |
2037 p_ssc->SRB_Target = HIBYTE( fd->i_sid ); | |
2038 | |
2039 ResetEvent( hEvent ); | |
2040 if( fd->lpSendCommand( (void*) p_ssc ) == SS_PENDING ) | |
2041 WaitForSingleObject( hEvent, INFINITE ); | |
2042 | |
2043 CloseHandle( hEvent ); | |
2044 | |
2045 return p_ssc->SRB_Status == SS_COMP ? 0 : -1; | |
2046 } | |
2047 #endif | |
2048 | |
2049 #if defined( __QNXNTO__ ) | |
2050 /***************************************************************************** | |
8637
0211de3039eb
update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents:
8575
diff
changeset
|
2051 * QNXInitCPT: initialize a CPT structure for QNX Neutrino |
7027 | 2052 ***************************************************************************** |
8637
0211de3039eb
update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents:
8575
diff
changeset
|
2053 * This function initializes a cpt command structure for future use, |
0211de3039eb
update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents:
8575
diff
changeset
|
2054 * either a read command or a write command. |
7027 | 2055 *****************************************************************************/ |
2056 static void QNXInitCPT( CAM_PASS_THRU * p_cpt, int i_type ) | |
2057 { | |
2058 switch( i_type ) | |
2059 { | |
2060 case GPCMD_SEND_KEY: | |
2061 p_cpt->cam_flags = CAM_DIR_OUT; | |
2062 break; | |
2063 | |
2064 case GPCMD_READ_DVD_STRUCTURE: | |
2065 case GPCMD_REPORT_KEY: | |
2066 p_cpt->cam_flags = CAM_DIR_IN; | |
2067 break; | |
2068 } | |
2069 | |
2070 p_cpt->cam_cdb[0] = i_type; | |
2071 | |
2072 p_cpt->cam_cdb[ 8 ] = (p_cpt->cam_dxfer_len >> 8) & 0xff; | |
2073 p_cpt->cam_cdb[ 9 ] = p_cpt->cam_dxfer_len & 0xff; | |
2074 p_cpt->cam_cdb_len = 12; | |
2075 | |
8637
0211de3039eb
update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents:
8575
diff
changeset
|
2076 p_cpt->cam_timeout = CAM_TIME_DEFAULT; |
7027 | 2077 } |
2078 #endif | |
2079 | |
2080 #if defined( SYS_OS2 ) | |
2081 /***************************************************************************** | |
2082 * OS2InitSDC: initialize a SDC structure for the Execute SCSI-command | |
2083 ***************************************************************************** | |
9333
f0f0f176d298
sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents:
8839
diff
changeset
|
2084 * This function initializes a OS2 'execute SCSI command' structure for |
7027 | 2085 * future use, either a read command or a write command. |
2086 *****************************************************************************/ | |
2087 static void OS2InitSDC( struct OS2_ExecSCSICmd *p_sdc, int i_type ) | |
2088 { | |
2089 switch( i_type ) | |
2090 { | |
2091 case GPCMD_SEND_KEY: | |
2092 p_sdc->flags = 0; | |
2093 break; | |
2094 | |
2095 case GPCMD_READ_DVD_STRUCTURE: | |
2096 case GPCMD_REPORT_KEY: | |
2097 p_sdc->flags = EX_DIRECTION_IN; | |
2098 break; | |
2099 } | |
2100 | |
2101 p_sdc->command[ 0 ] = i_type; | |
2102 p_sdc->command[ 8 ] = (p_sdc->data_length >> 8) & 0xff; | |
2103 p_sdc->command[ 9 ] = p_sdc->data_length & 0xff; | |
2104 p_sdc->id_code = 0x31304443; // 'CD01' | |
2105 p_sdc->cmd_length = 12; | |
2106 } | |
2107 #endif |