annotate libdvdcss/ioctl.c @ 32444:99efb38a4f4e

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