1 /*
2  * akrip32.h - Copyright (C) 1999 Jay A. Key
3  *
4  * API for akrip32.dll
5  *
6  **********************************************************************
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License as published
10  * by the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21  *
22  **********************************************************************
23  *
24  */
25 
26 #ifndef _AKRIP32_H_
27 #define _AKRIP32_H_
28 
29 #include <windows.h>
30 #include "myaspi32.h"
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 #ifndef __GNUC__
37 #define PACKED
38 #endif
39 
40 #define TRACK_AUDIO   0x00
41 #define TRACK_DATA    0x01
42 
43 #define  MAXIDLEN   64
44 #define  MAXCDLIST  8
45 
46 /*
47  * TRACKBUF
48  *
49  * This structure should not be allocated directly.  If a buffer containing
50  * 27 * 2353 bytes is desired, a buffer should be allocated containing
51  * the desired amount + 24 bytes.  The allocated memory can then be
52  * typecast to a LPTRACKBUF.  It is the program's responsibility to guard
53  * against reading/writing past the end of allocated memory.
54  *
55  * The following must always apply:
56  *   (len + startOffset) <= (numFrames * 2352) <= maxLen
57  */
58 typedef struct
59 {
60   DWORD   startFrame;       /* 00: starting frame number          */
61   DWORD   numFrames;        /* 04: number of frames read          */
62   DWORD   maxLen;           /* 08: length of buffer itself        */
63   DWORD   len;              /* 0C: length of data actually in buf */
64   DWORD   status;           /* 10: status of last read operation  */
65   int     startOffset;      /* 14: offset of valid data in buf    */
66   BYTE    buf[1024*1024];     /* 18: the data itself                */
67 } *PTRACKBUF, FAR *LPTRACKBUF;
68 
69 typedef struct
70 {
71   DWORD   startFrame;       /* 00: starting frame number          */
72   DWORD   numFrames;        /* 04: number of frames read          */
73   DWORD   maxLen;           /* 08: length of buffer itself        */
74   DWORD   len;              /* 0C: length of data actually in buf */
75   DWORD   status;           /* 10: status of last read operation  */
76   int     startOffset;      /* 14: offset of valid data in buf    */
77 } TRACKBUFDUMMY;
78 #define TRACKBUFEXTRA   sizeof(TRACKBUFDUMMY)
79 
80 
81 typedef struct
82 {
83   char vendor[9];
84   char prodId[17];
85   char rev[5];
86   char vendSpec[21];
87 } CDINFO, *PCDINFO, FAR *LPCDINFO;
88 
89 typedef struct
90 {
91   BYTE      ha;
92   BYTE      tgt;
93   BYTE      lun;
94   BYTE      pad;
95   char      id[MAXIDLEN + 1];
96   CDINFO    info;
97 } CDREC, *PCDREC, FAR *LPCDREC;
98 
99 typedef struct
100 {
101   BYTE      max;
102   BYTE      num;
103   CDREC     cd[MAXCDLIST];
104 } CDLIST, *PCDLIST, FAR *LPCDLIST;
105 
106 
107 #ifndef __GNUC__
108 #pragma pack(1)
109 #endif
110 
111 /*
112  * TOCTRACK and TOC must be byte-aligned.  If you're not using Mingw32,
113  * CygWin, or some other compiler that understands the PACKED keyword,
114  * you need to ensure that these structures are byte aligned.  Usually,
115  * this is done using a
116  *  #pragma pack(1)
117  * See your compiler's documentation for details
118  */
119 typedef struct
120 {
121   BYTE      rsvd;
122   BYTE      ADR;
123   BYTE      trackNumber;
124   BYTE      rsvd2;
125   BYTE      addr[4];
126 } PACKED TOCTRACK;
127 
128 typedef struct
129 {
130   WORD      tocLen;
131   BYTE      firstTrack;
132   BYTE      lastTrack;
133   TOCTRACK tracks[100];
134 } PACKED TOC, *PTOC, FAR *LPTOC;
135 
136 typedef struct
137 {
138   int   trackNo;
139   DWORD startLBA;
140   DWORD trackLen;
141   BYTE  type;
142   BYTE  pad[3];
143   char  name[256];
144 } PACKED TRACK, *PTRACK, FAR *LPTRACK;
145 
146 #ifndef __GNUC__
147 #pragma pack()
148 #endif
149 
150 typedef struct
151 {
152   BYTE sm;
153   BYTE ss;
154   BYTE sf;
155   BYTE em;
156   BYTE es;
157   BYTE ef;
158 } READMSF, *PREADMSF, FAR *LPREADMSF;
159 
160 
161 /*
162  * Error codes set by functions in ASPILIB.C
163  */
164 #define ALERR_NOERROR           0
165 #define ALERR_NOWNASPI         -1
166 #define ALERR_NOGETASPI32SUPP  -2
167 #define ALERR_NOSENDASPICMD    -3
168 #define ALERR_ASPI             -4
169 #define ALERR_NOCDSELECTED     -5
170 #define ALERR_BUFTOOSMALL      -6
171 #define ALERR_INVHANDLE        -7
172 #define ALERR_NOMOREHAND       -8
173 #define ALERR_BUFPTR           -9
174 #define ALERR_NOTACD           -10
175 #define ALERR_LOCK             -11
176 #define ALERR_DUPHAND          -12
177 #define ALERR_INVPTR           -13
178 #define ALERR_INVPARM          -14
179 #define ALERR_JITTER           -15
180 #define ALERR_NOADAPTERS       -16
181 #define ALERR_NOCDFOUND        -17
182 
183 /*
184  * API codes
185  */
186 #define APIC_NONE        0
187 #define APIC_ASPI        1
188 #define APIC_SCSIPT      2
189 
190 /*
191  * constants used for queryCDParms()
192  */
193 
194 #define CDP_READCDR      0x0001     // can read CD-R
195 #define CDP_READCDE      0x0002     // can read CD-E
196 #define CDP_METHOD2      0x0003     // can read CD-R wriiten via method 2
197 #define CDP_WRITECDR     0x0004     // can write CD-R
198 #define CDP_WRITECDE     0x0005     // can write CD-E
199 #define CDP_AUDIOPLAY    0x0006     // can play audio
200 #define CDP_COMPOSITE    0x0007     // composite audio/video stream
201 #define CDP_DIGITAL1     0x0008     // digital output (IEC958) on port 1
202 #define CDP_DIGITAL2     0x0009     // digital output (IEC958) on port 2
203 #define CDP_M2FORM1      0x000A     // reads Mode 2 Form 1 (XA) format
204 #define CDP_M2FORM2      0x000B     // reads Mode 2 Form 2 format
205 #define CDP_MULTISES     0x000C     // reads multi-session or Photo-CD
206 #define CDP_CDDA         0x000D     // supports cd-da
207 #define CDP_STREAMACC    0x000E     // supports "stream is accurate"
208 #define CDP_RW           0x000F     // can return R-W info
209 #define CDP_RWCORR       0x0010     // returns R-W de-interleaved and err.
210                                     // corrected
211 #define CDP_C2SUPP       0x0011     // C2 error pointers
212 #define CDP_ISRC         0x0012     // can return the ISRC info
213 #define CDP_UPC          0x0013     // can return the Media Catalog Number
214 #define CDP_CANLOCK      0x0014     // prevent/allow cmd. can lock the media
215 #define CDP_LOCKED       0x0015     // current lock state (TRUE = LOCKED)
216 #define CDP_PREVJUMP     0x0016     // prevent/allow jumper state
217 #define CDP_CANEJECT     0x0017     // drive can eject disk
218 #define CDP_MECHTYPE     0x0018     // type of disk loading supported
219 #define CDP_SEPVOL       0x0019     // independent audio level for channels
220 #define CDP_SEPMUTE      0x001A     // independent mute for channels
221 #define CDP_SDP          0x001B     // supports disk present (SDP)
222 #define CDP_SSS          0x001C     // Software Slot Selection
223 #define CDP_MAXSPEED     0x001D     // maximum supported speed of drive
224 #define CDP_NUMVOL       0x001E     // number of volume levels
225 #define CDP_BUFSIZE      0x001F     // size of output buffer
226 #define CDP_CURRSPEED    0x0020     // current speed of drive
227 #define CDP_SPM          0x0021     // "S" units per "M" (MSF format)
228 #define CDP_FPS          0x0022     // "F" units per "S" (MSF format)
229 #define CDP_INACTMULT    0x0023     // inactivity multiplier ( x 125 ms)
230 #define CDP_MSF          0x0024     // use MSF format for READ TOC cmd
231 #define CDP_OVERLAP      0x0025     // number of overlap frames for jitter
232 #define CDP_JITTER       0x0026     // number of frames to check for jitter
233 #define CDP_READMODE     0x0027     // mode to attempt jitter corr.
234 
235 /*
236  * defines for GETCDHAND  readType
237  *
238  */
239 #define CDR_ANY          0x00       // unknown
240 #define CDR_ATAPI1       0x01       // ATAPI per spec
241 #define CDR_ATAPI2       0x02       // alternate ATAPI
242 #define CDR_READ6        0x03       // using SCSI READ(6)
243 #define CDR_READ10       0x04       // using SCSI READ(10)
244 #define CDR_READ_D8      0x05       // using command 0xD8 (Plextor?)
245 #define CDR_READ_D4      0x06       // using command 0xD4 (NEC?)
246 #define CDR_READ_D4_1    0x07       // 0xD4 with a mode select
247 #define CDR_READ10_2     0x08       // different mode select w/ READ(10)
248 
249 /*
250  * defines for the read mode (CDP_READMODE)
251  */
252 #define CDRM_NOJITTER      0x00     // never jitter correct
253 #define CDRM_JITTER        0x01     // always jitter correct
254 #define CDRM_JITTERONERR   0x02     // jitter correct only after a read error
255 
256 #ifndef __GNUC__
257 #pragma pack(1)
258 #endif
259 
260 typedef HANDLE HCDROM;
261 typedef struct _GETCDHAND {
262   BYTE size;             /* set to sizeof(GETCDHAND)            */
263   BYTE ver;              /* set to AKRIPVER                     */
264   BYTE ha;               /* host adapter                        */
265   BYTE tgt;              /* target id                           */
266   BYTE lun;              /* LUN                                 */
267   BYTE readType;         /* read function to use                */
268   BOOL jitterCorr;       /* use built-in jitter correction?     */
269   BYTE numJitter;        /* number of frames to try to match    */
270   BYTE numOverlap;       /* number of frames to overlap         */
271 } PACKED GETCDHAND, *PGETCDHAND, FAR *LPGETCDHAND;
272 
273 #ifndef __GNUC__
274 #pragma pack()
275 #endif
276 
277 // Used by InsertCDCacheItem
278 #define CDDB_NONE    0
279 #define CDDB_QUERY   1
280 #define CDDB_ENTRY   2
281 
282 
283 #define CDDB_OPT_SERVER      0
284 #define CDDB_OPT_PROXY       1
285 #define CDDB_OPT_USEPROXY    2
286 #define CDDB_OPT_AGENT       3
287 #define CDDB_OPT_USER        4
288 #define CDDB_OPT_PROXYPORT   5
289 #define CDDB_OPT_CGI         6
290 #define CDDB_OPT_HTTPPORT    7
291 #define CDDB_OPT_USECDPLAYERINI 8
292 #define CDDB_OPT_USEHTTP1_0  9
293 #define CDDB_OPT_SUBMITCGI   10
294 #define CDDB_OPT_USERAUTH    11
295 #define CDDB_OPT_PROTOLEVEL  12
296 
297 int GetNumAdapters( void );
298 int GetCDList( LPCDLIST cd );
299 int GetAspiLibError( void );
300 BYTE GetAspiLibAspiError( void );
301 
302 DWORD GetCDId( HCDROM hCD, char *buf, int maxBuf );
303 DWORD GetDriveInfo( BYTE ha, BYTE tgt, BYTE lun, LPCDREC cdrec );
304 DWORD ReadTOC( HCDROM hCD, LPTOC lpToc );
305 DWORD ReadCDAudioLBA( HCDROM hCD, LPTRACKBUF );
306 BOOL QueryCDParms( HCDROM hCD, int which, DWORD *pNum );
307 BOOL ModifyCDParms( HCDROM hCD, int which, DWORD val );
308 HCDROM GetCDHandle( LPGETCDHAND lpcd );
309 BOOL CloseCDHandle( HCDROM );
310 DWORD ReadCDAudioLBAEx( HCDROM hCD, LPTRACKBUF, LPTRACKBUF );
311 DWORD GetAKRipDllVersion( void );
312 
313 /*
314  * CDDB support
315  */
316 typedef struct {
317   char categ[12];
318   char cddbId[9];
319   BOOL bExact;
320   char artist[81];
321   char title[81];
322 } CDDBQUERYITEM, FAR *LPCDDBQUERYITEM;
323 
324 
325 typedef struct {
326   int num;
327   LPCDDBQUERYITEM q;
328 } CDDBQUERY, FAR *LPCDDBQUERY;
329 
330 
331 typedef struct {
332   char szServer[81];
333   BOOL bHTTP;
334   int  iPort;
335   char szCGI[81];
336   char szNorth[16];
337   char szSouth[16];
338   char szLocation[81];
339 } CDDBSITE, FAR *LPCDDBSITE;
340 
341 
342 typedef struct {
343   int num;
344   LPCDDBSITE s;
345 } CDDBSITELIST, FAR *LPCDDBSITELIST;
346 
347 
348 DWORD GetCDDBDiskID( HCDROM hCD, DWORD *pID, int numEntries );
349 DWORD CDDBQuery( HCDROM hCD, LPCDDBQUERY lpq );
350 DWORD CDDBGetDiskInfo( LPCDDBQUERYITEM lpq, char *szCDDBEntry, int maxLen );
351 void CDDBSetOption( int what, char *szVal, int iVal );
352 DWORD CDDBGetOptionInt( int what, BOOL *bValid );
353 char *CDDBGetOptionText( int what, char *szBuf, int maxLen, BOOL *bValid );
354 DWORD CDDBGetServerList( LPCDDBSITELIST lpSiteList );
355 DWORD CDDBSubmit( DWORD dwDiscID, BOOL bTest, char *szEmail, char *szCategory,
356 		  char *szEntry );
357 
358 /*
359  * CDDA
360  */
361 DWORD PlayTrack( HCDROM hCD, DWORD track_index );
362 DWORD PlayAudioRange( HCDROM hCD, DWORD From, DWORD Length );
363 DWORD startStopUnit( HCDROM hCD, BOOL bLoEj, BOOL bStart );
364 DWORD pauseResumeCD( HCDROM hCD, BOOL bPause );
365 
366 #ifdef __cplusplus
367 }
368 #endif
369 
370 #endif   /* _AKRIP32_H_ */
371