1
0
mirror of http://mpg123.de/trunk/.git synced 2025-07-30 02:01:12 +03:00

Some things relating to ID3v2 handling:

- the named entries for artist, album, etc in struct mpg123_id3v2 are now pointers...
	- ... into the new arrays of ID3v2 text, comment and extra (TXXX) data
	- That makes a lot more info directly accessible; which id3dump now does access
	- adapted id3print.c to the pointer thing (by dropping some & ;-)
	- mpg123_copy_string() now produces an empty string (_not_ "") when copying from NULL

id3.c got a bit of structure, but the main parsing function is still to bloated.
In general, I hope this change of ID3v2 handling makes sense.
You have more data plus the possibility to easily loop through the entries...



git-svn-id: svn://scm.orgis.org/mpg123/trunk@1205 35dc7657-300d-0410-a2e5-dc2837fedb53
This commit is contained in:
thor
2007-12-01 21:42:44 +00:00
parent 57fe26c8e9
commit 56ed6fb018
7 changed files with 255 additions and 136 deletions

View File

@ -87,18 +87,56 @@ void print_v2(mpg123_id3v2 *v2)
int i;
const char *names[] = { "Title", "Artist", "Album", "Year", "Comment", "Genre" };
mpg123_string *sources[sizeof(names)/sizeof(char*)];
sources[0] = &v2->title;
sources[1] = &v2->artist;
sources[2] = &v2->album;
sources[3] = &v2->year;
sources[4] = v2->generic_comment;
sources[5] = &v2->genre;
sources[0] = v2->title;
sources[1] = v2->artist;
sources[2] = v2->album;
sources[3] = v2->year;
sources[4] = v2->comment;
sources[5] = v2->genre;
printf("title = %p\n", (void*)v2->title);
for(i=0; i<V1FIELDS; ++i)
{
print_lines(names[i], sources[i]);
}
}
void print_raw_v2(mpg123_id3v2 *v2)
{
size_t i;
for(i=0; i<v2->texts; ++i)
{
char id[5];
memcpy(id, v2->text[i].id, 4);
id[4] = 0;
printf("%p %s\n", (void*)(&v2->text[i].text), id);
print_lines("", &v2->text[i].text);
}
for(i=0; i<v2->extras; ++i)
{
char id[5];
memcpy(id, v2->extra[i].id, 4);
id[4] = 0;
printf( "%s description(%s)\n",
id,
v2->extra[i].description.fill ? v2->extra[i].description.p : "" );
print_lines("", &v2->extra[i].text);
}
for(i=0; i<v2->comments; ++i)
{
char id[5];
char lang[3];
memcpy(id, v2->comment_list[i].id, 4);
id[4] = 0;
memcpy(lang, v2->comment_list[i].lang, 3);
lang[3] = 0;
printf( "%s description(%s) language(%s): \n",
id,
v2->comment_list[i].description.fill ? v2->comment_list[i].description.p : "",
lang );
print_lines("", &v2->comment_list[i].text);
}
}
int main(int argc, char **argv)
{
int i;
@ -112,7 +150,7 @@ int main(int argc, char **argv)
mpg123_init();
m = mpg123_new(NULL, NULL);
mpg123_param(m, MPG123_VERBOSE, 4, 0);
for(i=1; i < argc; ++i)
{
mpg123_id3v1 *v1;
@ -128,11 +166,14 @@ mpg123_param(m, MPG123_VERBOSE, 4, 0);
if(meta & MPG123_ID3 && mpg123_id3(m, &v1, &v2) == MPG123_OK)
{
printf("Tag data on %s:\n", argv[i]);
printf("\n==== ID3v1 ====\n");
printf("\n==== ID3v1 ====\n");
if(v1 != NULL) print_v1(v1);
printf("\n==== ID3v2 ====\n");
printf("\n==== ID3v2 ====\n");
if(v2 != NULL) print_v2(v2);
printf("\n==== ID3v2 Raw frames ====\n");
if(v2 != NULL) print_raw_v2(v2);
}
else printf("Nothing found for %s.\n", argv[i]);