annotate Plugins/Input/mpg123/id3_frame.c @ 867:86e8224baa0e trunk

[svn] fixed multiple spawns of flac aboutbox
author giacomo
date Fri, 24 Mar 2006 08:00:06 -0800
parents d15862899bbe
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
1 /*********************************************************************
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
2 *
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
3 * Copyright (C) 1999-2000, 2001, Espen Skoglund
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
4 * Department of Computer Science, University of Tromsų
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
5 *
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
6 * Filename: id3_frame.c
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
7 * Description: Code for handling ID3 frames.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
8 * Author: Espen Skoglund <espensk@stud.cs.uit.no>
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
9 * Created at: Fri Feb 5 23:47:08 1999
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
10 *
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
11 * $Id: id3_frame.c,v 1.5 2004/07/20 21:47:22 descender Exp $
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
12 *
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
13 * This program is free software; you can redistribute it and/or
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
14 * modify it under the terms of the GNU General Public License
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
15 * as published by the Free Software Foundation; either version 2
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
16 * of the License, or (at your option) any later version.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
17 *
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
18 * This program is distributed in the hope that it will be useful,
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
21 * GNU General Public License for more details.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
22 *
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
23 * You should have received a copy of the GNU General Public License
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
24 * along with this program; if not, write to the Free Software
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
25 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
26 *
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
27 ********************************************************************/
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
28 #include "config.h"
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
29
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
30 #ifdef HAVE_LIBZ
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
31 #include <zlib.h>
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
32 #endif
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
33 #include <glib.h>
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
34 #include <stdio.h>
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
35 #include <string.h>
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
36 #include <stdlib.h>
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
37 #include <stdarg.h>
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
38
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
39 #include "xmms-id3.h"
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
40 #include "id3_header.h"
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
41
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
42 static void *id3_frame_get_dataptr(struct id3_frame *frame);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
43 static int id3_frame_get_size(struct id3_frame *frame);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
44 static int id3_read_frame_v22(struct id3_tag *id3);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
45
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
46
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
47 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
48 * Description of all valid ID3v2 frames.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
49 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
50 static struct id3_framedesc framedesc[] = {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
51 {ID3_AENC, "AENC", "Audio encryption"},
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
52 {ID3_APIC, "APIC", "Attached picture"},
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
53 {ID3_ASPI, "ASPI", "Audio seek point index"}, /* v4 only */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
54
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
55 {ID3_COMM, "COMM", "Comments"},
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
56 {ID3_COMR, "COMR", "Commercial frame"},
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
57
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
58 {ID3_ENCR, "ENCR", "Encryption method registration"},
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
59 {ID3_EQUA, "EQUA", "Equalization"}, /* v3 only */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
60 {ID3_EQU2, "EQU2", "Equalization (2)"}, /* v4 only */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
61 {ID3_ETCO, "ETCO", "Event timing codes"},
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
62
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
63 {ID3_GEOB, "GEOB", "General encapsulated object"},
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
64 {ID3_GRID, "GRID", "Group identification registration"},
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
65
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
66 {ID3_IPLS, "IPLS", "Involved people list"}, /* v3 only */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
67
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
68 {ID3_LINK, "LINK", "Linked information"},
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
69
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
70 {ID3_MCDI, "MCDI", "Music CD identifier"},
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
71 {ID3_MLLT, "MLLT", "MPEG location lookup table"},
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
72
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
73 {ID3_OWNE, "OWNE", "Ownership frame"},
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
74
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
75 {ID3_PRIV, "PRIV", "Private frame"},
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
76 {ID3_PCNT, "PCNT", "Play counter"},
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
77 {ID3_POPM, "POPM", "Popularimeter"},
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
78 {ID3_POSS, "POSS", "Position synchronisation frame"},
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
79
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
80 {ID3_RBUF, "RBUF", "Recommended buffer size"},
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
81 {ID3_RVAD, "RVAD", "Relative volume adjustment"}, /* v3 only */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
82 {ID3_RVA2, "RVA2", "RVA2 Relative volume adjustment (2)"}, /* v4 only */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
83 {ID3_RVRB, "RVRB", "Reverb"},
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
84
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
85 {ID3_SEEK, "SEEK", "Seek frame"}, /* v4 only */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
86 {ID3_SIGN, "SIGN", "Signature frame"}, /* v4 only */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
87 {ID3_SYLT, "SYLT", "Synchronized lyric/text"},
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
88 {ID3_SYTC, "SYTC", "Synchronized tempo codes"},
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
89
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
90 {ID3_TALB, "TALB", "Album/Movie/Show title"},
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
91 {ID3_TBPM, "TBPM", "BPM (beats per minute)"},
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
92 {ID3_TCOM, "TCOM", "Composer"},
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
93 {ID3_TCON, "TCON", "Content type"},
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
94 {ID3_TCOP, "TCOP", "Copyright message"},
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
95 {ID3_TDAT, "TDAT", "Date"}, /* v3 only */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
96 {ID3_TDEN, "TDEN", "Encoding time"}, /* v4 only */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
97 {ID3_TDLY, "TDLY", "Playlist delay"},
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
98 {ID3_TDOR, "TDOR", "Original release time"}, /* v4 only */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
99 {ID3_TDRC, "TDRC", "Recording time"}, /* v4 only */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
100 {ID3_TDRL, "TDRL", "Release time"}, /* v4 only */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
101 {ID3_TDTG, "TDTG", "Tagging time"}, /* v4 only */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
102
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
103 {ID3_TENC, "TENC", "Encoded by"},
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
104 {ID3_TEXT, "TEXT", "Lyricist/Text writer"},
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
105 {ID3_TFLT, "TFLT", "File type"},
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
106 {ID3_TIME, "TIME", "Time"}, /* v3 only */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
107 {ID3_TIPL, "TIPL", "Involved people list"}, /* v4 only */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
108 {ID3_TIT1, "TIT1", "Content group description"},
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
109 {ID3_TIT2, "TIT2", "Title/songname/content description"},
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
110 {ID3_TIT3, "TIT3", "Subtitle/Description refinement"},
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
111 {ID3_TKEY, "TKEY", "Initial key"},
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
112 {ID3_TLAN, "TLAN", "Language(s)"},
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
113 {ID3_TLEN, "TLEN", "Length"},
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
114 {ID3_TMCL, "TMCL", "Musician credits list"}, /* v4 only */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
115 {ID3_TMOO, "TMOO", "Mood"}, /* v4 only */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
116 {ID3_TMED, "TMED", "Media type"},
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
117 {ID3_TOAL, "TOAL", "Original album/movie/show title"},
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
118 {ID3_TOFN, "TOFN", "Original filename"},
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
119 {ID3_TOLY, "TOLY", "Original lyricist(s)/text writer(s)"},
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
120 {ID3_TOPE, "TOPE", "Original artist(s)/performer(s)"},
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
121 {ID3_TORY, "TORY", "Original release year"}, /* v3 only */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
122 {ID3_TOWN, "TOWN", "File owner/licensee"},
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
123 {ID3_TPE1, "TPE1", "Lead performer(s)/Soloist(s)"},
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
124 {ID3_TPE2, "TPE2", "Band/orchestra/accompaniment"},
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
125 {ID3_TPE3, "TPE3", "Conductor/performer refinement"},
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
126 {ID3_TPE4, "TPE4", "Interpreted, remixed, or otherwise modified by"},
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
127 {ID3_TPOS, "TPOS", "Part of a set"},
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
128 {ID3_TPRO, "TPRO", "Produced notice"}, /* v4 only */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
129 {ID3_TPUB, "TPUB", "Publisher"},
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
130 {ID3_TRCK, "TRCK", "Track number/Position in set"},
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
131 {ID3_TRDA, "TRDA", "Recording dates"}, /* v3 only */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
132 {ID3_TRSN, "TRSN", "Internet radio station name"},
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
133 {ID3_TRSO, "TRSO", "Internet radio station owner"},
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
134 {ID3_TSIZ, "TSIZ", "Size"}, /* v3 only */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
135 {ID3_TSOA, "TSOA", "Album sort order"}, /* v4 only */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
136 {ID3_TSOP, "TSOP", "Performer sort order"}, /* v4 only */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
137 {ID3_TSOT, "TSOT", "Title sort order"}, /* v4 only */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
138
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
139 {ID3_TSRC, "TSRC", "ISRC (international standard recording code)"},
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
140 {ID3_TSSE, "TSSE", "Software/Hardware and settings used for encoding"},
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
141 {ID3_TSST, "TSST", "Set subtitle"}, /* v4 only */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
142 {ID3_TYER, "TYER", "Year"}, /* v3 only */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
143 {ID3_TXXX, "TXXX", "User defined text information frame"},
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
144
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
145 {ID3_UFID, "UFID", "Unique file identifier"},
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
146 {ID3_USER, "USER", "Terms of use"},
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
147 {ID3_USLT, "USLT", "Unsychronized lyric/text transcription"},
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
148
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
149 {ID3_WCOM, "WCOM", "Commercial information"},
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
150 {ID3_WCOP, "WCOP", "Copyright/Legal information"},
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
151 {ID3_WOAF, "WOAF", "Official audio file webpage"},
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
152 {ID3_WOAR, "WOAR", "Official artist/performer webpage"},
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
153 {ID3_WOAS, "WOAS", "Official audio source webpage"},
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
154 {ID3_WORS, "WORS", "Official internet radio station homepage"},
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
155 {ID3_WPAY, "WPAY", "Payment"},
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
156 {ID3_WPUB, "WPUB", "Publishers official webpage"},
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
157 {ID3_WXXX, "WXXX", "User defined URL link frame"},
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
158 };
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
159
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
160 struct id3_framedesc22 {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
161 guint32 fd_v22, fd_v24;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
162 };
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
163
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
164 static struct id3_framedesc22 framedesc22[] = {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
165 {ID3_BUF, ID3_RBUF}, /* Recommended buffer size */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
166
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
167 {ID3_CNT, ID3_PCNT}, /* Play counter */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
168 {ID3_COM, ID3_COMM}, /* Comments */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
169 {ID3_CRA, ID3_AENC}, /* Audio encryption */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
170 {ID3_CRM, 0}, /* Encrypted meta frame */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
171
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
172 {ID3_ETC, ID3_ETCO}, /* Event timing codes */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
173 /* Could be converted to EQU2 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
174 {ID3_EQU, 0}, /* Equalization */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
175
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
176 {ID3_GEO, ID3_GEOB}, /* General encapsulated object */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
177
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
178 /* Would need conversion to TIPL */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
179 {ID3_IPL, 0}, /* Involved people list */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
180
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
181 /* This is so fragile it's not worth trying to save */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
182 {ID3_LNK, 0}, /* Linked information */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
183
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
184 {ID3_MCI, ID3_MCDI}, /* Music CD Identifier */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
185 {ID3_MLL, ID3_MLLT}, /* MPEG location lookup table */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
186
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
187 /* Would need to convert header for APIC */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
188 {ID3_PIC, 0}, /* Attached picture */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
189 {ID3_POP, ID3_POPM}, /* Popularimeter */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
190
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
191 {ID3_REV, ID3_RVRB}, /* Reverb */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
192 /* Could be converted to RVA2 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
193 {ID3_RVA, 0}, /* Relative volume adjustment */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
194
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
195 {ID3_SLT, ID3_SYLT}, /* Synchronized lyric/text */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
196 {ID3_STC, ID3_SYTC}, /* Synced tempo codes */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
197
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
198 {ID3_TAL, ID3_TALB}, /* Album/Movie/Show title */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
199 {ID3_TBP, ID3_TBPM}, /* BPM (Beats Per Minute) */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
200 {ID3_TCM, ID3_TCOM}, /* Composer */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
201 {ID3_TCO, ID3_TCON}, /* Content type */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
202 {ID3_TCR, ID3_TCOP}, /* Copyright message */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
203 /* This could be incorporated into TDRC */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
204 {ID3_TDA, 0}, /* Date */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
205 {ID3_TDY, ID3_TDLY}, /* Playlist delay */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
206 {ID3_TEN, ID3_TENC}, /* Encoded by */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
207 {ID3_TFT, ID3_TFLT}, /* File type */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
208 /* This could be incorporated into TDRC */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
209 {ID3_TIM, 0}, /* Time */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
210 {ID3_TKE, ID3_TKEY}, /* Initial key */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
211 {ID3_TLA, ID3_TLAN}, /* Language(s) */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
212 {ID3_TLE, ID3_TLEN}, /* Length */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
213 {ID3_TMT, ID3_TMED}, /* Media type */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
214 {ID3_TOA, ID3_TOPE}, /* Original artist(s)/performer(s) */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
215 {ID3_TOF, ID3_TOFN}, /* Original filename */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
216 {ID3_TOL, ID3_TOLY}, /* Original Lyricist(s)/text writer(s) */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
217 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
218 * The docs says that original release year should be in
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
219 * milliseconds! Hopefully that is a typo.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
220 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
221 {ID3_TOR, ID3_TDOR}, /* Original release year */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
222 {ID3_TOT, ID3_TOAL}, /* Original album/Movie/Show title */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
223 {ID3_TP1, ID3_TPE1}, /* Lead artist(s)/Lead performer(s)/Soloist(s)/Performing group */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
224 {ID3_TP2, ID3_TPE2}, /* Band/Orchestra/Accompaniment */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
225 {ID3_TP3, ID3_TPE3}, /* Conductor/Performer refinement */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
226 {ID3_TP4, ID3_TPE4}, /* Interpreted, remixed, or otherwise modified by */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
227 {ID3_TPA, ID3_TPOS}, /* Part of a set */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
228 {ID3_TPB, ID3_TPUB}, /* Publisher */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
229 {ID3_TRC, ID3_TSRC}, /* ISRC (International Standard Recording Code) */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
230 {ID3_TRD, 0}, /* Recording dates */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
231 {ID3_TRK, ID3_TRCK}, /* Track number/Position in set */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
232 {ID3_TSI, 0}, /* Size */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
233 {ID3_TSS, ID3_TSSE}, /* Software/hardware and settings used for encoding */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
234 {ID3_TT1, ID3_TIT1}, /* Content group description */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
235 {ID3_TT2, ID3_TIT2}, /* Title/Songname/Content description */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
236 {ID3_TT3, ID3_TIT3}, /* Subtitle/Description refinement */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
237 {ID3_TXT, ID3_TEXT}, /* Lyricist/text writer */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
238 {ID3_TXX, ID3_TXXX}, /* User defined text information frame */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
239 {ID3_TYE, ID3_TDRC}, /* Year */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
240
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
241 {ID3_UFI, ID3_UFID}, /* Unique file identifier */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
242 {ID3_ULT, ID3_USLT}, /* Unsychronized lyric/text transcription */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
243
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
244 {ID3_WAF, ID3_WOAF}, /* Official audio file webpage */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
245 {ID3_WAR, ID3_WOAR}, /* Official artist/performer webpage */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
246 {ID3_WAS, ID3_WOAS}, /* Official audio source webpage */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
247 {ID3_WCM, ID3_WCOM}, /* Commercial information */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
248 {ID3_WCP, ID3_WCOP}, /* Copyright/Legal information */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
249 {ID3_WPB, ID3_WPUB}, /* Publishers official webpage */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
250 {ID3_WXX, ID3_WXXX}, /* User defined URL link frame */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
251 };
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
252
788
d15862899bbe [svn] - experimental ID32.2 fix
nenolod
parents: 787
diff changeset
253 /*
d15862899bbe [svn] - experimental ID32.2 fix
nenolod
parents: 787
diff changeset
254 * These need to be signed, because otherwise this code will get wonky.
d15862899bbe [svn] - experimental ID32.2 fix
nenolod
parents: 787
diff changeset
255 * BTW, I hate this code and I hope it dies someday.
d15862899bbe [svn] - experimental ID32.2 fix
nenolod
parents: 787
diff changeset
256 * --nenolod
d15862899bbe [svn] - experimental ID32.2 fix
nenolod
parents: 787
diff changeset
257 */
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
258 static struct id3_framedesc *
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
259 find_frame_description(guint32 id)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
260 {
788
d15862899bbe [svn] - experimental ID32.2 fix
nenolod
parents: 787
diff changeset
261 int i;
d15862899bbe [svn] - experimental ID32.2 fix
nenolod
parents: 787
diff changeset
262 for (i = 0; i < (int) sizeof(framedesc) / (int) sizeof(struct id3_framedesc); i++)
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
263 if (framedesc[i].fd_id == id)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
264 return &framedesc[i];
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
265 return NULL;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
266 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
267
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
268
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
269 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
270 * Function id3_read_frame (id3)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
271 *
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
272 * Read next frame from the indicated ID3 tag. Return 0 upon
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
273 * success, or -1 if an error occured.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
274 *
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
275 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
276 int
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
277 id3_read_frame(struct id3_tag *id3)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
278 {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
279 struct id3_frame *frame;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
280 guint32 id;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
281 char *buf;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
282
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
283 if (id3->id3_version == 2)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
284 return id3_read_frame_v22(id3);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
285
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
286 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
287 * Read frame header.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
288 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
289 buf = id3->id3_read(id3, NULL, ID3_FRAMEHDR_SIZE);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
290 if (buf == NULL)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
291 return -1;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
292
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
293 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
294 * If we encounter an invalid frame id, we assume that there is
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
295 * some padding in the header. We just skip the rest of the ID3
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
296 * tag.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
297 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
298 if (!((buf[0] >= '0' && buf[0] <= '9')
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
299 || (buf[0] >= 'A' && buf[0] <= 'Z'))) {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
300 id3->id3_seek(id3, id3->id3_tagsize - id3->id3_pos);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
301 return 0;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
302 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
303 id = ID3_FRAME_ID(buf[0], buf[1], buf[2], buf[3]);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
304
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
305 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
306 * Allocate frame.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
307 */
787
e776161c16db [svn] - more fixes, sizeof *frame !($&($&(@!#$@#*&@!$# whoever wrote this code is an idiot
nenolod
parents: 785
diff changeset
308 frame = g_malloc0(sizeof(struct id3_frame));
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
309
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
310 frame->fr_owner = id3;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
311 /* FIXME v2.4.0 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
312 frame->fr_raw_size = buf[4] << 24 | buf[5] << 16 | buf[6] << 8 | buf[7];
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
313 if (frame->fr_raw_size < 0 || frame->fr_raw_size > 1000000) {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
314 g_free(frame);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
315 return -1;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
316 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
317 frame->fr_flags = buf[8] << 8 | buf[9];
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
318
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
319 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
320 * Determine the type of the frame.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
321 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
322
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
323 frame->fr_desc = find_frame_description(id);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
324
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
325 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
326 * Check if frame had a valid id.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
327 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
328 if (frame->fr_desc == NULL) {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
329 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
330 * No. Ignore the frame.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
331 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
332 if (id3->id3_seek(id3, frame->fr_raw_size) < 0) {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
333 g_free(frame);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
334 return -1;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
335 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
336 return 0;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
337 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
338
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
339 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
340 * Initialize frame.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
341 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
342
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
343 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
344 * We allocate 2 extra bytes. This simplifies retrieval of
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
345 * text strings.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
346 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
347 frame->fr_raw_data = g_malloc0(frame->fr_raw_size + 2);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
348 if (id3->id3_read(id3, frame->fr_raw_data, frame->fr_raw_size) == NULL) {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
349 g_free(frame->fr_raw_data);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
350 g_free(frame);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
351 return -1;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
352 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
353
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
354 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
355 * Insert frame into linked list.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
356 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
357 id3->id3_frame = g_list_append(id3->id3_frame, frame);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
358
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
359 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
360 * Check if frame is compressed using zlib.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
361 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
362 if (frame->fr_flags & ID3_FHFLAG_COMPRESS)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
363 return 0;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
364
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
365 frame->fr_data = id3_frame_get_dataptr(frame);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
366 frame->fr_size = id3_frame_get_size(frame);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
367
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
368 return 0;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
369 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
370
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
371
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
372 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
373 * Function id3_get_frame (id3, type, num)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
374 *
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
375 * Search in the list of frames for the ID3-tag, and return a frame
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
376 * of the indicated type. If tag contains several frames of the
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
377 * indicated type, the third argument tells which of the frames to
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
378 * return.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
379 *
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
380 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
381 struct id3_frame *
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
382 id3_get_frame(struct id3_tag *id3, guint32 type, int num)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
383 {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
384 GList *node;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
385
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
386 for (node = id3->id3_frame; node != NULL; node = node->next) {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
387 struct id3_frame *fr = node->data;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
388 if (fr->fr_desc && fr->fr_desc->fd_id == type) {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
389 if (--num <= 0)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
390 return fr;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
391 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
392 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
393 return NULL;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
394 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
395
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
396 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
397 * Function decompress_frame(frame)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
398 *
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
399 * Uncompress the indicated frame. Return 0 upon success, or -1 if
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
400 * an error occured.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
401 *
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
402 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
403 static int
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
404 decompress_frame(struct id3_frame *frame)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
405 {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
406 #ifdef HAVE_LIBZ
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
407 z_stream z;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
408 int r;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
409
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
410 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
411 * Fetch the size of the decompressed data.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
412 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
413 frame->fr_size_z = g_ntohl(*((guint32 *) frame->fr_raw_data));
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
414 if (frame->fr_size_z < 0 || frame->fr_size_z > 1000000)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
415 return -1;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
416
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
417 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
418 * Allocate memory to hold uncompressed frame.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
419 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
420 frame->fr_data_z = g_malloc(frame->fr_size_z +
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
421 (id3_frame_is_text(frame) ? 2 : 0));
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
422
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
423 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
424 * Initialize zlib.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
425 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
426 z.next_in = id3_frame_get_dataptr(frame);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
427 z.avail_in = id3_frame_get_size(frame);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
428 z.zalloc = NULL;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
429 z.zfree = NULL;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
430 z.opaque = NULL;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
431
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
432 r = inflateInit(&z);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
433 switch (r) {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
434 case Z_OK:
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
435 break;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
436 case Z_MEM_ERROR:
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
437 id3_error(frame->fr_owner, "zlib - no memory");
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
438 goto Error_init;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
439 case Z_VERSION_ERROR:
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
440 id3_error(frame->fr_owner, "zlib - invalid version");
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
441 goto Error_init;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
442 default:
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
443 id3_error(frame->fr_owner, "zlib - unknown error");
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
444 goto Error_init;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
445 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
446
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
447 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
448 * Decompress frame.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
449 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
450 z.next_out = frame->fr_data_z;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
451 z.avail_out = frame->fr_size_z;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
452 r = inflate(&z, Z_SYNC_FLUSH);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
453 switch (r) {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
454 case Z_STREAM_END:
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
455 break;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
456 case Z_OK:
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
457 if (z.avail_in == 0)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
458 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
459 * This should not be possible with a correct stream.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
460 * We will be nice however, and try to go on.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
461 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
462 break;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
463 id3_error(frame->fr_owner, "zlib - buffer exhausted");
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
464 goto Error_inflate;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
465 default:
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
466 id3_error(frame->fr_owner, "zlib - unknown error");
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
467 goto Error_inflate;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
468 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
469
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
470 r = inflateEnd(&z);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
471 if (r != Z_OK)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
472 id3_error(frame->fr_owner, "zlib - inflateEnd error");
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
473
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
474 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
475 * Null-terminate text frames.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
476 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
477 if (id3_frame_is_text(frame)) {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
478 ((char *) frame->fr_data_z)[frame->fr_size_z] = 0;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
479 ((char *) frame->fr_data_z)[frame->fr_size_z + 1] = 0;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
480 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
481 frame->fr_data = frame->fr_data_z;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
482 frame->fr_size = frame->fr_size_z + (id3_frame_is_text(frame) ? 2 : 0);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
483
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
484 return 0;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
485
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
486 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
487 * Cleanup code.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
488 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
489 Error_inflate:
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
490 r = inflateEnd(&z);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
491 Error_init:
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
492 g_free(frame->fr_data_z);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
493 frame->fr_data_z = NULL;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
494 #endif
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
495 return -1;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
496 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
497
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
498 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
499 * Function id3_decompress_frame(frame)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
500 *
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
501 * Check if frame is compressed, and uncompress if necessary.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
502 * Return 0 upon success, or -1 if an error occured.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
503 *
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
504 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
505 int
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
506 id3_decompress_frame(struct id3_frame *frame)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
507 {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
508 if (!(frame->fr_flags & ID3_FHFLAG_COMPRESS))
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
509 /* Frame not compressed */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
510 return 0;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
511 if (frame->fr_data_z)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
512 /* Frame already decompressed */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
513 return 0;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
514 /* Do decompression */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
515 return decompress_frame(frame);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
516 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
517
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
518
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
519 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
520 * Function id3_delete_frame (frame)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
521 *
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
522 * Remove frame from ID3 tag and release memory ocupied by it.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
523 *
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
524 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
525 int
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
526 id3_delete_frame(struct id3_frame *frame)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
527 {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
528 GList *list = frame->fr_owner->id3_frame;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
529 int ret;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
530
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
531 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
532 * Search for frame in list.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
533 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
534
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
535 if (g_list_find(list, frame) != NULL) {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
536 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
537 * Frame does not exist in frame list.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
538 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
539 ret = -1;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
540
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
541 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
542 else {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
543 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
544 * Remove frame from frame list.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
545 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
546 list = g_list_remove(list, frame);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
547 frame->fr_owner->id3_altered = 1;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
548 ret = 0;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
549 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
550
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
551 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
552 * Release memory occupied by frame.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
553 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
554 if (frame->fr_raw_data)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
555 g_free(frame->fr_raw_data);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
556 if (frame->fr_data_z)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
557 g_free(frame->fr_data_z);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
558 g_free(frame);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
559
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
560 return ret;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
561 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
562
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
563
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
564 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
565 * Function id3_add_frame (id3, type)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
566 *
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
567 * Add a new frame to the ID3 tag. Return a pointer to the new
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
568 * frame, or NULL if an error occured.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
569 *
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
570 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
571 struct id3_frame *
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
572 id3_add_frame(struct id3_tag *id3, guint32 type)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
573 {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
574 struct id3_frame *frame;
788
d15862899bbe [svn] - experimental ID32.2 fix
nenolod
parents: 787
diff changeset
575 int i;
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
576
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
577 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
578 * Allocate frame.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
579 */
787
e776161c16db [svn] - more fixes, sizeof *frame !($&($&(@!#$@#*&@!$# whoever wrote this code is an idiot
nenolod
parents: 785
diff changeset
580 frame = g_malloc0(sizeof(struct id3_frame));
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
581
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
582 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
583 * Initialize frame
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
584 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
585 frame->fr_owner = id3;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
586
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
587 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
588 * Try finding the correct frame descriptor.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
589 */
788
d15862899bbe [svn] - experimental ID32.2 fix
nenolod
parents: 787
diff changeset
590 for (i = 0; i < (int) sizeof(framedesc) / (int) sizeof(struct id3_framedesc); i++) {
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
591 if (framedesc[i].fd_id == type) {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
592 frame->fr_desc = &framedesc[i];
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
593 break;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
594 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
595 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
596
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
597 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
598 * Insert frame into linked list.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
599 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
600 id3->id3_frame = g_list_append(id3->id3_frame, frame);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
601 id3->id3_altered = 1;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
602
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
603 return frame;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
604 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
605
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
606
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
607 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
608 * Destroy all frames in an id3 tag, and free all data
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
609 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
610 void
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
611 id3_destroy_frames(struct id3_tag *id)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
612 {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
613 GList *node;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
614
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
615 for (node = id->id3_frame; node != NULL; node = node->next) {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
616 struct id3_frame *frame = node->data;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
617 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
618 * Release memory occupied by frame.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
619 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
620 if (frame->fr_raw_data)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
621 g_free(frame->fr_raw_data);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
622 if (frame->fr_data_z)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
623 g_free(frame->fr_data_z);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
624 g_free(frame);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
625 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
626 g_list_free(id->id3_frame);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
627 id->id3_frame = NULL;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
628 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
629
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
630 static int
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
631 id3_frame_extra_headers(struct id3_frame *frame)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
632 {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
633 int retv = 0;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
634 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
635 * If frame is encrypted, we have four extra bytes in the
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
636 * header.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
637 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
638 if (frame->fr_flags & ID3_FHFLAG_COMPRESS)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
639 retv += 4;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
640 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
641 * If frame is encrypted, we have one extra byte in the
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
642 * header.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
643 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
644 if (frame->fr_flags & ID3_FHFLAG_ENCRYPT)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
645 retv += 1;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
646
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
647 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
648 * If frame has grouping identity, we have one extra byte in
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
649 * the header.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
650 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
651 if (frame->fr_flags & ID3_FHFLAG_GROUP)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
652 retv += 1;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
653
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
654 return retv;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
655 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
656
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
657 static void *
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
658 id3_frame_get_dataptr(struct id3_frame *frame)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
659 {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
660 char *ptr = frame->fr_raw_data;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
661
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
662 ptr += id3_frame_extra_headers(frame);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
663
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
664 return ptr;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
665 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
666
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
667 static int
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
668 id3_frame_get_size(struct id3_frame *frame)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
669 {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
670 return frame->fr_raw_size - id3_frame_extra_headers(frame);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
671 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
672
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
673 void
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
674 id3_frame_clear_data(struct id3_frame *frame)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
675 {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
676 if (frame->fr_raw_data)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
677 g_free(frame->fr_raw_data);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
678 if (frame->fr_data_z)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
679 g_free(frame->fr_data_z);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
680 frame->fr_raw_data = NULL;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
681 frame->fr_raw_size = 0;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
682 frame->fr_data = NULL;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
683 frame->fr_size = 0;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
684 frame->fr_data_z = NULL;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
685 frame->fr_size_z = 0;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
686 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
687
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
688 static guint32
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
689 find_v24_id(guint32 v22)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
690 {
788
d15862899bbe [svn] - experimental ID32.2 fix
nenolod
parents: 787
diff changeset
691 int i;
d15862899bbe [svn] - experimental ID32.2 fix
nenolod
parents: 787
diff changeset
692 for (i = 0; i < (int) sizeof(framedesc22) / (int) sizeof(struct id3_framedesc22); i++)
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
693 if (framedesc22[i].fd_v22 == v22)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
694 return framedesc22[i].fd_v24;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
695
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
696 return 0;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
697 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
698
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
699 static int
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
700 id3_read_frame_v22(struct id3_tag *id3)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
701 {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
702 struct id3_frame *frame;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
703 guint32 id, idv24;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
704 char *buf;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
705 int size;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
706
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
707 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
708 * Read frame header.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
709 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
710 buf = id3->id3_read(id3, NULL, ID3_FRAMEHDR_SIZE_22);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
711 if (buf == NULL)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
712 return -1;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
713
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
714 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
715 * If we encounter an invalid frame id, we assume that there
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
716 * is some. We just skip the rest of the ID3 tag.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
717 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
718 if (!((buf[0] >= '0' && buf[0] <= '9')
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
719 || (buf[0] >= 'A' && buf[0] <= 'Z'))) {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
720 id3->id3_seek(id3, id3->id3_tagsize - id3->id3_pos);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
721 return 0;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
722 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
723
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
724 id = ID3_FRAME_ID_22(buf[0], buf[1], buf[2]);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
725 size = buf[3] << 16 | buf[4] << 8 | buf[5];
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
726
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
727 if ((idv24 = find_v24_id(id)) == 0) {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
728 if (id3->id3_seek(id3, size) < 0)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
729 return -1;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
730 return 0;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
731 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
732
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
733 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
734 * Allocate frame.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
735 */
785
20a62ae86b6e [svn] - some compilers couldn't figure the original call out, so put a struct infront of it
nenolod
parents: 784
diff changeset
736 frame = g_malloc0(sizeof(struct id3_frame));
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
737
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
738 frame->fr_owner = id3;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
739 frame->fr_raw_size = size;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
740 if (frame->fr_raw_size < 0 || frame->fr_raw_size > 1000000) {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
741 g_free(frame);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
742 return -1;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
743 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
744
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
745 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
746 * Initialize frame.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
747 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
748 frame->fr_desc = find_frame_description(idv24);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
749
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
750 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
751 * We allocate 2 extra bytes. This simplifies retrieval of
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
752 * text strings.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
753 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
754 frame->fr_raw_data = g_malloc0(frame->fr_raw_size + 2);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
755 if (id3->id3_read(id3, frame->fr_raw_data, frame->fr_raw_size) == NULL) {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
756 g_free(frame->fr_raw_data);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
757 g_free(frame);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
758 return -1;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
759 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
760
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
761 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
762 * Insert frame into linked list.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
763 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
764 id3->id3_frame = g_list_append(id3->id3_frame, frame);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
765
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
766 frame->fr_data = frame->fr_raw_data;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
767 frame->fr_size = frame->fr_raw_size;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
768
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
769 return 0;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
770 }