Debian Codegraph @

include/support/CDRip.h

raw symbols SCIP
1 /* CDRip Ripping Library
2 * Copyright (C) 1999-2002 Albert L. Faber
3 * Portions Copyright (C) 2002-2015 Robert Kausch <[email protected]>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
18
19 #ifndef CDRIP_INCLUDED
20 #define CDRIP_INCLUDED
21
22 #include <windows.h>
23
24 #pragma pack(push, 4)
25
26 #ifdef _WIN32
27 #define CRCCONV _stdcall
28 #else
29 #define CRCCONV
30 #endif
31
32 #undef DLLEXPORT
33
34 #ifdef CDEX_DLL
35 #define DLLEXPORT __declspec (dllexport)
36 #else
37 #define DLLEXPORT __declspec (dllimport)
38 #endif
39
40 #define CDEX_ERR LONG
41 #define CDEX_OK 0x00000000
42 #define CDEX_ERROR 0x00000001
43 #define CDEX_FILEOPEN_ERROR 0x00000002
44 #define CDEX_JITTER_ERROR 0x00000003
45 #define CDEX_RIPPING_DONE 0x00000004
46 #define CDEX_RIPPING_INPROGRESS 0x00000005
47 #define CDEX_FILEWRITE_ERROR 0x00000006
48 #define CDEX_OUTOFMEMORY 0x00000007
49 #define CDEX_NOCDROMDEVICES 0x00000008
50 #define CDEX_FAILEDTOLOADASPIDRIVERS 0x00000009
51 #define CDEX_NATIVEEASPINOTSUPPORTED 0x0000000A
52 #define CDEX_FAILEDTOGETASPISTATUS 0x0000000B
53 #define CDEX_NATIVEEASPISUPPORTEDNOTSELECTED 0x0000000C
54 #define CDEX_ACCESSDENIED 0x0000000D
55 #define CDEX_SOMEACCESSDENIED 0x0000000E
56 #define CDEX_CACHE_ERROR 0x0000000F
57
58 #define HASTAT_OK 0x00 // Host adapter did not detect an error.
59 #define HASTAT_TIMEOUT 0x09 // The time allocated for a bus transaction ran out.
60 #define HASTAT_COMMAND_TIMEOUT 0x0B // SRB expired while waiting to be processed.
61 #define HASTAT_MESSAGE_REJECT 0x0D // MESSAGE REJECT received while processing SRB.
62 #define HASTAT_BUS_RESET 0x0E // A bus reset was detected.
63 #define HASTAT_PARITY_ERROR 0x0F // A parity error was detected.
64 #define HASTAT_REQUEST_SENSE_FAILED 0x10 // The adapter failed in issuing a Request Sense after a check condition was reported by the target device.
65 #define HASTAT_SEL_TO 0x11 // Selection of target timed out.
66 #define HASTAT_DO_DU 0x12 // Data overrun.
67 #define HASTAT_BUS_FREE 0x13 // Unexpected Bus Free.
68 #define HASTAT_PHASE_ERR 0x14 // Target Bus phase sequence failure.
69
70 #define STATUS_GOOD 0x00 // No target status.
71 #define STATUS_CHKCOND 0x02 // Check status (sense data is in SenseArea).
72 #define STATUS_BUSY 0x08 // Specified Target/LUN is busy.
73 #define STATUS_RESCONF 0x18 // Reservation conflict.
74
75 #define TRANSPLAYER_ASPI (0)
76 #define TRANSPLAYER_NTSCSI (1)
77
78 #define CDROMDATAFLAG 0x04
79 #define AUDIOTRKFLAG 0x10
80
81 #define CR_RIPPING_MODE_NORMAL (0)
82 #define CR_RIPPING_MODE_PARANOIA (1)
83
84 enum CDMEDIASTATUS
85 {
86 CDMEDIA_PRESENT = 0,
87 CDMEDIA_NOT_PRESENT,
88 CDMEDIA_NOT_PRESENT_TRAY_OPEN,
89 CDMEDIA_NOT_PRESENT_TRAY_CLOSED,
90 };
91
92 typedef struct
93 {
94 BYTE sk;
95 BYTE asc;
96 BYTE ascq;
97 BYTE ha_stat;
98 BYTE target_stat;
99 }
100 CDSTATUSINFO;
101
102 enum DRIVETYPE
103 {
104 GENERIC = 0,
105 TOSHIBA,
106 TOSHIBANEW,
107 IBM,
108 NEC,
109 DEC,
110 IMS,
111 KODAK,
112 RICOH,
113 HP,
114 PHILIPS,
115 PLASMON,
116 GRUNDIGCDR100IPW,
117 MITSUMICDR,
118 PLEXTOR,
119 SONY,
120 YAMAHA,
121 NRC,
122 IMSCDD5,
123 CUSTOMDRIVE,
124 NUMDRIVETYPES
125 };
126
127 enum READMETHOD
128 {
129 READMMC = 0,
130 READ10,
131 READNEC,
132 READSONY,
133 READMMC2,
134 READMMC3,
135 READC1,
136 READC2,
137 READC3,
138 READMMC4,
139 NUMREADMETHODS
140 };
141
142 enum SETSPEED
143 {
144 SPEEDNONE = 0,
145 SPEEDMMC,
146 SPEEDSONY,
147 SPEEDYAMAHA,
148 SPEEDTOSHIBA,
149 SPEEDPHILIPS,
150 SPEEDNEC,
151 NUMSPEEDMETHODS
152 };
153
154 enum ENDIAN
155 {
156 ENDIAN_BIG = 0,
157 ENDIAN_LITTLE,
158 ENDIAN_NUM
159 };
160
161 enum ENABLEMODE
162 {
163 ENABLENONE = 0,
164 ENABLESTD,
165 NUMENABLEMODES
166 };
167
168 typedef struct
169 {
170 DRIVETYPE DriveType;
171 READMETHOD ReadMethod;
172 SETSPEED SetSpeed;
173 ENDIAN Endian;
174 ENABLEMODE EnableMode;
175 LONG nDensity;
176 BOOL bAtapi;
177 } DRIVETABLE;
178
179 enum OUTPUTFORMAT
180 {
181 STEREO44100 = 0,
182 MONO44100,
183 STEREO22050,
184 MONO22050,
185 STEREO11025,
186 MONO11025,
187 NUMOUTPUTFORMATS
188 };
189
190 typedef struct
191 {
192 char mmCatalog[0x18];
193 }
194 MCN;
195
196 typedef struct
197 {
198 char isrc[0x18];
199 }
200 ISRC;
201
202 // Anonymous CDROM drive structure
203 struct CDROMDRIVE;
204
205 // CDROM parameters structure
206 typedef struct
207 {
208 char lpszCDROMID[255]; // CD-ROM ID, must be unique to index settings in INI file
209 LONG nNumReadSectors; // Number of sector to read per burst
210 LONG nNumOverlapSectors; // Number of overlap sectors for jitter correction
211 LONG nNumCompareSectors; // Number of sector to compare for jitter correction
212 LONG nOffsetStart; // Fudge factor at start of ripping in sectors
213 LONG nOffsetEnd; // Fudge factor at the end of ripping in sectors
214 LONG nSpeed; // CD-ROM speed factor 0 .. 32 x
215 LONG nSpinUpTime; // CD-ROM spin up time in seconds
216 BOOL bJitterCorrection; // Boolean indicates whether to use Jitter Correction
217 BOOL bSwapLefRightChannel; // Swap left and right channel ?
218 DRIVETABLE DriveTable; // Drive specific parameters
219
220 BYTE btTargetID; // SCSI target ID
221 BYTE btAdapterID; // SCSI Adapter ID
222 BYTE btLunID; // SCSI LUN ID
223
224 BOOL bAspiPosting; // When set ASPI posting is used, otherwhiese ASPI polling is used
225 INT nAspiRetries;
226 INT nAspiTimeOut;
227
228 BOOL bEnableMultiRead; // Enables Multiple Read Verify Feature
229 BOOL bMultiReadFirstOnly; // Only do the multiple reads on the first block
230 INT nMultiReadCount; // Number of times to reread and compare
231
232 BOOL bLockDuringRead; // Lock the CD-ROM drive tray during the ripping
233
234 INT nRippingMode;
235 INT nParanoiaMode;
236
237 BOOL bUseCDText; // Read CD Text info?
238 }
239 CDROMPARAMS;
240
241 // Table of contents structure
242 typedef struct
243 {
244 DWORD dwStartSector; // Start sector of the track
245 BYTE btFlag; // Track flags (i.e. data or audio track)
246 BYTE btTrackNumber; // Track number
247 }
248 TOCENTRY;
249
250 extern "C"
251 {
252 // Call Init before anything else
253 DLLEXPORT CDEX_ERR CRCCONV CR_Init(int nTransportLayer);
254
255 // Call DeInit when ripping library is no longer needed
256 DLLEXPORT CDEX_ERR CRCCONV CR_DeInit();
257
258 // True if CR_Init has been called already
259 DLLEXPORT BOOL CRCCONV CR_IsInitialized();
260
261 // Get the DLL version number
262 DLLEXPORT LONG CRCCONV CR_GetCDRipVersion();
263
264 // Get the number of detected CD-ROM drives
265 DLLEXPORT LONG CRCCONV CR_GetNumCDROM();
266
267 // Open a CDROM drive for subsequent action (0 ... GetNumCDROM() - 1)
268 DLLEXPORT CDROMDRIVE * CRCCONV CR_OpenCDROM(LONG nActiveDrive);
269
270 // Close a previously opened CDROM drive
271 DLLEXPORT CDEX_ERR CRCCONV CR_CloseCDROM(CDROMDRIVE *pDrive);
272
273 // Select the DRIVETYPE of the active drive
274 DLLEXPORT CDEX_ERR CRCCONV CR_SelectCDROMType(CDROMDRIVE *pCDRom, DRIVETYPE cdType);
275
276 // Get the Selected CDROM type
277 DLLEXPORT DRIVETYPE CRCCONV CR_GetCDROMType(CDROMDRIVE *pCDRom);
278
279 // Get the CDROM parameters of the active drive
280 DLLEXPORT CDEX_ERR CRCCONV CR_GetCDROMParameters(CDROMDRIVE *pCDRom, CDROMPARAMS *pParam);
281
282 // Set the CDROM parameters of the active drive
283 DLLEXPORT CDEX_ERR CRCCONV CR_SetCDROMParameters(CDROMDRIVE *pCDRom, CDROMPARAMS *pParam);
284
285 // Start ripping section, output is fetched to WriteBufferFunc
286 // Data is extracted from dwStartSector to dwEndSector
287 DLLEXPORT CDEX_ERR CRCCONV CR_OpenRipper(CDROMDRIVE *pCDRom, LONG *plBufferSize, LONG dwStartSector, LONG dwEndSector);
288
289 // Close the ripper, has to be called when the ripping process is completed (i.e 100%)
290 // Or it can be called to abort the current ripping section
291 DLLEXPORT CDEX_ERR CRCCONV CR_CloseRipper(CDROMDRIVE *pCDRom);
292
293 // Indicates how far the ripping process is right now
294 // Returns 100% when the ripping is completed
295 DLLEXPORT LONG CRCCONV CR_GetPercentCompleted(CDROMDRIVE *pCDRom);
296
297 // Returns the peak value of the ripped section (0..2^15)
298 DLLEXPORT LONG CRCCONV CR_GetPeakValue(CDROMDRIVE *pCDRom);
299
300 // Get number of Jitter errors that have occured during the ripping
301 // This function must be called before CloseRipper is called!
302 DLLEXPORT LONG CRCCONV CR_GetNumberOfJitterErrors(CDROMDRIVE *pCDRom);
303 DLLEXPORT void CRCCONV CR_GetLastJitterErrorPosition(CDROMDRIVE *pCDRom, DWORD &dwStartSector, DWORD &dwEndSector);
304
305 // Get the jitter position of the extracted track
306 DLLEXPORT LONG CRCCONV CR_GetJitterPosition(CDROMDRIVE *pCDRom);
307
308 // Get number of cache errors that have occured during the ripping
309 // This function must be called before CloseRipper is called!
310 DLLEXPORT LONG CRCCONV CR_GetNumberOfCacheErrors(CDROMDRIVE *pCDRom);
311
312 // Rip a chunk from the CD, pbtStream contains the ripped data, pNumBytes the
313 // number of bytes that have been ripped and corrected for jitter (if enabled)
314 DLLEXPORT CDEX_ERR CRCCONV CR_RipChunk(CDROMDRIVE *pCDRom, BYTE *pbtStream, LONG *pNumBytes, BOOL &bAbort);
315
316 // Normalize the stream (i.e. multiply by dScaleFactor)
317 DLLEXPORT void CRCCONV CR_NormalizeChunk(CDROMDRIVE *pCDRom, SHORT *pbsStream, LONG nNumSamples, DOUBLE dScaleFactor);
318
319 // Read the table of contents
320 DLLEXPORT CDEX_ERR CRCCONV CR_ReadToc(CDROMDRIVE *pCDRom);
321
322 // Read CD Text entry
323 DLLEXPORT CDEX_ERR CRCCONV CR_ReadCDText(CDROMDRIVE *pCDRom, BYTE *pbtBuffer, int nBufferSize, LPINT pnCDTextSize);
324
325 // Get the number of TOC entries, including the lead out
326 DLLEXPORT LONG CRCCONV CR_GetNumTocEntries(CDROMDRIVE *pCDRom);
327
328 // Get the TOC entry
329 DLLEXPORT TOCENTRY CRCCONV CR_GetTocEntry(CDROMDRIVE *pCDRom, LONG nTocEntry);
330
331 // Get Media Catalog Number
332 DLLEXPORT CDEX_ERR CRCCONV CR_ReadAndGetMCN(CDROMDRIVE *pCDRom, MCN *mcn);
333
334 // Get ISRC
335 DLLEXPORT CDEX_ERR CRCCONV CR_ReadAndGetISRC(CDROMDRIVE *pCDRom, ISRC *isrc, int track);
336
337 // Checks if the unit is ready (i.e. is the CD media present)
338 DLLEXPORT BOOL CRCCONV CR_IsUnitReady(CDROMDRIVE *pCDRom);
339
340 // Checks if the Media is loaded
341 DLLEXPORT CDEX_ERR CRCCONV CR_IsMediaLoaded(CDROMDRIVE *pCDRom, CDMEDIASTATUS &IsMediaLoaded);
342
343 // Eject the CD, bEject == TRUE => the CD will be ejected, bEject == FALSE => the CD will be loaded
344 DLLEXPORT BOOL CRCCONV CR_EjectCD(CDROMDRIVE *pCDRom, BOOL bEject);
345
346 // Get debug information
347 DLLEXPORT CDSTATUSINFO CRCCONV CR_GetCDStatusInfo(CDROMDRIVE *pCDRom);
348
349 // Lock/unlock the CD Tray
350 DLLEXPORT void CRCCONV CR_LockCD(CDROMDRIVE *pCDRom, BOOL bLock);
351
352 DLLEXPORT void CRCCONV CR_GetSubChannelTrackInfo(CDROMDRIVE *pCDRom, int &nReadIndex, int &nReadTrack, DWORD &dwReadPos);
353
354 DLLEXPORT CDEX_ERR CRCCONV CR_ScanForC2Errors(CDROMDRIVE *pCDRom, DWORD dwStartSector, DWORD dwNumSectors, DWORD &dwErrors, DWORD *pdwErrorSectors);
355
356 DLLEXPORT CDEX_ERR CRCCONV CR_GetDetailedDriveInfo(CDROMDRIVE *pCDRom, LPSTR lpszInfo, DWORD dwInfoSize);
357 } // extern "C"
358
359 #pragma pack(pop)
360
361 #endif