1 // -*- C++ -*-
2 /* $Id: globals.h,v 1.54 2003/02/21 03:47:41 slackorama Exp $
3 
4  * id3lib: a C++ library for creating and manipulating id3v1/v2 tags
5  * Copyright 1999, 2000 Scott Thomas Haug
6  * Copyright 2002 Thijmen Klok (thijmen@id3lib.org)
7 
8  * This library is free software; you can redistribute it and/or modify it
9  * under the terms of the GNU Library General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or (at your
11  * option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
16  * License for more details.
17  *
18  * You should have received a copy of the GNU Library General Public License
19  * along with this library; if not, write to the Free Software Foundation,
20  * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 
22  * The id3lib authors encourage improvements and optimisations to be sent to
23  * the id3lib coordinator.  Please see the README file for details on where to
24  * send such submissions.  See the AUTHORS file for a list of people who have
25  * contributed to id3lib.  See the ChangeLog file for a list of changes to
26  * id3lib.  These files are distributed with id3lib at
27  * http://download.sourceforge.net/id3lib/
28  */
29 
30 /** This file defines common macros, types, constants, and enums used
31  ** throughout id3lib.
32  **/
33 
34 #ifndef _ID3LIB_GLOBALS_H_
35 #define _ID3LIB_GLOBALS_H_
36 
37 #include <stdlib.h>
38 #include "id3/sized_types.h"
39 
40 /* id3lib version.
41  * we prefix variable declarations so they can
42  * properly get exported in windows dlls.
43  */
44 #ifdef WIN32
45 #  define LINKOPTION_STATIC         1 //both for use and creation of static lib
46 #  define LINKOPTION_CREATE_DYNAMIC 2 //should only be used by prj/id3lib.dsp
47 #  define LINKOPTION_USE_DYNAMIC    3 //if your project links id3lib dynamic
48 #  ifndef ID3LIB_LINKOPTION
49 #    pragma message("*** NOTICE *** (not a real error)")
50 #    pragma message("* You should include a define in your project which reflect how you link the library")
51 #    pragma message("* If you use id3lib.lib or libprj/id3lib.dsp (you link static) you should add")
52 #    pragma message("* ID3LIB_LINKOPTION=1 to your preprocessor definitions of your project.")
53 #    pragma message("* If you use id3lib.dll (you link dynamic) you should add ID3LIB_LINKOPTION=3")
54 #    pragma message("* to your preprocessor definitions of your project.")
55 #    pragma message("***")
56 #    error read message above or win32.readme.first.txt
57 #  else
58 #    if (ID3LIB_LINKOPTION == LINKOPTION_CREATE_DYNAMIC)
59        //used for creating a dynamic dll
60 #      define ID3_C_EXPORT extern _declspec(dllexport)
61 #      define ID3_CPP_EXPORT __declspec(dllexport)
62 #      define CCONV __stdcall // Added for VB & Delphi Compatibility - By FrogPrince Advised By Lothar
63 #    endif
64 #    if (ID3LIB_LINKOPTION == LINKOPTION_STATIC)
65        //used for creating a static lib and using a static lib
66 #      define ID3_C_EXPORT
67 #      define ID3_CPP_EXPORT
68 #      define CCONV
69 #    endif
70 #    if (ID3LIB_LINKOPTION == LINKOPTION_USE_DYNAMIC)
71        //used for those that do not link static and are using the dynamic dll by including a id3lib header
72 #      define ID3_C_EXPORT extern _declspec(dllimport)
73 #      define ID3_CPP_EXPORT __declspec(dllimport) //functions like these shouldn't be used by vb and delphi,
74 #      define CCONV __stdcall // Added for VB & Delphi Compatibility - By FrogPrince Advised By Lothar
75 #    endif
76 #  endif
77 #else /* !WIN32 */
78 #  define ID3_C_EXPORT
79 #  define ID3_CPP_EXPORT
80 #  define CCONV
81 #endif /* !WIN32 */
82 
83 #define ID3_C_VAR extern
84 
85 #ifndef __cplusplus
86 
87 typedef int bool;
88 #  define false (0)
89 #  define true (!false)
90 
91 #endif /* __cplusplus */
92 
93 ID3_C_VAR const char * const ID3LIB_NAME;
94 ID3_C_VAR const char * const ID3LIB_RELEASE;
95 ID3_C_VAR const char * const ID3LIB_FULL_NAME;
96 ID3_C_VAR const int          ID3LIB_MAJOR_VERSION;
97 ID3_C_VAR const int          ID3LIB_MINOR_VERSION;
98 ID3_C_VAR const int          ID3LIB_PATCH_VERSION;
99 ID3_C_VAR const int          ID3LIB_INTERFACE_AGE;
100 ID3_C_VAR const int          ID3LIB_BINARY_AGE;
101 
102 #define ID3_TAGID               "ID3"
103 #define ID3_TAGIDSIZE           (3)
104 #define ID3_TAGHEADERSIZE       (10)
105 
106 /** String used for the description field of a comment tag converted from an
107  ** id3v1 tag to an id3v2 tag
108  **
109  ** \sa #ID3V1_Tag
110  **/
111 #define STR_V1_COMMENT_DESC "ID3v1 Comment"
112 
113 
114 typedef       unsigned char   uchar;
115 typedef long  unsigned int    luint;
116 
117 typedef uint16                unicode_t;
118 typedef uint16                flags_t;
119 
120 #define NULL_UNICODE ((unicode_t) '\0')
121 
122 /* These macros are used to make the C and C++ declarations for enums and
123  * structs have the same syntax.  Basically, it allows C users to refer to an
124  * enum or a struct without prepending enum/struct.
125  */
126 #ifdef __cplusplus
127 #  define ID3_ENUM(E)   enum   E
128 #  define ID3_STRUCT(S) struct S
129 #else
130 #  define ID3_ENUM(E)   typedef enum   _ ## E E; enum   _ ## E
131 #  define ID3_STRUCT(S) typedef struct _ ## S S; struct _ ## S
132 #endif
133 
134 /** \enum ID3_TextEnc
135  ** Enumeration of the types of text encodings: ascii or unicode
136  **/
ID3_ENUM(ID3_TextEnc)137 ID3_ENUM(ID3_TextEnc)
138 {
139   ID3TE_NONE = -1,
140   ID3TE_ISO8859_1,
141   ID3TE_UTF16,
142   ID3TE_UTF16BE,
143   ID3TE_UTF8,
144   ID3TE_NUMENCODINGS,
145   ID3TE_ASCII = ID3TE_ISO8859_1, // do not use this -> use ID3TE_IS_SINGLE_BYTE_ENC(enc) instead
146   ID3TE_UNICODE = ID3TE_UTF16    // do not use this -> use ID3TE_IS_DOUBLE_BYTE_ENC(enc) instead
147 };
148 
149 #define ID3TE_IS_SINGLE_BYTE_ENC(enc)    ((enc) == ID3TE_ISO8859_1 || (enc) == ID3TE_UTF8)
150 #define ID3TE_IS_DOUBLE_BYTE_ENC(enc)    ((enc) == ID3TE_UTF16 || (enc) == ID3TE_UTF16BE)
151 
152 /** Enumeration of the various id3 specifications
153  **/
ID3_ENUM(ID3_V1Spec)154 ID3_ENUM(ID3_V1Spec)
155 {
156   ID3V1_0 = 0,
157   ID3V1_1,
158   ID3V1_NUMSPECS
159 };
160 
ID3_ENUM(ID3_V2Spec)161 ID3_ENUM(ID3_V2Spec)
162 {
163   ID3V2_UNKNOWN = -1,
164   ID3V2_2_0 = 0,
165   ID3V2_2_1,
166   ID3V2_3_0,
167   ID3V2_4_0,
168   ID3V2_EARLIEST = ID3V2_2_0,
169   ID3V2_LATEST = ID3V2_3_0
170 };
171 
172 /** The various types of tags that id3lib can handle
173  **/
ID3_ENUM(ID3_TagType)174 ID3_ENUM(ID3_TagType)
175 {
176   ID3TT_NONE       =      0,   /**< Represents an empty or non-existant tag */
177   ID3TT_ID3V1      = 1 << 0,   /**< Represents an id3v1 or id3v1.1 tag */
178   ID3TT_ID3V2      = 1 << 1,   /**< Represents an id3v2 tag */
179   ID3TT_LYRICS3    = 1 << 2,   /**< Represents a Lyrics3 tag */
180   ID3TT_LYRICS3V2  = 1 << 3,   /**< Represents a Lyrics3 v2.00 tag */
181   ID3TT_MUSICMATCH = 1 << 4,   /**< Represents a MusicMatch tag */
182    /**< Represents a Lyrics3 tag (for backwards compatibility) */
183   ID3TT_LYRICS     = ID3TT_LYRICS3,
184   /** Represents both id3 tags: id3v1 and id3v2 */
185   ID3TT_ID3        = ID3TT_ID3V1 | ID3TT_ID3V2,
186   /** Represents all possible types of tags */
187   ID3TT_ALL        = ~ID3TT_NONE,
188   /** Represents all tag types that can be prepended to a file */
189   ID3TT_PREPENDED  = ID3TT_ID3V2,
190   /** Represents all tag types that can be appended to a file */
191   ID3TT_APPENDED   = ID3TT_ALL & ~ID3TT_ID3V2
192 };
193 
194 /**
195  ** Enumeration of the different types of fields in a frame.
196  **/
ID3_ENUM(ID3_FieldID)197 ID3_ENUM(ID3_FieldID)
198 {
199   ID3FN_NOFIELD = 0,    /**< No field */
200   ID3FN_TEXTENC,        /**< Text encoding (unicode or ASCII) */
201   ID3FN_TEXT,           /**< Text field */
202   ID3FN_URL,            /**< A URL */
203   ID3FN_DATA,           /**< Data field */
204   ID3FN_DESCRIPTION,    /**< Description field */
205   ID3FN_OWNER,          /**< Owner field */
206   ID3FN_EMAIL,          /**< Email field */
207   ID3FN_RATING,         /**< Rating field */
208   ID3FN_FILENAME,       /**< Filename field */
209   ID3FN_LANGUAGE,       /**< Language field */
210   ID3FN_PICTURETYPE,    /**< Picture type field */
211   ID3FN_IMAGEFORMAT,    /**< Image format field */
212   ID3FN_MIMETYPE,       /**< Mimetype field */
213   ID3FN_COUNTER,        /**< Counter field */
214   ID3FN_ID,             /**< Identifier/Symbol field */
215   ID3FN_VOLUMEADJ,      /**< Volume adjustment field */
216   ID3FN_NUMBITS,        /**< Number of bits field */
217   ID3FN_VOLCHGRIGHT,    /**< Volume chage on the right channel */
218   ID3FN_VOLCHGLEFT,     /**< Volume chage on the left channel */
219   ID3FN_PEAKVOLRIGHT,   /**< Peak volume on the right channel */
220   ID3FN_PEAKVOLLEFT,    /**< Peak volume on the left channel */
221   ID3FN_TIMESTAMPFORMAT,/**< SYLT Timestamp Format */
222   ID3FN_CONTENTTYPE,    /**< SYLT content type */
223   ID3FN_LASTFIELDID     /**< Last field placeholder */
224 };
225 
226 /**
227  ** Enumeration of the different types of frames recognized by id3lib
228  **/
ID3_ENUM(ID3_FrameID)229 ID3_ENUM(ID3_FrameID)
230 {
231   /* ???? */ ID3FID_NOFRAME = 0,       /**< No known frame */
232   /* AENC */ ID3FID_AUDIOCRYPTO,       /**< Audio encryption */
233   /* APIC */ ID3FID_PICTURE,           /**< Attached picture */
234   /* ASPI */ ID3FID_AUDIOSEEKPOINT,    /**< Audio seek point index */
235   /* COMM */ ID3FID_COMMENT,           /**< Comments */
236   /* COMR */ ID3FID_COMMERCIAL,        /**< Commercial frame */
237   /* ENCR */ ID3FID_CRYPTOREG,         /**< Encryption method registration */
238   /* EQU2 */ ID3FID_EQUALIZATION2,     /**< Equalisation (2) */
239   /* EQUA */ ID3FID_EQUALIZATION,      /**< Equalization */
240   /* ETCO */ ID3FID_EVENTTIMING,       /**< Event timing codes */
241   /* GEOB */ ID3FID_GENERALOBJECT,     /**< General encapsulated object */
242   /* GRID */ ID3FID_GROUPINGREG,       /**< Group identification registration */
243   /* IPLS */ ID3FID_INVOLVEDPEOPLE,    /**< Involved people list */
244   /* LINK */ ID3FID_LINKEDINFO,        /**< Linked information */
245   /* MCDI */ ID3FID_CDID,              /**< Music CD identifier */
246   /* MLLT */ ID3FID_MPEGLOOKUP,        /**< MPEG location lookup table */
247   /* OWNE */ ID3FID_OWNERSHIP,         /**< Ownership frame */
248   /* PRIV */ ID3FID_PRIVATE,           /**< Private frame */
249   /* PCNT */ ID3FID_PLAYCOUNTER,       /**< Play counter */
250   /* POPM */ ID3FID_POPULARIMETER,     /**< Popularimeter */
251   /* POSS */ ID3FID_POSITIONSYNC,      /**< Position synchronisation frame */
252   /* RBUF */ ID3FID_BUFFERSIZE,        /**< Recommended buffer size */
253   /* RVA2 */ ID3FID_VOLUMEADJ2,        /**< Relative volume adjustment (2) */
254   /* RVAD */ ID3FID_VOLUMEADJ,         /**< Relative volume adjustment */
255   /* RVRB */ ID3FID_REVERB,            /**< Reverb */
256   /* SEEK */ ID3FID_SEEKFRAME,         /**< Seek frame */
257   /* SIGN */ ID3FID_SIGNATURE,         /**< Signature frame */
258   /* SYLT */ ID3FID_SYNCEDLYRICS,      /**< Synchronized lyric/text */
259   /* SYTC */ ID3FID_SYNCEDTEMPO,       /**< Synchronized tempo codes */
260   /* TALB */ ID3FID_ALBUM,             /**< Album/Movie/Show title */
261   /* TBPM */ ID3FID_BPM,               /**< BPM (beats per minute) */
262   /* TCOM */ ID3FID_COMPOSER,          /**< Composer */
263   /* TCON */ ID3FID_CONTENTTYPE,       /**< Content type */
264   /* TCOP */ ID3FID_COPYRIGHT,         /**< Copyright message */
265   /* TDAT */ ID3FID_DATE,              /**< Date */
266   /* TDEN */ ID3FID_ENCODINGTIME,      /**< Encoding time */
267   /* TDLY */ ID3FID_PLAYLISTDELAY,     /**< Playlist delay */
268   /* TDOR */ ID3FID_ORIGRELEASETIME,   /**< Original release time */
269   /* TDRC */ ID3FID_RECORDINGTIME,     /**< Recording time */
270   /* TDRL */ ID3FID_RELEASETIME,       /**< Release time */
271   /* TDTG */ ID3FID_TAGGINGTIME,       /**< Tagging time */
272   /* TIPL */ ID3FID_INVOLVEDPEOPLE2,   /**< Involved people list */
273   /* TENC */ ID3FID_ENCODEDBY,         /**< Encoded by */
274   /* TEXT */ ID3FID_LYRICIST,          /**< Lyricist/Text writer */
275   /* TFLT */ ID3FID_FILETYPE,          /**< File type */
276   /* TIME */ ID3FID_TIME,              /**< Time */
277   /* TIT1 */ ID3FID_CONTENTGROUP,      /**< Content group description */
278   /* TIT2 */ ID3FID_TITLE,             /**< Title/songname/content description */
279   /* TIT3 */ ID3FID_SUBTITLE,          /**< Subtitle/Description refinement */
280   /* TKEY */ ID3FID_INITIALKEY,        /**< Initial key */
281   /* TLAN */ ID3FID_LANGUAGE,          /**< Language(s) */
282   /* TLEN */ ID3FID_SONGLEN,           /**< Length */
283   /* TMCL */ ID3FID_MUSICIANCREDITLIST,/**< Musician credits list */
284   /* TMED */ ID3FID_MEDIATYPE,         /**< Media type */
285   /* TMOO */ ID3FID_MOOD,              /**< Mood */
286   /* TOAL */ ID3FID_ORIGALBUM,         /**< Original album/movie/show title */
287   /* TOFN */ ID3FID_ORIGFILENAME,      /**< Original filename */
288   /* TOLY */ ID3FID_ORIGLYRICIST,      /**< Original lyricist(s)/text writer(s) */
289   /* TOPE */ ID3FID_ORIGARTIST,        /**< Original artist(s)/performer(s) */
290   /* TORY */ ID3FID_ORIGYEAR,          /**< Original release year */
291   /* TOWN */ ID3FID_FILEOWNER,         /**< File owner/licensee */
292   /* TPE1 */ ID3FID_LEADARTIST,        /**< Lead performer(s)/Soloist(s) */
293   /* TPE2 */ ID3FID_BAND,              /**< Band/orchestra/accompaniment */
294   /* TPE3 */ ID3FID_CONDUCTOR,         /**< Conductor/performer refinement */
295   /* TPE4 */ ID3FID_MIXARTIST,         /**< Interpreted, remixed, or otherwise modified by */
296   /* TPOS */ ID3FID_PARTINSET,         /**< Part of a set */
297   /* TPRO */ ID3FID_PRODUCEDNOTICE,    /**< Produced notice */
298   /* TPUB */ ID3FID_PUBLISHER,         /**< Publisher */
299   /* TRCK */ ID3FID_TRACKNUM,          /**< Track number/Position in set */
300   /* TRDA */ ID3FID_RECORDINGDATES,    /**< Recording dates */
301   /* TRSN */ ID3FID_NETRADIOSTATION,   /**< Internet radio station name */
302   /* TRSO */ ID3FID_NETRADIOOWNER,     /**< Internet radio station owner */
303   /* TSIZ */ ID3FID_SIZE,              /**< Size */
304   /* TSOA */ ID3FID_ALBUMSORTORDER,    /**< Album sort order */
305   /* TSOP */ ID3FID_PERFORMERSORTORDER,/**< Performer sort order */
306   /* TSOT */ ID3FID_TITLESORTORDER,    /**< Title sort order */
307   /* TSRC */ ID3FID_ISRC,              /**< ISRC (international standard recording code) */
308   /* TSSE */ ID3FID_ENCODERSETTINGS,   /**< Software/Hardware and settings used for encoding */
309   /* TSST */ ID3FID_SETSUBTITLE,       /**< Set subtitle */
310   /* TXXX */ ID3FID_USERTEXT,          /**< User defined text information */
311   /* TYER */ ID3FID_YEAR,              /**< Year */
312   /* UFID */ ID3FID_UNIQUEFILEID,      /**< Unique file identifier */
313   /* USER */ ID3FID_TERMSOFUSE,        /**< Terms of use */
314   /* USLT */ ID3FID_UNSYNCEDLYRICS,    /**< Unsynchronized lyric/text transcription */
315   /* WCOM */ ID3FID_WWWCOMMERCIALINFO, /**< Commercial information */
316   /* WCOP */ ID3FID_WWWCOPYRIGHT,      /**< Copyright/Legal infromation */
317   /* WOAF */ ID3FID_WWWAUDIOFILE,      /**< Official audio file webpage */
318   /* WOAR */ ID3FID_WWWARTIST,         /**< Official artist/performer webpage */
319   /* WOAS */ ID3FID_WWWAUDIOSOURCE,    /**< Official audio source webpage */
320   /* WORS */ ID3FID_WWWRADIOPAGE,      /**< Official internet radio station homepage */
321   /* WPAY */ ID3FID_WWWPAYMENT,        /**< Payment */
322   /* WPUB */ ID3FID_WWWPUBLISHER,      /**< Official publisher webpage */
323   /* WXXX */ ID3FID_WWWUSER,           /**< User defined URL link */
324   /*      */ ID3FID_METACRYPTO,        /**< Encrypted meta frame (id3v2.2.x) */
325   /*      */ ID3FID_METACOMPRESSION,   /**< Compressed meta frame (id3v2.2.1) */
326   /* >>>> */ ID3FID_LASTFRAMEID        /**< Last field placeholder */
327 };
328 
ID3_ENUM(ID3_V1Lengths)329 ID3_ENUM(ID3_V1Lengths)
330 {
331   ID3_V1_LEN         = 128,
332   ID3_V1_LEN_ID      =   3,
333   ID3_V1_LEN_TITLE   =  30,
334   ID3_V1_LEN_ARTIST  =  30,
335   ID3_V1_LEN_ALBUM   =  30,
336   ID3_V1_LEN_YEAR    =   4,
337   ID3_V1_LEN_COMMENT =  30,
338   ID3_V1_LEN_GENRE   =   1
339 };
340 
ID3_ENUM(ID3_FieldFlags)341 ID3_ENUM(ID3_FieldFlags)
342 {
343   ID3FF_NONE       =      0,
344   ID3FF_CSTR       = 1 << 0,
345   ID3FF_LIST       = 1 << 1,
346   ID3FF_ENCODABLE  = 1 << 2,
347   ID3FF_TEXTLIST   = ID3FF_CSTR | ID3FF_LIST | ID3FF_ENCODABLE
348 };
349 
350 /** Enumeration of the types of field types */
ID3_ENUM(ID3_FieldType)351 ID3_ENUM(ID3_FieldType)
352 {
353   ID3FTY_NONE           = -1,
354   ID3FTY_INTEGER        = 0,
355   ID3FTY_BINARY,
356   ID3FTY_TEXTSTRING,
357   ID3FTY_NUMTYPES
358 };
359 
360 /**
361  ** Predefined id3lib error types.
362  **/
ID3_ENUM(ID3_Err)363 ID3_ENUM(ID3_Err)
364 {
365   ID3E_NoError = 0,             /**< No error reported */
366   ID3E_NoMemory,                /**< No available memory */
367   ID3E_NoData,                  /**< No data to parse */
368   ID3E_BadData,                 /**< Improperly formatted data */
369   ID3E_NoBuffer,                /**< No buffer to write to */
370   ID3E_SmallBuffer,             /**< Buffer is too small */
371   ID3E_InvalidFrameID,          /**< Invalid frame id */
372   ID3E_FieldNotFound,           /**< Requested field not found */
373   ID3E_UnknownFieldType,        /**< Unknown field type */
374   ID3E_TagAlreadyAttached,      /**< Tag is already attached to a file */
375   ID3E_InvalidTagVersion,       /**< Invalid tag version */
376   ID3E_NoFile,                  /**< No file to parse */
377   ID3E_ReadOnly,                /**< Attempting to write to a read-only file */
378   ID3E_zlibError                /**< Error in compression/uncompression */
379 };
380 
ID3_ENUM(ID3_ContentType)381 ID3_ENUM(ID3_ContentType)
382 {
383   ID3CT_OTHER = 0,
384   ID3CT_LYRICS,
385   ID3CT_TEXTTRANSCRIPTION,
386   ID3CT_MOVEMENT,
387   ID3CT_EVENTS,
388   ID3CT_CHORD,
389   ID3CT_TRIVIA
390 };
391 
ID3_ENUM(ID3_PictureType)392 ID3_ENUM(ID3_PictureType)
393 {
394   ID3PT_OTHER = 0,
395   ID3PT_PNG32ICON = 1,     //  32x32 pixels 'file icon' (PNG only)
396   ID3PT_OTHERICON = 2,     // Other file icon
397   ID3PT_COVERFRONT = 3,    // Cover (front)
398   ID3PT_COVERBACK = 4,     // Cover (back)
399   ID3PT_LEAFLETPAGE = 5,   // Leaflet page
400   ID3PT_MEDIA = 6,         // Media (e.g. lable side of CD)
401   ID3PT_LEADARTIST = 7,    // Lead artist/lead performer/soloist
402   ID3PT_ARTIST = 8,        // Artist/performer
403   ID3PT_CONDUCTOR = 9,     // Conductor
404   ID3PT_BAND = 10,         // Band/Orchestra
405   ID3PT_COMPOSER = 11,     // Composer
406   ID3PT_LYRICIST = 12,     // Lyricist/text writer
407   ID3PT_REC_LOCATION = 13, // Recording Location
408   ID3PT_RECORDING = 14,    // During recording
409   ID3PT_PERFORMANCE = 15,  // During performance
410   ID3PT_VIDEO = 16,        // Movie/video screen capture
411   ID3PT_FISH = 17,         // A bright coloured fish
412   ID3PT_ILLUSTRATION = 18, // Illustration
413   ID3PT_ARTISTLOGO = 19,   // Band/artist logotype
414   ID3PT_PUBLISHERLOGO = 20 // Publisher/Studio logotype
415 };
416 
ID3_ENUM(ID3_TimeStampFormat)417 ID3_ENUM(ID3_TimeStampFormat)
418 {
419   ID3TSF_FRAME  = 1,
420   ID3TSF_MS
421 };
422 
ID3_ENUM(MP3_BitRates)423 ID3_ENUM(MP3_BitRates)
424 {
425   MP3BITRATE_FALSE = -1,
426   MP3BITRATE_NONE = 0,
427   MP3BITRATE_8K   = 8000,
428   MP3BITRATE_16K  = 16000,
429   MP3BITRATE_24K  = 24000,
430   MP3BITRATE_32K  = 32000,
431   MP3BITRATE_40K  = 40000,
432   MP3BITRATE_48K  = 48000,
433   MP3BITRATE_56K  = 56000,
434   MP3BITRATE_64K  = 64000,
435   MP3BITRATE_80K  = 80000,
436   MP3BITRATE_96K  = 96000,
437   MP3BITRATE_112K = 112000,
438   MP3BITRATE_128K = 128000,
439   MP3BITRATE_144K = 144000,
440   MP3BITRATE_160K = 160000,
441   MP3BITRATE_176K = 176000,
442   MP3BITRATE_192K = 192000,
443   MP3BITRATE_224K = 224000,
444   MP3BITRATE_256K = 256000,
445   MP3BITRATE_288K = 288000,
446   MP3BITRATE_320K = 320000,
447   MP3BITRATE_352K = 352000,
448   MP3BITRATE_384K = 384000,
449   MP3BITRATE_416K = 416000,
450   MP3BITRATE_448K = 448000
451 };
452 
ID3_ENUM(Mpeg_Layers)453 ID3_ENUM(Mpeg_Layers)
454 {
455   MPEGLAYER_FALSE = -1,
456   MPEGLAYER_UNDEFINED,
457   MPEGLAYER_III,
458   MPEGLAYER_II,
459   MPEGLAYER_I
460 };
461 
ID3_ENUM(Mpeg_Version)462 ID3_ENUM(Mpeg_Version)
463 {
464   MPEGVERSION_FALSE = -1,
465   MPEGVERSION_2_5,
466   MPEGVERSION_Reserved,
467   MPEGVERSION_2,
468   MPEGVERSION_1
469 };
470 
ID3_ENUM(Mp3_Frequencies)471 ID3_ENUM(Mp3_Frequencies)
472 {
473   MP3FREQUENCIES_FALSE = -1,
474   MP3FREQUENCIES_Reserved = 0,
475   MP3FREQUENCIES_8000HZ = 8000,
476   MP3FREQUENCIES_11025HZ = 11025,
477   MP3FREQUENCIES_12000HZ = 12000,
478   MP3FREQUENCIES_16000HZ = 16000,
479   MP3FREQUENCIES_22050HZ = 22050,
480   MP3FREQUENCIES_24000HZ = 24000,
481   MP3FREQUENCIES_32000HZ = 32000,
482   MP3FREQUENCIES_48000HZ = 48000,
483   MP3FREQUENCIES_44100HZ = 44100
484 };
485 
ID3_ENUM(Mp3_ChannelMode)486 ID3_ENUM(Mp3_ChannelMode)
487 {
488   MP3CHANNELMODE_FALSE = -1,
489   MP3CHANNELMODE_STEREO,
490   MP3CHANNELMODE_JOINT_STEREO,
491   MP3CHANNELMODE_DUAL_CHANNEL,
492   MP3CHANNELMODE_SINGLE_CHANNEL
493 };
494 
ID3_ENUM(Mp3_ModeExt)495 ID3_ENUM(Mp3_ModeExt)
496 {
497   MP3MODEEXT_FALSE = -1,
498   MP3MODEEXT_0,
499   MP3MODEEXT_1,
500   MP3MODEEXT_2,
501   MP3MODEEXT_3
502 };
503 
ID3_ENUM(Mp3_Emphasis)504 ID3_ENUM(Mp3_Emphasis)
505 {
506   MP3EMPHASIS_FALSE = -1,
507   MP3EMPHASIS_NONE,
508   MP3EMPHASIS_50_15MS,
509   MP3EMPHASIS_Reserved,
510   MP3EMPHASIS_CCIT_J17
511 };
512 
ID3_ENUM(Mp3_Crc)513 ID3_ENUM(Mp3_Crc)
514 {
515   MP3CRC_ERROR_SIZE = -2,
516   MP3CRC_MISMATCH = -1,
517   MP3CRC_NONE = 0,
518   MP3CRC_OK = 1
519 };
520 
ID3_STRUCT(Mp3_Headerinfo)521 ID3_STRUCT(Mp3_Headerinfo)
522 {
523   Mpeg_Layers layer;
524   Mpeg_Version version;
525   MP3_BitRates bitrate;
526   Mp3_ChannelMode channelmode;
527   Mp3_ModeExt modeext;
528   Mp3_Emphasis emphasis;
529   Mp3_Crc crc;
530   uint32 vbr_bitrate;           // avg bitrate from xing header
531   uint32 frequency;             // samplerate
532   uint32 framesize;
533   uint32 frames;                // nr of frames
534   uint32 time;                  // nr of seconds in song
535   bool privatebit;
536   bool copyrighted;
537   bool original;
538 };
539 
540 #define ID3_NR_OF_V1_GENRES 148
541 
542 static const char *ID3_v1_genre_description[ID3_NR_OF_V1_GENRES] =
543 {
544   "Blues",             //0
545   "Classic Rock",      //1
546   "Country",           //2
547   "Dance",             //3
548   "Disco",             //4
549   "Funk",              //5
550   "Grunge",            //6
551   "Hip-Hop",           //7
552   "Jazz",              //8
553   "Metal",             //9
554   "New Age",           //10
555   "Oldies",            //11
556   "Other",             //12
557   "Pop",               //13
558   "R&B",               //14
559   "Rap",               //15
560   "Reggae",            //16
561   "Rock",              //17
562   "Techno",            //18
563   "Industrial",        //19
564   "Alternative",       //20
565   "Ska",               //21
566   "Death Metal",       //22
567   "Pranks",            //23
568   "Soundtrack",        //24
569   "Euro-Techno",       //25
570   "Ambient",           //26
571   "Trip-Hop",          //27
572   "Vocal",             //28
573   "Jazz+Funk",         //29
574   "Fusion",            //30
575   "Trance",            //31
576   "Classical",         //32
577   "Instrumental",      //33
578   "Acid",              //34
579   "House",             //35
580   "Game",              //36
581   "Sound Clip",        //37
582   "Gospel",            //38
583   "Noise",             //39
584   "AlternRock",        //40
585   "Bass",              //41
586   "Soul",              //42
587   "Punk",              //43
588   "Space",             //44
589   "Meditative",        //45
590   "Instrumental Pop",  //46
591   "Instrumental Rock", //47
592   "Ethnic",            //48
593   "Gothic",            //49
594   "Darkwave",          //50
595   "Techno-Industrial", //51
596   "Electronic",        //52
597   "Pop-Folk",          //53
598   "Eurodance",         //54
599   "Dream",             //55
600   "Southern Rock",     //56
601   "Comedy",            //57
602   "Cult",              //58
603   "Gangsta",           //59
604   "Top 40",            //60
605   "Christian Rap",     //61
606   "Pop/Funk",          //62
607   "Jungle",            //63
608   "Native American",   //64
609   "Cabaret",           //65
610   "New Wave",          //66
611   "Psychadelic",       //67
612   "Rave",              //68
613   "Showtunes",         //69
614   "Trailer",           //70
615   "Lo-Fi",             //71
616   "Tribal",            //72
617   "Acid Punk",         //73
618   "Acid Jazz",         //74
619   "Polka",             //75
620   "Retro",             //76
621   "Musical",           //77
622   "Rock & Roll",       //78
623   "Hard Rock",         //79
624 // following are winamp extentions
625   "Folk",                  //80
626   "Folk-Rock",             //81
627   "National Folk",         //82
628   "Swing",                 //83
629   "Fast Fusion",           //84
630   "Bebob",                 //85
631   "Latin",                 //86
632   "Revival",               //87
633   "Celtic",                //88
634   "Bluegrass",             //89
635   "Avantgarde",            //90
636   "Gothic Rock",           //91
637   "Progressive Rock",      //92
638   "Psychedelic Rock",      //93
639   "Symphonic Rock",        //94
640   "Slow Rock",             //95
641   "Big Band",              //96
642   "Chorus",                //97
643   "Easy Listening",        //98
644   "Acoustic",              //99
645   "Humour",                //100
646   "Speech",                //101
647   "Chanson",               //102
648   "Opera",                 //103
649   "Chamber Music",         //104
650   "Sonata",                //105
651   "Symphony",              //106
652   "Booty Bass",            //107
653   "Primus",                //108
654   "Porn Groove",           //109
655   "Satire",                //110
656   "Slow Jam",              //111
657   "Club",                  //112
658   "Tango",                 //113
659   "Samba",                 //114
660   "Folklore",              //115
661   "Ballad",                //116
662   "Power Ballad",          //117
663   "Rhythmic Soul",         //118
664   "Freestyle",             //119
665   "Duet",                  //120
666   "Punk Rock",             //121
667   "Drum Solo",             //122
668   "A capella",             //123
669   "Euro-House",            //124
670   "Dance Hall",            //125
671   "Goa",                   //126
672   "Drum & Bass",           //127
673   "Club-House",            //128
674   "Hardcore",              //129
675   "Terror",                //130
676   "Indie",                 //131
677   "Britpop",               //132
678   "Negerpunk",             //133
679   "Polsk Punk",            //134
680   "Beat",                  //135
681   "Christian Gangsta Rap", //136
682   "Heavy Metal",           //137
683   "Black Metal",           //138
684   "Crossover",             //139
685   "Contemporary Christian",//140
686   "Christian Rock ",       //141
687   "Merengue",              //142
688   "Salsa",                 //143
689   "Trash Metal",           //144
690   "Anime",                 //145
691   "JPop",                  //146
692   "Synthpop"               //147
693 };
694 
695 #define ID3_V1GENRE2DESCRIPTION(x) (x < ID3_NR_OF_V1_GENRES && x >= 0) ? ID3_v1_genre_description[x] : NULL
696 
697 #define MASK(bits) ((1 << (bits)) - 1)
698 #define MASK1 MASK(1)
699 #define MASK2 MASK(2)
700 #define MASK3 MASK(3)
701 #define MASK4 MASK(4)
702 #define MASK5 MASK(5)
703 #define MASK6 MASK(6)
704 #define MASK7 MASK(7)
705 #define MASK8 MASK(8)
706 
707 /*
708  * The following is borrowed from glib.h (http://www.gtk.org)
709  */
710 #ifdef WIN32
711 
712 /* On native Win32, directory separator is the backslash, and search path
713  * separator is the semicolon.
714  */
715 #  define ID3_DIR_SEPARATOR '\\'
716 #  define ID3_DIR_SEPARATOR_S "\\"
717 #  define ID3_SEARCHPATH_SEPARATOR ';'
718 #  define ID3_SEARCHPATH_SEPARATOR_S ";"
719 
720 #else  /* !WIN32 */
721 
722 #  ifndef _EMX_
723 /* Unix */
724 
725 #    define ID3_DIR_SEPARATOR '/'
726 #    define ID3_DIR_SEPARATOR_S "/"
727 #    define ID3_SEARCHPATH_SEPARATOR ':'
728 #    define ID3_SEARCHPATH_SEPARATOR_S ":"
729 
730 #  else
731 /* EMX/OS2 */
732 
733 #    define ID3_DIR_SEPARATOR '/'
734 #    define ID3_DIR_SEPARATOR_S "/"
735 #    define ID3_SEARCHPATH_SEPARATOR ';'
736 #    define ID3_SEARCHPATH_SEPARATOR_S ";"
737 
738 #  endif
739 
740 #endif /* !WIN32 */
741 
742 #ifndef NULL
743 #  define NULL ((void*) 0)
744 #endif
745 
746 #endif /* _ID3LIB_GLOBALS_H_ */
747 
748