1 /*
2  * Copyright 2008-2013 Various Authors
3  * Copyright 2005 Timo Hirvonen
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License as
7  * published by the Free Software Foundation; either version 2 of the
8  * License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef CMUS_ID3_H
20 #define CMUS_ID3_H
21 
22 #include <stdint.h>
23 
24 /* flags for id3_read_tags */
25 #define ID3_V1	(1 << 0)
26 #define ID3_V2	(1 << 1)
27 
28 enum id3_key {
29 	ID3_ARTIST,
30 	ID3_ALBUM,
31 	ID3_TITLE,
32 	ID3_DATE,
33 	ID3_ORIGINALDATE,
34 	ID3_GENRE,
35 	ID3_DISC,
36 	ID3_TRACK,
37 	ID3_ALBUMARTIST,
38 	ID3_ARTISTSORT,
39 	ID3_ALBUMARTISTSORT,
40 	ID3_ALBUMSORT,
41 	ID3_COMPILATION,
42 	ID3_RG_TRACK_GAIN,
43 	ID3_RG_TRACK_PEAK,
44 	ID3_RG_ALBUM_GAIN,
45 	ID3_RG_ALBUM_PEAK,
46 	ID3_COMPOSER,
47 	ID3_CONDUCTOR,
48 	ID3_LYRICIST,
49 	ID3_REMIXER,
50 	ID3_LABEL,
51 	ID3_PUBLISHER,
52 	ID3_SUBTITLE,
53 	ID3_COMMENT,
54 	ID3_MUSICBRAINZ_TRACKID,
55 	ID3_MEDIA,
56 	ID3_BPM,
57 
58 	NUM_ID3_KEYS
59 };
60 
61 struct id3tag {
62 	char v1[128];
63 	char *v2[NUM_ID3_KEYS];
64 
65 	unsigned int has_v1 : 1;
66 	unsigned int has_v2 : 1;
67 };
68 
69 extern const char * const id3_key_names[NUM_ID3_KEYS];
70 
71 int id3_tag_size(const char *buf, int buf_size);
72 
73 void id3_init(struct id3tag *id3);
74 void id3_free(struct id3tag *id3);
75 
76 int id3_read_tags(struct id3tag *id3, int fd, unsigned int flags);
77 char *id3_get_comment(struct id3tag *id3, enum id3_key key);
78 
79 char const *id3_get_genre(uint16_t id);
80 
81 #endif
82