10#include <sp/spChunk.h>
16#define spID3FrameSize spChunkSize
18#define SP_ID3_CHUNK_INFO_OPTION_TEXT_MASK (1<<(SP_CHUNK_INFO_OPTION_USER_MASK_OFFSET))
19#define SP_ID3_CHUNK_INFO_OPTION_DESC_MASK (1<<(SP_CHUNK_INFO_OPTION_USER_MASK_OFFSET+1))
20#define SP_ID3_CHUNK_INFO_OPTION_LANG_MASK (1<<(SP_CHUNK_INFO_OPTION_USER_MASK_OFFSET+2))
21#define SP_ID3_CHUNK_INFO_OPTION_DESC_TEXT_MASK (SP_ID3_CHUNK_INFO_OPTION_DESC_MASK|SP_ID3_CHUNK_INFO_OPTION_TEXT_MASK)
22#define SP_ID3_CHUNK_INFO_OPTION_LANG_TEXT_MASK (SP_ID3_CHUNK_INFO_OPTION_LANG_MASK|SP_ID3_CHUNK_INFO_OPTION_DESC_TEXT_MASK)
24#define SP_ID3_FRAME_TYPE_ALBUM_V2_2 "TAL"
25#define SP_ID3_FRAME_TYPE_ALBUM_V2_3 "TALB"
26#define SP_ID3_FRAME_TYPE_ALBUM SP_ID3_FRAME_TYPE_ALBUM_V2_3
27#define SP_ID3_FRAME_TYPE_COMPOSER_V2_2 "TCM"
28#define SP_ID3_FRAME_TYPE_COMPOSER_V2_3 "TCOM"
29#define SP_ID3_FRAME_TYPE_COMPOSER SP_ID3_FRAME_TYPE_COMPOSER_V2_3
30#define SP_ID3_FRAME_TYPE_LYRICIST_V2_2 "TXT"
31#define SP_ID3_FRAME_TYPE_LYRICIST_V2_3 "TEXT"
32#define SP_ID3_FRAME_TYPE_LYRICIST SP_ID3_FRAME_TYPE_LYRICIST_V2_3
33#define SP_ID3_FRAME_TYPE_COPYRIGHT_V2_2 "TCR"
34#define SP_ID3_FRAME_TYPE_COPYRIGHT_V2_3 "TCOP"
35#define SP_ID3_FRAME_TYPE_COPYRIGHT SP_ID3_FRAME_TYPE_COPYRIGHT_V2_3
36#define SP_ID3_FRAME_TYPE_TRACK_V2_2 "TRK"
37#define SP_ID3_FRAME_TYPE_TRACK_V2_3 "TRCK"
38#define SP_ID3_FRAME_TYPE_TRACK SP_ID3_FRAME_TYPE_TRACK_V2_3
39#define SP_ID3_FRAME_TYPE_DISC_V2_2 "TPA"
40#define SP_ID3_FRAME_TYPE_DISC_V2_3 "TPOS"
41#define SP_ID3_FRAME_TYPE_DISC SP_ID3_FRAME_TYPE_DISC_V2_3
42#define SP_ID3_FRAME_TYPE_TITLE_V2_2 "TT2"
43#define SP_ID3_FRAME_TYPE_TITLE_V2_3 "TIT2"
44#define SP_ID3_FRAME_TYPE_TITLE SP_ID3_FRAME_TYPE_TITLE_V2_3
45#define SP_ID3_FRAME_TYPE_ARTIST_V2_2 "TP1"
46#define SP_ID3_FRAME_TYPE_ARTIST_V2_3 "TPE1"
47#define SP_ID3_FRAME_TYPE_ARTIST SP_ID3_FRAME_TYPE_ARTIST_V2_3
48#define SP_ID3_FRAME_TYPE_ALBUM_ARTIST_V2_2 "TP2"
49#define SP_ID3_FRAME_TYPE_ALBUM_ARTIST_V2_3 "TPE2"
50#define SP_ID3_FRAME_TYPE_ALBUM_ARTIST SP_ID3_FRAME_TYPE_ALBUM_ARTIST_V2_3
51#define SP_ID3_FRAME_TYPE_GENRE_V2_2 "TCO"
52#define SP_ID3_FRAME_TYPE_GENRE_V2_3 "TCON"
53#define SP_ID3_FRAME_TYPE_GENRE SP_ID3_FRAME_TYPE_GENRE_V2_3
54#define SP_ID3_FRAME_TYPE_SOFTWARE_V2_2 "TEN"
55#define SP_ID3_FRAME_TYPE_SOFTWARE_V2_3 "TENC"
56#define SP_ID3_FRAME_TYPE_SOFTWARE SP_ID3_FRAME_TYPE_SOFTWARE_V2_3
57#define SP_ID3_FRAME_TYPE_TEMPO_V2_2 "TBP"
58#define SP_ID3_FRAME_TYPE_TEMPO_V2_3 "TBPM"
59#define SP_ID3_FRAME_TYPE_TEMPO SP_ID3_FRAME_TYPE_TEMPO_V2_3
60#define SP_ID3_FRAME_TYPE_COMMENT_V2_2 "COM"
61#define SP_ID3_FRAME_TYPE_COMMENT_V2_3 "COMM"
62#define SP_ID3_FRAME_TYPE_COMMENT SP_ID3_FRAME_TYPE_COMMENT_V2_3
63#define SP_ID3_FRAME_TYPE_PUBLISHER_V2_2 "TPB"
64#define SP_ID3_FRAME_TYPE_PUBLISHER_V2_3 "TPUB"
65#define SP_ID3_FRAME_TYPE_PUBLISHER SP_ID3_FRAME_TYPE_PUBLISHER_V2_3
67#define SP_ID3_FRAME_TYPE_RELEASE_V2_2 "TYE"
68#define SP_ID3_FRAME_TYPE_RELEASE_V2_3 "TYER"
69#define SP_ID3_FRAME_TYPE_RELEASE_V2_4 "TDRC"
70#define SP_ID3_FRAME_TYPE_RELEASE SP_ID3_FRAME_TYPE_RELEASE_V2_4
72#define SP_ID3_FRAME_TYPE_ISRC_V2_3 "TSRC"
73#define SP_ID3_FRAME_TYPE_ISRC SP_ID3_FRAME_TYPE_ISRC_V2_3
75#define SP_ID3_HEADER_FLAG_UNSYNCHRONISATION_MASK 0x80
76#define SP_ID3_HEADER_FLAG_V2_2_COMPRESSION_MASK 0x40
77#define SP_ID3_HEADER_FLAG_EXTENDED_MASK 0x40
78#define SP_ID3_HEADER_FLAG_EXPERIMENTAL_MASK 0x20
79#define SP_ID3_HEADER_FLAG_V2_4_FOOTERL_MASK 0x10
81#define SP_ID3_HEADER_EXTRA_FLAG_V2_3_CRC_MASK 0x8000
83#define SP_ID3_HEADER_EXTRA_FLAG_V2_4_TAG_UPDATE_MASK 0x40
84#define SP_ID3_HEADER_EXTRA_FLAG_V2_4_CRC_MASK 0x20
85#define SP_ID3_HEADER_EXTRA_FLAG_V2_4_TAG_RESTRICTIONS_MASK 0x10
87#define SP_ID3_HEADER_EXTRA_TAG_RESTRICTIONS_SIZE_1MB 0x0
88#define SP_ID3_HEADER_EXTRA_TAG_RESTRICTIONS_SIZE_128KB 0x40
89#define SP_ID3_HEADER_EXTRA_TAG_RESTRICTIONS_SIZE_40KB 0x80
90#define SP_ID3_HEADER_EXTRA_TAG_RESTRICTIONS_SIZE_4KB 0xc0
92#define SP_ID3_HEADER_EXTRA_TAG_RESTRICTIONS_TEXT_ENCODING_NONE 0x0
93#define SP_ID3_HEADER_EXTRA_TAG_RESTRICTIONS_TEXT_ENCODING_ISO8859_1_OR_UTF8 0x20
95#define SP_ID3_HEADER_EXTRA_TAG_RESTRICTIONS_TEXT_SIZE_NONE 0x0
96#define SP_ID3_HEADER_EXTRA_TAG_RESTRICTIONS_TEXT_SIZE_1024 0x8
97#define SP_ID3_HEADER_EXTRA_TAG_RESTRICTIONS_TEXT_SIZE_128 0x10
98#define SP_ID3_HEADER_EXTRA_TAG_RESTRICTIONS_TEXT_SIZE_30 0x18
100#define SP_ID3_HEADER_EXTRA_TAG_RESTRICTIONS_IMAGE_ENCODING_NONE 0x0
101#define SP_ID3_HEADER_EXTRA_TAG_RESTRICTIONS_IMAGE_ENCODING_PNG_OR_JPEG 0x4
103#define SP_ID3_HEADER_EXTRA_TAG_RESTRICTIONS_IMAGE_SIZE_NONE 0x0
104#define SP_ID3_HEADER_EXTRA_TAG_RESTRICTIONS_IMAGE_SIZE_UP_TO_256x256 0x1
105#define SP_ID3_HEADER_EXTRA_TAG_RESTRICTIONS_IMAGE_SIZE_UP_TO_64x64 0x2
106#define SP_ID3_HEADER_EXTRA_TAG_RESTRICTIONS_IMAGE_SIZE_EXACTLY_64x64 0x3
108#define SP_ID3_FRAME_HEADER_FLAG1_V2_3_TAG_ALTER_MASK 0x80
109#define SP_ID3_FRAME_HEADER_FLAG1_V2_3_FILE_ALTER_MASK 0x40
110#define SP_ID3_FRAME_HEADER_FLAG1_V2_3_READ_ONLY_MASK 0x20
112#define SP_ID3_FRAME_HEADER_FLAG2_V2_3_COMPRESSION_MASK 0x80
113#define SP_ID3_FRAME_HEADER_FLAG2_V2_3_ENCRIPTION_MASK 0x40
114#define SP_ID3_FRAME_HEADER_FLAG2_V2_3_GROUPING_MASK 0x20
116#define SP_ID3_FRAME_HEADER_FLAG1_V2_4_TAG_ALTER_MASK 0x40
117#define SP_ID3_FRAME_HEADER_FLAG1_V2_4_FILE_ALTER_MASK 0x20
118#define SP_ID3_FRAME_HEADER_FLAG1_V2_4_READ_ONLY_MASK 0x10
120#define SP_ID3_FRAME_HEADER_FLAG2_V2_4_GROUPING_MASK 0x40
121#define SP_ID3_FRAME_HEADER_FLAG2_V2_4_COMPRESSION_MASK 0x8
122#define SP_ID3_FRAME_HEADER_FLAG2_V2_4_ENCRIPTION_MASK 0x4
123#define SP_ID3_FRAME_HEADER_FLAG2_V2_4_UNSYNCHRONISATION_MASK 0x2
124#define SP_ID3_FRAME_HEADER_FLAG2_V2_4_DATA_LENGTH_MASK 0x1
126typedef struct _spID3HeaderExtra_V2_3 {
129 unsigned long padding_size;
131} spID3HeaderExtra_V2_3;
133typedef struct _spID3HeaderExtra_V2_4 {
135 unsigned char flag_length;
138 unsigned char restrictions;
139} spID3HeaderExtra_V2_4;
141typedef struct _spID3FrameHeaderExtra_V2_3 {
142 unsigned long decompressed_size;
143 unsigned char encryption_method;
144 unsigned char group_id;
145} spID3FrameHeaderExtra_V2_3;
147typedef struct _spID3FrameHeaderExtra_V2_4 {
148 unsigned char group_id;
149 unsigned char encryption_method;
150 unsigned long data_length_indicator;
151} spID3FrameHeaderExtra_V2_4;
153typedef struct _spID3FrameHeader {
161 spID3FrameHeaderExtra_V2_3 v2_3;
162 spID3FrameHeaderExtra_V2_4 v2_4;
166typedef struct _spID3Frame {
167 struct _spID3Frame *parent;
168 struct _spID3Frame *child;
170 struct _spID3Frame *prev;
171 struct _spID3Frame *next;
175 spID3FrameHeader header;
180typedef struct _spID3Header {
181 struct _spID3Frame *parent;
182 struct _spID3Frame *child;
184 struct _spID3Frame *prev;
185 struct _spID3Frame *next;
189 spID3FrameHeader header;
193 unsigned char version;
194 unsigned char revision;
197 spID3HeaderExtra_V2_3 v2_3;
198 spID3HeaderExtra_V2_4 v2_4;
202typedef struct _spID3DataFrame {
203 struct _spID3Frame *parent;
204 struct _spID3Frame *child;
206 struct _spID3Frame *prev;
207 struct _spID3Frame *next;
211 spID3FrameHeader header;
218typedef struct _spID3TextFrame {
219 struct _spID3Frame *parent;
220 struct _spID3Frame *child;
222 struct _spID3Frame *prev;
223 struct _spID3Frame *next;
227 spID3FrameHeader header;
231 unsigned char encoding;
235 unsigned char *string;
238typedef struct _spID3DescTextFrame {
239 struct _spID3Frame *parent;
240 struct _spID3Frame *child;
242 struct _spID3Frame *prev;
243 struct _spID3Frame *next;
247 spID3FrameHeader header;
251 unsigned char encoding;
255 unsigned char *string;
256 unsigned char *actual_string;
259typedef struct _spID3LangTextFrame {
260 struct _spID3Frame *parent;
261 struct _spID3Frame *child;
263 struct _spID3Frame *prev;
264 struct _spID3Frame *next;
268 spID3FrameHeader header;
272 unsigned char encoding;
276 unsigned char *string;
277 unsigned char *actual_string;
279 unsigned char lang[3];
282typedef struct _spID3MimeDataFrame {
283 struct _spID3Frame *parent;
284 struct _spID3Frame *child;
286 struct _spID3Frame *prev;
287 struct _spID3Frame *next;
291 spID3FrameHeader header;
295 unsigned char encoding;
296 unsigned char format[3];
298 unsigned char *mime_type;
300 unsigned char *filename;
301 unsigned char data_type;
302 long description_len;
303 unsigned char *description;
310 SP_ID3V1_GENRE_EXTENSION_UNKNOWN = -1,
311 SP_ID3V1_GENRE_NONEXTENSION = 0,
312 SP_ID3V1_GENRE_EXTENSION_WINAMP_CORE = 88,
313 SP_ID3V1_GENRE_EXTENSION_WINAMP_1998 = 142,
314 SP_ID3V1_GENRE_EXTENSION_WINAMP_2010 = 148,
315 SP_ID3V1_GENRE_EXTENSION_END = 191,
316} spID3v1GenreExtension;
318typedef spID3FrameSize (*spID3FrameUpdateFunc)(spID3Frame *frame,
void *data);
320extern spBool spInitID3Header(spID3Header *header,
unsigned char version,
unsigned char revision);
321extern void spPropagateID3FrameContentSize(spID3Frame *parent, spChunkSize size_diff);
322extern spBool spSetID3FrameContentSize(spID3Frame *frame, spID3FrameSize size,
spBool propagate_size);
323extern spID3Frame *spCreateID3FrameWithCB(spID3Header *header,
const char *type, spID3FrameUpdateFunc update_func,
void *data);
324extern spID3Frame *spCreateID3Frame(spID3Header *header,
const char *type);
326extern spID3FrameSize spGetID3FrameContentSize(spID3Frame *frame);
327extern spID3FrameSize spGetID3FrameSize(spID3Frame *frame,
char *
string );
328extern spID3FrameSize spGetID3HeaderSize(spID3Header *header);
329extern spID3FrameSize spReadID3Header(spID3Header *header, FILE *fp);
330extern spID3FrameSize spWriteID3Header(spID3Header *header, FILE *fp);
331extern spBool spFreeID3Header(spID3Header *header);
332extern spID3FrameSize spCopyID3Header(spID3Header *dest_header, spID3Header *src_header);
334extern spID3Frame *spFindID3FrameFromHeader(spID3Header *header,
const char *type);
335extern spID3Frame *spFindID3Frame(spID3Frame *frame,
const char *type);
337extern const unsigned char *spGetID3TextFrameString(spID3TextFrame *tframe,
unsigned char *encoding);
338extern spBool spGetID3TextFrameStringToLocaleCode(spID3TextFrame *tframe,
unsigned char *str_in_locale,
long size);
339extern spBool spGetID3TextFrameTrackNumber(spID3TextFrame *tframe, spLong32 *track, spLong32 *total);
340extern spBool spGetID3TextFrameNumber(spID3TextFrame *tframe, spLong32 *number);
342extern const unsigned char *spFindID3TextFrameString(spID3Header *header,
const char *type,
unsigned char *encoding);
343extern spBool spFindID3TextFrameStringToLocaleCode(spID3Header *header,
const char *type,
unsigned char *str_in_locale,
long size);
344extern spBool spFindID3TextFrameTrackNumber(spID3Header *header, spLong32 *track, spLong32 *total);
345extern spBool spFindID3TextFrameDiscNumber(spID3Header *header, spLong32 *disc, spLong32 *total);
346extern spBool spFindID3TextFrameTempo(spID3Header *header, spLong32 *tempo);
348extern spBool spSetID3TextFrameString(spID3TextFrame *tframe,
unsigned char encoding,
const unsigned char *str,
long len);
349extern spBool spSetID3TextFrameStringFromLocaleCode(spID3TextFrame *tframe,
unsigned char encoding,
const unsigned char *str_in_locale);
350extern spID3TextFrame *spAppendID3TextFrameStringFromLocaleCode(spID3Header *header,
const char *type,
spBool find_existing_frame,
unsigned char encoding,
const unsigned char *str_in_locale);
351extern spID3TextFrame *spAppendID3TextFrameString(spID3Header *header,
const char *type,
spBool find_existing_frame,
352 unsigned char encoding,
const unsigned char *str,
long len);
353extern spID3TextFrame *spAppendID3TextFrameTrackNumber(spID3Header *header, spLong32 number, spLong32 total);
354extern spID3TextFrame *spAppendID3TextFrameDiscNumber(spID3Header *header, spLong32 number, spLong32 total);
355extern spID3TextFrame *spAppendID3TextFrameTempo(spID3Header *header, spLong32 tempo);
360extern spBool spIsStringInsideID3AsciiRange(
const unsigned char *str);
361extern spBool spIsStringInsideID3Laten1Range(
const unsigned char *str);
363extern void spShowID3HeaderInfo(spID3Header *header);
365extern const char *spGetID3v1GenreString(
int index, spID3v1GenreExtension *extension_type);
366extern int spFindID3v1GenreIndex(
const char *
string, spID3v1GenreExtension extension_limit);
369typedef struct spID3Converter *spID3Converter;
371#define SP_ID3_CONVERTER_OPTION_NONE 0L
372#define SP_ID3_CONVERTER_OPTION_NO_CODESET_CONVERTER 1L
374extern spID3Converter spID3ConverterOpen(
const char *system_codeset,
unsigned long options);
375extern void spID3ConverterClose(spID3Converter id3conv);
376extern spBool spID3ConverterFindTextFrameString(spID3Converter id3conv, spID3Header *header,
const char *type,
377 unsigned char *str_in_codeset,
long size);
378extern spID3TextFrame *spID3ConverterAppendTextFrameString(spID3Converter id3conv, spID3Header *header,
const char *type,
379 spBool find_existing_frame,
unsigned char encoding,
const unsigned char *str_in_lang);
380extern spBool spID3ConverterParseSongInfo(spID3Converter id3conv, spID3Header *header,
spSongInfoV2 *song_info);
381extern spBool spID3ConverterAppendSongInfo(spID3Converter id3conv, spID3Header *header,
spSongInfoV2 *song_info);
382extern void spID3ConverterShowID3HeaderInfo(spID3Converter id3conv, spID3Header *header);
383extern spBool spID3ConverterConvertUTF8StringTo(spID3Converter id3conv,
unsigned char *iobuf,
long buf_size);
384extern spBool spID3ConverterConvertToUTF8String(spID3Converter id3conv,
unsigned char *iobuf,
long buf_size);