API documentation for libmpg123, libout123, and libsyn123
Let me emphasize that the policy for the lib*123 family is to always stay backwards compatible -- only additions are planned (and it's not yet planned to change the plans;-).
Classes | |
struct | mpg123_string |
struct | mpg123_text |
struct | mpg123_picture |
struct | mpg123_id3v2 |
struct | mpg123_id3v1 |
Macros | |
#define | MPG123_ID3 0x3 |
#define | MPG123_NEW_ID3 0x1 |
#define | MPG123_ICY 0xc |
#define | MPG123_NEW_ICY 0x4 |
Detailed Description
Functions to retrieve the metadata from MPEG Audio files and streams. Also includes string handling functions.
Macro Definition Documentation
◆ MPG123_ID3
#define MPG123_ID3 0x3 |
◆ MPG123_NEW_ID3
#define MPG123_NEW_ID3 0x1 |
◆ MPG123_ICY
#define MPG123_ICY 0xc |
◆ MPG123_NEW_ICY
#define MPG123_NEW_ICY 0x4 |
Enumeration Type Documentation
◆ mpg123_text_encoding
enum mpg123_text_encoding |
The mpg123 text encodings. This contains encodings we encounter in ID3 tags or ICY meta info.
◆ mpg123_id3_enc
enum mpg123_id3_enc |
The encoding byte values from ID3v2.
◆ mpg123_id3_pic_type
enum mpg123_id3_pic_type |
The picture type values from ID3v2.
Function Documentation
◆ mpg123_new_string()
MPG123_EXPORT mpg123_string* mpg123_new_string | ( | const char * | val | ) |
Allocate and intialize a new string.
- Parameters
-
val optional initial string value (can be NULL)
◆ mpg123_delete_string()
MPG123_EXPORT void mpg123_delete_string | ( | mpg123_string * | sb | ) |
Free memory of contents and the string structure itself.
- Parameters
-
sb string handle
◆ mpg123_init_string()
MPG123_EXPORT void mpg123_init_string | ( | mpg123_string * | sb | ) |
Initialize an existing mpg123_string structure to {NULL, 0, 0}. If you hand in a NULL pointer here, your program should crash. The other string functions are more forgiving, but this one here is too basic.
- Parameters
-
sb string handle (address of existing structure on your side)
◆ mpg123_free_string()
MPG123_EXPORT void mpg123_free_string | ( | mpg123_string * | sb | ) |
Free-up memory of the contents of an mpg123_string (not the struct itself). This also calls mpg123_init_string() and hence is safe to be called repeatedly.
- Parameters
-
sb string handle
◆ mpg123_resize_string()
MPG123_EXPORT int mpg123_resize_string | ( | mpg123_string * | sb, |
size_t | news | ||
) |
Change the size of a mpg123_string
- Parameters
-
sb string handle news new size in bytes
- Returns
- 0 on error, 1 on success
◆ mpg123_grow_string()
MPG123_EXPORT int mpg123_grow_string | ( | mpg123_string * | sb, |
size_t | news | ||
) |
Increase size of a mpg123_string if necessary (it may stay larger). Note that the functions for adding and setting in current libmpg123 use this instead of mpg123_resize_string(). That way, you can preallocate memory and safely work afterwards with pieces.
- Parameters
-
sb string handle news new minimum size
- Returns
- 0 on error, 1 on success
◆ mpg123_copy_string()
MPG123_EXPORT int mpg123_copy_string | ( | mpg123_string * | from, |
mpg123_string * | to | ||
) |
Copy the contents of one mpg123_string string to another. Yes the order of arguments is reversed compated to memcpy().
- Parameters
-
from string handle to string handle
- Returns
- 0 on error, 1 on success
◆ mpg123_move_string()
MPG123_EXPORT int mpg123_move_string | ( | mpg123_string * | from, |
mpg123_string * | to | ||
) |
Move the contents of one mpg123_string string to another. This frees any memory associated with the target and moves over the pointers from the source, leaving the source without content after that. The only possible error is that you hand in NULL pointers. If you handed in a valid source, its contents will be gone, even if there was no target to move to. If you hand in a valid target, its original contents will also always be gone, to be replaced with the source's contents if there was some.
- Parameters
-
from source string handle to target string handle
- Returns
- 0 on error, 1 on success
◆ mpg123_add_string()
MPG123_EXPORT int mpg123_add_string | ( | mpg123_string * | sb, |
const char * | stuff | ||
) |
Append a C-String to an mpg123_string
- Parameters
-
sb string handle stuff to append
- Returns
- 0 on error, 1 on success
◆ mpg123_add_substring()
MPG123_EXPORT int mpg123_add_substring | ( | mpg123_string * | sb, |
const char * | stuff, | ||
size_t | from, | ||
size_t | count | ||
) |
Append a C-substring to an mpg123 string
- Parameters
-
sb string handle stuff content to copy from offset to copy from count number of characters to copy (a null-byte is always appended)
- Returns
- 0 on error, 1 on success
◆ mpg123_set_string()
MPG123_EXPORT int mpg123_set_string | ( | mpg123_string * | sb, |
const char * | stuff | ||
) |
Set the content of a mpg123_string to a C-string
- Parameters
-
sb string handle stuff content to copy
- Returns
- 0 on error, 1 on success
◆ mpg123_set_substring()
MPG123_EXPORT int mpg123_set_substring | ( | mpg123_string * | sb, |
const char * | stuff, | ||
size_t | from, | ||
size_t | count | ||
) |
Set the content of a mpg123_string to a C-substring
- Parameters
-
sb string handle stuff the future content from offset to copy from count number of characters to copy (a null-byte is always appended)
- Returns
- 0 on error, 1 on success
◆ mpg123_strlen()
MPG123_EXPORT size_t mpg123_strlen | ( | mpg123_string * | sb, |
int | utf8 | ||
) |
Count characters in a mpg123 string (non-null bytes or Unicode points). This function is of limited use, as it does just count code points encoded in an UTF-8 string, only loosely related to the count of visible characters. Get your full Unicode handling support elsewhere.
- Parameters
-
sb string handle utf8 a flag to tell if the string is in utf8 encoding
- Returns
- character count
◆ mpg123_chomp_string()
MPG123_EXPORT int mpg123_chomp_string | ( | mpg123_string * | sb | ) |
Remove trailing \r and \n, if present.
- Parameters
-
sb string handle
- Returns
- 0 on error, 1 on success
◆ mpg123_same_string()
MPG123_EXPORT int mpg123_same_string | ( | mpg123_string * | a, |
mpg123_string * | b | ||
) |
Determine if two strings contain the same data. This only returns 1 if both given handles are non-NULL and if they are filled with the same bytes.
- Parameters
-
a first string handle b second string handle
- Returns
- 0 for different strings, 1 for identical
◆ mpg123_enc_from_id3()
MPG123_EXPORT enum mpg123_text_encoding mpg123_enc_from_id3 | ( | unsigned char | id3_enc_byte | ) |
Convert ID3 encoding byte to mpg123 encoding index.
Note that this name is mapped to mpg123_enc_from_id3_2() instead unless MPG123_ENUM_API is defined.
- Parameters
-
id3_enc_byte the ID3 encoding code
- Returns
- the mpg123 encoding index
◆ mpg123_enc_from_id3_2()
MPG123_EXPORT int mpg123_enc_from_id3_2 | ( | unsigned char | id3_enc_byte | ) |
Convert ID3 encoding byte to mpg123 encoding index. No enums.
This is actually called instead of mpg123_enc_from_id3() unless MPG123_ENUM_API is defined.
- Parameters
-
id3_enc_byte the ID3 encoding code
- Returns
- the mpg123 encoding index
◆ mpg123_store_utf8()
MPG123_EXPORT int mpg123_store_utf8 | ( | mpg123_string * | sb, |
enum mpg123_text_encoding | enc, | ||
const unsigned char * | source, | ||
size_t | source_size | ||
) |
Store text data in string, after converting to UTF-8 from indicated encoding.
Note that this name is mapped to mpg123_store_utf8_2() instead unless MPG123_ENUM_API is defined.
A prominent error can be that you provided an unknown encoding value, or this build of libmpg123 lacks support for certain encodings (ID3 or ICY stuff missing). Also, you might want to take a bit of care with preparing the data; for example, strip leading zeroes (I have seen that).
- Parameters
-
sb target string enc mpg123 text encoding value source source buffer with plain unsigned bytes (you might need to cast from signed char) source_size number of bytes in the source buffer
- Returns
- 0 on error, 1 on success (on error, mpg123_free_string is called on sb)
◆ mpg123_store_utf8_2()
MPG123_EXPORT int mpg123_store_utf8_2 | ( | mpg123_string * | sb, |
int | enc, | ||
const unsigned char * | source, | ||
size_t | source_size | ||
) |
Store text data in string, after converting to UTF-8 from indicated encoding. No enums.
This is actually called instead of mpg123_store_utf8() unless MPG123_ENUM_API is defined.
A prominent error can be that you provided an unknown encoding value, or this build of libmpg123 lacks support for certain encodings (ID3 or ICY stuff missing). Also, you might want to take a bit of care with preparing the data; for example, strip leading zeroes (I have seen that).
- Parameters
-
sb target string enc mpg123 text encoding value (enum mpg123_text_encoding) source source buffer with plain unsigned bytes (you might need to cast from signed char) source_size number of bytes in the source buffer
- Returns
- 0 on error, 1 on success (on error, mpg123_free_string is called on sb)
◆ mpg123_meta_check()
MPG123_EXPORT int mpg123_meta_check | ( | mpg123_handle * | mh | ) |
Query if there is (new) meta info, be it ID3 or ICY (or something new in future).
- Parameters
-
mh handle
- Returns
- combination of flags, 0 on error (same as "nothing new")
◆ mpg123_meta_free()
MPG123_EXPORT void mpg123_meta_free | ( | mpg123_handle * | mh | ) |
Clean up meta data storage (ID3v2 and ICY), freeing memory.
- Parameters
-
mh handle
◆ mpg123_id3()
MPG123_EXPORT int mpg123_id3 | ( | mpg123_handle * | mh, |
mpg123_id3v1 ** | v1, | ||
mpg123_id3v2 ** | v2 | ||
) |
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.
- Returns
- MPG123_OK on success
◆ mpg123_id3_raw()
MPG123_EXPORT int mpg123_id3_raw | ( | mpg123_handle * | mh, |
unsigned char ** | v1, | ||
size_t * | v1_size, | ||
unsigned char ** | v2, | ||
size_t * | v2_size | ||
) |
Return pointers to and size of stored raw ID3 data if storage has been configured with MPG123_STORE_RAW_ID3 and stream parsing passed the metadata already. Null value with zero size is a possibility! The storage can change at any next API call.
- Parameters
-
mh mpg123 handle v1 address to store pointer to v1 tag v1_size size of v1 data in bytes v2 address to store pointer to v2 tag v2_size size of v2 data in bytes
- Returns
- MPG123_OK or MPG123_ERR. Only on MPG123_OK the output values are set.
◆ mpg123_icy()
MPG123_EXPORT int mpg123_icy | ( | mpg123_handle * | mh, |
char ** | icy_meta | ||
) |
Point icy_meta to existing data structure wich may change on any next read/decode function call.
- Parameters
-
mh handle icy_meta return address for ICY meta string (set to NULL if nothing there)
- Returns
- MPG123_OK on success
◆ mpg123_icy2utf8()
MPG123_EXPORT char* mpg123_icy2utf8 | ( | const char * | icy_text | ) |
Decode from windows-1252 (the encoding ICY metainfo used) to UTF-8. Note that this is very similar to mpg123_store_utf8(&sb, mpg123_text_icy, icy_text, strlen(icy_text+1)) .
- Parameters
-
icy_text The input data in ICY encoding
- Returns
- pointer to newly allocated buffer with UTF-8 data (You free() it!)