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