annotate libdvdcss/ioctl.c @ 36404:4df68a2d918b

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