Mercurial > audlegacy-plugins
annotate src/aac/mp4ff/mp4meta.c @ 679:c8dc00a58f0d trunk
[svn] - remove a bunch of pointless code. we don't do ID3 for raw AAC files at this time.
| author | nenolod |
|---|---|
| date | Tue, 20 Feb 2007 04:13:46 -0800 |
| parents | 5826c77f4acf |
| children | 22a470857579 |
| rev | line source |
|---|---|
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
1 /* |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
2 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
3 ** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
4 ** |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
5 ** This program is free software; you can redistribute it and/or modify |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
6 ** it under the terms of the GNU General Public License as published by |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
7 ** the Free Software Foundation; either version 2 of the License, or |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
8 ** (at your option) any later version. |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
9 ** |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
10 ** This program is distributed in the hope that it will be useful, |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
11 ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
12 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
13 ** GNU General Public License for more details. |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
14 ** |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
15 ** You should have received a copy of the GNU General Public License |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
16 ** along with this program; if not, write to the Free Software |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
17 ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
18 ** |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
19 ** Any non-GPL usage of this software or parts of this software is strictly |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
20 ** forbidden. |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
21 ** |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
22 ** Commercial non-GPL licensing of this software is possible. |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
23 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
24 ** |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
25 ** $Id: mp4meta.c,v 1.13 2004/01/11 15:52:18 menno Exp $ |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
26 **/ |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
27 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
28 #ifdef USE_TAGGING |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
29 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
30 #include <stdlib.h> |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
31 #include <stdio.h> |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
32 #include <string.h> |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
33 #include "mp4ffint.h" |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
34 |
|
451
5826c77f4acf
[svn] - various overflow and security-related fixes from XMMS2 (mainly Juho Vaha-Herttua, et al)
nenolod
parents:
12
diff
changeset
|
35 int32_t mp4ff_tag_add_field_len(mp4ff_metadata_t *tags, const char *item, const char *value, uint32_t valuelen) |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
36 { |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
37 void *backup = (void *)tags->tags; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
38 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
39 if (!item || (item && !*item) || !value) return 0; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
40 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
41 tags->tags = (mp4ff_tag_t*)realloc(tags->tags, (tags->count+1) * sizeof(mp4ff_tag_t)); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
42 if (!tags->tags) |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
43 { |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
44 if (backup) free(backup); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
45 return 0; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
46 } else { |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
47 tags->tags[tags->count].item = strdup(item); |
|
451
5826c77f4acf
[svn] - various overflow and security-related fixes from XMMS2 (mainly Juho Vaha-Herttua, et al)
nenolod
parents:
12
diff
changeset
|
48 |
|
5826c77f4acf
[svn] - various overflow and security-related fixes from XMMS2 (mainly Juho Vaha-Herttua, et al)
nenolod
parents:
12
diff
changeset
|
49 /* ugly hack to make covers work */ |
|
5826c77f4acf
[svn] - various overflow and security-related fixes from XMMS2 (mainly Juho Vaha-Herttua, et al)
nenolod
parents:
12
diff
changeset
|
50 tags->tags[tags->count].value = malloc(valuelen+1); |
|
5826c77f4acf
[svn] - various overflow and security-related fixes from XMMS2 (mainly Juho Vaha-Herttua, et al)
nenolod
parents:
12
diff
changeset
|
51 memcpy(tags->tags[tags->count].value, value, valuelen); |
|
5826c77f4acf
[svn] - various overflow and security-related fixes from XMMS2 (mainly Juho Vaha-Herttua, et al)
nenolod
parents:
12
diff
changeset
|
52 tags->tags[tags->count].value[valuelen] = '\0'; |
|
5826c77f4acf
[svn] - various overflow and security-related fixes from XMMS2 (mainly Juho Vaha-Herttua, et al)
nenolod
parents:
12
diff
changeset
|
53 |
|
5826c77f4acf
[svn] - various overflow and security-related fixes from XMMS2 (mainly Juho Vaha-Herttua, et al)
nenolod
parents:
12
diff
changeset
|
54 tags->tags[tags->count].value_length = valuelen; |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
55 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
56 if (!tags->tags[tags->count].item || !tags->tags[tags->count].value) |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
57 { |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
58 if (!tags->tags[tags->count].item) free (tags->tags[tags->count].item); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
59 if (!tags->tags[tags->count].value) free (tags->tags[tags->count].value); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
60 tags->tags[tags->count].item = NULL; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
61 tags->tags[tags->count].value = NULL; |
|
451
5826c77f4acf
[svn] - various overflow and security-related fixes from XMMS2 (mainly Juho Vaha-Herttua, et al)
nenolod
parents:
12
diff
changeset
|
62 tags->tags[tags->count].value_length = 0; |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
63 return 0; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
64 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
65 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
66 tags->count++; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
67 return 1; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
68 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
69 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
70 |
|
451
5826c77f4acf
[svn] - various overflow and security-related fixes from XMMS2 (mainly Juho Vaha-Herttua, et al)
nenolod
parents:
12
diff
changeset
|
71 int32_t mp4ff_tag_add_field(mp4ff_metadata_t *tags, const char *item, const char *value) |
|
5826c77f4acf
[svn] - various overflow and security-related fixes from XMMS2 (mainly Juho Vaha-Herttua, et al)
nenolod
parents:
12
diff
changeset
|
72 { |
|
5826c77f4acf
[svn] - various overflow and security-related fixes from XMMS2 (mainly Juho Vaha-Herttua, et al)
nenolod
parents:
12
diff
changeset
|
73 return mp4ff_tag_add_field_len(tags, item, value, strlen(value)); |
|
5826c77f4acf
[svn] - various overflow and security-related fixes from XMMS2 (mainly Juho Vaha-Herttua, et al)
nenolod
parents:
12
diff
changeset
|
74 } |
|
5826c77f4acf
[svn] - various overflow and security-related fixes from XMMS2 (mainly Juho Vaha-Herttua, et al)
nenolod
parents:
12
diff
changeset
|
75 |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
76 int32_t mp4ff_tag_set_field(mp4ff_metadata_t *tags, const char *item, const char *value) |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
77 { |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
78 unsigned int i; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
79 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
80 if (!item || (item && !*item) || !value) return 0; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
81 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
82 for (i = 0; i < tags->count; i++) |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
83 { |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
84 if (!stricmp(tags->tags[i].item, item)) |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
85 { |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
86 free(tags->tags[i].value); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
87 tags->tags[i].value = strdup(value); |
|
451
5826c77f4acf
[svn] - various overflow and security-related fixes from XMMS2 (mainly Juho Vaha-Herttua, et al)
nenolod
parents:
12
diff
changeset
|
88 tags->tags[i].value_length = strlen(value); |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
89 return 1; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
90 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
91 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
92 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
93 return mp4ff_tag_add_field(tags, item, value); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
94 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
95 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
96 int32_t mp4ff_tag_delete(mp4ff_metadata_t *tags) |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
97 { |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
98 uint32_t i; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
99 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
100 for (i = 0; i < tags->count; i++) |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
101 { |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
102 if (tags->tags[i].item) free(tags->tags[i].item); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
103 if (tags->tags[i].value) free(tags->tags[i].value); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
104 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
105 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
106 if (tags->tags) free(tags->tags); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
107 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
108 tags->tags = NULL; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
109 tags->count = 0; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
110 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
111 return 0; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
112 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
113 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
114 const char* ID3v1GenreList[] = { |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
115 "Blues", "Classic Rock", "Country", "Dance", "Disco", "Funk", |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
116 "Grunge", "Hip-Hop", "Jazz", "Metal", "New Age", "Oldies", |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
117 "Other", "Pop", "R&B", "Rap", "Reggae", "Rock", |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
118 "Techno", "Industrial", "Alternative", "Ska", "Death Metal", "Pranks", |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
119 "Soundtrack", "Euro-Techno", "Ambient", "Trip-Hop", "Vocal", "Jazz+Funk", |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
120 "Fusion", "Trance", "Classical", "Instrumental", "Acid", "House", |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
121 "Game", "Sound Clip", "Gospel", "Noise", "AlternRock", "Bass", |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
122 "Soul", "Punk", "Space", "Meditative", "Instrumental Pop", "Instrumental Rock", |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
123 "Ethnic", "Gothic", "Darkwave", "Techno-Industrial", "Electronic", "Pop-Folk", |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
124 "Eurodance", "Dream", "Southern Rock", "Comedy", "Cult", "Gangsta", |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
125 "Top 40", "Christian Rap", "Pop/Funk", "Jungle", "Native American", "Cabaret", |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
126 "New Wave", "Psychadelic", "Rave", "Showtunes", "Trailer", "Lo-Fi", |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
127 "Tribal", "Acid Punk", "Acid Jazz", "Polka", "Retro", "Musical", |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
128 "Rock & Roll", "Hard Rock", "Folk", "Folk/Rock", "National Folk", "Swing", |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
129 "Fast-Fusion", "Bebob", "Latin", "Revival", "Celtic", "Bluegrass", "Avantgarde", |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
130 "Gothic Rock", "Progressive Rock", "Psychedelic Rock", "Symphonic Rock", "Slow Rock", "Big Band", |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
131 "Chorus", "Easy Listening", "Acoustic", "Humour", "Speech", "Chanson", |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
132 "Opera", "Chamber Music", "Sonata", "Symphony", "Booty Bass", "Primus", |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
133 "Porn Groove", "Satire", "Slow Jam", "Club", "Tango", "Samba", |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
134 "Folklore", "Ballad", "Power Ballad", "Rhythmic Soul", "Freestyle", "Duet", |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
135 "Punk Rock", "Drum Solo", "A capella", "Euro-House", "Dance Hall", |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
136 "Goa", "Drum & Bass", "Club House", "Hardcore", "Terror", |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
137 "Indie", "BritPop", "NegerPunk", "Polsk Punk", "Beat", |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
138 "Christian Gangsta", "Heavy Metal", "Black Metal", "Crossover", "Contemporary C", |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
139 "Christian Rock", "Merengue", "Salsa", "Thrash Metal", "Anime", "JPop", |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
140 "SynthPop", |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
141 }; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
142 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
143 uint32_t mp4ff_meta_genre_to_index(const char * genrestr) |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
144 { |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
145 unsigned n; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
146 for(n=0;n<sizeof(ID3v1GenreList)/sizeof(ID3v1GenreList[0]);n++) |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
147 { |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
148 if (!stricmp(genrestr,ID3v1GenreList[n])) return n+1; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
149 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
150 return 0; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
151 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
152 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
153 const char * mp4ff_meta_index_to_genre(uint32_t idx) |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
154 { |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
155 if (idx>0 && idx<=sizeof(ID3v1GenreList)/sizeof(ID3v1GenreList[0])) |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
156 { |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
157 return ID3v1GenreList[idx-1]; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
158 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
159 else |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
160 { |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
161 return 0; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
162 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
163 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
164 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
165 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
166 int32_t TrackToString(char** str, const uint16_t track, const uint16_t totalTracks) |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
167 { |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
168 char temp[32]; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
169 sprintf(temp, "%.5u of %.5u", track, totalTracks); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
170 *str = strdup(temp); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
171 return 0; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
172 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
173 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
174 int32_t mp4ff_set_metadata_name(mp4ff_t *f, const uint8_t atom_type, unsigned char **name) |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
175 { |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
176 char *tag_names[] = { |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
177 "unknown", "title", "artist", "writer", "album", |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
178 "date", "tool", "comment", "genre", "track", |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
179 "disc", "compilation", "genre", "tempo", "cover" |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
180 }; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
181 uint8_t tag_idx = 0; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
182 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
183 switch (atom_type) |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
184 { |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
185 case ATOM_TITLE: tag_idx = 1; break; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
186 case ATOM_ARTIST: tag_idx = 2; break; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
187 case ATOM_WRITER: tag_idx = 3; break; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
188 case ATOM_ALBUM: tag_idx = 4; break; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
189 case ATOM_DATE: tag_idx = 5; break; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
190 case ATOM_TOOL: tag_idx = 6; break; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
191 case ATOM_COMMENT: tag_idx = 7; break; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
192 case ATOM_GENRE1: tag_idx = 8; break; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
193 case ATOM_TRACK: tag_idx = 9; break; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
194 case ATOM_DISC: tag_idx = 10; break; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
195 case ATOM_COMPILATION: tag_idx = 11; break; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
196 case ATOM_GENRE2: tag_idx = 12; break; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
197 case ATOM_TEMPO: tag_idx = 13; break; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
198 case ATOM_COVER: tag_idx = 14; break; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
199 default: tag_idx = 0; break; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
200 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
201 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
202 *name = (unsigned char*)strdup(tag_names[tag_idx]); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
203 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
204 return 0; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
205 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
206 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
207 int32_t mp4ff_parse_tag(mp4ff_t *f, const uint8_t parent_atom_type, const int32_t size) |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
208 { |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
209 uint8_t atom_type; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
210 uint8_t header_size = 0; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
211 uint64_t subsize, sumsize = 0; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
212 unsigned char * name = NULL; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
213 unsigned char * data = NULL; |
|
451
5826c77f4acf
[svn] - various overflow and security-related fixes from XMMS2 (mainly Juho Vaha-Herttua, et al)
nenolod
parents:
12
diff
changeset
|
214 uint32_t datalen = 0; |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
215 uint32_t done = 0; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
216 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
217 while (sumsize < size) |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
218 { |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
219 uint64_t destpos; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
220 subsize = mp4ff_atom_read_header(f, &atom_type, &header_size); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
221 destpos = mp4ff_position(f)+subsize-header_size; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
222 if (!done) |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
223 { |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
224 if (atom_type == ATOM_DATA) |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
225 { |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
226 mp4ff_read_char(f); /* version */ |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
227 mp4ff_read_int24(f); /* flags */ |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
228 mp4ff_read_int32(f); /* reserved */ |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
229 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
230 /* some need special attention */ |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
231 if (parent_atom_type == ATOM_GENRE2 || parent_atom_type == ATOM_TEMPO) |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
232 { |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
233 if (subsize - header_size >= 8 + 2) |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
234 { |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
235 uint16_t val = mp4ff_read_int16(f); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
236 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
237 if (parent_atom_type == ATOM_TEMPO) |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
238 { |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
239 char temp[16]; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
240 sprintf(temp, "%.5u BPM", val); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
241 mp4ff_tag_add_field(&(f->tags), "tempo", temp); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
242 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
243 else |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
244 { |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
245 const char * temp = mp4ff_meta_index_to_genre(val); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
246 if (temp) |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
247 { |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
248 mp4ff_tag_add_field(&(f->tags), "genre", temp); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
249 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
250 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
251 done = 1; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
252 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
253 } else if (parent_atom_type == ATOM_TRACK || parent_atom_type == ATOM_DISC) { |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
254 if (!done && subsize - header_size >= 8 + 8) |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
255 { |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
256 uint16_t index,total; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
257 char temp[32]; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
258 mp4ff_read_int16(f); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
259 index = mp4ff_read_int16(f); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
260 total = mp4ff_read_int16(f); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
261 mp4ff_read_int16(f); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
262 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
263 sprintf(temp,"%d",index); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
264 mp4ff_tag_add_field(&(f->tags), parent_atom_type == ATOM_TRACK ? "track" : "disc", temp); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
265 if (total>0) |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
266 { |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
267 sprintf(temp,"%d",total); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
268 mp4ff_tag_add_field(&(f->tags), parent_atom_type == ATOM_TRACK ? "totaltracks" : "totaldiscs", temp); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
269 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
270 done = 1; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
271 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
272 } else |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
273 { |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
274 if (data) {free(data);data = NULL;} |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
275 data = mp4ff_read_string(f,(uint32_t)(subsize-(header_size+8))); |
|
451
5826c77f4acf
[svn] - various overflow and security-related fixes from XMMS2 (mainly Juho Vaha-Herttua, et al)
nenolod
parents:
12
diff
changeset
|
276 datalen = (uint32_t)(subsize-(header_size+8)); |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
277 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
278 } else if (atom_type == ATOM_NAME) { |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
279 if (!done) |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
280 { |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
281 mp4ff_read_char(f); /* version */ |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
282 mp4ff_read_int24(f); /* flags */ |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
283 if (name) free(name); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
284 name = mp4ff_read_string(f,(uint32_t)(subsize-(header_size+4))); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
285 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
286 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
287 mp4ff_set_position(f, destpos); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
288 sumsize += subsize; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
289 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
290 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
291 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
292 if (data) |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
293 { |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
294 if (!done) |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
295 { |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
296 if (name == NULL) mp4ff_set_metadata_name(f, parent_atom_type, &name); |
|
451
5826c77f4acf
[svn] - various overflow and security-related fixes from XMMS2 (mainly Juho Vaha-Herttua, et al)
nenolod
parents:
12
diff
changeset
|
297 if (name) mp4ff_tag_add_field_len(&(f->tags), name, data, datalen); |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
298 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
299 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
300 free(data); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
301 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
302 if (name) free(name); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
303 return 1; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
304 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
305 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
306 int32_t mp4ff_parse_metadata(mp4ff_t *f, const int32_t size) |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
307 { |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
308 uint64_t subsize, sumsize = 0; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
309 uint8_t atom_type; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
310 uint8_t header_size = 0; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
311 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
312 while (sumsize < size) |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
313 { |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
314 subsize = mp4ff_atom_read_header(f, &atom_type, &header_size); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
315 mp4ff_parse_tag(f, atom_type, (uint32_t)(subsize-header_size)); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
316 sumsize += subsize; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
317 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
318 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
319 return 0; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
320 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
321 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
322 /* find a metadata item by name */ |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
323 /* returns 0 if item found, 1 if no such item */ |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
324 int32_t mp4ff_meta_find_by_name(const mp4ff_t *f, const char *item, char **value) |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
325 { |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
326 uint32_t i; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
327 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
328 for (i = 0; i < f->tags.count; i++) |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
329 { |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
330 if (!stricmp(f->tags.tags[i].item, item)) |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
331 { |
|
451
5826c77f4acf
[svn] - various overflow and security-related fixes from XMMS2 (mainly Juho Vaha-Herttua, et al)
nenolod
parents:
12
diff
changeset
|
332 uint32_t value_length = f->tags.tags[i].value_length; |
|
5826c77f4acf
[svn] - various overflow and security-related fixes from XMMS2 (mainly Juho Vaha-Herttua, et al)
nenolod
parents:
12
diff
changeset
|
333 |
|
5826c77f4acf
[svn] - various overflow and security-related fixes from XMMS2 (mainly Juho Vaha-Herttua, et al)
nenolod
parents:
12
diff
changeset
|
334 if (value_length > 0) { |
|
5826c77f4acf
[svn] - various overflow and security-related fixes from XMMS2 (mainly Juho Vaha-Herttua, et al)
nenolod
parents:
12
diff
changeset
|
335 *value = malloc(value_length+1); |
|
5826c77f4acf
[svn] - various overflow and security-related fixes from XMMS2 (mainly Juho Vaha-Herttua, et al)
nenolod
parents:
12
diff
changeset
|
336 memcpy(*value, f->tags.tags[i].value, value_length+1); |
|
5826c77f4acf
[svn] - various overflow and security-related fixes from XMMS2 (mainly Juho Vaha-Herttua, et al)
nenolod
parents:
12
diff
changeset
|
337 return value_length; |
|
5826c77f4acf
[svn] - various overflow and security-related fixes from XMMS2 (mainly Juho Vaha-Herttua, et al)
nenolod
parents:
12
diff
changeset
|
338 } |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
339 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
340 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
341 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
342 *value = NULL; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
343 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
344 /* not found */ |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
345 return 0; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
346 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
347 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
348 int32_t mp4ff_meta_get_num_items(const mp4ff_t *f) |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
349 { |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
350 return f->tags.count; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
351 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
352 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
353 int32_t mp4ff_meta_get_by_index(const mp4ff_t *f, uint32_t index, |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
354 char **item, char **value) |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
355 { |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
356 if (index >= f->tags.count) |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
357 { |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
358 *item = NULL; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
359 *value = NULL; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
360 return 0; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
361 } else { |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
362 *item = strdup(f->tags.tags[index].item); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
363 *value = strdup(f->tags.tags[index].value); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
364 return 1; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
365 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
366 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
367 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
368 int32_t mp4ff_meta_get_title(const mp4ff_t *f, char **value) |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
369 { |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
370 return mp4ff_meta_find_by_name(f, "title", value); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
371 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
372 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
373 int32_t mp4ff_meta_get_artist(const mp4ff_t *f, char **value) |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
374 { |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
375 return mp4ff_meta_find_by_name(f, "artist", value); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
376 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
377 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
378 int32_t mp4ff_meta_get_writer(const mp4ff_t *f, char **value) |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
379 { |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
380 return mp4ff_meta_find_by_name(f, "writer", value); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
381 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
382 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
383 int32_t mp4ff_meta_get_album(const mp4ff_t *f, char **value) |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
384 { |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
385 return mp4ff_meta_find_by_name(f, "album", value); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
386 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
387 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
388 int32_t mp4ff_meta_get_date(const mp4ff_t *f, char **value) |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
389 { |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
390 return mp4ff_meta_find_by_name(f, "date", value); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
391 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
392 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
393 int32_t mp4ff_meta_get_tool(const mp4ff_t *f, char **value) |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
394 { |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
395 return mp4ff_meta_find_by_name(f, "tool", value); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
396 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
397 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
398 int32_t mp4ff_meta_get_comment(const mp4ff_t *f, char **value) |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
399 { |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
400 return mp4ff_meta_find_by_name(f, "comment", value); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
401 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
402 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
403 int32_t mp4ff_meta_get_genre(const mp4ff_t *f, char **value) |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
404 { |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
405 return mp4ff_meta_find_by_name(f, "genre", value); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
406 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
407 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
408 int32_t mp4ff_meta_get_track(const mp4ff_t *f, char **value) |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
409 { |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
410 return mp4ff_meta_find_by_name(f, "track", value); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
411 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
412 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
413 int32_t mp4ff_meta_get_disc(const mp4ff_t *f, char **value) |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
414 { |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
415 return mp4ff_meta_find_by_name(f, "disc", value); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
416 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
417 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
418 int32_t mp4ff_meta_get_compilation(const mp4ff_t *f, char **value) |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
419 { |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
420 return mp4ff_meta_find_by_name(f, "compilation", value); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
421 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
422 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
423 int32_t mp4ff_meta_get_tempo(const mp4ff_t *f, char **value) |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
424 { |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
425 return mp4ff_meta_find_by_name(f, "tempo", value); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
426 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
427 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
428 int32_t mp4ff_meta_get_coverart(const mp4ff_t *f, char **value) |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
429 { |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
430 return mp4ff_meta_find_by_name(f, "cover", value); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
431 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
432 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
433 #endif |
