From: <ny...@us...> - 2007-09-25 16:23:30
|
Revision: 417 http://pmplib.svn.sourceforge.net/pmplib/?rev=417&view=rev Author: nyaochi Date: 2007-09-25 09:23:32 -0700 (Tue, 25 Sep 2007) Log Message: ----------- More work on analyzing the iTunesDB format. Modified Paths: -------------- trunk/pmplib/lib/pmp_ipod/ipod.c trunk/pmplib/lib/pmp_ipod/ipod.h trunk/pmplib/lib/pmp_ipod/itunesdb.c trunk/pmplib/lib/pmp_ipod/itunesdb.h Modified: trunk/pmplib/lib/pmp_ipod/ipod.c =================================================================== --- trunk/pmplib/lib/pmp_ipod/ipod.c 2007-09-25 14:27:01 UTC (rev 416) +++ trunk/pmplib/lib/pmp_ipod/ipod.c 2007-09-25 16:23:32 UTC (rev 417) @@ -40,6 +40,7 @@ #include "util.h" #include "ipod.h" #include "ipodprop.h" +#include "ipodserial.h" #include "itunesdb.h" #include "playcounts.h" @@ -117,6 +118,7 @@ ipodprop_finish(&ip); ucs2free(path); + return ret; } @@ -360,7 +362,7 @@ } /* Construct an "mhod" chunk for album artist. */ - if (rec->artist && *rec->artist) { + if (rec->album_artist && *rec->album_artist) { mhod = itunesdb_new_child(mhit); if (mhod) { if (ret = itunesdb_init(mhod, "mhod", "album_artist")) return ret; @@ -565,7 +567,7 @@ return ret; } -static int comp_artist(const void *_x, const void *_y) +static int comp_sortartist(const void *_x, const void *_y) { int ret = 0; const sorted_index_t *xi = (const sorted_index_t*)_x; @@ -581,6 +583,41 @@ return ret; } +static int comp_albumartist(const void *_x, const void *_y) +{ + int ret = 0; + const sorted_index_t *xi = (const sorted_index_t*)_x; + const sorted_index_t *yi = (const sorted_index_t*)_y; + const pmp_music_record_t* base = (const pmp_music_record_t*)xi->base; + const pmp_music_record_t* x = &base[xi->index]; + const pmp_music_record_t* y = &base[yi->index]; + + ret = comp_string(x->album_artist, y->album_artist); + if (ret == 0) { + return comp_album(_x, _y); + } + return ret; +} + +static int comp_albumartist_sortartist(const void *_x, const void *_y) +{ + int ret = 0; + const sorted_index_t *xi = (const sorted_index_t*)_x; + const sorted_index_t *yi = (const sorted_index_t*)_y; + const pmp_music_record_t* base = (const pmp_music_record_t*)xi->base; + const pmp_music_record_t* x = &base[xi->index]; + const pmp_music_record_t* y = &base[yi->index]; + + ret = comp_string(x->album_artist, y->album_artist); + if (ret == 0) { + ret = comp_string(x->artist, y->artist); + if (ret == 0) { + return comp_album(_x, _y); + } + } + return ret; +} + static int comp_genre(const void *_x, const void *_y) { int ret = 0; @@ -592,7 +629,7 @@ ret = comp_string(x->genre, y->genre); if (ret == 0) { - return comp_artist(_x, _y); + return comp_sortartist(_x, _y); } return ret; } @@ -654,10 +691,16 @@ if (ret = itunesdb_set_mhod_string(mhod, artist)) return ret; } - mhia_data->num_children = 2; + mhod = itunesdb_new_child(mhia); + if (mhod) { + if (ret = itunesdb_init(mhod, "mhod", "sort_artist_albumlist")) return ret; + if (ret = itunesdb_set_mhod_string(mhod, artist)) return ret; + } + + mhia_data->num_children = 3; mhia_data->album_id = i; mhia_data->timestamp = 0; - mhia_data->unknown1 = 2; + mhia_data->unknown1 = 258; } prev_album = album; @@ -684,7 +727,7 @@ } mhyp_data->flag_master = 1; - mhyp_data->id = 0x7520EA5FA870F9EA; + mhyp_data->id = 0xC6EEB59E19650DDA; mhyp_data->unk3 = 0; mhyp_data->unk4 = 1; mhyp_data->sort_order = 1; @@ -696,7 +739,7 @@ if (ret = itunesdb_set_mhod_string(mhod, ucs2cs_master)) return ret; } - /* Construct an "mhod" chunk for title index. */ + /* Construct an "mhod" chunk for index: title. */ mhod = itunesdb_new_child(mhyp); if (mhod) { if (ret = itunesdb_init(mhod, "mhod", "index")) return ret; @@ -704,15 +747,15 @@ if (ret = itunesdb_set_mhod_index(mhod, 0x03, si, num_records)) return ret; } - /* Construct an "mhod" chunk for artist index. */ + /* Construct an "mhod" chunk for index: sortartist, disc/tracknumber, title. */ mhod = itunesdb_new_child(mhyp); if (mhod) { if (ret = itunesdb_init(mhod, "mhod", "index")) return ret; - qsort(si, num_records, sizeof(si[0]), comp_artist); + qsort(si, num_records, sizeof(si[0]), comp_sortartist); if (ret = itunesdb_set_mhod_index(mhod, 0x05, si, num_records)) return ret; } - /* Construct an "mhod" chunk for album index. */ + /* Construct an "mhod" chunk for index: album, disc/tracknumber, title. */ mhod = itunesdb_new_child(mhyp); if (mhod) { if (ret = itunesdb_init(mhod, "mhod", "index")) return ret; @@ -720,7 +763,7 @@ if (ret = itunesdb_set_mhod_index(mhod, 0x04, si, num_records)) return ret; } - /* Construct an "mhod" chunk for genre index. */ + /* Construct an "mhod" chunk for index: genre, sortartist, album, disc/tracknumber, title */ mhod = itunesdb_new_child(mhyp); if (mhod) { if (ret = itunesdb_init(mhod, "mhod", "index")) return ret; @@ -728,7 +771,7 @@ if (ret = itunesdb_set_mhod_index(mhod, 0x07, si, num_records)) return ret; } - /* Construct an "mhod" chunk for composer index. */ + /* Construct an "mhod" chunk for index: composer, title. */ mhod = itunesdb_new_child(mhyp); if (mhod) { if (ret = itunesdb_init(mhod, "mhod", "index")) return ret; @@ -736,23 +779,23 @@ if (ret = itunesdb_set_mhod_index(mhod, 0x12, si, num_records)) return ret; } - /* Construct an "mhod" chunk for 'unknown' index. */ + /* Construct an "mhod" chunk for index: albumartist, sortartist, disc/tracknumber, title. */ mhod = itunesdb_new_child(mhyp); if (mhod) { if (ret = itunesdb_init(mhod, "mhod", "index")) return ret; - qsort(si, num_records, sizeof(si[0]), comp_album); + qsort(si, num_records, sizeof(si[0]), comp_albumartist_sortartist); if (ret = itunesdb_set_mhod_index(mhod, 0x23, si, num_records)) return ret; } - /* Construct an "mhod" chunk for 'unknown' index. */ + /* Construct an "mhod" chunk for index: albumartist, album, disc/tracknumber, title*/ mhod = itunesdb_new_child(mhyp); if (mhod) { if (ret = itunesdb_init(mhod, "mhod", "index")) return ret; - qsort(si, num_records, sizeof(si[0]), comp_album); + qsort(si, num_records, sizeof(si[0]), comp_albumartist); if (ret = itunesdb_set_mhod_index(mhod, 0x24, si, num_records)) return ret; } - /* Construct an "mhod" chunk for 'unknown' index. */ + /* Construct an "mhod" chunk for index: title?. */ mhod = itunesdb_new_child(mhyp); if (mhod) { if (ret = itunesdb_init(mhod, "mhod", "index")) return ret; @@ -760,7 +803,7 @@ if (ret = itunesdb_set_mhod_index(mhod, 0x1D, si, num_records)) return ret; } - /* Construct an "mhod" chunk for 'unknown' index. */ + /* Construct an "mhod" chunk for index: title?. */ mhod = itunesdb_new_child(mhyp); if (mhod) { if (ret = itunesdb_init(mhod, "mhod", "index")) return ret; @@ -768,7 +811,7 @@ if (ret = itunesdb_set_mhod_index(mhod, 0x1E, si, num_records)) return ret; } - /* Construct an "mhod" chunk for 'unknown' index. */ + /* Construct an "mhod" chunk for index: title?. */ mhod = itunesdb_new_child(mhyp); if (mhod) { if (ret = itunesdb_init(mhod, "mhod", "index")) return ret; @@ -903,7 +946,6 @@ if (ret = itunesdb_init(mhbd, "mhbd", NULL)) return ret; mhbd_data = (itunesdb_mhbd_t*)mhbd->data; -#if 0 /* Construct "mhsd" chunk with album_list type (type = 4). */ mhsd = itunesdb_new_child(mhbd); if (mhsd) { @@ -923,7 +965,6 @@ } else { return IPODE_FAILEDNEWCHUNK; } -#endif /* Construct "mhsd" chunk with track type (type = 1). */ mhsd = itunesdb_new_child(mhbd); Modified: trunk/pmplib/lib/pmp_ipod/ipod.h =================================================================== --- trunk/pmplib/lib/pmp_ipod/ipod.h 2007-09-25 14:27:01 UTC (rev 416) +++ trunk/pmplib/lib/pmp_ipod/ipod.h 2007-09-25 16:23:32 UTC (rev 417) @@ -51,6 +51,7 @@ typedef struct { itunesdb_chunk_t* itunesdb; playcounts_t* pcs; + uint8_t serial[8]; } ipod_t; const ipod_descriptor_t* ipod_detect(const ucs2char_t* path_to_device, const char *id, pmp_device_information_t* ptr_info); Modified: trunk/pmplib/lib/pmp_ipod/itunesdb.c =================================================================== --- trunk/pmplib/lib/pmp_ipod/itunesdb.c 2007-09-25 14:27:01 UTC (rev 416) +++ trunk/pmplib/lib/pmp_ipod/itunesdb.c 2007-09-25 16:23:32 UTC (rev 417) @@ -576,12 +576,12 @@ for (i = 0;i < lp_index->num_entries;++i) { char fieldname[128]; - sprintf(fieldname, "entries[%d].unknown1", i); - if (ret = serialize_uint32le(sio, fieldname, "%u", &lp_index->entries[i].unknown1)) return ret; - sprintf(fieldname, "entries[%d].unknown2", i); - if (ret = serialize_uint32le(sio, fieldname, "%u", &lp_index->entries[i].unknown2)) return ret; - sprintf(fieldname, "entries[%d].unknown3", i); - if (ret = serialize_uint32le(sio, fieldname, "%u", &lp_index->entries[i].unknown3)) return ret; + sprintf(fieldname, "entries[%d].value", i); + if (ret = serialize_uint32le(sio, fieldname, "%u", &lp_index->entries[i].value)) return ret; + sprintf(fieldname, "entries[%d].begin", i); + if (ret = serialize_uint32le(sio, fieldname, "%u", &lp_index->entries[i].begin)) return ret; + sprintf(fieldname, "entries[%d].num", i); + if (ret = serialize_uint32le(sio, fieldname, "%u", &lp_index->entries[i].num)) return ret; } return 0; Modified: trunk/pmplib/lib/pmp_ipod/itunesdb.h =================================================================== --- trunk/pmplib/lib/pmp_ipod/itunesdb.h 2007-09-25 14:27:01 UTC (rev 416) +++ trunk/pmplib/lib/pmp_ipod/itunesdb.h 2007-09-25 16:23:32 UTC (rev 417) @@ -223,9 +223,9 @@ } itunesdb_mhod_playlist_column_t; typedef struct { - uint32_t unknown1; - uint32_t unknown2; - uint32_t unknown3; + uint32_t value; + uint32_t begin; + uint32_t num; } itunesdb_mhod_library_playlist_entry_t; typedef struct { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |