ReactOS 0.4.16-dev-122-g325d74c
Collaboration diagram for mpg123 metadata handling:

Modules

 mpg123 advanced parameter API
 

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
 

Enumerations

enum  mpg123_text_encoding {
  mpg123_text_unknown = 0 , mpg123_text_utf8 = 1 , mpg123_text_latin1 = 2 , mpg123_text_icy = 3 ,
  mpg123_text_cp1252 = 4 , mpg123_text_utf16 = 5 , mpg123_text_utf16bom = 6 , mpg123_text_utf16be = 7 ,
  mpg123_text_max = 7
}
 
enum  mpg123_id3_enc {
  mpg123_id3_latin1 = 0 , mpg123_id3_utf16bom = 1 , mpg123_id3_utf16be = 2 , mpg123_id3_utf8 = 3 ,
  mpg123_id3_enc_max = 3
}
 
enum  mpg123_id3_pic_type {
  mpg123_id3_pic_other = 0 , mpg123_id3_pic_icon = 1 , mpg123_id3_pic_other_icon = 2 , mpg123_id3_pic_front_cover = 3 ,
  mpg123_id3_pic_back_cover = 4 , mpg123_id3_pic_leaflet = 5 , mpg123_id3_pic_media = 6 , mpg123_id3_pic_lead = 7 ,
  mpg123_id3_pic_artist = 8 , mpg123_id3_pic_conductor = 9 , mpg123_id3_pic_orchestra = 10 , mpg123_id3_pic_composer = 11 ,
  mpg123_id3_pic_lyricist = 12 , mpg123_id3_pic_location = 13 , mpg123_id3_pic_recording = 14 , mpg123_id3_pic_performance = 15 ,
  mpg123_id3_pic_video = 16 , mpg123_id3_pic_fish = 17 , mpg123_id3_pic_illustration = 18 , mpg123_id3_pic_artist_logo = 19 ,
  mpg123_id3_pic_publisher_logo = 20
}
 

Functions

MPG123_EXPORT mpg123_stringmpg123_new_string (const char *val)
 
MPG123_EXPORT void mpg123_delete_string (mpg123_string *sb)
 
MPG123_EXPORT void mpg123_init_string (mpg123_string *sb)
 
MPG123_EXPORT void mpg123_free_string (mpg123_string *sb)
 
MPG123_EXPORT int mpg123_resize_string (mpg123_string *sb, size_t news)
 
MPG123_EXPORT int mpg123_grow_string (mpg123_string *sb, size_t news)
 
MPG123_EXPORT int mpg123_copy_string (mpg123_string *from, mpg123_string *to)
 
MPG123_EXPORT int mpg123_move_string (mpg123_string *from, mpg123_string *to)
 
MPG123_EXPORT int mpg123_add_string (mpg123_string *sb, const char *stuff)
 
MPG123_EXPORT int mpg123_add_substring (mpg123_string *sb, const char *stuff, size_t from, size_t count)
 
MPG123_EXPORT int mpg123_set_string (mpg123_string *sb, const char *stuff)
 
MPG123_EXPORT int mpg123_set_substring (mpg123_string *sb, const char *stuff, size_t from, size_t count)
 
MPG123_EXPORT size_t mpg123_strlen (mpg123_string *sb, int utf8)
 
MPG123_EXPORT int mpg123_chomp_string (mpg123_string *sb)
 
MPG123_EXPORT int mpg123_same_string (mpg123_string *a, mpg123_string *b)
 
MPG123_EXPORT enum mpg123_text_encoding mpg123_enc_from_id3 (unsigned char id3_enc_byte)
 
MPG123_EXPORT int mpg123_store_utf8 (mpg123_string *sb, enum mpg123_text_encoding enc, const unsigned char *source, size_t source_size)
 
MPG123_EXPORT int mpg123_meta_check (mpg123_handle *mh)
 
MPG123_EXPORT void mpg123_meta_free (mpg123_handle *mh)
 
MPG123_EXPORT int mpg123_id3 (mpg123_handle *mh, mpg123_id3v1 **v1, mpg123_id3v2 **v2)
 
MPG123_EXPORT int mpg123_id3_raw (mpg123_handle *mh, unsigned char **v1, size_t *v1_size, unsigned char **v2, size_t *v2_size)
 
MPG123_EXPORT int mpg123_icy (mpg123_handle *mh, char **icy_meta)
 
MPG123_EXPORT charmpg123_icy2utf8 (const char *icy_text)
 

Detailed Description

Functions to retrieve the metadata from MPEG Audio files and streams. Also includes string handling functions.

Macro Definition Documentation

◆ MPG123_ICY

#define MPG123_ICY   0xc

1100 There is some ICY info. Also matches 0100 or NEW_ICY.

Definition at line 1466 of file mpg123.h.

◆ MPG123_ID3

#define MPG123_ID3   0x3

0011 There is some ID3 info. Also matches 0010 or NEW_ID3.

Definition at line 1464 of file mpg123.h.

◆ MPG123_NEW_ICY

#define MPG123_NEW_ICY   0x4

0100 There is ICY info that changed since last call to mpg123_icy.

Definition at line 1467 of file mpg123.h.

◆ MPG123_NEW_ID3

#define MPG123_NEW_ID3   0x1

0001 There is ID3 info that changed since last call to mpg123_id3.

Definition at line 1465 of file mpg123.h.

Enumeration Type Documentation

◆ mpg123_id3_enc

The encoding byte values from ID3v2.

Enumerator
mpg123_id3_latin1 

Note: This sometimes can mean anything in practice...

mpg123_id3_utf16bom 

UTF16, UCS-2 ... it's all the same for practical purposes.

mpg123_id3_utf16be 

Big-endian UTF-16, BOM see note for mpg123_text_utf16be.

mpg123_id3_utf8 

Our lovely overly ASCII-compatible 8 byte encoding for the world.

mpg123_id3_enc_max 

Placeholder to check valid range of encoding byte.

Definition at line 1342 of file mpg123.h.

1343{
1346 ,mpg123_id3_utf16be = 2
1347 ,mpg123_id3_utf8 = 3
1348 ,mpg123_id3_enc_max = 3
1349};
@ mpg123_id3_latin1
Definition: mpg123.h:1344
@ mpg123_id3_utf16be
Definition: mpg123.h:1346
@ mpg123_id3_enc_max
Definition: mpg123.h:1348
@ mpg123_id3_utf16bom
Definition: mpg123.h:1345
@ mpg123_id3_utf8
Definition: mpg123.h:1347

◆ mpg123_id3_pic_type

The picture type values from ID3v2.

Enumerator
mpg123_id3_pic_other 

see ID3v2 docs

mpg123_id3_pic_icon 

see ID3v2 docs

mpg123_id3_pic_other_icon 

see ID3v2 docs

mpg123_id3_pic_front_cover 

see ID3v2 docs

mpg123_id3_pic_back_cover 

see ID3v2 docs

mpg123_id3_pic_leaflet 

see ID3v2 docs

mpg123_id3_pic_media 

see ID3v2 docs

mpg123_id3_pic_lead 

see ID3v2 docs

mpg123_id3_pic_artist 

see ID3v2 docs

mpg123_id3_pic_conductor 

see ID3v2 docs

mpg123_id3_pic_orchestra 

see ID3v2 docs

mpg123_id3_pic_composer 

see ID3v2 docs

mpg123_id3_pic_lyricist 

see ID3v2 docs

mpg123_id3_pic_location 

see ID3v2 docs

mpg123_id3_pic_recording 

see ID3v2 docs

mpg123_id3_pic_performance 

see ID3v2 docs

mpg123_id3_pic_video 

see ID3v2 docs

mpg123_id3_pic_fish 

see ID3v2 docs

mpg123_id3_pic_illustration 

see ID3v2 docs

mpg123_id3_pic_artist_logo 

see ID3v2 docs

mpg123_id3_pic_publisher_logo 

see ID3v2 docs

Definition at line 1384 of file mpg123.h.

1385{
1403 ,mpg123_id3_pic_fish = 17
1407};
@ mpg123_id3_pic_publisher_logo
Definition: mpg123.h:1406
@ mpg123_id3_pic_performance
Definition: mpg123.h:1401
@ mpg123_id3_pic_leaflet
Definition: mpg123.h:1391
@ mpg123_id3_pic_recording
Definition: mpg123.h:1400
@ mpg123_id3_pic_back_cover
Definition: mpg123.h:1390
@ mpg123_id3_pic_video
Definition: mpg123.h:1402
@ mpg123_id3_pic_conductor
Definition: mpg123.h:1395
@ mpg123_id3_pic_media
Definition: mpg123.h:1392
@ mpg123_id3_pic_lead
Definition: mpg123.h:1393
@ mpg123_id3_pic_artist
Definition: mpg123.h:1394
@ mpg123_id3_pic_artist_logo
Definition: mpg123.h:1405
@ mpg123_id3_pic_orchestra
Definition: mpg123.h:1396
@ mpg123_id3_pic_icon
Definition: mpg123.h:1387
@ mpg123_id3_pic_composer
Definition: mpg123.h:1397
@ mpg123_id3_pic_other
Definition: mpg123.h:1386
@ mpg123_id3_pic_location
Definition: mpg123.h:1399
@ mpg123_id3_pic_illustration
Definition: mpg123.h:1404
@ mpg123_id3_pic_front_cover
Definition: mpg123.h:1389
@ mpg123_id3_pic_lyricist
Definition: mpg123.h:1398
@ mpg123_id3_pic_fish
Definition: mpg123.h:1403
@ mpg123_id3_pic_other_icon
Definition: mpg123.h:1388

◆ mpg123_text_encoding

The mpg123 text encodings. This contains encodings we encounter in ID3 tags or ICY meta info.

Enumerator
mpg123_text_unknown 

Unkown encoding... mpg123_id3_encoding can return that on invalid codes.

mpg123_text_utf8 

UTF-8

mpg123_text_latin1 

ISO-8859-1. Note that sometimes latin1 in ID3 is abused for totally different encodings.

mpg123_text_icy 

ICY metadata encoding, usually CP-1252 but we take it as UTF-8 if it qualifies as such.

mpg123_text_cp1252 

Really CP-1252 without any guessing.

mpg123_text_utf16 

Some UTF-16 encoding. The last of a set of leading BOMs (byte order mark) rules. When there is no BOM, big endian ordering is used. Note that UCS-2 qualifies as UTF-8 when you don't mess with the reserved code points. If you want to decode little endian data without BOM you need to prepend 0xff 0xfe yourself.

mpg123_text_utf16bom 

Just an alias for UTF-16, ID3v2 has this as distinct code.

mpg123_text_utf16be 

Another alias for UTF16 from ID3v2. Note, that, because of the mess that is reality, BOMs are used if encountered. There really is not much distinction between the UTF16 types for mpg123 One exception: Since this is seen in ID3v2 tags, leading null bytes are skipped for all other UTF16 types (we expect a BOM before real data there), not so for utf16be!

mpg123_text_max 

Placeholder for the maximum encoding value.

Definition at line 1322 of file mpg123.h.

1323{
1325 ,mpg123_text_utf8 = 1
1326 ,mpg123_text_latin1 = 2
1327 ,mpg123_text_icy = 3
1328 ,mpg123_text_cp1252 = 4
1329 ,mpg123_text_utf16 = 5
1338 ,mpg123_text_max = 7
1339};
@ mpg123_text_cp1252
Definition: mpg123.h:1328
@ mpg123_text_max
Definition: mpg123.h:1338
@ mpg123_text_utf16bom
Definition: mpg123.h:1333
@ mpg123_text_utf16be
Definition: mpg123.h:1334
@ mpg123_text_unknown
Definition: mpg123.h:1324
@ mpg123_text_icy
Definition: mpg123.h:1327
@ mpg123_text_utf16
Definition: mpg123.h:1329
@ mpg123_text_utf8
Definition: mpg123.h:1325
@ mpg123_text_latin1
Definition: mpg123.h:1326

Function Documentation

◆ mpg123_add_string()

MPG123_EXPORT int mpg123_add_string ( mpg123_string sb,
const char stuff 
)

Append a C-String to an mpg123_string

Parameters
sbstring handle
stuffto append
Returns
0 on error, 1 on success

Definition at line 135 of file stringbuf.c.

136{
137 debug1("adding %s", stuff);
138 return mpg123_add_substring(sb, stuff, 0, stuff ? strlen(stuff) : 0);
139}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
superblock * sb
Definition: btrfs.c:4261
int attribute_align_arg mpg123_add_substring(mpg123_string *sb, const char *stuff, size_t from, size_t count)
Definition: stringbuf.c:141
#define debug1(s, a)
Definition: debug.h:61

Referenced by mpg123_set_string().

◆ 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
sbstring handle
stuffcontent to copy
fromoffset to copy from
countnumber of characters to copy (a null-byte is always appended)
Returns
0 on error, 1 on success

Definition at line 141 of file stringbuf.c.

142{
143 debug("adding a substring");
144 if(!sb || !stuff)
145 return 0;
146 if(sb->fill) /* includes zero byte... */
147 {
148 if( (SIZE_MAX - sb->fill >= count) /* Avoid overflow. */
149 && (sb->size >= sb->fill+count || mpg123_grow_string(sb, sb->fill+count)) )
150 {
151 memcpy(sb->p+sb->fill-1, stuff+from, count);
152 sb->fill += count;
153 sb->p[sb->fill-1] = 0; /* Terminate! */
154 }
155 else return 0;
156 }
157 else
158 {
160 {
161 memcpy(sb->p, stuff+from, count);
162 sb->fill = count+1;
163 sb->p[sb->fill-1] = 0; /* Terminate! */
164 }
165 else return 0;
166 }
167 return 1;
168}
GLuint GLuint GLsizei count
Definition: gl.h:1545
int attribute_align_arg mpg123_grow_string(mpg123_string *sb, size_t new)
Definition: stringbuf.c:51
#define SIZE_MAX
Definition: limits.h:75
#define debug(msg)
Definition: key_call.c:71
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
CardRegion * from
Definition: spigame.cpp:19

Referenced by mpg123_add_string(), and mpg123_set_substring().

◆ mpg123_chomp_string()

MPG123_EXPORT int mpg123_chomp_string ( mpg123_string sb)

Remove trailing \r and \n, if present.

Parameters
sbstring handle
Returns
0 on error, 1 on success

Definition at line 218 of file stringbuf.c.

219{
220 ssize_t i;
221 if(!sb || !sb->fill) return 0;
222
223 /* Ensure that it is zero-terminated. */
224 sb->p[sb->fill-1] = 0;
225 for(i=sb->fill-2; i>=0; --i)
226 {
227 char *c = sb->p+i;
228 /* Stop at the first proper character. */
229 if(*c && *c != '\r' && *c != '\n') break;
230 else *c = 0;
231 }
232 /* initial fill at least 1, so i at least -1,
233 +2 means nothing happened for fill=1 .
234 With i=0, we got one non-null character, fill shall be 2
235 to accomodate the trailing zero. */
236 sb->fill = (size_t)i+2;
237
238 return 1;
239}
__kernel_size_t size_t
Definition: linux.h:237
const GLubyte * c
Definition: glext.h:8905
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
int ssize_t
Definition: rosdhcp.h:48

◆ 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
fromstring handle
tostring handle
Returns
0 on error, 1 on success

Definition at line 93 of file stringbuf.c.

94{
95 size_t fill;
96 char *text;
97
98 debug2("called copy_string with %p -> %p", (void*)from, (void*)to);
99 if(to == NULL)
100 return 0;
101 if(from == NULL)
102 {
103 fill = 0;
104 text = NULL;
105 }
106 else
107 {
108 fill = from->fill;
109 text = from->p;
110 }
111
113 {
114 if(fill) /* Avoid memcpy(NULL, NULL, 0) */
115 memcpy(to->p, text, fill);
116 to->fill = fill;
117 return 1;
118 }
119 else return 0;
120}
_STLP_MOVE_TO_STD_NAMESPACE void fill(_ForwardIter __first, _ForwardIter __last, const _Tp &__val)
Definition: _algobase.h:449
#define NULL
Definition: types.h:112
const WCHAR * text
Definition: package.c:1794
char * p
Definition: mpg123.h:1193
size_t fill
Definition: mpg123.h:1195
int attribute_align_arg mpg123_resize_string(mpg123_string *sb, size_t new)
Definition: stringbuf.c:59
#define debug2(s, a, b)
Definition: debug.h:62

◆ mpg123_delete_string()

MPG123_EXPORT void mpg123_delete_string ( mpg123_string sb)

Free memory of contents and the string structure itself.

Parameters
sbstring handle

Definition at line 27 of file stringbuf.c.

28{
29 if(!sb)
30 return;
32 free(sb);
33}
#define free
Definition: debug_ros.c:5
void attribute_align_arg mpg123_free_string(mpg123_string *sb)
Definition: stringbuf.c:43

◆ 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.

Parameters
id3_enc_bytethe ID3 encoding code
Returns
the mpg123 encoding index

Definition at line 1591 of file libmpg123.c.

1592{
1593 switch(id3_enc_byte)
1594 {
1596 case mpg123_id3_utf16bom: return mpg123_text_utf16bom; /* ID3v2.3 has UCS-2 with BOM here. */
1598 case mpg123_id3_utf8: return mpg123_text_utf8;
1599 default: return mpg123_text_unknown;
1600 }
1601}

◆ 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
sbstring handle

Definition at line 43 of file stringbuf.c.

44{
45 if(!sb)
46 return;
47 if(sb->p != NULL) free(sb->p);
49}
void attribute_align_arg mpg123_init_string(mpg123_string *sb)
Definition: stringbuf.c:35

Referenced by free_mpg123_picture(), free_mpg123_text(), mpg123_delete_string(), mpg123_move_string(), mpg123_store_utf8(), process_comment(), process_extra(), and process_picture().

◆ 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
sbstring handle
newsnew minimum size
Returns
0 on error, 1 on success

Definition at line 51 of file stringbuf.c.

52{
53 if(!sb)
54 return 0;
55 if(sb->size < new) return mpg123_resize_string(sb, new);
56 else return 1;
57}

Referenced by convert_latin1(), convert_utf16bom(), convert_utf8(), mpg123_add_substring(), and store_id3_text().

◆ 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
mhhandle
icy_metareturn address for ICY meta string (set to NULL if nothing there)
Returns
MPG123_OK on success

Definition at line 1557 of file libmpg123.c.

1558{
1559 if(mh == NULL) return MPG123_BAD_HANDLE;
1560#ifndef NO_ICY
1561 if(icy_meta == NULL)
1562 {
1564 return MPG123_ERR;
1565 }
1566 *icy_meta = NULL;
1567
1568 if(mh->metaflags & MPG123_ICY)
1569 {
1570 *icy_meta = mh->icy.data;
1571 mh->metaflags |= MPG123_ICY;
1572 mh->metaflags &= ~MPG123_NEW_ICY;
1573 }
1574 return MPG123_OK;
1575#else
1577 return MPG123_ERR;
1578#endif
1579}
@ MPG123_BAD_HANDLE
Definition: mpg123.h:393
@ MPG123_ERR
Definition: mpg123.h:382
@ MPG123_NULL_POINTER
Definition: mpg123.h:416
@ MPG123_MISSING_FEATURE
Definition: mpg123.h:421
@ MPG123_OK
Definition: mpg123.h:383
#define MPG123_ICY
Definition: mpg123.h:1466
Definition: icy.h:17
struct icy_meta icy
Definition: frame.h:303

◆ 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_textThe input data in ICY encoding
Returns
pointer to newly allocated buffer with UTF-8 data (You free() it!)

Definition at line 1581 of file libmpg123.c.

1582{
1583#ifndef NO_ICY
1584 return icy2utf8(icy_text, 0);
1585#else
1586 return NULL;
1587#endif
1588}
#define icy2utf8
Definition: intsym.h:207

◆ 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

Definition at line 1517 of file libmpg123.c.

1518{
1519 if(v1 != NULL) *v1 = NULL;
1520 if(v2 != NULL) *v2 = NULL;
1521 if(mh == NULL) return MPG123_BAD_HANDLE;
1522
1523 if(mh->metaflags & MPG123_ID3)
1524 {
1525 id3_link(mh);
1526 if(v1 != NULL && mh->rdat.flags & READER_ID3TAG) *v1 = (mpg123_id3v1*) mh->id3buf;
1527 if(v2 != NULL)
1528#ifdef NO_ID3V2
1529 *v2 = NULL;
1530#else
1531 *v2 = &mh->id3v2;
1532#endif
1533
1534 mh->metaflags |= MPG123_ID3;
1535 mh->metaflags &= ~MPG123_NEW_ID3;
1536 }
1537 return MPG123_OK;
1538}
GLfloat GLfloat v1
Definition: glext.h:6062
GLfloat GLfloat GLfloat v2
Definition: glext.h:6063
#define MPG123_ID3
Definition: mpg123.h:1464
#define id3_link
Definition: intsym.h:214
#define READER_ID3TAG
Definition: reader.h:114
unsigned char id3buf[128]
Definition: frame.h:296
mpg123_id3v2 id3v2
Definition: frame.h:298
struct reader_data rdat
Definition: frame.h:288

◆ 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_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
v1address to store pointer to v1 tag
v1_sizesize of v1 data in bytes
v2address to store pointer to v2 tag
v2_sizesize of v2 data in bytes
Returns
MPG123_OK or MPG123_ERR. Only on MPG123_OK the output values are set.

Definition at line 1540 of file libmpg123.c.

1543{
1544 if(!mh)
1545 return MPG123_ERR;
1546 if(v1 != NULL)
1547 *v1 = mh->id3buf[0] ? mh->id3buf : NULL;
1548 if(v1_size != NULL)
1549 *v1_size = mh->id3buf[0] ? 128 : 0;
1550 if(v2 != NULL)
1551 *v2 = mh->id3v2_raw;
1552 if(v2_size != NULL)
1553 *v2_size = mh->id3v2_size;
1554 return MPG123_OK;
1555}
unsigned char * id3v2_raw
Definition: frame.h:300
size_t id3v2_size
Definition: frame.h:301

◆ 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
sbstring handle (address of existing structure on your side)

Definition at line 35 of file stringbuf.c.

36{
37 /* Handing in NULL here is a fatal mistake and rightfully so. */
38 sb->p = NULL;
39 sb->size = 0;
40 sb->fill = 0;
41}

Referenced by init_mpg123_picture(), init_mpg123_text(), mpg123_free_string(), mpg123_move_string(), mpg123_new_string(), mpg123_resize_string(), process_comment(), process_extra(), and process_picture().

◆ 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
mhhandle
Returns
combination of flags, 0 on error (same as "nothing new")

Definition at line 1503 of file libmpg123.c.

1504{
1505 if(mh != NULL) return mh->metaflags;
1506 else return 0;
1507}

◆ mpg123_meta_free()

MPG123_EXPORT void mpg123_meta_free ( mpg123_handle mh)

Clean up meta data storage (ID3v2 and ICY), freeing memory.

Parameters
mhhandle

Definition at line 1509 of file libmpg123.c.

1510{
1511 if(mh == NULL) return;
1512
1513 reset_id3(mh);
1514 reset_icy(&mh->icy);
1515}
#define reset_id3
Definition: intsym.h:213
#define reset_icy
Definition: intsym.h:210

◆ 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
fromsource string handle
totarget string handle
Returns
0 on error, 1 on success

Definition at line 122 of file stringbuf.c.

123{
124 if(to)
126 else
128 if(from && to)
129 *to = *from;
130 if(from)
132 return (from && to) ? 1 : 0;
133}

Referenced by process_comment(), process_extra(), and process_picture().

◆ mpg123_new_string()

MPG123_EXPORT mpg123_string * mpg123_new_string ( const char val)

Allocate and intialize a new string.

Parameters
valoptional initial string value (can be NULL)

Definition at line 17 of file stringbuf.c.

18{
20 if(!sb)
21 return NULL;
24 return sb;
25}
#define malloc
Definition: debug_ros.c:4
GLuint GLfloat * val
Definition: glext.h:7180
int attribute_align_arg mpg123_set_string(mpg123_string *sb, const char *stuff)
Definition: stringbuf.c:178

◆ mpg123_resize_string()

MPG123_EXPORT int mpg123_resize_string ( mpg123_string sb,
size_t  news 
)

Change the size of a mpg123_string

Parameters
sbstring handle
newsnew size in bytes
Returns
0 on error, 1 on success

Definition at line 59 of file stringbuf.c.

60{
61 if(!sb)
62 return 0;
63 debug3("resizing string pointer %p from %lu to %lu", (void*) sb->p, (unsigned long)sb->size, (unsigned long)new);
64 if(new == 0)
65 {
66 if(sb->size && sb->p != NULL) free(sb->p);
68 return 1;
69 }
70 if(sb->size != new)
71 {
72 char* t;
73 debug("really!");
74 t = (char*) safe_realloc(sb->p, new*sizeof(char));
75 debug1("safe_realloc returned %p", (void*) t);
76 if(t != NULL)
77 {
78 sb->p = t;
79 sb->size = new;
80 if(sb->size < sb->fill)
81 {
82 // Cut short the existing data, properly.
83 sb->fill = sb->size;
84 sb->p[sb->fill-1] = 0;
85 }
86 return 1;
87 }
88 else return 0;
89 }
90 else return 1; /* success */
91}
GLdouble GLdouble t
Definition: gl.h:2047
#define safe_realloc
Definition: intsym.h:10
#define debug3(s, a, b, c)
Definition: debug.h:63

Referenced by mpg123_copy_string(), and mpg123_grow_string().

◆ 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
afirst string handle
bsecond string handle
Returns
0 for different strings, 1 for identical

Definition at line 241 of file stringbuf.c.

242{
243 if(!a || !b)
244 return 0;
245 if(a->fill != b->fill)
246 return 0;
247 if(memcmp(a->p, b->p, a->fill))
248 return 0;
249 return 1;
250}
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204

Referenced by add_id3_picture(), and add_id3_text().

◆ 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
sbstring handle
stuffcontent to copy
Returns
0 on error, 1 on success

Definition at line 178 of file stringbuf.c.

179{
180 if(!sb)
181 return 0;
182 sb->fill = 0;
183 return mpg123_add_string(sb, stuff);
184}
int attribute_align_arg mpg123_add_string(mpg123_string *sb, const char *stuff)
Definition: stringbuf.c:135

Referenced by mpg123_new_string(), and mpg123_store_utf8().

◆ 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
sbstring handle
stuffthe future content
fromoffset to copy from
countnumber of characters to copy (a null-byte is always appended)
Returns
0 on error, 1 on success

Definition at line 170 of file stringbuf.c.

171{
172 if(!sb)
173 return 0;
174 sb->fill = 0;
175 return mpg123_add_substring(sb, stuff, from, count);
176}

◆ 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 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
sbtarget string
encmpg123 text encoding value
sourcesource buffer with plain unsigned bytes (you might need to cast from signed char)
source_sizenumber of bytes in the source buffer
Returns
0 on error, 1 on success (on error, mpg123_free_string is called on sb)

Definition at line 1604 of file libmpg123.c.

1605{
1606 switch(enc)
1607 {
1608#ifndef NO_ID3V2
1609 /* The encodings we get from ID3v2 tags. */
1610 case mpg123_text_utf8:
1611 id3_to_utf8(sb, mpg123_id3_utf8, source, source_size, 0);
1612 break;
1613 case mpg123_text_latin1:
1614 id3_to_utf8(sb, mpg123_id3_latin1, source, source_size, 0);
1615 break;
1617 case mpg123_text_utf16:
1618 id3_to_utf8(sb, mpg123_id3_utf16bom, source, source_size, 0);
1619 break;
1620 /* Special because one cannot skip zero bytes here. */
1622 id3_to_utf8(sb, mpg123_id3_utf16be, source, source_size, 0);
1623 break;
1624#endif
1625#ifndef NO_ICY
1626 /* ICY encoding... */
1627 case mpg123_text_icy:
1628 case mpg123_text_cp1252:
1629 {
1631 /* Paranoia: Make sure that the string ends inside the buffer... */
1632 if(source[source_size-1] == 0)
1633 {
1634 /* Convert from ICY encoding... with force applied or not. */
1635 char *tmpstring = icy2utf8((const char*)source, enc == mpg123_text_cp1252 ? 1 : 0);
1636 if(tmpstring != NULL)
1637 {
1638 mpg123_set_string(sb, tmpstring);
1639 free(tmpstring);
1640 }
1641 }
1642 }
1643 break;
1644#endif
1645 default:
1647 }
1648 /* At least a trailing null of some form should be there... */
1649 return (sb->fill > 0) ? 1 : 0;
1650}
#define id3_to_utf8
Definition: intsym.h:216

◆ 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
sbstring handle
utf8a flag to tell if the string is in utf8 encoding
Returns
character count

Definition at line 186 of file stringbuf.c.

187{
188 size_t i;
189 size_t bytelen;
190
191 /* Notions of empty string. If there's only a single character, it has to be the trailing zero, and if the first is the trailing zero anyway, we got empty. */
192 if(!sb || sb->fill < 2 || sb->p[0] == 0) return 0;
193
194 /* Find the first non-null character from the back.
195 We already established that the first character is non-null
196 That at fill-2 has to be null, though. */
197 for(i=sb->fill-2; i>0; --i)
198 if(sb->p[i] != 0) break;
199
200 /* For simple byte strings, we are done now. */
201 bytelen = i+1;
202
203 if(!utf8) return bytelen;
204 else
205 {
206 /* Work out the actual count of UTF8 bytes.
207 This employs no particular encoding error checking. */
208 size_t len = 0;
209 for(i=0; i<bytelen; ++i)
210 {
211 /* Every byte that is not a continuation byte ( 0xc0 == 10xx xxxx ) stands for a character. */
212 if((sb->p[i] & 0xc0) != 0x80) len++;
213 }
214 return len;
215 }
216}
GLenum GLsizei len
Definition: glext.h:6722