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