annotate Plugins/Input/mpg123/id3_frame.c @ 61:fa848bd484d8 trunk

[svn] Move plugins to Plugins/
author nenolod
date Fri, 28 Oct 2005 22:58:11 -0700
parents
children d539e5c5f730
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
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
253 static struct id3_framedesc *
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
254 find_frame_description(guint32 id)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
255 {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
256 int i;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
257 for (i = 0; i < sizeof(framedesc) / sizeof(struct id3_framedesc); i++)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
258 if (framedesc[i].fd_id == id)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
259 return &framedesc[i];
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
260 return NULL;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
261 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
262
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
263
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
264 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
265 * Function id3_read_frame (id3)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
266 *
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
267 * Read next frame from the indicated ID3 tag. Return 0 upon
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
268 * success, or -1 if an error occured.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
269 *
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
270 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
271 int
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
272 id3_read_frame(struct id3_tag *id3)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
273 {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
274 struct id3_frame *frame;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
275 guint32 id;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
276 char *buf;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
277
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
278 if (id3->id3_version == 2)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
279 return id3_read_frame_v22(id3);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
280
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
281 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
282 * Read frame header.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
283 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
284 buf = id3->id3_read(id3, NULL, ID3_FRAMEHDR_SIZE);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
285 if (buf == NULL)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
286 return -1;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
287
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
288 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
289 * If we encounter an invalid frame id, we assume that there is
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
290 * some padding in the header. We just skip the rest of the ID3
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
291 * tag.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
292 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
293 if (!((buf[0] >= '0' && buf[0] <= '9')
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
294 || (buf[0] >= 'A' && buf[0] <= 'Z'))) {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
295 id3->id3_seek(id3, id3->id3_tagsize - id3->id3_pos);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
296 return 0;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
297 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
298 id = ID3_FRAME_ID(buf[0], buf[1], buf[2], buf[3]);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
299
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
300 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
301 * Allocate frame.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
302 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
303 frame = g_malloc0(sizeof(*frame));
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
304
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
305 frame->fr_owner = id3;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
306 /* FIXME v2.4.0 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
307 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
308 if (frame->fr_raw_size < 0 || frame->fr_raw_size > 1000000) {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
309 g_free(frame);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
310 return -1;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
311 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
312 frame->fr_flags = buf[8] << 8 | buf[9];
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
313
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
314 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
315 * Determine the type of the frame.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
316 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
317
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
318 frame->fr_desc = find_frame_description(id);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
319
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
320 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
321 * Check if frame had a valid id.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
322 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
323 if (frame->fr_desc == NULL) {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
324 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
325 * No. Ignore the frame.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
326 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
327 if (id3->id3_seek(id3, frame->fr_raw_size) < 0) {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
328 g_free(frame);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
329 return -1;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
330 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
331 return 0;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
332 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
333
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
334 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
335 * Initialize frame.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
336 */
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 * We allocate 2 extra bytes. This simplifies retrieval of
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
340 * text strings.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
341 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
342 frame->fr_raw_data = g_malloc0(frame->fr_raw_size + 2);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
343 if (id3->id3_read(id3, frame->fr_raw_data, frame->fr_raw_size) == NULL) {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
344 g_free(frame->fr_raw_data);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
345 g_free(frame);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
346 return -1;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
347 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
348
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
349 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
350 * Insert frame into linked list.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
351 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
352 id3->id3_frame = g_list_append(id3->id3_frame, frame);
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 * Check if frame is compressed using zlib.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
356 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
357 if (frame->fr_flags & ID3_FHFLAG_COMPRESS)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
358 return 0;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
359
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
360 frame->fr_data = id3_frame_get_dataptr(frame);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
361 frame->fr_size = id3_frame_get_size(frame);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
362
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
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
366
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
367 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
368 * Function id3_get_frame (id3, type, num)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
369 *
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
370 * Search in the list of frames for the ID3-tag, and return a frame
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
371 * of the indicated type. If tag contains several frames of the
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
372 * indicated type, the third argument tells which of the frames to
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
373 * return.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
374 *
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
375 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
376 struct id3_frame *
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
377 id3_get_frame(struct id3_tag *id3, guint32 type, int num)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
378 {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
379 GList *node;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
380
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
381 for (node = id3->id3_frame; node != NULL; node = node->next) {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
382 struct id3_frame *fr = node->data;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
383 if (fr->fr_desc && fr->fr_desc->fd_id == type) {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
384 if (--num <= 0)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
385 return fr;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
386 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
387 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
388 return NULL;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
389 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
390
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
391 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
392 * Function decompress_frame(frame)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
393 *
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
394 * Uncompress the indicated frame. Return 0 upon success, or -1 if
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
395 * an error occured.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
396 *
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
397 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
398 static int
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
399 decompress_frame(struct id3_frame *frame)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
400 {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
401 #ifdef HAVE_LIBZ
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
402 z_stream z;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
403 int r;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
404
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
405 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
406 * Fetch the size of the decompressed data.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
407 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
408 frame->fr_size_z = g_ntohl(*((guint32 *) frame->fr_raw_data));
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
409 if (frame->fr_size_z < 0 || frame->fr_size_z > 1000000)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
410 return -1;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
411
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
412 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
413 * Allocate memory to hold uncompressed frame.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
414 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
415 frame->fr_data_z = g_malloc(frame->fr_size_z +
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
416 (id3_frame_is_text(frame) ? 2 : 0));
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
417
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
418 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
419 * Initialize zlib.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
420 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
421 z.next_in = id3_frame_get_dataptr(frame);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
422 z.avail_in = id3_frame_get_size(frame);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
423 z.zalloc = NULL;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
424 z.zfree = NULL;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
425 z.opaque = NULL;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
426
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
427 r = inflateInit(&z);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
428 switch (r) {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
429 case Z_OK:
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
430 break;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
431 case Z_MEM_ERROR:
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
432 id3_error(frame->fr_owner, "zlib - no memory");
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
433 goto Error_init;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
434 case Z_VERSION_ERROR:
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
435 id3_error(frame->fr_owner, "zlib - invalid version");
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
436 goto Error_init;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
437 default:
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
438 id3_error(frame->fr_owner, "zlib - unknown error");
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
439 goto Error_init;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
440 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
441
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
442 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
443 * Decompress frame.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
444 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
445 z.next_out = frame->fr_data_z;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
446 z.avail_out = frame->fr_size_z;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
447 r = inflate(&z, Z_SYNC_FLUSH);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
448 switch (r) {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
449 case Z_STREAM_END:
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
450 break;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
451 case Z_OK:
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
452 if (z.avail_in == 0)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
453 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
454 * This should not be possible with a correct stream.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
455 * We will be nice however, and try to go on.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
456 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
457 break;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
458 id3_error(frame->fr_owner, "zlib - buffer exhausted");
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
459 goto Error_inflate;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
460 default:
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
461 id3_error(frame->fr_owner, "zlib - unknown error");
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
462 goto Error_inflate;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
463 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
464
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
465 r = inflateEnd(&z);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
466 if (r != Z_OK)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
467 id3_error(frame->fr_owner, "zlib - inflateEnd error");
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 * Null-terminate text frames.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
471 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
472 if (id3_frame_is_text(frame)) {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
473 ((char *) frame->fr_data_z)[frame->fr_size_z] = 0;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
474 ((char *) frame->fr_data_z)[frame->fr_size_z + 1] = 0;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
475 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
476 frame->fr_data = frame->fr_data_z;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
477 frame->fr_size = frame->fr_size_z + (id3_frame_is_text(frame) ? 2 : 0);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
478
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
479 return 0;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
480
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
481 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
482 * Cleanup code.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
483 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
484 Error_inflate:
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
485 r = inflateEnd(&z);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
486 Error_init:
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
487 g_free(frame->fr_data_z);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
488 frame->fr_data_z = NULL;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
489 #endif
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
490 return -1;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
491 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
492
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
493 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
494 * Function id3_decompress_frame(frame)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
495 *
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
496 * Check if frame is compressed, and uncompress if necessary.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
497 * Return 0 upon success, or -1 if an error occured.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
498 *
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
499 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
500 int
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
501 id3_decompress_frame(struct id3_frame *frame)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
502 {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
503 if (!(frame->fr_flags & ID3_FHFLAG_COMPRESS))
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
504 /* Frame not compressed */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
505 return 0;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
506 if (frame->fr_data_z)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
507 /* Frame already decompressed */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
508 return 0;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
509 /* Do decompression */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
510 return decompress_frame(frame);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
511 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
512
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
513
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
514 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
515 * Function id3_delete_frame (frame)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
516 *
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
517 * Remove frame from ID3 tag and release memory ocupied by it.
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 int
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
521 id3_delete_frame(struct id3_frame *frame)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
522 {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
523 GList *list = frame->fr_owner->id3_frame;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
524 int ret;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
525
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
526 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
527 * Search for frame in list.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
528 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
529
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
530 if (g_list_find(list, frame) != NULL) {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
531 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
532 * Frame does not exist in frame list.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
533 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
534 ret = -1;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
535
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
536 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
537 else {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
538 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
539 * Remove frame from frame list.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
540 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
541 list = g_list_remove(list, frame);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
542 frame->fr_owner->id3_altered = 1;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
543 ret = 0;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
544 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
545
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
546 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
547 * Release memory occupied by frame.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
548 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
549 if (frame->fr_raw_data)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
550 g_free(frame->fr_raw_data);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
551 if (frame->fr_data_z)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
552 g_free(frame->fr_data_z);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
553 g_free(frame);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
554
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
555 return ret;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
556 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
557
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
558
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
559 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
560 * Function id3_add_frame (id3, type)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
561 *
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
562 * Add a new frame to the ID3 tag. Return a pointer to the new
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
563 * frame, or NULL if an error occured.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
564 *
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
565 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
566 struct id3_frame *
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
567 id3_add_frame(struct id3_tag *id3, guint32 type)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
568 {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
569 struct id3_frame *frame;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
570 int i;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
571
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
572 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
573 * Allocate frame.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
574 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
575 frame = g_malloc0(sizeof(*frame));
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 * Initialize frame
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
579 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
580 frame->fr_owner = id3;
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 * Try finding the correct frame descriptor.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
584 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
585 for (i = 0; i < sizeof(framedesc) / sizeof(struct id3_framedesc); i++) {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
586 if (framedesc[i].fd_id == type) {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
587 frame->fr_desc = &framedesc[i];
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
588 break;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
589 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
590 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
591
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
592 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
593 * Insert frame into linked list.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
594 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
595 id3->id3_frame = g_list_append(id3->id3_frame, frame);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
596 id3->id3_altered = 1;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
597
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
598 return frame;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
599 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
600
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
601
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
602 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
603 * Destroy all frames in an id3 tag, and free all data
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
604 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
605 void
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
606 id3_destroy_frames(struct id3_tag *id)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
607 {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
608 GList *node;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
609
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
610 for (node = id->id3_frame; node != NULL; node = node->next) {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
611 struct id3_frame *frame = node->data;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
612 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
613 * Release memory occupied by frame.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
614 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
615 if (frame->fr_raw_data)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
616 g_free(frame->fr_raw_data);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
617 if (frame->fr_data_z)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
618 g_free(frame->fr_data_z);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
619 g_free(frame);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
620 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
621 g_list_free(id->id3_frame);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
622 id->id3_frame = NULL;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
623 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
624
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
625 static int
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
626 id3_frame_extra_headers(struct id3_frame *frame)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
627 {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
628 int retv = 0;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
629 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
630 * If frame is encrypted, we have four extra bytes in the
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
631 * header.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
632 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
633 if (frame->fr_flags & ID3_FHFLAG_COMPRESS)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
634 retv += 4;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
635 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
636 * If frame is encrypted, we have one extra byte in the
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
637 * header.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
638 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
639 if (frame->fr_flags & ID3_FHFLAG_ENCRYPT)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
640 retv += 1;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
641
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
642 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
643 * If frame has grouping identity, we have one extra byte in
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
644 * the header.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
645 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
646 if (frame->fr_flags & ID3_FHFLAG_GROUP)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
647 retv += 1;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
648
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
649 return retv;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
650 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
651
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
652 static void *
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
653 id3_frame_get_dataptr(struct id3_frame *frame)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
654 {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
655 char *ptr = frame->fr_raw_data;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
656
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
657 ptr += id3_frame_extra_headers(frame);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
658
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
659 return ptr;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
660 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
661
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
662 static int
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
663 id3_frame_get_size(struct id3_frame *frame)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
664 {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
665 return frame->fr_raw_size - id3_frame_extra_headers(frame);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
666 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
667
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
668 void
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
669 id3_frame_clear_data(struct id3_frame *frame)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
670 {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
671 if (frame->fr_raw_data)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
672 g_free(frame->fr_raw_data);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
673 if (frame->fr_data_z)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
674 g_free(frame->fr_data_z);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
675 frame->fr_raw_data = NULL;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
676 frame->fr_raw_size = 0;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
677 frame->fr_data = NULL;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
678 frame->fr_size = 0;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
679 frame->fr_data_z = NULL;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
680 frame->fr_size_z = 0;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
681 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
682
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
683 static guint32
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
684 find_v24_id(guint32 v22)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
685 {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
686 int i;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
687 for (i = 0; i < sizeof(framedesc22) / sizeof(framedesc22[0]); i++)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
688 if (framedesc22[i].fd_v22 == v22)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
689 return framedesc22[i].fd_v24;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
690
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
691 return 0;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
692 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
693
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
694 static int
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
695 id3_read_frame_v22(struct id3_tag *id3)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
696 {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
697 struct id3_frame *frame;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
698 guint32 id, idv24;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
699 char *buf;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
700 int size;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
701
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
702 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
703 * Read frame header.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
704 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
705 buf = id3->id3_read(id3, NULL, ID3_FRAMEHDR_SIZE_22);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
706 if (buf == NULL)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
707 return -1;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
708
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
709 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
710 * If we encounter an invalid frame id, we assume that there
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
711 * is some. We just skip the rest of the ID3 tag.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
712 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
713 if (!((buf[0] >= '0' && buf[0] <= '9')
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
714 || (buf[0] >= 'A' && buf[0] <= 'Z'))) {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
715 id3->id3_seek(id3, id3->id3_tagsize - id3->id3_pos);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
716 return 0;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
717 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
718
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
719 id = ID3_FRAME_ID_22(buf[0], buf[1], buf[2]);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
720 size = buf[3] << 16 | buf[4] << 8 | buf[5];
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
721
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
722 if ((idv24 = find_v24_id(id)) == 0) {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
723 if (id3->id3_seek(id3, size) < 0)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
724 return -1;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
725 return 0;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
726 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
727
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
728 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
729 * Allocate frame.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
730 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
731 frame = g_malloc0(sizeof(*frame));
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
732
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
733 frame->fr_owner = id3;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
734 frame->fr_raw_size = size;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
735 if (frame->fr_raw_size < 0 || frame->fr_raw_size > 1000000) {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
736 g_free(frame);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
737 return -1;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
738 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
739
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
740 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
741 * Initialize frame.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
742 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
743 frame->fr_desc = find_frame_description(idv24);
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 * We allocate 2 extra bytes. This simplifies retrieval of
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
747 * text strings.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
748 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
749 frame->fr_raw_data = g_malloc0(frame->fr_raw_size + 2);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
750 if (id3->id3_read(id3, frame->fr_raw_data, frame->fr_raw_size) == NULL) {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
751 g_free(frame->fr_raw_data);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
752 g_free(frame);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
753 return -1;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
754 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
755
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
756 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
757 * Insert frame into linked list.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
758 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
759 id3->id3_frame = g_list_append(id3->id3_frame, frame);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
760
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
761 frame->fr_data = frame->fr_raw_data;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
762 frame->fr_size = frame->fr_raw_size;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
763
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
764 return 0;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
765 }