1 /****************************************************************************
2 * cdrom_internals.h: cdrom tools private header
3 *****************************************************************************
4 * Copyright (C) 1998-2001 the VideoLAN team
7 * Authors: Johan Bilien <jobi@via.ecp.fr>
8 * Gildas Bazin <gbazin@netcourrier.com>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
25 /*****************************************************************************
26 * The vcddev structure
27 *****************************************************************************/
30 char *psz_dev; /* vcd device name */
32 /* Section used in vcd image mode */
33 int i_vcdimage_handle; /* vcd image file descriptor */
34 int i_tracks; /* number of tracks of the vcd */
35 int *p_sectors; /* tracks layout on the vcd */
37 /* Section used in vcd device mode */
40 HANDLE h_device_handle; /* vcd device descriptor */
43 long (*lpSendCommand)( void* );
46 int i_device_handle; /* vcd device descriptor */
52 /*****************************************************************************
54 *****************************************************************************/
55 /* LBA = msf.frame + 75 * ( msf.second + 60 * msf.minute ) */
56 #define MSF_TO_LBA(min, sec, frame) ((int)frame + 75 * (sec + 60 * min))
57 /* LBA = msf.frame + 75 * ( msf.second - 2 + 60 * msf.minute ) */
58 #define MSF_TO_LBA2(min, sec, frame) ((int)frame + 75 * (sec -2 + 60 * min))
66 /*****************************************************************************
68 *****************************************************************************/
69 #if defined( __APPLE__ )
70 #define darwin_freeTOC( p ) free( (void*)p )
71 #define CD_MIN_TRACK_NO 01
72 #define CD_MAX_TRACK_NO 99
77 /* Win32 DeviceIoControl specifics */
78 #ifndef MAXIMUM_NUMBER_TRACKS
79 # define MAXIMUM_NUMBER_TRACKS 100
81 typedef struct _TRACK_DATA {
88 } TRACK_DATA, *PTRACK_DATA;
89 typedef struct _CDROM_TOC {
93 TRACK_DATA TrackData[MAXIMUM_NUMBER_TRACKS];
94 } CDROM_TOC, *PCDROM_TOC;
95 typedef enum _TRACK_MODE_TYPE {
99 } TRACK_MODE_TYPE, *PTRACK_MODE_TYPE;
100 typedef struct __RAW_READ_INFO {
101 LARGE_INTEGER DiskOffset;
103 TRACK_MODE_TYPE TrackMode;
104 } RAW_READ_INFO, *PRAW_READ_INFO;
105 typedef struct _CDROM_READ_TOC_EX {
112 } CDROM_READ_TOC_EX, *PCDROM_READ_TOC_EX;
114 #ifndef IOCTL_CDROM_BASE
115 # define IOCTL_CDROM_BASE FILE_DEVICE_CD_ROM
117 #ifndef IOCTL_CDROM_READ_TOC
118 # define IOCTL_CDROM_READ_TOC CTL_CODE(IOCTL_CDROM_BASE, 0x0000, \
119 METHOD_BUFFERED, FILE_READ_ACCESS)
121 #ifndef IOCTL_CDROM_RAW_READ
122 #define IOCTL_CDROM_RAW_READ CTL_CODE(IOCTL_CDROM_BASE, 0x000F, \
123 METHOD_OUT_DIRECT, FILE_READ_ACCESS)
125 #define IOCTL_CDROM_READ_TOC_EX CTL_CODE(IOCTL_CDROM_BASE, 0x0015, \
126 METHOD_BUFFERED, FILE_READ_ACCESS)
129 #define MINIMUM_CDROM_READ_TOC_EX_SIZE 2
130 #define CDROM_READ_TOC_EX_FORMAT_CDTEXT 0x05
132 /* Win32 aspi specific */
133 #define WIN_NT ( GetVersion() < 0x80000000 )
135 #define ASPI_TARGET 0
136 #define DTYPE_CDROM 0x05
138 #define SENSE_LEN 0x0E
139 #define SC_GET_DEV_TYPE 0x01
140 #define SC_EXEC_SCSI_CMD 0x02
141 #define SC_GET_DISK_INFO 0x06
143 #define SS_PENDING 0x00
144 #define SS_NO_ADAPTERS 0xE8
145 #define SRB_DIR_IN 0x08
146 #define SRB_DIR_OUT 0x10
147 #define SRB_EVENT_NOTIFY 0x40
150 #define SECTOR_TYPE_MODE2_FORM2 0x14
151 #define SECTOR_TYPE_CDDA 0x04
152 #define READ_CD_RAW_MODE2 0xF0
153 #define READ_CD_USERDATA 0x10
155 #define READ_TOC 0x43
156 #define READ_TOC_FORMAT_TOC 0x0
160 struct SRB_GetDiskInfo
162 unsigned char SRB_Cmd;
163 unsigned char SRB_Status;
164 unsigned char SRB_HaId;
165 unsigned char SRB_Flags;
166 unsigned long SRB_Hdr_Rsvd;
167 unsigned char SRB_Target;
168 unsigned char SRB_Lun;
169 unsigned char SRB_DriveFlags;
170 unsigned char SRB_Int13HDriveInfo;
171 unsigned char SRB_Heads;
172 unsigned char SRB_Sectors;
173 unsigned char SRB_Rsvd1[22];
178 unsigned char SRB_Cmd;
179 unsigned char SRB_Status;
180 unsigned char SRB_HaId;
181 unsigned char SRB_Flags;
182 unsigned long SRB_Hdr_Rsvd;
183 unsigned char SRB_Target;
184 unsigned char SRB_Lun;
185 unsigned char SRB_DeviceType;
186 unsigned char SRB_Rsvd1;
189 struct SRB_ExecSCSICmd
191 unsigned char SRB_Cmd;
192 unsigned char SRB_Status;
193 unsigned char SRB_HaId;
194 unsigned char SRB_Flags;
195 unsigned long SRB_Hdr_Rsvd;
196 unsigned char SRB_Target;
197 unsigned char SRB_Lun;
198 unsigned short SRB_Rsvd1;
199 unsigned long SRB_BufLen;
200 unsigned char *SRB_BufPointer;
201 unsigned char SRB_SenseLen;
202 unsigned char SRB_CDBLen;
203 unsigned char SRB_HaStat;
204 unsigned char SRB_TargStat;
205 unsigned long *SRB_PostProc;
206 unsigned char SRB_Rsvd2[20];
207 unsigned char CDBByte[16];
208 unsigned char SenseArea[SENSE_LEN+2];
215 /*****************************************************************************
217 *****************************************************************************/
218 static int OpenVCDImage( vlc_object_t *, const char *, struct vcddev_s * );
219 static void CloseVCDImage( vlc_object_t *, struct vcddev_s * );
221 #if defined( __APPLE__ )
222 static CDTOC *darwin_getTOC( vlc_object_t *, const struct vcddev_s * );
223 static int darwin_getNumberOfTracks( CDTOC *, int );
225 #elif defined( WIN32 )
226 static int win32_vcd_open( vlc_object_t *, const char *, struct vcddev_s *);