1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2002 by Daniel Stenberg
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
26 /* Audio file types. */
27 /* NOTE: The values of the AFMT_* items are used for the %fc tag in the WPS
28 - so new entries MUST be added to the end to maintain compatibility.
32 AFMT_UNKNOWN
= 0, /* Unknown file format */
36 AFMT_MPA_L1
, /* MPEG Audio layer 1 */
37 AFMT_MPA_L2
, /* MPEG Audio layer 2 */
38 AFMT_MPA_L3
, /* MPEG Audio layer 3 */
40 #if CONFIG_CODEC == SWCODEC
41 AFMT_AIFF
, /* Audio Interchange File Format */
42 AFMT_PCM_WAV
, /* Uncompressed PCM in a WAV file */
43 AFMT_OGG_VORBIS
, /* Ogg Vorbis */
45 AFMT_MPC
, /* Musepack */
46 AFMT_A52
, /* A/52 (aka AC3) audio */
47 AFMT_WAVPACK
, /* WavPack */
48 AFMT_ALAC
, /* Apple Lossless Audio Codec */
49 AFMT_AAC
, /* Advanced Audio Coding (AAC) in M4A container */
50 AFMT_SHN
, /* Shorten */
51 AFMT_SID
, /* SID File Format */
52 AFMT_ADX
, /* ADX File Format */
53 AFMT_NSF
, /* NESM (NES Sound Format) */
54 AFMT_SPEEX
, /* Ogg Speex speech */
55 AFMT_SPC
, /* SPC700 save state */
58 /* add new formats at any index above this line to have a sensible order -
59 specified array index inits are used */
60 /* format arrays defined in id3.c */
64 #if CONFIG_CODEC == SWCODEC && defined(HAVE_RECORDING)
65 /* masks to decompose parts */
66 CODEC_AFMT_MASK
= 0x0fff,
67 CODEC_TYPE_MASK
= 0x7000,
69 /* switch for specifying codec type when requesting a filename */
70 CODEC_TYPE_DECODER
= (0 << 12), /* default */
71 CODEC_TYPE_ENCODER
= (1 << 12),
72 #endif /* CONFIG_CODEC == SWCODEC && defined(HAVE_RECORDING) */
75 #if CONFIG_CODEC == SWCODEC
76 #define CODEC_EXTENSION "codec"
79 #define ENCODER_SUFFIX "_enc"
80 enum rec_format_indexes
82 __REC_FORMAT_START_INDEX
= -1,
91 /* add new formats at any index above this line to have a sensible order -
92 specified array index inits are used
93 REC_FORMAT_CFG_NUM_BITS should allocate enough bits to hold the range
94 REC_FORMAT_CFG_VALUE_LIST should be in same order as indexes
99 REC_FORMAT_DEFAULT
= REC_FORMAT_PCM_WAV
,
100 REC_FORMAT_CFG_NUM_BITS
= 2
103 #define REC_FORMAT_CFG_VAL_LIST "wave,aiff,wvpk,mpa3"
105 /* get REC_FORMAT_* corresponding AFMT_* */
106 extern const int rec_format_afmt
[REC_NUM_FORMATS
];
107 /* get AFMT_* corresponding REC_FORMAT_* */
108 extern const int afmt_rec_format
[AFMT_NUM_CODECS
];
110 #define AFMT_ENTRY(label, root_fname, enc_root_fname, ext_list) \
111 { label, root_fname, enc_root_fname, ext_list }
112 #else /* !HAVE_RECORDING */
113 #define AFMT_ENTRY(label, root_fname, enc_root_fname, ext_list) \
114 { label, root_fname, ext_list }
115 #endif /* HAVE_RECORDING */
118 #define AFMT_ENTRY(label, root_fname, enc_root_fname, ext_list) \
120 #endif /* CONFIG_CODEC == SWCODEC */
122 /* record describing the audio format */
125 char label
[8]; /* format label */
126 #if CONFIG_CODEC == SWCODEC
127 char *codec_root_fn
; /* root codec filename (sans _enc and .codec) */
128 #ifdef HAVE_RECORDING
129 char *codec_enc_root_fn
; /* filename of encoder codec */
132 char *ext_list
; /* double NULL terminated extension
133 list for type with the first as
134 the default for recording */
137 /* database of labels and codecs. add formats per above enum */
138 extern const struct afmt_entry audio_formats
[AFMT_NUM_CODECS
];
155 unsigned char id3version
;
156 unsigned int codectype
;
157 unsigned int bitrate
;
158 unsigned long frequency
;
159 unsigned long id3v2len
;
160 unsigned long id3v1len
;
161 unsigned long first_frame_offset
; /* Byte offset to first real MP3 frame.
162 Used for skipping leading garbage to
163 avoid gaps between tracks. */
164 unsigned long vbr_header_pos
;
165 unsigned long filesize
; /* without headers; in bytes */
166 unsigned long length
; /* song length in ms */
167 unsigned long elapsed
; /* ms played */
169 int lead_trim
; /* Number of samples to skip at the beginning */
170 int tail_trim
; /* Number of samples to remove from the end */
172 /* Added for Vorbis */
173 unsigned long samples
; /* number of samples in track */
175 /* MP3 stream specific info */
176 unsigned long frame_count
; /* number of frames in the file (if VBR) */
178 /* Used for A52/AC3 */
179 unsigned long bytesperframe
; /* number of bytes per frame (if CBR) */
181 /* Xing VBR fields */
183 bool has_toc
; /* True if there is a VBR header in the file */
184 unsigned char toc
[100]; /* table of contents */
186 /* these following two fields are used for local buffering */
188 char id3v1buf
[4][92];
191 unsigned long offset
; /* bytes played */
192 int index
; /* playlist index */
194 /* FileEntry fields */
195 long fileentryoffset
;
197 long songentryoffset
;
198 long rundbentryoffset
;
200 /* runtime database fields */
205 /* replaygain support */
207 #if CONFIG_CODEC == SWCODEC
208 char* track_gain_string
;
209 char* album_gain_string
;
210 long track_gain
; /* 7.24 signed fixed point. 0 for no gain. */
212 long track_peak
; /* 7.24 signed fixed point. 0 for no peak. */
216 /* Cuesheet support */
217 int cuesheet_type
; /* 0: none, 1: external, 2: embedded */
228 bool get_mp3_metadata(int fd
, struct mp3entry
*entry
, const char *filename
, bool v1first
);
229 bool mp3info(struct mp3entry
*entry
, const char *filename
, bool v1first
);
230 char* id3_get_num_genre(const unsigned int genre_num
);
231 char* id3_get_codec(const struct mp3entry
* id3
);
232 int getid3v2len(int fd
);
233 void adjust_mp3entry(struct mp3entry
*entry
, void *dest
, void *orig
);
234 void copy_mp3entry(struct mp3entry
*dest
, struct mp3entry
*orig
);