📄 mpg123.h.in
字号:
{ enum mpg123_version version; /**< The MPEG version (1.0/2.0/2.5). */ int layer; /**< The MPEG Audio Layer (MP1/MP2/MP3). */ long rate; /**< The sampling rate in Hz. */ enum mpg123_mode mode; /**< The audio mode (Mono, Stereo, Joint-stero, Dual Channel). */ int mode_ext; /**< The mode extension bit flag. */ int framesize; /**< The size of the frame (in bytes). */ enum mpg123_flags flags; /**< MPEG Audio flag bits. */ int emphasis; /**< The emphasis type. */ int bitrate; /**< Bitrate of the frame (kbps). */ int abr_rate; /**< The target average bitrate. */ enum mpg123_vbr vbr; /**< The VBR mode. */};/** Get frame information about the MPEG audio bitstream and store it in a mpg123_frameinfo structure. */EXPORT int mpg123_info(mpg123_handle *mh, struct mpg123_frameinfo *mi);/** Get the safe output buffer size for all cases (when you want to replace the internal buffer) */EXPORT size_t mpg123_safe_buffer(); /** Make a full parsing scan of each frame in the file. ID3 tags are found. An accurate length * value is stored. Seek index will be filled. A seek back to current position * is performed. At all, this function refuses work when stream is * not seekable. * \return MPG123_OK or MPG123_ERR. */EXPORT int mpg123_scan(mpg123_handle *mh);/** Return, if possible, the full (expected) length of current track in samples. */EXPORT off_t mpg123_length(mpg123_handle *mh);/** Returns the time (seconds) per frame; <0 is error. */EXPORT double mpg123_tpf(mpg123_handle *mh);/** Get and reset the clip count. */EXPORT long mpg123_clip(mpg123_handle *mh);/*@}*//** \defgroup mpg123_metadata mpg123 metadata handling * * Functions to retrieve the metadata from MPEG Audio files and streams. * Also includes string handling functions. * * @{ *//** Data structure for storing strings in a safer way than a standard C-String. * Can also hold a number of null-terminated strings. */typedef struct { char* p; /**< pointer to the string data */ size_t size; /**< raw number of bytes allocated */ size_t fill; /**< number of used bytes (including closing zero byte) */} mpg123_string;/** Create and allocate memory for a new mpg123_string */EXPORT void mpg123_init_string(mpg123_string* sb);/** Free-up mempory for an existing mpg123_string */EXPORT void mpg123_free_string(mpg123_string* sb);/** Change the size of a mpg123_string * \return 0 on error, 1 on success */EXPORT int mpg123_resize_string(mpg123_string* sb, size_t news);/** Copy the contents of one mpg123_string string to another. * \return 0 on error, 1 on success */EXPORT int mpg123_copy_string(mpg123_string* from, mpg123_string* to);/** Append a C-String to an mpg123_string * \return 0 on error, 1 on success */EXPORT int mpg123_add_string(mpg123_string* sb, char* stuff);/** Set the conents of a mpg123_string to a C-String * \return 0 on error, 1 on success */EXPORT int mpg123_set_string(mpg123_string* sb, char* stuff);/** Sub data structure for ID3v2, for storing various text fields (including comments). * This is for ID3v2 COMM, TXXX and all the other text fields. * Only COMM and TXXX have a description, only COMM has a language. * You should consult the ID3v2 specification for the use of the various text fields ("frames" in ID3v2 documentation, I use "fields" here to separate from MPEG frames). */typedef struct{ char lang[3]; /**< Three-letter language code (not terminated). */ char id[4]; /**< The ID3v2 text field id, like TALB, TPE2, ... (4 characters, no string termination). */ mpg123_string description; /**< Empty for the generic comment... */ mpg123_string text; /**< ... */} mpg123_text;/** Data structure for storing IDV3v2 tags. * This structure is not a direct binary mapping with the file contents. * The ID3v2 text frames are allowed to contain multiple strings. * So check for null bytes until you reach the mpg123_string fill. * All text is encoded in UTF-8. */typedef struct{ unsigned char version; /**< 3 or 4 for ID3v2.3 or ID3v2.4. */ mpg123_string *title; /**< Title string (pointer into text_list). */ mpg123_string *artist; /**< Artist string (pointer into text_list). */ mpg123_string *album; /**< Album string (pointer into text_list). */ mpg123_string *year; /**< The year as a string (pointer into text_list). */ mpg123_string *genre; /**< Genre String (pointer into text_list). The genre string(s) may very well need postprocessing, esp. for ID3v2.3. */ mpg123_string *comment; /**< Pointer to last encountered comment text with empty description. */ /* Encountered ID3v2 fields are appended to these lists. There can be multiple occurences, the pointers above always point to the last encountered data. */ mpg123_text *comment_list; /**< Array of comments. */ size_t comments; /**< Number of comments. */ mpg123_text *text; /**< Array of ID3v2 text fields */ size_t texts; /**< Numer of text fields. */ mpg123_text *extra; /**< The array of extra (TXXX) fields. */ size_t extras; /**< Number of extra text (TXXX) fields. */} mpg123_id3v2;/** Data structure for ID3v1 tags (the last 128 bytes of a file). * Don't take anything for granted (like string termination)! * Also note the change ID3v1.1 did: comment[28] = 0; comment[19] = track_number * It is your task to support ID3v1 only or ID3v1.1 ...*/typedef struct{ char tag[3]; /**< Always the string "TAG", the classic intro. */ char title[30]; /**< Title string. */ char artist[30]; /**< Artist string. */ char album[30]; /**< Album string. */ char year[4]; /**< Year string. */ char comment[30]; /**< Comment string. */ unsigned char genre; /**< Genre index. */} mpg123_id3v1;#define MPG123_ID3 0x3 /**< 0011 There is some ID3 info. Also matches 0010 or NEW_ID3. */#define MPG123_NEW_ID3 0x1 /**< 0001 There is ID3 info that changed since last call to mpg123_id3. */#define MPG123_ICY 0xc /**< 1100 There is some ICY info. Also matches 0100 or NEW_ICY.*/#define MPG123_NEW_ICY 0x4 /**< 0100 There is ICY info that changed since last call to mpg123_icy. *//** Query if there is (new) meta info, be it ID3 or ICY (or something new in future). The check function returns a combination of flags. */EXPORT int mpg123_meta_check(mpg123_handle *mh); /* On error (no valid handle) just 0 is returned. *//** Point v1 and v2 to existing data structures wich may change on any next read/decode function call. * v1 and/or v2 can be set to NULL when there is no corresponding data. * \return Return value is MPG123_OK or MPG123_ERR, */EXPORT int mpg123_id3(mpg123_handle *mh, mpg123_id3v1 **v1, mpg123_id3v2 **v2);/** Point icy_meta to existing data structure wich may change on any next read/decode function call. * \return Return value is MPG123_OK or MPG123_ERR, */EXPORT int mpg123_icy(mpg123_handle *mh, char **icy_meta); /* same for ICY meta string *//* @} *//** \defgroup mpg123_advpar mpg123 advanced parameter API * * Direct access to a parameter set without full handle around it. * Possible uses: * - Influence behaviour of library _during_ initialization of handle (MPG123_VERBOSE). * - Use one set of parameters for multiple handles. * * The functions for handling mpg123_pars (mpg123_par() and mpg123_fmt() * family) directly return a fully qualified mpg123 error code, the ones * operating on full handles normally MPG123_OK or MPG123_ERR, storing the * specific error code itseld inside the handle. * * @{ *//** Opaque structure for the libmpg123 decoder parameters. */struct mpg123_pars_struct;/** Opaque structure for the libmpg123 decoder parameters. */typedef struct mpg123_pars_struct mpg123_pars;/** Create a handle with preset parameters. */EXPORT mpg123_handle *mpg123_parnew(mpg123_pars *mp, const char* decoder, int *error);/** Allocate memory for and return a pointer to a new mpg123_pars */EXPORT mpg123_pars *mpg123_new_pars(int *error);/** Delete and free up memory used by a mpg123_pars data structure */EXPORT void mpg123_delete_pars(mpg123_pars* mp);/** Configure mpg123 parameters to accept no output format at all, * use before specifying supported formats with mpg123_format */EXPORT int mpg123_fmt_none(mpg123_pars *mp);/** Configure mpg123 parameters to accept all formats * (also any custom rate you may set) -- this is default. */EXPORT int mpg123_fmt_all(mpg123_pars *mp);/** Set the audio format support of a mpg123_pars in detail: \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 0 on success, -1 if there was an error. /*/EXPORT int mpg123_fmt(mpg123_pars *mh, long rate, int channels, int encodings); /* 0 is good, -1 is error *//** Check to see if a specific format at a specific rate is supported * by mpg123_pars. * \return 0 for no support (that includes invalid parameters), MPG123_STEREO, * MPG123_MONO or MPG123_STEREO|MPG123_MONO. */EXPORT int mpg123_fmt_support(mpg123_pars *mh, long rate, int encoding);/** Set a specific parameter, for a specific mpg123_pars, using a parameter * type key chosen from the mpg123_parms enumeration, to the specified value. */EXPORT int mpg123_par(mpg123_pars *mp, enum mpg123_parms type, long value, double fvalue);/** Get a specific parameter, for a specific mpg123_pars. * See the mpg123_parms enumeration for a list of available parameters. */EXPORT int mpg123_getpar(mpg123_pars *mp, enum mpg123_parms type, long *val, double *fval);/* @} *//** \defgroup mpg123_lowio mpg123 low level I/O * You may want to do tricky stuff with I/O that does not work with mpg123's default file access or you want to make it decode into your own pocket... * * @{ *//** Replace default internal buffer with user-supplied buffer. * Instead of working on it's own private buffer, mpg123 will directly use the one you provide for storing decoded audio. */EXPORT int mpg123_replace_buffer(mpg123_handle *mh, unsigned char *data, size_t size);/** The max size of one frame's decoded output with current settings. * Use that to determine an appropriate minimum buffer size for decoding one frame. */EXPORT size_t mpg123_outblock(mpg123_handle *mh);/** Replace low-level stream access functions; read and lseek as known in POSIX. * You can use this to make any fancy file opening/closing yourself, * using open_fd to set the file descriptor for your read/lseek (doesn't need to be a "real" file descriptor...). * Setting a function to NULL means that the default internal read is * used (active from next mpg123_open call on). */EXPORT int mpg123_replace_reader( mpg123_handle *mh, ssize_t (*r_read) (int, void *, size_t), off_t (*r_lseek)(int, off_t, int) );/* @} */#ifdef __cplusplus}#endif#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -