summaryrefslogtreecommitdiff
path: root/apps/metadata.h
diff options
context:
space:
mode:
Diffstat (limited to 'apps/metadata.h')
-rw-r--r--apps/metadata.h219
1 files changed, 218 insertions, 1 deletions
diff --git a/apps/metadata.h b/apps/metadata.h
index c496f40914..b19098621c 100644
--- a/apps/metadata.h
+++ b/apps/metadata.h
@@ -23,11 +23,228 @@
23#define _METADATA_H 23#define _METADATA_H
24 24
25#include <stdbool.h> 25#include <stdbool.h>
26#include "file.h"
26#include "config.h" 27#include "config.h"
27#include "id3.h" 28
29
30/* Audio file types. */
31/* NOTE: The values of the AFMT_* items are used for the %fc tag in the WPS
32 - so new entries MUST be added to the end to maintain compatibility.
33 */
34enum
35{
36 AFMT_UNKNOWN = 0, /* Unknown file format */
37
38 /* start formats */
39
40 AFMT_MPA_L1, /* MPEG Audio layer 1 */
41 AFMT_MPA_L2, /* MPEG Audio layer 2 */
42 AFMT_MPA_L3, /* MPEG Audio layer 3 */
43
44#if CONFIG_CODEC == SWCODEC
45 AFMT_AIFF, /* Audio Interchange File Format */
46 AFMT_PCM_WAV, /* Uncompressed PCM in a WAV file */
47 AFMT_OGG_VORBIS, /* Ogg Vorbis */
48 AFMT_FLAC, /* FLAC */
49 AFMT_MPC, /* Musepack */
50 AFMT_A52, /* A/52 (aka AC3) audio */
51 AFMT_WAVPACK, /* WavPack */
52 AFMT_ALAC, /* Apple Lossless Audio Codec */
53 AFMT_AAC, /* Advanced Audio Coding (AAC) in M4A container */
54 AFMT_SHN, /* Shorten */
55 AFMT_SID, /* SID File Format */
56 AFMT_ADX, /* ADX File Format */
57 AFMT_NSF, /* NESM (NES Sound Format) */
58 AFMT_SPEEX, /* Ogg Speex speech */
59 AFMT_SPC, /* SPC700 save state */
60 AFMT_APE, /* Monkey's Audio (APE) */
61 AFMT_WMA, /* WMAV1/V2 in ASF */
62 AFMT_MOD, /* Amiga MOD File Format */
63 AFMT_SAP, /* Amiga 8Bit SAP Format */
64#endif
65
66 /* add new formats at any index above this line to have a sensible order -
67 specified array index inits are used */
68 /* format arrays defined in id3.c */
69
70 AFMT_NUM_CODECS,
71
72#if CONFIG_CODEC == SWCODEC && defined(HAVE_RECORDING)
73 /* masks to decompose parts */
74 CODEC_AFMT_MASK = 0x0fff,
75 CODEC_TYPE_MASK = 0x7000,
76
77 /* switch for specifying codec type when requesting a filename */
78 CODEC_TYPE_DECODER = (0 << 12), /* default */
79 CODEC_TYPE_ENCODER = (1 << 12),
80#endif /* CONFIG_CODEC == SWCODEC && defined(HAVE_RECORDING) */
81};
82
83#if CONFIG_CODEC == SWCODEC
84#define CODEC_EXTENSION "codec"
85
86#ifdef HAVE_RECORDING
87#define ENCODER_SUFFIX "_enc"
88enum rec_format_indexes
89{
90 __REC_FORMAT_START_INDEX = -1,
91
92 /* start formats */
93
94 REC_FORMAT_PCM_WAV,
95 REC_FORMAT_AIFF,
96 REC_FORMAT_WAVPACK,
97 REC_FORMAT_MPA_L3,
98
99 /* add new formats at any index above this line to have a sensible order -
100 specified array index inits are used
101 REC_FORMAT_CFG_NUM_BITS should allocate enough bits to hold the range
102 REC_FORMAT_CFG_VALUE_LIST should be in same order as indexes
103 */
104
105 REC_NUM_FORMATS,
106
107 REC_FORMAT_DEFAULT = REC_FORMAT_PCM_WAV,
108 REC_FORMAT_CFG_NUM_BITS = 2
109};
110
111#define REC_FORMAT_CFG_VAL_LIST "wave,aiff,wvpk,mpa3"
112
113/* get REC_FORMAT_* corresponding AFMT_* */
114extern const int rec_format_afmt[REC_NUM_FORMATS];
115/* get AFMT_* corresponding REC_FORMAT_* */
116extern const int afmt_rec_format[AFMT_NUM_CODECS];
117
118#define AFMT_ENTRY(label, root_fname, enc_root_fname, ext_list) \
119 { label, root_fname, enc_root_fname, ext_list }
120#else /* !HAVE_RECORDING */
121#define AFMT_ENTRY(label, root_fname, enc_root_fname, ext_list) \
122 { label, root_fname, ext_list }
123#endif /* HAVE_RECORDING */
124
125#else /* !SWCODEC */
126
127#define AFMT_ENTRY(label, root_fname, enc_root_fname, ext_list) \
128 { label, ext_list }
129#endif /* CONFIG_CODEC == SWCODEC */
130
131/** Database of audio formats **/
132/* record describing the audio format */
133struct afmt_entry
134{
135 char label[8]; /* format label */
136#if CONFIG_CODEC == SWCODEC
137 char *codec_root_fn; /* root codec filename (sans _enc and .codec) */
138#ifdef HAVE_RECORDING
139 char *codec_enc_root_fn; /* filename of encoder codec */
140#endif
141#endif
142 char *ext_list; /* double NULL terminated extension
143 list for type with the first as
144 the default for recording */
145};
146
147/* database of labels and codecs. add formats per above enum */
148extern const struct afmt_entry audio_formats[AFMT_NUM_CODECS];
149
150#define ID3V2_BUF_SIZE 300
151
152enum {
153 ID3_VER_1_0 = 1,
154 ID3_VER_1_1,
155 ID3_VER_2_2,
156 ID3_VER_2_3,
157 ID3_VER_2_4
158};
159
160struct mp3entry {
161 char path[MAX_PATH];
162 char* title;
163 char* artist;
164 char* album;
165 char* genre_string;
166 char* disc_string;
167 char* track_string;
168 char* year_string;
169 char* composer;
170 char* comment;
171 char* albumartist;
172 char* grouping;
173 int discnum;
174 int tracknum;
175 int version;
176 int layer;
177 int year;
178 unsigned char id3version;
179 unsigned int codectype;
180 unsigned int bitrate;
181 unsigned long frequency;
182 unsigned long id3v2len;
183 unsigned long id3v1len;
184 unsigned long first_frame_offset; /* Byte offset to first real MP3 frame.
185 Used for skipping leading garbage to
186 avoid gaps between tracks. */
187 unsigned long vbr_header_pos;
188 unsigned long filesize; /* without headers; in bytes */
189 unsigned long length; /* song length in ms */
190 unsigned long elapsed; /* ms played */
191
192 int lead_trim; /* Number of samples to skip at the beginning */
193 int tail_trim; /* Number of samples to remove from the end */
194
195 /* Added for Vorbis */
196 unsigned long samples; /* number of samples in track */
197
198 /* MP3 stream specific info */
199 unsigned long frame_count; /* number of frames in the file (if VBR) */
200
201 /* Used for A52/AC3 */
202 unsigned long bytesperframe; /* number of bytes per frame (if CBR) */
203
204 /* Xing VBR fields */
205 bool vbr;
206 bool has_toc; /* True if there is a VBR header in the file */
207 unsigned char toc[100]; /* table of contents */
208
209 /* these following two fields are used for local buffering */
210 char id3v2buf[ID3V2_BUF_SIZE];
211 char id3v1buf[4][92];
212
213 /* resume related */
214 unsigned long offset; /* bytes played */
215 int index; /* playlist index */
216
217 /* runtime database fields */
218 long tagcache_idx; /* 0=invalid, otherwise idx+1 */
219 int rating;
220 int score;
221 long playcount;
222 long lastplayed;
223 long playtime;
224
225 /* replaygain support */
226
227#if CONFIG_CODEC == SWCODEC
228 char* track_gain_string;
229 char* album_gain_string;
230 long track_gain; /* 7.24 signed fixed point. 0 for no gain. */
231 long album_gain;
232 long track_peak; /* 7.24 signed fixed point. 0 for no peak. */
233 long album_peak;
234#endif
235
236 /* Cuesheet support */
237 int cuesheet_type; /* 0: none, 1: external, 2: embedded */
238
239 /* Musicbrainz Track ID */
240 char* mb_track_id;
241};
28 242
29unsigned int probe_file_format(const char *filename); 243unsigned int probe_file_format(const char *filename);
30bool get_metadata(struct mp3entry* id3, int fd, const char* trackname); 244bool get_metadata(struct mp3entry* id3, int fd, const char* trackname);
245bool mp3info(struct mp3entry *entry, const char *filename);
246void adjust_mp3entry(struct mp3entry *entry, void *dest, const void *orig);
247void copy_mp3entry(struct mp3entry *dest, const struct mp3entry *orig);
31#if CONFIG_CODEC == SWCODEC 248#if CONFIG_CODEC == SWCODEC
32void strip_tags(int handle_id); 249void strip_tags(int handle_id);
33#endif 250#endif