cannam@87
|
1 /*
|
cannam@87
|
2 * libid3tag - ID3 tag manipulation library
|
cannam@87
|
3 * Copyright (C) 2000-2004 Underbit Technologies, Inc.
|
cannam@87
|
4 *
|
cannam@87
|
5 * This program is free software; you can redistribute it and/or modify
|
cannam@87
|
6 * it under the terms of the GNU General Public License as published by
|
cannam@87
|
7 * the Free Software Foundation; either version 2 of the License, or
|
cannam@87
|
8 * (at your option) any later version.
|
cannam@87
|
9 *
|
cannam@87
|
10 * This program is distributed in the hope that it will be useful,
|
cannam@87
|
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
cannam@87
|
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
cannam@87
|
13 * GNU General Public License for more details.
|
cannam@87
|
14 *
|
cannam@87
|
15 * You should have received a copy of the GNU General Public License
|
cannam@87
|
16 * along with this program; if not, write to the Free Software
|
cannam@87
|
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
cannam@87
|
18 *
|
cannam@87
|
19 * If you would like to negotiate alternate licensing terms, you may do
|
cannam@87
|
20 * so by contacting: Underbit Technologies, Inc. <info@underbit.com>
|
cannam@87
|
21 *
|
cannam@87
|
22 * $Id: id3tag.h,v 1.17 2004/01/23 23:22:46 rob Exp $
|
cannam@87
|
23 */
|
cannam@87
|
24
|
cannam@87
|
25 # ifndef LIBID3TAG_ID3TAG_H
|
cannam@87
|
26 # define LIBID3TAG_ID3TAG_H
|
cannam@87
|
27
|
cannam@87
|
28 # ifdef __cplusplus
|
cannam@87
|
29 extern "C" {
|
cannam@87
|
30 # endif
|
cannam@87
|
31
|
cannam@87
|
32 # define ID3_TAG_VERSION 0x0400
|
cannam@87
|
33 # define ID3_TAG_VERSION_MAJOR(x) (((x) >> 8) & 0xff)
|
cannam@87
|
34 # define ID3_TAG_VERSION_MINOR(x) (((x) >> 0) & 0xff)
|
cannam@87
|
35
|
cannam@87
|
36 typedef unsigned char id3_byte_t;
|
cannam@87
|
37 typedef unsigned long id3_length_t;
|
cannam@87
|
38
|
cannam@87
|
39 typedef unsigned long id3_ucs4_t;
|
cannam@87
|
40
|
cannam@87
|
41 typedef unsigned char id3_latin1_t;
|
cannam@87
|
42 typedef unsigned short id3_utf16_t;
|
cannam@87
|
43 typedef signed char id3_utf8_t;
|
cannam@87
|
44
|
cannam@87
|
45 struct id3_tag {
|
cannam@87
|
46 unsigned int refcount;
|
cannam@87
|
47 unsigned int version;
|
cannam@87
|
48 int flags;
|
cannam@87
|
49 int extendedflags;
|
cannam@87
|
50 int restrictions;
|
cannam@87
|
51 int options;
|
cannam@87
|
52 unsigned int nframes;
|
cannam@87
|
53 struct id3_frame **frames;
|
cannam@87
|
54 id3_length_t paddedsize;
|
cannam@87
|
55 };
|
cannam@87
|
56
|
cannam@87
|
57 # define ID3_TAG_QUERYSIZE 10
|
cannam@87
|
58
|
cannam@87
|
59 /* ID3v1 field frames */
|
cannam@87
|
60
|
cannam@87
|
61 # define ID3_FRAME_TITLE "TIT2"
|
cannam@87
|
62 # define ID3_FRAME_ARTIST "TPE1"
|
cannam@87
|
63 # define ID3_FRAME_ALBUM "TALB"
|
cannam@87
|
64 # define ID3_FRAME_TRACK "TRCK"
|
cannam@87
|
65 # define ID3_FRAME_YEAR "TDRC"
|
cannam@87
|
66 # define ID3_FRAME_GENRE "TCON"
|
cannam@87
|
67 # define ID3_FRAME_COMMENT "COMM"
|
cannam@87
|
68
|
cannam@87
|
69 /* special frames */
|
cannam@87
|
70
|
cannam@87
|
71 # define ID3_FRAME_OBSOLETE "ZOBS" /* with apologies to the French */
|
cannam@87
|
72
|
cannam@87
|
73 /* tag flags */
|
cannam@87
|
74
|
cannam@87
|
75 enum {
|
cannam@87
|
76 ID3_TAG_FLAG_UNSYNCHRONISATION = 0x80,
|
cannam@87
|
77 ID3_TAG_FLAG_EXTENDEDHEADER = 0x40,
|
cannam@87
|
78 ID3_TAG_FLAG_EXPERIMENTALINDICATOR = 0x20,
|
cannam@87
|
79 ID3_TAG_FLAG_FOOTERPRESENT = 0x10,
|
cannam@87
|
80
|
cannam@87
|
81 ID3_TAG_FLAG_KNOWNFLAGS = 0xf0
|
cannam@87
|
82 };
|
cannam@87
|
83
|
cannam@87
|
84 /* tag extended flags */
|
cannam@87
|
85
|
cannam@87
|
86 enum {
|
cannam@87
|
87 ID3_TAG_EXTENDEDFLAG_TAGISANUPDATE = 0x40,
|
cannam@87
|
88 ID3_TAG_EXTENDEDFLAG_CRCDATAPRESENT = 0x20,
|
cannam@87
|
89 ID3_TAG_EXTENDEDFLAG_TAGRESTRICTIONS = 0x10,
|
cannam@87
|
90
|
cannam@87
|
91 ID3_TAG_EXTENDEDFLAG_KNOWNFLAGS = 0x70
|
cannam@87
|
92 };
|
cannam@87
|
93
|
cannam@87
|
94 /* tag restrictions */
|
cannam@87
|
95
|
cannam@87
|
96 enum {
|
cannam@87
|
97 ID3_TAG_RESTRICTION_TAGSIZE_MASK = 0xc0,
|
cannam@87
|
98 ID3_TAG_RESTRICTION_TAGSIZE_128_FRAMES_1_MB = 0x00,
|
cannam@87
|
99 ID3_TAG_RESTRICTION_TAGSIZE_64_FRAMES_128_KB = 0x40,
|
cannam@87
|
100 ID3_TAG_RESTRICTION_TAGSIZE_32_FRAMES_40_KB = 0x80,
|
cannam@87
|
101 ID3_TAG_RESTRICTION_TAGSIZE_32_FRAMES_4_KB = 0xc0
|
cannam@87
|
102 };
|
cannam@87
|
103
|
cannam@87
|
104 enum {
|
cannam@87
|
105 ID3_TAG_RESTRICTION_TEXTENCODING_MASK = 0x20,
|
cannam@87
|
106 ID3_TAG_RESTRICTION_TEXTENCODING_NONE = 0x00,
|
cannam@87
|
107 ID3_TAG_RESTRICTION_TEXTENCODING_LATIN1_UTF8 = 0x20
|
cannam@87
|
108 };
|
cannam@87
|
109
|
cannam@87
|
110 enum {
|
cannam@87
|
111 ID3_TAG_RESTRICTION_TEXTSIZE_MASK = 0x18,
|
cannam@87
|
112 ID3_TAG_RESTRICTION_TEXTSIZE_NONE = 0x00,
|
cannam@87
|
113 ID3_TAG_RESTRICTION_TEXTSIZE_1024_CHARS = 0x08,
|
cannam@87
|
114 ID3_TAG_RESTRICTION_TEXTSIZE_128_CHARS = 0x10,
|
cannam@87
|
115 ID3_TAG_RESTRICTION_TEXTSIZE_30_CHARS = 0x18
|
cannam@87
|
116 };
|
cannam@87
|
117
|
cannam@87
|
118 enum {
|
cannam@87
|
119 ID3_TAG_RESTRICTION_IMAGEENCODING_MASK = 0x04,
|
cannam@87
|
120 ID3_TAG_RESTRICTION_IMAGEENCODING_NONE = 0x00,
|
cannam@87
|
121 ID3_TAG_RESTRICTION_IMAGEENCODING_PNG_JPEG = 0x04
|
cannam@87
|
122 };
|
cannam@87
|
123
|
cannam@87
|
124 enum {
|
cannam@87
|
125 ID3_TAG_RESTRICTION_IMAGESIZE_MASK = 0x03,
|
cannam@87
|
126 ID3_TAG_RESTRICTION_IMAGESIZE_NONE = 0x00,
|
cannam@87
|
127 ID3_TAG_RESTRICTION_IMAGESIZE_256_256 = 0x01,
|
cannam@87
|
128 ID3_TAG_RESTRICTION_IMAGESIZE_64_64 = 0x02,
|
cannam@87
|
129 ID3_TAG_RESTRICTION_IMAGESIZE_64_64_EXACT = 0x03
|
cannam@87
|
130 };
|
cannam@87
|
131
|
cannam@87
|
132 /* library options */
|
cannam@87
|
133
|
cannam@87
|
134 enum {
|
cannam@87
|
135 ID3_TAG_OPTION_UNSYNCHRONISATION = 0x0001, /* use unsynchronisation */
|
cannam@87
|
136 ID3_TAG_OPTION_COMPRESSION = 0x0002, /* use compression */
|
cannam@87
|
137 ID3_TAG_OPTION_CRC = 0x0004, /* use CRC */
|
cannam@87
|
138
|
cannam@87
|
139 ID3_TAG_OPTION_APPENDEDTAG = 0x0010, /* tag will be appended */
|
cannam@87
|
140 ID3_TAG_OPTION_FILEALTERED = 0x0020, /* audio data was altered */
|
cannam@87
|
141
|
cannam@87
|
142 ID3_TAG_OPTION_ID3V1 = 0x0100 /* render ID3v1/ID3v1.1 tag */
|
cannam@87
|
143 };
|
cannam@87
|
144
|
cannam@87
|
145 struct id3_frame {
|
cannam@87
|
146 char id[5];
|
cannam@87
|
147 char const *description;
|
cannam@87
|
148 unsigned int refcount;
|
cannam@87
|
149 int flags;
|
cannam@87
|
150 int group_id;
|
cannam@87
|
151 int encryption_method;
|
cannam@87
|
152 id3_byte_t *encoded;
|
cannam@87
|
153 id3_length_t encoded_length;
|
cannam@87
|
154 id3_length_t decoded_length;
|
cannam@87
|
155 unsigned int nfields;
|
cannam@87
|
156 union id3_field *fields;
|
cannam@87
|
157 };
|
cannam@87
|
158
|
cannam@87
|
159 enum {
|
cannam@87
|
160 /* frame status flags */
|
cannam@87
|
161 ID3_FRAME_FLAG_TAGALTERPRESERVATION = 0x4000,
|
cannam@87
|
162 ID3_FRAME_FLAG_FILEALTERPRESERVATION = 0x2000,
|
cannam@87
|
163 ID3_FRAME_FLAG_READONLY = 0x1000,
|
cannam@87
|
164
|
cannam@87
|
165 ID3_FRAME_FLAG_STATUSFLAGS = 0xff00,
|
cannam@87
|
166
|
cannam@87
|
167 /* frame format flags */
|
cannam@87
|
168 ID3_FRAME_FLAG_GROUPINGIDENTITY = 0x0040,
|
cannam@87
|
169 ID3_FRAME_FLAG_COMPRESSION = 0x0008,
|
cannam@87
|
170 ID3_FRAME_FLAG_ENCRYPTION = 0x0004,
|
cannam@87
|
171 ID3_FRAME_FLAG_UNSYNCHRONISATION = 0x0002,
|
cannam@87
|
172 ID3_FRAME_FLAG_DATALENGTHINDICATOR = 0x0001,
|
cannam@87
|
173
|
cannam@87
|
174 ID3_FRAME_FLAG_FORMATFLAGS = 0x00ff,
|
cannam@87
|
175
|
cannam@87
|
176 ID3_FRAME_FLAG_KNOWNFLAGS = 0x704f
|
cannam@87
|
177 };
|
cannam@87
|
178
|
cannam@87
|
179 enum id3_field_type {
|
cannam@87
|
180 ID3_FIELD_TYPE_TEXTENCODING,
|
cannam@87
|
181 ID3_FIELD_TYPE_LATIN1,
|
cannam@87
|
182 ID3_FIELD_TYPE_LATIN1FULL,
|
cannam@87
|
183 ID3_FIELD_TYPE_LATIN1LIST,
|
cannam@87
|
184 ID3_FIELD_TYPE_STRING,
|
cannam@87
|
185 ID3_FIELD_TYPE_STRINGFULL,
|
cannam@87
|
186 ID3_FIELD_TYPE_STRINGLIST,
|
cannam@87
|
187 ID3_FIELD_TYPE_LANGUAGE,
|
cannam@87
|
188 ID3_FIELD_TYPE_FRAMEID,
|
cannam@87
|
189 ID3_FIELD_TYPE_DATE,
|
cannam@87
|
190 ID3_FIELD_TYPE_INT8,
|
cannam@87
|
191 ID3_FIELD_TYPE_INT16,
|
cannam@87
|
192 ID3_FIELD_TYPE_INT24,
|
cannam@87
|
193 ID3_FIELD_TYPE_INT32,
|
cannam@87
|
194 ID3_FIELD_TYPE_INT32PLUS,
|
cannam@87
|
195 ID3_FIELD_TYPE_BINARYDATA
|
cannam@87
|
196 };
|
cannam@87
|
197
|
cannam@87
|
198 enum id3_field_textencoding {
|
cannam@87
|
199 ID3_FIELD_TEXTENCODING_ISO_8859_1 = 0x00,
|
cannam@87
|
200 ID3_FIELD_TEXTENCODING_UTF_16 = 0x01,
|
cannam@87
|
201 ID3_FIELD_TEXTENCODING_UTF_16BE = 0x02,
|
cannam@87
|
202 ID3_FIELD_TEXTENCODING_UTF_8 = 0x03
|
cannam@87
|
203 };
|
cannam@87
|
204
|
cannam@87
|
205 union id3_field {
|
cannam@87
|
206 enum id3_field_type type;
|
cannam@87
|
207 struct {
|
cannam@87
|
208 enum id3_field_type type;
|
cannam@87
|
209 signed long value;
|
cannam@87
|
210 } number;
|
cannam@87
|
211 struct {
|
cannam@87
|
212 enum id3_field_type type;
|
cannam@87
|
213 id3_latin1_t *ptr;
|
cannam@87
|
214 } latin1;
|
cannam@87
|
215 struct {
|
cannam@87
|
216 enum id3_field_type type;
|
cannam@87
|
217 unsigned int nstrings;
|
cannam@87
|
218 id3_latin1_t **strings;
|
cannam@87
|
219 } latin1list;
|
cannam@87
|
220 struct {
|
cannam@87
|
221 enum id3_field_type type;
|
cannam@87
|
222 id3_ucs4_t *ptr;
|
cannam@87
|
223 } string;
|
cannam@87
|
224 struct {
|
cannam@87
|
225 enum id3_field_type type;
|
cannam@87
|
226 unsigned int nstrings;
|
cannam@87
|
227 id3_ucs4_t **strings;
|
cannam@87
|
228 } stringlist;
|
cannam@87
|
229 struct {
|
cannam@87
|
230 enum id3_field_type type;
|
cannam@87
|
231 char value[9];
|
cannam@87
|
232 } immediate;
|
cannam@87
|
233 struct {
|
cannam@87
|
234 enum id3_field_type type;
|
cannam@87
|
235 id3_byte_t *data;
|
cannam@87
|
236 id3_length_t length;
|
cannam@87
|
237 } binary;
|
cannam@87
|
238 };
|
cannam@87
|
239
|
cannam@87
|
240 /* file interface */
|
cannam@87
|
241
|
cannam@87
|
242 enum id3_file_mode {
|
cannam@87
|
243 ID3_FILE_MODE_READONLY = 0,
|
cannam@87
|
244 ID3_FILE_MODE_READWRITE
|
cannam@87
|
245 };
|
cannam@87
|
246
|
cannam@87
|
247 struct id3_file *id3_file_open(char const *, enum id3_file_mode);
|
cannam@87
|
248 struct id3_file *id3_file_fdopen(int, enum id3_file_mode);
|
cannam@87
|
249 int id3_file_close(struct id3_file *);
|
cannam@87
|
250
|
cannam@87
|
251 struct id3_tag *id3_file_tag(struct id3_file const *);
|
cannam@87
|
252
|
cannam@87
|
253 int id3_file_update(struct id3_file *);
|
cannam@87
|
254
|
cannam@87
|
255 /* tag interface */
|
cannam@87
|
256
|
cannam@87
|
257 struct id3_tag *id3_tag_new(void);
|
cannam@87
|
258 void id3_tag_delete(struct id3_tag *);
|
cannam@87
|
259
|
cannam@87
|
260 unsigned int id3_tag_version(struct id3_tag const *);
|
cannam@87
|
261
|
cannam@87
|
262 int id3_tag_options(struct id3_tag *, int, int);
|
cannam@87
|
263 void id3_tag_setlength(struct id3_tag *, id3_length_t);
|
cannam@87
|
264
|
cannam@87
|
265 void id3_tag_clearframes(struct id3_tag *);
|
cannam@87
|
266
|
cannam@87
|
267 int id3_tag_attachframe(struct id3_tag *, struct id3_frame *);
|
cannam@87
|
268 int id3_tag_detachframe(struct id3_tag *, struct id3_frame *);
|
cannam@87
|
269
|
cannam@87
|
270 struct id3_frame *id3_tag_findframe(struct id3_tag const *,
|
cannam@87
|
271 char const *, unsigned int);
|
cannam@87
|
272
|
cannam@87
|
273 signed long id3_tag_query(id3_byte_t const *, id3_length_t);
|
cannam@87
|
274
|
cannam@87
|
275 struct id3_tag *id3_tag_parse(id3_byte_t const *, id3_length_t);
|
cannam@87
|
276 id3_length_t id3_tag_render(struct id3_tag const *, id3_byte_t *);
|
cannam@87
|
277
|
cannam@87
|
278 /* frame interface */
|
cannam@87
|
279
|
cannam@87
|
280 struct id3_frame *id3_frame_new(char const *);
|
cannam@87
|
281 void id3_frame_delete(struct id3_frame *);
|
cannam@87
|
282
|
cannam@87
|
283 union id3_field *id3_frame_field(struct id3_frame const *, unsigned int);
|
cannam@87
|
284
|
cannam@87
|
285 /* field interface */
|
cannam@87
|
286
|
cannam@87
|
287 enum id3_field_type id3_field_type(union id3_field const *);
|
cannam@87
|
288
|
cannam@87
|
289 int id3_field_setint(union id3_field *, signed long);
|
cannam@87
|
290 int id3_field_settextencoding(union id3_field *, enum id3_field_textencoding);
|
cannam@87
|
291 int id3_field_setstrings(union id3_field *, unsigned int, id3_ucs4_t **);
|
cannam@87
|
292 int id3_field_addstring(union id3_field *, id3_ucs4_t const *);
|
cannam@87
|
293 int id3_field_setlanguage(union id3_field *, char const *);
|
cannam@87
|
294 int id3_field_setlatin1(union id3_field *, id3_latin1_t const *);
|
cannam@87
|
295 int id3_field_setfulllatin1(union id3_field *, id3_latin1_t const *);
|
cannam@87
|
296 int id3_field_setstring(union id3_field *, id3_ucs4_t const *);
|
cannam@87
|
297 int id3_field_setfullstring(union id3_field *, id3_ucs4_t const *);
|
cannam@87
|
298 int id3_field_setframeid(union id3_field *, char const *);
|
cannam@87
|
299 int id3_field_setbinarydata(union id3_field *,
|
cannam@87
|
300 id3_byte_t const *, id3_length_t);
|
cannam@87
|
301
|
cannam@87
|
302 signed long id3_field_getint(union id3_field const *);
|
cannam@87
|
303 enum id3_field_textencoding id3_field_gettextencoding(union id3_field const *);
|
cannam@87
|
304 id3_latin1_t const *id3_field_getlatin1(union id3_field const *);
|
cannam@87
|
305 id3_latin1_t const *id3_field_getfulllatin1(union id3_field const *);
|
cannam@87
|
306 id3_ucs4_t const *id3_field_getstring(union id3_field const *);
|
cannam@87
|
307 id3_ucs4_t const *id3_field_getfullstring(union id3_field const *);
|
cannam@87
|
308 unsigned int id3_field_getnstrings(union id3_field const *);
|
cannam@87
|
309 id3_ucs4_t const *id3_field_getstrings(union id3_field const *,
|
cannam@87
|
310 unsigned int);
|
cannam@87
|
311 char const *id3_field_getframeid(union id3_field const *);
|
cannam@87
|
312 id3_byte_t const *id3_field_getbinarydata(union id3_field const *,
|
cannam@87
|
313 id3_length_t *);
|
cannam@87
|
314
|
cannam@87
|
315 /* genre interface */
|
cannam@87
|
316
|
cannam@87
|
317 id3_ucs4_t const *id3_genre_index(unsigned int);
|
cannam@87
|
318 id3_ucs4_t const *id3_genre_name(id3_ucs4_t const *);
|
cannam@87
|
319 int id3_genre_number(id3_ucs4_t const *);
|
cannam@87
|
320
|
cannam@87
|
321 /* ucs4 interface */
|
cannam@87
|
322
|
cannam@87
|
323 id3_latin1_t *id3_ucs4_latin1duplicate(id3_ucs4_t const *);
|
cannam@87
|
324 id3_utf16_t *id3_ucs4_utf16duplicate(id3_ucs4_t const *);
|
cannam@87
|
325 id3_utf8_t *id3_ucs4_utf8duplicate(id3_ucs4_t const *);
|
cannam@87
|
326
|
cannam@87
|
327 void id3_ucs4_putnumber(id3_ucs4_t *, unsigned long);
|
cannam@87
|
328 unsigned long id3_ucs4_getnumber(id3_ucs4_t const *);
|
cannam@87
|
329
|
cannam@87
|
330 /* latin1/utf16/utf8 interfaces */
|
cannam@87
|
331
|
cannam@87
|
332 id3_ucs4_t *id3_latin1_ucs4duplicate(id3_latin1_t const *);
|
cannam@87
|
333 id3_ucs4_t *id3_utf16_ucs4duplicate(id3_utf16_t const *);
|
cannam@87
|
334 id3_ucs4_t *id3_utf8_ucs4duplicate(id3_utf8_t const *);
|
cannam@87
|
335
|
cannam@87
|
336 /* version interface */
|
cannam@87
|
337
|
cannam@87
|
338 # define ID3_VERSION_MAJOR 0
|
cannam@87
|
339 # define ID3_VERSION_MINOR 15
|
cannam@87
|
340 # define ID3_VERSION_PATCH 1
|
cannam@87
|
341 # define ID3_VERSION_EXTRA " (beta)"
|
cannam@87
|
342
|
cannam@87
|
343 # define ID3_VERSION_STRINGIZE(str) #str
|
cannam@87
|
344 # define ID3_VERSION_STRING(num) ID3_VERSION_STRINGIZE(num)
|
cannam@87
|
345
|
cannam@87
|
346 # define ID3_VERSION ID3_VERSION_STRING(ID3_VERSION_MAJOR) "." \
|
cannam@87
|
347 ID3_VERSION_STRING(ID3_VERSION_MINOR) "." \
|
cannam@87
|
348 ID3_VERSION_STRING(ID3_VERSION_PATCH) \
|
cannam@87
|
349 ID3_VERSION_EXTRA
|
cannam@87
|
350
|
cannam@87
|
351 # define ID3_PUBLISHYEAR "2000-2004"
|
cannam@87
|
352 # define ID3_AUTHOR "Underbit Technologies, Inc."
|
cannam@87
|
353 # define ID3_EMAIL "info@underbit.com"
|
cannam@87
|
354
|
cannam@87
|
355 extern char const id3_version[];
|
cannam@87
|
356 extern char const id3_copyright[];
|
cannam@87
|
357 extern char const id3_author[];
|
cannam@87
|
358 extern char const id3_build[];
|
cannam@87
|
359
|
cannam@87
|
360 # ifdef __cplusplus
|
cannam@87
|
361 }
|
cannam@87
|
362 # endif
|
cannam@87
|
363
|
cannam@87
|
364 # endif
|