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