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;
106 #ifndef IOCTL_CDROM_BASE
107 # define IOCTL_CDROM_BASE FILE_DEVICE_CD_ROM
109 #ifndef IOCTL_CDROM_READ_TOC
110 # define IOCTL_CDROM_READ_TOC CTL_CODE(IOCTL_CDROM_BASE, 0x0000, \
111 METHOD_BUFFERED, FILE_READ_ACCESS)
113 #ifndef IOCTL_CDROM_RAW_READ
114 #define IOCTL_CDROM_RAW_READ CTL_CODE(IOCTL_CDROM_BASE, 0x000F, \
115 METHOD_OUT_DIRECT, FILE_READ_ACCESS)
118 /* Win32 aspi specific */
119 #define WIN_NT ( GetVersion() < 0x80000000 )
121 #define ASPI_TARGET 0
122 #define DTYPE_CDROM 0x05
124 #define SENSE_LEN 0x0E
125 #define SC_GET_DEV_TYPE 0x01
126 #define SC_EXEC_SCSI_CMD 0x02
127 #define SC_GET_DISK_INFO 0x06
129 #define SS_PENDING 0x00
130 #define SS_NO_ADAPTERS 0xE8
131 #define SRB_DIR_IN 0x08
132 #define SRB_DIR_OUT 0x10
133 #define SRB_EVENT_NOTIFY 0x40
136 #define SECTOR_TYPE_MODE2_FORM2 0x14
137 #define SECTOR_TYPE_CDDA 0x04
138 #define READ_CD_RAW_MODE2 0xF0
139 #define READ_CD_USERDATA 0x10
141 #define READ_TOC 0x43
142 #define READ_TOC_FORMAT_TOC 0x0
146 struct SRB_GetDiskInfo
148 unsigned char SRB_Cmd;
149 unsigned char SRB_Status;
150 unsigned char SRB_HaId;
151 unsigned char SRB_Flags;
152 unsigned long SRB_Hdr_Rsvd;
153 unsigned char SRB_Target;
154 unsigned char SRB_Lun;
155 unsigned char SRB_DriveFlags;
156 unsigned char SRB_Int13HDriveInfo;
157 unsigned char SRB_Heads;
158 unsigned char SRB_Sectors;
159 unsigned char SRB_Rsvd1[22];
164 unsigned char SRB_Cmd;
165 unsigned char SRB_Status;
166 unsigned char SRB_HaId;
167 unsigned char SRB_Flags;
168 unsigned long SRB_Hdr_Rsvd;
169 unsigned char SRB_Target;
170 unsigned char SRB_Lun;
171 unsigned char SRB_DeviceType;
172 unsigned char SRB_Rsvd1;
175 struct SRB_ExecSCSICmd
177 unsigned char SRB_Cmd;
178 unsigned char SRB_Status;
179 unsigned char SRB_HaId;
180 unsigned char SRB_Flags;
181 unsigned long SRB_Hdr_Rsvd;
182 unsigned char SRB_Target;
183 unsigned char SRB_Lun;
184 unsigned short SRB_Rsvd1;
185 unsigned long SRB_BufLen;
186 unsigned char *SRB_BufPointer;
187 unsigned char SRB_SenseLen;
188 unsigned char SRB_CDBLen;
189 unsigned char SRB_HaStat;
190 unsigned char SRB_TargStat;
191 unsigned long *SRB_PostProc;
192 unsigned char SRB_Rsvd2[20];
193 unsigned char CDBByte[16];
194 unsigned char SenseArea[SENSE_LEN+2];
201 /*****************************************************************************
203 *****************************************************************************/
204 static int OpenVCDImage( vlc_object_t *, const char *, struct vcddev_s * );
205 static void CloseVCDImage( vlc_object_t *, struct vcddev_s * );
207 #if defined( __APPLE__ )
208 static CDTOC *darwin_getTOC( vlc_object_t *, const struct vcddev_s * );
209 static int darwin_getNumberOfTracks( CDTOC *, int );
211 #elif defined( WIN32 )
212 static int win32_vcd_open( vlc_object_t *, const char *, struct vcddev_s *);