comparison Input/mpg123/xmms-id3.h @ 0:cb178e5ad177 trunk

[svn] Import audacious source.
author nenolod
date Mon, 24 Oct 2005 03:06:47 -0700
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:cb178e5ad177
1 /*********************************************************************
2 *
3 * Copyright (C) 1998, 1999, 2002, Espen Skoglund
4 * Department of Computer Science, University of Tromsų
5 *
6 * Filename: id3.h
7 * Description: Include file for accessing the ID3 library.
8 * Author: Espen Skoglund <espensk@stud.cs.uit.no>
9 * Created at: Thu Nov 5 15:55:10 1998
10 *
11 * $Id: xmms-id3.h,v 1.1 2004/07/20 21:47:22 descender Exp $
12 *
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version 2
16 * of the License, or (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26 *
27 ********************************************************************/
28 #ifndef ID3_H
29 #define ID3_H
30
31 #include <glib.h>
32 #include <libaudacious/vfs.h>
33
34 /*
35 * Option flags to id3_open_*().
36 */
37 #define ID3_OPENF_NONE 0x0000
38 #define ID3_OPENF_NOCHK 0x0001
39 #define ID3_OPENF_CREATE 0x0002
40
41
42 /*
43 * The size of the read buffer used by file operations.
44 */
45 #define ID3_FD_BUFSIZE 8192
46
47
48 /*
49 * Structure describing the ID3 tag.
50 */
51 struct id3_tag {
52 int id3_type; /* Memory or file desriptor */
53 int id3_oflags; /* Flags from open call */
54 int id3_flags; /* Flags from tag header */
55 int id3_altered; /* Set when tag has been altered */
56 int id3_newtag; /* Set if this is a new tag */
57
58 int id3_version; /* Major ID3 version number */
59 int id3_revision; /* ID3 revision number */
60
61 int id3_tagsize; /* Total size of ID3 tag */
62 int id3_pos; /* Current position within tag */
63
64 char *id3_error_msg; /* Last error message */
65
66 char id3_buffer[256]; /* Used for various strings */
67
68 union {
69 /*
70 * Memory specific fields.
71 */
72 struct {
73 void *id3_ptr;
74 } me;
75
76 /*
77 * File desc. specific fields.
78 */
79 struct {
80 int id3_fd;
81 void *id3_buf;
82 } fd;
83
84 /*
85 * File ptr. specific fields.
86 */
87 struct {
88 VFSFile *id3_fp;
89 void *id3_buf;
90 } fp;
91 } s;
92
93 /*
94 * Functions for doing operations within ID3 tag.
95 */
96 int (*id3_seek) (struct id3_tag *, int);
97 void *(*id3_read) (struct id3_tag *, void *, int);
98
99 /*
100 * Linked list of ID3 frames.
101 */
102 GList *id3_frame;
103 };
104
105 #define ID3_TYPE_NONE 0
106 #define ID3_TYPE_MEM 1
107 #define ID3_TYPE_FD 2
108 #define ID3_TYPE_FP 3
109
110
111 /*
112 * Structure describing an ID3 frame.
113 */
114 struct id3_frame {
115 struct id3_tag *fr_owner;
116 struct id3_framedesc *fr_desc;
117 int fr_flags;
118 unsigned char fr_encryption;
119 unsigned char fr_grouping;
120 unsigned char fr_altered;
121
122 void *fr_data; /* Pointer to frame data, excluding headers */
123 int fr_size; /* Size of uncompressed frame */
124
125 void *fr_raw_data; /* Frame data */
126 int fr_raw_size; /* Frame size */
127
128 void *fr_data_z; /* The decompressed compressed frame */
129 int fr_size_z; /* Size of decompressed compressed frame */
130 };
131
132
133 /*
134 * Structure describing an ID3 frame type.
135 */
136 struct id3_framedesc {
137 guint32 fd_id;
138 char fd_idstr[4];
139 char *fd_description;
140 };
141
142
143 /*
144 * Text encodings.
145 */
146 #define ID3_ENCODING_ISO_8859_1 0x00
147 #define ID3_ENCODING_UTF16 0x01
148 #define ID3_ENCODING_UTF16BE 0x02
149 #define ID3_ENCODING_UTF8 0x03
150
151
152
153 /*
154 * ID3 frame id numbers.
155 */
156 #define ID3_FRAME_ID(a,b,c,d) ((a << 24) | (b << 16) | (c << 8) | d)
157
158 #define ID3_AENC ID3_FRAME_ID('A','E','N','C')
159 #define ID3_APIC ID3_FRAME_ID('A','P','I','C')
160 #define ID3_ASPI ID3_FRAME_ID('A','S','P','I')
161 #define ID3_COMM ID3_FRAME_ID('C','O','M','M')
162 #define ID3_COMR ID3_FRAME_ID('C','O','M','R')
163 #define ID3_ENCR ID3_FRAME_ID('E','N','C','R')
164 #define ID3_EQUA ID3_FRAME_ID('E','Q','U','A')
165 #define ID3_EQU2 ID3_FRAME_ID('E','Q','U','2')
166 #define ID3_ETCO ID3_FRAME_ID('E','T','C','O')
167 #define ID3_GEOB ID3_FRAME_ID('G','E','O','B')
168 #define ID3_GRID ID3_FRAME_ID('G','R','I','D')
169 #define ID3_IPLS ID3_FRAME_ID('I','P','L','S')
170 #define ID3_LINK ID3_FRAME_ID('L','I','N','K')
171 #define ID3_MCDI ID3_FRAME_ID('M','C','D','I')
172 #define ID3_MLLT ID3_FRAME_ID('M','L','L','T')
173 #define ID3_OWNE ID3_FRAME_ID('O','W','N','E')
174 #define ID3_PRIV ID3_FRAME_ID('P','R','I','V')
175 #define ID3_PCNT ID3_FRAME_ID('P','C','N','T')
176 #define ID3_POPM ID3_FRAME_ID('P','O','P','M')
177 #define ID3_POSS ID3_FRAME_ID('P','O','S','S')
178 #define ID3_RBUF ID3_FRAME_ID('R','B','U','F')
179 #define ID3_RVAD ID3_FRAME_ID('R','V','A','D')
180 #define ID3_RVA2 ID3_FRAME_ID('R','V','A','2')
181 #define ID3_RVRB ID3_FRAME_ID('R','V','R','B')
182 #define ID3_SEEK ID3_FRAME_ID('S','E','E','K')
183 #define ID3_SIGN ID3_FRAME_ID('S','I','G','N')
184 #define ID3_SYLT ID3_FRAME_ID('S','Y','L','T')
185 #define ID3_SYTC ID3_FRAME_ID('S','Y','T','C')
186 #define ID3_TALB ID3_FRAME_ID('T','A','L','B')
187 #define ID3_TBPM ID3_FRAME_ID('T','B','P','M')
188 #define ID3_TCOM ID3_FRAME_ID('T','C','O','M')
189 #define ID3_TCON ID3_FRAME_ID('T','C','O','N')
190 #define ID3_TCOP ID3_FRAME_ID('T','C','O','P')
191 #define ID3_TDAT ID3_FRAME_ID('T','D','A','T')
192 #define ID3_TDEN ID3_FRAME_ID('T','D','E','N')
193 #define ID3_TDLY ID3_FRAME_ID('T','D','L','Y')
194 #define ID3_TDOR ID3_FRAME_ID('T','D','O','R')
195 #define ID3_TDRC ID3_FRAME_ID('T','D','R','C')
196 #define ID3_TDRL ID3_FRAME_ID('T','D','R','L')
197 #define ID3_TDTG ID3_FRAME_ID('T','D','T','G')
198 #define ID3_TENC ID3_FRAME_ID('T','E','N','C')
199 #define ID3_TEXT ID3_FRAME_ID('T','E','X','T')
200 #define ID3_TFLT ID3_FRAME_ID('T','F','L','T')
201 #define ID3_TIME ID3_FRAME_ID('T','I','M','E')
202 #define ID3_TIPL ID3_FRAME_ID('T','I','P','L')
203 #define ID3_TIT1 ID3_FRAME_ID('T','I','T','1')
204 #define ID3_TIT2 ID3_FRAME_ID('T','I','T','2')
205 #define ID3_TIT3 ID3_FRAME_ID('T','I','T','3')
206 #define ID3_TKEY ID3_FRAME_ID('T','K','E','Y')
207 #define ID3_TLAN ID3_FRAME_ID('T','L','A','N')
208 #define ID3_TLEN ID3_FRAME_ID('T','L','E','N')
209 #define ID3_TMCL ID3_FRAME_ID('T','M','C','L')
210 #define ID3_TMED ID3_FRAME_ID('T','M','E','D')
211 #define ID3_TMOO ID3_FRAME_ID('T','M','O','O')
212 #define ID3_TOAL ID3_FRAME_ID('T','O','A','L')
213 #define ID3_TOFN ID3_FRAME_ID('T','O','F','N')
214 #define ID3_TOLY ID3_FRAME_ID('T','O','L','Y')
215 #define ID3_TOPE ID3_FRAME_ID('T','O','P','E')
216 #define ID3_TORY ID3_FRAME_ID('T','O','R','Y')
217 #define ID3_TOWN ID3_FRAME_ID('T','O','W','N')
218 #define ID3_TPE1 ID3_FRAME_ID('T','P','E','1')
219 #define ID3_TPE2 ID3_FRAME_ID('T','P','E','2')
220 #define ID3_TPE3 ID3_FRAME_ID('T','P','E','3')
221 #define ID3_TPE4 ID3_FRAME_ID('T','P','E','4')
222 #define ID3_TPOS ID3_FRAME_ID('T','P','O','S')
223 #define ID3_TPRO ID3_FRAME_ID('T','P','R','O')
224 #define ID3_TPUB ID3_FRAME_ID('T','P','U','B')
225 #define ID3_TRCK ID3_FRAME_ID('T','R','C','K')
226 #define ID3_TRDA ID3_FRAME_ID('T','R','D','A')
227 #define ID3_TRSN ID3_FRAME_ID('T','R','S','N')
228 #define ID3_TRSO ID3_FRAME_ID('T','R','S','O')
229 #define ID3_TSIZ ID3_FRAME_ID('T','S','I','Z')
230 #define ID3_TSOA ID3_FRAME_ID('T','S','O','A')
231 #define ID3_TSOP ID3_FRAME_ID('T','S','O','P')
232 #define ID3_TSOT ID3_FRAME_ID('T','S','O','T')
233 #define ID3_TSRC ID3_FRAME_ID('T','S','R','C')
234 #define ID3_TSSE ID3_FRAME_ID('T','S','S','E')
235 #define ID3_TSST ID3_FRAME_ID('T','S','S','T')
236 #define ID3_TYER ID3_FRAME_ID('T','Y','E','R')
237 #define ID3_TXXX ID3_FRAME_ID('T','X','X','X')
238 #define ID3_UFID ID3_FRAME_ID('U','F','I','D')
239 #define ID3_USER ID3_FRAME_ID('U','S','E','R')
240 #define ID3_USLT ID3_FRAME_ID('U','S','L','T')
241 #define ID3_WCOM ID3_FRAME_ID('W','C','O','M')
242 #define ID3_WCOP ID3_FRAME_ID('W','C','O','P')
243 #define ID3_WOAF ID3_FRAME_ID('W','O','A','F')
244 #define ID3_WOAR ID3_FRAME_ID('W','O','A','R')
245 #define ID3_WOAS ID3_FRAME_ID('W','O','A','S')
246 #define ID3_WORS ID3_FRAME_ID('W','O','R','S')
247 #define ID3_WPAY ID3_FRAME_ID('W','P','A','Y')
248 #define ID3_WPUB ID3_FRAME_ID('W','P','U','B')
249 #define ID3_WXXX ID3_FRAME_ID('W','X','X','X')
250
251 /*
252 * Version 2.2.0
253 */
254
255 #define ID3_FRAME_ID_22(a, b, c) ((a << 16) | (b << 8) | c)
256
257 #define ID3_BUF ID3_FRAME_ID_22('B', 'U', 'F')
258 #define ID3_CNT ID3_FRAME_ID_22('C', 'N', 'T')
259 #define ID3_COM ID3_FRAME_ID_22('C', 'O', 'M')
260 #define ID3_CRA ID3_FRAME_ID_22('C', 'R', 'A')
261 #define ID3_CRM ID3_FRAME_ID_22('C', 'R', 'M')
262 #define ID3_ETC ID3_FRAME_ID_22('E', 'T', 'C')
263 #define ID3_EQU ID3_FRAME_ID_22('E', 'Q', 'U')
264 #define ID3_GEO ID3_FRAME_ID_22('G', 'E', 'O')
265 #define ID3_IPL ID3_FRAME_ID_22('I', 'P', 'L')
266 #define ID3_LNK ID3_FRAME_ID_22('L', 'N', 'K')
267 #define ID3_MCI ID3_FRAME_ID_22('M', 'C', 'I')
268 #define ID3_MLL ID3_FRAME_ID_22('M', 'L', 'L')
269 #define ID3_PIC ID3_FRAME_ID_22('P', 'I', 'C')
270 #define ID3_POP ID3_FRAME_ID_22('P', 'O', 'P')
271 #define ID3_REV ID3_FRAME_ID_22('R', 'E', 'V')
272 #define ID3_RVA ID3_FRAME_ID_22('R', 'V', 'A')
273 #define ID3_SLT ID3_FRAME_ID_22('S', 'L', 'T')
274 #define ID3_STC ID3_FRAME_ID_22('S', 'T', 'C')
275 #define ID3_TAL ID3_FRAME_ID_22('T', 'A', 'L')
276 #define ID3_TBP ID3_FRAME_ID_22('T', 'B', 'P')
277 #define ID3_TCM ID3_FRAME_ID_22('T', 'C', 'M')
278 #define ID3_TCO ID3_FRAME_ID_22('T', 'C', 'O')
279 #define ID3_TCR ID3_FRAME_ID_22('T', 'C', 'R')
280 #define ID3_TDA ID3_FRAME_ID_22('T', 'D', 'A')
281 #define ID3_TDY ID3_FRAME_ID_22('T', 'D', 'Y')
282 #define ID3_TEN ID3_FRAME_ID_22('T', 'E', 'N')
283 #define ID3_TFT ID3_FRAME_ID_22('T', 'F', 'T')
284 #define ID3_TIM ID3_FRAME_ID_22('T', 'I', 'M')
285 #define ID3_TKE ID3_FRAME_ID_22('T', 'K', 'E')
286 #define ID3_TLA ID3_FRAME_ID_22('T', 'L', 'A')
287 #define ID3_TLE ID3_FRAME_ID_22('T', 'L', 'E')
288 #define ID3_TMT ID3_FRAME_ID_22('T', 'M', 'T')
289 #define ID3_TOA ID3_FRAME_ID_22('T', 'O', 'A')
290 #define ID3_TOF ID3_FRAME_ID_22('T', 'O', 'F')
291 #define ID3_TOL ID3_FRAME_ID_22('T', 'O', 'L')
292 #define ID3_TOR ID3_FRAME_ID_22('T', 'O', 'R')
293 #define ID3_TOT ID3_FRAME_ID_22('T', 'O', 'T')
294 #define ID3_TP1 ID3_FRAME_ID_22('T', 'P', '1')
295 #define ID3_TP2 ID3_FRAME_ID_22('T', 'P', '2')
296 #define ID3_TP3 ID3_FRAME_ID_22('T', 'P', '3')
297 #define ID3_TP4 ID3_FRAME_ID_22('T', 'P', '4')
298 #define ID3_TPA ID3_FRAME_ID_22('T', 'P', 'A')
299 #define ID3_TPB ID3_FRAME_ID_22('T', 'P', 'B')
300 #define ID3_TRC ID3_FRAME_ID_22('T', 'R', 'C')
301 #define ID3_TRD ID3_FRAME_ID_22('T', 'R', 'D')
302 #define ID3_TRK ID3_FRAME_ID_22('T', 'R', 'K')
303 #define ID3_TSI ID3_FRAME_ID_22('T', 'S', 'I')
304 #define ID3_TSS ID3_FRAME_ID_22('T', 'S', 'S')
305 #define ID3_TT1 ID3_FRAME_ID_22('T', 'T', '1')
306 #define ID3_TT2 ID3_FRAME_ID_22('T', 'T', '2')
307 #define ID3_TT3 ID3_FRAME_ID_22('T', 'T', '3')
308 #define ID3_TXT ID3_FRAME_ID_22('T', 'X', 'T')
309 #define ID3_TXX ID3_FRAME_ID_22('T', 'X', 'X')
310 #define ID3_TYE ID3_FRAME_ID_22('T', 'Y', 'E')
311 #define ID3_UFI ID3_FRAME_ID_22('U', 'F', 'I')
312 #define ID3_ULT ID3_FRAME_ID_22('U', 'L', 'T')
313 #define ID3_WAF ID3_FRAME_ID_22('W', 'A', 'F')
314 #define ID3_WAR ID3_FRAME_ID_22('W', 'A', 'R')
315 #define ID3_WAS ID3_FRAME_ID_22('W', 'A', 'S')
316 #define ID3_WCM ID3_FRAME_ID_22('W', 'C', 'M')
317 #define ID3_WCP ID3_FRAME_ID_22('W', 'C', 'P')
318 #define ID3_WPB ID3_FRAME_ID_22('W', 'P', 'B')
319 #define ID3_WXX ID3_FRAME_ID_22('W', 'X', 'X')
320
321
322 /*
323 * Prototypes.
324 */
325
326 /* From id3.c */
327 struct id3_tag *id3_open_mem(void *, int);
328 struct id3_tag *id3_open_fd(int, int);
329 struct id3_tag *id3_open_fp(VFSFile *, int);
330 int id3_set_output(struct id3_tag *, char *);
331 int id3_close(struct id3_tag *);
332 int id3_tell(struct id3_tag *);
333 int id3_alter_file(struct id3_tag *);
334 int id3_write_tag(struct id3_tag *, int);
335
336 /* From id3_frame.c */
337 int id3_read_frame(struct id3_tag *id3);
338 struct id3_frame *id3_get_frame(struct id3_tag *, guint32, int);
339 int id3_delete_frame(struct id3_frame *frame);
340 struct id3_frame *id3_add_frame(struct id3_tag *, guint32);
341 int id3_decompress_frame(struct id3_frame *);
342 void id3_destroy_frames(struct id3_tag *id);
343 void id3_frame_clear_data(struct id3_frame *frame);
344
345 /* From id3_frame_text.c */
346 char *id3_utf16_to_ascii(void *);
347 gint8 id3_get_encoding(struct id3_frame *);
348 int id3_set_encoding(struct id3_frame *, gint8);
349 char *id3_get_text(struct id3_frame *);
350 char *id3_get_text_desc(struct id3_frame *);
351 int id3_get_text_number(struct id3_frame *);
352 int id3_set_text(struct id3_frame *, char *);
353 int id3_set_text_number(struct id3_frame *, int);
354 gboolean id3_frame_is_text(struct id3_frame *frame);
355
356 /* From id3_frame_content.c */
357 char *id3_get_content(struct id3_frame *);
358
359 /* From id3_frame_url.c */
360 char *id3_get_url(struct id3_frame *);
361 char *id3_get_url_desc(struct id3_frame *);
362
363 /* From id3_tag.c */
364 void id3_init_tag(struct id3_tag *id3);
365 int id3_read_tag(struct id3_tag *id3);
366
367 #endif /* ID3_H */