📄 mpg123.h.in
字号:
* You can still force mpg123 to resample to a different one, but by default you will only get audio in one of these samplings. * \param list Store a pointer to the sample rates array there. * \param number Store the number of sample rates there. */EXPORT void mpg123_rates(const long **list, size_t *number);/** An array of supported audio encodings. * An audio encoding is a logic OR of members of mpg123_enc_enum. * \param list Store a pointer to the encodings array there. * \param number Store the number of encodings there. */EXPORT void mpg123_encodings(const int **list, size_t *number);/** Configure a mpg123 handle to accept no output format at all, * use before specifying supported formats with mpg123_format */EXPORT int mpg123_format_none(mpg123_handle *mh);/** Configure mpg123 handle to accept all formats * (also any custom rate you may set) -- this is default. */EXPORT int mpg123_format_all(mpg123_handle *mh);/** Set the audio format support of a mpg123_handle in detail: * \param mh audio decoder handle * \param rate The sample rate value (in Hertz). * \param channels A combination of MPG123_STEREO and MPG123_MONO. * \param encodings A combination of accepted encodings for rate and channels, p.ex MPG123_ENC_SIGNED16 | MPG123_ENC_ULAW_8 (or 0 for no support). * \return MPG123_OK on success, MPG123_ERR if there was an error. */EXPORT int mpg123_format(mpg123_handle *mh, long rate, int channels, int encodings);/** Check to see if a specific format at a specific rate is supported * by mpg123_handle. * \return 0 for no support (that includes invalid parameters), MPG123_STEREO, * MPG123_MONO or MPG123_STEREO|MPG123_MONO. */EXPORT int mpg123_format_support(mpg123_handle *mh, long rate, int encoding);/** Get the current output format written to the addresses givenr. */EXPORT int mpg123_getformat(mpg123_handle *mh, long *rate, int *channels, int *encoding);/*@}*//** \defgroup mpg123_input mpg123 file input and decoding * * Functions for input bitstream and decoding operations. * * @{ *//* reading samples / triggering decoding, possible return values: *//** Enumeration of the error codes returned by libmpg123 functions. *//** Open and prepare to decode the specified file by filesystem path. * This does not open HTTP urls; libmpg123 contains no networking code. * If you want to decode internet streams, use mpg123_open_fd() or mpg123_open_feed(). */EXPORT int mpg123_open(mpg123_handle *mh, char *path);/** Use an already opened file descriptor as the bitstream input * mpg123_close() will _not_ close the file descriptor. */EXPORT int mpg123_open_fd(mpg123_handle *mh, int fd);/** Open a new bitstream and prepare for direct feeding * This works together with mpg123_decode(); you are responsible for reading and feeding the input bitstream. */EXPORT int mpg123_open_feed(mpg123_handle *mh);/** Closes the source, if libmpg123 opened it. */EXPORT int mpg123_close(mpg123_handle *mh);/** Read from stream and decode up to outmemsize bytes. * \param outmemory address of output buffer to write to * \param outmemsize maximum number of bytes to write * \param done address to store the number of actually decoded bytes to * \return error/message code (watch out for MPG123_DONE and friends!) */EXPORT int mpg123_read(mpg123_handle *mh, unsigned char *outmemory, size_t outmemsize, size_t *done);/** Decode MPEG Audio from inmemory to outmemory. * This is very close to a drop-in replacement for old mpglib. * When you give zero-sized output buffer the input will be parsed until * decoded data is available. This enables you to get MPG123_NEW_FORMAT (and query it) * without taking decoded data. * \param inmemory input buffer * \param inmemsize number of input bytes * \param outmemory output buffer * \param outmemsize maximum number of output bytes * \param done address to store the number of actually decoded bytes to * \return error/message code (watch out especially for MPG123_NEED_MORE) */EXPORT int mpg123_decode(mpg123_handle *mh, unsigned char *inmemory, size_t inmemsize, unsigned char *outmemory, size_t outmemsize, size_t *done);/** Decode next MPEG frame to internal buffer * or read a frame and return after setting a new format. * \param num current frame offset gets stored there * \param audio This pointer is set to the internal buffer to read the decoded audio from. * \param bytes number of output bytes ready in the buffer */EXPORT int mpg123_decode_frame(mpg123_handle *mh, off_t *num, unsigned char **audio, size_t *bytes);/*@}*//** \defgroup mpg123_seek mpg123 position and seeking * * Functions querying and manipulating position in the decoded audio bitstream. * The position is measured in decoded audio samples, or MPEG frame offset for the specific functions. * If gapless code is in effect, the positions are adjusted to compensate the skipped padding/delay - meaning, you should not care about that at all and just use the position defined for the samples you get out of the decoder;-) * The general usage is modelled after stdlib's ftell() and fseek(). * Especially, the whence parameter for the seek functions has the same meaning as the one for fseek() and needs the same constants from stdlib.h: * - SEEK_SET: set position to (or near to) specified offset * - SEEK_CUR: change position by offset from now * - SEEK_END: set position to offset from end * * Note that sample-afccurate seek only works when gapless support has been enabled at compile time; seek is frame-accurate otherwise. * Also, seeking is not guaranteed to work for all streams (underlying stream may not support it). * * @{ *//** Returns the current position in samples. * On the next read, you'd get that sample. */EXPORT off_t mpg123_tell(mpg123_handle *mh);/** Returns the frame number that the next read will give you data from. */EXPORT off_t mpg123_tellframe(mpg123_handle *mh);/** Seek to a desired sample offset. * Set whence to SEEK_SET, SEEK_CUR or SEEK_END. * \return The resulting offset >= 0 or error/message code */EXPORT off_t mpg123_seek(mpg123_handle *mh, off_t sampleoff, int whence);/** Seek to a desired sample offset in data feeding mode. * This just prepares things to be right only if you ensure that the next chunk of input data will be from input_offset byte position. * \param input_offset The position it expects to be at the * next time data is fed to mpg123_decode(). * \return The resulting offset >= 0 or error/message code */EXPORT off_t mpg123_feedseek(mpg123_handle *mh, off_t sampleoff, int whence, off_t *input_offset);/** Seek to a desired MPEG frame index. * Set whence to SEEK_SET, SEEK_CUR or SEEK_END. * \return The resulting offset >= 0 or error/message code */EXPORT off_t mpg123_seek_frame(mpg123_handle *mh, off_t frameoff, int whence);/** Return a MPEG frame offset corresponding to an offset in seconds. * 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. * \return frame offset >= 0 or error/message code */EXPORT off_t mpg123_timeframe(mpg123_handle *mh, double sec);/** Give access to the frame index table that is managed for seeking. * You are asked not to modify the values... unless you are really aware of what you are doing. * \param offsets pointer to the index array * \param step one index byte offset advances this many MPEG frames * \param fill number of recorded index offsets; size of the array */EXPORT int mpg123_index(mpg123_handle *mh, off_t **offsets, off_t *step, size_t *fill);/** Get information about current and remaining frames/seconds. * WARNING: This function is there because of special usage by standalone mpg123 and may be removed in the final version of libmpg123! * You provide an offset (in frames) from now and a number of output bytes * served by libmpg123 but not yet played. You get the projected current frame * and seconds, as well as the remaining frames/seconds. This does _not_ care * about skipped samples due to gapless playback. */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);/*@}*//** \defgroup mpg123_voleq mpg123 volume and equalizer * * @{ */enum mpg123_channels{ MPG123_LEFT=0x1, /**< The Left Channel. */ MPG123_RIGHT=0x2 /**< The Right Channel. */};/** Set the 32 Band Audio Equalizer settings. * \param channel Can be MPG123_LEFT, MPG123_RIGHT or MPG123_LEFT|MPG123_RIGHT for both. * \param band The equaliser band to change (from 0 to 31) * \param val The (linear) adjustment factor. */EXPORT int mpg123_eq(mpg123_handle *mh, enum mpg123_channels channel, int band, double val);/** Reset the 32 Band Audio Equalizer settings to flat */EXPORT int mpg123_reset_eq(mpg123_handle *mh);/** Set the absolute output volume including the RVA setting, * vol<0 just applies (a possibly changed) RVA setting. */EXPORT int mpg123_volume(mpg123_handle *mh, double vol);/** Adjust output volume including the RVA setting by chosen amount */EXPORT int mpg123_volume_change(mpg123_handle *mh, double change);/** Return current volume setting, the actual value due to RVA, and the RVA * adjustment itself. It's all as double float value to abstract the sample * format. The volume values are linear factors / amplitudes (not percent) * and the RVA value is in decibels. */EXPORT int mpg123_getvolume(mpg123_handle *mh, double *base, double *really, double *rva_db);/* TODO: Set some preamp in addition / to replace internal RVA handling? *//*@}*//** \defgroup mpg123_status mpg123 status and information * * @{ *//** Enumeration of the mode types of Variable Bitrate */enum mpg123_vbr { MPG123_CBR=0, /**< Constant Bitrate Mode (default) */ MPG123_VBR, /**< Variable Bitrate Mode */ MPG123_ABR /**< Average Bitrate Mode */};/** Enumeration of the MPEG Versions */enum mpg123_version { MPG123_1_0=0, /**< MPEG Version 1.0 */ MPG123_2_0, /**< MPEG Version 2.0 */ MPG123_2_5 /**< MPEG Version 2.5 */};/** Enumeration of the MPEG Audio mode. * Only the mono mode has 1 channel, the others have 2 channels. */enum mpg123_mode { MPG123_M_STEREO=0, /**< Standard Stereo. */ MPG123_M_JOINT, /**< Joint Stereo. */ MPG123_M_DUAL, /**< Dual Channel. */ MPG123_M_MONO /**< Single Channel. */};/** Enumeration of the MPEG Audio flag bits */enum mpg123_flags { MPG123_CRC=0x1, /**< The bitstream is error protected using 16-bit CRC. */ MPG123_COPYRIGHT=0x2, /**< The bitstream is copyrighted. */ MPG123_PRIVATE=0x4, /**< The private bit has been set. */ MPG123_ORIGINAL=0x8 /**< The bitstream is an original, not a copy. */};/** Data structure for storing information about a frame of MPEG Audio */struct mpg123_frameinfo
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -