Rev 1905 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1905 | Rev 3960 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | /* |
1 | /* |
2 | libmpg123: MPEG Audio Decoder library (version 1.9.0) |
2 | libmpg123: MPEG Audio Decoder library (version 1.15.4) |
Line 3... | Line 3... | ||
3 | 3 | ||
4 | copyright 1995-2008 by the mpg123 project - free software under the terms of the LGPL 2.1 |
4 | copyright 1995-2010 by the mpg123 project - free software under the terms of the LGPL 2.1 |
5 | see COPYING and AUTHORS files in distribution or http://mpg123.org |
5 | see COPYING and AUTHORS files in distribution or http://mpg123.org |
Line 6... | Line 6... | ||
6 | */ |
6 | */ |
7 | 7 | ||
Line 8... | Line 8... | ||
8 | #ifndef MPG123_LIB_H |
8 | #ifndef MPG123_LIB_H |
Line -... | Line 9... | ||
- | 9 | #define MPG123_LIB_H |
|
- | 10 | ||
- | 11 | /** \file mpg123.h The header file for the libmpg123 MPEG Audio decoder */ |
|
- | 12 | ||
9 | #define MPG123_LIB_H |
13 | /* A macro to check at compile time which set of API functions to expect. |
10 | 14 | This should be incremented at least each time a new symbol is added to the header. */ |
|
11 | /** \file mpg123.h The header file for the libmpg123 MPEG Audio decoder */ |
15 | #define MPG123_API_VERSION 37 |
12 | 16 | ||
13 | /* These aren't actually in use... seems to work without using libtool. */ |
17 | /* These aren't actually in use... seems to work without using libtool. */ |
Line 26... | Line 30... | ||
26 | 30 | ||
27 | #ifndef MPG123_NO_CONFIGURE /* Enable use of this file without configure. */ |
31 | #ifndef MPG123_NO_CONFIGURE /* Enable use of this file without configure. */ |
28 | #include |
32 | #include |
Line -... | Line 33... | ||
- | 33 | #include |
|
- | 34 | ||
- | 35 | /* Simplified large file handling. |
|
- | 36 | I used to have a check here that prevents building for a library with conflicting large file setup |
|
- | 37 | (application that uses 32 bit offsets with library that uses 64 bits). |
|
29 | #include |
38 | While that was perfectly fine in an environment where there is one incarnation of the library, |
- | 39 | it hurt GNU/Linux and Solaris systems with multilib where the distribution fails to provide the |
|
- | 40 | correct header matching the 32 bit library (where large files need explicit support) or |
|
- | 41 | the 64 bit library (where there is no distinction). |
|
- | 42 | ||
- | 43 | New approach: When the app defines _FILE_OFFSET_BITS, it wants non-default large file support, |
|
- | 44 | and thus functions with added suffix (mpg123_open_64). |
|
- | 45 | Any mismatch will be caught at link time because of the _FILE_OFFSET_BITS setting used when |
|
Line 30... | Line 46... | ||
30 | 46 | building libmpg123. Plus, there's dual mode large file support in mpg123 since 1.12 now. |
|
- | 47 | Link failure is not the expected outcome of any half-sane usage anymore. |
|
- | 48 | ||
- | 49 | More complication: What about client code defining _LARGEFILE64_SOURCE? It might want direct access to the _64 functions, along with the ones without suffix. Well, that's possible now via defining MPG123_NO_LARGENAME and MPG123_LARGESUFFIX, respectively, for disabling or enforcing the suffix names. |
|
31 | #if 0 /* If we need trickery for large file support. */ |
50 | */ |
32 | 51 | ||
33 | /* Check for compiling programs agains this libmpg123. */ |
52 | /* |
34 | #if (defined _FILE_OFFSET_BITS) && (_FILE_OFFSET_BITS+0 == ) |
53 | Now, the renaming of large file aware functions. |
35 | /* ...all is fine, having enabled large file support and also the correct sort of which. */ |
- | |
Line 36... | Line 54... | ||
36 | #else |
54 | By default, it appends underscore _FILE_OFFSET_BITS (so, mpg123_seek_64 for mpg123_seek), if _FILE_OFFSET_BITS is defined. You can force a different suffix via MPG123_LARGESUFFIX (that must include the underscore), or you can just disable the whole mess by defining MPG123_NO_LARGENAME. |
- | 55 | */ |
|
- | 56 | #if (!defined MPG123_NO_LARGENAME) && ((defined _FILE_OFFSET_BITS) || (defined MPG123_LARGESUFFIX)) |
|
- | 57 | ||
- | 58 | /* Need some trickery to concatenate the value(s) of the given macro(s). */ |
|
- | 59 | #define MPG123_MACROCAT_REALLY(a, b) a ## b |
|
37 | #error "Mismatch in large file setup! Enable/disable large file support appropriately to use libmpg123." |
60 | #define MPG123_MACROCAT(a, b) MPG123_MACROCAT_REALLY(a, b) |
Line 38... | Line 61... | ||
38 | #endif |
61 | #ifndef MPG123_LARGESUFFIX |
39 | 62 | #define MPG123_LARGESUFFIX MPG123_MACROCAT(_, _FILE_OFFSET_BITS) |
|
- | 63 | #endif |
|
- | 64 | #define MPG123_LARGENAME(func) MPG123_MACROCAT(func, MPG123_LARGESUFFIX) |
|
40 | /* Redefine names of functions dealing with file and file offsets |
65 | |
41 | ...everything handling off_t, for example, which can be 32 or 64 bits. */ |
66 | #define mpg123_open MPG123_LARGENAME(mpg123_open) |
42 | 67 | #define mpg123_open_fd MPG123_LARGENAME(mpg123_open_fd) |
|
43 | #define mpg123_open mpg123_open |
68 | #define mpg123_open_handle MPG123_LARGENAME(mpg123_open_handle) |
44 | #define mpg123_open_fd mpg123_open_fd |
69 | #define mpg123_framebyframe_decode MPG123_LARGENAME(mpg123_framebyframe_decode) |
45 | #define mpg123_decode_frame mpg123_decode_frame |
70 | #define mpg123_decode_frame MPG123_LARGENAME(mpg123_decode_frame) |
46 | #define mpg123_tell mpg123_tell |
71 | #define mpg123_tell MPG123_LARGENAME(mpg123_tell) |
47 | #define mpg123_tellframe mpg123_tellframe |
72 | #define mpg123_tellframe MPG123_LARGENAME(mpg123_tellframe) |
48 | #define mpg123_tell_stream mpg123_tell_stream |
73 | #define mpg123_tell_stream MPG123_LARGENAME(mpg123_tell_stream) |
- | 74 | #define mpg123_seek MPG123_LARGENAME(mpg123_seek) |
|
49 | #define mpg123_seek mpg123_seek |
75 | #define mpg123_feedseek MPG123_LARGENAME(mpg123_feedseek) |
50 | #define mpg123_feedseek mpg123_feedseek |
76 | #define mpg123_seek_frame MPG123_LARGENAME(mpg123_seek_frame) |
51 | #define mpg123_seek_frame mpg123_seek_frame |
77 | #define mpg123_timeframe MPG123_LARGENAME(mpg123_timeframe) |
- | 78 | #define mpg123_index MPG123_LARGENAME(mpg123_index) |
|
- | 79 | #define mpg123_set_index MPG123_LARGENAME(mpg123_set_index) |
|
- | 80 | #define mpg123_position MPG123_LARGENAME(mpg123_position) |
|
Line 52... | Line 81... | ||
52 | #define mpg123_timeframe mpg123_timeframe |
81 | #define mpg123_length MPG123_LARGENAME(mpg123_length) |
Line 53... | Line 82... | ||
53 | #define mpg123_index mpg123_index |
82 | #define mpg123_set_filesize MPG123_LARGENAME(mpg123_set_filesize) |
Line 54... | Line 83... | ||
54 | #define mpg123_position mpg123_position |
83 | #define mpg123_replace_reader MPG123_LARGENAME(mpg123_replace_reader) |
55 | #define mpg123_length mpg123_length |
84 | #define mpg123_replace_reader_handle MPG123_LARGENAME(mpg123_replace_reader_handle) |
Line 103... | Line 132... | ||
103 | EXPORT void mpg123_delete(mpg123_handle *mh); |
132 | EXPORT void mpg123_delete(mpg123_handle *mh); |
Line 104... | Line 133... | ||
104 | 133 | ||
105 | /** Enumeration of the parameters types that it is possible to set/get. */ |
134 | /** Enumeration of the parameters types that it is possible to set/get. */ |
106 | enum mpg123_parms |
135 | enum mpg123_parms |
107 | { |
136 | { |
108 | MPG123_VERBOSE, /**< set verbosity value for enabling messages to stderr, >= 0 makes sense (integer) */ |
137 | MPG123_VERBOSE = 0, /**< set verbosity value for enabling messages to stderr, >= 0 makes sense (integer) */ |
109 | MPG123_FLAGS, /**< set all flags, p.ex val = MPG123_GAPLESS|MPG123_MONO_MIX (integer) */ |
138 | MPG123_FLAGS, /**< set all flags, p.ex val = MPG123_GAPLESS|MPG123_MONO_MIX (integer) */ |
110 | MPG123_ADD_FLAGS, /**< add some flags (integer) */ |
139 | MPG123_ADD_FLAGS, /**< add some flags (integer) */ |
111 | MPG123_FORCE_RATE, /**< when value > 0, force output rate to that value (integer) */ |
140 | MPG123_FORCE_RATE, /**< when value > 0, force output rate to that value (integer) */ |
112 | MPG123_DOWN_SAMPLE, /**< 0=native rate, 1=half rate, 2=quarter rate (integer) */ |
141 | MPG123_DOWN_SAMPLE, /**< 0=native rate, 1=half rate, 2=quarter rate (integer) */ |
Line 117... | Line 146... | ||
117 | MPG123_DECODE_FRAMES, /**< decode only this number of frames (integer) */ |
146 | MPG123_DECODE_FRAMES, /**< decode only this number of frames (integer) */ |
118 | MPG123_ICY_INTERVAL, /**< stream contains ICY metadata with this interval (integer) */ |
147 | MPG123_ICY_INTERVAL, /**< stream contains ICY metadata with this interval (integer) */ |
119 | MPG123_OUTSCALE, /**< the scale for output samples (amplitude - integer or float according to mpg123 output format, normally integer) */ |
148 | MPG123_OUTSCALE, /**< the scale for output samples (amplitude - integer or float according to mpg123 output format, normally integer) */ |
120 | MPG123_TIMEOUT, /**< timeout for reading from a stream (not supported on win32, integer) */ |
149 | MPG123_TIMEOUT, /**< timeout for reading from a stream (not supported on win32, integer) */ |
121 | MPG123_REMOVE_FLAGS, /**< remove some flags (inverse of MPG123_ADD_FLAGS, integer) */ |
150 | MPG123_REMOVE_FLAGS, /**< remove some flags (inverse of MPG123_ADD_FLAGS, integer) */ |
122 | MPG123_RESYNC_LIMIT, /**< Try resync on frame parsing for that many bytes or until end of stream (<0 ... integer). */ |
151 | MPG123_RESYNC_LIMIT, /**< Try resync on frame parsing for that many bytes or until end of stream (<0 ... integer). This can enlarge the limit for skipping junk on beginning, too (but not reduce it). */ |
123 | MPG123_INDEX_SIZE /**< Set the frame index size (if supported). Values <0 mean that the index is allowed to grow dynamically in these steps (in positive direction, of course) -- Use this when you really want a full index with every individual frame. */ |
152 | MPG123_INDEX_SIZE /**< Set the frame index size (if supported). Values <0 mean that the index is allowed to grow dynamically in these steps (in positive direction, of course) -- Use this when you really want a full index with every individual frame. */ |
124 | ,MPG123_PREFRAMES /**< Decode/ignore that many frames in advance for layer 3. This is needed to fill bit reservoir after seeking, for example (but also at least one frame in advance is needed to have all "normal" data for layer 3). Give a positive integer value, please.*/ |
153 | ,MPG123_PREFRAMES /**< Decode/ignore that many frames in advance for layer 3. This is needed to fill bit reservoir after seeking, for example (but also at least one frame in advance is needed to have all "normal" data for layer 3). Give a positive integer value, please.*/ |
- | 154 | ,MPG123_FEEDPOOL /**< For feeder mode, keep that many buffers in a pool to avoid frequent malloc/free. The pool is allocated on mpg123_open_feed(). If you change this parameter afterwards, you can trigger growth and shrinkage during decoding. The default value could change any time. If you care about this, then set it. (integer) */ |
|
- | 155 | ,MPG123_FEEDBUFFER /**< Minimal size of one internal feeder buffer, again, the default value is subject to change. (integer) */ |
|
125 | }; |
156 | }; |
Line 126... | Line 157... | ||
126 | 157 | ||
127 | /** Flag bits for MPG123_FLAGS, use the usual binary or to combine. */ |
158 | /** Flag bits for MPG123_FLAGS, use the usual binary or to combine. */ |
128 | enum mpg123_param_flags |
159 | enum mpg123_param_flags |
Line 138... | Line 169... | ||
138 | ,MPG123_NO_RESYNC = 0x80 /**< 10000000 Disable resync stream after error. */ |
169 | ,MPG123_NO_RESYNC = 0x80 /**< 10000000 Disable resync stream after error. */ |
139 | ,MPG123_SEEKBUFFER = 0x100 /**< 000100000000 Enable small buffer on non-seekable streams to allow some peek-ahead (for better MPEG sync). */ |
170 | ,MPG123_SEEKBUFFER = 0x100 /**< 000100000000 Enable small buffer on non-seekable streams to allow some peek-ahead (for better MPEG sync). */ |
140 | ,MPG123_FUZZY = 0x200 /**< 001000000000 Enable fuzzy seeks (guessing byte offsets or using approximate seek points from Xing TOC) */ |
171 | ,MPG123_FUZZY = 0x200 /**< 001000000000 Enable fuzzy seeks (guessing byte offsets or using approximate seek points from Xing TOC) */ |
141 | ,MPG123_FORCE_FLOAT = 0x400 /**< 010000000000 Force floating point output (32 or 64 bits depends on mpg123 internal precision). */ |
172 | ,MPG123_FORCE_FLOAT = 0x400 /**< 010000000000 Force floating point output (32 or 64 bits depends on mpg123 internal precision). */ |
142 | ,MPG123_PLAIN_ID3TEXT = 0x800 /**< 100000000000 Do not translate ID3 text data to UTF-8. ID3 strings will contain the raw text data, with the first byte containing the ID3 encoding code. */ |
173 | ,MPG123_PLAIN_ID3TEXT = 0x800 /**< 100000000000 Do not translate ID3 text data to UTF-8. ID3 strings will contain the raw text data, with the first byte containing the ID3 encoding code. */ |
- | 174 | ,MPG123_IGNORE_STREAMLENGTH = 0x1000 /**< 1000000000000 Ignore any stream length information contained in the stream, which can be contained in a 'TLEN' frame of an ID3v2 tag or a Xing tag */ |
|
- | 175 | ,MPG123_SKIP_ID3V2 = 0x2000 /**< 10 0000 0000 0000 Do not parse ID3v2 tags, just skip them. */ |
|
- | 176 | ,MPG123_IGNORE_INFOFRAME = 0x4000 /**< 100 0000 0000 0000 Do not parse the LAME/Xing info frame, treat it as normal MPEG data. */ |
|
- | 177 | ,MPG123_AUTO_RESAMPLE = 0x8000 /**< 1000 0000 0000 0000 Allow automatic internal resampling of any kind (default on if supported). Especially when going lowlevel with replacing output buffer, you might want to unset this flag. Setting MPG123_DOWNSAMPLE or MPG123_FORCE_RATE will override this. */ |
|
143 | }; |
178 | }; |
Line 144... | Line 179... | ||
144 | 179 | ||
145 | /** choices for MPG123_RVA */ |
180 | /** choices for MPG123_RVA */ |
146 | enum mpg123_param_rva |
181 | enum mpg123_param_rva |
Line 159... | Line 194... | ||
159 | 194 | ||
160 | /** Get a specific parameter, for a specific mpg123_handle. |
195 | /** Get a specific parameter, for a specific mpg123_handle. |
161 | * See the mpg123_parms enumeration for a list of available parameters. */ |
196 | * See the mpg123_parms enumeration for a list of available parameters. */ |
Line -... | Line 197... | ||
- | 197 | EXPORT int mpg123_getparam(mpg123_handle *mh, enum mpg123_parms type, long *val, double *fval); |
|
- | 198 | ||
- | 199 | /** Feature set available for query with mpg123_feature. */ |
|
- | 200 | enum mpg123_feature_set |
|
- | 201 | { |
|
- | 202 | MPG123_FEATURE_ABI_UTF8OPEN = 0 /**< mpg123 expects path names to be given in UTF-8 encoding instead of plain native. */ |
|
- | 203 | ,MPG123_FEATURE_OUTPUT_8BIT /**< 8bit output */ |
|
- | 204 | ,MPG123_FEATURE_OUTPUT_16BIT /**< 16bit output */ |
|
- | 205 | ,MPG123_FEATURE_OUTPUT_32BIT /**< 32bit output */ |
|
- | 206 | ,MPG123_FEATURE_INDEX /**< support for building a frame index for accurate seeking */ |
|
- | 207 | ,MPG123_FEATURE_PARSE_ID3V2 /**< id3v2 parsing */ |
|
- | 208 | ,MPG123_FEATURE_DECODE_LAYER1 /**< mpeg layer-1 decoder enabled */ |
|
- | 209 | ,MPG123_FEATURE_DECODE_LAYER2 /**< mpeg layer-2 decoder enabled */ |
|
- | 210 | ,MPG123_FEATURE_DECODE_LAYER3 /**< mpeg layer-3 decoder enabled */ |
|
- | 211 | ,MPG123_FEATURE_DECODE_ACCURATE /**< accurate decoder rounding */ |
|
- | 212 | ,MPG123_FEATURE_DECODE_DOWNSAMPLE /**< downsample (sample omit) */ |
|
- | 213 | ,MPG123_FEATURE_DECODE_NTOM /**< flexible rate decoding */ |
|
- | 214 | ,MPG123_FEATURE_PARSE_ICY /**< ICY support */ |
|
- | 215 | ,MPG123_FEATURE_TIMEOUT_READ /**< Reader with timeout (network). */ |
|
- | 216 | }; |
|
- | 217 | ||
- | 218 | /** Query libmpg123 feature, 1 for success, 0 for unimplemented functions. */ |
|
162 | EXPORT int mpg123_getparam(mpg123_handle *mh, enum mpg123_parms type, long *val, double *fval); |
219 | EXPORT int mpg123_feature(const enum mpg123_feature_set key); |
Line 163... | Line 220... | ||
163 | 220 | ||
164 | /* @} */ |
221 | /* @} */ |
Line 207... | Line 264... | ||
207 | MPG123_NO_TIMEOUT, /**< Build does not support stream timeouts. */ |
264 | MPG123_NO_TIMEOUT, /**< Build does not support stream timeouts. */ |
208 | MPG123_BAD_FILE, /**< File access error. */ |
265 | MPG123_BAD_FILE, /**< File access error. */ |
209 | MPG123_NO_SEEK, /**< Seek not supported by stream. */ |
266 | MPG123_NO_SEEK, /**< Seek not supported by stream. */ |
210 | MPG123_NO_READER, /**< No stream opened. */ |
267 | MPG123_NO_READER, /**< No stream opened. */ |
211 | MPG123_BAD_PARS, /**< Bad parameter handle. */ |
268 | MPG123_BAD_PARS, /**< Bad parameter handle. */ |
212 | MPG123_BAD_INDEX_PAR, /**< Bad parameters to mpg123_index() */ |
269 | MPG123_BAD_INDEX_PAR, /**< Bad parameters to mpg123_index() and mpg123_set_index() */ |
213 | MPG123_OUT_OF_SYNC, /**< Lost track in bytestream and did not try to resync. */ |
270 | MPG123_OUT_OF_SYNC, /**< Lost track in bytestream and did not try to resync. */ |
214 | MPG123_RESYNC_FAIL, /**< Resync failed to find valid MPEG data. */ |
271 | MPG123_RESYNC_FAIL, /**< Resync failed to find valid MPEG data. */ |
215 | MPG123_NO_8BIT, /**< No 8bit encoding possible. */ |
272 | MPG123_NO_8BIT, /**< No 8bit encoding possible. */ |
216 | MPG123_BAD_ALIGN, /**< Stack aligmnent error */ |
273 | MPG123_BAD_ALIGN, /**< Stack aligmnent error */ |
217 | MPG123_NULL_BUFFER, /**< NULL input buffer with non-zero size... */ |
274 | MPG123_NULL_BUFFER, /**< NULL input buffer with non-zero size... */ |
Line 222... | Line 279... | ||
222 | MPG123_INDEX_FAIL, /**< Something with frame index went wrong. */ |
279 | MPG123_INDEX_FAIL, /**< Something with frame index went wrong. */ |
223 | MPG123_BAD_DECODER_SETUP, /**< Something prevents a proper decoder setup */ |
280 | MPG123_BAD_DECODER_SETUP, /**< Something prevents a proper decoder setup */ |
224 | MPG123_MISSING_FEATURE /**< This feature has not been built into libmpg123. */ |
281 | MPG123_MISSING_FEATURE /**< This feature has not been built into libmpg123. */ |
225 | ,MPG123_BAD_VALUE /**< A bad value has been given, somewhere. */ |
282 | ,MPG123_BAD_VALUE /**< A bad value has been given, somewhere. */ |
226 | ,MPG123_LSEEK_FAILED /**< Low-level seek failed. */ |
283 | ,MPG123_LSEEK_FAILED /**< Low-level seek failed. */ |
- | 284 | ,MPG123_BAD_CUSTOM_IO /**< Custom I/O not prepared. */ |
|
- | 285 | ,MPG123_LFS_OVERFLOW /**< Offset value overflow during translation of large file API calls -- your client program cannot handle that large file. */ |
|
- | 286 | ,MPG123_INT_OVERFLOW /**< Some integer overflow. */ |
|
227 | }; |
287 | }; |
Line 228... | Line 288... | ||
228 | 288 | ||
229 | /** Return a string describing that error errcode means. */ |
289 | /** Return a string describing that error errcode means. */ |
Line 248... | Line 308... | ||
248 | * |
308 | * |
249 | * @{ |
309 | * @{ |
250 | */ |
310 | */ |
Line 251... | Line 311... | ||
251 | 311 | ||
252 | /** Return a NULL-terminated array of generally available decoder names (plain 8bit ASCII). */ |
312 | /** Return a NULL-terminated array of generally available decoder names (plain 8bit ASCII). */ |
Line 253... | Line 313... | ||
253 | EXPORT const char **mpg123_decoders(); |
313 | EXPORT const char **mpg123_decoders(void); |
254 | 314 | ||
Line 255... | Line 315... | ||
255 | /** Return a NULL-terminated array of the decoders supported by the CPU (plain 8bit ASCII). */ |
315 | /** Return a NULL-terminated array of the decoders supported by the CPU (plain 8bit ASCII). */ |
256 | EXPORT const char **mpg123_supported_decoders(); |
316 | EXPORT const char **mpg123_supported_decoders(void); |
Line 257... | Line 317... | ||
257 | 317 | ||
Line 270... | Line 330... | ||
270 | 330 | ||
271 | /** \defgroup mpg123_output mpg123 output audio format |
331 | /** \defgroup mpg123_output mpg123 output audio format |
272 | * |
332 | * |
273 | * Functions to get and select the format of the decoded audio. |
333 | * Functions to get and select the format of the decoded audio. |
- | 334 | * |
|
- | 335 | * Before you dive in, please be warned that you might get confused by this. This seems to happen a lot, therefore I am trying to explain in advance. |
|
- | 336 | * |
|
- | 337 | * The mpg123 library decides what output format to use when encountering the first frame in a stream, or actually any frame that is still valid but differs from the frames before in the prompted output format. At such a deciding point, an internal table of allowed encodings, sampling rates and channel setups is consulted. According to this table, an output format is chosen and the decoding engine set up accordingly (including ptimized routines for different output formats). This might seem unusual but it just follows from the non-existence of "MPEG audio files" with defined overall properties. There are streams, streams are concatenations of (semi) independent frames. We store streams on disk and call them "MPEG audio files", but that does not change their nature as the decoder is concerned (the LAME/Xing header for gapless decoding makes things interesting again). |
|
- | 338 | * |
|
- | 339 | * To get to the point: What you do with mpg123_format() and friends is to fill the internal table of allowed formats before it is used. That includes removing support for some formats or adding your forced sample rate (see MPG123_FORCE_RATE) that will be used with the crude internal resampler. Also keep in mind that the sample encoding is just a question of choice -- the MPEG frames do only indicate their native sampling rate and channel count. If you want to decode to integer or float samples, 8 or 16 bit ... that is your decision. In a "clean" world, libmpg123 would always decode to 32 bit float and let you handle any sample conversion. But there are optimized routines that work faster by directly decoding to the desired encoding / accuracy. We prefer efficiency over conceptual tidyness. |
|
- | 340 | * |
|
- | 341 | * People often start out thinking that mpg123_format() should change the actual decoding format on the fly. That is wrong. It only has effect on the next natural change of output format, when libmpg123 will consult its format table again. To make life easier, you might want to call mpg123_format_none() before any thing else and then just allow one desired encoding and a limited set of sample rates / channel choices that you actually intend to deal with. You can force libmpg123 to decode everything to 44100 KHz, stereo, 16 bit integer ... it will duplicate mono channels and even do resampling if needed (unless that feature is disabled in the build, same with some encodings). But I have to stress that the resampling of libmpg123 is very crude and doesn't even contain any kind of "proper" interpolation. |
|
- | 342 | * |
|
- | 343 | * In any case, watch out for MPG123_NEW_FORMAT as return message from decoding routines and call mpg123_getformat() to get the currently active output format. |
|
274 | * |
344 | * |
275 | * @{ |
345 | * @{ |
Line 276... | Line 346... | ||
276 | */ |
346 | */ |
277 | 347 | ||
278 | /** An enum over all sample types possibly known to mpg123. |
348 | /** An enum over all sample types possibly known to mpg123. |
279 | * The values are designed as bit flags to allow bitmasking for encoding families. |
349 | * The values are designed as bit flags to allow bitmasking for encoding families. |
280 | * |
350 | * |
281 | * Note that (your build of) libmpg123 does not necessarily support all these. |
351 | * Note that (your build of) libmpg123 does not necessarily support all these. |
282 | * Usually, you can expect the 8bit encodings and signed 16 bit. |
352 | * Usually, you can expect the 8bit encodings and signed 16 bit. |
- | 353 | * Also 32bit float will be usual beginning with mpg123-1.7.0 . |
|
- | 354 | * What you should bear in mind is that (SSE, etc) optimized routines may be absent |
|
283 | * Also 32bit float will be usual beginning with mpg123-1.7.0 . |
355 | * for some formats. We do have SSE for 16, 32 bit and float, though. |
284 | * What you should bear in mind is that (SSE, etc) optimized routines are just for |
356 | * 24 bit integer is done via postprocessing of 32 bit output -- just cutting |
285 | * signed 16bit (and 8bit derived from that). Other formats use plain C code. |
357 | * the last byte, no rounding, even. If you want better, do it yourself. |
286 | * |
358 | * |
287 | * All formats are in native byte order. On a little endian machine this should mean |
359 | * All formats are in native byte order. If you need different endinaness, you |
288 | * that you can just feed the MPG123_ENC_SIGNED_32 data to common 24bit hardware that |
360 | * can simply postprocess the output buffers (libmpg123 wouldn't do anything else). |
289 | * ignores the lowest byte (or you could choose to do rounding with these lower bits). |
361 | * mpg123_encsize() can be helpful there. |
290 | */ |
362 | */ |
291 | enum mpg123_enc_enum |
363 | enum mpg123_enc_enum |
292 | { |
364 | { |
- | 365 | MPG123_ENC_8 = 0x00f /**< 0000 0000 1111 Some 8 bit integer encoding. */ |
|
293 | MPG123_ENC_8 = 0x00f /**< 0000 0000 1111 Some 8 bit integer encoding. */ |
366 | ,MPG123_ENC_16 = 0x040 /**< 0000 0100 0000 Some 16 bit integer encoding. */ |
294 | ,MPG123_ENC_16 = 0x040 /**< 0000 0100 0000 Some 16 bit integer encoding. */ |
367 | ,MPG123_ENC_24 = 0x4000 /**< 0100 0000 0000 0000 Some 24 bit integer encoding. */ |
295 | ,MPG123_ENC_32 = 0x100 /**< 0001 0000 0000 Some 32 bit integer encoding. */ |
368 | ,MPG123_ENC_32 = 0x100 /**< 0001 0000 0000 Some 32 bit integer encoding. */ |
296 | ,MPG123_ENC_SIGNED = 0x080 /**< 0000 1000 0000 Some signed integer encoding. */ |
369 | ,MPG123_ENC_SIGNED = 0x080 /**< 0000 1000 0000 Some signed integer encoding. */ |
297 | ,MPG123_ENC_FLOAT = 0xe00 /**< 1110 0000 0000 Some float encoding. */ |
370 | ,MPG123_ENC_FLOAT = 0xe00 /**< 1110 0000 0000 Some float encoding. */ |
Line 301... | Line 374... | ||
301 | ,MPG123_ENC_SIGNED_8 = (MPG123_ENC_SIGNED|0x02) /**< 1000 0010 signed 8 bit */ |
374 | ,MPG123_ENC_SIGNED_8 = (MPG123_ENC_SIGNED|0x02) /**< 1000 0010 signed 8 bit */ |
302 | ,MPG123_ENC_ULAW_8 = 0x04 /**< 0000 0100 ulaw 8 bit */ |
375 | ,MPG123_ENC_ULAW_8 = 0x04 /**< 0000 0100 ulaw 8 bit */ |
303 | ,MPG123_ENC_ALAW_8 = 0x08 /**< 0000 1000 alaw 8 bit */ |
376 | ,MPG123_ENC_ALAW_8 = 0x08 /**< 0000 1000 alaw 8 bit */ |
304 | ,MPG123_ENC_SIGNED_32 = MPG123_ENC_32|MPG123_ENC_SIGNED|0x1000 /**< 0001 0001 1000 0000 signed 32 bit */ |
377 | ,MPG123_ENC_SIGNED_32 = MPG123_ENC_32|MPG123_ENC_SIGNED|0x1000 /**< 0001 0001 1000 0000 signed 32 bit */ |
305 | ,MPG123_ENC_UNSIGNED_32 = MPG123_ENC_32|0x2000 /**< 0010 0001 0000 0000 unsigned 32 bit */ |
378 | ,MPG123_ENC_UNSIGNED_32 = MPG123_ENC_32|0x2000 /**< 0010 0001 0000 0000 unsigned 32 bit */ |
- | 379 | ,MPG123_ENC_SIGNED_24 = MPG123_ENC_24|MPG123_ENC_SIGNED|0x1000 /**< 0101 0000 1000 0000 signed 24 bit */ |
|
- | 380 | ,MPG123_ENC_UNSIGNED_24 = MPG123_ENC_24|0x2000 /**< 0110 0000 0000 0000 unsigned 24 bit */ |
|
306 | ,MPG123_ENC_FLOAT_32 = 0x200 /**< 0010 0000 0000 32bit float */ |
381 | ,MPG123_ENC_FLOAT_32 = 0x200 /**< 0010 0000 0000 32bit float */ |
307 | ,MPG123_ENC_FLOAT_64 = 0x400 /**< 0100 0000 0000 64bit float */ |
382 | ,MPG123_ENC_FLOAT_64 = 0x400 /**< 0100 0000 0000 64bit float */ |
308 | ,MPG123_ENC_ANY = ( MPG123_ENC_SIGNED_16 | MPG123_ENC_UNSIGNED_16 | MPG123_ENC_UNSIGNED_8 |
383 | ,MPG123_ENC_ANY = ( MPG123_ENC_SIGNED_16 | MPG123_ENC_UNSIGNED_16 | MPG123_ENC_UNSIGNED_8 |
309 | | MPG123_ENC_SIGNED_8 | MPG123_ENC_ULAW_8 | MPG123_ENC_ALAW_8 |
384 | | MPG123_ENC_SIGNED_8 | MPG123_ENC_ULAW_8 | MPG123_ENC_ALAW_8 |
310 | | MPG123_ENC_SIGNED_32 | MPG123_ENC_UNSIGNED_32 |
385 | | MPG123_ENC_SIGNED_32 | MPG123_ENC_UNSIGNED_32 |
- | 386 | | MPG123_ENC_SIGNED_24 | MPG123_ENC_UNSIGNED_24 |
|
311 | | MPG123_ENC_FLOAT_32 | MPG123_ENC_FLOAT_64 ) /**< any encoding */ |
387 | | MPG123_ENC_FLOAT_32 | MPG123_ENC_FLOAT_64 ) /**< Any encoding on the list. */ |
312 | }; |
388 | }; |
Line 313... | Line 389... | ||
313 | 389 | ||
314 | /** They can be combined into one number (3) to indicate mono and stereo... */ |
390 | /** They can be combined into one number (3) to indicate mono and stereo... */ |
315 | enum mpg123_channelcount |
391 | enum mpg123_channelcount |
Line 329... | Line 405... | ||
329 | * An audio encoding is one of the fully qualified members of mpg123_enc_enum (MPG123_ENC_SIGNED_16, not MPG123_SIGNED). |
405 | * An audio encoding is one of the fully qualified members of mpg123_enc_enum (MPG123_ENC_SIGNED_16, not MPG123_SIGNED). |
330 | * \param list Store a pointer to the encodings array there. |
406 | * \param list Store a pointer to the encodings array there. |
331 | * \param number Store the number of encodings there. */ |
407 | * \param number Store the number of encodings there. */ |
332 | EXPORT void mpg123_encodings(const int **list, size_t *number); |
408 | EXPORT void mpg123_encodings(const int **list, size_t *number); |
Line -... | Line 409... | ||
- | 409 | ||
- | 410 | /** Return the size (in bytes) of one mono sample of the named encoding. |
|
- | 411 | * \param encoding The encoding value to analyze. |
|
- | 412 | * \return positive size of encoding in bytes, 0 on invalid encoding. */ |
|
- | 413 | EXPORT int mpg123_encsize(int encoding); |
|
333 | 414 | ||
334 | /** Configure a mpg123 handle to accept no output format at all, |
415 | /** Configure a mpg123 handle to accept no output format at all, |
335 | * use before specifying supported formats with mpg123_format */ |
416 | * use before specifying supported formats with mpg123_format */ |
Line 336... | Line 417... | ||
336 | EXPORT int mpg123_format_none(mpg123_handle *mh); |
417 | EXPORT int mpg123_format_none(mpg123_handle *mh); |
Line 378... | Line 459... | ||
378 | /** Use an already opened file descriptor as the bitstream input |
459 | /** Use an already opened file descriptor as the bitstream input |
379 | * mpg123_close() will _not_ close the file descriptor. |
460 | * mpg123_close() will _not_ close the file descriptor. |
380 | */ |
461 | */ |
381 | EXPORT int mpg123_open_fd(mpg123_handle *mh, int fd); |
462 | EXPORT int mpg123_open_fd(mpg123_handle *mh, int fd); |
Line -... | Line 463... | ||
- | 463 | ||
- | 464 | /** Use an opaque handle as bitstream input. This works only with the |
|
- | 465 | * replaced I/O from mpg123_replace_reader_handle()! |
|
- | 466 | * mpg123_close() will call the cleanup callback for your handle (if you gave one). |
|
- | 467 | */ |
|
- | 468 | EXPORT int mpg123_open_handle(mpg123_handle *mh, void *iohandle); |
|
382 | 469 | ||
383 | /** Open a new bitstream and prepare for direct feeding |
470 | /** Open a new bitstream and prepare for direct feeding |
384 | * This works together with mpg123_decode(); you are responsible for reading and feeding the input bitstream. |
471 | * This works together with mpg123_decode(); you are responsible for reading and feeding the input bitstream. |
385 | */ |
472 | */ |
Line 414... | Line 501... | ||
414 | * \param outmemory output buffer |
501 | * \param outmemory output buffer |
415 | * \param outmemsize maximum number of output bytes |
502 | * \param outmemsize maximum number of output bytes |
416 | * \param done address to store the number of actually decoded bytes to |
503 | * \param done address to store the number of actually decoded bytes to |
417 | * \return error/message code (watch out especially for MPG123_NEED_MORE) |
504 | * \return error/message code (watch out especially for MPG123_NEED_MORE) |
418 | */ |
505 | */ |
419 | EXPORT int mpg123_decode(mpg123_handle *mh, const unsigned char *inmemory, size_t inmemsize, |
506 | EXPORT int mpg123_decode(mpg123_handle *mh, const unsigned char *inmemory, size_t inmemsize, unsigned char *outmemory, size_t outmemsize, size_t *done); |
420 | unsigned char *outmemory, size_t outmemsize, size_t *done); |
- | |
Line 421... | Line 507... | ||
421 | 507 | ||
422 | /** Decode next MPEG frame to internal buffer |
508 | /** Decode next MPEG frame to internal buffer |
423 | * or read a frame and return after setting a new format. |
509 | * or read a frame and return after setting a new format. |
424 | * \param num current frame offset gets stored there |
510 | * \param num current frame offset gets stored there |
425 | * \param audio This pointer is set to the internal buffer to read the decoded audio from. |
511 | * \param audio This pointer is set to the internal buffer to read the decoded audio from. |
426 | * \param bytes number of output bytes ready in the buffer |
512 | * \param bytes number of output bytes ready in the buffer |
427 | */ |
513 | */ |
Line -... | Line 514... | ||
- | 514 | EXPORT int mpg123_decode_frame(mpg123_handle *mh, off_t *num, unsigned char **audio, size_t *bytes); |
|
- | 515 | ||
- | 516 | /** Decode current MPEG frame to internal buffer. |
|
- | 517 | * Warning: This is experimental API that might change in future releases! |
|
- | 518 | * Please watch mpg123 development closely when using it. |
|
- | 519 | * \param num last frame offset gets stored there |
|
- | 520 | * \param audio this pointer is set to the internal buffer to read the decoded audio from. |
|
- | 521 | * \param bytes number of output bytes ready in the buffer |
|
- | 522 | */ |
|
- | 523 | EXPORT int mpg123_framebyframe_decode(mpg123_handle *mh, off_t *num, unsigned char **audio, size_t *bytes); |
|
- | 524 | ||
- | 525 | /** Find, read and parse the next mp3 frame |
|
- | 526 | * Warning: This is experimental API that might change in future releases! |
|
- | 527 | * Please watch mpg123 development closely when using it. |
|
- | 528 | */ |
|
- | 529 | EXPORT int mpg123_framebyframe_next(mpg123_handle *mh); |
|
- | 530 | ||
- | 531 | /** Get access to the raw input data for the last parsed frame. |
|
- | 532 | * This gives you a direct look (and write access) to the frame body data. |
|
- | 533 | * Together with the raw header, you can reconstruct the whole raw MPEG stream without junk and meta data, or play games by actually modifying the frame body data before decoding this frame (mpg123_framebyframe_decode()). |
|
- | 534 | * A more sane use would be to use this for CRC checking (see mpg123_info() and MPG123_CRC), the first two bytes of the body make up the CRC16 checksum, if present. |
|
- | 535 | * You can provide NULL for a parameter pointer when you are not interested in the value. |
|
- | 536 | * |
|
- | 537 | * \param header the 4-byte MPEG header |
|
- | 538 | * \param bodydata pointer to the frame body stored in the handle (without the header) |
|
- | 539 | * \param bodybytes size of frame body in bytes (without the header) |
|
- | 540 | * \return MPG123_OK if there was a yet un-decoded frame to get the data from, MPG123_ERR otherwise (without further explanation, the error state of the mpg123_handle is not modified by this function). |
|
- | 541 | */ |
|
- | 542 | EXPORT int mpg123_framedata(mpg123_handle *mh, unsigned long *header, unsigned char **bodydata, size_t *bodybytes); |
|
- | 543 | ||
- | 544 | /** Get the input position (byte offset in stream) of the last parsed frame. |
|
- | 545 | * This can be used for external seek index building, for example. |
|
- | 546 | * It just returns the internally stored offset, regardless of validity -- you ensure that a valid frame has been parsed before! */ |
|
428 | EXPORT int mpg123_decode_frame(mpg123_handle *mh, off_t *num, unsigned char **audio, size_t *bytes); |
547 | EXPORT off_t mpg123_framepos(mpg123_handle *mh); |
Line 429... | Line 548... | ||
429 | 548 | ||
430 | /*@}*/ |
549 | /*@}*/ |
Line 480... | Line 599... | ||
480 | * This assumes that the samples per frame do not change in the file/stream, which is a good assumption for any sane file/stream only. |
599 | * This assumes that the samples per frame do not change in the file/stream, which is a good assumption for any sane file/stream only. |
481 | * \return frame offset >= 0 or error/message code */ |
600 | * \return frame offset >= 0 or error/message code */ |
482 | EXPORT off_t mpg123_timeframe(mpg123_handle *mh, double sec); |
601 | EXPORT off_t mpg123_timeframe(mpg123_handle *mh, double sec); |
Line 483... | Line 602... | ||
483 | 602 | ||
484 | /** Give access to the frame index table that is managed for seeking. |
603 | /** Give access to the frame index table that is managed for seeking. |
- | 604 | * You are asked not to modify the values... Use mpg123_set_index to set the |
|
485 | * You are asked not to modify the values... unless you are really aware of what you are doing. |
605 | * seek index |
486 | * \param offsets pointer to the index array |
606 | * \param offsets pointer to the index array |
487 | * \param step one index byte offset advances this many MPEG frames |
607 | * \param step one index byte offset advances this many MPEG frames |
488 | * \param fill number of recorded index offsets; size of the array */ |
608 | * \param fill number of recorded index offsets; size of the array */ |
Line -... | Line 609... | ||
- | 609 | EXPORT int mpg123_index(mpg123_handle *mh, off_t **offsets, off_t *step, size_t *fill); |
|
- | 610 | ||
- | 611 | /** Set the frame index table |
|
- | 612 | * Setting offsets to NULL and fill > 0 will allocate fill entries. Setting offsets |
|
- | 613 | * to NULL and fill to 0 will clear the index and free the allocated memory used by the index. |
|
- | 614 | * \param offsets pointer to the index array |
|
- | 615 | * \param step one index byte offset advances this many MPEG frames |
|
- | 616 | * \param fill number of recorded index offsets; size of the array */ |
|
489 | EXPORT int mpg123_index(mpg123_handle *mh, off_t **offsets, off_t *step, size_t *fill); |
617 | EXPORT int mpg123_set_index(mpg123_handle *mh, off_t *offsets, off_t step, size_t fill); |
490 | 618 | ||
491 | /** Get information about current and remaining frames/seconds. |
619 | /** Get information about current and remaining frames/seconds. |
492 | * WARNING: This function is there because of special usage by standalone mpg123 and may be removed in the final version of libmpg123! |
620 | * WARNING: This function is there because of special usage by standalone mpg123 and may be removed in the final version of libmpg123! |
493 | * You provide an offset (in frames) from now and a number of output bytes |
621 | * You provide an offset (in frames) from now and a number of output bytes |
494 | * served by libmpg123 but not yet played. You get the projected current frame |
622 | * served by libmpg123 but not yet played. You get the projected current frame |
495 | * and seconds, as well as the remaining frames/seconds. This does _not_ care |
623 | * and seconds, as well as the remaining frames/seconds. This does _not_ care |
496 | * about skipped samples due to gapless playback. */ |
- | |
497 | EXPORT int mpg123_position( mpg123_handle *mh, off_t frame_offset, |
- | |
498 | off_t buffered_bytes, off_t *current_frame, |
- | |
Line 499... | Line 624... | ||
499 | off_t *frames_left, double *current_seconds, |
624 | * about skipped samples due to gapless playback. */ |
Line 500... | Line 625... | ||
500 | double *seconds_left); |
625 | EXPORT int mpg123_position( mpg123_handle *mh, off_t frame_offset, off_t buffered_bytes, off_t *current_frame, off_t *frames_left, double *current_seconds, double *seconds_left); |
Line 591... | Line 716... | ||
591 | enum mpg123_version version; /**< The MPEG version (1.0/2.0/2.5). */ |
716 | enum mpg123_version version; /**< The MPEG version (1.0/2.0/2.5). */ |
592 | int layer; /**< The MPEG Audio Layer (MP1/MP2/MP3). */ |
717 | int layer; /**< The MPEG Audio Layer (MP1/MP2/MP3). */ |
593 | long rate; /**< The sampling rate in Hz. */ |
718 | long rate; /**< The sampling rate in Hz. */ |
594 | enum mpg123_mode mode; /**< The audio mode (Mono, Stereo, Joint-stero, Dual Channel). */ |
719 | enum mpg123_mode mode; /**< The audio mode (Mono, Stereo, Joint-stero, Dual Channel). */ |
595 | int mode_ext; /**< The mode extension bit flag. */ |
720 | int mode_ext; /**< The mode extension bit flag. */ |
596 | int framesize; /**< The size of the frame (in bytes). */ |
721 | int framesize; /**< The size of the frame (in bytes, including header). */ |
597 | enum mpg123_flags flags; /**< MPEG Audio flag bits. */ |
722 | enum mpg123_flags flags; /**< MPEG Audio flag bits. Just now I realize that it should be declared as int, not enum. It's a bitwise combination of the enum values. */ |
598 | int emphasis; /**< The emphasis type. */ |
723 | int emphasis; /**< The emphasis type. */ |
599 | int bitrate; /**< Bitrate of the frame (kbps). */ |
724 | int bitrate; /**< Bitrate of the frame (kbps). */ |
600 | int abr_rate; /**< The target average bitrate. */ |
725 | int abr_rate; /**< The target average bitrate. */ |
601 | enum mpg123_vbr vbr; /**< The VBR mode. */ |
726 | enum mpg123_vbr vbr; /**< The VBR mode. */ |
602 | }; |
727 | }; |
Line 603... | Line 728... | ||
603 | 728 | ||
604 | /** Get frame information about the MPEG audio bitstream and store it in a mpg123_frameinfo structure. */ |
729 | /** Get frame information about the MPEG audio bitstream and store it in a mpg123_frameinfo structure. */ |
Line 605... | Line 730... | ||
605 | EXPORT int mpg123_info(mpg123_handle *mh, struct mpg123_frameinfo *mi); |
730 | EXPORT int mpg123_info(mpg123_handle *mh, struct mpg123_frameinfo *mi); |
606 | 731 | ||
Line 607... | Line 732... | ||
607 | /** Get the safe output buffer size for all cases (when you want to replace the internal buffer) */ |
732 | /** Get the safe output buffer size for all cases (when you want to replace the internal buffer) */ |
608 | EXPORT size_t mpg123_safe_buffer(); |
733 | EXPORT size_t mpg123_safe_buffer(void); |
609 | 734 | ||
610 | /** Make a full parsing scan of each frame in the file. ID3 tags are found. An accurate length |
735 | /** Make a full parsing scan of each frame in the file. ID3 tags are found. An accurate length |
Line 625... | Line 750... | ||
625 | EXPORT int mpg123_set_filesize(mpg123_handle *mh, off_t size); |
750 | EXPORT int mpg123_set_filesize(mpg123_handle *mh, off_t size); |
Line 626... | Line 751... | ||
626 | 751 | ||
627 | /** Returns the time (seconds) per frame; <0 is error. */ |
752 | /** Returns the time (seconds) per frame; <0 is error. */ |
Line -... | Line 753... | ||
- | 753 | EXPORT double mpg123_tpf(mpg123_handle *mh); |
|
- | 754 | ||
- | 755 | /** Returns the samples per frame for the most recently parsed frame; <0 is error. */ |
|
628 | EXPORT double mpg123_tpf(mpg123_handle *mh); |
756 | EXPORT int mpg123_spf(mpg123_handle *mh); |
629 | 757 | ||
Line 630... | Line 758... | ||
630 | /** Get and reset the clip count. */ |
758 | /** Get and reset the clip count. */ |
631 | EXPORT long mpg123_clip(mpg123_handle *mh); |
759 | EXPORT long mpg123_clip(mpg123_handle *mh); |
632 | 760 | ||
633 | 761 | ||
- | 762 | /** The key values for state information from mpg123_getstate(). */ |
|
- | 763 | enum mpg123_state |
|
634 | /** The key values for state information from mpg123_getstate(). */ |
764 | { |
Line 635... | Line 765... | ||
635 | enum mpg123_state |
765 | MPG123_ACCURATE = 1 /**< Query if positons are currently accurate (integer value, 0 if false, 1 if true) */ |
636 | { |
766 | ,MPG123_BUFFERFILL /**< Get fill of internal (feed) input buffer as integer byte count returned as long and as double. An error is returned on integer overflow while converting to (signed) long, but the returned floating point value shold still be fine. */ |
637 | MPG123_ACCURATE = 1 /**< Query if positons are currently accurate (integer value, 0 if false, 1 if true) */ |
767 | ,MPG123_FRANKENSTEIN /**< Stream consists of carelessly stitched together files (the leading one featuring gapless info). */ |
Line 703... | Line 833... | ||
703 | * \return 0 on error, 1 on success |
833 | * \return 0 on error, 1 on success |
704 | * \param from offset to copy from |
834 | * \param from offset to copy from |
705 | * \param count number of characters to copy (a null-byte is always appended) */ |
835 | * \param count number of characters to copy (a null-byte is always appended) */ |
706 | EXPORT int mpg123_set_substring(mpg123_string *sb, const char *stuff, size_t from, size_t count); |
836 | EXPORT int mpg123_set_substring(mpg123_string *sb, const char *stuff, size_t from, size_t count); |
Line -... | Line 837... | ||
- | 837 | ||
- | 838 | /** Count characters in a mpg123 string (non-null bytes or UTF-8 characters). |
|
- | 839 | * \return character count |
|
- | 840 | * \param sb the string |
|
- | 841 | * \param utf8 a flag to tell if the string is in utf8 encoding |
|
- | 842 | * Even with the fill property, the character count is not obvious as there could be multiple trailing null bytes. |
|
- | 843 | */ |
|
- | 844 | EXPORT size_t mpg123_strlen(mpg123_string *sb, int utf8); |
|
- | 845 | ||
- | 846 | /** Remove trailing \r and \n, if present. |
|
- | 847 | * \return 0 on error, 1 on success |
|
- | 848 | * \param sb the string |
|
- | 849 | */ |
|
- | 850 | EXPORT int mpg123_chomp_string(mpg123_string *sb); |
|
707 | 851 | ||
708 | /** The mpg123 text encodings. This contains encodings we encounter in ID3 tags or ICY meta info. */ |
852 | /** The mpg123 text encodings. This contains encodings we encounter in ID3 tags or ICY meta info. */ |
709 | enum mpg123_text_encoding |
853 | enum mpg123_text_encoding |
710 | { |
854 | { |
711 | mpg123_text_unknown = 0 /**< Unkown encoding... mpg123_id3_encoding can return that on invalid codes. */ |
855 | mpg123_text_unknown = 0 /**< Unkown encoding... mpg123_id3_encoding can return that on invalid codes. */ |
Line 808... | Line 952... | ||
808 | 952 | ||
809 | /** Query if there is (new) meta info, be it ID3 or ICY (or something new in future). |
953 | /** Query if there is (new) meta info, be it ID3 or ICY (or something new in future). |
810 | The check function returns a combination of flags. */ |
954 | The check function returns a combination of flags. */ |
Line -... | Line 955... | ||
- | 955 | EXPORT int mpg123_meta_check(mpg123_handle *mh); /* On error (no valid handle) just 0 is returned. */ |
|
- | 956 | ||
- | 957 | /** Clean up meta data storage (ID3v2 and ICY), freeing memory. */ |
|
811 | EXPORT int mpg123_meta_check(mpg123_handle *mh); /* On error (no valid handle) just 0 is returned. */ |
958 | EXPORT void mpg123_meta_free(mpg123_handle *mh); |
812 | 959 | ||
813 | /** Point v1 and v2 to existing data structures wich may change on any next read/decode function call. |
960 | /** Point v1 and v2 to existing data structures wich may change on any next read/decode function call. |
814 | * v1 and/or v2 can be set to NULL when there is no corresponding data. |
961 | * v1 and/or v2 can be set to NULL when there is no corresponding data. |
Line 905... | Line 1052... | ||
905 | * Use that to determine an appropriate minimum buffer size for decoding one frame. */ |
1052 | * Use that to determine an appropriate minimum buffer size for decoding one frame. */ |
906 | EXPORT size_t mpg123_outblock(mpg123_handle *mh); |
1053 | EXPORT size_t mpg123_outblock(mpg123_handle *mh); |
Line 907... | Line 1054... | ||
907 | 1054 | ||
908 | /** Replace low-level stream access functions; read and lseek as known in POSIX. |
1055 | /** Replace low-level stream access functions; read and lseek as known in POSIX. |
909 | * You can use this to make any fancy file opening/closing yourself, |
1056 | * You can use this to make any fancy file opening/closing yourself, |
910 | * using open_fd to set the file descriptor for your read/lseek (doesn't need to be a "real" file descriptor...). |
1057 | * using mpg123_open_fd() to set the file descriptor for your read/lseek (doesn't need to be a "real" file descriptor...). |
911 | * Setting a function to NULL means that the default internal read is |
1058 | * Setting a function to NULL means that the default internal read is |
- | 1059 | * used (active from next mpg123_open call on). |
|
- | 1060 | * Note: As it would be troublesome to mess with this while having a file open, |
|
- | 1061 | * this implies mpg123_close(). */ |
|
- | 1062 | EXPORT int mpg123_replace_reader(mpg123_handle *mh, ssize_t (*r_read) (int, void *, size_t), off_t (*r_lseek)(int, off_t, int)); |
|
- | 1063 | ||
- | 1064 | /** Replace I/O functions with your own ones operating on some kind of handle instead of integer descriptors. |
|
- | 1065 | * The handle is a void pointer, so you can pass any data you want... |
|
- | 1066 | * mpg123_open_handle() is the call you make to use the I/O defined here. |
|
- | 1067 | * There is no fallback to internal read/seek here. |
|
912 | * used (active from next mpg123_open call on). */ |
1068 | * Note: As it would be troublesome to mess with this while having a file open, |
913 | EXPORT int mpg123_replace_reader( mpg123_handle *mh, |
1069 | * this mpg123_close() is implied here. |
914 | ssize_t (*r_read) (int, void *, size_t), |
1070 | * \param r_read The callback for reading (behaviour like posix read). |
- | 1071 | * \param r_lseek The callback for seeking (like posix lseek). |
|
- | 1072 | * \param cleanup A callback to clean up an I/O handle on mpg123_close, can be NULL for none (you take care of cleaning your handles). */ |
|
Line 915... | Line 1073... | ||
915 | off_t (*r_lseek)(int, off_t, int) ); |
1073 | EXPORT int mpg123_replace_reader_handle(mpg123_handle *mh, ssize_t (*r_read) (void *, void *, size_t), off_t (*r_lseek)(void *, off_t, int), void (*cleanup)(void*)); |
Line 916... | Line -... | ||
916 | - | ||
917 | /* @} */ |
1074 | |
918 | 1075 | /* @} */ |
|
919 | 1076 | ||
Line 920... | Line 1077... | ||
920 | #ifdef __cplusplus |
1077 | #ifdef __cplusplus |