You can subscribe to this list here.
| 2006 |
Jan
|
Feb
|
Mar
(2) |
Apr
(4) |
May
(6) |
Jun
(56) |
Jul
(101) |
Aug
(14) |
Sep
|
Oct
(1) |
Nov
|
Dec
(40) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2007 |
Jan
(66) |
Feb
(106) |
Mar
(1) |
Apr
(2) |
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
(10) |
Oct
(7) |
Nov
|
Dec
|
| 2008 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <ny...@us...> - 2008-01-20 13:37:07
|
Revision: 432
http://pmplib.svn.sourceforge.net/pmplib/?rev=432&view=rev
Author: nyaochi
Date: 2008-01-20 05:36:19 -0800 (Sun, 20 Jan 2008)
Log Message:
-----------
Removed an unused library reference.
Modified Paths:
--------------
trunk/pmplib/lib/pmp_ipod/pmp_ipod.vcproj
Modified: trunk/pmplib/lib/pmp_ipod/pmp_ipod.vcproj
===================================================================
--- trunk/pmplib/lib/pmp_ipod/pmp_ipod.vcproj 2007-10-08 14:56:23 UTC (rev 431)
+++ trunk/pmplib/lib/pmp_ipod/pmp_ipod.vcproj 2008-01-20 13:36:19 UTC (rev 432)
@@ -61,7 +61,7 @@
/>
<Tool
Name="VCLinkerTool"
- AdditionalDependencies=".\win32\usbinfo_win32.lib .\win32spti\ipodprop_win32spti.lib shlwapi.lib bgd.lib libexpat.lib"
+ AdditionalDependencies=".\win32spti\ipodprop_win32spti.lib shlwapi.lib bgd.lib libexpat.lib"
LinkIncremental="2"
AdditionalLibraryDirectories="$(SolutionDir)win32\gd;$(SolutionDir)win32\expat\debug"
GenerateDebugInformation="true"
@@ -137,7 +137,7 @@
/>
<Tool
Name="VCLinkerTool"
- AdditionalDependencies=".\win32\usbinfo_win32.lib .\win32spti\ipodprop_win32spti.lib shlwapi.lib bgd.lib libexpat.lib"
+ AdditionalDependencies=".\win32spti\ipodprop_win32spti.lib shlwapi.lib bgd.lib libexpat.lib"
LinkIncremental="1"
AdditionalLibraryDirectories="$(SolutionDir)win32\gd;$(SolutionDir)win32\expat\release"
GenerateDebugInformation="true"
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ny...@us...> - 2007-10-08 14:27:24
|
Revision: 429
http://pmplib.svn.sourceforge.net/pmplib/?rev=429&view=rev
Author: nyaochi
Date: 2007-10-08 07:27:27 -0700 (Mon, 08 Oct 2007)
Log Message:
-----------
Rename chunk_finish() to chunk_delete().
Source-code cleanup for chunk.[c,h]
Modified Paths:
--------------
trunk/pmplib/lib/pmp_ipod/chunk.c
trunk/pmplib/lib/pmp_ipod/chunk.h
trunk/pmplib/lib/pmp_ipod/ipod.c
Modified: trunk/pmplib/lib/pmp_ipod/chunk.c
===================================================================
--- trunk/pmplib/lib/pmp_ipod/chunk.c 2007-10-08 14:16:18 UTC (rev 428)
+++ trunk/pmplib/lib/pmp_ipod/chunk.c 2007-10-08 14:27:27 UTC (rev 429)
@@ -39,7 +39,8 @@
#include "util.h"
#include "chunk.h"
-static const chunkdecl_t* find_chunkdecl(
+static const chunkdecl_t*
+find_chunkdecl(
const chunkdecl_t* cds,
const int8_t* name
)
@@ -53,7 +54,8 @@
return NULL;
}
-chunk_t* chunk_new(
+chunk_t*
+chunk_new(
const chunkdecl_t* cds,
chunk_t* parent,
const char *name
@@ -100,59 +102,29 @@
return child;
}
-/*
-int chunk_init(
+void
+chunk_delete(
const chunkdecl_t* cds,
- chunk_t* chunk,
- const char *name
- )
-{
- int ret = 0;
- const chunkdecl_t* decl = find_chunkdecl(cds, (int8_t*)name);
- if (!decl) {
- return IPODE_UNKNOWNCHUNK;
- }
-
- if (ret = decl->init(chunk, 1)) return ret;
- return 0;
-}
-*/
-
-void chunk_finish(
- const chunkdecl_t* cds,
chunk_t* chunk
)
{
uint32_t i;
const chunkdecl_t* decl = NULL;
+ /* Delete children (recursively). */
for (i = 0;i < chunk->num_children;++i) {
- chunk_finish(cds, &chunk->childlen[i]);
+ chunk_delete(cds, &chunk->childlen[i]);
}
+ /* Delete this chunk. */
decl = find_chunkdecl(cds, chunk->id);
if (decl) {
decl->finish(chunk);
}
}
-/*
-chunk_t* chunk_new_child(chunk_t* chunk)
-{
- chunk->childlen = (chunk_t*)realloc(
- chunk->childlen, sizeof(chunk_t) * (chunk->num_children + 1));
- if (chunk->childlen) {
- chunk_t* child = &chunk->childlen[chunk->num_children];
- memset(child, 0, sizeof(chunk_t));
- ++chunk->num_children;
- return child;
- } else {
- return NULL;
- }
-}
-*/
-
-int chunk_is(
+int
+chunk_is(
chunk_t* chunk,
const char *name
)
@@ -160,7 +132,8 @@
return (strncmp(chunk->id, name, 4) == 0);
}
-int chunk_repr(
+int
+chunk_repr(
const chunkdecl_t* cds,
chunk_t* chunk,
size_t index,
@@ -173,7 +146,7 @@
/* Start of a chunk */
serialize_indent(sio);
- fprintf(sio->fp, "Chunk %c%c%c%c (%d) = {\n", chunk->id[0], chunk->id[1], chunk->id[2], chunk->id[3], index);
+ fprintf(sio->fp, "CHUNK %c%c%c%c (%d) = {\n", chunk->id[0], chunk->id[1], chunk->id[2], chunk->id[3], index);
serialize_indent_ascend(sio);
/* Show information of the chunk header */
@@ -223,7 +196,8 @@
return 0;
}
-int chunk_read(
+int
+chunk_read(
const chunkdecl_t* cds,
chunk_t* chunk,
serializer_t* sio
@@ -253,13 +227,8 @@
}
/* Determine the size of padded data for this chunk. */
- //if (strncmp(chunk->id, "mhod", 4) == 0) {
- // next = begin + chunk->overall_size;
- // chunk->padding_size = next - serialize_tell(sio);
- //} else {
- next = begin + chunk->size;
- chunk->padding_size = next - serialize_tell(sio);
- //}
+ next = begin + chunk->size;
+ chunk->padding_size = next - serialize_tell(sio);
/* Read the padded data. */
if (0 < chunk->padding_size) {
@@ -304,7 +273,8 @@
return 0;
}
-int chunk_write(
+int
+chunk_write(
const chunkdecl_t* cds,
chunk_t* chunk,
serializer_t* sio
@@ -348,6 +318,7 @@
chunk->overall_size = (uint32_t)serialize_tell(sio) - chunk->offset;
}
+ /* Finalize the size of this chunk (including the descendants). */
offset = (uint32_t)serialize_tell(sio);
if (ret = serialize_seek(sio, chunk->offset + 2 * sizeof(uint32_t))) return ret;
if (ret = serialize_uint32le(sio, "overall_size", "%d", &chunk->overall_size)) return ret;
Modified: trunk/pmplib/lib/pmp_ipod/chunk.h
===================================================================
--- trunk/pmplib/lib/pmp_ipod/chunk.h 2007-10-08 14:16:18 UTC (rev 428)
+++ trunk/pmplib/lib/pmp_ipod/chunk.h 2007-10-08 14:27:27 UTC (rev 429)
@@ -48,10 +48,8 @@
} chunkdecl_t;
chunk_t* chunk_new(const chunkdecl_t* cds, chunk_t* chunk, const char *name);
-//int chunk_init(const chunkdecl_t* cds, chunk_t* chunk, const char *name);
-void chunk_finish(const chunkdecl_t* cds, chunk_t* chunk);
+void chunk_delete(const chunkdecl_t* cds, chunk_t* chunk);
int chunk_is(chunk_t* chunk, const char *name);
-//chunk_t* chunk_new_child(chunk_t* chunk);
int chunk_repr(const chunkdecl_t* cds, chunk_t* chunk, size_t index, serializer_t* sio);
int chunk_read(const chunkdecl_t* cds, chunk_t* chunk, serializer_t* sio);
int chunk_write(const chunkdecl_t* cds, chunk_t* chunk, serializer_t* sio);
Modified: trunk/pmplib/lib/pmp_ipod/ipod.c
===================================================================
--- trunk/pmplib/lib/pmp_ipod/ipod.c 2007-10-08 14:16:18 UTC (rev 428)
+++ trunk/pmplib/lib/pmp_ipod/ipod.c 2007-10-08 14:27:27 UTC (rev 429)
@@ -290,9 +290,9 @@
void ipod_finish(ipod_t* ipod)
{
- chunk_finish(artworkdb_cds, ipod->photodb);
- chunk_finish(itunesdb_cds, ipod->itunesdb);
- chunk_finish(artworkdb_cds, ipod->artworkdb);
+ chunk_delete(artworkdb_cds, ipod->photodb);
+ chunk_delete(itunesdb_cds, ipod->itunesdb);
+ chunk_delete(artworkdb_cds, ipod->artworkdb);
playcounts_finish(ipod->pcs);
free(ipod->photo_formats);
free(ipod->pcs);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ny...@us...> - 2007-10-08 14:16:15
|
Revision: 428
http://pmplib.svn.sourceforge.net/pmplib/?rev=428&view=rev
Author: nyaochi
Date: 2007-10-08 07:16:18 -0700 (Mon, 08 Oct 2007)
Log Message:
-----------
Merge chunk_new_chid() and chunk_init() for simplicity.
Modified Paths:
--------------
trunk/pmplib/lib/pmp_ipod/chunk.c
trunk/pmplib/lib/pmp_ipod/chunk.h
trunk/pmplib/lib/pmp_ipod/ipod.c
trunk/pmplib/lib/pmp_ipod/ipod_photo.c
Modified: trunk/pmplib/lib/pmp_ipod/chunk.c
===================================================================
--- trunk/pmplib/lib/pmp_ipod/chunk.c 2007-10-08 08:40:37 UTC (rev 427)
+++ trunk/pmplib/lib/pmp_ipod/chunk.c 2007-10-08 14:16:18 UTC (rev 428)
@@ -53,6 +53,54 @@
return NULL;
}
+chunk_t* chunk_new(
+ const chunkdecl_t* cds,
+ chunk_t* parent,
+ const char *name
+ )
+{
+ chunk_t* child = NULL;
+ const chunkdecl_t* decl = NULL;
+
+ /* Find the chunk description. */
+ if (name != NULL) {
+ decl = find_chunkdecl(cds, (int8_t*)name);
+ }
+
+ if (parent != NULL) {
+ /* Expand the child array. */
+ parent->childlen = (chunk_t*)realloc(
+ parent->childlen,
+ sizeof(chunk_t) * (parent->num_children + 1)
+ );
+ if (parent->childlen) {
+ child = &parent->childlen[parent->num_children];
+ memset(child, 0, sizeof(chunk_t));
+ ++parent->num_children;
+ }
+
+ /* Initialize the child. */
+ if (child != NULL && decl != NULL) {
+ if (decl->init(child, 1)) {
+ return NULL;
+ }
+ }
+ } else {
+ /* Create a new chunk. */
+ child = (chunk_t*)calloc(1, sizeof(chunk_t));
+ if (child != NULL && decl != NULL) {
+ if (decl->init(child, 1)) {
+ /* Failed to initialize the chunk. */
+ free(child);
+ child = NULL;
+ }
+ }
+ }
+
+ return child;
+}
+
+/*
int chunk_init(
const chunkdecl_t* cds,
chunk_t* chunk,
@@ -66,20 +114,9 @@
}
if (ret = decl->init(chunk, 1)) return ret;
- /*
- if (strncmp(name, "mhod", 4) == 0) {
- itunesdb_mhod_t* mhod = (itunesdb_mhod_t*)chunk->data;
- const itunes_mhoddecl_t* decl2 = find_mhoddecl_by_name(subtype);
- if (!decl2) {
- decl->finish(chunk);
- return IPODE_UNKNOWNSUBTYPE;
- }
- chunk->overall_size = decl2->overall_size;
- mhod->type = decl2->type;
- }
- */
return 0;
}
+*/
void chunk_finish(
const chunkdecl_t* cds,
@@ -99,6 +136,7 @@
}
}
+/*
chunk_t* chunk_new_child(chunk_t* chunk)
{
chunk->childlen = (chunk_t*)realloc(
@@ -112,21 +150,14 @@
return NULL;
}
}
+*/
int chunk_is(
chunk_t* chunk,
const char *name
)
{
- /*
- if (strncmp(name, "mhod", 4) == 0) {
- itunesdb_mhod_t* mhod = (itunesdb_mhod_t*)chunk->data;
- const itunes_mhoddecl_t* decl = find_mhoddecl(chunk);
- return (decl && strcmp(decl->name, subtype) == 0) ? 1 : 0;
- } else {
- */
- return (strncmp(chunk->id, name, 4) == 0);
-/* }*/
+ return (strncmp(chunk->id, name, 4) == 0);
}
int chunk_repr(
Modified: trunk/pmplib/lib/pmp_ipod/chunk.h
===================================================================
--- trunk/pmplib/lib/pmp_ipod/chunk.h 2007-10-08 08:40:37 UTC (rev 427)
+++ trunk/pmplib/lib/pmp_ipod/chunk.h 2007-10-08 14:16:18 UTC (rev 428)
@@ -47,10 +47,11 @@
int (*serialize)(chunk_t* chunk, serializer_t* sio);
} chunkdecl_t;
-int chunk_init(const chunkdecl_t* cds, chunk_t* chunk, const char *name);
+chunk_t* chunk_new(const chunkdecl_t* cds, chunk_t* chunk, const char *name);
+//int chunk_init(const chunkdecl_t* cds, chunk_t* chunk, const char *name);
void chunk_finish(const chunkdecl_t* cds, chunk_t* chunk);
int chunk_is(chunk_t* chunk, const char *name);
-chunk_t* chunk_new_child(chunk_t* chunk);
+//chunk_t* chunk_new_child(chunk_t* chunk);
int chunk_repr(const chunkdecl_t* cds, chunk_t* chunk, size_t index, serializer_t* sio);
int chunk_read(const chunkdecl_t* cds, chunk_t* chunk, serializer_t* sio);
int chunk_write(const chunkdecl_t* cds, chunk_t* chunk, serializer_t* sio);
Modified: trunk/pmplib/lib/pmp_ipod/ipod.c
===================================================================
--- trunk/pmplib/lib/pmp_ipod/ipod.c 2007-10-08 08:40:37 UTC (rev 427)
+++ trunk/pmplib/lib/pmp_ipod/ipod.c 2007-10-08 14:16:18 UTC (rev 428)
@@ -545,9 +545,8 @@
/* Construct an "mhod" chunk for title. */
if (rec->title && *rec->title) {
- mhod = chunk_new_child(mhit);
+ mhod = chunk_new(itunesdb_cds, mhit, "mhod");
if (mhod) {
- if (ret = chunk_init(itunesdb_cds, mhod, "mhod")) return ret;
if (ret = itunesdb_mhod_init(mhod, "title")) return ret;
if (ret = itunesdb_set_mhod_string(mhod, rec->title)) return ret;
}
@@ -555,9 +554,8 @@
/* Construct an "mhod" chunk for artist. */
if (rec->artist && *rec->artist) {
- mhod = chunk_new_child(mhit);
+ mhod = chunk_new(itunesdb_cds, mhit, "mhod");
if (mhod) {
- if (ret = chunk_init(itunesdb_cds, mhod, "mhod")) return ret;
if (ret = itunesdb_mhod_init(mhod, "artist")) return ret;
if (ret = itunesdb_set_mhod_string(mhod, rec->artist)) return ret;
}
@@ -566,9 +564,8 @@
/* Construct an "mhod" chunk for album artist. */
value = (rec->album_artist && *rec->album_artist) ? rec->album_artist : rec->artist;
if (value && *value) {
- mhod = chunk_new_child(mhit);
+ mhod = chunk_new(itunesdb_cds, mhit, "mhod");
if (mhod) {
- if (ret = chunk_init(itunesdb_cds, mhod, "mhod")) return ret;
if (ret = itunesdb_mhod_init(mhod, "album_artist")) return ret;
if (ret = itunesdb_set_mhod_string(mhod, value)) return ret;
}
@@ -576,9 +573,8 @@
/* Construct an "mhod" chunk for album. */
if (rec->album && *rec->album) {
- mhod = chunk_new_child(mhit);
+ mhod = chunk_new(itunesdb_cds, mhit, "mhod");
if (mhod) {
- if (ret = chunk_init(itunesdb_cds, mhod, "mhod")) return ret;
if (ret = itunesdb_mhod_init(mhod, "album")) return ret;
if (ret = itunesdb_set_mhod_string(mhod, rec->album)) return ret;
}
@@ -586,27 +582,24 @@
/* Construct an "mhod" chunk for album. */
if (rec->genre && *rec->genre) {
- mhod = chunk_new_child(mhit);
+ mhod = chunk_new(itunesdb_cds, mhit, "mhod");
if (mhod) {
- if (ret = chunk_init(itunesdb_cds, mhod, "mhod")) return ret;
if (ret = itunesdb_mhod_init(mhod, "genre")) return ret;
if (ret = itunesdb_set_mhod_string(mhod, rec->genre)) return ret;
}
}
/* Construct an "mhod" chunk for filetype. */
- mhod = chunk_new_child(mhit);
+ mhod = chunk_new(itunesdb_cds, mhit, "mhod");
if (mhod) {
- if (ret = chunk_init(itunesdb_cds, mhod, "mhod")) return ret;
if (ret = itunesdb_mhod_init(mhod, "filetype")) return ret;
if (ret = itunesdb_set_mhod_string(mhod, L"MPEG Audio file")) return ret;
}
/* Construct an "mhod" chunk for comment. */
if (rec->comment && *rec->comment) {
- mhod = chunk_new_child(mhit);
+ mhod = chunk_new(itunesdb_cds, mhit, "mhod");
if (mhod) {
- if (ret = chunk_init(itunesdb_cds, mhod, "mhod")) return ret;
if (ret = itunesdb_mhod_init(mhod, "comment")) return ret;
if (ret = itunesdb_set_mhod_string(mhod, rec->comment)) return ret;
}
@@ -614,14 +607,13 @@
/* Construct an "mhod" chunk for location. */
if (rec->filename && *rec->filename) {
- mhod = chunk_new_child(mhit);
+ mhod = chunk_new(itunesdb_cds, mhit, "mhod");
if (mhod) {
ucs2char_t pathname[MAX_PATH], *p = NULL;
ucs2cpy(pathname, filepath_skiproot(rec->filename, path_to_root, 1));
for (p = pathname;*p;++p) {
if (*p == PATHCHAR) *p = ':';
}
- if (ret = chunk_init(itunesdb_cds, mhod, "mhod")) return ret;
if (ret = itunesdb_mhod_init(mhod, "location")) return ret;
if (ret = itunesdb_set_mhod_string(mhod, pathname)) return ret;
}
@@ -923,27 +915,23 @@
const ucs2char_t* artist = cur->artist;
if (prev_album == NULL || ucs2cmp(prev_album, album) != 0) {
- mhia = chunk_new_child(mhla);
- if (ret = chunk_init(itunesdb_cds, mhia, "mhia")) return ret;
+ mhia = chunk_new(itunesdb_cds, mhla, "mhia");
mhia_data = (itunesdb_mhia_t*)mhia->data;
- mhod = chunk_new_child(mhia);
+ mhod = chunk_new(itunesdb_cds, mhia, "mhod");
if (mhod) {
- if (ret = chunk_init(itunesdb_cds, mhod, "mhod")) return ret;
if (ret = itunesdb_mhod_init(mhod, "album_albumlist")) return ret;
if (ret = itunesdb_set_mhod_string(mhod, album)) return ret;
}
- mhod = chunk_new_child(mhia);
+ mhod = chunk_new(itunesdb_cds, mhia, "mhod");
if (mhod) {
- if (ret = chunk_init(itunesdb_cds, mhod, "mhod")) return ret;
if (ret = itunesdb_mhod_init(mhod, "artist_albumlist")) return ret;
if (ret = itunesdb_set_mhod_string(mhod, artist)) return ret;
}
- mhod = chunk_new_child(mhia);
+ mhod = chunk_new(itunesdb_cds, mhia, "mhod");
if (mhod) {
- if (ret = chunk_init(itunesdb_cds, mhod, "mhod")) return ret;
if (ret = itunesdb_mhod_init(mhod, "sort_artist_albumlist")) return ret;
if (ret = itunesdb_set_mhod_string(mhod, artist)) return ret;
}
@@ -985,24 +973,21 @@
mhyp_data->sort_order = 1;
/* Construct an "mhod" chunk for title. */
- mhod = chunk_new_child(mhyp);
+ mhod = chunk_new(itunesdb_cds, mhyp, "mhod");
if (mhod) {
- if (ret = chunk_init(itunesdb_cds, mhod, "mhod")) return ret;
if (ret = itunesdb_mhod_init(mhod, "title")) return ret;
if (ret = itunesdb_set_mhod_string(mhod, ucs2cs_master)) return ret;
}
/* Construct an "mhod" chunk for index: title. */
- mhod = chunk_new_child(mhyp);
+ mhod = chunk_new(itunesdb_cds, mhyp, "mhod");
if (mhod) {
- if (ret = chunk_init(itunesdb_cds, mhod, "mhod")) return ret;
if (ret = itunesdb_mhod_init(mhod, "index")) return ret;
qsort(si, num_records, sizeof(si[0]), comp_title);
if (ret = itunesdb_set_mhod_order(mhod, 0x03, si, num_records)) return ret;
- mhod = chunk_new_child(mhyp);
+ mhod = chunk_new(itunesdb_cds, mhyp, "mhod");
if (mhod) {
- if (ret = chunk_init(itunesdb_cds, mhod, "mhod")) return ret;
if (ret = itunesdb_mhod_init(mhod, "library_playlist_index")) return ret;
set_prefix(si, num_records, prefix_title);
if (ret = itunesdb_set_mhod_index(mhod, 0x03, si, num_records)) return ret;
@@ -1010,16 +995,14 @@
}
/* Construct an "mhod" chunk for index: sortartist, disc/tracknumber, title. */
- mhod = chunk_new_child(mhyp);
+ mhod = chunk_new(itunesdb_cds, mhyp, "mhod");
if (mhod) {
- if (ret = chunk_init(itunesdb_cds, mhod, "mhod")) return ret;
if (ret = itunesdb_mhod_init(mhod, "index")) return ret;
qsort(si, num_records, sizeof(si[0]), comp_sortartist);
if (ret = itunesdb_set_mhod_order(mhod, 0x05, si, num_records)) return ret;
- mhod = chunk_new_child(mhyp);
+ mhod = chunk_new(itunesdb_cds, mhyp, "mhod");
if (mhod) {
- if (ret = chunk_init(itunesdb_cds, mhod, "mhod")) return ret;
if (ret = itunesdb_mhod_init(mhod, "library_playlist_index")) return ret;
set_prefix(si, num_records, prefix_sortartist);
if (ret = itunesdb_set_mhod_index(mhod, 0x05, si, num_records)) return ret;
@@ -1027,16 +1010,14 @@
}
/* Construct an "mhod" chunk for index: album, disc/tracknumber, title. */
- mhod = chunk_new_child(mhyp);
+ mhod = chunk_new(itunesdb_cds, mhyp, "mhod");
if (mhod) {
- if (ret = chunk_init(itunesdb_cds, mhod, "mhod")) return ret;
if (ret = itunesdb_mhod_init(mhod, "index")) return ret;
qsort(si, num_records, sizeof(si[0]), comp_album);
if (ret = itunesdb_set_mhod_order(mhod, 0x04, si, num_records)) return ret;
- mhod = chunk_new_child(mhyp);
+ mhod = chunk_new(itunesdb_cds, mhyp, "mhod");
if (mhod) {
- if (ret = chunk_init(itunesdb_cds, mhod, "mhod")) return ret;
if (ret = itunesdb_mhod_init(mhod, "library_playlist_index")) return ret;
set_prefix(si, num_records, prefix_album);
if (ret = itunesdb_set_mhod_index(mhod, 0x04, si, num_records)) return ret;
@@ -1044,16 +1025,14 @@
}
/* Construct an "mhod" chunk for index: genre, sortartist, album, disc/tracknumber, title */
- mhod = chunk_new_child(mhyp);
+ mhod = chunk_new(itunesdb_cds, mhyp, "mhod");
if (mhod) {
- if (ret = chunk_init(itunesdb_cds, mhod, "mhod")) return ret;
if (ret = itunesdb_mhod_init(mhod, "index")) return ret;
qsort(si, num_records, sizeof(si[0]), comp_genre);
if (ret = itunesdb_set_mhod_order(mhod, 0x07, si, num_records)) return ret;
- mhod = chunk_new_child(mhyp);
+ mhod = chunk_new(itunesdb_cds, mhyp, "mhod");
if (mhod) {
- if (ret = chunk_init(itunesdb_cds, mhod, "mhod")) return ret;
if (ret = itunesdb_mhod_init(mhod, "library_playlist_index")) return ret;
set_prefix(si, num_records, prefix_genre);
if (ret = itunesdb_set_mhod_index(mhod, 0x07, si, num_records)) return ret;
@@ -1061,16 +1040,14 @@
}
/* Construct an "mhod" chunk for index: composer, title. */
- mhod = chunk_new_child(mhyp);
+ mhod = chunk_new(itunesdb_cds, mhyp, "mhod");
if (mhod) {
- if (ret = chunk_init(itunesdb_cds, mhod, "mhod")) return ret;
if (ret = itunesdb_mhod_init(mhod, "index")) return ret;
qsort(si, num_records, sizeof(si[0]), comp_composer);
if (ret = itunesdb_set_mhod_order(mhod, 0x12, si, num_records)) return ret;
- mhod = chunk_new_child(mhyp);
+ mhod = chunk_new(itunesdb_cds, mhyp, "mhod");
if (mhod) {
- if (ret = chunk_init(itunesdb_cds, mhod, "mhod")) return ret;
if (ret = itunesdb_mhod_init(mhod, "library_playlist_index")) return ret;
set_prefix(si, num_records, prefix_composer);
if (ret = itunesdb_set_mhod_index(mhod, 0x12, si, num_records)) return ret;
@@ -1078,34 +1055,30 @@
}
/* Construct an "mhod" chunk for index: albumartist, sortartist, disc/tracknumber, title. */
- mhod = chunk_new_child(mhyp);
+ mhod = chunk_new(itunesdb_cds, mhyp, "mhod");
if (mhod) {
- if (ret = chunk_init(itunesdb_cds, mhod, "mhod")) return ret;
if (ret = itunesdb_mhod_init(mhod, "index")) return ret;
qsort(si, num_records, sizeof(si[0]), comp_albumartist_sortartist);
if (ret = itunesdb_set_mhod_order(mhod, 0x23, si, num_records)) return ret;
}
/* Construct an "mhod" chunk for index: albumartist, album, disc/tracknumber, title*/
- mhod = chunk_new_child(mhyp);
+ mhod = chunk_new(itunesdb_cds, mhyp, "mhod");
if (mhod) {
- if (ret = chunk_init(itunesdb_cds, mhod, "mhod")) return ret;
if (ret = itunesdb_mhod_init(mhod, "index")) return ret;
qsort(si, num_records, sizeof(si[0]), comp_albumartist);
if (ret = itunesdb_set_mhod_order(mhod, 0x24, si, num_records)) return ret;
}
/* Construct an "mhod" chunk for index: title?. */
- mhod = chunk_new_child(mhyp);
+ mhod = chunk_new(itunesdb_cds, mhyp, "mhod");
if (mhod) {
- if (ret = chunk_init(itunesdb_cds, mhod, "mhod")) return ret;
if (ret = itunesdb_mhod_init(mhod, "index")) return ret;
qsort(si, num_records, sizeof(si[0]), comp_title);
if (ret = itunesdb_set_mhod_order(mhod, 0x1D, si, num_records)) return ret;
- mhod = chunk_new_child(mhyp);
+ mhod = chunk_new(itunesdb_cds, mhyp, "mhod");
if (mhod) {
- if (ret = chunk_init(itunesdb_cds, mhod, "mhod")) return ret;
if (ret = itunesdb_mhod_init(mhod, "library_playlist_index")) return ret;
set_prefix(si, num_records, prefix_title);
if (ret = itunesdb_set_mhod_index(mhod, 0x1D, si, num_records)) return ret;
@@ -1113,18 +1086,16 @@
}
/* Construct an "mhod" chunk for index: title?. */
- mhod = chunk_new_child(mhyp);
+ mhod = chunk_new(itunesdb_cds, mhyp, "mhod");
if (mhod) {
- if (ret = chunk_init(itunesdb_cds, mhod, "mhod")) return ret;
if (ret = itunesdb_mhod_init(mhod, "index")) return ret;
qsort(si, num_records, sizeof(si[0]), comp_title);
if (ret = itunesdb_set_mhod_order(mhod, 0x1E, si, num_records)) return ret;
}
/* Construct an "mhod" chunk for index: title?. */
- mhod = chunk_new_child(mhyp);
+ mhod = chunk_new(itunesdb_cds, mhyp, "mhod");
if (mhod) {
- if (ret = chunk_init(itunesdb_cds, mhod, "mhod")) return ret;
if (ret = itunesdb_mhod_init(mhod, "index")) return ret;
qsort(si, num_records, sizeof(si[0]), comp_title);
if (ret = itunesdb_set_mhod_order(mhod, 0x1F, si, num_records)) return ret;
@@ -1135,19 +1106,16 @@
/* */
for (i = 0;i < num_records;++i) {
- mhip = chunk_new_child(mhyp);
+ mhip = chunk_new(itunesdb_cds, mhyp, "mhip");
if (mhip) {
- itunesdb_mhip_t* mhip_data = NULL;
- if (ret = chunk_init(itunesdb_cds, mhip, "mhip")) return ret;
- mhip_data = (itunesdb_mhip_t*)mhip->data;
+ itunesdb_mhip_t* mhip_data = (itunesdb_mhip_t*)mhip->data;
mhip_data->flag_podcast_group = 0;
mhip_data->track_id = 1008 + i * 2;
mhip_data->group_id = 1008 + i * 2 + 1;
- mhod = chunk_new_child(mhip);
+ mhod = chunk_new(itunesdb_cds, mhip, "mhod");
if (mhod) {
- if (ret = chunk_init(itunesdb_cds, mhod, "mhod")) return ret;
if (ret = itunesdb_mhod_init(mhod, "playlist_order")) return ret;
if (ret = itunesdb_set_mhod_playlist_order(mhod, 1008 + i * 2 + 1)) return ret;
} else {
@@ -1190,9 +1158,8 @@
mhyp_data->sort_order = 1;
/* Construct an "mhod" chunk for title. */
- mhod = chunk_new_child(mhyp);
+ mhod = chunk_new(itunesdb_cds, mhyp, "mhod");
if (mhod) {
- if (ret = chunk_init(itunesdb_cds, mhod, "mhod")) return ret;
if (ret = itunesdb_mhod_init(mhod, "title")) return ret;
if (ret = itunesdb_set_mhod_string(mhod, playlist->name)) return ret;
}
@@ -1205,19 +1172,15 @@
int index = (int)get_record_index(playlist->entries[i], records, num_records);
if (index < num_records) {
- mhip = chunk_new_child(mhyp);
+ mhip = chunk_new(itunesdb_cds, mhyp, "mhip");
if (mhip) {
- itunesdb_mhip_t* mhip_data = NULL;
- if (ret = chunk_init(itunesdb_cds, mhip, "mhip")) return ret;
- mhip_data = (itunesdb_mhip_t*)mhip->data;
-
+ itunesdb_mhip_t* mhip_data = (itunesdb_mhip_t*)mhip->data;
mhip_data->flag_podcast_group = 0;
mhip_data->track_id = index;
mhip_data->group_id = index + num_records;
- mhod = chunk_new_child(mhip);
+ mhod = chunk_new(itunesdb_cds, mhip, "mhod");
if (mhod) {
- if (ret = chunk_init(itunesdb_cds, mhod, "mhod")) return ret;
if (ret = itunesdb_mhod_init(mhod, "playlist_order")) return ret;
if (ret = itunesdb_set_mhod_playlist_order(mhod, i+1)) return ret;
} else {
@@ -1253,11 +1216,10 @@
itunesdb_mhbd_t* mhbd_data = NULL;
/* Construct "mhbd" chunk. */
- mhbd = (chunk_t*)calloc(1, sizeof(chunk_t));
+ mhbd = chunk_new(itunesdb_cds, NULL, "mhbd");
if (!mhbd) {
return IPODE_FAILEDNEWCHUNK;
}
- if (ret = chunk_init(itunesdb_cds, mhbd, "mhbd")) return ret;
mhbd_data = (itunesdb_mhbd_t*)mhbd->data;
#if 0
@@ -1283,27 +1245,21 @@
#endif
/* Construct "mhsd" chunk with track type (type = 1). */
- mhsd = chunk_new_child(mhbd);
+ mhsd = chunk_new(itunesdb_cds, mhbd, "mhsd");
if (mhsd) {
- itunesdb_mhsd_t* mhsd_data = NULL;
- if (ret = chunk_init(itunesdb_cds, mhsd, "mhsd")) return ret;
- mhsd_data = (itunesdb_mhsd_t*)mhsd->data;
+ itunesdb_mhsd_t* mhsd_data = (itunesdb_mhsd_t*)mhsd->data;
mhsd_data->type = 1; /* track type. */
/* Construct "mhlt" chunk. */
- mhlt = chunk_new_child(mhsd);
+ mhlt = chunk_new(itunesdb_cds, mhsd, "mhlt");
if (mhlt) {
- if (ret = chunk_init(itunesdb_cds, mhlt, "mhlt")) return ret;
-
/* For all records... */
for (i = 0;i < num_records;++i) {
const pmp_music_record_t* rec = &records[i];
/* Construct "mhit" chunk. */
- mhit = chunk_new_child(mhlt);
+ mhit = chunk_new(itunesdb_cds, mhlt, "mhit");
if (mhit) {
- if (ret = chunk_init(itunesdb_cds, mhit, "mhit")) return ret;
-
/* This will fill "mhit" chunk and create "mhod" chunks. */
if (ret = set_music_record(mhit, rec, i, path_to_root)) return ret;
} else {
@@ -1320,32 +1276,24 @@
/* Construct "mhsd" chunk with playlist type (type = 3). */
/* Construct "mhsd" chunk with playlist type (type = 2). */
- mhsd = chunk_new_child(mhbd);
+ mhsd = chunk_new(itunesdb_cds, mhbd, "mhsd");
if (mhsd) {
- itunesdb_mhsd_t* mhsd_data = NULL;
- if (ret = chunk_init(itunesdb_cds, mhsd, "mhsd")) return ret;
- mhsd_data = (itunesdb_mhsd_t*)mhsd->data;
+ itunesdb_mhsd_t* mhsd_data = (itunesdb_mhsd_t*)mhsd->data;
mhsd_data->type = 2; /* playlist type. */
/* Construct "mhlp" chunk. */
- mhlp = chunk_new_child(mhsd);
+ mhlp = chunk_new(itunesdb_cds, mhsd, "mhlp");
if (mhlp) {
- if (ret = chunk_init(itunesdb_cds, mhlp, "mhlp")) return ret;
-
/* Create a master playlist. */
- mhyp = chunk_new_child(mhlp);
+ mhyp = chunk_new(itunesdb_cds, mhlp, "mhyp");
if (mhyp) {
- itunesdb_mhyp_t* mhyp_data = NULL;
- if (ret = chunk_init(itunesdb_cds, mhyp, "mhyp")) return ret;
if (ret = set_master_playlist(mhyp, records, num_records)) return ret;
}
/* Create user's playlists. */
for (i = 0;i < num_playlists;++i) {
- mhyp = chunk_new_child(mhlp);
+ mhyp = chunk_new(itunesdb_cds, mhlp, "mhyp");
if (mhyp) {
- itunesdb_mhyp_t* mhyp_data = NULL;
- if (ret = chunk_init(itunesdb_cds, mhyp, "mhyp")) return ret;
if (ret = set_playlist(mhyp, &playlists[i], records, num_records)) return ret;
} else {
return IPODE_FAILEDNEWCHUNK;
Modified: trunk/pmplib/lib/pmp_ipod/ipod_photo.c
===================================================================
--- trunk/pmplib/lib/pmp_ipod/ipod_photo.c 2007-10-08 08:40:37 UTC (rev 427)
+++ trunk/pmplib/lib/pmp_ipod/ipod_photo.c 2007-10-08 14:16:18 UTC (rev 428)
@@ -82,15 +82,13 @@
int ret = 0;
chunk_t* mhod = NULL;
- mhod = chunk_new_child(mhii);
+ mhod = chunk_new(artworkdb_cds, mhii, "mhod");
if (mhod) {
chunk_t* mhni = NULL;
- if (ret = chunk_init(artworkdb_cds, mhod, "mhod")) return ret;
if (ret = artworkdb_mhod_init(mhod, 2)) return ret;
- mhni = chunk_new_child(mhod);
- if (ret = chunk_init(artworkdb_cds, mhni, "mhni")) return ret;
+ mhni = chunk_new(artworkdb_cds, mhod, "mhni");
if (mhni) {
chunk_t* mhod = NULL;
artworkdb_mhni_t *mhni_data = (artworkdb_mhni_t*)mhni->data;
@@ -102,9 +100,8 @@
mhni_data->width = tn->width;
mhni_data->height = tn->height;
- mhod = chunk_new_child(mhni);
+ mhod = chunk_new(artworkdb_cds, mhni, "mhod");
if (mhod) {
- if (ret = chunk_init(artworkdb_cds, mhod, "mhod")) return ret;
if (ret = artworkdb_mhod_init(mhod, 3)) return ret;
if (ret = artworkdb_mhod_set_ucs2string(mhod, tn->filename)) return ret;
}
@@ -137,32 +134,25 @@
uint32_t i;
chunk_t *mhba = NULL, *mhod = NULL, *mhia = NULL;
- mhba = chunk_new_child(mhla);
+ mhba = chunk_new(artworkdb_cds, mhla, "mhba");
if (mhba) {
- artworkdb_mhba_t *mhba_data = NULL;
- if (ret = chunk_init(artworkdb_cds, mhba, "mhba")) return ret;
-
- mhba_data = (artworkdb_mhba_t*)mhba->data;
+ artworkdb_mhba_t *mhba_data = (artworkdb_mhba_t*)mhba->data;
mhba_data->num_mhod = 1;
mhba_data->num_mhia = album->num_entries;
mhba_data->playlist_id = 263;
mhba_data->prev_playlist_id = 100;
mhba_data->album_type = 1;
- mhod = chunk_new_child(mhba);
+ mhod = chunk_new(artworkdb_cds, mhba, "mhod");
if (mhod) {
- if (ret = chunk_init(artworkdb_cds, mhod, "mhod")) return ret;
if (ret = artworkdb_mhod_init(mhod, 1)) return ret;
if (ret = artworkdb_mhod_set_utf8string(mhod, album->name)) return ret;
}
for (i = 0;i < album->num_entries;++i) {
- mhia = chunk_new_child(mhba);
+ mhia = chunk_new(artworkdb_cds, mhba, "mhia");
if (mhia) {
- artworkdb_mhia_t *mhia_data = NULL;
- if (ret = chunk_init(artworkdb_cds, mhia, "mhia")) return ret;
-
- mhia_data = (artworkdb_mhia_t*)mhia->data;
+ artworkdb_mhia_t *mhia_data = (artworkdb_mhia_t*)mhia->data;
mhia_data->image_id = 100+i;
}
}
@@ -192,29 +182,24 @@
pmp_photo_album_t ma;
/* Construct "mhfd" chunk. */
- mhfd = (chunk_t*)calloc(1, sizeof(chunk_t));
+ mhfd = chunk_new(artworkdb_cds, NULL, "mhfd");
if (!mhfd) {
return IPODE_FAILEDNEWCHUNK;
}
- if (ret = chunk_init(artworkdb_cds, mhfd, "mhfd")) return ret;
- mhfd_data = (artworkdb_mhfd_t*)mhfd->data;
+ mhfd_data = (artworkdb_mhfd_t*)mhfd->data;
mhfd_data->unknown8 = 2;
mhfd_data->next_nhii = num_records;
/* Construct "mhsd" chunk (type = 1). */
- mhsd = chunk_new_child(mhfd);
+ mhsd = chunk_new(artworkdb_cds, mhfd, "mhsd");
if (mhsd) {
- artworkdb_mhsd_t* mhsd_data = NULL;
- if (ret = chunk_init(artworkdb_cds, mhsd, "mhsd")) return ret;
- mhsd_data = (artworkdb_mhsd_t*)mhsd->data;
+ artworkdb_mhsd_t* mhsd_data = (artworkdb_mhsd_t*)mhsd->data;
mhsd_data->type = 1; /* */
/* Construct "mhli" chunk. */
- mhli = chunk_new_child(mhsd);
- if (mhli) {
- if (ret = chunk_init(artworkdb_cds, mhli, "mhli")) return ret;
- } else {
+ mhli = chunk_new(artworkdb_cds, mhsd, "mhli");
+ if (mhli == NULL) {
return IPODE_FAILEDNEWCHUNK;
}
@@ -223,11 +208,9 @@
const ipod_photo_record_t* rec = &records[i];
/* Construct "mhii" chunk. */
- mhii = chunk_new_child(mhli);
+ mhii = chunk_new(artworkdb_cds, mhli, "mhii");
if (mhii) {
- artworkdb_mhii_t* mhii_data = NULL;
- if (ret = chunk_init(artworkdb_cds, mhii, "mhii")) return ret;
- mhii_data = (artworkdb_mhii_t*)mhii->data;
+ artworkdb_mhii_t* mhii_data = (artworkdb_mhii_t*)mhii->data;
/* This will fill "mhii" chunk and create "mhod" chunks. */
if (ret = set_photo_record(mhii, rec, i, path_to_root)) return ret;
@@ -242,18 +225,14 @@
}
/* Construct "mhsd" chunk (type = 2). */
- mhsd = chunk_new_child(mhfd);
+ mhsd = chunk_new(artworkdb_cds, mhfd, "mhsd");
if (mhsd) {
- artworkdb_mhsd_t* mhsd_data = NULL;
- if (ret = chunk_init(artworkdb_cds, mhsd, "mhsd")) return ret;
- mhsd_data = (artworkdb_mhsd_t*)mhsd->data;
+ artworkdb_mhsd_t* mhsd_data = (artworkdb_mhsd_t*)mhsd->data;
mhsd_data->type = 2; /* */
/* Construct "mhla" chunk. */
- mhla = chunk_new_child(mhsd);
- if (mhla) {
- if (ret = chunk_init(artworkdb_cds, mhla, "mhla")) return ret;
- } else {
+ mhla = chunk_new(artworkdb_cds, mhsd, "mhla");
+ if (mhla == NULL) {
return IPODE_FAILEDNEWCHUNK;
}
@@ -272,24 +251,19 @@
}
/* Construct "mhsd" chunk (type = 3). */
- mhsd = chunk_new_child(mhfd);
+ mhsd = chunk_new(artworkdb_cds, mhfd, "mhsd");
if (mhsd) {
- artworkdb_mhsd_t* mhsd_data = NULL;
- if (ret = chunk_init(artworkdb_cds, mhsd, "mhsd")) return ret;
- mhsd_data = (artworkdb_mhsd_t*)mhsd->data;
+ artworkdb_mhsd_t* mhsd_data = (artworkdb_mhsd_t*)mhsd->data;
mhsd_data->type = 3; /* */
/* Construct "mhlf" chunk. */
- mhlf = chunk_new_child(mhsd);
- if (mhlf) {
- if (ret = chunk_init(artworkdb_cds, mhlf, "mhlf")) return ret;
- } else {
+ mhlf = chunk_new(artworkdb_cds, mhsd, "mhlf");
+ if (mhlf == NULL) {
return IPODE_FAILEDNEWCHUNK;
}
for (i = 0;i < ipod->num_photo_formats;++i) {
- mhif = chunk_new_child(mhlf);
- if (ret = chunk_init(artworkdb_cds, mhif, "mhif")) return ret;
+ mhif = chunk_new(artworkdb_cds, mhlf, "mhif");
mhif_data = (artworkdb_mhif_t*)mhif->data;
mhif_data->format_id = ipod->photo_formats[i].format;
mhif_data->image_size = ipod->photo_formats[i].size;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ny...@us...> - 2007-10-08 08:40:36
|
Revision: 427
http://pmplib.svn.sourceforge.net/pmplib/?rev=427&view=rev
Author: nyaochi
Date: 2007-10-08 01:40:37 -0700 (Mon, 08 Oct 2007)
Log Message:
-----------
Updated the build system for Win32 with the latest
library dependencies.
Modified Paths:
--------------
trunk/pmplib/frontend/easypmp/cui/easypmp_cui.vcproj
trunk/pmplib/lib/gmi/gmi.vcproj
trunk/pmplib/lib/playlist/playlist.vcproj
trunk/pmplib/lib/pmp_ipod/pmp_ipod.vcproj
Modified: trunk/pmplib/frontend/easypmp/cui/easypmp_cui.vcproj
===================================================================
--- trunk/pmplib/frontend/easypmp/cui/easypmp_cui.vcproj 2007-10-08 07:59:18 UTC (rev 426)
+++ trunk/pmplib/frontend/easypmp/cui/easypmp_cui.vcproj 2007-10-08 08:40:37 UTC (rev 427)
@@ -41,7 +41,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
- AdditionalIncludeDirectories="$(SolutionDir)include\win32,$(SolutionDir)include,..\common,..\contrib"
+ AdditionalIncludeDirectories="$(SolutionDir)include\win32,$(SolutionDir)include,$(SolutionDir)win32,..\common"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_H"
MinimalRebuild="true"
BasicRuntimeChecks="3"
@@ -65,7 +65,7 @@
AdditionalDependencies="bgd.lib"
OutputFile="$(OutDir)/easypmp_cui.exe"
LinkIncremental="2"
- AdditionalLibraryDirectories="..\contrib\gd"
+ AdditionalLibraryDirectories="$(SolutionDir)win32\gd"
GenerateDebugInformation="true"
ProgramDatabaseFile="$(OutDir)/easypmp_cui.pdb"
SubSystem="1"
@@ -121,7 +121,7 @@
/>
<Tool
Name="VCCLCompilerTool"
- AdditionalIncludeDirectories="$(SolutionDir)include\win32,$(SolutionDir)include,..\common,..\contrib"
+ AdditionalIncludeDirectories="$(SolutionDir)include\win32,$(SolutionDir)include,$(SolutionDir)win32,..\common"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;HAVE_CONFIG_H"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
@@ -143,7 +143,7 @@
AdditionalDependencies="bgd.lib"
OutputFile="$(OutDir)/easypmp_cui.exe"
LinkIncremental="1"
- AdditionalLibraryDirectories="..\contrib\gd"
+ AdditionalLibraryDirectories="$(SolutionDir)win32\gd"
GenerateDebugInformation="true"
SubSystem="1"
OptimizeReferences="2"
Modified: trunk/pmplib/lib/gmi/gmi.vcproj
===================================================================
--- trunk/pmplib/lib/gmi/gmi.vcproj 2007-10-08 07:59:18 UTC (rev 426)
+++ trunk/pmplib/lib/gmi/gmi.vcproj 2007-10-08 08:40:37 UTC (rev 427)
@@ -41,7 +41,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
- AdditionalIncludeDirectories="$(SolutionDir)include\win32,$(SolutionDir)include,contrib,contrib\id3tag,contrib\mp4v2"
+ AdditionalIncludeDirectories="$(SolutionDir)include\win32,$(SolutionDir)include,$(SolutionDir)win32,$(SolutionDir)win32\id3tag,$(SolutionDir)win32\mp4v2"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;GMI_EXPORTS;HAVE_CONFIG_H"
MinimalRebuild="true"
BasicRuntimeChecks="3"
@@ -62,9 +62,10 @@
/>
<Tool
Name="VCLinkerTool"
- AdditionalDependencies=".\contrib\id3tag\win32\libid3tagd.lib .\contrib\id3tag\win32\zlibd.lib .\contrib\ogg\win32\ogg_static_d.lib .\contrib\vorbis\win32\vorbis_static_d.lib .\contrib\vorbis\win32\vorbisfile_static_d.lib .\contrib\mp4v2\win32\libmp4v2d.lib"
+ AdditionalDependencies="libid3tagd.lib zlibd.lib ogg_static_d.lib vorbis_static_d.lib vorbisfile_static_d.lib libmp4v2d.lib"
OutputFile="$(OutDir)/gmi.dll"
LinkIncremental="2"
+ AdditionalLibraryDirectories="$(SolutionDir)win32\zlib;$(SolutionDir)win32\id3tag;$(SolutionDir)win32\ogg;$(SolutionDir)win32\vorbis;$(SolutionDir)win32\mp4v2"
GenerateDebugInformation="true"
ProgramDatabaseFile="$(OutDir)/gmi.pdb"
SubSystem="2"
@@ -121,7 +122,7 @@
/>
<Tool
Name="VCCLCompilerTool"
- AdditionalIncludeDirectories="$(SolutionDir)include\win32,$(SolutionDir)include,contrib,contrib\id3tag,contrib\mp4v2"
+ AdditionalIncludeDirectories="$(SolutionDir)include\win32,$(SolutionDir)include,$(SolutionDir)win32,$(SolutionDir)win32\id3tag,$(SolutionDir)win32\mp4v2"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;GMI_EXPORTS;HAVE_CONFIG_H"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
@@ -140,9 +141,10 @@
/>
<Tool
Name="VCLinkerTool"
- AdditionalDependencies=".\contrib\id3tag\win32\libid3tag.lib .\contrib\id3tag\win32\zlib.lib .\contrib\ogg\win32\ogg_static.lib .\contrib\vorbis\win32\vorbis_static.lib .\contrib\vorbis\win32\vorbisfile_static.lib .\contrib\mp4v2\win32\libmp4v2.lib"
+ AdditionalDependencies="libid3tag.lib zlib.lib ogg_static.lib vorbis_static.lib vorbisfile_static.lib libmp4v2.lib"
OutputFile="$(OutDir)/gmi.dll"
LinkIncremental="1"
+ AdditionalLibraryDirectories="$(SolutionDir)win32\zlib;$(SolutionDir)win32\id3tag;$(SolutionDir)win32\ogg;$(SolutionDir)win32\vorbis;$(SolutionDir)win32\mp4v2"
GenerateDebugInformation="true"
SubSystem="2"
OptimizeReferences="2"
Modified: trunk/pmplib/lib/playlist/playlist.vcproj
===================================================================
--- trunk/pmplib/lib/playlist/playlist.vcproj 2007-10-08 07:59:18 UTC (rev 426)
+++ trunk/pmplib/lib/playlist/playlist.vcproj 2007-10-08 08:40:37 UTC (rev 427)
@@ -40,7 +40,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
- AdditionalIncludeDirectories="$(SolutionDir)include,.\contrib\js"
+ AdditionalIncludeDirectories="$(SolutionDir)include,$(SolutionDir)win32\js"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;PLAYLIST_EXPORTS;XP_WIN;HAVE_JSAPI_H"
MinimalRebuild="true"
BasicRuntimeChecks="3"
@@ -61,9 +61,10 @@
/>
<Tool
Name="VCLinkerTool"
- AdditionalDependencies=".\contrib\js\win32\js32d.lib"
+ AdditionalDependencies="js32d.lib"
OutputFile="$(OutDir)/playlist.dll"
LinkIncremental="2"
+ AdditionalLibraryDirectories="$(SolutionDir)win32\js\debug"
GenerateDebugInformation="true"
ProgramDatabaseFile="$(OutDir)/playlist.pdb"
SubSystem="2"
@@ -120,7 +121,7 @@
/>
<Tool
Name="VCCLCompilerTool"
- AdditionalIncludeDirectories="$(SolutionDir)include,.\contrib\js"
+ AdditionalIncludeDirectories="$(SolutionDir)include,$(SolutionDir)win32\js"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;PLAYLIST_EXPORTS;XP_WIN;HAVE_JSAPI_H"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
@@ -139,9 +140,10 @@
/>
<Tool
Name="VCLinkerTool"
- AdditionalDependencies=".\contrib\js\win32\js32.lib"
+ AdditionalDependencies="js32.lib"
OutputFile="$(OutDir)/playlist.dll"
LinkIncremental="1"
+ AdditionalLibraryDirectories="$(SolutionDir)win32\js\release"
GenerateDebugInformation="true"
SubSystem="2"
OptimizeReferences="2"
Modified: trunk/pmplib/lib/pmp_ipod/pmp_ipod.vcproj
===================================================================
--- trunk/pmplib/lib/pmp_ipod/pmp_ipod.vcproj 2007-10-08 07:59:18 UTC (rev 426)
+++ trunk/pmplib/lib/pmp_ipod/pmp_ipod.vcproj 2007-10-08 08:40:37 UTC (rev 427)
@@ -139,7 +139,7 @@
Name="VCLinkerTool"
AdditionalDependencies=".\win32\usbinfo_win32.lib .\win32spti\ipodprop_win32spti.lib shlwapi.lib bgd.lib libexpat.lib"
LinkIncremental="1"
- AdditionalLibraryDirectories="$(SolutionDir)win32\gd;$(SolutionDir)win32\expat"
+ AdditionalLibraryDirectories="$(SolutionDir)win32\gd;$(SolutionDir)win32\expat\release"
GenerateDebugInformation="true"
SubSystem="2"
OptimizeReferences="2"
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ny...@us...> - 2007-10-06 02:22:42
|
Revision: 423
http://pmplib.svn.sourceforge.net/pmplib/?rev=423&view=rev
Author: nyaochi
Date: 2007-10-05 19:22:44 -0700 (Fri, 05 Oct 2007)
Log Message:
-----------
Renamt correlation_id -> format_id since these values are
associated with the dictionary entries of
<key>FormatId</key>.
Modified Paths:
--------------
trunk/pmplib/lib/pmp_ipod/artworkdb.c
trunk/pmplib/lib/pmp_ipod/artworkdb.h
Modified: trunk/pmplib/lib/pmp_ipod/artworkdb.c
===================================================================
--- trunk/pmplib/lib/pmp_ipod/artworkdb.c 2007-10-06 01:17:54 UTC (rev 422)
+++ trunk/pmplib/lib/pmp_ipod/artworkdb.c 2007-10-06 02:22:44 UTC (rev 423)
@@ -213,7 +213,7 @@
mhni = (artworkdb_mhni_t*)calloc(1, sizeof(artworkdb_mhni_t));
if (def && mhni) {
mhni->num_children = 0;
- mhni->correlation_id = 0;
+ mhni->format_id = 0;
mhni->ithmb_offset = 0;
mhni->ithmb_size = 0;
mhni->vertical_padding = 0;
@@ -231,7 +231,7 @@
artworkdb_mhni_t* mhni = (artworkdb_mhni_t*)chunk->data;
if (ret = serialize_uint32le(sio, "num_children", "%d", &mhni->num_children)) return ret;
- if (ret = serialize_uint32le(sio, "correlation_id", "%d", &mhni->correlation_id)) return ret;
+ if (ret = serialize_uint32le(sio, "format_id", "%d", &mhni->format_id)) return ret;
if (ret = serialize_uint32le(sio, "ithmb_offset", "%d", &mhni->ithmb_offset)) return ret;
if (ret = serialize_uint32le(sio, "ithmb_size", "%d", &mhni->ithmb_size)) return ret;
if (ret = serialize_uint16le(sio, "vertical_padding", "%d", &mhni->vertical_padding)) return ret;
@@ -389,7 +389,7 @@
artworkdb_mhif_t* mhif = (artworkdb_mhif_t*)chunk->data;
if (ret = serialize_uint32le(sio, "unknown1", "%d", &mhif->unknown1)) return ret;
- if (ret = serialize_uint32le(sio, "correlation_id", "%d", &mhif->correlation_id)) return ret;
+ if (ret = serialize_uint32le(sio, "format_id", "%d", &mhif->format_id)) return ret;
if (ret = serialize_uint32le(sio, "image_size", "%d", &mhif->image_size)) return ret;
return 0;
Modified: trunk/pmplib/lib/pmp_ipod/artworkdb.h
===================================================================
--- trunk/pmplib/lib/pmp_ipod/artworkdb.h 2007-10-06 01:17:54 UTC (rev 422)
+++ trunk/pmplib/lib/pmp_ipod/artworkdb.h 2007-10-06 02:22:44 UTC (rev 423)
@@ -63,7 +63,7 @@
typedef struct {
uint32_t num_children;
- uint32_t correlation_id;
+ uint32_t format_id;
uint32_t ithmb_offset;
uint32_t ithmb_size;
uint16_t vertical_padding;
@@ -101,7 +101,7 @@
typedef struct {
uint32_t unknown1;
- uint32_t correlation_id;
+ uint32_t format_id;
uint32_t image_size;
} artworkdb_mhif_t;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ny...@us...> - 2007-10-06 01:17:50
|
Revision: 422
http://pmplib.svn.sourceforge.net/pmplib/?rev=422&view=rev
Author: nyaochi
Date: 2007-10-05 18:17:54 -0700 (Fri, 05 Oct 2007)
Log Message:
-----------
Obtain serial IDs from iPod device information.
We don't have to query USB serial directly to the USB
port driver.
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
trunk/pmplib/lib/pmp_ipod/pmp_ipod.c
trunk/pmplib/lib/pmp_ipod/pmp_ipod.vcproj
Modified: trunk/pmplib/lib/pmp_ipod/ipod.c
===================================================================
--- trunk/pmplib/lib/pmp_ipod/ipod.c 2007-10-05 17:13:21 UTC (rev 421)
+++ trunk/pmplib/lib/pmp_ipod/ipod.c 2007-10-06 01:17:54 UTC (rev 422)
@@ -40,7 +40,6 @@
#include "util.h"
#include "ipod.h"
#include "ipodprop.h"
-#include "ipodserial.h"
#include "chunk.h"
#include "itunesdb.h"
#include "artworkdb.h"
@@ -94,6 +93,14 @@
return IPODE_DEVICEINFO;
}
+static uint8_t get_uint8(const char *str, int begin)
+{
+ char value[] = {'0','x','0','0',0};
+ value[2] = str[begin];
+ value[3] = str[begin+1];
+ return (uint8_t)strtoul(value, NULL, 16);
+}
+
static int detect_model(
const ucs2char_t* path_to_device,
const ipod_descriptor_t* md,
@@ -164,20 +171,50 @@
}
}
-int ipod_init(ipod_t* ipod)
+int ipod_init(ipod_t* ipod, const ucs2char_t* path_to_device)
{
+ int i;
+ ipodprop_t ip;
+ char *path = ucs2dupmbs(path_to_device);
+
+ memset(ipod, 0, sizeof(*ipod));
+
+ /* Obtain the device information. */
+ ipodprop_init(&ip);
+ if (ipodprop_get(path, &ip) == 0) {
+ if (ip.vendor && strncmp(ip.vendor, "Apple", 5) == 0 &&
+ ip.product && strncmp(ip.product, "iPod", 4) == 0) {
+
+ char serial[128];
+
+ if (ip.info) {
+ ipod->xml = strdup(ip.info);
+
+ get_string_value(ip.info, "FireWireGUID", (char*)serial, sizeof(serial));
+ for (i = 0;i < 8;++i) {
+ ipod->serial[i] = get_uint8(serial, 2*i);
+ }
+ }
+ }
+ }
+ ipodprop_finish(&ip);
+ ucs2free(path);
+
ipod->itunesdb = (itunes_chunk_t*)calloc(1, sizeof(itunes_chunk_t));
if (!ipod->itunesdb) {
return IPODE_OUTOFMEMORY;
}
+
ipod->artworkdb = (itunes_chunk_t*)calloc(1, sizeof(itunes_chunk_t));
if (!ipod->artworkdb) {
return IPODE_OUTOFMEMORY;
}
+
ipod->pcs = (playcounts_t*)calloc(1, sizeof(playcounts_t));
if (!ipod->pcs) {
return IPODE_OUTOFMEMORY;
}
+
return 0;
}
@@ -188,6 +225,7 @@
itunesdb_finish(artworkdb_cds, ipod->artworkdb);
free(ipod->pcs);
free(ipod->itunesdb);
+ free(ipod->xml);
}
int ipod_read(ipod_t* ipod, const ucs2char_t* itunesdb, const ucs2char_t* artworkdb, const ucs2char_t* playcounts)
@@ -284,7 +322,7 @@
fp = ucs2fopen(itunesdb, "wb");
if (fp) {
/* Finalize the database (fill the hash58 value). */
- itunesdb_finalize(sio.base, sio.offset);
+ itunesdb_finalize(sio.base, sio.offset, ipod->serial);
if (fwrite(sio.base, 1, sio.offset, fp) != sio.offset) {
return (IPODC_ITUNESDB|IPODE_FILEWRITEERROR);
Modified: trunk/pmplib/lib/pmp_ipod/ipod.h
===================================================================
--- trunk/pmplib/lib/pmp_ipod/ipod.h 2007-10-05 17:13:21 UTC (rev 421)
+++ trunk/pmplib/lib/pmp_ipod/ipod.h 2007-10-06 01:17:54 UTC (rev 422)
@@ -53,13 +53,14 @@
itunes_chunk_t* itunesdb;
itunes_chunk_t* artworkdb;
playcounts_t* pcs;
+ char *xml;
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);
const ipod_descriptor_t* ipod_next_descriptor(const ipod_descriptor_t* md);
-int ipod_init(ipod_t* ipod);
+int ipod_init(ipod_t* ipod, const ucs2char_t* path_to_device);
void ipod_finish(ipod_t* ipod);
int ipod_read(ipod_t* ipod, const ucs2char_t* itunesdb, const ucs2char_t* artworkdb, const ucs2char_t* playcounts);
int ipod_write(ipod_t* ipod, const ucs2char_t* itunesdb, const ucs2char_t* artworkdb, const ucs2char_t* playcounts);
Modified: trunk/pmplib/lib/pmp_ipod/itunesdb.c
===================================================================
--- trunk/pmplib/lib/pmp_ipod/itunesdb.c 2007-10-05 17:13:21 UTC (rev 421)
+++ trunk/pmplib/lib/pmp_ipod/itunesdb.c 2007-10-06 01:17:54 UTC (rev 422)
@@ -822,13 +822,10 @@
-int itunesdb_finalize(uint8_t* buffer, size_t size)
+int itunesdb_finalize(uint8_t* buffer, size_t size, uint8_t fwid[8])
{
uint8_t* src = NULL;
uint8_t hash58[20];
- uint8_t fwid[8] = {
- 0x00, 0x0A, 0x27, 0x00, 0x1A, 0x1D, 0x72, 0xF1
- }; /* iPod nano 3rd gen only for now. */
src = (uint8_t*)malloc(size);
if (src == NULL) {
Modified: trunk/pmplib/lib/pmp_ipod/itunesdb.h
===================================================================
--- trunk/pmplib/lib/pmp_ipod/itunesdb.h 2007-10-05 17:13:21 UTC (rev 421)
+++ trunk/pmplib/lib/pmp_ipod/itunesdb.h 2007-10-06 01:17:54 UTC (rev 422)
@@ -311,7 +311,7 @@
*/
int itunesdb_set_mhod_playlist_order(itunes_chunk_t* chunk, uint32_t order);
-int itunesdb_finalize(uint8_t* buffer, size_t size);
+int itunesdb_finalize(uint8_t* buffer, size_t size, uint8_t fwid[8]);
int itunesdb_mhod_init(itunes_chunk_t* chunk, const char *name);
int itunesdb_is_mhodchunk(itunes_chunk_t* chunk, const char *type);
Modified: trunk/pmplib/lib/pmp_ipod/pmp_ipod.c
===================================================================
--- trunk/pmplib/lib/pmp_ipod/pmp_ipod.c 2007-10-05 17:13:21 UTC (rev 421)
+++ trunk/pmplib/lib/pmp_ipod/pmp_ipod.c 2007-10-06 01:17:54 UTC (rev 422)
@@ -341,7 +341,7 @@
ucs2char_t itunesdb[MAX_PATH], artworkdb[MAX_PATH], playcounts[MAX_PATH];
// Initialize ipod library.
- ipod_init(&ipod);
+ ipod_init(&ipod, pmp->info.path_to_root);
// Read the music database.
set_filenames(itunesdb, artworkdb, playcounts, music->pmp);
@@ -403,7 +403,7 @@
ucs2char_t itunesdb[MAX_PATH], artworkdb[MAX_PATH], playcounts[MAX_PATH];
// Initialize ipod library.
- ipod_init(&ipod);
+ ipod_init(&ipod, pmp->info.path_to_root);
// Read the music database.
set_filenames(itunesdb, artworkdb, playcounts, music->pmp);
@@ -454,10 +454,11 @@
{
ipod_t ipod;
result_t ret = 0;
+ pmp_t* pmp = music->pmp;
ucs2char_t itunesdb[MAX_PATH], artworkdb[MAX_PATH], playcounts[MAX_PATH];
// Initialize IP3DB.
- ipod_init(&ipod);
+ ipod_init(&ipod, pmp->info.path_to_root);
// Read the music database.
set_filenames(itunesdb, artworkdb, playcounts, music->pmp);
Modified: trunk/pmplib/lib/pmp_ipod/pmp_ipod.vcproj
===================================================================
--- trunk/pmplib/lib/pmp_ipod/pmp_ipod.vcproj 2007-10-05 17:13:21 UTC (rev 421)
+++ trunk/pmplib/lib/pmp_ipod/pmp_ipod.vcproj 2007-10-06 01:17:54 UTC (rev 422)
@@ -195,10 +195,6 @@
>
</File>
<File
- RelativePath=".\ipodserial_win32.c"
- >
- </File>
- <File
RelativePath=".\itunesdb.c"
>
</File>
@@ -245,14 +241,6 @@
>
</File>
<File
- RelativePath=".\ipodprop.h"
- >
- </File>
- <File
- RelativePath=".\ipodserial.h"
- >
- </File>
- <File
RelativePath=".\itunesdb.h"
>
</File>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ny...@us...> - 2007-10-05 17:13:18
|
Revision: 421
http://pmplib.svn.sourceforge.net/pmplib/?rev=421&view=rev
Author: nyaochi
Date: 2007-10-05 10:13:21 -0700 (Fri, 05 Oct 2007)
Log Message:
-----------
pmp_ipod now dumps ArtworkDB content.
Modified Paths:
--------------
trunk/pmplib/lib/pmp_ipod/artworkdb.c
trunk/pmplib/lib/pmp_ipod/artworkdb.h
trunk/pmplib/lib/pmp_ipod/chunk.c
trunk/pmplib/lib/pmp_ipod/chunk.h
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/pmp_ipod.c
Modified: trunk/pmplib/lib/pmp_ipod/artworkdb.c
===================================================================
--- trunk/pmplib/lib/pmp_ipod/artworkdb.c 2007-10-05 14:47:54 UTC (rev 420)
+++ trunk/pmplib/lib/pmp_ipod/artworkdb.c 2007-10-05 17:13:21 UTC (rev 421)
@@ -19,7 +19,7 @@
*
*/
-/* $Id:$ */
+/* $Id$ */
#ifdef HAVE_CONFIG_H
#include <config.h>
@@ -37,16 +37,17 @@
#include "ipod.h"
#include "serialize.h"
#include "util.h"
+#include "chunk.h"
#include "artworkdb.h"
-static void chunk_finish(artworkdb_chunk_t* chunk)
+static void chunk_finish(itunes_chunk_t* chunk)
{
free(chunk->data);
free(chunk->padding);
memset(chunk, 0, sizeof(*chunk));
}
-static int mhfd_init(artworkdb_chunk_t* chunk, int def)
+static int mhfd_init(itunes_chunk_t* chunk, int def)
{
artworkdb_mhfd_t* mhfd = NULL;
@@ -64,19 +65,18 @@
mhfd->num_children = 0; /* to be filled */
mhfd->unknown3 = 0;
mhfd->next_nhii = 0;
- mhfd->unknown5 = 0;
- mhfd->unknown6 = 0;
+ mhfd->unknown5 = 0x0E777BDE5D06AD9B;
+ mhfd->unknown6 = 0x368B84B5E61BC6ED;
mhfd->unknown7 = 2;
mhfd->unknown8 = 0;
mhfd->unknown9 = 0;
- mhfd->unknown10 = 0;
- mhfd->unknown11 = 0;
+ mhfd->unknown10 = 0x15C516AB8F8EB3A4;
}
chunk->data = mhfd;
return mhfd ? 0 : IPODE_OUTOFMEMORY;
}
-static int mhfd_serialize(artworkdb_chunk_t* chunk, serializer_t* sio)
+static int mhfd_serialize(itunes_chunk_t* chunk, serializer_t* sio)
{
int ret = 0;
artworkdb_mhfd_t* mhfd = (artworkdb_mhfd_t*)chunk->data;
@@ -91,15 +91,14 @@
if (ret = serialize_uint32le(sio, "unknown7", "%d", &mhfd->unknown7)) return ret;
if (ret = serialize_uint32le(sio, "unknown8", "%d", &mhfd->unknown8)) return ret;
if (ret = serialize_uint32le(sio, "unknown9", "%d", &mhfd->unknown9)) return ret;
- if (ret = serialize_uint32le(sio, "unknown10", "%d", &mhfd->unknown10)) return ret;
- if (ret = serialize_uint32le(sio, "unknown11", "%d", &mhfd->unknown10)) return ret;
+ if (ret = serialize_uint64le(sio, "unknown10", "%016llX", &mhfd->unknown10)) return ret;
return 0;
}
-static mhsd_init(artworkdb_chunk_t* chunk, int def)
+static mhsd_init(itunes_chunk_t* chunk, int def)
{
artworkdb_mhsd_t* mhsd = NULL;
@@ -119,7 +118,7 @@
return mhsd ? 0 : IPODE_OUTOFMEMORY;
}
-static int mhsd_serialize(artworkdb_chunk_t* chunk, serializer_t* sio)
+static int mhsd_serialize(itunes_chunk_t* chunk, serializer_t* sio)
{
int ret = 0;
artworkdb_mhsd_t* mhsd = (artworkdb_mhsd_t*)chunk->data;
@@ -131,12 +130,12 @@
-static mhli_init(artworkdb_chunk_t* chunk, int def)
+static mhli_init(itunes_chunk_t* chunk, int def)
{
if (def) {
memset(chunk, 0, sizeof(*chunk));
strncpy(chunk->id, "mhli", 4);
- chunk->size = 96;
+ chunk->size = 92;
chunk->overall_size = 0; /* to be filled */
}
@@ -144,21 +143,21 @@
return 0;
}
-static int mhli_serialize(artworkdb_chunk_t* chunk, serializer_t* sio)
+static int mhli_serialize(itunes_chunk_t* chunk, serializer_t* sio)
{
return 0;
}
-static int mhii_init(artworkdb_chunk_t* chunk, int def)
+static int mhii_init(itunes_chunk_t* chunk, int def)
{
artworkdb_mhii_t* mhii = NULL;
if (def) {
memset(chunk, 0, sizeof(*chunk));
strncpy(chunk->id, "mhii", 4);
- chunk->size = 104;
+ chunk->size = 152;
chunk->overall_size = 0; /* to be filled */
}
@@ -178,7 +177,7 @@
return mhii ? 0 : IPODE_OUTOFMEMORY;
}
-static int mhii_serialize(artworkdb_chunk_t* chunk, serializer_t* sio)
+static int mhii_serialize(itunes_chunk_t* chunk, serializer_t* sio)
{
int ret = 0;
artworkdb_mhii_t* mhii = (artworkdb_mhii_t*)chunk->data;
@@ -192,19 +191,22 @@
if (ret = serialize_uint32le(sio, "ts_file", "%d", &mhii->ts_file)) return ret;
if (ret = serialize_uint32le(sio, "ts_import", "%d", &mhii->ts_import)) return ret;
if (ret = serialize_uint32le(sio, "original_size", "%d", &mhii->original_size)) return ret;
+ if (ret = serialize_uint32le(sio, "unknown10", "%d", &mhii->unknown10)) return ret;
+ if (ret = serialize_uint32le(sio, "unknown11", "%d", &mhii->unknown11)) return ret;
+ if (ret = serialize_uint32le(sio, "unknown12", "%d", &mhii->unknown12)) return ret;
return 0;
}
-static int mhni_init(artworkdb_chunk_t* chunk, int def)
+static int mhni_init(itunes_chunk_t* chunk, int def)
{
artworkdb_mhni_t* mhni = NULL;
if (def) {
memset(chunk, 0, sizeof(*chunk));
strncpy(chunk->id, "mhni", 4);
- chunk->size = 104;
+ chunk->size = 76;
chunk->overall_size = 0; /* to be filled */
}
@@ -223,7 +225,7 @@
return mhni ? 0 : IPODE_OUTOFMEMORY;
}
-static int mhni_serialize(artworkdb_chunk_t* chunk, serializer_t* sio)
+static int mhni_serialize(itunes_chunk_t* chunk, serializer_t* sio)
{
int ret = 0;
artworkdb_mhni_t* mhni = (artworkdb_mhni_t*)chunk->data;
@@ -244,14 +246,14 @@
-static int mhba_init(artworkdb_chunk_t* chunk, int def)
+static int mhba_init(itunes_chunk_t* chunk, int def)
{
artworkdb_mhba_t* mhba = NULL;
if (def) {
memset(chunk, 0, sizeof(*chunk));
strncpy(chunk->id, "mhba", 4);
- chunk->size = 104;
+ chunk->size = 104; /* ??? */
chunk->overall_size = 0; /* to be filled */
}
@@ -262,7 +264,7 @@
return mhba ? 0 : IPODE_OUTOFMEMORY;
}
-static int mhba_serialize(artworkdb_chunk_t* chunk, serializer_t* sio)
+static int mhba_serialize(itunes_chunk_t* chunk, serializer_t* sio)
{
int ret = 0;
artworkdb_mhba_t* mhba = (artworkdb_mhba_t*)chunk->data;
@@ -289,15 +291,35 @@
}
+static mhla_init(itunes_chunk_t* chunk, int def)
+{
+ if (def) {
+ memset(chunk, 0, sizeof(*chunk));
+ strncpy(chunk->id, "mhla", 4);
+ chunk->size = 92;
+ chunk->overall_size = 0; /* to be filled */
+ }
-static mhia_init(artworkdb_chunk_t* chunk, int def)
+ chunk->data = 0;
+ return 0;
+}
+
+static int mhla_serialize(itunes_chunk_t* chunk, serializer_t* sio)
{
+ return 0;
+}
+
+
+
+
+static mhia_init(itunes_chunk_t* chunk, int def)
+{
artworkdb_mhia_t* mhia = NULL;
if (def) {
memset(chunk, 0, sizeof(*chunk));
strncpy(chunk->id, "mhia", 4);
- chunk->size = 96;
+ chunk->size = 96; /* ??? */
chunk->overall_size = 0; /* to be filled */
}
@@ -309,7 +331,7 @@
return mhia ? 0 : IPODE_OUTOFMEMORY;
}
-static int mhia_serialize(artworkdb_chunk_t* chunk, serializer_t* sio)
+static int mhia_serialize(itunes_chunk_t* chunk, serializer_t* sio)
{
int ret = 0;
artworkdb_mhia_t* mhia = (artworkdb_mhia_t*)chunk->data;
@@ -322,12 +344,12 @@
-static mhlf_init(artworkdb_chunk_t* chunk, int def)
+static mhlf_init(itunes_chunk_t* chunk, int def)
{
if (def) {
memset(chunk, 0, sizeof(*chunk));
strncpy(chunk->id, "mhlf", 4);
- chunk->size = 96;
+ chunk->size = 92;
chunk->overall_size = 0; /* to be filled */
}
@@ -335,21 +357,21 @@
return 0;
}
-static int mhlf_serialize(artworkdb_chunk_t* chunk, serializer_t* sio)
+static int mhlf_serialize(itunes_chunk_t* chunk, serializer_t* sio)
{
return 0;
}
-static mhif_init(artworkdb_chunk_t* chunk, int def)
+static mhif_init(itunes_chunk_t* chunk, int def)
{
artworkdb_mhif_t* mhif = NULL;
if (def) {
memset(chunk, 0, sizeof(*chunk));
strncpy(chunk->id, "mhif", 4);
- chunk->size = 96;
+ chunk->size = 124;
chunk->overall_size = 0; /* to be filled */
}
@@ -361,7 +383,7 @@
return mhif ? 0 : IPODE_OUTOFMEMORY;
}
-static int mhif_serialize(artworkdb_chunk_t* chunk, serializer_t* sio)
+static int mhif_serialize(itunes_chunk_t* chunk, serializer_t* sio)
{
int ret = 0;
artworkdb_mhif_t* mhif = (artworkdb_mhif_t*)chunk->data;
@@ -373,3 +395,140 @@
return 0;
}
+static void mhod_container_finish(itunes_chunk_t* chunk)
+{
+ artworkdb_mhod_t* mhod = (artworkdb_mhod_t*)chunk->data;
+ memset(mhod, 0, sizeof(*mhod));
+}
+
+static int mhod_container_serialize(itunes_chunk_t* chunk, const char *name, serializer_t* sio)
+{
+ return 0;
+}
+
+static void mhod_string_finish(itunes_chunk_t* chunk)
+{
+ artworkdb_mhod_t* mhod = (artworkdb_mhod_t*)chunk->data;
+ artworkdb_mhod_string_t* string = &mhod->data.str;
+ ucs2free(string->ucs2);
+ ucs2free(string->utf8);
+ memset(string, 0, sizeof(*string));
+}
+
+static int mhod_string_serialize(itunes_chunk_t* chunk, const char *name, serializer_t* sio)
+{
+ int ret = 0;
+ artworkdb_mhod_string_t* string = &((artworkdb_mhod_t*)chunk->data)->data.str;
+
+ if (ret = serialize_uint32le(sio, "size", "%u", &string->size)) return ret;
+ if (ret = serialize_uint32le(sio, "encoding", "%u", &string->encoding)) return ret;
+ if (ret = serialize_uint32le(sio, "unknown", "%u", &string->unknown)) return ret;
+ if (string->encoding == 2) {
+ if (ret = serialize_ucs2lestr_fixed(sio, name, "%s", &string->ucs2, string->size / sizeof(ucs2char_t))) return ret;
+ } else {
+ if (ret = serialize_utf8str_fixed(sio, name, "%s", &string->utf8, string->size)) return ret;
+ }
+
+ return 0;
+}
+
+static const artworkdb_mhoddecl_t mds[] = {
+ {1, "album", 0, mhod_string_finish, mhod_string_serialize},
+ {2, "thumbnail", 1, mhod_container_finish, mhod_container_serialize},
+ {3, "filename", 0, mhod_string_finish, mhod_string_serialize},
+ {5, "fullsize", 1, mhod_container_finish, mhod_container_serialize},
+ {0, NULL, 0, NULL},
+};
+
+static const artworkdb_mhoddecl_t* find_mhoddecl(itunes_chunk_t* chunk)
+{
+ const artworkdb_mhoddecl_t* decl = mds;
+ artworkdb_mhod_t* mhod = (artworkdb_mhod_t*)chunk->data;
+
+ while (decl->name) {
+ if (decl->type == mhod->type) {
+ return decl;
+ }
+ ++decl;
+ }
+ return NULL;
+}
+
+static const artworkdb_mhoddecl_t* find_mhoddecl_by_name(const char *name)
+{
+ const artworkdb_mhoddecl_t* decl = mds;
+
+ while (decl->name) {
+ if (strcmp(decl->name, name) == 0) {
+ return decl;
+ }
+ ++decl;
+ }
+ return NULL;
+}
+
+static int mhod_init(itunes_chunk_t* chunk, int def)
+{
+ if (def) {
+ memset(chunk, 0, sizeof(*chunk));
+ strncpy(chunk->id, "mhod", 4);
+ chunk->size = 24;
+ chunk->overall_size = chunk->size;
+ }
+ chunk->data = calloc(1, sizeof(artworkdb_mhod_t));
+ return chunk->data ? 0 : IPODE_OUTOFMEMORY;
+}
+
+static void mhod_finish(itunes_chunk_t* chunk)
+{
+ artworkdb_mhod_t* mhod = (artworkdb_mhod_t*)chunk->data;
+ const artworkdb_mhoddecl_t* decl = NULL;
+ decl = find_mhoddecl(chunk);
+ if (decl) {
+ decl->finish(chunk);
+ }
+ chunk_finish(chunk);
+}
+
+static int mhod_serialize(itunes_chunk_t* chunk, serializer_t* sio)
+{
+ int ret = 0;
+ artworkdb_mhod_t* mhod = (artworkdb_mhod_t*)chunk->data;
+ const artworkdb_mhoddecl_t* decl = NULL;
+
+ if (ret = serialize_uint16le(sio, "type", "%u", &mhod->type)) return ret;
+ if (ret = serialize_uint8(sio, "unknown1", "%u", &mhod->unknown1)) return ret;
+ if (ret = serialize_uint8(sio, "padding_length", "%u", &mhod->padding_length)) return ret;
+ if (ret = serialize_uint32le(sio, "unknown2", "%u", &mhod->unknown2)) return ret;
+ if (ret = serialize_uint32le(sio, "unknown3", "%u", &mhod->unknown2)) return ret;
+
+ decl = find_mhoddecl(chunk);
+ if (decl) {
+ if (ret = decl->serialize(chunk, decl->name, sio)) return ret;
+ if (!decl->is_container) chunk->size = chunk->overall_size;
+ } else {
+ if (serialize_dumping(sio)) {
+ serialize_indent(sio);
+ fprintf(sio->fp, "!unknown_mhod_type!\n");
+ }
+ chunk->size = chunk->overall_size;
+ }
+
+ return 0;
+}
+
+const itunes_chunkdecl_t artworkdb_cds[] = {
+ {"mhfd", 0, mhfd_init, chunk_finish, mhfd_serialize},
+ {"mhsd", 0, mhsd_init, chunk_finish, mhsd_serialize},
+ {"mhli", 1, mhli_init, chunk_finish, mhli_serialize},
+ {"mhii", 0, mhii_init, chunk_finish, mhii_serialize},
+ {"mhni", 0, mhni_init, chunk_finish, mhni_serialize},
+ {"mhba", 0, mhba_init, chunk_finish, mhba_serialize},
+ {"mhla", 1, mhla_init, chunk_finish, mhla_serialize},
+ {"mhia", 0, mhia_init, chunk_finish, mhia_serialize},
+ {"mhlf", 1, mhlf_init, chunk_finish, mhlf_serialize},
+ {"mhif", 0, mhif_init, chunk_finish, mhif_serialize},
+ {"mhod", 0, mhod_init, mhod_finish, mhod_serialize},
+ {NULL, 0, NULL, NULL, NULL},
+};
+
Modified: trunk/pmplib/lib/pmp_ipod/artworkdb.h
===================================================================
--- trunk/pmplib/lib/pmp_ipod/artworkdb.h 2007-10-05 14:47:54 UTC (rev 420)
+++ trunk/pmplib/lib/pmp_ipod/artworkdb.h 2007-10-05 17:13:21 UTC (rev 421)
@@ -19,7 +19,7 @@
*
*/
-/* $Id:$ */
+/* $Id$ */
#ifndef __ARTWORKDB_H__
#define __ARTWORKDB_H__
@@ -35,8 +35,7 @@
uint32_t unknown7; /* always set to 2. */
uint32_t unknown8; /* always set to 0. */
uint32_t unknown9; /* always set to 0. */
- uint32_t unknown10;
- uint32_t unknown11;
+ uint64_t unknown10;
} artworkdb_mhfd_t;
typedef struct {
@@ -57,6 +56,9 @@
uint32_t ts_file;
uint32_t ts_import;
uint32_t original_size;
+ uint32_t unknown10;
+ uint32_t unknown11;
+ uint32_t unknown12;
} artworkdb_mhii_t;
typedef struct {
@@ -104,80 +106,38 @@
} artworkdb_mhif_t;
typedef struct {
- uint32_t length;
+ uint32_t size;
uint32_t encoding;
uint32_t unknown;
- ucs2char_t* value;
-} artworkdb_mhod_ucs2string_t;
+ ucs2char_t* ucs2;
+ char* utf8;
+} artworkdb_mhod_string_t;
typedef struct {
- uint32_t length;
- uint32_t encoding;
- uint32_t unknown;
- char* value;
-} artworkdb_mhod_utf8string_t;
-
-typedef struct {
uint16_t type;
- uint16_t unk1;
+ uint8_t unknown1;
+ uint8_t padding_length;
+ uint32_t unknown2;
+ uint32_t unknown3;
union {
- artworkdb_mhod_ucs2string_t ucs2str;
- artworkdb_mhod_utf8string_t ucs8str;
+ artworkdb_mhod_string_t str;
} data;
} artworkdb_mhod_t;
-struct tag_artworkdb_chunk {
- int8_t id[4];
- uint32_t size;
- uint32_t overall_size;
-
- void* data;
-
- uint32_t num_children; /* This field does not exist in the actual database. */
- struct tag_artworkdb_chunk* childlen;
-
- int32_t padding_size;
- uint8_t* padding;
-
- uint32_t offset; /* This field does not exist in the actual database. */
-};
-
-typedef struct tag_artworkdb_chunk artworkdb_chunk_t;
-
typedef struct {
uint32_t type;
const char* name;
- uint32_t overall_size;
- void (*finish)(artworkdb_chunk_t* chunk);
- int (*serialize)(artworkdb_chunk_t* chunk, const char *name, serializer_t* sio);
-} albumartdb_mhoddecl_t;
+ int is_container;
+ void (*finish)(itunes_chunk_t* chunk);
+ int (*serialize)(itunes_chunk_t* chunk, const char *name, serializer_t* sio);
+} artworkdb_mhoddecl_t;
-typedef struct {
- const char* name;
- int (*init)(artworkdb_chunk_t* chunk, int dataonly);
- void (*finish)(artworkdb_chunk_t* chunk);
- int (*serialize)(artworkdb_chunk_t* chunk, serializer_t* sio);
-} albumartdb_chunkdecl_t;
+int albumartdb_set_mhod_ucs2string(itunes_chunk_t* chunk, const ucs2char_t* str);
+int albumartdb_get_mhod_ucs2string(itunes_chunk_t* chunk, ucs2char_t** str);
+int albumartdb_set_mhod_utf8string(itunes_chunk_t* chunk, const char* str);
+int albumartdb_get_mhod_utf8string(itunes_chunk_t* chunk, char** str);
-int albumartdb_init(artworkdb_chunk_t* chunk, const char *identifer, const char *subtype);
+extern const itunes_chunkdecl_t artworkdb_cds[];
-int albumartdb_ischunk(artworkdb_chunk_t* chunk, const char *name, const char *subtype);
-
-artworkdb_chunk_t* albumartdb_new_child(artworkdb_chunk_t* chunk);
-
-void albumartdb_finish(artworkdb_chunk_t* chunk);
-
-int albumartdb_set_mhod_ucs2string(artworkdb_chunk_t* chunk, const ucs2char_t* str);
-
-int albumartdb_get_mhod_ucs2string(artworkdb_chunk_t* chunk, ucs2char_t** str);
-
-int albumartdb_set_mhod_utf8string(artworkdb_chunk_t* chunk, const char* str);
-
-int albumartdb_get_mhod_utf8string(artworkdb_chunk_t* chunk, char** str);
-
-int albumartdb_repr(artworkdb_chunk_t* chunk, size_t index, serializer_t* sio);
-int albumartdb_read(artworkdb_chunk_t* chunk, serializer_t* sio);
-int albumartdb_write(artworkdb_chunk_t* chunk, serializer_t* sio);
-
#endif/*__ARTWORKDB_H__*/
Modified: trunk/pmplib/lib/pmp_ipod/chunk.c
===================================================================
--- trunk/pmplib/lib/pmp_ipod/chunk.c 2007-10-05 14:47:54 UTC (rev 420)
+++ trunk/pmplib/lib/pmp_ipod/chunk.c 2007-10-05 17:13:21 UTC (rev 421)
@@ -222,13 +222,13 @@
}
/* Determine the size of padded data for this chunk. */
- if (strncmp(chunk->id, "mhod", 4) == 0) {
- next = begin + chunk->overall_size;
- chunk->padding_size = next - serialize_tell(sio);
- } else {
+ //if (strncmp(chunk->id, "mhod", 4) == 0) {
+ // next = begin + chunk->overall_size;
+ // chunk->padding_size = next - serialize_tell(sio);
+ //} else {
next = begin + chunk->size;
chunk->padding_size = next - serialize_tell(sio);
- }
+ //}
/* Read the padded data. */
if (0 < chunk->padding_size) {
@@ -251,8 +251,8 @@
}
/* Read children for this chunk. */
- if (strncmp(chunk->id, "mhla", 4) == 0 || strncmp(chunk->id, "mhlt", 4) == 0 || strncmp(chunk->id, "mhlp", 4) == 0) {
- /* chunk->overall_size represents the number of children for "mhlt" and "mhlp" chunks */
+ if (decl && decl->overall_size_is_num_children) {
+ /* chunk->overall_size represents the number of children. */
chunk->num_children = chunk->overall_size;
chunk->childlen = (itunes_chunk_t*)calloc(chunk->num_children, sizeof(itunes_chunk_t));
for (i = 0;i < chunk->num_children;++i) {
@@ -309,8 +309,8 @@
}
/* Calculate chunk->overall_size. */
- if (strncmp(chunk->id, "mhla", 4) == 0 || strncmp(chunk->id, "mhlt", 4) == 0 || strncmp(chunk->id, "mhlp", 4) == 0) {
- /* chunk->overall_size represents the number of children for "mhlt" and "mhlp" chunks */
+ if (decl && decl->overall_size_is_num_children) {
+ /* chunk->overall_size represents the number of children. */
chunk->overall_size = chunk->num_children;
} else {
/* chunk->overall_size represents the size in bytes of this chunk */
Modified: trunk/pmplib/lib/pmp_ipod/chunk.h
===================================================================
--- trunk/pmplib/lib/pmp_ipod/chunk.h 2007-10-05 14:47:54 UTC (rev 420)
+++ trunk/pmplib/lib/pmp_ipod/chunk.h 2007-10-05 17:13:21 UTC (rev 421)
@@ -19,7 +19,7 @@
*
*/
-/* $Id:$ */
+/* $Id$ */
#ifndef __CHUNK_H__
#define __CHUNK_H__
@@ -41,6 +41,7 @@
typedef struct {
const char* name;
+ int overall_size_is_num_children;
int (*init)(itunes_chunk_t* chunk, int dataonly);
void (*finish)(itunes_chunk_t* chunk);
int (*serialize)(itunes_chunk_t* chunk, serializer_t* sio);
Modified: trunk/pmplib/lib/pmp_ipod/ipod.c
===================================================================
--- trunk/pmplib/lib/pmp_ipod/ipod.c 2007-10-05 14:47:54 UTC (rev 420)
+++ trunk/pmplib/lib/pmp_ipod/ipod.c 2007-10-05 17:13:21 UTC (rev 421)
@@ -43,6 +43,7 @@
#include "ipodserial.h"
#include "chunk.h"
#include "itunesdb.h"
+#include "artworkdb.h"
#include "playcounts.h"
#define COMP(a, b) ((a)>(b))-((a)<(b))
@@ -52,6 +53,7 @@
"apple_ipod", "Apple", "iPod", "UM",
"---", "---",
"iPod_Control\\iTunes\\iTunesDB",
+ "iPod_Control\\Artwork\\ArtworkDB",
"iPod_Control\\iTunes\\Play Counts",
".mp3\0.m4a\0",
{PMPCODEC_MPEGLAYER3, PMPCODEC_MPEG4AUDIO, 0, 0, 0, 0, 0, 0},
@@ -63,6 +65,7 @@
NULL,
NULL,
NULL,
+ NULL,
{0, 0, 0, 0, 0, 0, 0, 0},
NULL, NULL, NULL,
},
@@ -167,6 +170,10 @@
if (!ipod->itunesdb) {
return IPODE_OUTOFMEMORY;
}
+ ipod->artworkdb = (itunes_chunk_t*)calloc(1, sizeof(itunes_chunk_t));
+ if (!ipod->artworkdb) {
+ return IPODE_OUTOFMEMORY;
+ }
ipod->pcs = (playcounts_t*)calloc(1, sizeof(playcounts_t));
if (!ipod->pcs) {
return IPODE_OUTOFMEMORY;
@@ -178,11 +185,12 @@
{
playcounts_finish(ipod->pcs);
itunesdb_finish(itunesdb_cds, ipod->itunesdb);
+ itunesdb_finish(artworkdb_cds, ipod->artworkdb);
free(ipod->pcs);
free(ipod->itunesdb);
}
-int ipod_read(ipod_t* ipod, const ucs2char_t* itunesdb, const ucs2char_t* playcounts)
+int ipod_read(ipod_t* ipod, const ucs2char_t* itunesdb, const ucs2char_t* artworkdb, const ucs2char_t* playcounts)
{
int ret = 0;
FILE *fp = NULL;
@@ -211,6 +219,30 @@
return (IPODC_ITUNESDB|IPODE_FILEOPENFORREAD);
}
+ /* Read ArtworkDB. */
+ fp = ucs2fopen(artworkdb, "rb");
+ if (fp) {
+ serializer_t sio;
+ uint8_t* buffer = NULL;
+ long size = 0;
+
+ ret = fread_all(fp, &buffer, &size);
+ if (IPODFAILED(ret)) {
+ return (IPODC_ITUNESDB|ret);
+ }
+ fclose(fp);
+
+ serialize_init_read(&sio, buffer, (size_t)size);
+ ret = itunesdb_read(artworkdb_cds, ipod->artworkdb, &sio);
+ if (IPODFAILED(ret)) {
+ return (IPODC_ITUNESDB|ret);
+ }
+ serialize_finish(&sio);
+ free(buffer);
+ } else {
+ return (IPODC_ITUNESDB|IPODE_FILEOPENFORREAD);
+ }
+
/* Read "Play Counts". Don't care if this file does not exist. */
fp = ucs2fopen(playcounts, "rb");
if (fp) {
@@ -237,7 +269,7 @@
return 0;
}
-int ipod_write(ipod_t* ipod, const ucs2char_t* itunesdb, const ucs2char_t* playcounts)
+int ipod_write(ipod_t* ipod, const ucs2char_t* itunesdb, const ucs2char_t* artworkdb, const ucs2char_t* playcounts)
{
int ret = 0;
FILE *fp = NULL;
@@ -264,6 +296,24 @@
serialize_finish(&sio);
+ serialize_init_write(&sio, 0x10000);
+ ret = itunesdb_write(artworkdb_cds, ipod->artworkdb, &sio);
+ if (IPODFAILED(ret)) {
+ return (IPODC_ITUNESDB|ret);
+ }
+
+ fp = ucs2fopen(artworkdb, "wb");
+ if (fp) {
+ if (fwrite(sio.base, 1, sio.offset, fp) != sio.offset) {
+ return (IPODC_ITUNESDB|IPODE_FILEWRITEERROR);
+ }
+ fclose(fp);
+ } else {
+ ret = (IPODC_ITUNESDB|IPODE_FILEOPENFORWRITE);
+ }
+
+ serialize_finish(&sio);
+
/* Remove "Play Counts" file, which is always created by the player. */
filepath_removefile(playcounts);
@@ -279,6 +329,10 @@
itunesdb_repr(itunesdb_cds, ipod->itunesdb, 0, &sio);
fprintf(fpo, "\n");
+ fprintf(fpo, "[ArtworkDB]\n");
+ itunesdb_repr(artworkdb_cds, ipod->artworkdb, 0, &sio);
+ fprintf(fpo, "\n");
+
fprintf(fpo, "[Play Counts]\n");
playcounts_serialize(ipod->pcs, &sio);
fprintf(fpo, "\n");
Modified: trunk/pmplib/lib/pmp_ipod/ipod.h
===================================================================
--- trunk/pmplib/lib/pmp_ipod/ipod.h 2007-10-05 14:47:54 UTC (rev 420)
+++ trunk/pmplib/lib/pmp_ipod/ipod.h 2007-10-05 17:13:21 UTC (rev 421)
@@ -34,6 +34,7 @@
const char *min_version;
const char *max_version;
const char *itunesdb_filename;
+ const char *artworkdb_filename;
const char *playcounts_filename;
const char *extensions;
uint32_t codecs[8];
@@ -50,6 +51,7 @@
typedef struct {
itunes_chunk_t* itunesdb;
+ itunes_chunk_t* artworkdb;
playcounts_t* pcs;
uint8_t serial[8];
} ipod_t;
@@ -59,8 +61,8 @@
int ipod_init(ipod_t* ipod);
void ipod_finish(ipod_t* ipod);
-int ipod_read(ipod_t* ipod, const ucs2char_t* itunesdb, const ucs2char_t* playcounts);
-int ipod_write(ipod_t* ipod, const ucs2char_t* itunesdb, const ucs2char_t* playcounts);
+int ipod_read(ipod_t* ipod, const ucs2char_t* itunesdb, const ucs2char_t* artworkdb, const ucs2char_t* playcounts);
+int ipod_write(ipod_t* ipod, const ucs2char_t* itunesdb, const ucs2char_t* artworkdb, const ucs2char_t* playcounts);
int ipod_dump(ipod_t* ipod, FILE *fpo);
int ipod_set(
ipod_t* ipod,
Modified: trunk/pmplib/lib/pmp_ipod/itunesdb.c
===================================================================
--- trunk/pmplib/lib/pmp_ipod/itunesdb.c 2007-10-05 14:47:54 UTC (rev 420)
+++ trunk/pmplib/lib/pmp_ipod/itunesdb.c 2007-10-05 17:13:21 UTC (rev 421)
@@ -772,21 +772,24 @@
}
}
+ /* The size field in "MHOD" chunk is always 24. */
+ chunk->size = chunk->overall_size;
+
return 0;
}
const itunes_chunkdecl_t itunesdb_cds[] = {
- {"mhbd", mhbd_init, chunk_finish, mhbd_serialize},
- {"mhsd", mhsd_init, chunk_finish, mhsd_serialize},
- {"mhla", mhla_init, chunk_finish, mhla_serialize},
- {"mhia", mhia_init, chunk_finish, mhia_serialize},
- {"mhlt", mhlt_init, chunk_finish, mhlt_serialize},
- {"mhit", mhit_init, chunk_finish, mhit_serialize},
- {"mhlp", mhlp_init, chunk_finish, mhlp_serialize},
- {"mhyp", mhyp_init, chunk_finish, mhyp_serialize},
- {"mhip", mhip_init, chunk_finish, mhip_serialize},
- {"mhod", mhod_init, mhod_finish, mhod_serialize},
- {NULL, NULL, NULL, NULL},
+ {"mhbd", 0, mhbd_init, chunk_finish, mhbd_serialize},
+ {"mhsd", 0, mhsd_init, chunk_finish, mhsd_serialize},
+ {"mhla", 1, mhla_init, chunk_finish, mhla_serialize},
+ {"mhia", 0, mhia_init, chunk_finish, mhia_serialize},
+ {"mhlt", 1, mhlt_init, chunk_finish, mhlt_serialize},
+ {"mhit", 0, mhit_init, chunk_finish, mhit_serialize},
+ {"mhlp", 1, mhlp_init, chunk_finish, mhlp_serialize},
+ {"mhyp", 0, mhyp_init, chunk_finish, mhyp_serialize},
+ {"mhip", 0, mhip_init, chunk_finish, mhip_serialize},
+ {"mhod", 0, mhod_init, mhod_finish, mhod_serialize},
+ {NULL, 0, NULL, NULL, NULL},
};
int itunesdb_mhod_init(
Modified: trunk/pmplib/lib/pmp_ipod/pmp_ipod.c
===================================================================
--- trunk/pmplib/lib/pmp_ipod/pmp_ipod.c 2007-10-05 14:47:54 UTC (rev 420)
+++ trunk/pmplib/lib/pmp_ipod/pmp_ipod.c 2007-10-05 17:13:21 UTC (rev 421)
@@ -145,7 +145,7 @@
memset(info, 0, sizeof(*info));
}
-static void set_filenames(ucs2char_t *itunesdb, ucs2char_t* playcounts, pmp_t *pmp)
+static void set_filenames(ucs2char_t *itunesdb, ucs2char_t *artworkdb, ucs2char_t* playcounts, pmp_t *pmp)
{
ucs2char_t* ucs2 = NULL;
pmp_internal_t* pmpi = (pmp_internal_t*)pmp->instance;
@@ -157,6 +157,13 @@
ucs2cat(itunesdb, ucs2);
ucs2free(ucs2);
}
+ if (artworkdb) {
+ ucs2cpy(artworkdb, pmp->info.path_to_root);
+ filepath_addslash(artworkdb);
+ ucs2 = mbsdupucs2(pmpi->decl->artworkdb_filename);
+ ucs2cat(artworkdb, ucs2);
+ ucs2free(ucs2);
+ }
if (playcounts) {
ucs2cpy(playcounts, pmp->info.path_to_root);
filepath_addslash(playcounts);
@@ -331,18 +338,18 @@
result_t ret = 0;
pmp_t* pmp = music->pmp;
pmp_music_internal_t* pmpmi = (pmp_music_internal_t*)music->instance;
- ucs2char_t itunesdb[MAX_PATH], playcounts[MAX_PATH];
+ ucs2char_t itunesdb[MAX_PATH], artworkdb[MAX_PATH], playcounts[MAX_PATH];
// Initialize ipod library.
ipod_init(&ipod);
// Read the music database.
- set_filenames(itunesdb, playcounts, music->pmp);
+ set_filenames(itunesdb, artworkdb, playcounts, music->pmp);
if (pmp->flag & (PMPOF_MUSIC_DB_READ|PMPOF_MUSIC_PL_READ)) {
int num_records = 0, num_playlists = 0;
- ipod_read(&ipod, itunesdb, playcounts);
+ ipod_read(&ipod, itunesdb, artworkdb, playcounts);
ipod_get(&ipod, NULL, &num_records, NULL, &num_playlists, pmp->info.path_to_root);
// Allocate records.
@@ -393,17 +400,17 @@
result_t ret = 0;
pmp_t* pmp = music->pmp;
pmp_music_internal_t* pmpmi = (pmp_music_internal_t*)music->instance;
- ucs2char_t itunesdb[MAX_PATH], playcounts[MAX_PATH];
+ ucs2char_t itunesdb[MAX_PATH], artworkdb[MAX_PATH], playcounts[MAX_PATH];
// Initialize ipod library.
ipod_init(&ipod);
// Read the music database.
- set_filenames(itunesdb, playcounts, music->pmp);
+ set_filenames(itunesdb, artworkdb, playcounts, music->pmp);
if (pmp->flag & PMPOF_MUSIC_DB_WRITE) {
ipod_set(&ipod, pmpmi->records, pmpmi->num_records, pmpmi->playlists, pmpmi->num_playlists, pmp->info.path_to_root);
- ipod_write(&ipod, itunesdb, playcounts);
+ ipod_write(&ipod, itunesdb, artworkdb, playcounts);
}
exit_this:
@@ -447,14 +454,14 @@
{
ipod_t ipod;
result_t ret = 0;
- ucs2char_t itunesdb[MAX_PATH], playcounts[MAX_PATH];
+ ucs2char_t itunesdb[MAX_PATH], artworkdb[MAX_PATH], playcounts[MAX_PATH];
// Initialize IP3DB.
ipod_init(&ipod);
// Read the music database.
- set_filenames(itunesdb, playcounts, music->pmp);
- ret = ipod_read(&ipod, itunesdb, playcounts);
+ set_filenames(itunesdb, artworkdb, playcounts, music->pmp);
+ ret = ipod_read(&ipod, itunesdb, artworkdb, playcounts);
if (ret) {
goto exit_this;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ny...@us...> - 2007-10-05 14:47:50
|
Revision: 420
http://pmplib.svn.sourceforge.net/pmplib/?rev=420&view=rev
Author: nyaochi
Date: 2007-10-05 07:47:54 -0700 (Fri, 05 Oct 2007)
Log Message:
-----------
Initial commit of ArtworkDB routines.
Added Paths:
-----------
trunk/pmplib/lib/pmp_ipod/artworkdb.c
trunk/pmplib/lib/pmp_ipod/artworkdb.h
Added: trunk/pmplib/lib/pmp_ipod/artworkdb.c
===================================================================
--- trunk/pmplib/lib/pmp_ipod/artworkdb.c (rev 0)
+++ trunk/pmplib/lib/pmp_ipod/artworkdb.c 2007-10-05 14:47:54 UTC (rev 420)
@@ -0,0 +1,375 @@
+/*
+ * ArtworkDB reader/writer/dumper.
+ *
+ * Copyright (c) 2005-2007 Naoaki Okazaki
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+/* $Id:$ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif/*HAVE_CONFIG_H*/
+
+#include <os.h>
+#include <stdio.h>
+#include <stdlib.h>
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif/*HAVE_STRING_H*/
+#include <pmplib/ucs2char.h>
+
+#include "status.h"
+#include "ipod.h"
+#include "serialize.h"
+#include "util.h"
+#include "artworkdb.h"
+
+static void chunk_finish(artworkdb_chunk_t* chunk)
+{
+ free(chunk->data);
+ free(chunk->padding);
+ memset(chunk, 0, sizeof(*chunk));
+}
+
+static int mhfd_init(artworkdb_chunk_t* chunk, int def)
+{
+ artworkdb_mhfd_t* mhfd = NULL;
+
+ if (def) {
+ memset(chunk, 0, sizeof(*chunk));
+ strncpy(chunk->id, "mhfd", 4);
+ chunk->size = 132;
+ chunk->overall_size = 0; /* to be filled */
+ }
+
+ mhfd = (artworkdb_mhfd_t*)calloc(1, sizeof(artworkdb_mhfd_t));
+ if (def && mhfd) {
+ mhfd->unknown1 = 0;
+ mhfd->version = 2; /* iTunes 4.9 or above */
+ mhfd->num_children = 0; /* to be filled */
+ mhfd->unknown3 = 0;
+ mhfd->next_nhii = 0;
+ mhfd->unknown5 = 0;
+ mhfd->unknown6 = 0;
+ mhfd->unknown7 = 2;
+ mhfd->unknown8 = 0;
+ mhfd->unknown9 = 0;
+ mhfd->unknown10 = 0;
+ mhfd->unknown11 = 0;
+ }
+ chunk->data = mhfd;
+ return mhfd ? 0 : IPODE_OUTOFMEMORY;
+}
+
+static int mhfd_serialize(artworkdb_chunk_t* chunk, serializer_t* sio)
+{
+ int ret = 0;
+ artworkdb_mhfd_t* mhfd = (artworkdb_mhfd_t*)chunk->data;
+
+ if (ret = serialize_uint32le(sio, "unknown1", "%d", &mhfd->unknown1)) return ret;
+ if (ret = serialize_uint32le(sio, "version", "%d", &mhfd->version)) return ret;
+ if (ret = serialize_uint32le(sio, "num_children", "%d", &mhfd->num_children)) return ret;
+ if (ret = serialize_uint32le(sio, "unknown3", "%d", &mhfd->unknown3)) return ret;
+ if (ret = serialize_uint32le(sio, "next_nhii", "%d", &mhfd->next_nhii)) return ret;
+ if (ret = serialize_uint64le(sio, "unknown5", "%016llX", &mhfd->unknown5)) return ret;
+ if (ret = serialize_uint64le(sio, "unknown6", "%016llX", &mhfd->unknown6)) return ret;
+ if (ret = serialize_uint32le(sio, "unknown7", "%d", &mhfd->unknown7)) return ret;
+ if (ret = serialize_uint32le(sio, "unknown8", "%d", &mhfd->unknown8)) return ret;
+ if (ret = serialize_uint32le(sio, "unknown9", "%d", &mhfd->unknown9)) return ret;
+ if (ret = serialize_uint32le(sio, "unknown10", "%d", &mhfd->unknown10)) return ret;
+ if (ret = serialize_uint32le(sio, "unknown11", "%d", &mhfd->unknown10)) return ret;
+
+ return 0;
+}
+
+
+
+static mhsd_init(artworkdb_chunk_t* chunk, int def)
+{
+ artworkdb_mhsd_t* mhsd = NULL;
+
+ if (def) {
+ memset(chunk, 0, sizeof(*chunk));
+ strncpy(chunk->id, "mhsd", 4);
+ chunk->size = 96;
+ chunk->overall_size = 0; /* to be filled */
+ }
+
+ mhsd = (artworkdb_mhsd_t*)calloc(1, sizeof(artworkdb_mhsd_t));
+ if (mhsd && def) {
+ mhsd->type = 0; /* to be filled */
+ }
+
+ chunk->data = mhsd;
+ return mhsd ? 0 : IPODE_OUTOFMEMORY;
+}
+
+static int mhsd_serialize(artworkdb_chunk_t* chunk, serializer_t* sio)
+{
+ int ret = 0;
+ artworkdb_mhsd_t* mhsd = (artworkdb_mhsd_t*)chunk->data;
+
+ if (ret = serialize_uint32le(sio, "type", "%d", &mhsd->type)) return ret;
+
+ return 0;
+}
+
+
+
+static mhli_init(artworkdb_chunk_t* chunk, int def)
+{
+ if (def) {
+ memset(chunk, 0, sizeof(*chunk));
+ strncpy(chunk->id, "mhli", 4);
+ chunk->size = 96;
+ chunk->overall_size = 0; /* to be filled */
+ }
+
+ chunk->data = 0;
+ return 0;
+}
+
+static int mhli_serialize(artworkdb_chunk_t* chunk, serializer_t* sio)
+{
+ return 0;
+}
+
+
+
+static int mhii_init(artworkdb_chunk_t* chunk, int def)
+{
+ artworkdb_mhii_t* mhii = NULL;
+
+ if (def) {
+ memset(chunk, 0, sizeof(*chunk));
+ strncpy(chunk->id, "mhii", 4);
+ chunk->size = 104;
+ chunk->overall_size = 0; /* to be filled */
+ }
+
+ mhii = (artworkdb_mhii_t*)calloc(1, sizeof(artworkdb_mhii_t));
+ if (def && mhii) {
+ mhii->num_children = 0;
+ mhii->id = 0;
+ mhii->song_id = 0;
+ mhii->unknown4 = 0;
+ mhii->rating = 0;
+ mhii->unknown6 = 0;
+ mhii->ts_file = 0;
+ mhii->ts_import = 0;
+ mhii->original_size = 0;
+ }
+ chunk->data = mhii;
+ return mhii ? 0 : IPODE_OUTOFMEMORY;
+}
+
+static int mhii_serialize(artworkdb_chunk_t* chunk, serializer_t* sio)
+{
+ int ret = 0;
+ artworkdb_mhii_t* mhii = (artworkdb_mhii_t*)chunk->data;
+
+ if (ret = serialize_uint32le(sio, "num_children", "%d", &mhii->num_children)) return ret;
+ if (ret = serialize_uint32le(sio, "id", "%d", &mhii->id)) return ret;
+ if (ret = serialize_uint64le(sio, "song_id", "%016llX", &mhii->song_id)) return ret;
+ if (ret = serialize_uint32le(sio, "unknown4", "%d", &mhii->unknown4)) return ret;
+ if (ret = serialize_uint32le(sio, "rating", "%d", &mhii->rating)) return ret;
+ if (ret = serialize_uint32le(sio, "unknown6", "%d", &mhii->unknown6)) return ret;
+ if (ret = serialize_uint32le(sio, "ts_file", "%d", &mhii->ts_file)) return ret;
+ if (ret = serialize_uint32le(sio, "ts_import", "%d", &mhii->ts_import)) return ret;
+ if (ret = serialize_uint32le(sio, "original_size", "%d", &mhii->original_size)) return ret;
+
+ return 0;
+}
+
+
+static int mhni_init(artworkdb_chunk_t* chunk, int def)
+{
+ artworkdb_mhni_t* mhni = NULL;
+
+ if (def) {
+ memset(chunk, 0, sizeof(*chunk));
+ strncpy(chunk->id, "mhni", 4);
+ chunk->size = 104;
+ chunk->overall_size = 0; /* to be filled */
+ }
+
+ mhni = (artworkdb_mhni_t*)calloc(1, sizeof(artworkdb_mhni_t));
+ if (def && mhni) {
+ mhni->num_children = 0;
+ mhni->correlation_id = 0;
+ mhni->ithmb_offset = 0;
+ mhni->ithmb_size = 0;
+ mhni->vertical_padding = 0;
+ mhni->horizontal_padding = 0;
+ mhni->height = 0;
+ mhni->width = 0;
+ }
+ chunk->data = mhni;
+ return mhni ? 0 : IPODE_OUTOFMEMORY;
+}
+
+static int mhni_serialize(artworkdb_chunk_t* chunk, serializer_t* sio)
+{
+ int ret = 0;
+ artworkdb_mhni_t* mhni = (artworkdb_mhni_t*)chunk->data;
+
+ if (ret = serialize_uint32le(sio, "num_children", "%d", &mhni->num_children)) return ret;
+ if (ret = serialize_uint32le(sio, "correlation_id", "%d", &mhni->correlation_id)) return ret;
+ if (ret = serialize_uint32le(sio, "ithmb_offset", "%d", &mhni->ithmb_offset)) return ret;
+ if (ret = serialize_uint32le(sio, "ithmb_size", "%d", &mhni->ithmb_size)) return ret;
+ if (ret = serialize_uint16le(sio, "vertical_padding", "%d", &mhni->vertical_padding)) return ret;
+ if (ret = serialize_uint16le(sio, "horizontal_padding", "%d", &mhni->horizontal_padding)) return ret;
+ if (ret = serialize_uint16le(sio, "height", "%d", &mhni->height)) return ret;
+ if (ret = serialize_uint16le(sio, "width", "%d", &mhni->width)) return ret;
+ if (ret = serialize_uint32le(sio, "unknown", "%d", &mhni->unknown)) return ret;
+ if (ret = serialize_uint32le(sio, "image_size", "%d", &mhni->image_size)) return ret;
+
+ return 0;
+}
+
+
+
+static int mhba_init(artworkdb_chunk_t* chunk, int def)
+{
+ artworkdb_mhba_t* mhba = NULL;
+
+ if (def) {
+ memset(chunk, 0, sizeof(*chunk));
+ strncpy(chunk->id, "mhba", 4);
+ chunk->size = 104;
+ chunk->overall_size = 0; /* to be filled */
+ }
+
+ mhba = (artworkdb_mhba_t*)calloc(1, sizeof(artworkdb_mhba_t));
+ if (def && mhba) {
+ }
+ chunk->data = mhba;
+ return mhba ? 0 : IPODE_OUTOFMEMORY;
+}
+
+static int mhba_serialize(artworkdb_chunk_t* chunk, serializer_t* sio)
+{
+ int ret = 0;
+ artworkdb_mhba_t* mhba = (artworkdb_mhba_t*)chunk->data;
+
+ if (ret = serialize_uint32le(sio, "num_mhod", "%d", &mhba->num_mhod)) return ret;
+ if (ret = serialize_uint32le(sio, "num_mhia", "%d", &mhba->num_mhia)) return ret;
+ if (ret = serialize_uint32le(sio, "playlist_id", "%d", &mhba->playlist_id)) return ret;
+ if (ret = serialize_uint32le(sio, "unk2", "%d", &mhba->unk2)) return ret;
+ if (ret = serialize_uint16le(sio, "unk3", "%d", &mhba->unk3)) return ret;
+ if (ret = serialize_uint8(sio, "album_type", "%d", &mhba->album_type)) return ret;
+ if (ret = serialize_uint8(sio, "play_music", "%d", &mhba->play_music)) return ret;
+ if (ret = serialize_uint8(sio, "repeat", "%d", &mhba->repeat)) return ret;
+ if (ret = serialize_uint8(sio, "random", "%d", &mhba->random)) return ret;
+ if (ret = serialize_uint8(sio, "show_titles", "%d", &mhba->show_titles)) return ret;
+ if (ret = serialize_uint8(sio, "transition_direction", "%d", &mhba->transition_direction)) return ret;
+ if (ret = serialize_uint32le(sio, "slide_duration", "%d", &mhba->slide_duration)) return ret;
+ if (ret = serialize_uint32le(sio, "transition_duration", "%d", &mhba->transition_duration)) return ret;
+ if (ret = serialize_uint32le(sio, "unk7", "%d", &mhba->unk7)) return ret;
+ if (ret = serialize_uint32le(sio, "unk8", "%d", &mhba->unk8)) return ret;
+ if (ret = serialize_uint64le(sio, "dbid2", "%016llX", &mhba->dbid2)) return ret;
+ if (ret = serialize_uint32le(sio, "prev_playlist_id", "%d", &mhba->prev_playlist_id)) return ret;
+
+ return 0;
+}
+
+
+
+static mhia_init(artworkdb_chunk_t* chunk, int def)
+{
+ artworkdb_mhia_t* mhia = NULL;
+
+ if (def) {
+ memset(chunk, 0, sizeof(*chunk));
+ strncpy(chunk->id, "mhia", 4);
+ chunk->size = 96;
+ chunk->overall_size = 0; /* to be filled */
+ }
+
+ mhia = (artworkdb_mhia_t*)calloc(1, sizeof(artworkdb_mhia_t));
+ if (mhia && def) {
+ }
+
+ chunk->data = mhia;
+ return mhia ? 0 : IPODE_OUTOFMEMORY;
+}
+
+static int mhia_serialize(artworkdb_chunk_t* chunk, serializer_t* sio)
+{
+ int ret = 0;
+ artworkdb_mhia_t* mhia = (artworkdb_mhia_t*)chunk->data;
+
+ if (ret = serialize_uint32le(sio, "unk1", "%d", &mhia->unk1)) return ret;
+ if (ret = serialize_uint32le(sio, "image_id", "%d", &mhia->image_id)) return ret;
+
+ return 0;
+}
+
+
+
+static mhlf_init(artworkdb_chunk_t* chunk, int def)
+{
+ if (def) {
+ memset(chunk, 0, sizeof(*chunk));
+ strncpy(chunk->id, "mhlf", 4);
+ chunk->size = 96;
+ chunk->overall_size = 0; /* to be filled */
+ }
+
+ chunk->data = 0;
+ return 0;
+}
+
+static int mhlf_serialize(artworkdb_chunk_t* chunk, serializer_t* sio)
+{
+ return 0;
+}
+
+
+
+static mhif_init(artworkdb_chunk_t* chunk, int def)
+{
+ artworkdb_mhif_t* mhif = NULL;
+
+ if (def) {
+ memset(chunk, 0, sizeof(*chunk));
+ strncpy(chunk->id, "mhif", 4);
+ chunk->size = 96;
+ chunk->overall_size = 0; /* to be filled */
+ }
+
+ mhif = (artworkdb_mhif_t*)calloc(1, sizeof(artworkdb_mhif_t));
+ if (mhif && def) {
+ }
+
+ chunk->data = mhif;
+ return mhif ? 0 : IPODE_OUTOFMEMORY;
+}
+
+static int mhif_serialize(artworkdb_chunk_t* chunk, serializer_t* sio)
+{
+ int ret = 0;
+ artworkdb_mhif_t* mhif = (artworkdb_mhif_t*)chunk->data;
+
+ if (ret = serialize_uint32le(sio, "unknown1", "%d", &mhif->unknown1)) return ret;
+ if (ret = serialize_uint32le(sio, "correlation_id", "%d", &mhif->correlation_id)) return ret;
+ if (ret = serialize_uint32le(sio, "image_size", "%d", &mhif->image_size)) return ret;
+
+ return 0;
+}
+
Property changes on: trunk/pmplib/lib/pmp_ipod/artworkdb.c
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: trunk/pmplib/lib/pmp_ipod/artworkdb.h
===================================================================
--- trunk/pmplib/lib/pmp_ipod/artworkdb.h (rev 0)
+++ trunk/pmplib/lib/pmp_ipod/artworkdb.h 2007-10-05 14:47:54 UTC (rev 420)
@@ -0,0 +1,183 @@
+/*
+ * ArtworkDB reader/writer/dumper.
+ *
+ * Copyright (c) 2005-2007 Naoaki Okazaki
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+/* $Id:$ */
+
+#ifndef __ARTWORKDB_H__
+#define __ARTWORKDB_H__
+
+typedef struct {
+ uint32_t unknown1; /* always set to 0. */
+ uint32_t version; /* should be 2. */
+ uint32_t num_children; /* usually 3. */
+ uint32_t unknown3; /* always set to 0. */
+ uint32_t next_nhii;
+ uint64_t unknown5;
+ uint64_t unknown6;
+ uint32_t unknown7; /* always set to 2. */
+ uint32_t unknown8; /* always set to 0. */
+ uint32_t unknown9; /* always set to 0. */
+ uint32_t unknown10;
+ uint32_t unknown11;
+} artworkdb_mhfd_t;
+
+typedef struct {
+ uint32_t type; /* 1 (image list), 2 (album list), or 3 (file list). */
+} artworkdb_mhsd_t;
+
+typedef struct {
+ uint8_t unknown; /* zero padded. */
+} artworkdb_mhli_t;
+
+typedef struct {
+ uint32_t num_children;
+ uint32_t id;
+ uint64_t song_id;
+ uint32_t unknown4;
+ uint32_t rating;
+ uint32_t unknown6;
+ uint32_t ts_file;
+ uint32_t ts_import;
+ uint32_t original_size;
+} artworkdb_mhii_t;
+
+typedef struct {
+ uint32_t num_children;
+ uint32_t correlation_id;
+ uint32_t ithmb_offset;
+ uint32_t ithmb_size;
+ uint16_t vertical_padding;
+ uint16_t horizontal_padding;
+ uint16_t height;
+ uint16_t width;
+ uint32_t unknown;
+ uint32_t image_size;
+} artworkdb_mhni_t;
+
+typedef struct {
+ uint32_t num_mhod;
+ uint32_t num_mhia;
+ uint32_t playlist_id;
+ uint32_t unk2;
+ uint16_t unk3;
+ uint8_t album_type;
+ uint8_t play_music;
+ uint8_t repeat;
+ uint8_t random;
+ uint8_t show_titles;
+ uint8_t transition_direction;
+ uint32_t slide_duration;
+ uint32_t transition_duration;
+ uint32_t unk7;
+ uint32_t unk8;
+ uint64_t dbid2;
+ uint32_t prev_playlist_id;
+} artworkdb_mhba_t;
+
+typedef struct {
+ uint32_t unk1;
+ uint32_t image_id;
+} artworkdb_mhia_t;
+
+typedef struct {
+ uint32_t unknown1;
+ uint32_t correlation_id;
+ uint32_t image_size;
+} artworkdb_mhif_t;
+
+typedef struct {
+ uint32_t length;
+ uint32_t encoding;
+ uint32_t unknown;
+ ucs2char_t* value;
+} artworkdb_mhod_ucs2string_t;
+
+typedef struct {
+ uint32_t length;
+ uint32_t encoding;
+ uint32_t unknown;
+ char* value;
+} artworkdb_mhod_utf8string_t;
+
+typedef struct {
+ uint16_t type;
+ uint16_t unk1;
+ union {
+ artworkdb_mhod_ucs2string_t ucs2str;
+ artworkdb_mhod_utf8string_t ucs8str;
+ } data;
+} artworkdb_mhod_t;
+
+
+struct tag_artworkdb_chunk {
+ int8_t id[4];
+ uint32_t size;
+ uint32_t overall_size;
+
+ void* data;
+
+ uint32_t num_children; /* This field does not exist in the actual database. */
+ struct tag_artworkdb_chunk* childlen;
+
+ int32_t padding_size;
+ uint8_t* padding;
+
+ uint32_t offset; /* This field does not exist in the actual database. */
+};
+
+typedef struct tag_artworkdb_chunk artworkdb_chunk_t;
+
+typedef struct {
+ uint32_t type;
+ const char* name;
+ uint32_t overall_size;
+ void (*finish)(artworkdb_chunk_t* chunk);
+ int (*serialize)(artworkdb_chunk_t* chunk, const char *name, serializer_t* sio);
+} albumartdb_mhoddecl_t;
+
+typedef struct {
+ const char* name;
+ int (*init)(artworkdb_chunk_t* chunk, int dataonly);
+ void (*finish)(artworkdb_chunk_t* chunk);
+ int (*serialize)(artworkdb_chunk_t* chunk, serializer_t* sio);
+} albumartdb_chunkdecl_t;
+
+int albumartdb_init(artworkdb_chunk_t* chunk, const char *identifer, const char *subtype);
+
+int albumartdb_ischunk(artworkdb_chunk_t* chunk, const char *name, const char *subtype);
+
+artworkdb_chunk_t* albumartdb_new_child(artworkdb_chunk_t* chunk);
+
+void albumartdb_finish(artworkdb_chunk_t* chunk);
+
+int albumartdb_set_mhod_ucs2string(artworkdb_chunk_t* chunk, const ucs2char_t* str);
+
+int albumartdb_get_mhod_ucs2string(artworkdb_chunk_t* chunk, ucs2char_t** str);
+
+int albumartdb_set_mhod_utf8string(artworkdb_chunk_t* chunk, const char* str);
+
+int albumartdb_get_mhod_utf8string(artworkdb_chunk_t* chunk, char** str);
+
+int albumartdb_repr(artworkdb_chunk_t* chunk, size_t index, serializer_t* sio);
+int albumartdb_read(artworkdb_chunk_t* chunk, serializer_t* sio);
+int albumartdb_write(artworkdb_chunk_t* chunk, serializer_t* sio);
+
+#endif/*__ARTWORKDB_H__*/
Property changes on: trunk/pmplib/lib/pmp_ipod/artworkdb.h
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ny...@us...> - 2007-09-30 15:57:52
|
Revision: 418
http://pmplib.svn.sourceforge.net/pmplib/?rev=418&view=rev
Author: nyaochi
Date: 2007-09-30 08:57:53 -0700 (Sun, 30 Sep 2007)
Log Message:
-----------
- PMPlib now works with iPod nano 3rd gen. Setting
dbid and/or dbid2 fields in "mhit" chunk made this
magic.
- Sync with the latest fields in "mhit" chunk although
I'm not sure these new fields are necessary to the
latest iPods.
- Generating prefix indices ("mhod" chunk type 53).
Modified Paths:
--------------
trunk/pmplib/lib/pmp_ipod/ipod.c
trunk/pmplib/lib/pmp_ipod/itunesdb.c
trunk/pmplib/lib/pmp_ipod/itunesdb.h
trunk/pmplib/lib/pmp_ipod/pmp_ipod.vcproj
Modified: trunk/pmplib/lib/pmp_ipod/ipod.c
===================================================================
--- trunk/pmplib/lib/pmp_ipod/ipod.c 2007-09-25 16:23:32 UTC (rev 417)
+++ trunk/pmplib/lib/pmp_ipod/ipod.c 2007-09-30 15:57:53 UTC (rev 418)
@@ -294,10 +294,11 @@
)
{
int ret = 0;
+ const ucs2char_t* value = NULL;
itunesdb_chunk_t* mhod = NULL;
itunesdb_mhit_t* mhit_data = (itunesdb_mhit_t*)mhit->data;
- mhit_data->uid = uid;
+ mhit_data->uid = 1008 + uid * 2;
mhit_data->visible = 1;
switch (rec->codec) {
case PMPCODEC_MPEGLAYER3:
@@ -306,12 +307,12 @@
mhit_data->type2 = rec->is_vbr ? 0x01 : 0x00;
break;
default:
- mhit_data->type1 = 0x01;
+ mhit_data->type1 = 0x00;
mhit_data->type2 = 0x01;
break;
}
mhit_data->compilation = rec->is_compilation ? 1 : 0;
- mhit_data->rating = rec->rating * 20;
+ mhit_data->rating = rec->rating + 1;
mhit_data->last_modified = (uint32_t)from_time((time_t)rec->ts_update);
mhit_data->filesize = rec->filesize;
mhit_data->duration = rec->duration;
@@ -323,7 +324,7 @@
mhit_data->disc_number = rec->disc_number;
mhit_data->total_discs = rec->total_discs;
mhit_data->date_added = (uint32_t)from_time((time_t)rec->ts_import);
- mhit_data->dbid = 0;
+ mhit_data->dbid = 0xFA14A98319EB2BBD + uid;
mhit_data->unk9 = 0xFFFF;
switch (rec->codec) {
case PMPCODEC_MPEGLAYER3:
@@ -338,10 +339,16 @@
break;
}
mhit_data->unk14_1 = 12;
- mhit_data->is_played = 2;
+ mhit_data->is_played = 1;
mhit_data->unk27 = 1;
mhit_data->media_type = 1;
mhit_data->num_samples = rec->num_samples;
+ mhit_data->dbid2 = 0xC6EEB59E19650E3C + uid;
+ mhit_data->unk40 = 1011;
+ mhit_data->newunk3 = 0xBCD054CD8C063208;
+ mhit_data->unk43 = 0x0000808080808080;
+ mhit_data->newunk5 = 106;
+ mhit_data->newunk7 = 32;
/* Construct an "mhod" chunk for title. */
if (rec->title && *rec->title) {
@@ -362,11 +369,12 @@
}
/* Construct an "mhod" chunk for album artist. */
- if (rec->album_artist && *rec->album_artist) {
+ value = (rec->album_artist && *rec->album_artist) ? rec->album_artist : rec->artist;
+ if (value && *value) {
mhod = itunesdb_new_child(mhit);
if (mhod) {
if (ret = itunesdb_init(mhod, "mhod", "album_artist")) return ret;
- if (ret = itunesdb_set_mhod_string(mhod, rec->album_artist)) return ret;
+ if (ret = itunesdb_set_mhod_string(mhod, value)) return ret;
}
}
@@ -520,8 +528,8 @@
static int comp_title(const void *_x, const void *_y)
{
- const sorted_index_t *xi = (const sorted_index_t*)_x;
- const sorted_index_t *yi = (const sorted_index_t*)_y;
+ const itunesdb_playlist_entry_t *xi = (const itunesdb_playlist_entry_t*)_x;
+ const itunesdb_playlist_entry_t *yi = (const itunesdb_playlist_entry_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];
@@ -529,11 +537,16 @@
return comp_string(x->title, y->title);
}
+static uint32_t prefix_title(const pmp_music_record_t* record)
+{
+ return ((record->title != NULL) ? record->title[0] : 0);
+}
+
static int comp_album(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 itunesdb_playlist_entry_t *xi = (const itunesdb_playlist_entry_t*)_x;
+ const itunesdb_playlist_entry_t *yi = (const itunesdb_playlist_entry_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];
@@ -551,11 +564,16 @@
return ret;
}
+static uint32_t prefix_album(const pmp_music_record_t* record)
+{
+ return ((record->album != NULL) ? record->album[0] : 0);
+}
+
static int comp_album_for_list(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 itunesdb_playlist_entry_t *xi = (const itunesdb_playlist_entry_t*)_x;
+ const itunesdb_playlist_entry_t *yi = (const itunesdb_playlist_entry_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];
@@ -570,8 +588,8 @@
static int comp_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 itunesdb_playlist_entry_t *xi = (const itunesdb_playlist_entry_t*)_x;
+ const itunesdb_playlist_entry_t *yi = (const itunesdb_playlist_entry_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];
@@ -583,11 +601,16 @@
return ret;
}
+static uint32_t prefix_sortartist(const pmp_music_record_t* record)
+{
+ return ((record->artist != NULL) ? record->artist[0] : 0);
+}
+
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 itunesdb_playlist_entry_t *xi = (const itunesdb_playlist_entry_t*)_x;
+ const itunesdb_playlist_entry_t *yi = (const itunesdb_playlist_entry_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];
@@ -602,8 +625,8 @@
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 itunesdb_playlist_entry_t *xi = (const itunesdb_playlist_entry_t*)_x;
+ const itunesdb_playlist_entry_t *yi = (const itunesdb_playlist_entry_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];
@@ -621,8 +644,8 @@
static int comp_genre(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 itunesdb_playlist_entry_t *xi = (const itunesdb_playlist_entry_t*)_x;
+ const itunesdb_playlist_entry_t *yi = (const itunesdb_playlist_entry_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];
@@ -634,11 +657,16 @@
return ret;
}
+static uint32_t prefix_genre(const pmp_music_record_t* record)
+{
+ return ((record->genre != NULL) ? record->genre[0] : 0);
+}
+
static int comp_composer(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 itunesdb_playlist_entry_t *xi = (const itunesdb_playlist_entry_t*)_x;
+ const itunesdb_playlist_entry_t *yi = (const itunesdb_playlist_entry_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];
@@ -650,6 +678,25 @@
return ret;
}
+static uint32_t prefix_composer(const pmp_music_record_t* record)
+{
+ return ((record->composer != NULL) ? record->composer[0] : 0);
+}
+
+
+typedef uint32_t (*prefix_func)(const pmp_music_record_t* record);
+
+static void set_prefix(itunesdb_playlist_entry_t* array, size_t n, prefix_func func)
+{
+ size_t i;
+
+ for (i = 0;i < n;++i) {
+ itunesdb_playlist_entry_t *x = &array[i];
+ const pmp_music_record_t* base = (const pmp_music_record_t*)x->base;
+ x->prefix = func(&base[x->index]);
+ }
+}
+
static int set_album_list(itunesdb_chunk_t* mhla, const pmp_music_record_t* records, int num_records)
{
int i;
@@ -658,7 +705,7 @@
const ucs2char_t* prev_artist = NULL;
itunesdb_chunk_t *mhod = NULL, *mhia = NULL;
itunesdb_mhia_t *mhia_data = NULL;
- sorted_index_t* si = (sorted_index_t*)calloc(num_records, sizeof(sorted_index_t));
+ itunesdb_playlist_entry_t* si = (itunesdb_playlist_entry_t*)calloc(num_records, sizeof(itunesdb_playlist_entry_t));
if (!si) {
return IPODE_OUTOFMEMORY;
@@ -715,7 +762,8 @@
int ret = 0;
itunesdb_chunk_t *mhod = NULL, *mhip = NULL;
itunesdb_mhyp_t* mhyp_data = (itunesdb_mhyp_t*)mhyp->data;
- sorted_index_t* si = (sorted_index_t*)calloc(num_records, sizeof(sorted_index_t));
+ itunesdb_playlist_entry_t* si =
+ (itunesdb_playlist_entry_t*)calloc(num_records, sizeof(itunesdb_playlist_entry_t));
const static ucs2char_t ucs2cs_master[] = {'M','a','s','t','e','r',0};
if (!si) {
@@ -744,7 +792,14 @@
if (mhod) {
if (ret = itunesdb_init(mhod, "mhod", "index")) return ret;
qsort(si, num_records, sizeof(si[0]), comp_title);
- if (ret = itunesdb_set_mhod_index(mhod, 0x03, si, num_records)) return ret;
+ if (ret = itunesdb_set_mhod_order(mhod, 0x03, si, num_records)) return ret;
+
+ mhod = itunesdb_new_child(mhyp);
+ if (mhod) {
+ if (ret = itunesdb_init(mhod, "mhod", "library_playlist_index")) return ret;
+ set_prefix(si, num_records, prefix_title);
+ if (ret = itunesdb_set_mhod_index(mhod, 0x03, si, num_records)) return ret;
+ }
}
/* Construct an "mhod" chunk for index: sortartist, disc/tracknumber, title. */
@@ -752,7 +807,14 @@
if (mhod) {
if (ret = itunesdb_init(mhod, "mhod", "index")) return ret;
qsort(si, num_records, sizeof(si[0]), comp_sortartist);
- if (ret = itunesdb_set_mhod_index(mhod, 0x05, si, num_records)) return ret;
+ if (ret = itunesdb_set_mhod_order(mhod, 0x05, si, num_records)) return ret;
+
+ mhod = itunesdb_new_child(mhyp);
+ if (mhod) {
+ if (ret = itunesdb_init(mhod, "mhod", "library_playlist_index")) return ret;
+ set_prefix(si, num_records, prefix_sortartist);
+ if (ret = itunesdb_set_mhod_index(mhod, 0x05, si, num_records)) return ret;
+ }
}
/* Construct an "mhod" chunk for index: album, disc/tracknumber, title. */
@@ -760,7 +822,14 @@
if (mhod) {
if (ret = itunesdb_init(mhod, "mhod", "index")) return ret;
qsort(si, num_records, sizeof(si[0]), comp_album);
- if (ret = itunesdb_set_mhod_index(mhod, 0x04, si, num_records)) return ret;
+ if (ret = itunesdb_set_mhod_order(mhod, 0x04, si, num_records)) return ret;
+
+ mhod = itunesdb_new_child(mhyp);
+ if (mhod) {
+ if (ret = itunesdb_init(mhod, "mhod", "library_playlist_index")) return ret;
+ set_prefix(si, num_records, prefix_album);
+ if (ret = itunesdb_set_mhod_index(mhod, 0x04, si, num_records)) return ret;
+ }
}
/* Construct an "mhod" chunk for index: genre, sortartist, album, disc/tracknumber, title */
@@ -768,7 +837,14 @@
if (mhod) {
if (ret = itunesdb_init(mhod, "mhod", "index")) return ret;
qsort(si, num_records, sizeof(si[0]), comp_genre);
- if (ret = itunesdb_set_mhod_index(mhod, 0x07, si, num_records)) return ret;
+ if (ret = itunesdb_set_mhod_order(mhod, 0x07, si, num_records)) return ret;
+
+ mhod = itunesdb_new_child(mhyp);
+ if (mhod) {
+ if (ret = itunesdb_init(mhod, "mhod", "library_playlist_index")) return ret;
+ set_prefix(si, num_records, prefix_genre);
+ if (ret = itunesdb_set_mhod_index(mhod, 0x07, si, num_records)) return ret;
+ }
}
/* Construct an "mhod" chunk for index: composer, title. */
@@ -776,7 +852,14 @@
if (mhod) {
if (ret = itunesdb_init(mhod, "mhod", "index")) return ret;
qsort(si, num_records, sizeof(si[0]), comp_composer);
- if (ret = itunesdb_set_mhod_index(mhod, 0x12, si, num_records)) return ret;
+ if (ret = itunesdb_set_mhod_order(mhod, 0x12, si, num_records)) return ret;
+
+ mhod = itunesdb_new_child(mhyp);
+ if (mhod) {
+ if (ret = itunesdb_init(mhod, "mhod", "library_playlist_index")) return ret;
+ set_prefix(si, num_records, prefix_composer);
+ if (ret = itunesdb_set_mhod_index(mhod, 0x12, si, num_records)) return ret;
+ }
}
/* Construct an "mhod" chunk for index: albumartist, sortartist, disc/tracknumber, title. */
@@ -784,7 +867,7 @@
if (mhod) {
if (ret = itunesdb_init(mhod, "mhod", "index")) return ret;
qsort(si, num_records, sizeof(si[0]), comp_albumartist_sortartist);
- if (ret = itunesdb_set_mhod_index(mhod, 0x23, si, num_records)) return ret;
+ if (ret = itunesdb_set_mhod_order(mhod, 0x23, si, num_records)) return ret;
}
/* Construct an "mhod" chunk for index: albumartist, album, disc/tracknumber, title*/
@@ -792,7 +875,7 @@
if (mhod) {
if (ret = itunesdb_init(mhod, "mhod", "index")) return ret;
qsort(si, num_records, sizeof(si[0]), comp_albumartist);
- if (ret = itunesdb_set_mhod_index(mhod, 0x24, si, num_records)) return ret;
+ if (ret = itunesdb_set_mhod_order(mhod, 0x24, si, num_records)) return ret;
}
/* Construct an "mhod" chunk for index: title?. */
@@ -800,7 +883,14 @@
if (mhod) {
if (ret = itunesdb_init(mhod, "mhod", "index")) return ret;
qsort(si, num_records, sizeof(si[0]), comp_title);
- if (ret = itunesdb_set_mhod_index(mhod, 0x1D, si, num_records)) return ret;
+ if (ret = itunesdb_set_mhod_order(mhod, 0x1D, si, num_records)) return ret;
+
+ mhod = itunesdb_new_child(mhyp);
+ if (mhod) {
+ if (ret = itunesdb_init(mhod, "mhod", "library_playlist_index")) return ret;
+ set_prefix(si, num_records, prefix_title);
+ if (ret = itunesdb_set_mhod_index(mhod, 0x1D, si, num_records)) return ret;
+ }
}
/* Construct an "mhod" chunk for index: title?. */
@@ -808,7 +898,7 @@
if (mhod) {
if (ret = itunesdb_init(mhod, "mhod", "index")) return ret;
qsort(si, num_records, sizeof(si[0]), comp_title);
- if (ret = itunesdb_set_mhod_index(mhod, 0x1E, si, num_records)) return ret;
+ if (ret = itunesdb_set_mhod_order(mhod, 0x1E, si, num_records)) return ret;
}
/* Construct an "mhod" chunk for index: title?. */
@@ -816,7 +906,7 @@
if (mhod) {
if (ret = itunesdb_init(mhod, "mhod", "index")) return ret;
qsort(si, num_records, sizeof(si[0]), comp_title);
- if (ret = itunesdb_set_mhod_index(mhod, 0x1F, si, num_records)) return ret;
+ if (ret = itunesdb_set_mhod_order(mhod, 0x1F, si, num_records)) return ret;
}
/* End of the series of "mhod" chunks. */
@@ -831,13 +921,13 @@
mhip_data = (itunesdb_mhip_t*)mhip->data;
mhip_data->flag_podcast_group = 0;
- mhip_data->track_id = i;
- mhip_data->group_id = i + num_records;
+ mhip_data->track_id = 1008 + i * 2;
+ mhip_data->group_id = 1008 + i * 2 + 1;
mhod = itunesdb_new_child(mhip);
if (mhod) {
if (ret = itunesdb_init(mhod, "mhod", "playlist_order")) return ret;
- if (ret = itunesdb_set_mhod_playlist_order(mhod, i+1)) return ret;
+ if (ret = itunesdb_set_mhod_playlist_order(mhod, 1008 + i * 2 + 1)) return ret;
} else {
return IPODE_OUTOFMEMORY;
}
@@ -946,6 +1036,7 @@
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) {
@@ -965,6 +1056,7 @@
} else {
return IPODE_FAILEDNEWCHUNK;
}
+#endif
/* Construct "mhsd" chunk with track type (type = 1). */
mhsd = itunesdb_new_child(mhbd);
Modified: trunk/pmplib/lib/pmp_ipod/itunesdb.c
===================================================================
--- trunk/pmplib/lib/pmp_ipod/itunesdb.c 2007-09-25 16:23:32 UTC (rev 417)
+++ trunk/pmplib/lib/pmp_ipod/itunesdb.c 2007-09-30 15:57:53 UTC (rev 418)
@@ -332,6 +332,17 @@
if (ret = serialize_uint16le(sio, "gapless_track", "%u", &mhit->gapless_track)) return ret;
if (ret = serialize_uint16le(sio, "gapless_album", "%u", &mhit->gapless_album)) return ret;
if (ret = serialize_uint8_array(sio, "unknown_hash", "%02X ", mhit->unknown_hash, sizeof(mhit->unknown_hash))) return ret;
+ if (ret = serialize_uint32le(sio, "newunk1", "%u", &mhit->newunk1)) return ret;
+ if (ret = serialize_uint32le(sio, "newunk2", "%u", &mhit->newunk2)) return ret;
+ if (ret = serialize_uint32le(sio, "unk40", "%u", &mhit->unk40)) return ret;
+ if (ret = serialize_uint64le(sio, "newunk3", "%016llX", &mhit->newunk3)) return ret;
+ if (ret = serialize_uint32le(sio, "unk41", "%u", &mhit->unk41)) return ret;
+ if (ret = serialize_uint32le(sio, "unk42", "%u", &mhit->unk42)) return ret;
+ if (ret = serialize_uint64le(sio, "unk43", "%016llX", &mhit->unk43)) return ret;
+ if (ret = serialize_uint8_array(sio, "newunk4", "%02X ", mhit->newunk4, sizeof(mhit->newunk4))) return ret;
+ if (ret = serialize_uint32le(sio, "newunk5", "%u", &mhit->newunk5)) return ret;
+ if (ret = serialize_uint32le(sio, "newunk6", "%u", &mhit->newunk6)) return ret;
+ if (ret = serialize_uint32le(sio, "newunk7", "%u", &mhit->newunk7)) return ret;
return 0;
}
@@ -1099,7 +1110,7 @@
}
-int itunesdb_set_mhod_index(itunesdb_chunk_t* chunk, uint32_t type, sorted_index_t* si, uint32_t n)
+int itunesdb_set_mhod_order(itunesdb_chunk_t* chunk, uint32_t type, itunesdb_playlist_entry_t* si, uint32_t n)
{
uint32_t i;
itunesdb_mhod_t* mhod = (itunesdb_mhod_t*)chunk->data;
@@ -1123,6 +1134,51 @@
return 0;
}
+int itunesdb_set_mhod_index(itunesdb_chunk_t* chunk, uint32_t type, itunesdb_playlist_entry_t* si, uint32_t n)
+{
+ uint32_t i, m = 0, prev = 0;
+ itunesdb_mhod_t* mhod = (itunesdb_mhod_t*)chunk->data;
+ itunesdb_mhod_library_playlist_index_t* index = &mhod->data.lp_index;
+
+ /* Make sure this is an "mhod" chunk. */
+ if (strncmp(chunk->id, "mhod", 4) != 0) {
+ return IPODE_INCOMPATIBLECHUNK;
+ }
+
+ /* Store the index type. */
+ index->type = type;
+ /* Initialize the number of entries as zero. */
+ index->num_entries = 0;
+
+ /* Does nothing for an empty array. */
+ if (n <= 0) {
+ return 0;
+ }
+
+ /* Allocate the entry array with the maximum size. */
+ index->entries = (itunesdb_mhod_library_playlist_entry_t*)calloc(
+ n, sizeof(itunesdb_mhod_library_playlist_entry_t));
+ if (!index->entries) {
+ return IPODE_OUTOFMEMORY;
+ }
+
+ prev = si[0].prefix + 1;
+ for (i = 0;i < n;++i) {
+ if (prev != si[i].prefix) {
+ index->entries[m].value = si[i].prefix;
+ index->entries[m].begin = i;
+ index->entries[m].num = 1;
+ ++m;
+ } else {
+ ++index->entries[m-1].num;
+ }
+ prev = si[i].prefix;
+ }
+
+ index->num_entries = m;
+ return 0;
+}
+
int itunesdb_set_mhod_playlist_order(itunesdb_chunk_t* chunk, uint32_t order)
{
itunesdb_mhod_t* mhod = (itunesdb_mhod_t*)chunk->data;
Modified: trunk/pmplib/lib/pmp_ipod/itunesdb.h
===================================================================
--- trunk/pmplib/lib/pmp_ipod/itunesdb.h 2007-09-25 16:23:32 UTC (rev 417)
+++ trunk/pmplib/lib/pmp_ipod/itunesdb.h 2007-09-30 15:57:53 UTC (rev 418)
@@ -138,6 +138,17 @@
uint16_t gapless_track;
uint16_t gapless_album;
uint8_t unknown_hash[20];
+ uint32_t newunk1;
+ uint32_t newunk2;
+ uint32_t unk40;
+ uint64_t newunk3;
+ uint32_t unk41;
+ uint32_t unk42;
+ uint64_t unk43;
+ uint8_t newunk4[36];
+ uint32_t newunk5;
+ uint32_t newunk6;
+ uint32_t newunk7;
} itunesdb_mhit_t;
typedef struct {
@@ -289,9 +300,10 @@
} itunesdb_chunkdecl_t;
typedef struct {
- uint32_t index;
- const void* base;
-} sorted_index_t;
+ uint32_t index;
+ uint32_t prefix;
+ const void* base;
+} itunesdb_playlist_entry_t;
/**
* Initialize a chunk with identifier and subtype (for "mhod" chunk)
@@ -335,7 +347,8 @@
* @param n The number of entries in the sorted index.
* @retval int zero if succeeded, otherwise nonzero.
*/
-int itunesdb_set_mhod_index(itunesdb_chunk_t* chunk, uint32_t sort_order, sorted_index_t* si, uint32_t n);
+int itunesdb_set_mhod_order(itunesdb_chunk_t* chunk, uint32_t sort_order, itunesdb_playlist_entry_t* si, uint32_t n);
+int itunesdb_set_mhod_index(itunesdb_chunk_t* chunk, uint32_t sort_order, itunesdb_playlist_entry_t* si, uint32_t n);
/**
* Set ordinal value to "mhod" chunk.
Modified: trunk/pmplib/lib/pmp_ipod/pmp_ipod.vcproj
===================================================================
--- trunk/pmplib/lib/pmp_ipod/pmp_ipod.vcproj 2007-09-25 16:23:32 UTC (rev 417)
+++ trunk/pmplib/lib/pmp_ipod/pmp_ipod.vcproj 2007-09-30 15:57:53 UTC (rev 418)
@@ -40,7 +40,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
- AdditionalIncludeDirectories="$(SolutionDir)include"
+ AdditionalIncludeDirectories="$(SolutionDir)include;win32"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;PMP_IPOD_EXPORTS"
MinimalRebuild="true"
BasicRuntimeChecks="3"
@@ -61,7 +61,7 @@
/>
<Tool
Name="VCLinkerTool"
- AdditionalDependencies=".\win32spti\ipodprop_win32spti.lib shlwapi.lib"
+ AdditionalDependencies=".\win32\usbinfo_win32.lib .\win32spti\ipodprop_win32spti.lib shlwapi.lib"
LinkIncremental="2"
GenerateDebugInformation="true"
SubSystem="2"
@@ -117,7 +117,7 @@
/>
<Tool
Name="VCCLCompilerTool"
- AdditionalIncludeDirectories="$(SolutionDir)include"
+ AdditionalIncludeDirectories="$(SolutionDir)include;win32"
PreprocessorDefinitions="WIN32;_WINDOWS;_USRDLL;PMP_IPOD_EXPORTS"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
@@ -136,7 +136,7 @@
/>
<Tool
Name="VCLinkerTool"
- AdditionalDependencies=".\win32spti\ipodprop_win32spti.lib shlwapi.lib"
+ AdditionalDependencies=".\win32\usbinfo_win32.lib .\win32spti\ipodprop_win32spti.lib shlwapi.lib"
LinkIncremental="1"
GenerateDebugInformation="true"
SubSystem="2"
@@ -187,6 +187,10 @@
>
</File>
<File
+ RelativePath=".\ipodserial_win32.c"
+ >
+ </File>
+ <File
RelativePath=".\itunesdb.c"
>
</File>
@@ -229,6 +233,10 @@
>
</File>
<File
+ RelativePath=".\ipodserial.h"
+ >
+ </File>
+ <File
RelativePath=".\itunesdb.h"
>
</File>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
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.
|
|
From: <ny...@us...> - 2007-09-25 14:27:03
|
Revision: 416
http://pmplib.svn.sourceforge.net/pmplib/?rev=416&view=rev
Author: nyaochi
Date: 2007-09-25 07:27:01 -0700 (Tue, 25 Sep 2007)
Log Message:
-----------
- Sync with MPEG4ip Version 1.6. libgmi now requires
libmp4v2 bundled with version 1.6.
- Retrieval of albumartist values.
Modified Paths:
--------------
trunk/pmplib/lib/gmi/contrib/mp4v2/mp4.h
trunk/pmplib/lib/gmi/contrib/mp4v2/mpeg4ip.h
trunk/pmplib/lib/gmi/contrib/mp4v2/mpeg4ip_version.h
trunk/pmplib/lib/gmi/contrib/mp4v2/mpeg4ip_win32.h
trunk/pmplib/lib/gmi/gmi.vcproj
trunk/pmplib/lib/gmi/gmi_mp4v2.c
Added Paths:
-----------
trunk/pmplib/lib/gmi/contrib/mp4v2/win32/libmp4v2.lib
trunk/pmplib/lib/gmi/contrib/mp4v2/win32/libmp4v2d.lib
Removed Paths:
-------------
trunk/pmplib/lib/gmi/contrib/mp4v2/win32/libmp4v260.lib
trunk/pmplib/lib/gmi/contrib/mp4v2/win32/libmp4v260d.lib
Modified: trunk/pmplib/lib/gmi/contrib/mp4v2/mp4.h
===================================================================
--- trunk/pmplib/lib/gmi/contrib/mp4v2/mp4.h 2007-09-24 03:34:31 UTC (rev 415)
+++ trunk/pmplib/lib/gmi/contrib/mp4v2/mp4.h 2007-09-25 14:27:01 UTC (rev 416)
@@ -33,18 +33,19 @@
/* include system and project specific headers */
#include "mpeg4ip.h"
-
#include <math.h> /* to define float HUGE_VAL and/or NAN */
#ifndef NAN
#define NAN HUGE_VAL
#endif
+#ifndef DEFAULT
#ifdef __cplusplus
/* exploit C++ ability of default values for function parameters */
#define DEFAULT(x) =x
#else
#define DEFAULT(x)
#endif
+#endif
/* MP4 API types */
typedef void* MP4FileHandle;
@@ -54,6 +55,26 @@
typedef u_int64_t MP4Duration;
typedef u_int32_t MP4EditId;
+typedef u_int64_t (*VIRTUALIO_GETFILELENGTH)(void *user); // return file length in bytes
+typedef int (*VIRTUALIO_SETPOSITION)(void *user, u_int64_t position); // return 0 on success
+typedef int (*VIRTUALIO_GETPOSITION)(void *user, u_int64_t *position); // fill position, return 0 on success
+typedef size_t (*VIRTUALIO_READ)(void *user, void *buffer, size_t size); // return number of bytes actually read
+typedef size_t (*VIRTUALIO_WRITE)(void *user, void *buffer, size_t size); // return number of bytes actually written
+typedef int (*VIRTUALIO_ENDOFFILE)(void *user); // return 1 if file hit EOF
+typedef int (*VIRTUALIO_CLOSE)(void *user); // return 0 on success
+
+typedef struct Virtual_IO
+{
+ VIRTUALIO_GETFILELENGTH GetFileLength;
+ VIRTUALIO_SETPOSITION SetPosition;
+ VIRTUALIO_GETPOSITION GetPosition;
+ VIRTUALIO_READ Read;
+ VIRTUALIO_WRITE Write;
+ VIRTUALIO_ENDOFFILE EndOfFile;
+ VIRTUALIO_CLOSE Close;
+} Virtual_IO_t;
+
+
/* Invalid values for API types */
#define MP4_INVALID_FILE_HANDLE ((MP4FileHandle)NULL)
#define MP4_INVALID_TRACK_ID ((MP4TrackId)0)
@@ -100,6 +121,7 @@
#define MP4_VIDEO_TRACK_TYPE "vide"
#define MP4_HINT_TRACK_TYPE "hint"
#define MP4_CNTL_TRACK_TYPE "cntl"
+#define MP4_TEXT_TRACK_TYPE "text"
/*
* This second set of track types should be created
* via MP4AddSystemsTrack(type)
@@ -169,6 +191,11 @@
#define MP4_MPEG4_WAVETABLE_AUDIO_TYPE 14
#define MP4_MPEG4_MIDI_AUDIO_TYPE 15
#define MP4_MPEG4_ALGORITHMIC_FX_AUDIO_TYPE 16
+#define MP4_MPEG4_ALS_AUDIO_TYPE 31
+#define MP4_MPEG4_LAYER1_AUDIO_TYPE 32
+#define MP4_MPEG4_LAYER2_AUDIO_TYPE 33
+#define MP4_MPEG4_LAYER3_AUDIO_TYPE 34
+#define MP4_MPEG4_SLS_AUDIO_TYPE 35
/* MP4 Audio type utilities following common usage */
#define MP4_IS_MP3_AUDIO_TYPE(type) \
@@ -313,7 +340,13 @@
const char* fileName,
u_int32_t verbosity DEFAULT(0));
-bool MP4Close(
+// benski>
+MP4FileHandle MP4ReadEx(const char* fileName,
+ void *user,
+ Virtual_IO_t *virtual_IO,
+ u_int32_t verbosity DEFAULT(0));
+
+void MP4Close(
MP4FileHandle hFile);
bool MP4Optimize(
@@ -340,7 +373,7 @@
u_int32_t MP4GetVerbosity(MP4FileHandle hFile);
-bool MP4SetVerbosity(MP4FileHandle hFile, u_int32_t verbosity);
+void MP4SetVerbosity(MP4FileHandle hFile, u_int32_t verbosity);
MP4Duration MP4GetDuration(MP4FileHandle hFile);
@@ -359,11 +392,11 @@
u_int8_t MP4GetVideoProfileLevel(MP4FileHandle hFile,
MP4TrackId trackId DEFAULT(MP4_INVALID_TRACK_ID));
-bool MP4SetVideoProfileLevel(MP4FileHandle hFile, u_int8_t value);
+void MP4SetVideoProfileLevel(MP4FileHandle hFile, u_int8_t value);
u_int8_t MP4GetAudioProfileLevel(MP4FileHandle hFile);
-bool MP4SetAudioProfileLevel(MP4FileHandle hFile, u_int8_t value);
+void MP4SetAudioProfileLevel(MP4FileHandle hFile, u_int8_t value);
u_int8_t MP4GetGraphicsProfileLevel(MP4FileHandle hFile);
@@ -440,9 +473,12 @@
u_int8_t key_ind_len;
u_int8_t iv_len;
u_int8_t selective_enc;
- char *kms_uri;
+ const char *kms_uri;
} mp4v2_ismacrypParams;
+// API to initialize ismacryp properties to sensible defaults
+// if input param is null then mallocs a params struct
+mp4v2_ismacrypParams *MP4DefaultISMACrypParams(mp4v2_ismacrypParams *ptr);
MP4TrackId MP4AddEncAudioTrack(
MP4FileHandle hFile,
@@ -450,6 +486,7 @@
MP4Duration sampleDuration,
mp4v2_ismacrypParams *icPp,
u_int8_t audioType DEFAULT(MP4_MPEG4_AUDIO_TYPE));
+
MP4TrackId MP4AddAmrAudioTrack(
MP4FileHandle hFile,
u_int32_t timeScale,
@@ -473,8 +510,11 @@
MP4TrackId MP4AddHrefTrack(MP4FileHandle hFile,
uint32_t timeScale,
- MP4Duration sampleDuration);
+ MP4Duration sampleDuration,
+ const char *base_url DEFAULT(NULL));
+const char *MP4GetHrefTrackBaseUrl(MP4FileHandle hFile,
+ MP4TrackId trackId);
MP4TrackId MP4AddVideoTrack(
MP4FileHandle hFile,
u_int32_t timeScale,
@@ -490,7 +530,8 @@
u_int16_t width,
u_int16_t height,
mp4v2_ismacrypParams *icPp,
- u_int8_t videoType DEFAULT(MP4_MPEG4_VIDEO_TYPE));
+ u_int8_t videoType DEFAULT(MP4_MPEG4_VIDEO_TYPE),
+ const char *oFormat DEFAULT(NULL));
MP4TrackId MP4AddH264VideoTrack(
MP4FileHandle hFile,
@@ -502,11 +543,22 @@
uint8_t profile_compat,
uint8_t AVCLevelIndication,
uint8_t sampleLenFieldSizeMinusOne);
-bool MP4AddH264SequenceParameterSet(MP4FileHandle hFile,
+
+MP4TrackId MP4AddEncH264VideoTrack(
+ MP4FileHandle dstFile,
+ u_int32_t timeScale,
+ MP4Duration sampleDuration,
+ u_int16_t width,
+ u_int16_t height,
+ MP4FileHandle srcFile,
+ MP4TrackId srcTrackId,
+ mp4v2_ismacrypParams *icPp);
+
+void MP4AddH264SequenceParameterSet(MP4FileHandle hFile,
MP4TrackId trackId,
const uint8_t *pSequence,
uint16_t sequenceLen);
-bool MP4AddH264PictureParameterSet(MP4FileHandle hFile,
+void MP4AddH264PictureParameterSet(MP4FileHandle hFile,
MP4TrackId trackId,
const uint8_t *pPict,
uint16_t pictLen);
@@ -541,6 +593,14 @@
MP4FileHandle hFile,
MP4TrackId refTrackId);
+MP4TrackId MP4AddTextTrack(
+ MP4FileHandle hFile,
+ MP4TrackId refTrackId);
+
+MP4TrackId MP4AddChapterTextTrack(
+ MP4FileHandle hFile,
+ MP4TrackId refTrackId);
+
MP4TrackId MP4CloneTrack(
MP4FileHandle srcFile,
MP4TrackId srcTrackId,
@@ -573,7 +633,7 @@
bool applyEdits DEFAULT(false),
MP4TrackId dstHintTrackReferenceTrack DEFAULT(MP4_INVALID_TRACK_ID));
-bool MP4DeleteTrack(
+void MP4DeleteTrack(
MP4FileHandle hFile,
MP4TrackId trackId);
@@ -606,6 +666,12 @@
const char *MP4GetTrackMediaDataName(MP4FileHandle hFile,
MP4TrackId trackId);
+
+// MP4GetTrackMediaDataOriginalFormat is to be used to get the original
+// MediaDataName if a track has been encrypted.
+bool MP4GetTrackMediaDataOriginalFormat(MP4FileHandle hFile,
+ MP4TrackId trackId, char *originalFormat, u_int32_t buflen);
+
MP4Duration MP4GetTrackDuration(
MP4FileHandle hFile,
MP4TrackId trackId);
@@ -614,7 +680,7 @@
MP4FileHandle hFile,
MP4TrackId trackId);
-bool MP4SetTrackTimeScale(
+void MP4SetTrackTimeScale(
MP4FileHandle hFile,
MP4TrackId trackId,
u_int32_t value);
@@ -658,7 +724,7 @@
MP4TrackId trackId,
uint8_t *pProfile,
uint8_t *pLevel);
-bool MP4GetTrackH264SeqPictHeaders(MP4FileHandle hFile,
+void MP4GetTrackH264SeqPictHeaders(MP4FileHandle hFile,
MP4TrackId trackId,
uint8_t ***pSeqHeaders,
uint32_t **pSeqHeaderSize,
@@ -1100,8 +1166,9 @@
/* iTunes metadata handling */
bool MP4MetadataDelete(MP4FileHandle hFile);
bool MP4GetMetadataByIndex(MP4FileHandle hFile, u_int32_t index,
- const char** ppName,
- u_int8_t** ppValue, u_int32_t* pValueSize);
+ char** ppName, // need to free memory
+ u_int8_t** ppValue, // need to free
+ u_int32_t* pValueSize);
bool MP4SetMetadataName(MP4FileHandle hFile, const char* value);
bool MP4GetMetadataName(MP4FileHandle hFile, char** value);
bool MP4DeleteMetadataName(MP4FileHandle hFile);
@@ -1145,19 +1212,27 @@
bool MP4SetMetadataCompilation(MP4FileHandle hFile, u_int8_t cpl);
bool MP4GetMetadataCompilation(MP4FileHandle hFile, u_int8_t* cpl);
bool MP4DeleteMetadataCompilation(MP4FileHandle hFile);
+bool MP4SetMetadataPartOfGaplessAlbum(MP4FileHandle hFile, uint8_t pgap);
+bool MP4GetMetadataPartOfGaplessAlbum(MP4FileHandle hFile, uint8_t *pgap);
+bool MP4DeleteMetadataPartOfGaplessAlbum(MP4FileHandle hFile);
bool MP4SetMetadataCoverArt(MP4FileHandle hFile,
u_int8_t *coverArt, u_int32_t size);
bool MP4GetMetadataCoverArt(MP4FileHandle hFile,
- u_int8_t **coverArt, u_int32_t* size);
+ u_int8_t **coverArt, u_int32_t* size,
+ uint32_t index DEFAULT(0));
u_int32_t MP4GetMetadataCoverArtCount(MP4FileHandle hFile);
bool MP4DeleteMetadataCoverArt(MP4FileHandle hFile);
-bool MP4SetMetadataFreeForm(MP4FileHandle hFile, char *name,
- u_int8_t* pValue, u_int32_t valueSize);
-bool MP4GetMetadataFreeForm(MP4FileHandle hFile, char *name,
- u_int8_t** pValue, u_int32_t* valueSize);
-bool MP4DeleteMetadataFreeForm(MP4FileHandle hFile, char *name);
-
+bool MP4SetMetadataAlbumArtist(MP4FileHandle hFile, const char* value);
+bool MP4GetMetadataAlbumArtist(MP4FileHandle hFile, char** value);
+bool MP4DeleteMetadataAlbumArtist(MP4FileHandle hFile);
+
+bool MP4SetMetadataFreeForm(MP4FileHandle hFile, const char *name,
+ const u_int8_t* pValue, u_int32_t valueSize, const char *owner DEFAULT(NULL));
+bool MP4GetMetadataFreeForm(MP4FileHandle hFile, const char *name,
+ u_int8_t** pValue, u_int32_t* valueSize, const char *owner DEFAULT(NULL));
+bool MP4DeleteMetadataFreeForm(MP4FileHandle hFile, const char *name, const char *owner DEFAULT(NULL));
+
/* time conversion utilties */
/* predefined values for timeScale parameter below */
@@ -1211,7 +1286,7 @@
uint8_t *Base64ToBinary(const char *pData,
uint32_t decodeSize,
uint32_t *pDataSize);
-
+void MP4Free(void *p);
#ifdef __cplusplus
}
#endif
Modified: trunk/pmplib/lib/gmi/contrib/mp4v2/mpeg4ip.h
===================================================================
--- trunk/pmplib/lib/gmi/contrib/mp4v2/mpeg4ip.h 2007-09-24 03:34:31 UTC (rev 415)
+++ trunk/pmplib/lib/gmi/contrib/mp4v2/mpeg4ip.h 2007-09-25 14:27:01 UTC (rev 416)
@@ -331,5 +331,12 @@
AUDIO_FMT_HW_AC3,
} audio_format_t;
+#ifndef HAVE_STRUCT_IOVEC
+struct iovec {
+ void *iov_base;
+ unsigned int iov_len;
+};
+#endif
+
#endif /* __MPEG4IP_INCLUDED__ */
Modified: trunk/pmplib/lib/gmi/contrib/mp4v2/mpeg4ip_version.h
===================================================================
--- trunk/pmplib/lib/gmi/contrib/mp4v2/mpeg4ip_version.h 2007-09-24 03:34:31 UTC (rev 415)
+++ trunk/pmplib/lib/gmi/contrib/mp4v2/mpeg4ip_version.h 2007-09-25 14:27:01 UTC (rev 416)
@@ -1,6 +1,6 @@
#define MPEG4IP_PACKAGE "mpeg4ip"
-#define MPEG4IP_VERSION "1.5.0.1"
+#define MPEG4IP_VERSION "1.6"
#define MPEG4IP_MAJOR_VERSION 0x1
-#define MPEG4IP_MINOR_VERSION 0x5
-#define MPEG4IP_CVS_VERSION 0x01
+#define MPEG4IP_MINOR_VERSION 0x6
+#define MPEG4IP_CVS_VERSION 0x
#define MPEG4IP_HEX_VERSION ((MPEG4IP_MAJOR_VERSION << 16) | (MPEG4IP_MINOR_VERSION << 8) | MPEG4IP_CVS_VERSION)
Modified: trunk/pmplib/lib/gmi/contrib/mp4v2/mpeg4ip_win32.h
===================================================================
--- trunk/pmplib/lib/gmi/contrib/mp4v2/mpeg4ip_win32.h 2007-09-24 03:34:31 UTC (rev 415)
+++ trunk/pmplib/lib/gmi/contrib/mp4v2/mpeg4ip_win32.h 2007-09-25 14:27:01 UTC (rev 416)
@@ -24,9 +24,17 @@
#define HAVE_IN_PORT_T
#define HAVE_SOCKLEN_T
#define NEED_SDL_VIDEO_IN_MAIN_THREAD
+#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0400
+#endif
#define _WINSOCKAPI_
#define _INTEGRAL_MAX_BITS 64
+#ifndef __GNUC__
+#define _CRT_SECURE_NO_DEPRECATE 1
+#ifndef _WIN32
+#define _WIN32
+#endif
+#endif
#include <windows.h>
#include <winsock2.h>
#include <stdio.h>
@@ -35,6 +43,9 @@
#include <time.h>
#include <limits.h>
+#ifndef inline
+#define inline __inline
+#endif
typedef unsigned __int64 uint64_t;
typedef unsigned __int32 uint32_t;
typedef unsigned __int16 uint16_t;
@@ -43,22 +54,39 @@
typedef unsigned __int32 u_int32_t;
typedef unsigned __int16 u_int16_t;
typedef unsigned __int8 u_int8_t;
-typedef __int64 int64_t;
-typedef __int32 int32_t;
-typedef __int16 int16_t;
-typedef __int8 int8_t;
+typedef signed __int64 int64_t;
+typedef signed __int32 int32_t;
+typedef signed __int16 int16_t;
+typedef signed __int8 int8_t;
typedef unsigned short in_port_t;
typedef int socklen_t;
typedef int ssize_t;
typedef unsigned int uint;
-#define snprintf _snprintf
+static inline int snprintf(char *buffer, size_t count,
+ const char *format, ...) {
+ va_list ap;
+ int ret;
+ va_start(ap, format);
+ ret = vsnprintf_s(buffer, count, _TRUNCATE, format, ap);
+ va_end(ap);
+ if (ret == -1) {
+ if (errno == EINVAL) return -1;
+ return (int)count;
+ }
+ return ret;
+}
#define strncasecmp _strnicmp
#define strcasecmp _stricmp
+#define localtime_r(a,b) localtime_s(b,a)
+#define printf printf_s
+#define fprintf fprintf_s
#include <io.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
+#ifndef __GNUC__
+#define read _read
#define write _write
#define lseek _lseek
#define close _close
@@ -67,6 +95,9 @@
#define vsnprintf _vsnprintf
#define stat _stati64
#define fstat _fstati64
+#define fileno _fileno
+#define strdup _strdup
+#endif
#define F_OK 0
#define OPEN_RDWR (_O_RDWR | _O_BINARY)
#define OPEN_CREAT (_O_CREAT | _O_BINARY)
@@ -84,8 +115,11 @@
}
#endif
+#ifndef PATH_MAX
#define PATH_MAX MAX_PATH
+#endif
#define MAX_UINT64 -1
+
#define D64F "I64d"
#define U64F "I64u"
#define X64F "I64x"
@@ -102,7 +136,7 @@
#define LOG_INFO 6
#define LOG_DEBUG 7
-#if !__STDC__ && _INTEGRAL_MAX_BITS >= 64
+#if defined (__GNUC__) || (!__STDC__ && _INTEGRAL_MAX_BITS >= 64)
#define VAR_TO_FPOS(fpos, var) (fpos) = (var)
#define FPOS_TO_VAR(fpos, typed, var) (var) = (typed)(fpos)
#else
@@ -127,4 +161,18 @@
#define SIZEOF_BOOL 1
+#ifndef __GNUC__
+#ifndef _SS_PAD1SIZE
+struct sockaddr_storage {
+ unsigned short ss_family;
+ uint32_t ss_align;
+ char __ss_padding[128 - 2 * sizeof(uint32_t)];
+};
#endif
+#pragma warning(disable : 4244)
+#pragma warning(disable: 4996)
+#define HAVE_STRUCT_SOCKADDR_STORAGE 1
+#define HAVE_INET_PTON 1
+#define HAVE_INET_NTOP 1
+#endif
+#endif
Added: trunk/pmplib/lib/gmi/contrib/mp4v2/win32/libmp4v2.lib
===================================================================
(Binary files differ)
Property changes on: trunk/pmplib/lib/gmi/contrib/mp4v2/win32/libmp4v2.lib
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: trunk/pmplib/lib/gmi/contrib/mp4v2/win32/libmp4v260.lib
===================================================================
(Binary files differ)
Deleted: trunk/pmplib/lib/gmi/contrib/mp4v2/win32/libmp4v260d.lib
===================================================================
(Binary files differ)
Added: trunk/pmplib/lib/gmi/contrib/mp4v2/win32/libmp4v2d.lib
===================================================================
(Binary files differ)
Property changes on: trunk/pmplib/lib/gmi/contrib/mp4v2/win32/libmp4v2d.lib
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/pmplib/lib/gmi/gmi.vcproj
===================================================================
--- trunk/pmplib/lib/gmi/gmi.vcproj 2007-09-24 03:34:31 UTC (rev 415)
+++ trunk/pmplib/lib/gmi/gmi.vcproj 2007-09-25 14:27:01 UTC (rev 416)
@@ -62,7 +62,7 @@
/>
<Tool
Name="VCLinkerTool"
- AdditionalDependencies=".\contrib\id3tag\win32\libid3tagd.lib .\contrib\id3tag\win32\zlibd.lib .\contrib\ogg\win32\ogg_static_d.lib .\contrib\vorbis\win32\vorbis_static_d.lib .\contrib\vorbis\win32\vorbisfile_static_d.lib .\contrib\mp4v2\win32\libmp4v260d.lib"
+ AdditionalDependencies=".\contrib\id3tag\win32\libid3tagd.lib .\contrib\id3tag\win32\zlibd.lib .\contrib\ogg\win32\ogg_static_d.lib .\contrib\vorbis\win32\vorbis_static_d.lib .\contrib\vorbis\win32\vorbisfile_static_d.lib .\contrib\mp4v2\win32\libmp4v2d.lib"
OutputFile="$(OutDir)/gmi.dll"
LinkIncremental="2"
GenerateDebugInformation="true"
@@ -140,7 +140,7 @@
/>
<Tool
Name="VCLinkerTool"
- AdditionalDependencies=".\contrib\id3tag\win32\libid3tag.lib .\contrib\id3tag\win32\zlib.lib .\contrib\ogg\win32\ogg_static.lib .\contrib\vorbis\win32\vorbis_static.lib .\contrib\vorbis\win32\vorbisfile_static.lib .\contrib\mp4v2\win32\libmp4v260.lib"
+ AdditionalDependencies=".\contrib\id3tag\win32\libid3tag.lib .\contrib\id3tag\win32\zlib.lib .\contrib\ogg\win32\ogg_static.lib .\contrib\vorbis\win32\vorbis_static.lib .\contrib\vorbis\win32\vorbisfile_static.lib .\contrib\mp4v2\win32\libmp4v2.lib"
OutputFile="$(OutDir)/gmi.dll"
LinkIncremental="1"
GenerateDebugInformation="true"
Modified: trunk/pmplib/lib/gmi/gmi_mp4v2.c
===================================================================
--- trunk/pmplib/lib/gmi/gmi_mp4v2.c 2007-09-24 03:34:31 UTC (rev 415)
+++ trunk/pmplib/lib/gmi/gmi_mp4v2.c 2007-09-25 14:27:01 UTC (rev 416)
@@ -105,6 +105,11 @@
info->artist = utf8dupucs2(value);
free(value);
}
+ if (MP4GetMetadataAlbumArtist(mp4file, &value) && value != NULL) {
+ ucs2free(info->album_artist);
+ info->album_artist = utf8dupucs2(value);
+ free(value);
+ }
if (MP4GetMetadataAlbum(mp4file, &value) && value != NULL) {
ucs2free(info->album);
info->album = utf8dupucs2(value);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ny...@us...> - 2007-09-24 03:34:28
|
Revision: 415
http://pmplib.svn.sourceforge.net/pmplib/?rev=415&view=rev
Author: nyaochi
Date: 2007-09-23 20:34:31 -0700 (Sun, 23 Sep 2007)
Log Message:
-----------
- Fixed several bugs.
- Support SmartPlaylist Data mhod type.
- Read/write album_artist fields.
Modified Paths:
--------------
trunk/pmplib/lib/pmp_ipod/ipod.c
trunk/pmplib/lib/pmp_ipod/itunesdb.c
trunk/pmplib/lib/pmp_ipod/itunesdb.h
trunk/pmplib/lib/pmp_ipod/util.c
Modified: trunk/pmplib/lib/pmp_ipod/ipod.c
===================================================================
--- trunk/pmplib/lib/pmp_ipod/ipod.c 2007-09-17 13:00:32 UTC (rev 414)
+++ trunk/pmplib/lib/pmp_ipod/ipod.c 2007-09-24 03:34:31 UTC (rev 415)
@@ -359,6 +359,15 @@
}
}
+ /* Construct an "mhod" chunk for album artist. */
+ if (rec->artist && *rec->artist) {
+ mhod = itunesdb_new_child(mhit);
+ if (mhod) {
+ if (ret = itunesdb_init(mhod, "mhod", "album_artist")) return ret;
+ if (ret = itunesdb_set_mhod_string(mhod, rec->album_artist)) return ret;
+ }
+ }
+
/* Construct an "mhod" chunk for album. */
if (rec->album && *rec->album) {
mhod = itunesdb_new_child(mhit);
@@ -466,6 +475,8 @@
if (ret = itunesdb_get_mhod_string(mhod, &rec->title)) return ret;
} else if (itunesdb_ischunk(mhod, "mhod", "artist")) {
if (ret = itunesdb_get_mhod_string(mhod, &rec->artist)) return ret;
+ } else if (itunesdb_ischunk(mhod, "mhod", "album_artist")) {
+ if (ret = itunesdb_get_mhod_string(mhod, &rec->album_artist)) return ret;
} else if (itunesdb_ischunk(mhod, "mhod", "album")) {
if (ret = itunesdb_get_mhod_string(mhod, &rec->album)) return ret;
} else if (itunesdb_ischunk(mhod, "mhod", "genre")) {
Modified: trunk/pmplib/lib/pmp_ipod/itunesdb.c
===================================================================
--- trunk/pmplib/lib/pmp_ipod/itunesdb.c 2007-09-17 13:00:32 UTC (rev 414)
+++ trunk/pmplib/lib/pmp_ipod/itunesdb.c 2007-09-24 03:34:31 UTC (rev 415)
@@ -331,6 +331,7 @@
if (ret = serialize_uint32le(sio, "unk38", "%u", &mhit->unk38)) return ret;
if (ret = serialize_uint16le(sio, "gapless_track", "%u", &mhit->gapless_track)) return ret;
if (ret = serialize_uint16le(sio, "gapless_album", "%u", &mhit->gapless_album)) return ret;
+ if (ret = serialize_uint8_array(sio, "unknown_hash", "%02X ", mhit->unknown_hash, sizeof(mhit->unknown_hash))) return ret;
return 0;
}
@@ -478,6 +479,34 @@
return 0;
}
+static void mhod_smartplaylist_data_finish(itunesdb_chunk_t* chunk)
+{
+ itunesdb_mhod_t* mhod = (itunesdb_mhod_t*)chunk->data;
+ itunesdb_mhod_smartplaylist_data_t* spd = &mhod->data.spd;
+ memset(spd, 0, sizeof(*spd));
+}
+
+static int mhod_smartplaylist_data_serialize(itunesdb_chunk_t* chunk, const char *name, serializer_t* sio)
+{
+ int ret = 0;
+ itunesdb_mhod_t* mhod = (itunesdb_mhod_t*)chunk->data;
+ itunesdb_mhod_smartplaylist_data_t* spd = &mhod->data.spd;
+
+ if (ret = serialize_uint8(sio, "live_update", "%d", &spd->live_update)) return ret;
+ if (ret = serialize_uint8(sio, "check_rules", "%d", &spd->check_rules)) return ret;
+ if (ret = serialize_uint8(sio, "check_limits", "%d", &spd->check_limits)) return ret;
+ if (ret = serialize_uint8(sio, "limit_type", "%d", &spd->limit_type)) return ret;
+ if (ret = serialize_uint8(sio, "limit_sort", "%d", &spd->limit_sort)) return ret;
+ if (ret = serialize_uint8(sio, "unknown1", "%d", &spd->unknown1)) return ret;
+ if (ret = serialize_uint8(sio, "unknown2", "%d", &spd->unknown2)) return ret;
+ if (ret = serialize_uint8(sio, "unknown3", "%d", &spd->unknown3)) return ret;
+ if (ret = serialize_uint32le(sio, "limit_value", "%d", &spd->limit_value)) return ret;
+ if (ret = serialize_uint8(sio, "match_checked_only", "%d", &spd->match_checked_only)) return ret;
+ if (ret = serialize_uint8(sio, "reverse_limit_sort", "%d", &spd->reverse_limit_sort)) return ret;
+
+ return ret;
+}
+
static void mhod_index_finish(itunesdb_chunk_t* chunk)
{
itunesdb_mhod_t* mhod = (itunesdb_mhod_t*)chunk->data;
@@ -642,10 +671,13 @@
{14, "description", 0, mhod_string_finish, mhod_string_serialize},
{15, "podcast_enclosure_url", 0, mhod_url_finish, mhod_url_serialize},
{16, "podcast_rss_url", 0, mhod_url_finish, mhod_url_serialize},
+ {22, "album_artist", 0, mhod_string_finish, mhod_string_serialize},
+ {23, "sort_artist", 0, mhod_string_finish, mhod_string_serialize},
{27, "sort_title", 0, mhod_string_finish, mhod_string_serialize},
{28, "sort_album", 0, mhod_string_finish, mhod_string_serialize},
{29, "sort_albumartist", 0, mhod_string_finish, mhod_string_serialize},
{30, "sort_composer", 0, mhod_string_finish, mhod_string_serialize},
+ {50, "smartplaylist_data", 0, mhod_smartplaylist_data_finish, mhod_smartplaylist_data_serialize},
{52, "index", 0, mhod_index_finish, mhod_index_serialize},
{53, "library_playlist_index", 0, mhod_library_playlist_index_finish, mhod_library_playlist_index_serialize},
{100, "playlist_column", 0x288, mhod_playlist_column_finish, mhod_playlist_column_serialize},
@@ -919,7 +951,7 @@
}
/* Read children for this chunk. */
- if (strncmp(chunk->id, "mhlt", 4) == 0 || strncmp(chunk->id, "mhlp", 4) == 0) {
+ if (strncmp(chunk->id, "mhla", 4) == 0 || strncmp(chunk->id, "mhlt", 4) == 0 || strncmp(chunk->id, "mhlp", 4) == 0) {
/* chunk->overall_size represents the number of children for "mhlt" and "mhlp" chunks */
chunk->num_children = chunk->overall_size;
chunk->childlen = (itunesdb_chunk_t*)calloc(chunk->num_children, sizeof(itunesdb_chunk_t));
Modified: trunk/pmplib/lib/pmp_ipod/itunesdb.h
===================================================================
--- trunk/pmplib/lib/pmp_ipod/itunesdb.h 2007-09-17 13:00:32 UTC (rev 414)
+++ trunk/pmplib/lib/pmp_ipod/itunesdb.h 2007-09-24 03:34:31 UTC (rev 415)
@@ -137,6 +137,7 @@
uint32_t unk38;
uint16_t gapless_track;
uint16_t gapless_album;
+ uint8_t unknown_hash[20];
} itunesdb_mhit_t;
typedef struct {
@@ -180,6 +181,20 @@
} itunesdb_mhod_url_t;
typedef struct {
+ uint8_t live_update;
+ uint8_t check_rules;
+ uint8_t check_limits;
+ uint8_t limit_type;
+ uint8_t limit_sort;
+ uint8_t unknown1;
+ uint8_t unknown2;
+ uint8_t unknown3;
+ uint32_t limit_value;
+ uint8_t match_checked_only;
+ uint8_t reverse_limit_sort;
+} itunesdb_mhod_smartplaylist_data_t;
+
+typedef struct {
uint32_t type;
uint32_t num_entries;
uint8_t padding[40];
@@ -233,6 +248,7 @@
union {
itunesdb_mhod_string_t str;
itunesdb_mhod_url_t url;
+ itunesdb_mhod_smartplaylist_data_t spd;
itunesdb_mhod_index_t index;
itunesdb_mhod_playlist_column_t pc;
itunesdb_mhod_playlist_order_t po;
Modified: trunk/pmplib/lib/pmp_ipod/util.c
===================================================================
--- trunk/pmplib/lib/pmp_ipod/util.c 2007-09-17 13:00:32 UTC (rev 414)
+++ trunk/pmplib/lib/pmp_ipod/util.c 2007-09-24 03:34:31 UTC (rev 415)
@@ -42,7 +42,7 @@
{
size_t i;
for (i = 0;i < size;i++) {
- if (array[0] != value) {
+ if (array[i] != value) {
return 0;
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ny...@us...> - 2007-09-17 13:00:29
|
Revision: 414
http://pmplib.svn.sourceforge.net/pmplib/?rev=414&view=rev
Author: nyaochi
Date: 2007-09-17 06:00:32 -0700 (Mon, 17 Sep 2007)
Log Message:
-----------
Supported iPod nano 3rd gen. Many thanks go to those
who analyzed the algorithm to compute the hash value in
"mhbd" chunk, especially wtbw, nopcode, retar_d,
oleavr, and desrt at #gtkpod.
Other new iPod models are not supported at this moment
due to the lack of the code to obtain the serial string
on USB devices.
Modified Paths:
--------------
trunk/pmplib/lib/pmp_ipod/ipod.c
trunk/pmplib/lib/pmp_ipod/itunesdb.c
trunk/pmplib/lib/pmp_ipod/itunesdb.h
trunk/pmplib/lib/pmp_ipod/pmp_ipod.vcproj
Added Paths:
-----------
trunk/pmplib/lib/pmp_ipod/hash58.c
trunk/pmplib/lib/pmp_ipod/hash58.h
trunk/pmplib/lib/pmp_ipod/sha1.c
trunk/pmplib/lib/pmp_ipod/sha1.h
Added: trunk/pmplib/lib/pmp_ipod/hash58.c
===================================================================
--- trunk/pmplib/lib/pmp_ipod/hash58.c (rev 0)
+++ trunk/pmplib/lib/pmp_ipod/hash58.c 2007-09-17 13:00:32 UTC (rev 414)
@@ -0,0 +1,173 @@
+/*
+SHA1 hash value generator for offset 0x58 of "mhbd" chunk.
+
+This source code is taken from the implementation at:
+http://main.wtbw.co.uk/hash58.zip
+
+Many thanks to those who involved in the analysis at #gtkpod
+(wtbw, nopcode, retar_d, oleavr, desrt)
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif/*HAVE_CONFIG_H*/
+
+#include <os.h>
+#include <memory.h>
+#include "sha1.h"
+
+#define MIN2(a, b) ((a) < (b) ? (a) : (b))
+
+unsigned char invTable[256] = {
+ 0x74, 0x85, 0x96, 0xA7, 0xB8, 0xC9, 0xDA, 0xEB, 0xFC, 0x0D, 0x1E, 0x2F, 0x40, 0x51, 0x62, 0x73,
+ 0x84, 0x95, 0xA6, 0xB7, 0xC8, 0xD9, 0xEA, 0xFB, 0x0C, 0x1D, 0x2E, 0x3F, 0x50, 0x61, 0x72, 0x83,
+ 0x94, 0xA5, 0xB6, 0xC7, 0xD8, 0xE9, 0xFA, 0x0B, 0x1C, 0x2D, 0x3E, 0x4F, 0x60, 0x71, 0x82, 0x93,
+ 0xA4, 0xB5, 0xC6, 0xD7, 0xE8, 0xF9, 0x0A, 0x1B, 0x2C, 0x3D, 0x4E, 0x5F, 0x70, 0x81, 0x92, 0xA3,
+ 0xB4, 0xC5, 0xD6, 0xE7, 0xF8, 0x09, 0x1A, 0x2B, 0x3C, 0x4D, 0x5E, 0x6F, 0x80, 0x91, 0xA2, 0xB3,
+ 0xC4, 0xD5, 0xE6, 0xF7, 0x08, 0x19, 0x2A, 0x3B, 0x4C, 0x5D, 0x6E, 0x7F, 0x90, 0xA1, 0xB2, 0xC3,
+ 0xD4, 0xE5, 0xF6, 0x07, 0x18, 0x29, 0x3A, 0x4B, 0x5C, 0x6D, 0x7E, 0x8F, 0xA0, 0xB1, 0xC2, 0xD3,
+ 0xE4, 0xF5, 0x06, 0x17, 0x28, 0x39, 0x4A, 0x5B, 0x6C, 0x7D, 0x8E, 0x9F, 0xB0, 0xC1, 0xD2, 0xE3,
+ 0xF4, 0x05, 0x16, 0x27, 0x38, 0x49, 0x5A, 0x6B, 0x7C, 0x8D, 0x9E, 0xAF, 0xC0, 0xD1, 0xE2, 0xF3,
+ 0x04, 0x15, 0x26, 0x37, 0x48, 0x59, 0x6A, 0x7B, 0x8C, 0x9D, 0xAE, 0xBF, 0xD0, 0xE1, 0xF2, 0x03,
+ 0x14, 0x25, 0x36, 0x47, 0x58, 0x69, 0x7A, 0x8B, 0x9C, 0xAD, 0xBE, 0xCF, 0xE0, 0xF1, 0x02, 0x13,
+ 0x24, 0x35, 0x46, 0x57, 0x68, 0x79, 0x8A, 0x9B, 0xAC, 0xBD, 0xCE, 0xDF, 0xF0, 0x01, 0x12, 0x23,
+ 0x34, 0x45, 0x56, 0x67, 0x78, 0x89, 0x9A, 0xAB, 0xBC, 0xCD, 0xDE, 0xEF, 0x00, 0x11, 0x22, 0x33,
+ 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF, 0x10, 0x21, 0x32, 0x43,
+ 0x54, 0x65, 0x76, 0x87, 0x98, 0xA9, 0xBA, 0xCB, 0xDC, 0xED, 0xFE, 0x0F, 0x20, 0x31, 0x42, 0x53,
+ 0x64, 0x75, 0x86, 0x97, 0xA8, 0xB9, 0xCA, 0xDB, 0xEC, 0xFD, 0x0E, 0x1F, 0x30, 0x41, 0x52, 0x63
+};
+
+unsigned char table1[256] = {
+ 0x3A, 0x3F, 0x3E, 0x72, 0xBD, 0xA2, 0xD6, 0xB4, 0x63, 0xC0, 0x6E, 0x62, 0x59, 0x1E, 0xE2, 0x71,
+ 0xB5, 0x0D, 0xE8, 0x0C, 0x25, 0x38, 0xCE, 0x23, 0x7C, 0xB7, 0xAD, 0x16, 0xDF, 0x47, 0x3D, 0xB3,
+ 0x7E, 0x8C, 0xAA, 0x61, 0x31, 0x66, 0xBE, 0x4F, 0x97, 0x14, 0x54, 0xF0, 0x70, 0xEB, 0x30, 0xC4,
+ 0x27, 0x4E, 0xFA, 0x1A, 0x2B, 0x11, 0xF4, 0x45, 0x8E, 0x5D, 0x73, 0xED, 0x22, 0x2E, 0x7D, 0xA4,
+ 0x28, 0xDA, 0x2F, 0xC5, 0x92, 0x09, 0x05, 0x13, 0x9D, 0x32, 0x51, 0x4A, 0xC8, 0xBA, 0x96, 0xA7,
+ 0x6A, 0x50, 0xF3, 0xBC, 0x93, 0xBF, 0xB0, 0xD2, 0xD5, 0x82, 0x19, 0x98, 0x35, 0xCF, 0x6B, 0xB6,
+ 0x83, 0x56, 0x15, 0xF2, 0x9A, 0x9C, 0xCA, 0x74, 0x34, 0x58, 0x8D, 0xA6, 0x03, 0xFF, 0x46, 0x7B,
+ 0xD0, 0x7A, 0x33, 0x76, 0xDD, 0xAC, 0xCB, 0x24, 0x7F, 0xB1, 0x85, 0x60, 0xC3, 0x26, 0x8A, 0x1D,
+ 0x1C, 0x8F, 0x2A, 0xEF, 0x06, 0xDE, 0x67, 0x5E, 0xE7, 0xAE, 0xD9, 0xCC, 0x07, 0x6C, 0xF8, 0x0A,
+ 0xD3, 0x40, 0x36, 0x1F, 0x2D, 0x95, 0x43, 0xDB, 0x01, 0x89, 0x4B, 0xF7, 0xB9, 0x39, 0xC2, 0x52,
+ 0x53, 0xFD, 0x65, 0xF5, 0x68, 0xC1, 0xC7, 0x9F, 0x4D, 0xEA, 0xAF, 0x6D, 0x10, 0x44, 0x87, 0xD8,
+ 0xEE, 0x1B, 0xFE, 0x3C, 0xDC, 0x84, 0x69, 0x48, 0x6F, 0xD1, 0x57, 0x55, 0xD4, 0xA5, 0x49, 0x5B,
+ 0xE5, 0x0B, 0x94, 0xC9, 0x5F, 0xE1, 0x17, 0x81, 0xBB, 0xEC, 0xD7, 0xC6, 0x02, 0x4C, 0x42, 0x75,
+ 0xA3, 0x99, 0xE4, 0xA1, 0x9B, 0x5A, 0xF1, 0x29, 0xA0, 0x64, 0x9E, 0x18, 0x41, 0x80, 0x2C, 0x79,
+ 0x20, 0x8B, 0xAB, 0x90, 0x08, 0xB8, 0xA9, 0x77, 0x12, 0xF9, 0x0E, 0x88, 0xE9, 0x04, 0xFB, 0x86,
+ 0x0F, 0xE0, 0xA8, 0x5C, 0xE6, 0x21, 0xCD, 0x3B, 0x00, 0x78, 0xFC, 0xF6, 0xE3, 0x37, 0xB2, 0x91
+};
+
+unsigned char table2[256] = {
+ 0xF3, 0xE4, 0x1B, 0x38, 0xE5, 0x6F, 0xE8, 0x9D, 0x3E, 0x55, 0xBA, 0xC7, 0xAC, 0xEA, 0x66, 0xA2,
+ 0xB9, 0x7A, 0x34, 0x43, 0x02, 0x4E, 0xFE, 0x36, 0x41, 0x57, 0x1A, 0xB1, 0x31, 0x87, 0x04, 0x52,
+ 0x21, 0x22, 0xE1, 0x13, 0x7F, 0x03, 0x3A, 0x90, 0xF7, 0x69, 0x78, 0x12, 0x83, 0x0B, 0x9A, 0x97,
+ 0x4D, 0xB7, 0x8C, 0xBF, 0x2D, 0x94, 0xD1, 0x93, 0x2F, 0x42, 0x23, 0xA4, 0xE0, 0x92, 0xDC, 0x68,
+ 0xD3, 0xDD, 0xAF, 0x91, 0x9F, 0xED, 0x3D, 0x8F, 0xA1, 0x51, 0xD9, 0xE9, 0x70, 0x28, 0xEF, 0xB3,
+ 0x49, 0xA5, 0x0D, 0xC5, 0xD0, 0x60, 0xB4, 0x2B, 0x07, 0xF8, 0xDF, 0xE6, 0x16, 0xC0, 0x30, 0x71,
+ 0x85, 0xFD, 0x72, 0x95, 0x29, 0x79, 0x0A, 0x7B, 0x46, 0x11, 0x7D, 0x88, 0x1D, 0x2A, 0x48, 0x1F,
+ 0x45, 0x89, 0x47, 0xEE, 0xBB, 0xBE, 0x6E, 0xC3, 0x6C, 0xCE, 0x10, 0x5A, 0x2C, 0xCA, 0xFB, 0xB2,
+ 0xCB, 0x1C, 0x9C, 0xEC, 0x2E, 0x56, 0x59, 0x9B, 0xA6, 0x53, 0xAE, 0x17, 0x25, 0xC1, 0x3F, 0x6A,
+ 0x0F, 0x09, 0x01, 0xA3, 0xD6, 0xA0, 0xD8, 0x08, 0xE3, 0x74, 0x06, 0x6D, 0x19, 0x98, 0x1E, 0x77,
+ 0x76, 0xBC, 0xEB, 0x3C, 0xB0, 0xC4, 0xC8, 0x64, 0x0E, 0x86, 0x63, 0xD7, 0xDB, 0xBD, 0xA7, 0x82,
+ 0x39, 0x4F, 0x27, 0xD2, 0x5F, 0x73, 0xF4, 0x75, 0x6B, 0xC2, 0xD5, 0x67, 0x5D, 0x80, 0xAB, 0x81,
+ 0xDE, 0xF0, 0xAD, 0xAA, 0xCD, 0xB6, 0xF6, 0x7C, 0xFC, 0x33, 0x05, 0x14, 0x96, 0x15, 0xC9, 0x9E,
+ 0x35, 0x5C, 0x7E, 0x44, 0x54, 0x58, 0x3B, 0x40, 0x20, 0xA8, 0x8B, 0x5E, 0x4A, 0x24, 0x99, 0x8E,
+ 0xF5, 0xB5, 0x62, 0x00, 0x37, 0x5B, 0x18, 0x65, 0x8D, 0x32, 0xE2, 0xF9, 0xDA, 0x8A, 0xD4, 0xCC,
+ 0x26, 0xF2, 0xF1, 0xE7, 0x4B, 0xC6, 0xCF, 0xFF, 0x4C, 0x84, 0x61, 0xFA, 0xB8, 0x0C, 0xA9, 0x50
+};
+
+unsigned char fixed[18] = {
+ 0x67, 0x23, 0xFE, 0x30, 0x45, 0x33, 0xF8, 0x90, 0x99, 0x21, 0x07, 0xC1, 0xD0, 0x12, 0xB2, 0xA1, 0x07, 0x81
+};
+
+int GCD(int a, int b){
+ while( 1 )
+ {
+ a = a % b;
+ if( a == 0 )
+ return b;
+ b = b % a;
+ if( b == 0 )
+ return a;
+ }
+}
+
+int LCM(int a, int b)
+{
+ if(a==0 || b==0)
+ return 1;
+
+ return (a*b)/GCD(a,b);
+}
+
+
+//pFWID -> 8 bytes
+//pKey -> 64 byte buffer
+void GenerateKey(unsigned char *pFWID, unsigned char *pKey)
+{
+ int i;
+ SHA1_CTX context;
+ unsigned char y[16];
+
+ memset(pKey,0, 64);
+
+ //take LCM of each two bytes in the FWID in turn
+ for(i=0;i<4;i++){
+ int a=pFWID[i*2];
+ int b=pFWID[i*2+1];
+ int lcm = LCM(a,b);
+
+ unsigned char hi = (lcm & 0xFF00) >> 8;
+ unsigned char lo = lcm & 0xFF;
+
+ y[i*4] = ((table1[hi] * 0xB5) - 3);
+ y[i*4 + 1] = ((table2[hi] * 0xB7) + 0x49);
+ y[i*4 + 2] = ((table1[lo] * 0xB5) - 3);
+ y[i*4 + 3] = ((table2[lo] * 0xB7) + 0x49);
+ }
+
+ //convert y
+ for(i=0;i<16;i++){
+ y[i] = invTable[y[i]];
+ }
+
+ //hash
+ SHA1Init(&context);
+ SHA1Update(&context, fixed, 18);
+ SHA1Update(&context, y, 16);
+ SHA1Final(pKey, &context);
+}
+
+#define SIZE_OF_HEADERS 0x6C
+
+//pDataBase -> iTunesDB
+//pFWID -> 8 bytes
+//pHash -> 20 byte buffer
+void GenerateHash(uint8_t *pFWID, uint8_t *pDataBase, size_t lSize, uint8_t *pHash)
+{
+ int i;
+ SHA1_CTX context;
+ unsigned char key[64];
+ size_t lSizeWithoutHeaders = lSize - SIZE_OF_HEADERS;
+ size_t lSizeToUse = MIN2((long)0x40000, lSizeWithoutHeaders) + SIZE_OF_HEADERS;
+
+ //generate invtable
+ GenerateKey(pFWID, key);
+
+ //hmac sha1
+ for (i=0; i < 64; i++)
+ key[i] ^= 0x36;
+
+
+ SHA1Init(&context);
+ SHA1Update(&context, key, 64);
+ SHA1Update(&context, pDataBase, lSizeToUse);
+ SHA1Final(pHash, &context);
+
+ for (i=0; i < 64; i++)
+ key[i] ^= 0x36 ^ 0x5c;
+
+ SHA1Init(&context);
+ SHA1Update(&context, key, 64);
+ SHA1Update(&context, pHash, 20);
+ SHA1Final(pHash, &context);
+}
Added: trunk/pmplib/lib/pmp_ipod/hash58.h
===================================================================
--- trunk/pmplib/lib/pmp_ipod/hash58.h (rev 0)
+++ trunk/pmplib/lib/pmp_ipod/hash58.h 2007-09-17 13:00:32 UTC (rev 414)
@@ -0,0 +1,6 @@
+#ifndef __HASH58_H__
+#define __HASH58_H__
+
+void GenerateHash(uint8_t *pFWID, uint8_t *pDataBase, size_t lSize, uint8_t *pHash);
+
+#endif/*__HASH58_H__*/
Modified: trunk/pmplib/lib/pmp_ipod/ipod.c
===================================================================
--- trunk/pmplib/lib/pmp_ipod/ipod.c 2007-09-17 12:14:30 UTC (rev 413)
+++ trunk/pmplib/lib/pmp_ipod/ipod.c 2007-09-17 13:00:32 UTC (rev 414)
@@ -248,6 +248,9 @@
fp = ucs2fopen(itunesdb, "wb");
if (fp) {
+ /* Finalize the database (fill the hash58 value). */
+ itunesdb_finalize(sio.base, sio.offset);
+
if (fwrite(sio.base, 1, sio.offset, fp) != sio.offset) {
return (IPODC_ITUNESDB|IPODE_FILEWRITEERROR);
}
Modified: trunk/pmplib/lib/pmp_ipod/itunesdb.c
===================================================================
--- trunk/pmplib/lib/pmp_ipod/itunesdb.c 2007-09-17 12:14:30 UTC (rev 413)
+++ trunk/pmplib/lib/pmp_ipod/itunesdb.c 2007-09-17 13:00:32 UTC (rev 414)
@@ -38,9 +38,9 @@
#include "serialize.h"
#include "util.h"
#include "itunesdb.h"
+#include "hash58.h"
-
static void chunk_finish(itunesdb_chunk_t* chunk)
{
free(chunk->data);
@@ -989,6 +989,31 @@
return 0;
}
+int itunesdb_finalize(uint8_t* buffer, size_t size)
+{
+ uint8_t* src = NULL;
+ uint8_t hash58[20];
+ uint8_t fwid[8] = {
+ 0x00, 0x0A, 0x27, 0x00, 0x1A, 0x1D, 0x72, 0xF1
+ }; /* iPod nano 3rd gen only for now. */
+
+ src = (uint8_t*)malloc(size);
+ if (src == NULL) {
+ return 1;
+ }
+ memcpy(src, buffer, size);
+
+ memset(src+0x18, 0, 8);
+ memset(src+0x32, 0, 20);
+ memset(src+0x58, 0, 20);
+ GenerateHash(fwid, src, size, hash58);
+ free(src);
+
+ memcpy(buffer+0x58, hash58, sizeof(hash58));
+ return 0;
+}
+
+
itunesdb_chunk_t* itunesdb_new_child(itunesdb_chunk_t* chunk)
{
chunk->childlen = (itunesdb_chunk_t*)realloc(
Modified: trunk/pmplib/lib/pmp_ipod/itunesdb.h
===================================================================
--- trunk/pmplib/lib/pmp_ipod/itunesdb.h 2007-09-17 12:14:30 UTC (rev 413)
+++ trunk/pmplib/lib/pmp_ipod/itunesdb.h 2007-09-17 13:00:32 UTC (rev 414)
@@ -332,5 +332,6 @@
int itunesdb_repr(itunesdb_chunk_t* chunk, size_t index, serializer_t* sio);
int itunesdb_read(itunesdb_chunk_t* chunk, serializer_t* sio);
int itunesdb_write(itunesdb_chunk_t* chunk, serializer_t* sio);
+int itunesdb_finalize(uint8_t* buffer, size_t size);
#endif/*__ITUNESDB_H__*/
Modified: trunk/pmplib/lib/pmp_ipod/pmp_ipod.vcproj
===================================================================
--- trunk/pmplib/lib/pmp_ipod/pmp_ipod.vcproj 2007-09-17 12:14:30 UTC (rev 413)
+++ trunk/pmplib/lib/pmp_ipod/pmp_ipod.vcproj 2007-09-17 13:00:32 UTC (rev 414)
@@ -179,6 +179,10 @@
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
+ RelativePath=".\hash58.c"
+ >
+ </File>
+ <File
RelativePath=".\ipod.c"
>
</File>
@@ -199,6 +203,10 @@
>
</File>
<File
+ RelativePath=".\sha1.c"
+ >
+ </File>
+ <File
RelativePath=".\util.c"
>
</File>
@@ -209,6 +217,10 @@
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
+ RelativePath=".\hash58.h"
+ >
+ </File>
+ <File
RelativePath=".\ipod.h"
>
</File>
@@ -229,6 +241,10 @@
>
</File>
<File
+ RelativePath=".\sha1.h"
+ >
+ </File>
+ <File
RelativePath=".\status.h"
>
</File>
Added: trunk/pmplib/lib/pmp_ipod/sha1.c
===================================================================
--- trunk/pmplib/lib/pmp_ipod/sha1.c (rev 0)
+++ trunk/pmplib/lib/pmp_ipod/sha1.c 2007-09-17 13:00:32 UTC (rev 414)
@@ -0,0 +1,245 @@
+/*
+SHA-1 in C
+By Steve Reid <st...@ed...>
+100% Public Domain
+
+Test Vectors (from FIPS PUB 180-1)
+"abc"
+A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D
+"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
+84983E44 1C3BD26E BAAE4AA1 F95129E5 E54670F1
+A million repetitions of "a"
+34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F
+*/
+
+#define LITTLE_ENDIAN /* This should be #define'd if true. */
+/* #define SHA1HANDSOFF * Copies data before messing with it. */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif/*HAVE_CONFIG_H*/
+
+#include <os.h>
+#include <stdio.h>
+#include <string.h>
+
+typedef struct {
+ unsigned long state[5];
+ unsigned long count[2];
+ unsigned char buffer[64];
+} SHA1_CTX;
+
+void SHA1Transform(unsigned long state[5], unsigned char buffer[64]);
+void SHA1Init(SHA1_CTX* context);
+void SHA1Update(SHA1_CTX* context, unsigned char* data, unsigned int len);
+void SHA1Final(unsigned char digest[20], SHA1_CTX* context);
+
+#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
+
+/* blk0() and blk() perform the initial expand. */
+/* I got the idea of expanding during the round function from SSLeay */
+#ifdef LITTLE_ENDIAN
+#define blk0(i) (block->l[i] = (rol(block->l[i],24)&0xFF00FF00) \
+ |(rol(block->l[i],8)&0x00FF00FF))
+#else
+#define blk0(i) block->l[i]
+#endif
+#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
+ ^block->l[(i+2)&15]^block->l[i&15],1))
+
+/* (R0+R1), R2, R3, R4 are the different operations used in SHA1 */
+#define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
+#define R1(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk(i)+0x5A827999+rol(v,5);w=rol(w,30);
+#define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
+#define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
+#define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
+
+/* Hash a single 512-bit block. This is the core of the algorithm. */
+
+void SHA1Transform(unsigned long state[5], unsigned char buffer[64])
+{
+ unsigned long a, b, c, d, e;
+ typedef union {
+ unsigned char c[64];
+ unsigned long l[16];
+ } CHAR64LONG16;
+ CHAR64LONG16* block;
+
+ /*
+ printf("SHA1Transform:\n");
+ for (k = 0; k < 4; k++) {
+ for (i = 0; i < 4; i++) {
+ for (j = 0; j < 4; j++) {
+ printf("%02X", buffer[k*16+i*4+j]);
+ }
+ putchar(' ');
+ }
+ putchar('\n');
+ }
+ printf("SHA1Transform (translated):\n");
+ for (k = 0; k < 4; k++) {
+ for (i = 0; i < 4; i++) {
+ for (j = 0; j < 4; j++) {
+ long x = buffer[k*16+i*4+j] & 0xFF;
+ printf("%02X", cryptTable[x] & 0xFF);
+ }
+ putchar(' ');
+ }
+ putchar('\n');
+ }
+ */
+
+#ifdef SHA1HANDSOFF
+ static unsigned char workspace[64];
+ block = (CHAR64LONG16*)workspace;
+ memcpy(block, buffer, 64);
+#else
+ block = (CHAR64LONG16*)buffer;
+#endif
+ /* Copy context->state[] to working vars */
+ a = state[0];
+ b = state[1];
+ c = state[2];
+ d = state[3];
+ e = state[4];
+ /* 4 rounds of 20 operations each. Loop unrolled. */
+ R0(a,b,c,d,e, 0); R0(e,a,b,c,d, 1); R0(d,e,a,b,c, 2); R0(c,d,e,a,b, 3);
+ R0(b,c,d,e,a, 4); R0(a,b,c,d,e, 5); R0(e,a,b,c,d, 6); R0(d,e,a,b,c, 7);
+ R0(c,d,e,a,b, 8); R0(b,c,d,e,a, 9); R0(a,b,c,d,e,10); R0(e,a,b,c,d,11);
+ R0(d,e,a,b,c,12); R0(c,d,e,a,b,13); R0(b,c,d,e,a,14); R0(a,b,c,d,e,15);
+ R1(e,a,b,c,d,16); R1(d,e,a,b,c,17); R1(c,d,e,a,b,18); R1(b,c,d,e,a,19);
+ R2(a,b,c,d,e,20); R2(e,a,b,c,d,21); R2(d,e,a,b,c,22); R2(c,d,e,a,b,23);
+ R2(b,c,d,e,a,24); R2(a,b,c,d,e,25); R2(e,a,b,c,d,26); R2(d,e,a,b,c,27);
+ R2(c,d,e,a,b,28); R2(b,c,d,e,a,29); R2(a,b,c,d,e,30); R2(e,a,b,c,d,31);
+ R2(d,e,a,b,c,32); R2(c,d,e,a,b,33); R2(b,c,d,e,a,34); R2(a,b,c,d,e,35);
+ R2(e,a,b,c,d,36); R2(d,e,a,b,c,37); R2(c,d,e,a,b,38); R2(b,c,d,e,a,39);
+ R3(a,b,c,d,e,40); R3(e,a,b,c,d,41); R3(d,e,a,b,c,42); R3(c,d,e,a,b,43);
+ R3(b,c,d,e,a,44); R3(a,b,c,d,e,45); R3(e,a,b,c,d,46); R3(d,e,a,b,c,47);
+ R3(c,d,e,a,b,48); R3(b,c,d,e,a,49); R3(a,b,c,d,e,50); R3(e,a,b,c,d,51);
+ R3(d,e,a,b,c,52); R3(c,d,e,a,b,53); R3(b,c,d,e,a,54); R3(a,b,c,d,e,55);
+ R3(e,a,b,c,d,56); R3(d,e,a,b,c,57); R3(c,d,e,a,b,58); R3(b,c,d,e,a,59);
+ R4(a,b,c,d,e,60); R4(e,a,b,c,d,61); R4(d,e,a,b,c,62); R4(c,d,e,a,b,63);
+ R4(b,c,d,e,a,64); R4(a,b,c,d,e,65); R4(e,a,b,c,d,66); R4(d,e,a,b,c,67);
+ R4(c,d,e,a,b,68); R4(b,c,d,e,a,69); R4(a,b,c,d,e,70); R4(e,a,b,c,d,71);
+ R4(d,e,a,b,c,72); R4(c,d,e,a,b,73); R4(b,c,d,e,a,74); R4(a,b,c,d,e,75);
+ R4(e,a,b,c,d,76); R4(d,e,a,b,c,77); R4(c,d,e,a,b,78); R4(b,c,d,e,a,79);
+ /* Add the working vars back into context.state[] */
+ state[0] += a;
+ state[1] += b;
+ state[2] += c;
+ state[3] += d;
+ state[4] += e;
+ /* Wipe variables */
+ a = b = c = d = e = 0;
+}
+
+
+/* SHA1Init - Initialize new context */
+
+void SHA1Init(SHA1_CTX* context)
+{
+ /* SHA1 initialization constants */
+ context->state[0] = 0x67452301;
+ context->state[1] = 0xEFCDAB89;
+ context->state[2] = 0x98BADCFE;
+ context->state[3] = 0x10325476;
+ context->state[4] = 0xC3D2E1F0;
+ context->count[0] = context->count[1] = 0;
+}
+
+
+/* Run your data through this. */
+
+void SHA1Update(SHA1_CTX* context, unsigned char* data, unsigned int len)
+{
+ unsigned int i, j;
+
+ j = (context->count[0] >> 3) & 63;
+ if ((context->count[0] += len << 3) < (len << 3)) context->count[1]++;
+ context->count[1] += (len >> 29);
+ if ((j + len) > 63) {
+ memcpy(&context->buffer[j], data, (i = 64-j));
+ SHA1Transform(context->state, context->buffer);
+ for ( ; i + 63 < len; i += 64) {
+ SHA1Transform(context->state, &data[i]);
+ }
+ j = 0;
+ }
+ else i = 0;
+ memcpy(&context->buffer[j], &data[i], len - i);
+}
+
+
+/* Add padding and return the message digest. */
+
+void SHA1Final(unsigned char digest[20], SHA1_CTX* context)
+{
+ unsigned long i, j;
+ unsigned char finalcount[8];
+
+ for (i = 0; i < 8; i++) {
+ finalcount[i] = (unsigned char)((context->count[(i >= 4 ? 0 : 1)]
+ >> ((3-(i & 3)) * 8) ) & 255); /* Endian independent */
+ }
+ SHA1Update(context, (unsigned char *)"\200", 1);
+ while ((context->count[0] & 504) != 448) {
+ SHA1Update(context, (unsigned char *)"\0", 1);
+ }
+ SHA1Update(context, finalcount, 8); /* Should cause a SHA1Transform() */
+ for (i = 0; i < 20; i++) {
+ digest[i] = (unsigned char)
+ ((context->state[i>>2] >> ((3-(i & 3)) * 8) ) & 255);
+ }
+ /* Wipe variables */
+ i = j = 0;
+ memset(context->buffer, 0, 64);
+ memset(context->state, 0, 20);
+ memset(context->count, 0, 8);
+ memset(&finalcount, 0, 8);
+#ifdef SHA1HANDSOFF /* make SHA1Transform overwrite it's own static vars */
+ SHA1Transform(context->state, context->buffer);
+#endif
+}
+
+
+/*************************************************************/
+
+/*
+int main(int argc, char** argv)
+{
+ int i, j;
+ SHA1_CTX context;
+ unsigned char digest[20], buffer[16384];
+ FILE* file;
+
+ if (argc > 2) {
+ puts("Public domain SHA-1 implementation - by Steve Reid <st...@ed...>");
+ puts("Produces the SHA-1 hash of a file, or stdin if no file is specified.");
+ exit(0);
+ }
+ if (argc < 2) {
+ file = stdin;
+ }
+ else {
+ if (!(file = fopen(argv[1], "rb"))) {
+ fputs("Unable to open file.", stderr);
+ exit(-1);
+ }
+ }
+ SHA1Init(&context);
+ while (!feof(file)) { /* note: what if ferror(file)
+ i = fread(buffer, 1, 16384, file);
+ SHA1Update(&context, buffer, i);
+ }
+ SHA1Final(digest, &context);
+ fclose(file);
+ for (i = 0; i < 5; i++) {
+ for (j = 0; j < 4; j++) {
+ printf("%02X", digest[i*4+j]);
+ }
+ putchar(' ');
+ }
+ putchar('\n');
+ exit(0);
+}
+*/
Added: trunk/pmplib/lib/pmp_ipod/sha1.h
===================================================================
--- trunk/pmplib/lib/pmp_ipod/sha1.h (rev 0)
+++ trunk/pmplib/lib/pmp_ipod/sha1.h 2007-09-17 13:00:32 UTC (rev 414)
@@ -0,0 +1,13 @@
+#ifndef __SHA1_H__
+
+typedef struct {
+ unsigned long state[5];
+ unsigned long count[2];
+ unsigned char buffer[64];
+} SHA1_CTX;
+
+void SHA1Init(SHA1_CTX* context);
+void SHA1Update(SHA1_CTX* context, unsigned char* data, unsigned int len);
+void SHA1Final(unsigned char digest[20], SHA1_CTX* context);
+
+#endif/*__SHA1_H__*/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ny...@us...> - 2007-09-17 12:14:27
|
Revision: 413
http://pmplib.svn.sourceforge.net/pmplib/?rev=413&view=rev
Author: nyaochi
Date: 2007-09-17 05:14:30 -0700 (Mon, 17 Sep 2007)
Log Message:
-----------
- Updated the layout of "mhsd" chunk.
Modified Paths:
--------------
trunk/pmplib/lib/pmp_ipod/ipod.c
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-12 17:04:54 UTC (rev 412)
+++ trunk/pmplib/lib/pmp_ipod/ipod.c 2007-09-17 12:14:30 UTC (rev 413)
@@ -889,6 +889,7 @@
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) {
@@ -908,6 +909,7 @@
} else {
return IPODE_FAILEDNEWCHUNK;
}
+#endif
/* Construct "mhsd" chunk with track type (type = 1). */
mhsd = itunesdb_new_child(mhbd);
Modified: trunk/pmplib/lib/pmp_ipod/itunesdb.c
===================================================================
--- trunk/pmplib/lib/pmp_ipod/itunesdb.c 2007-09-12 17:04:54 UTC (rev 412)
+++ trunk/pmplib/lib/pmp_ipod/itunesdb.c 2007-09-17 12:14:30 UTC (rev 413)
@@ -64,12 +64,18 @@
mhbd->unknown1 = 1;
mhbd->version = 0x19; /* iTunes 7.4.1 */
mhbd->num_children = 0; /* to be filled */
- mhbd->identifier = 0x7F6BBD850EB674E2;
+ mhbd->identifier = 0x5967FDF4464C603D;
mhbd->unknown2 = 2;
mhbd->unknown3 = 611;
mhbd->unknown4 = 0xBCD054CD8C063208;
+ mhbd->unknown5 = 0;
+ mhbd->unknown6 = 1;
mhbd->language[0] = 'j';
mhbd->language[1] = 'a';
+ mhbd->unknown7 = 0x39F6D17B62A94AC7;
+ mhbd->unknown8 = 1;
+ mhbd->unknown9 = 13;
+ mhbd->timezone = 0x00007E90;
}
chunk->data = mhbd;
return mhbd ? 0 : IPODE_OUTOFMEMORY;
@@ -87,8 +93,15 @@
if (ret = serialize_uint16le(sio, "unkonwn2", "%d", &mhbd->unknown2)) return ret;
if (ret = serialize_uint16le(sio, "unkonwn3", "%d", &mhbd->unknown3)) return ret;
if (ret = serialize_uint64le(sio, "unknown4", "%016llX", &mhbd->unknown4)) return ret;
- if (ret = serialize_uint8_array(sio, "unknown5", "%02X ", mhbd->unknown5, sizeof(mhbd->unknown5))) return ret;
+ if (ret = serialize_uint32le(sio, "unknown5", "%d", &mhbd->unknown5)) return ret;
+ if (ret = serialize_uint16le(sio, "unknown6", "%d", &mhbd->unknown6)) return ret;
+ if (ret = serialize_uint8_array(sio, "hash32", "%02X ", mhbd->hash32, sizeof(mhbd->hash32))) return ret;
if (ret = serialize_uint8_array(sio, "language", "%c ", mhbd->language, sizeof(mhbd->language))) return ret;
+ if (ret = serialize_uint64le(sio, "unknown7", "%016llX", &mhbd->unknown7)) return ret;
+ if (ret = serialize_uint32le(sio, "unknown8", "%d", &mhbd->unknown8)) return ret;
+ if (ret = serialize_uint32le(sio, "unknown9", "%d", &mhbd->unknown9)) return ret;
+ if (ret = serialize_uint8_array(sio, "hash58", "%02X ", mhbd->hash58, sizeof(mhbd->hash58))) return ret;
+ if (ret = serialize_uint32le(sio, "timezone", "%d", &mhbd->timezone)) return ret;
return 0;
}
Modified: trunk/pmplib/lib/pmp_ipod/itunesdb.h
===================================================================
--- trunk/pmplib/lib/pmp_ipod/itunesdb.h 2007-09-12 17:04:54 UTC (rev 412)
+++ trunk/pmplib/lib/pmp_ipod/itunesdb.h 2007-09-17 12:14:30 UTC (rev 413)
@@ -32,8 +32,15 @@
uint16_t unknown2; /* always set to 2. */
uint16_t unknown3; /* 0x0263 */
uint64_t unknown4;
- uint8_t unknown5[26]; /* zero padded. */
+ uint32_t unknown5;
+ uint16_t unknown6;
+ uint8_t hash32[20];
uint8_t language[2]; /* e.g., "en", "ja" */
+ uint64_t unknown7;
+ uint32_t unknown8;
+ uint32_t unknown9;
+ uint8_t hash58[20];
+ uint32_t timezone;
} itunesdb_mhbd_t;
typedef struct {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ny...@us...> - 2007-09-12 17:04:51
|
Revision: 412
http://pmplib.svn.sourceforge.net/pmplib/?rev=412&view=rev
Author: nyaochi
Date: 2007-09-12 10:04:54 -0700 (Wed, 12 Sep 2007)
Log Message:
-----------
- Added mhsd (type = 4).
Modified Paths:
--------------
trunk/pmplib/lib/pmp_ipod/ipod.c
trunk/pmplib/lib/pmp_ipod/itunesdb.c
Modified: trunk/pmplib/lib/pmp_ipod/ipod.c
===================================================================
--- trunk/pmplib/lib/pmp_ipod/ipod.c 2007-09-12 16:20:00 UTC (rev 411)
+++ trunk/pmplib/lib/pmp_ipod/ipod.c 2007-09-12 17:04:54 UTC (rev 412)
@@ -535,6 +535,22 @@
return ret;
}
+static int comp_album_for_list(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, y->album);
+ if (ret == 0) {
+ ret = comp_string(x->artist, y->artist);
+ }
+ return ret;
+}
+
static int comp_artist(const void *_x, const void *_y)
{
int ret = 0;
@@ -583,6 +599,59 @@
return ret;
}
+static int set_album_list(itunesdb_chunk_t* mhla, const pmp_music_record_t* records, int num_records)
+{
+ int i;
+ int ret = 0;
+ const ucs2char_t* prev_album = NULL;
+ const ucs2char_t* prev_artist = NULL;
+ itunesdb_chunk_t *mhod = NULL, *mhia = NULL;
+ itunesdb_mhia_t *mhia_data = NULL;
+ sorted_index_t* si = (sorted_index_t*)calloc(num_records, sizeof(sorted_index_t));
+
+ if (!si) {
+ return IPODE_OUTOFMEMORY;
+ }
+ for (i = 0;i < num_records;++i) {
+ si[i].base = records;
+ si[i].index = i;
+ }
+ qsort(si, num_records, sizeof(si[0]), comp_album_for_list);
+
+ for (i = 0;i < num_records;++i) {
+ const pmp_music_record_t* cur = &records[si[i].index];
+ const ucs2char_t* album = cur->album;
+ const ucs2char_t* artist = cur->artist;
+
+ if (prev_album == NULL || ucs2cmp(prev_album, album) != 0) {
+ mhia = itunesdb_new_child(mhla);
+ if (ret = itunesdb_init(mhia, "mhia", NULL)) return ret;
+ mhia_data = (itunesdb_mhia_t*)mhia->data;
+
+ mhod = itunesdb_new_child(mhia);
+ if (mhod) {
+ if (ret = itunesdb_init(mhod, "mhod", "album_albumlist")) return ret;
+ if (ret = itunesdb_set_mhod_string(mhod, album)) return ret;
+ }
+
+ mhod = itunesdb_new_child(mhia);
+ if (mhod) {
+ if (ret = itunesdb_init(mhod, "mhod", "artist_albumlist")) return ret;
+ if (ret = itunesdb_set_mhod_string(mhod, artist)) return ret;
+ }
+
+ mhia_data->num_children = 2;
+ mhia_data->album_id = i;
+ mhia_data->timestamp = 0;
+ mhia_data->unknown1 = 2;
+ }
+
+ prev_album = album;
+ }
+
+ return 0;
+}
+
static int set_master_playlist(itunesdb_chunk_t* mhyp, const pmp_music_record_t* records, int num_records)
{
int i;
@@ -807,6 +876,7 @@
int i;
int ret = 0;
itunesdb_chunk_t *mhbd = NULL, *mhsd = NULL;
+ itunesdb_chunk_t *mhla = NULL;
itunesdb_chunk_t *mhlt = NULL, *mhit = NULL;
itunesdb_chunk_t *mhlp = NULL, *mhyp = NULL;
itunesdb_mhbd_t* mhbd_data = NULL;
@@ -820,7 +890,25 @@
mhbd_data = (itunesdb_mhbd_t*)mhbd->data;
/* Construct "mhsd" chunk with album_list type (type = 4). */
+ mhsd = itunesdb_new_child(mhbd);
+ if (mhsd) {
+ itunesdb_mhsd_t* mhsd_data = NULL;
+ if (ret = itunesdb_init(mhsd, "mhsd", NULL)) return ret;
+ mhsd_data = (itunesdb_mhsd_t*)mhsd->data;
+ mhsd_data->type = 4; /* album_list type. */
+ /* Construct "mhla" chunk. */
+ mhla = itunesdb_new_child(mhsd);
+ if (mhla) {
+ if (ret = itunesdb_init(mhla, "mhla", NULL)) return ret;
+ if (ret = set_album_list(mhla, records, num_records)) return ret;
+ } else {
+ return IPODE_FAILEDNEWCHUNK;
+ }
+ } else {
+ return IPODE_FAILEDNEWCHUNK;
+ }
+
/* Construct "mhsd" chunk with track type (type = 1). */
mhsd = itunesdb_new_child(mhbd);
if (mhsd) {
Modified: trunk/pmplib/lib/pmp_ipod/itunesdb.c
===================================================================
--- trunk/pmplib/lib/pmp_ipod/itunesdb.c 2007-09-12 16:20:00 UTC (rev 411)
+++ trunk/pmplib/lib/pmp_ipod/itunesdb.c 2007-09-12 17:04:54 UTC (rev 412)
@@ -960,7 +960,7 @@
}
/* Calculate chunk->overall_size. */
- if (strncmp(chunk->id, "mhlt", 4) == 0 || strncmp(chunk->id, "mhlp", 4) == 0) {
+ if (strncmp(chunk->id, "mhla", 4) == 0 || strncmp(chunk->id, "mhlt", 4) == 0 || strncmp(chunk->id, "mhlp", 4) == 0) {
/* chunk->overall_size represents the number of children for "mhlt" and "mhlp" chunks */
chunk->overall_size = chunk->num_children;
} else {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ny...@us...> - 2007-09-12 16:20:01
|
Revision: 411
http://pmplib.svn.sourceforge.net/pmplib/?rev=411&view=rev
Author: nyaochi
Date: 2007-09-12 09:20:00 -0700 (Wed, 12 Sep 2007)
Log Message:
-----------
Added some indices, but it's still not working.
Modified Paths:
--------------
trunk/pmplib/lib/pmp_ipod/ipod.c
Modified: trunk/pmplib/lib/pmp_ipod/ipod.c
===================================================================
--- trunk/pmplib/lib/pmp_ipod/ipod.c 2007-09-12 15:07:27 UTC (rev 410)
+++ trunk/pmplib/lib/pmp_ipod/ipod.c 2007-09-12 16:20:00 UTC (rev 411)
@@ -618,23 +618,23 @@
if (mhod) {
if (ret = itunesdb_init(mhod, "mhod", "index")) return ret;
qsort(si, num_records, sizeof(si[0]), comp_title);
- if (itunesdb_set_mhod_index(mhod, 0x03, si, num_records)) return ret;
+ if (ret = itunesdb_set_mhod_index(mhod, 0x03, si, num_records)) return ret;
}
- /* Construct an "mhod" chunk for album index. */
+ /* Construct an "mhod" chunk for artist index. */
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);
- if (ret = itunesdb_set_mhod_index(mhod, 0x04, si, num_records)) return ret;
+ qsort(si, num_records, sizeof(si[0]), comp_artist);
+ if (ret = itunesdb_set_mhod_index(mhod, 0x05, si, num_records)) return ret;
}
- /* Construct an "mhod" chunk for artist index. */
+ /* Construct an "mhod" chunk for album index. */
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);
- if (ret = itunesdb_set_mhod_index(mhod, 0x05, si, num_records)) return ret;
+ qsort(si, num_records, sizeof(si[0]), comp_album);
+ if (ret = itunesdb_set_mhod_index(mhod, 0x04, si, num_records)) return ret;
}
/* Construct an "mhod" chunk for genre index. */
@@ -642,7 +642,7 @@
if (mhod) {
if (ret = itunesdb_init(mhod, "mhod", "index")) return ret;
qsort(si, num_records, sizeof(si[0]), comp_genre);
- if (ret = itunesdb_set_mhod_index(mhod, 0x06, si, num_records)) return ret;
+ if (ret = itunesdb_set_mhod_index(mhod, 0x07, si, num_records)) return ret;
}
/* Construct an "mhod" chunk for composer index. */
@@ -653,6 +653,46 @@
if (ret = itunesdb_set_mhod_index(mhod, 0x12, si, num_records)) return ret;
}
+ /* Construct an "mhod" chunk for 'unknown' index. */
+ 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);
+ if (ret = itunesdb_set_mhod_index(mhod, 0x23, si, num_records)) return ret;
+ }
+
+ /* Construct an "mhod" chunk for 'unknown' index. */
+ 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);
+ if (ret = itunesdb_set_mhod_index(mhod, 0x24, si, num_records)) return ret;
+ }
+
+ /* Construct an "mhod" chunk for 'unknown' index. */
+ mhod = itunesdb_new_child(mhyp);
+ if (mhod) {
+ if (ret = itunesdb_init(mhod, "mhod", "index")) return ret;
+ qsort(si, num_records, sizeof(si[0]), comp_title);
+ if (ret = itunesdb_set_mhod_index(mhod, 0x1D, si, num_records)) return ret;
+ }
+
+ /* Construct an "mhod" chunk for 'unknown' index. */
+ mhod = itunesdb_new_child(mhyp);
+ if (mhod) {
+ if (ret = itunesdb_init(mhod, "mhod", "index")) return ret;
+ qsort(si, num_records, sizeof(si[0]), comp_title);
+ if (ret = itunesdb_set_mhod_index(mhod, 0x1E, si, num_records)) return ret;
+ }
+
+ /* Construct an "mhod" chunk for 'unknown' index. */
+ mhod = itunesdb_new_child(mhyp);
+ if (mhod) {
+ if (ret = itunesdb_init(mhod, "mhod", "index")) return ret;
+ qsort(si, num_records, sizeof(si[0]), comp_title);
+ if (ret = itunesdb_set_mhod_index(mhod, 0x1F, si, num_records)) return ret;
+ }
+
/* End of the series of "mhod" chunks. */
mhyp_data->num_mhod = mhyp->num_children;
@@ -779,7 +819,9 @@
if (ret = itunesdb_init(mhbd, "mhbd", NULL)) return ret;
mhbd_data = (itunesdb_mhbd_t*)mhbd->data;
- /* Construct "mhsd" chunk with track type. */
+ /* Construct "mhsd" chunk with album_list type (type = 4). */
+
+ /* Construct "mhsd" chunk with track type (type = 1). */
mhsd = itunesdb_new_child(mhbd);
if (mhsd) {
itunesdb_mhsd_t* mhsd_data = NULL;
@@ -814,7 +856,9 @@
return IPODE_FAILEDNEWCHUNK;
}
- /* Construct "mhsd" chunk with playlist type. */
+ /* Construct "mhsd" chunk with playlist type (type = 3). */
+
+ /* Construct "mhsd" chunk with playlist type (type = 2). */
mhsd = itunesdb_new_child(mhbd);
if (mhsd) {
itunesdb_mhsd_t* mhsd_data = NULL;
@@ -853,6 +897,8 @@
return IPODE_FAILEDNEWCHUNK;
}
+ /* Construct "mhsd" chunk with unknown type (type = 5). */
+
mhbd_data->num_children = mhbd->num_children;
ipod->itunesdb = mhbd;
return 0;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ny...@us...> - 2007-09-12 15:07:27
|
Revision: 410
http://pmplib.svn.sourceforge.net/pmplib/?rev=410&view=rev
Author: nyaochi
Date: 2007-09-12 08:07:27 -0700 (Wed, 12 Sep 2007)
Log Message:
-----------
- Updated parameters for database construction,
which is still not working though.
Modified Paths:
--------------
trunk/pmplib/lib/pmp_ipod/itunesdb.c
Modified: trunk/pmplib/lib/pmp_ipod/itunesdb.c
===================================================================
--- trunk/pmplib/lib/pmp_ipod/itunesdb.c 2007-09-12 14:25:36 UTC (rev 409)
+++ trunk/pmplib/lib/pmp_ipod/itunesdb.c 2007-09-12 15:07:27 UTC (rev 410)
@@ -55,16 +55,16 @@
if (def) {
memset(chunk, 0, sizeof(*chunk));
strncpy(chunk->id, "mhbd", 4);
- chunk->size = 104;
+ chunk->size = 188;
chunk->overall_size = 0; /* to be filled */
}
mhbd = (itunesdb_mhbd_t*)calloc(1, sizeof(itunesdb_mhbd_t));
if (def && mhbd) {
mhbd->unknown1 = 1;
- mhbd->version = 0x13; /* iTunes 7 */
+ mhbd->version = 0x19; /* iTunes 7.4.1 */
mhbd->num_children = 0; /* to be filled */
- mhbd->identifier = 0x8CD2513B66EF2541;
+ mhbd->identifier = 0x7F6BBD850EB674E2;
mhbd->unknown2 = 2;
mhbd->unknown3 = 611;
mhbd->unknown4 = 0xBCD054CD8C063208;
@@ -166,6 +166,10 @@
chunk->overall_size = 0; /* to be filled */
}
mhia = (itunesdb_mhia_t*)calloc(1, sizeof(itunesdb_mhia_t));
+
+ if (mhia && def) {
+ mhia->unknown1 = 2;
+ }
chunk->data = mhia;
return mhia ? 0 : IPODE_OUTOFMEMORY;
@@ -221,7 +225,7 @@
if (def) {
memset(chunk, 0, sizeof(*chunk));
strncpy(chunk->id, "mhit", 4);
- chunk->size = 328;
+ chunk->size = 388;
chunk->overall_size = 0; /* to be filled */
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ny...@us...> - 2007-09-12 14:25:34
|
Revision: 409
http://pmplib.svn.sourceforge.net/pmplib/?rev=409&view=rev
Author: nyaochi
Date: 2007-09-12 07:25:36 -0700 (Wed, 12 Sep 2007)
Log Message:
-----------
- Added "itunes_" prefix to structure names
- Initial attempt to support iTunes 7.4.1;
database dump appears to work
Modified Paths:
--------------
trunk/pmplib/lib/pmp_ipod/ipod.c
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-05-12 02:26:41 UTC (rev 408)
+++ trunk/pmplib/lib/pmp_ipod/ipod.c 2007-09-12 14:25:36 UTC (rev 409)
@@ -290,7 +290,7 @@
{
int ret = 0;
itunesdb_chunk_t* mhod = NULL;
- chunk_mhit_t* mhit_data = (chunk_mhit_t*)mhit->data;
+ itunesdb_mhit_t* mhit_data = (itunesdb_mhit_t*)mhit->data;
mhit_data->uid = uid;
mhit_data->visible = 1;
@@ -418,7 +418,7 @@
uint32_t i;
int ret = 0;
itunesdb_chunk_t* mhod = NULL;
- chunk_mhit_t* mhit_data = (chunk_mhit_t*)mhit->data;
+ itunesdb_mhit_t* mhit_data = (itunesdb_mhit_t*)mhit->data;
switch (mhit_data->filetype) {
case 0x4D503320:
@@ -588,7 +588,7 @@
int i;
int ret = 0;
itunesdb_chunk_t *mhod = NULL, *mhip = NULL;
- chunk_mhyp_t* mhyp_data = (chunk_mhyp_t*)mhyp->data;
+ itunesdb_mhyp_t* mhyp_data = (itunesdb_mhyp_t*)mhyp->data;
sorted_index_t* si = (sorted_index_t*)calloc(num_records, sizeof(sorted_index_t));
const static ucs2char_t ucs2cs_master[] = {'M','a','s','t','e','r',0};
@@ -660,9 +660,9 @@
for (i = 0;i < num_records;++i) {
mhip = itunesdb_new_child(mhyp);
if (mhip) {
- chunk_mhip_t* mhip_data = NULL;
+ itunesdb_mhip_t* mhip_data = NULL;
if (ret = itunesdb_init(mhip, "mhip", NULL)) return ret;
- mhip_data = (chunk_mhip_t*)mhip->data;
+ mhip_data = (itunesdb_mhip_t*)mhip->data;
mhip_data->flag_podcast_group = 0;
mhip_data->track_id = i;
@@ -703,7 +703,7 @@
int i;
int ret = 0;
itunesdb_chunk_t *mhod = NULL, *mhip = NULL;
- chunk_mhyp_t* mhyp_data = (chunk_mhyp_t*)mhyp->data;
+ itunesdb_mhyp_t* mhyp_data = (itunesdb_mhyp_t*)mhyp->data;
mhyp_data->flag_master = 0;
mhyp_data->id = 0x7520EA5FA870F9EA;
@@ -728,9 +728,9 @@
if (index < num_records) {
mhip = itunesdb_new_child(mhyp);
if (mhip) {
- chunk_mhip_t* mhip_data = NULL;
+ itunesdb_mhip_t* mhip_data = NULL;
if (ret = itunesdb_init(mhip, "mhip", NULL)) return ret;
- mhip_data = (chunk_mhip_t*)mhip->data;
+ mhip_data = (itunesdb_mhip_t*)mhip->data;
mhip_data->flag_podcast_group = 0;
mhip_data->track_id = index;
@@ -769,7 +769,7 @@
itunesdb_chunk_t *mhbd = NULL, *mhsd = NULL;
itunesdb_chunk_t *mhlt = NULL, *mhit = NULL;
itunesdb_chunk_t *mhlp = NULL, *mhyp = NULL;
- chunk_mhbd_t* mhbd_data = NULL;
+ itunesdb_mhbd_t* mhbd_data = NULL;
/* Construct "mhbd" chunk. */
mhbd = (itunesdb_chunk_t*)calloc(1, sizeof(itunesdb_chunk_t));
@@ -777,14 +777,14 @@
return IPODE_FAILEDNEWCHUNK;
}
if (ret = itunesdb_init(mhbd, "mhbd", NULL)) return ret;
- mhbd_data = (chunk_mhbd_t*)mhbd->data;
+ mhbd_data = (itunesdb_mhbd_t*)mhbd->data;
/* Construct "mhsd" chunk with track type. */
mhsd = itunesdb_new_child(mhbd);
if (mhsd) {
- chunk_mhsd_t* mhsd_data = NULL;
+ itunesdb_mhsd_t* mhsd_data = NULL;
if (ret = itunesdb_init(mhsd, "mhsd", NULL)) return ret;
- mhsd_data = (chunk_mhsd_t*)mhsd->data;
+ mhsd_data = (itunesdb_mhsd_t*)mhsd->data;
mhsd_data->type = 1; /* track type. */
/* Construct "mhlt" chunk. */
@@ -817,9 +817,9 @@
/* Construct "mhsd" chunk with playlist type. */
mhsd = itunesdb_new_child(mhbd);
if (mhsd) {
- chunk_mhsd_t* mhsd_data = NULL;
+ itunesdb_mhsd_t* mhsd_data = NULL;
if (ret = itunesdb_init(mhsd, "mhsd", NULL)) return ret;
- mhsd_data = (chunk_mhsd_t*)mhsd->data;
+ mhsd_data = (itunesdb_mhsd_t*)mhsd->data;
mhsd_data->type = 2; /* playlist type. */
/* Construct "mhlp" chunk. */
@@ -830,7 +830,7 @@
/* Create a master playlist. */
mhyp = itunesdb_new_child(mhlp);
if (mhyp) {
- chunk_mhyp_t* mhyp_data = NULL;
+ itunesdb_mhyp_t* mhyp_data = NULL;
if (ret = itunesdb_init(mhyp, "mhyp", NULL)) return ret;
if (ret = set_master_playlist(mhyp, records, num_records)) return ret;
}
@@ -839,7 +839,7 @@
for (i = 0;i < num_playlists;++i) {
mhyp = itunesdb_new_child(mhlp);
if (mhyp) {
- chunk_mhyp_t* mhyp_data = NULL;
+ itunesdb_mhyp_t* mhyp_data = NULL;
if (ret = itunesdb_init(mhyp, "mhyp", NULL)) return ret;
if (ret = set_playlist(mhyp, &playlists[i], records, num_records)) return ret;
} else {
@@ -883,7 +883,7 @@
for (i = 0;i < mhbd->num_children;++i) {
mhsd = &mhbd->childlen[i];
if (mhsd && strncmp(mhsd->id, "mhsd", 4) == 0) {
- chunk_mhsd_t* mhsd_data = (chunk_mhsd_t*)mhsd->data;
+ itunesdb_mhsd_t* mhsd_data = (itunesdb_mhsd_t*)mhsd->data;
if (mhsd_data->type == 1) {
/* Track list. */
for (j = 0;j < mhsd->num_children;++j) {
Modified: trunk/pmplib/lib/pmp_ipod/itunesdb.c
===================================================================
--- trunk/pmplib/lib/pmp_ipod/itunesdb.c 2007-05-12 02:26:41 UTC (rev 408)
+++ trunk/pmplib/lib/pmp_ipod/itunesdb.c 2007-09-12 14:25:36 UTC (rev 409)
@@ -50,7 +50,7 @@
static int mhbd_init(itunesdb_chunk_t* chunk, int def)
{
- chunk_mhbd_t* mhbd = NULL;
+ itunesdb_mhbd_t* mhbd = NULL;
if (def) {
memset(chunk, 0, sizeof(*chunk));
@@ -59,7 +59,7 @@
chunk->overall_size = 0; /* to be filled */
}
- mhbd = (chunk_mhbd_t*)calloc(1, sizeof(chunk_mhbd_t));
+ mhbd = (itunesdb_mhbd_t*)calloc(1, sizeof(itunesdb_mhbd_t));
if (def && mhbd) {
mhbd->unknown1 = 1;
mhbd->version = 0x13; /* iTunes 7 */
@@ -78,7 +78,7 @@
static int mhbd_serialize(itunesdb_chunk_t* chunk, serializer_t* sio)
{
int ret = 0;
- chunk_mhbd_t* mhbd = (chunk_mhbd_t*)chunk->data;
+ itunesdb_mhbd_t* mhbd = (itunesdb_mhbd_t*)chunk->data;
if (ret = serialize_uint32le(sio, "unknown1", "%d", &mhbd->unknown1)) return ret;
if (ret = serialize_uint32le(sio, "version", "%d", &mhbd->version)) return ret;
@@ -97,7 +97,7 @@
static mhsd_init(itunesdb_chunk_t* chunk, int def)
{
- chunk_mhsd_t* mhsd = NULL;
+ itunesdb_mhsd_t* mhsd = NULL;
if (def) {
memset(chunk, 0, sizeof(*chunk));
@@ -106,7 +106,7 @@
chunk->overall_size = 0; /* to be filled */
}
- mhsd = (chunk_mhsd_t*)calloc(1, sizeof(chunk_mhsd_t));
+ mhsd = (itunesdb_mhsd_t*)calloc(1, sizeof(itunesdb_mhsd_t));
if (mhsd && def) {
mhsd->type = 0; /* to be filled */
}
@@ -118,7 +118,7 @@
static int mhsd_serialize(itunesdb_chunk_t* chunk, serializer_t* sio)
{
int ret = 0;
- chunk_mhsd_t* mhsd = (chunk_mhsd_t*)chunk->data;
+ itunesdb_mhsd_t* mhsd = (itunesdb_mhsd_t*)chunk->data;
if (ret = serialize_uint32le(sio, "type", "%d", &mhsd->type)) return ret;
@@ -127,9 +127,68 @@
+static mhla_init(itunesdb_chunk_t* chunk, int def)
+{
+ itunesdb_mhla_t* mhla = NULL;
+
+ if (def) {
+ memset(chunk, 0, sizeof(*chunk));
+ strncpy(chunk->id, "mhla", 4);
+ chunk->size = 92;
+ chunk->overall_size = 0; /* to be filled */
+ }
+ mhla = (itunesdb_mhla_t*)calloc(1, sizeof(itunesdb_mhla_t));
+
+ chunk->data = mhla;
+ return mhla ? 0 : IPODE_OUTOFMEMORY;
+}
+
+static int mhla_serialize(itunesdb_chunk_t* chunk, serializer_t* sio)
+{
+ int ret = 0;
+ itunesdb_mhla_t* mhla = (itunesdb_mhla_t*)chunk->data;
+
+ if (ret = serialize_uint8(sio, "unknown", "%02X", &mhla->unknown)) return ret;
+
+ return 0;
+}
+
+
+
+static mhia_init(itunesdb_chunk_t* chunk, int def)
+{
+ itunesdb_mhia_t* mhia = NULL;
+
+ if (def) {
+ memset(chunk, 0, sizeof(*chunk));
+ strncpy(chunk->id, "mhia", 4);
+ chunk->size = 88;
+ chunk->overall_size = 0; /* to be filled */
+ }
+ mhia = (itunesdb_mhia_t*)calloc(1, sizeof(itunesdb_mhia_t));
+
+ chunk->data = mhia;
+ return mhia ? 0 : IPODE_OUTOFMEMORY;
+}
+
+static int mhia_serialize(itunesdb_chunk_t* chunk, serializer_t* sio)
+{
+ int ret = 0;
+ itunesdb_mhia_t* mhia = (itunesdb_mhia_t*)chunk->data;
+
+ if (ret = serialize_uint32le(sio, "num_children", "%u", &mhia->num_children)) return ret;
+ if (ret = serialize_uint32le(sio, "album_id", "%u", &mhia->album_id)) return ret;
+ if (ret = serialize_uint64le(sio, "timestamp", "%u", &mhia->timestamp)) return ret;
+ if (ret = serialize_uint32le(sio, "unknown1", "%u", &mhia->unknown1)) return ret;
+
+ return 0;
+}
+
+
+
static mhlt_init(itunesdb_chunk_t* chunk, int def)
{
- chunk_mhlt_t* mhlt = NULL;
+ itunesdb_mhlt_t* mhlt = NULL;
if (def) {
memset(chunk, 0, sizeof(*chunk));
@@ -137,7 +196,7 @@
chunk->size = 92;
chunk->overall_size = 0; /* to be filled */
}
- mhlt = (chunk_mhlt_t*)calloc(1, sizeof(chunk_mhlt_t));
+ mhlt = (itunesdb_mhlt_t*)calloc(1, sizeof(itunesdb_mhlt_t));
chunk->data = mhlt;
return mhlt ? 0 : IPODE_OUTOFMEMORY;
@@ -146,7 +205,7 @@
static int mhlt_serialize(itunesdb_chunk_t* chunk, serializer_t* sio)
{
int ret = 0;
- chunk_mhlt_t* mhlt = (chunk_mhlt_t*)chunk->data;
+ itunesdb_mhlt_t* mhlt = (itunesdb_mhlt_t*)chunk->data;
if (ret = serialize_uint8(sio, "unknown", "%02X", &mhlt->unknown)) return ret;
@@ -157,7 +216,7 @@
static mhit_init(itunesdb_chunk_t* chunk, int def)
{
- chunk_mhit_t* mhit = NULL;
+ itunesdb_mhit_t* mhit = NULL;
if (def) {
memset(chunk, 0, sizeof(*chunk));
@@ -166,7 +225,7 @@
chunk->overall_size = 0; /* to be filled */
}
- mhit = (chunk_mhit_t*)calloc(1, sizeof(chunk_mhit_t));
+ mhit = (itunesdb_mhit_t*)calloc(1, sizeof(itunesdb_mhit_t));
if (mhit && def) {
mhit->visible = 1; /* visible by default */
/* other fields to be filled later */
@@ -179,7 +238,7 @@
static int mhit_serialize(itunesdb_chunk_t* chunk, serializer_t* sio)
{
int ret = 0;
- chunk_mhit_t* mhit = (chunk_mhit_t*)chunk->data;
+ itunesdb_mhit_t* mhit = (itunesdb_mhit_t*)chunk->data;
if (ret = serialize_uint32le(sio, "num_children", "%u", &mhit->num_children)) return ret;
if (ret = serialize_uint32le(sio, "uid", "%u", &mhit->uid)) return ret;
@@ -263,7 +322,7 @@
static mhlp_init(itunesdb_chunk_t* chunk, int def)
{
- chunk_mhlp_t* mhlp = NULL;
+ itunesdb_mhlp_t* mhlp = NULL;
if (def) {
memset(chunk, 0, sizeof(*chunk));
@@ -272,7 +331,7 @@
chunk->overall_size = 0; /* to be filled */
}
- mhlp = (chunk_mhlp_t*)calloc(1, sizeof(chunk_mhlp_t));
+ mhlp = (itunesdb_mhlp_t*)calloc(1, sizeof(itunesdb_mhlp_t));
chunk->data = mhlp;
return mhlp ? 0 : IPODE_OUTOFMEMORY;
}
@@ -280,7 +339,7 @@
static int mhlp_serialize(itunesdb_chunk_t* chunk, serializer_t* sio)
{
int ret = 0;
- chunk_mhlp_t* mhlp = (chunk_mhlp_t*)chunk->data;
+ itunesdb_mhlp_t* mhlp = (itunesdb_mhlp_t*)chunk->data;
if (ret = serialize_uint8(sio, "unknown", "%02X", &mhlp->unknown)) return ret;
@@ -291,7 +350,7 @@
static mhyp_init(itunesdb_chunk_t* chunk, int def)
{
- chunk_mhyp_t* mhyp = NULL;
+ itunesdb_mhyp_t* mhyp = NULL;
if (def) {
memset(chunk, 0, sizeof(*chunk));
@@ -300,7 +359,7 @@
chunk->overall_size = 0; /* to be filled */
}
- mhyp = (chunk_mhyp_t*)calloc(1, sizeof(chunk_mhyp_t));
+ mhyp = (itunesdb_mhyp_t*)calloc(1, sizeof(itunesdb_mhyp_t));
chunk->data = mhyp;
return mhyp ? 0 : IPODE_OUTOFMEMORY;
}
@@ -308,7 +367,7 @@
static int mhyp_serialize(itunesdb_chunk_t* chunk, serializer_t* sio)
{
int ret = 0;
- chunk_mhyp_t* mhyp = (chunk_mhyp_t*)chunk->data;
+ itunesdb_mhyp_t* mhyp = (itunesdb_mhyp_t*)chunk->data;
if (ret = serialize_uint32le(sio, "num_mhod", "%u", &mhyp->num_mhod)) return ret;
if (ret = serialize_uint32le(sio, "num_mhip", "%u", &mhyp->num_mhip)) return ret;
@@ -330,7 +389,7 @@
static mhip_init(itunesdb_chunk_t* chunk, int def)
{
- chunk_mhip_t* mhip = NULL;
+ itunesdb_mhip_t* mhip = NULL;
if (def) {
memset(chunk, 0, sizeof(*chunk));
@@ -339,7 +398,7 @@
chunk->overall_size = 0; /* to be filled */
}
- mhip = (chunk_mhip_t*)calloc(1, sizeof(chunk_mhip_t));
+ mhip = (itunesdb_mhip_t*)calloc(1, sizeof(itunesdb_mhip_t));
chunk->data = mhip;
return mhip ? 0 : IPODE_OUTOFMEMORY;
}
@@ -347,7 +406,7 @@
static int mhip_serialize(itunesdb_chunk_t* chunk, serializer_t* sio)
{
int ret = 0;
- chunk_mhip_t* mhip = (chunk_mhip_t*)chunk->data;
+ itunesdb_mhip_t* mhip = (itunesdb_mhip_t*)chunk->data;
if (ret = serialize_uint32le(sio, "num_mhod", "%u", &mhip->num_mhod)) return ret;
if (ret = serialize_uint32le(sio, "flag_podcast_group", "%X", &mhip->flag_podcast_group)) return ret;
@@ -363,8 +422,8 @@
static void mhod_string_finish(itunesdb_chunk_t* chunk)
{
- chunk_mhod_t* mhod = (chunk_mhod_t*)chunk->data;
- chunk_mhod_string_t* string = &mhod->data.str;
+ itunesdb_mhod_t* mhod = (itunesdb_mhod_t*)chunk->data;
+ itunesdb_mhod_string_t* string = &mhod->data.str;
ucs2free(string->value);
memset(string, 0, sizeof(*string));
}
@@ -372,7 +431,7 @@
static int mhod_string_serialize(itunesdb_chunk_t* chunk, const char *name, serializer_t* sio)
{
int ret = 0;
- chunk_mhod_string_t* string = &((chunk_mhod_t*)chunk->data)->data.str;
+ itunesdb_mhod_string_t* string = &((itunesdb_mhod_t*)chunk->data)->data.str;
if (ret = serialize_uint32le(sio, "position", "%u", &string->position)) return ret;
if (ret = serialize_uint32le(sio, "size", "%u", &string->size)) return ret;
@@ -385,8 +444,8 @@
static void mhod_url_finish(itunesdb_chunk_t* chunk)
{
- chunk_mhod_t* mhod = (chunk_mhod_t*)chunk->data;
- chunk_mhod_url_t* url = &mhod->data.url;
+ itunesdb_mhod_t* mhod = (itunesdb_mhod_t*)chunk->data;
+ itunesdb_mhod_url_t* url = &mhod->data.url;
ucs2free(url->value);
memset(url, 0, sizeof(*url));
}
@@ -394,8 +453,8 @@
static int mhod_url_serialize(itunesdb_chunk_t* chunk, const char *name, serializer_t* sio)
{
int ret = 0;
- chunk_mhod_t* mhod = (chunk_mhod_t*)chunk->data;
- chunk_mhod_url_t* url = &mhod->data.url;
+ itunesdb_mhod_t* mhod = (itunesdb_mhod_t*)chunk->data;
+ itunesdb_mhod_url_t* url = &mhod->data.url;
if (ret = serialize_utf8str_fixed(sio, name, "%s", &url->value, chunk->size - chunk->overall_size)) return ret;
@@ -404,8 +463,8 @@
static void mhod_index_finish(itunesdb_chunk_t* chunk)
{
- chunk_mhod_t* mhod = (chunk_mhod_t*)chunk->data;
- chunk_mhod_index_t* index = &mhod->data.index;
+ itunesdb_mhod_t* mhod = (itunesdb_mhod_t*)chunk->data;
+ itunesdb_mhod_index_t* index = &mhod->data.index;
ucs2free(index->entries);
memset(index, 0, sizeof(*index));
}
@@ -414,8 +473,8 @@
{
uint32_t i;
int ret = 0;
- chunk_mhod_t* mhod = (chunk_mhod_t*)chunk->data;
- chunk_mhod_index_t* index = &mhod->data.index;
+ itunesdb_mhod_t* mhod = (itunesdb_mhod_t*)chunk->data;
+ itunesdb_mhod_index_t* index = &mhod->data.index;
if (ret = serialize_uint32le(sio, "type", "%u", &index->type)) return ret;
if (ret = serialize_uint32le(sio, "num_entries", "%u", &index->num_entries)) return ret;
@@ -438,10 +497,54 @@
return 0;
}
+static void mhod_library_playlist_index_finish(itunesdb_chunk_t* chunk)
+{
+ itunesdb_mhod_t* mhod = (itunesdb_mhod_t*)chunk->data;
+ itunesdb_mhod_library_playlist_index_t* lp_index = &mhod->data.lp_index;
+ ucs2free(lp_index->entries);
+ memset(lp_index, 0, sizeof(*lp_index));
+}
+
+static int mhod_library_playlist_index_serialize(itunesdb_chunk_t* chunk, const char *name, serializer_t* sio)
+{
+ uint32_t i;
+ int ret = 0;
+ itunesdb_mhod_t* mhod = (itunesdb_mhod_t*)chunk->data;
+ itunesdb_mhod_library_playlist_index_t* lp_index = &mhod->data.lp_index;
+
+ if (ret = serialize_uint32le(sio, "type", "%u", &lp_index->type)) return ret;
+ if (ret = serialize_uint32le(sio, "num_entries", "%u", &lp_index->num_entries)) return ret;
+ if (ret = serialize_uint32le(sio, "unknown1", "%u", &lp_index->unknown1)) return ret;
+ if (ret = serialize_uint32le(sio, "unknown2", "%u", &lp_index->unknown2)) return ret;
+
+ /* Allocate array when reading. */
+ if (serialize_reading(sio)) {
+ lp_index->entries = calloc(
+ lp_index->num_entries,
+ sizeof(itunesdb_mhod_library_playlist_entry_t)
+ );
+ if (!lp_index->entries) {
+ return IPODE_OUTOFMEMORY;
+ }
+ }
+
+ 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;
+ }
+
+ return 0;
+}
+
static void mhod_playlist_column_finish(itunesdb_chunk_t* chunk)
{
- chunk_mhod_t* mhod = (chunk_mhod_t*)chunk->data;
- chunk_mhod_playlist_column_t* pc = &mhod->data.pc;
+ itunesdb_mhod_t* mhod = (itunesdb_mhod_t*)chunk->data;
+ itunesdb_mhod_playlist_column_t* pc = &mhod->data.pc;
ucs2free(pc->columns);
memset(pc, 0, sizeof(*pc));
}
@@ -450,8 +553,8 @@
{
uint32_t i;
int ret = 0;
- chunk_mhod_t* mhod = (chunk_mhod_t*)chunk->data;
- chunk_mhod_playlist_column_t* pc = &mhod->data.pc;
+ itunesdb_mhod_t* mhod = (itunesdb_mhod_t*)chunk->data;
+ itunesdb_mhod_playlist_column_t* pc = &mhod->data.pc;
if (ret = serialize_uint32le(sio, "unk3", "%u", &pc->unk3)) return ret;
if (ret = serialize_uint64le(sio, "unk4", "%016llX", &pc->unk4)) return ret;
@@ -464,8 +567,8 @@
/* Allocate array when reading. */
if (serialize_reading(sio)) {
- pc->columns = (chunk_mhod_playlist_column_definition_t*)calloc(
- pc->num_columns, sizeof(chunk_mhod_playlist_column_definition_t));
+ pc->columns = (itunesdb_mhod_playlist_column_definition_t*)calloc(
+ pc->num_columns, sizeof(itunesdb_mhod_playlist_column_definition_t));
if (!pc->columns) {
return IPODE_OUTOFMEMORY;
}
@@ -473,7 +576,7 @@
for (i = 0;i < pc->num_columns;++i) {
char fieldname[128];
- chunk_mhod_playlist_column_definition_t* def = &pc->columns[i];
+ itunesdb_mhod_playlist_column_definition_t* def = &pc->columns[i];
sprintf(fieldname, "columns[%d].id", i);
if (ret = serialize_uint16le(sio, fieldname, "%u", &def->id)) return ret;
@@ -490,16 +593,16 @@
static void mhod_playlist_order_finish(itunesdb_chunk_t* chunk)
{
- chunk_mhod_t* mhod = (chunk_mhod_t*)chunk->data;
- chunk_mhod_playlist_order_t* po = &mhod->data.po;
+ itunesdb_mhod_t* mhod = (itunesdb_mhod_t*)chunk->data;
+ itunesdb_mhod_playlist_order_t* po = &mhod->data.po;
memset(po, 0, sizeof(*po));
}
static int mhod_playlist_order_serialize(itunesdb_chunk_t* chunk, const char *name, serializer_t* sio)
{
int ret = 0;
- chunk_mhod_t* mhod = (chunk_mhod_t*)chunk->data;
- chunk_mhod_playlist_order_t* po = &mhod->data.po;
+ itunesdb_mhod_t* mhod = (itunesdb_mhod_t*)chunk->data;
+ itunesdb_mhod_playlist_order_t* po = &mhod->data.po;
if (ret = serialize_uint32le(sio, "position", "%u", &po->position)) return ret;
if (ret = serialize_uint8_array(sio, "unknown", "%02X ", po->unknown, sizeof(po->unknown))) return ret;
@@ -522,16 +625,24 @@
{14, "description", 0, mhod_string_finish, mhod_string_serialize},
{15, "podcast_enclosure_url", 0, mhod_url_finish, mhod_url_serialize},
{16, "podcast_rss_url", 0, mhod_url_finish, mhod_url_serialize},
+ {27, "sort_title", 0, mhod_string_finish, mhod_string_serialize},
+ {28, "sort_album", 0, mhod_string_finish, mhod_string_serialize},
+ {29, "sort_albumartist", 0, mhod_string_finish, mhod_string_serialize},
+ {30, "sort_composer", 0, mhod_string_finish, mhod_string_serialize},
{52, "index", 0, mhod_index_finish, mhod_index_serialize},
+ {53, "library_playlist_index", 0, mhod_library_playlist_index_finish, mhod_library_playlist_index_serialize},
{100, "playlist_column", 0x288, mhod_playlist_column_finish, mhod_playlist_column_serialize},
{100, "playlist_order", 0x2C, mhod_playlist_order_finish, mhod_playlist_order_serialize},
+ {200, "album_albumlist", 0, mhod_string_finish, mhod_string_serialize},
+ {201, "artist_albumlist", 0, mhod_string_finish, mhod_string_serialize},
+ {202, "sort_artist_albumlist", 0, mhod_string_finish, mhod_string_serialize},
{0, NULL, 0, NULL},
};
static const itunesdb_mhoddecl_t* find_mhoddecl(itunesdb_chunk_t* chunk)
{
const itunesdb_mhoddecl_t* decl = mds;
- chunk_mhod_t* mhod = (chunk_mhod_t*)chunk->data;
+ itunesdb_mhod_t* mhod = (itunesdb_mhod_t*)chunk->data;
while (decl->name) {
if (decl->type == mhod->type) {
@@ -565,13 +676,13 @@
chunk->size = 24;
chunk->overall_size = chunk->size;
}
- chunk->data = calloc(1, sizeof(chunk_mhod_t));
+ chunk->data = calloc(1, sizeof(itunesdb_mhod_t));
return chunk->data ? 0 : IPODE_OUTOFMEMORY;
}
static void mhod_finish(itunesdb_chunk_t* chunk)
{
- chunk_mhod_t* mhod = (chunk_mhod_t*)chunk->data;
+ itunesdb_mhod_t* mhod = (itunesdb_mhod_t*)chunk->data;
const itunesdb_mhoddecl_t* decl = NULL;
decl = find_mhoddecl(chunk);
if (decl) {
@@ -583,7 +694,7 @@
static int mhod_serialize(itunesdb_chunk_t* chunk, serializer_t* sio)
{
int ret = 0;
- chunk_mhod_t* mhod = (chunk_mhod_t*)chunk->data;
+ itunesdb_mhod_t* mhod = (itunesdb_mhod_t*)chunk->data;
const itunesdb_mhoddecl_t* decl = NULL;
if (ret = serialize_uint32le(sio, "type", "%u", &mhod->type)) return ret;
@@ -609,6 +720,8 @@
static const itunesdb_chunkdecl_t cds[] = {
{"mhbd", mhbd_init, chunk_finish, mhbd_serialize},
{"mhsd", mhsd_init, chunk_finish, mhsd_serialize},
+ {"mhla", mhla_init, chunk_finish, mhla_serialize},
+ {"mhia", mhia_init, chunk_finish, mhia_serialize},
{"mhlt", mhlt_init, chunk_finish, mhlt_serialize},
{"mhit", mhit_init, chunk_finish, mhit_serialize},
{"mhlp", mhlp_init, chunk_finish, mhlp_serialize},
@@ -638,7 +751,7 @@
if (ret = decl->init(chunk, 1)) return ret;
if (strncmp(name, "mhod", 4) == 0) {
- chunk_mhod_t* mhod = (chunk_mhod_t*)chunk->data;
+ itunesdb_mhod_t* mhod = (itunesdb_mhod_t*)chunk->data;
const itunesdb_mhoddecl_t* decl2 = find_mhoddecl_by_name(subtype);
if (!decl2) {
decl->finish(chunk);
@@ -653,7 +766,7 @@
int itunesdb_ischunk(itunesdb_chunk_t* chunk, const char *name, const char *subtype)
{
if (strncmp(name, "mhod", 4) == 0) {
- chunk_mhod_t* mhod = (chunk_mhod_t*)chunk->data;
+ itunesdb_mhod_t* mhod = (itunesdb_mhod_t*)chunk->data;
const itunesdb_mhoddecl_t* decl = find_mhoddecl(chunk);
return (decl && strcmp(decl->name, subtype) == 0) ? 1 : 0;
} else {
@@ -875,8 +988,8 @@
int itunesdb_set_mhod_string(itunesdb_chunk_t* chunk, const ucs2char_t* value)
{
- chunk_mhod_t* mhod = (chunk_mhod_t*)chunk->data;
- chunk_mhod_string_t* str = &mhod->data.str;
+ itunesdb_mhod_t* mhod = (itunesdb_mhod_t*)chunk->data;
+ itunesdb_mhod_string_t* str = &mhod->data.str;
/* Make sure this is an "mhod" chunk. */
if (strncmp(chunk->id, "mhod", 4) != 0) {
@@ -896,8 +1009,8 @@
int itunesdb_get_mhod_string(itunesdb_chunk_t* chunk, ucs2char_t** value)
{
- chunk_mhod_t* mhod = (chunk_mhod_t*)chunk->data;
- chunk_mhod_string_t* str = &mhod->data.str;
+ itunesdb_mhod_t* mhod = (itunesdb_mhod_t*)chunk->data;
+ itunesdb_mhod_string_t* str = &mhod->data.str;
/* Make sure this is an "mhod" chunk. */
if (strncmp(chunk->id, "mhod", 4) != 0) {
@@ -915,8 +1028,8 @@
int itunesdb_set_mhod_index(itunesdb_chunk_t* chunk, uint32_t type, sorted_index_t* si, uint32_t n)
{
uint32_t i;
- chunk_mhod_t* mhod = (chunk_mhod_t*)chunk->data;
- chunk_mhod_index_t* index = &mhod->data.index;
+ itunesdb_mhod_t* mhod = (itunesdb_mhod_t*)chunk->data;
+ itunesdb_mhod_index_t* index = &mhod->data.index;
/* Make sure this is an "mhod" chunk. */
if (strncmp(chunk->id, "mhod", 4) != 0) {
@@ -938,8 +1051,8 @@
int itunesdb_set_mhod_playlist_order(itunesdb_chunk_t* chunk, uint32_t order)
{
- chunk_mhod_t* mhod = (chunk_mhod_t*)chunk->data;
- chunk_mhod_playlist_order_t* po = &mhod->data.po;
+ itunesdb_mhod_t* mhod = (itunesdb_mhod_t*)chunk->data;
+ itunesdb_mhod_playlist_order_t* po = &mhod->data.po;
/* Make sure this is an "mhod" chunk. */
if (strncmp(chunk->id, "mhod", 4) != 0) {
Modified: trunk/pmplib/lib/pmp_ipod/itunesdb.h
===================================================================
--- trunk/pmplib/lib/pmp_ipod/itunesdb.h 2007-05-12 02:26:41 UTC (rev 408)
+++ trunk/pmplib/lib/pmp_ipod/itunesdb.h 2007-09-12 14:25:36 UTC (rev 409)
@@ -34,15 +34,26 @@
uint64_t unknown4;
uint8_t unknown5[26]; /* zero padded. */
uint8_t language[2]; /* e.g., "en", "ja" */
-} chunk_mhbd_t;
+} itunesdb_mhbd_t;
typedef struct {
uint32_t type; /* 1 (track list), 2 (playlist list), or 3 (podcast list). */
-} chunk_mhsd_t;
+} itunesdb_mhsd_t;
typedef struct {
+ uint8_t unknown; /* Zero padded. */
+} itunesdb_mhla_t;
+
+typedef struct {
+ uint32_t num_children;
+ uint32_t album_id;
+ uint64_t timestamp;
+ uint32_t unknown1;
+} itunesdb_mhia_t;
+
+typedef struct {
uint8_t unknown; /* zero padded. */
-} chunk_mhlt_t;
+} itunesdb_mhlt_t;
typedef struct {
uint32_t num_children;
@@ -119,11 +130,11 @@
uint32_t unk38;
uint16_t gapless_track;
uint16_t gapless_album;
-} chunk_mhit_t;
+} itunesdb_mhit_t;
typedef struct {
uint8_t unknown; /* zero padded. */
-} chunk_mhlp_t;
+} itunesdb_mhlp_t;
typedef struct {
uint32_t num_mhod;
@@ -138,7 +149,7 @@
uint16_t unk4;
uint16_t flag_podcast;
uint32_t sort_order;
-} chunk_mhyp_t;
+} itunesdb_mhyp_t;
typedef struct {
uint32_t num_mhod;
@@ -147,7 +158,7 @@
uint32_t track_id;
uint32_t timestamp;
uint32_t podcast_parent;
-} chunk_mhip_t;
+} itunesdb_mhip_t;
typedef struct {
uint32_t position;
@@ -155,25 +166,25 @@
uint32_t unknown;
uint32_t unk4;
ucs2char_t* value;
-} chunk_mhod_string_t;
+} itunesdb_mhod_string_t;
typedef struct {
char* value;
-} chunk_mhod_url_t;
+} itunesdb_mhod_url_t;
typedef struct {
uint32_t type;
uint32_t num_entries;
uint8_t padding[40];
uint32_t* entries;
-} chunk_mhod_index_t;
+} itunesdb_mhod_index_t;
typedef struct {
uint16_t id;
uint16_t width;
uint32_t sort_direction;
uint64_t padding;
-} chunk_mhod_playlist_column_definition_t;
+} itunesdb_mhod_playlist_column_definition_t;
typedef struct {
uint32_t unk1;
@@ -186,26 +197,41 @@
uint32_t sort_type;
uint32_t num_columns;
uint32_t unknown;
- chunk_mhod_playlist_column_definition_t* columns;
-} chunk_mhod_playlist_column_t;
+ itunesdb_mhod_playlist_column_definition_t* columns;
+} itunesdb_mhod_playlist_column_t;
typedef struct {
+ uint32_t unknown1;
+ uint32_t unknown2;
+ uint32_t unknown3;
+} itunesdb_mhod_library_playlist_entry_t;
+
+typedef struct {
+ uint32_t type;
+ uint32_t num_entries;
+ uint32_t unknown1;
+ uint32_t unknown2;
+ itunesdb_mhod_library_playlist_entry_t *entries;
+} itunesdb_mhod_library_playlist_index_t;
+
+typedef struct {
uint32_t position;
uint8_t unknown[16];
-} chunk_mhod_playlist_order_t;
+} itunesdb_mhod_playlist_order_t;
typedef struct {
uint32_t type;
uint32_t unk1;
uint32_t unk2;
union {
- chunk_mhod_string_t str;
- chunk_mhod_url_t url;
- chunk_mhod_index_t index;
- chunk_mhod_playlist_column_t pc;
- chunk_mhod_playlist_order_t po;
+ itunesdb_mhod_string_t str;
+ itunesdb_mhod_url_t url;
+ itunesdb_mhod_index_t index;
+ itunesdb_mhod_playlist_column_t pc;
+ itunesdb_mhod_playlist_order_t po;
+ itunesdb_mhod_library_playlist_index_t lp_index;
} data;
-} chunk_mhod_t;
+} itunesdb_mhod_t;
struct tag_itunesdb_chunk {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ny...@us...> - 2007-05-12 02:26:40
|
Revision: 408
http://svn.sourceforge.net/pmplib/?rev=408&view=rev
Author: nyaochi
Date: 2007-05-11 19:26:41 -0700 (Fri, 11 May 2007)
Log Message:
-----------
- Make easypmp_cui work again on Win32 environments.
- Minor bug fix.
Modified Paths:
--------------
trunk/pmplib/frontend/easypmp/cui/easypmp_cui.vcproj
trunk/pmplib/lib/gmi/gmi.vcproj
trunk/pmplib/lib/pmp_ipod/ipod.c
trunk/pmplib/lib/pmp_ipod/pmp_ipod.vcproj
Added Paths:
-----------
trunk/pmplib/include/win32/
trunk/pmplib/include/win32/config.h
Modified: trunk/pmplib/frontend/easypmp/cui/easypmp_cui.vcproj
===================================================================
--- trunk/pmplib/frontend/easypmp/cui/easypmp_cui.vcproj 2007-05-12 01:28:22 UTC (rev 407)
+++ trunk/pmplib/frontend/easypmp/cui/easypmp_cui.vcproj 2007-05-12 02:26:41 UTC (rev 408)
@@ -41,8 +41,8 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
- AdditionalIncludeDirectories="$(SolutionDir)include,..\common"
- PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ AdditionalIncludeDirectories="$(SolutionDir)include\win32,$(SolutionDir)include,..\common"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_H"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
@@ -119,8 +119,8 @@
/>
<Tool
Name="VCCLCompilerTool"
- AdditionalIncludeDirectories="$(SolutionDir)include,..\common"
- PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ AdditionalIncludeDirectories="$(SolutionDir)include\win32,$(SolutionDir)include,..\common"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;HAVE_CONFIG_H"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
WarningLevel="3"
Added: trunk/pmplib/include/win32/config.h
===================================================================
--- trunk/pmplib/include/win32/config.h (rev 0)
+++ trunk/pmplib/include/win32/config.h 2007-05-12 02:26:41 UTC (rev 408)
@@ -0,0 +1,6 @@
+#ifndef __CONFIG_H__
+#define __CONFIG_H__
+
+#define HAVE_MP4V2 1
+
+#endif/*__CONFIG_H__*/
Property changes on: trunk/pmplib/include/win32/config.h
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Modified: trunk/pmplib/lib/gmi/gmi.vcproj
===================================================================
--- trunk/pmplib/lib/gmi/gmi.vcproj 2007-05-12 01:28:22 UTC (rev 407)
+++ trunk/pmplib/lib/gmi/gmi.vcproj 2007-05-12 02:26:41 UTC (rev 408)
@@ -41,8 +41,8 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
- AdditionalIncludeDirectories="$(SolutionDir)include,contrib,contrib\id3tag,contrib\mp4v2"
- PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;GMI_EXPORTS"
+ AdditionalIncludeDirectories="$(SolutionDir)include\win32,$(SolutionDir)include,contrib,contrib\id3tag,contrib\mp4v2"
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;GMI_EXPORTS;HAVE_CONFIG_H"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
@@ -121,8 +121,8 @@
/>
<Tool
Name="VCCLCompilerTool"
- AdditionalIncludeDirectories="$(SolutionDir)include,contrib,contrib\id3tag"
- PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;GMI_EXPORTS"
+ AdditionalIncludeDirectories="$(SolutionDir)include\win32,$(SolutionDir)include,contrib,contrib\id3tag,contrib\mp4v2"
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;GMI_EXPORTS;HAVE_CONFIG_H"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
WarningLevel="3"
@@ -140,7 +140,7 @@
/>
<Tool
Name="VCLinkerTool"
- AdditionalDependencies=".\contrib\id3tag\win32\libid3tag.lib .\contrib\id3tag\win32\zlib.lib .\contrib\ogg\win32\ogg_static.lib .\contrib\vorbis\win32\vorbis_static.lib .\contrib\vorbis\win32\vorbisfile_static.lib"
+ AdditionalDependencies=".\contrib\id3tag\win32\libid3tag.lib .\contrib\id3tag\win32\zlib.lib .\contrib\ogg\win32\ogg_static.lib .\contrib\vorbis\win32\vorbis_static.lib .\contrib\vorbis\win32\vorbisfile_static.lib .\contrib\mp4v2\win32\libmp4v260.lib"
OutputFile="$(OutDir)/gmi.dll"
LinkIncremental="1"
GenerateDebugInformation="true"
Modified: trunk/pmplib/lib/pmp_ipod/ipod.c
===================================================================
--- trunk/pmplib/lib/pmp_ipod/ipod.c 2007-05-12 01:28:22 UTC (rev 407)
+++ trunk/pmplib/lib/pmp_ipod/ipod.c 2007-05-12 02:26:41 UTC (rev 408)
@@ -659,7 +659,7 @@
/* */
for (i = 0;i < num_records;++i) {
mhip = itunesdb_new_child(mhyp);
- if (!mhip) {
+ if (mhip) {
chunk_mhip_t* mhip_data = NULL;
if (ret = itunesdb_init(mhip, "mhip", NULL)) return ret;
mhip_data = (chunk_mhip_t*)mhip->data;
Modified: trunk/pmplib/lib/pmp_ipod/pmp_ipod.vcproj
===================================================================
--- trunk/pmplib/lib/pmp_ipod/pmp_ipod.vcproj 2007-05-12 01:28:22 UTC (rev 407)
+++ trunk/pmplib/lib/pmp_ipod/pmp_ipod.vcproj 2007-05-12 02:26:41 UTC (rev 408)
@@ -136,6 +136,7 @@
/>
<Tool
Name="VCLinkerTool"
+ AdditionalDependencies=".\win32spti\ipodprop_win32spti.lib shlwapi.lib"
LinkIncremental="1"
GenerateDebugInformation="true"
SubSystem="2"
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ny...@us...> - 2007-05-12 01:28:20
|
Revision: 407
http://svn.sourceforge.net/pmplib/?rev=407&view=rev
Author: nyaochi
Date: 2007-05-11 18:28:22 -0700 (Fri, 11 May 2007)
Log Message:
-----------
Added a missing file.
Added Paths:
-----------
trunk/pmplib/lib/pmp_ipod/status.h
Added: trunk/pmplib/lib/pmp_ipod/status.h
===================================================================
--- trunk/pmplib/lib/pmp_ipod/status.h (rev 0)
+++ trunk/pmplib/lib/pmp_ipod/status.h 2007-05-12 01:28:22 UTC (rev 407)
@@ -0,0 +1,51 @@
+/*
+ * Status/error handling.
+ *
+ * Copyright (c) 2005-2007 Naoaki Okazaki
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+/* $Id:$ */
+
+#ifndef __STATUS_H__
+#define __STATUS_H__
+
+enum {
+ IPODS_SUCCESS = 0,
+ IPODS_OUTOFLIMITTER,
+ IPODC_NONE = 0x00010000,
+ IPODC_ITUNESDB,
+ IPODC_PLAYCOUNTS,
+ IPODE_ERROR = 0x01000000,
+ IPODE_OUTOFMEMORY,
+ IPODE_OUTOFBUFFER,
+ IPODE_FILEOPENFORREAD,
+ IPODE_FILEOPENFORWRITE,
+ IPODE_FILEREADERROR,
+ IPODE_FILEWRITEERROR,
+ IPODE_FILESEEKERROR,
+ IPODE_UNKNOWNCHUNK,
+ IPODE_UNKNOWNSUBTYPE,
+ IPODE_FAILEDNEWCHUNK,
+ IPODE_INCOMPATIBLECHUNK,
+ IPODE_MHBDNOTFOUND,
+ IPODE_DEVICEINFO,
+};
+
+#define IPODFAILED(x) ((x) >= IPODE_ERROR)
+
+#endif/*__STATUS_H__*/
\ No newline at end of file
Property changes on: trunk/pmplib/lib/pmp_ipod/status.h
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <suc...@us...> - 2007-04-08 16:42:22
|
Revision: 406
http://svn.sourceforge.net/pmplib/?rev=406&view=rev
Author: sucknblow
Date: 2007-04-08 09:42:23 -0700 (Sun, 08 Apr 2007)
Log Message:
-----------
* Make use of the mp4v2 library optional, via --without-mp4v2
configure option.
* Run autoupdate - adds a little extra quoting to configure.in,
bumps AC_PREREQ, and remove obsolete AM_PROG_CC_STDC.
* Add libmp4v2-dev to list of Debian build dependencies.
Modified Paths:
--------------
trunk/pmplib/configure.in
trunk/pmplib/debian/control
trunk/pmplib/lib/gmi/Makefile.am
trunk/pmplib/lib/gmi/gmi.c
Added Paths:
-----------
trunk/pmplib/m4/mp4v2.m4
Modified: trunk/pmplib/configure.in
===================================================================
--- trunk/pmplib/configure.in 2007-04-08 14:52:22 UTC (rev 405)
+++ trunk/pmplib/configure.in 2007-04-08 16:42:23 UTC (rev 406)
@@ -10,7 +10,7 @@
dnl ------------------------------------------------------------------
dnl Initialization for autoconf
dnl ------------------------------------------------------------------
-AC_PREREQ(2.53)
+AC_PREREQ(2.61)
AC_INIT
AC_CONFIG_SRCDIR([frontend/easypmp/cui/main.c])
@@ -36,7 +36,6 @@
dnl ------------------------------------------------------------------
dnl Checks for program
dnl ------------------------------------------------------------------
-AM_PROG_CC_STDC
AC_PROG_CC
AC_PROG_INSTALL
AC_PROG_LN_S
@@ -127,7 +126,7 @@
dnl ------------------------------------------------------------------
AC_ARG_ENABLE(
debug,
- [AC_HELP_STRING(--enable-debug, [Turn on debugging])]
+ [AS_HELP_STRING([--enable-debug],[Turn on debugging])]
)
if test "$enable_debug" = "yes"; then
@@ -156,13 +155,13 @@
dnl Checks for id3tag
AC_ARG_WITH(
id3tag-header,
- [AC_HELP_STRING(--with-id3tag-header=DIR, [id3tag header directory])],
+ [AS_HELP_STRING([--with-id3tag-header=DIR],[id3tag header directory])],
[CFLAGS="-I$withval ${CFLAGS}"]
)
AC_ARG_WITH(
id3tag-library,
- [AC_HELP_STRING(--with-id3tag-library=DIR, [id3tag library directory])],
+ [AS_HELP_STRING([--with-id3tag-library=DIR],[id3tag library directory])],
[LDFLAGS="-L$withval ${LDFLAGS}"]
)
@@ -184,18 +183,8 @@
dnl Checks for vorbis
AM_PATH_VORBIS
-dnl Checks for libmp4v2
-AC_CHECK_HEADER(
- mp4.h,
- ,
- [AC_MSG_ERROR(mp4v2 header not found!)]
-)
-AC_CHECK_LIB(
- mp4v2,
- MP4Read,
- [MP4V2_LIBS="-lmp4v2"],
- AC_MSG_ERROR([mp4v2 library is not found!])
-)
+dnl Checks for mp4v2
+PMP_PATH_MP4V2
dnl Check for libsmjs (SpiderMonkey JavaScript engine)
AC_PATH_SPIDERMONKEY
@@ -245,7 +234,7 @@
dnl ------------------------------------------------------------------
AC_ARG_ENABLE(
versioned-libdir,
- [AC_HELP_STRING(--enable-versioned-libdir, [Include version number in plugins path])]
+ [AS_HELP_STRING([--enable-versioned-libdir],[Include version number in plugins path])]
)
if test "$enable_versioned_libdir" = "yes" ; then
PLUGIN_DIR=$PACKAGE-$VERSION
@@ -259,7 +248,7 @@
dnl ------------------------------------------------------------------
AC_ARG_ENABLE(
versioned-jspldir,
- [AC_HELP_STRING(--enable-versioned-jspldir, [Include version number in JSPL path])]
+ [AS_HELP_STRING([--enable-versioned-jspldir],[Include version number in JSPL path])]
)
if test "$enable_versioned_jspldir" = "yes" ; then
JSPL_DIR=$PACKAGE-$VERSION
@@ -280,9 +269,17 @@
AC_OUTPUT
if test -z "$JS_CFLAGS" ; then
+ echo
if test "$enable_js" != no ; then
- echo
echo " Warning: JavaScript interpreter engine not found"
fi
echo " pmplib will be build without support for JavaScript playlists."
fi
+
+if test -z "$HAVE_MP4V2" ; then
+ echo
+ if test "$with_mp4v2" != no ; then
+ echo " Warning: mp4v2 development files not found"
+ fi
+ echo " pmplib will be build without support for MP4 files."
+fi
Modified: trunk/pmplib/debian/control
===================================================================
--- trunk/pmplib/debian/control 2007-04-08 14:52:22 UTC (rev 405)
+++ trunk/pmplib/debian/control 2007-04-08 16:42:23 UTC (rev 406)
@@ -2,7 +2,7 @@
Section: sound
Priority: extra
Maintainer: Martin Ellis <ma...@do...>
-Build-Depends: debhelper (>= 5), libvorbis-dev, libid3tag0-dev, libmozjs-dev
+Build-Depends: debhelper (>= 5), libvorbis-dev, libid3tag0-dev, libmp4v2-dev, libmozjs-dev
Standards-Version: 3.7.2
Package: easypmp
Modified: trunk/pmplib/lib/gmi/Makefile.am
===================================================================
--- trunk/pmplib/lib/gmi/Makefile.am 2007-04-08 14:52:22 UTC (rev 405)
+++ trunk/pmplib/lib/gmi/Makefile.am 2007-04-08 16:42:23 UTC (rev 406)
@@ -2,10 +2,13 @@
noinst_LTLIBRARIES = libgmi.la
+if have_mp4v2
+ gmi_mp4v2_c=gmi_mp4v2.c
+endif
libgmi_la_SOURCES = \
../../include/gmi.h \
gmi_mp3.c \
- gmi_mp4v2.c \
+ $(gmi_mp4v2_c) \
gmi_wma.c \
gmi_wav.c \
gmi_vorbis.c \
Modified: trunk/pmplib/lib/gmi/gmi.c
===================================================================
--- trunk/pmplib/lib/gmi/gmi.c 2007-04-08 14:52:22 UTC (rev 405)
+++ trunk/pmplib/lib/gmi/gmi.c 2007-04-08 16:42:23 UTC (rev 406)
@@ -39,8 +39,10 @@
int gmi_mp3(media_info_t* info, const ucs2char_t *filename, const char *charset);
static const ucs2char_t ucs2cs_ext_mp3[] = {'.','m','p','3',0};
+#if HAVE_MP4V2
int gmi_mp4v2(media_info_t* info, const ucs2char_t *filename, const char *charset);
static const ucs2char_t ucs2cs_ext_m4a[] = {'.','m','4','a',0};
+#endif
int gmi_wma(media_info_t* info, const ucs2char_t *filename, const char *charset);
static const ucs2char_t ucs2cs_ext_wma[] = {'.','w','m','a',0};
@@ -58,7 +60,9 @@
static gmi_exports_t gmi_exports[] = {
{gmi_mp3, ucs2cs_ext_mp3},
+#if HAVE_MP4V2
{gmi_mp4v2, ucs2cs_ext_m4a},
+#endif
{gmi_wma, ucs2cs_ext_wma},
{gmi_vorbis, ucs2cs_ext_ogg},
{gmi_wav, ucs2cs_ext_wav},
Added: trunk/pmplib/m4/mp4v2.m4
===================================================================
--- trunk/pmplib/m4/mp4v2.m4 (rev 0)
+++ trunk/pmplib/m4/mp4v2.m4 2007-04-08 16:42:23 UTC (rev 406)
@@ -0,0 +1,32 @@
+AC_DEFUN([PMP_PATH_MP4V2],[
+dnl Checks for libmp4v2
+ AC_ARG_WITH(
+ mp4v2,
+ [AS_HELP_STRING([--without-mp4v2],[do not try to use mp4v2 for MP4 file support])]
+ )
+
+ if test "$with_mp4v2" != "no" ; then
+
+ AC_CHECK_HEADER(
+ [mp4.h],
+ [HAVE_MP4V2_HEADER="yes"],
+ AC_MSG_WARN(mp4v2 header not found!)
+ )
+
+ AC_CHECK_LIB(
+ mp4v2,
+ MP4Read,
+ [MP4V2_LIBS="-lmp4v2"],
+ AC_MSG_WARN([mp4v2 library is not found!])
+ )
+ fi
+
+ if test "$HAVE_MP4V2_HEADER" = "yes" -a "MP4V2_LIBS" != "" ; then
+ HAVE_MP4V2=yes
+ AC_DEFINE([HAVE_MP4_H], 1, [Define if you have the mp4.h header])
+ AC_SUBST(MP4V2_LIBS)
+ fi
+
+ AM_CONDITIONAL(have_mp4v2, test "$HAVE_MP4V2" = "yes")
+])
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <suc...@us...> - 2007-04-08 14:52:22
|
Revision: 405
http://svn.sourceforge.net/pmplib/?rev=405&view=rev
Author: sucknblow
Date: 2007-04-08 07:52:22 -0700 (Sun, 08 Apr 2007)
Log Message:
-----------
Set svn:eol-style to native for source files
Modified Paths:
--------------
trunk/pmplib/lib/gmi/gmi_mp4v2.c
Property Changed:
----------------
trunk/pmplib/lib/gmi/contrib/mp4v2/mp4.h
trunk/pmplib/lib/gmi/contrib/mp4v2/mpeg4ip.h
trunk/pmplib/lib/gmi/contrib/mp4v2/mpeg4ip_version.h
trunk/pmplib/lib/gmi/contrib/mp4v2/mpeg4ip_win32.h
trunk/pmplib/lib/gmi/gmi_mp4v2.c
Property changes on: trunk/pmplib/lib/gmi/contrib/mp4v2/mp4.h
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: trunk/pmplib/lib/gmi/contrib/mp4v2/mpeg4ip.h
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: trunk/pmplib/lib/gmi/contrib/mp4v2/mpeg4ip_version.h
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: trunk/pmplib/lib/gmi/contrib/mp4v2/mpeg4ip_win32.h
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/pmplib/lib/gmi/gmi_mp4v2.c
===================================================================
--- trunk/pmplib/lib/gmi/gmi_mp4v2.c 2007-03-06 04:55:33 UTC (rev 404)
+++ trunk/pmplib/lib/gmi/gmi_mp4v2.c 2007-04-08 14:52:22 UTC (rev 405)
@@ -1,144 +1,144 @@
-/*
- * Tag and audio information retrieval by libmp4v2
- *
- * Copyright (c) 2005-2007 Naoaki Okazaki
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA, or visit
- * http://www.gnu.org/copyleft/gpl.html .
- *
- */
-
-/* $Id:$ */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif/*HAVE_CONFIG_H*/
-
-#if defined(WIN32)
-/* In Win32 version of libmp4v2, <mp4.h> header also includes <winsock2.h>
- * header, which cannot coexist with <winsock.h>. Defining _WINSOCKAPI_ will
- * prevent from <winsock.h> being referred to by <windows.h>, which is also
- * referred to by <os.h> header (Win32 only). Therefore, this definition
- * must be placed before including <os.h>.
- */
-#define _WINSOCKAPI_
-/* Add Winsock2 library */
-#pragma comment(lib, "ws2_32.lib")
-#endif/*defined(WIN32)*/
-
-#include <os.h>
-#include <limits.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <pmplib/ucs2char.h>
-#include <gmi.h>
-
-#include <mp4.h>
-
-#ifdef WIN32
-/* Taken from mpeg4ip-1.5.0.1/lib/gnu/need_for_win32.c */
-#include <sys/timeb.h>
-
-int gettimeofday (struct timeval *t, void *foo)
-{
- struct _timeb temp;
- _ftime(&temp);
- t->tv_sec = temp.time;
- t->tv_usec = temp.millitm * 1000;
- return (0);
-}
-#endif/*WIN32*/
-
-
-
-int gmi_mp4v2(media_info_t* info, const ucs2char_t *filename, const char *charset)
-{
- int ret = 0;
- uint32_t i, num_tracks = 0;
- uint16_t numvalue, numvalue2;
- char *value = ucs2dupmbs(filename);
- MP4FileHandle mp4file = MP4_INVALID_FILE_HANDLE;
-
- mp4file = MP4Read(value, 0);
- ucs2free(value);
- if (mp4file == MP4_INVALID_FILE_HANDLE) {
- ret = -1;
- goto error_exit;
- }
-
- num_tracks = MP4GetNumberOfTracks(mp4file, NULL, 0);
- for (i = 0;i < num_tracks;++i) {
- uint32_t tid = MP4FindTrackId(mp4file, (u_int16_t)i, NULL, 0);
- const char *type = MP4GetTrackType(mp4file, tid);
-
- if (type && strcmp(type, MP4_AUDIO_TRACK_TYPE) == 0) {
- MP4Duration duration = MP4GetTrackDuration(mp4file, tid);
- info->num_samples = (uint64_t)duration;
- info->duration = (uint32_t)MP4ConvertFromTrackDuration(mp4file, tid, duration, MP4_MSECS_TIME_SCALE);
- info->sample_rate = MP4GetTrackTimeScale(mp4file, tid);
- info->bitrate = MP4GetTrackBitRate(mp4file, tid);
- }
- }
-
- if (MP4GetMetadataName(mp4file, &value) && value != NULL) {
- ucs2free(info->title);
- info->title = utf8dupucs2(value);
- free(value);
- }
- if (MP4GetMetadataArtist(mp4file, &value) && value != NULL) {
- ucs2free(info->artist);
- info->artist = utf8dupucs2(value);
- free(value);
- }
- if (MP4GetMetadataAlbum(mp4file, &value) && value != NULL) {
- ucs2free(info->album);
- info->album = utf8dupucs2(value);
- free(value);
- }
- if (MP4GetMetadataWriter(mp4file, &value) && value != NULL) {
- ucs2free(info->composer);
- info->composer = utf8dupucs2(value);
- free(value);
- }
- if (MP4GetMetadataGenre(mp4file, &value) && value != NULL) {
- ucs2free(info->genre);
- info->genre = utf8dupucs2(value);
- free(value);
- }
- if (MP4GetMetadataYear(mp4file, &value) && value != NULL) {
- ucs2free(info->date);
- info->date = utf8dupucs2(value);
- free(value);
- }
- if (MP4GetMetadataTrack(mp4file, &numvalue, &numvalue2)) {
- info->track_number = numvalue;
- info->total_tracks = numvalue2;
- }
- if (MP4GetMetadataDisk(mp4file, &numvalue, &numvalue2)) {
- info->disc_number = numvalue;
- info->total_discs = numvalue2;
- }
-
- info->codec = PMPCODEC_MPEG4AUDIO;
-
-error_exit:
- if (mp4file != MP4_INVALID_FILE_HANDLE) {
- MP4Close(mp4file);
- }
- return ret;
-}
+/*
+ * Tag and audio information retrieval by libmp4v2
+ *
+ * Copyright (c) 2005-2007 Naoaki Okazaki
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA, or visit
+ * http://www.gnu.org/copyleft/gpl.html .
+ *
+ */
+
+/* $Id:$ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif/*HAVE_CONFIG_H*/
+
+#if defined(WIN32)
+/* In Win32 version of libmp4v2, <mp4.h> header also includes <winsock2.h>
+ * header, which cannot coexist with <winsock.h>. Defining _WINSOCKAPI_ will
+ * prevent from <winsock.h> being referred to by <windows.h>, which is also
+ * referred to by <os.h> header (Win32 only). Therefore, this definition
+ * must be placed before including <os.h>.
+ */
+#define _WINSOCKAPI_
+/* Add Winsock2 library */
+#pragma comment(lib, "ws2_32.lib")
+#endif/*defined(WIN32)*/
+
+#include <os.h>
+#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <pmplib/ucs2char.h>
+#include <gmi.h>
+
+#include <mp4.h>
+
+#ifdef WIN32
+/* Taken from mpeg4ip-1.5.0.1/lib/gnu/need_for_win32.c */
+#include <sys/timeb.h>
+
+int gettimeofday (struct timeval *t, void *foo)
+{
+ struct _timeb temp;
+ _ftime(&temp);
+ t->tv_sec = temp.time;
+ t->tv_usec = temp.millitm * 1000;
+ return (0);
+}
+#endif/*WIN32*/
+
+
+
+int gmi_mp4v2(media_info_t* info, const ucs2char_t *filename, const char *charset)
+{
+ int ret = 0;
+ uint32_t i, num_tracks = 0;
+ uint16_t numvalue, numvalue2;
+ char *value = ucs2dupmbs(filename);
+ MP4FileHandle mp4file = MP4_INVALID_FILE_HANDLE;
+
+ mp4file = MP4Read(value, 0);
+ ucs2free(value);
+ if (mp4file == MP4_INVALID_FILE_HANDLE) {
+ ret = -1;
+ goto error_exit;
+ }
+
+ num_tracks = MP4GetNumberOfTracks(mp4file, NULL, 0);
+ for (i = 0;i < num_tracks;++i) {
+ uint32_t tid = MP4FindTrackId(mp4file, (u_int16_t)i, NULL, 0);
+ const char *type = MP4GetTrackType(mp4file, tid);
+
+ if (type && strcmp(type, MP4_AUDIO_TRACK_TYPE) == 0) {
+ MP4Duration duration = MP4GetTrackDuration(mp4file, tid);
+ info->num_samples = (uint64_t)duration;
+ info->duration = (uint32_t)MP4ConvertFromTrackDuration(mp4file, tid, duration, MP4_MSECS_TIME_SCALE);
+ info->sample_rate = MP4GetTrackTimeScale(mp4file, tid);
+ info->bitrate = MP4GetTrackBitRate(mp4file, tid);
+ }
+ }
+
+ if (MP4GetMetadataName(mp4file, &value) && value != NULL) {
+ ucs2free(info->title);
+ info->title = utf8dupucs2(value);
+ free(value);
+ }
+ if (MP4GetMetadataArtist(mp4file, &value) && value != NULL) {
+ ucs2free(info->artist);
+ info->artist = utf8dupucs2(value);
+ free(value);
+ }
+ if (MP4GetMetadataAlbum(mp4file, &value) && value != NULL) {
+ ucs2free(info->album);
+ info->album = utf8dupucs2(value);
+ free(value);
+ }
+ if (MP4GetMetadataWriter(mp4file, &value) && value != NULL) {
+ ucs2free(info->composer);
+ info->composer = utf8dupucs2(value);
+ free(value);
+ }
+ if (MP4GetMetadataGenre(mp4file, &value) && value != NULL) {
+ ucs2free(info->genre);
+ info->genre = utf8dupucs2(value);
+ free(value);
+ }
+ if (MP4GetMetadataYear(mp4file, &value) && value != NULL) {
+ ucs2free(info->date);
+ info->date = utf8dupucs2(value);
+ free(value);
+ }
+ if (MP4GetMetadataTrack(mp4file, &numvalue, &numvalue2)) {
+ info->track_number = numvalue;
+ info->total_tracks = numvalue2;
+ }
+ if (MP4GetMetadataDisk(mp4file, &numvalue, &numvalue2)) {
+ info->disc_number = numvalue;
+ info->total_discs = numvalue2;
+ }
+
+ info->codec = PMPCODEC_MPEG4AUDIO;
+
+error_exit:
+ if (mp4file != MP4_INVALID_FILE_HANDLE) {
+ MP4Close(mp4file);
+ }
+ return ret;
+}
Property changes on: trunk/pmplib/lib/gmi/gmi_mp4v2.c
___________________________________________________________________
Name: svn:eol-style
+ native
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ny...@us...> - 2007-03-06 04:23:32
|
Revision: 403
http://svn.sourceforge.net/pmplib/?rev=403&view=rev
Author: nyaochi
Date: 2007-03-05 20:23:18 -0800 (Mon, 05 Mar 2007)
Log Message:
-----------
Make the SVN head build on POSIX for debugging iriver E10 database problem. Now libmp4v2 is necessary (but should be omittable later).
Modified Paths:
--------------
trunk/pmplib/configure.in
trunk/pmplib/frontend/easypmp/cui/Makefile.am
trunk/pmplib/lib/filepath/filepath_posix.c
trunk/pmplib/lib/gmi/Makefile.am
trunk/pmplib/lib/ucs2/ucs2char_iconv.c
Modified: trunk/pmplib/configure.in
===================================================================
--- trunk/pmplib/configure.in 2007-02-28 12:21:46 UTC (rev 402)
+++ trunk/pmplib/configure.in 2007-03-06 04:23:18 UTC (rev 403)
@@ -184,6 +184,19 @@
dnl Checks for vorbis
AM_PATH_VORBIS
+dnl Checks for libmp4v2
+AC_CHECK_HEADER(
+ mp4.h,
+ ,
+ [AC_MSG_ERROR(mp4v2 header not found!)]
+)
+AC_CHECK_LIB(
+ mp4v2,
+ MP4Read,
+ [MP4V2_LIBS="-lmp4v2"],
+ AC_MSG_ERROR([mp4v2 library is not found!])
+)
+
dnl Check for libsmjs (SpiderMonkey JavaScript engine)
AC_PATH_SPIDERMONKEY
@@ -219,6 +232,7 @@
AC_SUBST(OGG_LIBS)
AC_SUBST(VORBIS_LIBS)
AC_SUBST(VORBISFILE_LIBS)
+AC_SUBST(MP4V2_LIBS)
AC_SUBST(JS_CFLAGS)
AC_SUBST(JS_LIBS)
AC_SUBST(JS_RPATH)
Modified: trunk/pmplib/frontend/easypmp/cui/Makefile.am
===================================================================
--- trunk/pmplib/frontend/easypmp/cui/Makefile.am 2007-02-28 12:21:46 UTC (rev 402)
+++ trunk/pmplib/frontend/easypmp/cui/Makefile.am 2007-03-06 04:23:18 UTC (rev 403)
@@ -13,6 +13,7 @@
../common/database.c \
../common/enumerate.c \
../common/playlist.c \
+ ../common/settle.c \
device.c \
option.c \
option.h \
@@ -35,4 +36,5 @@
easypmp_LDADD = \
$(top_builddir)/lib/pmp/libpmp.la \
$(top_builddir)/lib/gmi/libgmi.la \
- $(top_builddir)/lib/playlist/libplaylist.la
+ $(top_builddir)/lib/playlist/libplaylist.la \
+ $(JS_LIBS)
Modified: trunk/pmplib/lib/filepath/filepath_posix.c
===================================================================
--- trunk/pmplib/lib/filepath/filepath_posix.c 2007-02-28 12:21:46 UTC (rev 402)
+++ trunk/pmplib/lib/filepath/filepath_posix.c 2007-03-06 04:23:18 UTC (rev 403)
@@ -37,6 +37,8 @@
#include <pmplib/filepath.h>
#include "rel2abs.h"
+static const ucs2char_t ucs2cs_link_ext[] = {'.','m','3','u','8',0};
+
static int _decode(char* path)
{
while (*path) {
@@ -189,10 +191,17 @@
return dst;
}
-const ucs2char_t* filepath_skiproot(const ucs2char_t* path, const ucs2char_t* root)
+const ucs2char_t* filepath_skiproot(const ucs2char_t* path, const ucs2char_t* root, int pathchar)
{
- if (ucs2ncmp(path, root, ucs2len(root)) == 0) {
- return path + ucs2len(root);
+ /* Make sure the _root ends with a PATHCHAR. */
+ ucs2char_t* _root = alloca(sizeof(ucs2char_t) * (ucs2len(root) + 2));
+ ucs2cpy(_root, root);
+ filepath_addslash(_root);
+
+ if (ucs2ncmp(path, _root, ucs2len(_root)) == 0) {
+ const ucs2char_t* p = path + ucs2len(_root);
+ if (pathchar) --p;
+ return p < path ? path : p;
} else {
return path;
}
@@ -204,22 +213,18 @@
return p ? p+1 : path;
}
-const ucs2char_t* filepath_changeroot(const ucs2char_t* path, const ucs2char_t* root)
-{
- const ucs2char_t* p = filepath_skiproot(path, root);
- if (p == NULL) p = path;
- if (path < p && p[-1] == PATHCHAR) {
- --p;
- }
- return p;
-}
-
const ucs2char_t* filepath_skipadirectory(const ucs2char_t* path)
{
ucs2char_t* p = ucs2chr(path, PATHCHAR);
return p ? p+1 : NULL;
}
+const ucs2char_t* filepath_extract_extension(const ucs2char_t* path)
+{
+ ucs2char_t* p = ucs2rchr(path, '.');
+ return p ? p : path;
+}
+
void filepath_strippath(ucs2char_t* path)
{
ucs2char_t* p = path + ucs2len(path) - 1;
@@ -316,6 +321,18 @@
return (ret1 - ret2);
}
+int filepath_createdirs(const ucs2char_t* filename)
+{
+ ucs2char_t* dirname = (ucs2char_t*)alloca(sizeof(ucs2char_t) * (ucs2len(filename) + 1));
+ filepath_removeslash(dirname);
+ if (filepath_file_exists(dirname)) {
+ return 0;
+ } else {
+ filepath_remove_filespec(dirname);
+ return filepath_createdirs(dirname);
+ }
+}
+
int filepath_copyfile(const ucs2char_t* src, const ucs2char_t* dst)
{
int ret = 0;
@@ -354,6 +371,79 @@
return ret;
}
+int filepath_movefile(const ucs2char_t* src, const ucs2char_t* dst)
+{
+ int ret = 0;
+ char *_src = ucs2dupmbs(src);
+ char *_dst = ucs2dupmbs(dst);
+ ret = (rename(_src, _dst) == 0);
+ ucs2free(_dst);
+ ucs2free(_src);
+ return ret;
+}
+
+int filepath_linkfile(const ucs2char_t* target, const ucs2char_t* link)
+{
+ /* Create a m3u8 playlist with the target file. */
+ FILE *fp = NULL;
+ ucs2char_t* _link = alloca(sizeof(ucs2char_t) * (ucs2len(link) + ucs2len(ucs2cs_link_ext) + 1));
+
+ /* Add ".m3u8" extension. */
+ ucs2cpy(_link, link);
+ ucs2cat(_link, ucs2cs_link_ext);
+
+ /* Write the */
+ fp = ucs2fopen(_link, "w");
+ if (fp) {
+ char *utf8 = ucs2duputf8(target);
+ fputc('\\', fp);
+ fputs(utf8, fp);
+ ucs2free(utf8);
+ fclose(fp);
+ return 0;
+ } else {
+ return -1;
+ }
+}
+
+int filepath_followlink(const ucs2char_t* link, ucs2char_t* org)
+{
+ /* Create a m3u8 playlist with the target file. */
+ FILE *fp = NULL;
+ ucs2char_t* _link = (ucs2char_t*)alloca(
+ sizeof(ucs2char_t) * (ucs2len(link) + ucs2len(ucs2cs_link_ext) + 1));
+
+ /* Add ".m3u8" extension. */
+ ucs2cpy(_link, link);
+ ucs2cat(_link, ucs2cs_link_ext);
+
+ /* Write the */
+ fp = ucs2fopen(_link, "r");
+ if (fp) {
+ char buff[MAX_PATH*4];
+ ucs2char_t target[MAX_PATH];
+ fgets(buff, sizeof(buff)-1, fp);
+ utf8toucs2(target, MAX_PATH, buff, strlen(buff)+1);
+ filepath_combinepath(org, MAX_PATH, link, target);
+ fclose(fp);
+ return 0;
+ } else {
+ return -1;
+ }
+}
+
+int filepath_removelinkfile(const ucs2char_t* file)
+{
+ ucs2char_t* _link = (ucs2char_t*)alloca(
+ sizeof(ucs2char_t) * (ucs2len(file) + ucs2len(ucs2cs_link_ext) + 1));
+
+ /* Add ".m3u8" extension. */
+ ucs2cpy(_link, file);
+ ucs2cat(_link, ucs2cs_link_ext);
+
+ return filepath_removefile(_link);
+}
+
int filepath_encode(ucs2char_t* path)
{
while (*path) {
@@ -426,3 +516,8 @@
}
return 0;
}
+
+int filepath_is_link(const ucs2char_t *path)
+{
+ return filepath_hasext(path, ucs2cs_link_ext);
+}
Modified: trunk/pmplib/lib/gmi/Makefile.am
===================================================================
--- trunk/pmplib/lib/gmi/Makefile.am 2007-02-28 12:21:46 UTC (rev 402)
+++ trunk/pmplib/lib/gmi/Makefile.am 2007-03-06 04:23:18 UTC (rev 403)
@@ -5,6 +5,7 @@
libgmi_la_SOURCES = \
../../include/gmi.h \
gmi_mp3.c \
+ gmi_mp4v2.c \
gmi_wma.c \
gmi_wav.c \
gmi_vorbis.c \
@@ -12,7 +13,7 @@
libgmi_la_LDFLAGS = \
@ID3TAG_LIBS@ @OGG_LIBS@ @VORBIS_LIBS@ @VORBISFILE_LIBS@ \
- -no-undefined
+ @MP4V2_LIBS@ -no-undefined
AM_CFLAGS = @CFLAGS@
INCLUDES = @INCLUDES@
Modified: trunk/pmplib/lib/ucs2/ucs2char_iconv.c
===================================================================
--- trunk/pmplib/lib/ucs2/ucs2char_iconv.c 2007-02-28 12:21:46 UTC (rev 402)
+++ trunk/pmplib/lib/ucs2/ucs2char_iconv.c 2007-03-06 04:23:18 UTC (rev 403)
@@ -237,6 +237,13 @@
return ret;
}
+size_t ucs2toutf8(char *mbstr, size_t mbs_size, const ucs2char_t *ucs2str, size_t ucs_size)
+{
+ iconv_t cd = iconv_open("UTF-8", g_ucs2encoding);
+ size_t ret = iconv_convert(cd, (char **)&mbstr, mbs_size, (char **)&ucs2str, ucs_size * sizeof(ucs2char_t));
+ iconv_close(cd);
+ return ret;
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ny...@us...> - 2007-02-28 12:21:47
|
Revision: 402
http://svn.sourceforge.net/pmplib/?rev=402&view=rev
Author: nyaochi
Date: 2007-02-28 04:21:46 -0800 (Wed, 28 Feb 2007)
Log Message:
-----------
- Implemented database update for iPod players.
- Removed filepath_changeroot function.
- Added an argument to filepath_skiproot to specify the necessity of a path character at the head of the string
returned by the function.
- Added comment field to pmp_t.
- Time stamps are now represented in uint64_t.
- Reduced warnings.
- Removed unnecessary routines.
Modified Paths:
--------------
trunk/pmplib/frontend/easypmp/common/database.c
trunk/pmplib/frontend/easypmp/common/settle.c
trunk/pmplib/frontend/easypmp/cui/console_win32.c
trunk/pmplib/frontend/easypmp/cui/device.c
trunk/pmplib/include/pmplib/filepath.h
trunk/pmplib/include/pmplib/pmp.h
trunk/pmplib/lib/filepath/filepath_win32.c
trunk/pmplib/lib/gmi/gmi_mp4v2.c
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
trunk/pmplib/lib/pmp_ipod/pmp_ipod.c
trunk/pmplib/lib/pmp_ipod/util.c
trunk/pmplib/lib/pmp_ipod/util.h
trunk/pmplib/lib/pmp_iriverplus2/ip2db.c
trunk/pmplib/lib/pmp_iriverplus2/playlist.c
trunk/pmplib/lib/pmp_iriverplus3/dat.c
trunk/pmplib/lib/pmp_iriverplus3/dic.c
trunk/pmplib/lib/pmp_iriverplus3/idx.c
trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c
trunk/pmplib/lib/pmp_irivnavi/playlist.c
trunk/pmplib/lib/pmp_irivnavi/pmp_irivnavi.c
trunk/pmplib/lib/pmp_portalplayer1/model_iriver_h10.c
trunk/pmplib/lib/pmp_portalplayer1/model_medion_mdjuke220.c
trunk/pmplib/lib/pmp_portalplayer1/model_medion_mdjuke440.c
trunk/pmplib/lib/pmp_portalplayer1/model_msi_megaplayer.c
trunk/pmplib/lib/pmp_portalplayer1/model_philips_hdd6320.c
trunk/pmplib/lib/pmp_portalplayer1/model_samsung.c
trunk/pmplib/lib/pmp_portalplayer1/model_sirius_s50.c
trunk/pmplib/lib/pmp_portalplayer1/playlist.c
Modified: trunk/pmplib/frontend/easypmp/common/database.c
===================================================================
--- trunk/pmplib/frontend/easypmp/common/database.c 2007-02-28 08:17:04 UTC (rev 401)
+++ trunk/pmplib/frontend/easypmp/common/database.c 2007-02-28 12:21:46 UTC (rev 402)
@@ -283,7 +283,7 @@
int easypmp_set_strip_words(option_t* opt, const ucs2char_t* str)
{
- size_t i;
+ int i;
const ucs2char_t *p = 0, *q = 0;
/*
Modified: trunk/pmplib/frontend/easypmp/common/settle.c
===================================================================
--- trunk/pmplib/frontend/easypmp/common/settle.c 2007-02-28 08:17:04 UTC (rev 401)
+++ trunk/pmplib/frontend/easypmp/common/settle.c 2007-02-28 12:21:46 UTC (rev 402)
@@ -93,7 +93,7 @@
ucs2char_t music[MAX_PATH];
ucs2char_t directory[MAX_PATH];
- srand(time(NULL));
+ srand((unsigned int)time(NULL));
// Remove music files that are not pointed by any links.
if (opt->verb & MODE_REMOVE_UNREF) {
Modified: trunk/pmplib/frontend/easypmp/cui/console_win32.c
===================================================================
--- trunk/pmplib/frontend/easypmp/cui/console_win32.c 2007-02-28 08:17:04 UTC (rev 401)
+++ trunk/pmplib/frontend/easypmp/cui/console_win32.c 2007-02-28 12:21:46 UTC (rev 402)
@@ -101,7 +101,7 @@
return (int)(p - line);
} else {
fprintf(fp, "%S\n", line);
- return ucs2len(line);
+ return (int)ucs2len(line);
}
}
Modified: trunk/pmplib/frontend/easypmp/cui/device.c
===================================================================
--- trunk/pmplib/frontend/easypmp/cui/device.c 2007-02-28 08:17:04 UTC (rev 401)
+++ trunk/pmplib/frontend/easypmp/cui/device.c 2007-02-28 12:21:46 UTC (rev 402)
@@ -47,7 +47,7 @@
void device_show_information(pmp_t* pmp, FILE *fp)
{
- int i;
+ uint32_t i;
fprintf(fp, "Device identifier: %s\n", pmp->info.decl.id);
fprintf(fp, " Manufacturer: %s\n", pmp->info.decl.manufacturer);
Modified: trunk/pmplib/include/pmplib/filepath.h
===================================================================
--- trunk/pmplib/include/pmplib/filepath.h 2007-02-28 08:17:04 UTC (rev 401)
+++ trunk/pmplib/include/pmplib/filepath.h 2007-02-28 12:21:46 UTC (rev 402)
@@ -125,26 +125,16 @@
* function skips the portion.
* @param root The pointer to the string representing the portion to
* be skipped.
+ * @param pathchar Boolean value to determine whether the resultant
+ * string should starts with a path character or not.
+ * If \a pathchar is non-zero value, the resultant string
+ * will starts with a path character.
* @retval const ucs2char_t* The pointer at the next character after the
* portion \a root ends in \a path.
*/
-FILEPATHAPI const ucs2char_t* filepath_skiproot(const ucs2char_t* path, const ucs2char_t* root);
+FILEPATHAPI const ucs2char_t* filepath_skiproot(const ucs2char_t* path, const ucs2char_t* root, int pathchar);
/**
- * Skip a portion in filepath name, assuming it as the root directory.
- *
- * The resultant string will begin with a path character.
- *
- * @param path The pointer to the filepath name from which this
- * function skips the portion.
- * @param root The pointer to the string representing the portion to
- * be skipped.
- * @retval const ucs2char_t* The pointer at the next character after the
- * portion \a root ends in \a path.
- */
-FILEPATHAPI const ucs2char_t* filepath_changeroot(const ucs2char_t* path, const ucs2char_t* root);
-
-/**
* Skip a directory name in filepath name.
*
* @param path The pointer to the filepath name from which this
Modified: trunk/pmplib/include/pmplib/pmp.h
===================================================================
--- trunk/pmplib/include/pmplib/pmp.h 2007-02-28 08:17:04 UTC (rev 401)
+++ trunk/pmplib/include/pmplib/pmp.h 2007-02-28 12:21:46 UTC (rev 402)
@@ -129,7 +129,9 @@
#define PMPCODEC_NONE PMPFOURCC(' ',' ',' ',' ')
/** MPEG Audio Layer III. */
#define PMPCODEC_MPEGLAYER3 PMPFOURCC('M','P','A','3')
-/** MPEG 4. */
+/** MPEG AAC. */
+#define PMPCODEC_MPEGAAC PMPFOURCC('A','A','C',' ')
+/** MPEG 4 Audio. */
#define PMPCODEC_MPEG4AUDIO PMPFOURCC('M','P','4','A')
/** Windows Media Audio. */
#define PMPCODEC_WMA PMPFOURCC('W','M','A',' ')
@@ -377,6 +379,13 @@
ucs2char_t *date;
/**
+ * Comment.
+ * e.g., "Encoded with LAME"
+ * @assert @code comment != NULL @endcode
+ */
+ ucs2char_t *comment;
+
+ /**
* Compilation flag.
* e.g., 1 for compilation album.
*/
@@ -437,8 +446,8 @@
uint32_t bitrate;
/**
- * Duration in seconds.
- * e.g., 260
+ * Duration in miliseconds.
+ * e.g., 260000
*/
uint32_t duration;
@@ -456,9 +465,9 @@
/**
* Timestamp of the last update of the music file.
- * The value is equivalent to \c st.st_mtime after \c stat(&st, filename);
+ * The value represents the elapsed seconds from 1970-01-01T00:00:00 (UTC).
*/
- uint32_t ts_update;
+ uint64_t ts_update;
/**
* Rating.
@@ -474,13 +483,15 @@
/**
* Timestamp of the recent playback on the device.
+ * The value represents the elapsed seconds from 1970-01-01T00:00:00 (UTC).
*/
- uint32_t ts_playback;
+ uint64_t ts_playback;
/**
* timestamp when the track was imported.
+ * The value represents the elapsed seconds from 1970-01-01T00:00:00 (UTC).
*/
- uint32_t ts_import;
+ uint64_t ts_import;
};
/**
Modified: trunk/pmplib/lib/filepath/filepath_win32.c
===================================================================
--- trunk/pmplib/lib/filepath/filepath_win32.c 2007-02-28 08:17:04 UTC (rev 401)
+++ trunk/pmplib/lib/filepath/filepath_win32.c 2007-02-28 12:21:46 UTC (rev 402)
@@ -106,10 +106,17 @@
return dst;
}
-const ucs2char_t* filepath_skiproot(const ucs2char_t* path, const ucs2char_t* root)
+const ucs2char_t* filepath_skiproot(const ucs2char_t* path, const ucs2char_t* root, int pathchar)
{
- if (ucs2ncmp(path, root, ucs2len(root)) == 0) {
- return path + ucs2len(root);
+ /* Make sure the _root ends with a PATHCHAR. */
+ ucs2char_t* _root = alloca(sizeof(ucs2char_t) * (ucs2len(root) + 2));
+ ucs2cpy(_root, root);
+ filepath_addslash(_root);
+
+ if (ucs2ncmp(path, _root, ucs2len(_root)) == 0) {
+ const ucs2char_t* p = path + ucs2len(_root);
+ if (pathchar) --p;
+ return p < path ? path : p;
} else {
return path;
}
@@ -121,16 +128,6 @@
return p ? p+1 : path;
}
-const ucs2char_t* filepath_changeroot(const ucs2char_t* path, const ucs2char_t* root)
-{
- const ucs2char_t* p = filepath_skiproot(path, root);
- if (p == NULL) p = path;
- if (path < p && p[-1] == '\\') {
- --p;
- }
- return p;
-}
-
const ucs2char_t* filepath_skipadirectory(const ucs2char_t* path)
{
ucs2char_t* p = ucs2chr(path, '\\');
Modified: trunk/pmplib/lib/gmi/gmi_mp4v2.c
===================================================================
--- trunk/pmplib/lib/gmi/gmi_mp4v2.c 2007-02-28 08:17:04 UTC (rev 401)
+++ trunk/pmplib/lib/gmi/gmi_mp4v2.c 2007-02-28 12:21:46 UTC (rev 402)
@@ -89,7 +89,7 @@
if (type && strcmp(type, MP4_AUDIO_TRACK_TYPE) == 0) {
MP4Duration duration = MP4GetTrackDuration(mp4file, tid);
info->num_samples = (uint64_t)duration;
- info->duration = MP4ConvertFromTrackDuration(mp4file, tid, duration, MP4_MSECS_TIME_SCALE);
+ info->duration = (uint32_t)MP4ConvertFromTrackDuration(mp4file, tid, duration, MP4_MSECS_TIME_SCALE);
info->sample_rate = MP4GetTrackTimeScale(mp4file, tid);
info->bitrate = MP4GetTrackBitRate(mp4file, tid);
}
Modified: trunk/pmplib/lib/pmp_ipod/ipod.c
===================================================================
--- trunk/pmplib/lib/pmp_ipod/ipod.c 2007-02-28 08:17:04 UTC (rev 401)
+++ trunk/pmplib/lib/pmp_ipod/ipod.c 2007-02-28 12:21:46 UTC (rev 402)
@@ -32,6 +32,7 @@
#include <string.h>
#endif/*HAVE_STRING_H*/
#include <pmplib/ucs2char.h>
+#include <pmplib/filepath.h>
#include <pmplib/pmp.h>
#include "serialize.h"
@@ -248,7 +249,12 @@
return 0;
}
-static int set_music_record(itunesdb_chunk_t* mhit, const pmp_music_record_t* rec, uint32_t uid)
+static int set_music_record(
+ itunesdb_chunk_t* mhit,
+ const pmp_music_record_t* rec,
+ uint32_t uid,
+ const ucs2char_t* path_to_root
+ )
{
itunesdb_chunk_t* mhod = NULL;
chunk_mhit_t* mhit_data = (chunk_mhit_t*)mhit->data;
@@ -267,8 +273,8 @@
break;
}
mhit_data->compilation = rec->is_compilation ? 1 : 0;
- mhit_data->rating = 0;
- mhit_data->last_modified = rec->ts_update;
+ mhit_data->rating = rec->rating;
+ mhit_data->last_modified = (uint32_t)from_time((time_t)rec->ts_update);
mhit_data->filesize = rec->filesize;
mhit_data->duration = rec->duration;
mhit_data->track_number = rec->track_number;
@@ -278,7 +284,7 @@
mhit_data->samplerate = rec->sample_rate;
mhit_data->disc_number = rec->disc_number;
mhit_data->total_discs = rec->total_discs;
- mhit_data->date_added = rec->ts_import;
+ mhit_data->date_added = (uint32_t)from_time((time_t)rec->ts_import);
mhit_data->dbid = 0;
mhit_data->unk9 = 0xFFFF;
switch (rec->codec) {
@@ -343,10 +349,12 @@
}
/* Construct an "mhod" chunk for comment. */
- mhod = itunesdb_new_child(mhit);
- if (mhod) {
- itunesdb_init(mhod, "mhod", "comment");
- itunesdb_set_mhod_string(mhod, L"Some comment");
+ if (rec->comment && *rec->comment) {
+ mhod = itunesdb_new_child(mhit);
+ if (mhod) {
+ itunesdb_init(mhod, "mhod", "comment");
+ itunesdb_set_mhod_string(mhod, rec->comment);
+ }
}
/* Construct an "mhod" chunk for location. */
@@ -354,11 +362,11 @@
mhod = itunesdb_new_child(mhit);
if (mhod) {
ucs2char_t pathname[MAX_PATH], *p = NULL;
- itunesdb_init(mhod, "mhod", "location");
- ucs2cpy(pathname, rec->filename + 2);
+ ucs2cpy(pathname, filepath_skiproot(rec->filename, path_to_root, 1));
for (p = pathname;*p;++p) {
if (*p == PATHCHAR) *p = ':';
}
+ itunesdb_init(mhod, "mhod", "location");
itunesdb_set_mhod_string(mhod, pathname);
}
}
@@ -367,6 +375,87 @@
return 0;
}
+static int get_music_record(
+ itunesdb_chunk_t* mhit,
+ pmp_music_record_t* rec,
+ uint32_t uid,
+ const ucs2char_t* path_to_root
+ )
+{
+ uint32_t i;
+ itunesdb_chunk_t* mhod = NULL;
+ chunk_mhit_t* mhit_data = (chunk_mhit_t*)mhit->data;
+
+ switch (mhit_data->filetype) {
+ case 0x4D503320:
+ rec->codec = PMPCODEC_MPEGLAYER3;
+ rec->is_vbr = mhit_data->type1 ? 1 : 0;
+ break;
+ case 0x41414320:
+ rec->codec = PMPCODEC_MPEGAAC;
+ break;
+ case 0x4D344120:
+ rec->codec = PMPCODEC_MPEG4AUDIO;
+ break;
+ }
+
+ rec->is_compilation = mhit_data->compilation ? 1 : 0;
+ rec->rating = mhit_data->rating;
+ rec->ts_update = (uint64_t)to_time(mhit_data->last_modified);
+ rec->filesize = mhit_data->filesize;
+ rec->duration = mhit_data->duration;
+ rec->track_number = mhit_data->track_number;
+ rec->total_tracks = mhit_data->total_tracks;
+ //rec->date =
+ rec->bitrate = mhit_data->bitrate * 1000;
+ rec->sample_rate = mhit_data->samplerate;
+ rec->disc_number = mhit_data->disc_number;
+ rec->total_discs = mhit_data->total_discs;
+ rec->ts_import = (uint64_t)to_time(mhit_data->date_added);
+ switch (rec->codec) {
+ case PMPCODEC_MPEGLAYER3:
+ switch (mhit_data->unk14_1) {
+ case 0x0016: rec->codec_version = 200; break;
+ case 0x0020: rec->codec_version = 205; break;
+ default: rec->codec_version = 100; break;
+ }
+ break;
+ }
+ rec->num_samples = mhit_data->num_samples;
+
+ for (i = 0;i < mhit->num_children;++i) {
+ mhod = &mhit->childlen[i];
+ if (itunesdb_ischunk(mhod, "mhod", "title")) {
+ itunesdb_get_mhod_string(mhod, &rec->title);
+ } else if (itunesdb_ischunk(mhod, "mhod", "artist")) {
+ itunesdb_get_mhod_string(mhod, &rec->artist);
+ } else if (itunesdb_ischunk(mhod, "mhod", "album")) {
+ itunesdb_get_mhod_string(mhod, &rec->album);
+ } else if (itunesdb_ischunk(mhod, "mhod", "genre")) {
+ itunesdb_get_mhod_string(mhod, &rec->genre);
+ } else if (itunesdb_ischunk(mhod, "mhod", "comment")) {
+ itunesdb_get_mhod_string(mhod, &rec->comment);
+ } else if (itunesdb_ischunk(mhod, "mhod", "location")) {
+ ucs2char_t *location = NULL;
+ itunesdb_get_mhod_string(mhod, &location);
+ if (location) {
+ size_t length = 0;
+ ucs2char_t* p = NULL;
+ for (p = location;*p;++p) {
+ if (*p == ':') *p = PATHCHAR;
+ }
+ length = ucs2len(path_to_root) + ucs2len(location) + 3;
+ rec->filename = ucs2calloc(sizeof(ucs2char_t) * length);
+ if (rec->filename) {
+ filepath_combinepath(rec->filename, length, path_to_root, location);
+ }
+ ucs2free(location);
+ }
+ }
+ }
+ return 0;
+}
+
static int comp_string(const ucs2char_t* x, const ucs2char_t*y)
{
int ret = 0;
@@ -560,7 +649,7 @@
static uint32_t get_record_index(const ucs2char_t* filename, const pmp_music_record_t* records, int num_records)
{
- uint32_t i;
+ int i;
for (i = 0;i < num_records;++i) {
if (ucs2icmp(records[i].filename, filename) == 0) {
@@ -593,8 +682,8 @@
mhyp_data->num_mhod = mhyp->num_children;
/* */
- for (i = 0;i < playlist->num_entries;++i) {
- uint32_t index = get_record_index(playlist->entries[i], records, num_records);
+ for (i = 0;i < (int)playlist->num_entries;++i) {
+ int index = (int)get_record_index(playlist->entries[i], records, num_records);
if (index < num_records) {
mhip = itunesdb_new_child(mhyp);
@@ -622,7 +711,14 @@
return 0;
}
-result_t ipod_set(ipod_t* ipod, const pmp_music_record_t* records, int num_records, const pmp_playlist_t* playlists, int num_playlists)
+result_t ipod_set(
+ ipod_t* ipod,
+ const pmp_music_record_t* records,
+ int num_records,
+ const pmp_playlist_t* playlists,
+ int num_playlists,
+ const ucs2char_t* path_to_root
+ )
{
int i;
itunesdb_chunk_t *mhbd = NULL, *mhsd = NULL;
@@ -659,7 +755,7 @@
itunesdb_init(mhit, "mhit", NULL);
/* This will fill "mhit" chunk and create "mhod" chunks. */
- set_music_record(mhit, rec, i);
+ set_music_record(mhit, rec, i, path_to_root);
}
}
}
@@ -702,3 +798,59 @@
ipod->itunesdb = mhbd;
return 0;
}
+
+result_t ipod_get(
+ ipod_t* ipod,
+ pmp_music_record_t* records,
+ int *num_records,
+ pmp_playlist_t* playlists,
+ int *num_playlists,
+ const ucs2char_t* path_to_root
+ )
+{
+ uint32_t i, j, k;
+ itunesdb_chunk_t* mhbd = ipod->itunesdb;
+ itunesdb_chunk_t *mhsd = NULL;
+ itunesdb_chunk_t *mhlt = NULL, *mhit = NULL;
+ itunesdb_chunk_t *mhlp = NULL, *mhyp = NULL;
+
+ /* Initialize the numbers with zero. */
+ if (!records) *num_records = 0;
+ if (!playlists) *num_playlists = 0;
+
+ if (mhbd && strncmp(mhbd->id, "mhbd", 4) == 0) {
+ for (i = 0;i < mhbd->num_children;++i) {
+ mhsd = &mhbd->childlen[i];
+ if (mhsd && strncmp(mhsd->id, "mhsd", 4) == 0) {
+ chunk_mhsd_t* mhsd_data = (chunk_mhsd_t*)mhsd->data;
+ if (mhsd_data->type == 1) {
+ /* Track list. */
+ for (j = 0;j < mhsd->num_children;++j) {
+ mhlt = &mhsd->childlen[j];
+ if (mhlt && strncmp(mhlt->id, "mhlt", 4) == 0) {
+ if (records) {
+ /* Make sure the array has sufficient entries. */
+ if (*num_records < (int)mhlt->num_children) {
+ return PMPERR_INSUFFICIENTMEMORY;
+ }
+ /* Obtain media records. */
+ for (k = 0;k < mhlt->num_children;++k) {
+ mhit = &mhlt->childlen[k];
+ if (mhit && strncmp(mhit->id, "mhit", 4) == 0) {
+ get_music_record(mhit, &records[k], k, path_to_root);
+ }
+ }
+ } else {
+ /* Return the number of records. */
+ *num_records = mhlt->num_children;
+ }
+ }
+ }
+ } else if (mhsd_data->type == 2) {
+ /* Playlist list. */
+ }
+ }
+ }
+ }
+ return 0;
+}
Modified: trunk/pmplib/lib/pmp_ipod/ipod.h
===================================================================
--- trunk/pmplib/lib/pmp_ipod/ipod.h 2007-02-28 08:17:04 UTC (rev 401)
+++ trunk/pmplib/lib/pmp_ipod/ipod.h 2007-02-28 12:21:46 UTC (rev 402)
@@ -58,9 +58,24 @@
void ipod_init(ipod_t* ipod);
void ipod_finish(ipod_t* ipod);
-result_t ipod_set(ipod_t* ipod, const pmp_music_record_t* records, int num_records, const pmp_playlist_t* playlists, int num_playlists);
result_t ipod_read(ipod_t* ipod, const ucs2char_t* itunesdb, const ucs2char_t* playcounts);
result_t ipod_write(ipod_t* ipod, const ucs2char_t* itunesdb);
result_t ipod_dump(ipod_t* ipod, FILE *fpo);
+result_t ipod_set(
+ ipod_t* ipod,
+ const pmp_music_record_t* records,
+ int num_records,
+ const pmp_playlist_t* playlists,
+ int num_playlists,
+ const ucs2char_t* path_to_root
+ );
+result_t ipod_get(
+ ipod_t* ipod,
+ pmp_music_record_t* records,
+ int *num_records,
+ pmp_playlist_t* playlists,
+ int *num_playlists,
+ const ucs2char_t* path_to_root
+ );
#endif/*__IPOD_H__*/
Modified: trunk/pmplib/lib/pmp_ipod/itunesdb.c
===================================================================
--- trunk/pmplib/lib/pmp_ipod/itunesdb.c 2007-02-28 08:17:04 UTC (rev 401)
+++ trunk/pmplib/lib/pmp_ipod/itunesdb.c 2007-02-28 12:21:46 UTC (rev 402)
@@ -633,6 +633,17 @@
}
}
+int itunesdb_ischunk(itunesdb_chunk_t* chunk, const char *name, const char *subtype)
+{
+ if (strncmp(name, "mhod", 4) == 0) {
+ chunk_mhod_t* mhod = (chunk_mhod_t*)chunk->data;
+ const itunesdb_mhoddecl_t* decl = find_mhoddecl(chunk);
+ return (decl && strcmp(decl->name, subtype) == 0) ? 1 : 0;
+ } else {
+ return (strncmp(chunk->id, name, 4) == 0);
+ }
+}
+
void itunesdb_finish(itunesdb_chunk_t* chunk)
{
uint32_t i;
@@ -847,6 +858,24 @@
return 0;
}
+int itunesdb_get_mhod_string(itunesdb_chunk_t* chunk, ucs2char_t** value)
+{
+ chunk_mhod_t* mhod = (chunk_mhod_t*)chunk->data;
+ chunk_mhod_string_t* str = &mhod->data.str;
+
+ /* Make sure this is an "mhod" chunk. */
+ if (strncmp(chunk->id, "mhod", 4) != 0) {
+ return 1;
+ }
+
+ /* Store the string value. */
+ ucs2free(*value);
+ *value = (ucs2char_t*)ucs2calloc(str->size + sizeof(ucs2char_t));
+ ucs2ncpy(*value, str->value, str->size / sizeof(ucs2char_t));
+ return 0;
+}
+
+
int itunesdb_set_mhod_index(itunesdb_chunk_t* chunk, uint32_t type, sorted_index_t* si, uint32_t n)
{
uint32_t i;
Modified: trunk/pmplib/lib/pmp_ipod/itunesdb.h
===================================================================
--- trunk/pmplib/lib/pmp_ipod/itunesdb.h 2007-02-28 08:17:04 UTC (rev 401)
+++ trunk/pmplib/lib/pmp_ipod/itunesdb.h 2007-02-28 12:21:46 UTC (rev 402)
@@ -19,7 +19,7 @@
*
*/
-/* $Id:$ */
+/* $Id$ */
#ifndef __ITUNESDB_H__
#define __ITUNESDB_H__
@@ -253,6 +253,8 @@
*/
int itunesdb_init(itunesdb_chunk_t* chunk, const char *identifer, const char *subtype);
+int itunesdb_ischunk(itunesdb_chunk_t* chunk, const char *name, const char *subtype);
+
/**
* Create a new chunk and append it to the children of the parent chunk.
* @param chunk The chunk where a new child will be appended.
@@ -274,6 +276,8 @@
*/
int itunesdb_set_mhod_string(itunesdb_chunk_t* chunk, const ucs2char_t* str);
+int itunesdb_get_mhod_string(itunesdb_chunk_t* chunk, ucs2char_t** str);
+
/**
* Set sorted index to "mhod" chunk.
* @param chunk The pointer to "mhod" chunk.
Modified: trunk/pmplib/lib/pmp_ipod/pmp_ipod.c
===================================================================
--- trunk/pmplib/lib/pmp_ipod/pmp_ipod.c 2007-02-28 08:17:04 UTC (rev 401)
+++ trunk/pmplib/lib/pmp_ipod/pmp_ipod.c 2007-02-28 12:21:46 UTC (rev 402)
@@ -327,83 +327,63 @@
static uint32_t pmpmusic_open(pmp_music_t* music)
{
- //ip3db_t ip3db;
+ ipod_t ipod;
result_t ret = 0;
pmp_t* pmp = music->pmp;
pmp_music_internal_t* pmpmi = (pmp_music_internal_t*)music->instance;
+ ucs2char_t itunesdb[MAX_PATH], playcounts[MAX_PATH];
- /*
- // Initialize IP3DB.
- ip3db_init(&ip3db);
+ // Initialize ipod library.
+ ipod_init(&ipod);
- // Free the existing records.
- pmplib_records_finish(pmpmi->records, pmpmi->num_records);
- pmpmi->records = 0;
- pmpmi->num_records = 0;
+ // Read the music database.
+ set_filenames(itunesdb, playcounts, music->pmp);
- // Open the music database if necessary.
- if (pmp->flag & PMPOF_MUSIC_DB_READ) {
- int i;
- ucs2char_t dat[MAX_PATH], dic[MAX_PATH], idx[MAX_PATH];
- pmp_music_internal_t* pmpmi = (pmp_music_internal_t*)pmp->music->instance;
+ if (pmp->flag & (PMPOF_MUSIC_DB_READ|PMPOF_MUSIC_PL_READ)) {
+ int num_records = 0, num_playlists = 0;
- // Read the music database.
- set_filenames(dat, dic, idx, pmp);
- ret = ip3db_read(&ip3db, dat, dic, idx);
- if (ret) {
- goto exit_this;
+ ipod_read(&ipod, itunesdb, playcounts);
+ ipod_get(&ipod, NULL, &num_records, NULL, &num_playlists, pmp->info.path_to_root);
+
+ // Allocate records.
+ if (pmp->flag & PMPOF_MUSIC_DB_READ) {
+ if (0 < num_records) {
+ ucs2free(pmpmi->records);
+ pmpmi->records = (pmp_music_record_t*)ucs2calloc(sizeof(pmp_music_record_t) * num_records);
+ if (!pmpmi->records) {
+ ret = PMPERR_INSUFFICIENTMEMORY;
+ goto exit_this;
+ }
+ pmpmi->num_records = num_records;
+ }
+ } else {
+ ucs2free(pmpmi->records);
+ pmpmi->records = 0;
+ pmpmi->num_records = 0;
}
- // The number of music records.
- pmpmi->num_records = ip3db_num_records(&ip3db);
-
- // Allocate an array of the records.
- pmpmi->records = (pmp_music_record_t*)malloc(sizeof(pmp_music_record_t) * pmpmi->num_records);
-
- // Convert IP3DB records to a pmp_music_record_t array.
- for (i = 0;i < pmpmi->num_records;++i) {
- const ip3db_variant_t* src = (const ip3db_variant_t*)ip3db_get_record(&ip3db, i);
- pmp_music_record_t* dst = &pmpmi->records[i];
- size_t length = 0;
-
- pmplib_record_init(dst);
-
- length = ucs2len(pmp->info.path_to_root);
- length += ucs2len(src[IP3DBF_MUSIC_FILEPATH].value.str);
- length += ucs2len(src[IP3DBF_MUSIC_FILENAME].value.str);
- dst->filename = (ucs2char_t*)ucs2malloc(sizeof(ucs2char_t) * (length+1));
- ucs2cpy(dst->filename, pmp->info.path_to_root);
- ucs2cat(dst->filename, src[IP3DBF_MUSIC_FILEPATH].value.str+1);
- ucs2cat(dst->filename, src[IP3DBF_MUSIC_FILENAME].value.str);
- filepath_backslash(dst->filename);
-
- dst->title = ucs2dup(src[IP3DBF_MUSIC_TITLE].value.str);
- dst->artist = ucs2dup(src[IP3DBF_MUSIC_ARTIST].value.str);
- dst->album = ucs2dup(src[IP3DBF_MUSIC_ALBUM].value.str);
- dst->genre = ucs2dup(src[IP3DBF_MUSIC_GENRE].value.str);
- dst->date = ucs2dup(src[IP3DBF_MUSIC_ORGRELEASEDATE].value.str);
- switch (src[IP3DBF_MUSIC_FILEFORMAT].value.word) {
- case 0:
- dst->codec = PMPCODEC_MPEGLAYER3;
- break;
- case 3:
- dst->codec = PMPCODEC_VORBIS;
- break;
- case 5:
- dst->codec = PMPCODEC_WMA;
- break;
+ // Allocate playlists.
+ if (pmp->flag & PMPOF_MUSIC_PL_READ) {
+ if (0 < num_playlists) {
+ ucs2free(pmpmi->playlists);
+ pmpmi->playlists = (pmp_playlist_t*)ucs2calloc(sizeof(pmp_playlist_t) * num_playlists);
+ if (!pmpmi->playlists) {
+ ret = PMPERR_INSUFFICIENTMEMORY;
+ goto exit_this;
+ }
+ pmpmi->num_playlists = num_playlists;
}
- dst->track_number = src[IP3DBF_MUSIC_TRACKNUMBER].value.word;
- dst->bitrate = src[IP3DBF_MUSIC_BITRATE].value.dword;
- dst->duration = src[IP3DBF_MUSIC_DURATION].value.dword;
- dst->ts_update = src[IP3DBF_MUSIC_CLUSA].value.dword;
- dst->rating = src[IP3DBF_MUSIC_RATING].value.word;
+ } else {
+ ucs2free(pmpmi->playlists);
+ pmpmi->playlists = 0;
+ pmpmi->num_playlists = 0;
}
+
+ ipod_get(&ipod, pmpmi->records, &num_records, pmpmi->playlists, &num_playlists, pmp->info.path_to_root);
}
- */
exit_this:
- //ip3db_finish(&ip3db);
+ ipod_finish(&ipod);
return ret;
}
@@ -422,7 +402,7 @@
set_filenames(itunesdb, playcounts, music->pmp);
if (pmp->flag & PMPOF_MUSIC_DB_WRITE) {
- ipod_set(&ipod, pmpmi->records, pmpmi->num_records, pmpmi->playlists, pmpmi->num_playlists);
+ ipod_set(&ipod, pmpmi->records, pmpmi->num_records, pmpmi->playlists, pmpmi->num_playlists, pmp->info.path_to_root);
ipod_write(&ipod, itunesdb);
}
Modified: trunk/pmplib/lib/pmp_ipod/util.c
===================================================================
--- trunk/pmplib/lib/pmp_ipod/util.c 2007-02-28 08:17:04 UTC (rev 401)
+++ trunk/pmplib/lib/pmp_ipod/util.c 2007-02-28 12:21:46 UTC (rev 402)
@@ -19,7 +19,7 @@
*
*/
-/* $Id:$ */
+/* $Id$ */
#ifdef HAVE_CONFIG_H
#include <config.h>
@@ -153,23 +153,12 @@
return 0;
}
-void filepath_slash(ucs2char_t* path)
+time_t to_time(uint64_t t)
{
- while (*path) {
- if (*path == 0x005C) {
- *path = 0x002F;
- }
- path++;
- }
+ return (time_t)((2082844800 < t) ? (t - 2082844800) : 0);
}
-void filepath_backslash(ucs2char_t* path)
+uint64_t from_time(time_t t)
{
- while (*path) {
- if (*path == 0x002F) {
- *path = 0x005C;
- }
- path++;
- }
+ return (uint64_t)t + 2082844800;
}
-
Modified: trunk/pmplib/lib/pmp_ipod/util.h
===================================================================
--- trunk/pmplib/lib/pmp_ipod/util.h 2007-02-28 08:17:04 UTC (rev 401)
+++ trunk/pmplib/lib/pmp_ipod/util.h 2007-02-28 12:21:46 UTC (rev 402)
@@ -35,7 +35,7 @@
int fread_all(FILE *fp, uint8_t** ptr_buffer, long* ptr_size);
-void filepath_slash(ucs2char_t* path);
-void filepath_backslash(ucs2char_t* path);
+time_t to_time(uint64_t t);
+uint64_t from_time(time_t t);
#endif/*__IP3DB_UTIL_H__*/
Modified: trunk/pmplib/lib/pmp_iriverplus2/ip2db.c
===================================================================
--- trunk/pmplib/lib/pmp_iriverplus2/ip2db.c 2007-02-28 08:17:04 UTC (rev 401)
+++ trunk/pmplib/lib/pmp_iriverplus2/ip2db.c 2007-02-28 12:21:46 UTC (rev 402)
@@ -196,7 +196,7 @@
}
dst->entry_number = j+1;
- dst->pathname = ucs2dup(filepath_changeroot(src->filename, path_to_root));
+ dst->pathname = ucs2dup(filepath_skiproot(src->filename, path_to_root, 1));
filepath_remove_filespec(dst->pathname);
filepath_encode(dst->pathname);
dst->filename = ucs2dup(filepath_skippath(src->filename));
@@ -206,7 +206,7 @@
dst->genre = ucs2dup(src->genre ? src->genre : ucs2cs_unknown);
dst->rating = src->rating;
dst->play_count = src->play_count;
- dst->recent_play = src->ts_playback;
+ dst->recent_play = (uint32_t)src->ts_playback;
dst->track_number = src->track_number;
if (src->date) {
dst->year = ucs2toi(src->date);
@@ -215,7 +215,7 @@
dst->duration = src->duration / 1000;
dst->sample_rate = src->sample_rate;
dst->bitrate = src->bitrate;
- dst->timestamp = src->ts_update;
+ dst->timestamp = (uint32_t)src->ts_update;
++j;
}
Modified: trunk/pmplib/lib/pmp_iriverplus2/playlist.c
===================================================================
--- trunk/pmplib/lib/pmp_iriverplus2/playlist.c 2007-02-28 08:17:04 UTC (rev 401)
+++ trunk/pmplib/lib/pmp_iriverplus2/playlist.c 2007-02-28 12:21:46 UTC (rev 402)
@@ -58,7 +58,7 @@
filepath_decode(decoded_filename);
// 2. As above, with mount point prefix stripped.
- ucs2cpy(decoded_filepathname, filepath_changeroot(decoded_filename, path_to_root));
+ ucs2cpy(decoded_filepathname, filepath_skiproot(decoded_filename, path_to_root, 1));
// 3. As above, but with filename stripped.
ucs2cpy(decoded_pathname, decoded_filepathname);
Modified: trunk/pmplib/lib/pmp_iriverplus3/dat.c
===================================================================
--- trunk/pmplib/lib/pmp_iriverplus3/dat.c 2007-02-28 08:17:04 UTC (rev 401)
+++ trunk/pmplib/lib/pmp_iriverplus3/dat.c 2007-02-28 12:21:46 UTC (rev 402)
@@ -305,7 +305,7 @@
static sort_index_t* dat_uidmap_create(dat_list_t* list)
{
- int i;
+ uint32_t i;
sort_index_t* si = (sort_index_t*)malloc(sizeof(sort_index_t) * list->num_entries);
if (si) {
@@ -574,7 +574,7 @@
static uint32_t findfile(dat_t* dat, const ucs2char_t *filename)
{
- int i;
+ uint32_t i;
const ucs2char_t *filepart = NULL;
ucs2char_t *pathname = alloca(sizeof(ucs2char_t) * (ucs2len(filename) + 1));
@@ -767,7 +767,7 @@
qsort(objects, num_objects, sizeof(objects[0]), comp_pathname);
/* Loop for the records. */
- for (i = 0;i < num_objects;++i) {
+ for (i = 0;i < (int)num_objects;++i) {
/*
* Split a path name into two parts: a prefix that have already been
* registered in the Object table: and a postfix that is being registered
Modified: trunk/pmplib/lib/pmp_iriverplus3/dic.c
===================================================================
--- trunk/pmplib/lib/pmp_iriverplus3/dic.c 2007-02-28 08:17:04 UTC (rev 401)
+++ trunk/pmplib/lib/pmp_iriverplus3/dic.c 2007-02-28 12:21:46 UTC (rev 402)
@@ -145,7 +145,8 @@
static size_t dic_table_serialize(uint8_t* buffer, uint32_t start, dic_table_t* list, int is_storing)
{
- uint32_t i, next;
+ int i;
+ uint32_t next;
uint8_t *p = buffer + start;
p += serialize_uint32be(p, &list->unknown0, is_storing);
Modified: trunk/pmplib/lib/pmp_iriverplus3/idx.c
===================================================================
--- trunk/pmplib/lib/pmp_iriverplus3/idx.c 2007-02-28 08:17:04 UTC (rev 401)
+++ trunk/pmplib/lib/pmp_iriverplus3/idx.c 2007-02-28 12:21:46 UTC (rev 402)
@@ -160,7 +160,7 @@
static uint32_t avlnode_new(avl_t* avl, size_t keysize)
{
- uint32_t offset = avl_allocate(avl, sizeof(avlnode_t) + keysize);
+ uint32_t offset = (uint32_t)avl_allocate(avl, sizeof(avlnode_t) + keysize);
avlnode_t* a = avlnode(avl, offset);
a->left = 0;
a->right = 0;
Modified: trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c
===================================================================
--- trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c 2007-02-28 08:17:04 UTC (rev 401)
+++ trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c 2007-02-28 12:21:46 UTC (rev 402)
@@ -576,7 +576,7 @@
ip3db_variant_t* dst = records[i];
ip3db_record_init(&ip3db, &records[i]);
- ip3db_variant_set_str(&dst[IP3DBF_MUSIC_FILEPATH], filepath_changeroot(src->filename, pmp->info.path_to_root));
+ ip3db_variant_set_str(&dst[IP3DBF_MUSIC_FILEPATH], filepath_skiproot(src->filename, pmp->info.path_to_root, 1));
filepath_remove_filespec(dst[IP3DBF_MUSIC_FILEPATH].value.str);
filepath_addslash(dst[IP3DBF_MUSIC_FILEPATH].value.str);
filepath_slash(dst[IP3DBF_MUSIC_FILEPATH].value.str);
@@ -600,7 +600,7 @@
}
ip3db_variant_set_word(&dst[IP3DBF_MUSIC_TRACKNUMBER], (uint16_t)src->track_number);
ip3db_variant_set_dword(&dst[IP3DBF_MUSIC_BITRATE], src->bitrate);
- ip3db_variant_set_dword(&dst[IP3DBF_MUSIC_CLUSA], src->ts_update);
+ ip3db_variant_set_dword(&dst[IP3DBF_MUSIC_CLUSA], (uint32_t)src->ts_update);
ip3db_variant_set_dword(&dst[IP3DBF_MUSIC_UID], (uint32_t)i+1);
}
@@ -708,7 +708,7 @@
static result_t pmpmusic_set_playlists(pmp_music_t* music, const pmp_playlist_t* playlists, uint32_t num_playlists)
{
- uint32_t i, j;
+ int i, j;
static const ucs2char_t rootdir[] = {PATHCHAR,0};
static const ucs2char_t plp_ext[] = {'.','p','l','p',0};
pmp_music_internal_t* pmpmi = (pmp_music_internal_t*)music->instance;
@@ -724,7 +724,7 @@
pmpmi->num_playlists = num_playlists;
// Copy the content of the playlists.
- for (i = 0;i < num_playlists;++i) {
+ for (i = 0;i < (int)num_playlists;++i) {
ucs2char_t filepath[MAX_PATH];
const pmp_playlist_t* src = &playlists[i];
ip3db_playlist_t* dst = &pmpmi->playlists[i];
@@ -735,7 +735,7 @@
filepath_combinepath(filepath, MAX_PATH, rootdir, music->pmp->info.path_to_playlist);
filepath_addslash(filepath);
- dst->filepath = ucs2dup(filepath_changeroot(filepath, music->pmp->info.path_to_root));
+ dst->filepath = ucs2dup(filepath_skiproot(filepath, music->pmp->info.path_to_root, 1));
filepath_slash(dst->filepath);
dst->num_entries = src->num_entries;
@@ -743,7 +743,7 @@
for (j = 0;j < src->num_entries;++j) {
ucs2char_t filename[MAX_PATH];
- ucs2cpy(filename, filepath_changeroot(src->entries[j], music->pmp->info.path_to_root));
+ ucs2cpy(filename, filepath_skiproot(src->entries[j], music->pmp->info.path_to_root, 1));
filepath_slash(filename);
dst->entries[j] = ucs2dup(filename);
}
Modified: trunk/pmplib/lib/pmp_irivnavi/playlist.c
===================================================================
--- trunk/pmplib/lib/pmp_irivnavi/playlist.c 2007-02-28 08:17:04 UTC (rev 401)
+++ trunk/pmplib/lib/pmp_irivnavi/playlist.c 2007-02-28 12:21:46 UTC (rev 402)
@@ -63,7 +63,7 @@
if (mediafiles[i][0]) {
char *mbs = NULL;
ucs2char_t filename[MAX_PATH];
- ucs2cpy(filename, filepath_changeroot(mediafiles[i], path_to_root));
+ ucs2cpy(filename, filepath_skiproot(mediafiles[i], path_to_root, 1));
filepath_encode(filename);
Modified: trunk/pmplib/lib/pmp_irivnavi/pmp_irivnavi.c
===================================================================
--- trunk/pmplib/lib/pmp_irivnavi/pmp_irivnavi.c 2007-02-28 08:17:04 UTC (rev 401)
+++ trunk/pmplib/lib/pmp_irivnavi/pmp_irivnavi.c 2007-02-28 12:21:46 UTC (rev 402)
@@ -478,12 +478,12 @@
// Set record fields.
record_init(dst);
- dst->filename = ucs2dupmbs(filepath_changeroot(src->filename, music->pmp->info.path_to_root));
+ dst->filename = ucs2dupmbs(filepath_skiproot(src->filename, music->pmp->info.path_to_root, 1));
dst->title = src->title ? ucs2dupmbs(src->title) : ucs2dupmbs(filepath_skippath(src->filename));;
dst->artist = ucs2dupmbs(src->artist ? src->artist : ucs2cs_unknown);
dst->album = ucs2dupmbs(src->album ? src->album : ucs2cs_unknown);
dst->genre = ucs2dupmbs(src->genre ? src->genre : ucs2cs_unknown);
- dst->timestamp = src->ts_update;
+ dst->timestamp = (uint32_t)src->ts_update;
++j;
}
Modified: trunk/pmplib/lib/pmp_portalplayer1/model_iriver_h10.c
===================================================================
--- trunk/pmplib/lib/pmp_portalplayer1/model_iriver_h10.c 2007-02-28 08:17:04 UTC (rev 401)
+++ trunk/pmplib/lib/pmp_portalplayer1/model_iriver_h10.c 2007-02-28 12:21:46 UTC (rev 402)
@@ -100,7 +100,7 @@
// Set fields.
dst->status = 0;
dst->unknown1 = 0;
- dst->fields[PP1DB_DATFIELD_PATHNAME].value.str = ucs2dup(filepath_skiproot(src->filename, path_to_root));
+ dst->fields[PP1DB_DATFIELD_PATHNAME].value.str = ucs2dup(filepath_skiproot(src->filename, path_to_root, 0));
filepath_remove_filespec(dst->fields[PP1DB_DATFIELD_PATHNAME].value.str);
filepath_addslash(dst->fields[PP1DB_DATFIELD_PATHNAME].value.str);
filepath_encode(dst->fields[PP1DB_DATFIELD_PATHNAME].value.str);
@@ -112,7 +112,7 @@
dst->fields[PP1DB_DATFIELD_GENRE].value.str = ucs2dup(src->genre ? src->genre : ucs2cs_unknown);
dst->fields[PP1DB_DATFIELD_RATING].value.dword = src->rating;
dst->fields[PP1DB_DATFIELD_PLAYCOUNT].value.dword = src->play_count;
- dst->fields[PP1DB_DATFIELD_RECENTPLAY].value.dword = src->ts_playback;
+ dst->fields[PP1DB_DATFIELD_RECENTPLAY].value.dword = (uint32_t)src->ts_playback;
dst->fields[PP1DB_DATFIELD_UNKNOWN3].value.dword = 0;
dst->fields[PP1DB_DATFIELD_TRACKNUMBER].value.dword = src->track_number;
if (src->date) {
@@ -124,7 +124,7 @@
dst->fields[PP1DB_DATFIELD_BITRATE].value.dword = src->bitrate;
dst->fields[PP1DB_DATFIELD_UNKNOWN4].value.dword = 0;
dst->fields[PP1DB_DATFIELD_UNKNOWN5].value.str = ucs2dup(ucs2cs_empty);
- dst->fields[PP1DB_DATFIELD_UNKNOWN6].value.dword = src->ts_update;
+ dst->fields[PP1DB_DATFIELD_UNKNOWN6].value.dword = (uint32_t)src->ts_update;
dst->fields[PP1DB_DATFIELD_UNKNOWN7].value.str = ucs2dup(ucs2cs_empty);
return 0;
}
Modified: trunk/pmplib/lib/pmp_portalplayer1/model_medion_mdjuke220.c
===================================================================
--- trunk/pmplib/lib/pmp_portalplayer1/model_medion_mdjuke220.c 2007-02-28 08:17:04 UTC (rev 401)
+++ trunk/pmplib/lib/pmp_portalplayer1/model_medion_mdjuke220.c 2007-02-28 12:21:46 UTC (rev 402)
@@ -86,7 +86,7 @@
// Set fields.
dst->status = 0;
dst->unknown1 = 0;
- dst->fields[PP1DB_DATFIELD_PATHNAME].value.str = ucs2dup(filepath_skiproot(src->filename, path_to_root));
+ dst->fields[PP1DB_DATFIELD_PATHNAME].value.str = ucs2dup(filepath_skiproot(src->filename, path_to_root, 0));
filepath_remove_filespec(dst->fields[PP1DB_DATFIELD_PATHNAME].value.str);
filepath_addslash(dst->fields[PP1DB_DATFIELD_PATHNAME].value.str);
filepath_encode(dst->fields[PP1DB_DATFIELD_PATHNAME].value.str);
Modified: trunk/pmplib/lib/pmp_portalplayer1/model_medion_mdjuke440.c
===================================================================
--- trunk/pmplib/lib/pmp_portalplayer1/model_medion_mdjuke440.c 2007-02-28 08:17:04 UTC (rev 401)
+++ trunk/pmplib/lib/pmp_portalplayer1/model_medion_mdjuke440.c 2007-02-28 12:21:46 UTC (rev 402)
@@ -74,7 +74,7 @@
// Set fields.
dst->status = 0;
dst->unknown1 = 0;
- dst->fields[PP1DB_DATFIELD_PATHNAME].value.str = ucs2dup(filepath_skiproot(src->filename, path_to_root));
+ dst->fields[PP1DB_DATFIELD_PATHNAME].value.str = ucs2dup(filepath_skiproot(src->filename, path_to_root, 0));
filepath_remove_filespec(dst->fields[PP1DB_DATFIELD_PATHNAME].value.str);
filepath_addslash(dst->fields[PP1DB_DATFIELD_PATHNAME].value.str);
filepath_encode(dst->fields[PP1DB_DATFIELD_PATHNAME].value.str);
Modified: trunk/pmplib/lib/pmp_portalplayer1/model_msi_megaplayer.c
===================================================================
--- trunk/pmplib/lib/pmp_portalplayer1/model_msi_megaplayer.c 2007-02-28 08:17:04 UTC (rev 401)
+++ trunk/pmplib/lib/pmp_portalplayer1/model_msi_megaplayer.c 2007-02-28 12:21:46 UTC (rev 402)
@@ -85,7 +85,7 @@
// Set fields.
dst->status = 0;
dst->unknown1 = 0;
- dst->fields[PP1DB_DATFIELD_PATHNAME].value.str = ucs2dup(filepath_skiproot(src->filename, path_to_root));
+ dst->fields[PP1DB_DATFIELD_PATHNAME].value.str = ucs2dup(filepath_skiproot(src->filename, path_to_root, 0));
filepath_remove_filespec(dst->fields[PP1DB_DATFIELD_PATHNAME].value.str);
filepath_addslash(dst->fields[PP1DB_DATFIELD_PATHNAME].value.str);
filepath_encode(dst->fields[PP1DB_DATFIELD_PATHNAME].value.str);
Modified: trunk/pmplib/lib/pmp_portalplayer1/model_philips_hdd6320.c
===================================================================
--- trunk/pmplib/lib/pmp_portalplayer1/model_philips_hdd6320.c 2007-02-28 08:17:04 UTC (rev 401)
+++ trunk/pmplib/lib/pmp_portalplayer1/model_philips_hdd6320.c 2007-02-28 12:21:46 UTC (rev 402)
@@ -90,7 +90,7 @@
// Set fields.
dst->status = 0;
dst->unknown1 = 0;
- dst->fields[PP1DB_DATFIELD_PATHNAME].value.str = ucs2dup(filepath_skiproot(src->filename, path_to_root));
+ dst->fields[PP1DB_DATFIELD_PATHNAME].value.str = ucs2dup(filepath_skiproot(src->filename, path_to_root, 0));
filepath_remove_filespec(dst->fields[PP1DB_DATFIELD_PATHNAME].value.str);
filepath_addslash(dst->fields[PP1DB_DATFIELD_PATHNAME].value.str);
filepath_encode(dst->fields[PP1DB_DATFIELD_PATHNAME].value.str);
Modified: trunk/pmplib/lib/pmp_portalplayer1/model_samsung.c
===================================================================
--- trunk/pmplib/lib/pmp_portalplayer1/model_samsung.c 2007-02-28 08:17:04 UTC (rev 401)
+++ trunk/pmplib/lib/pmp_portalplayer1/model_samsung.c 2007-02-28 12:21:46 UTC (rev 402)
@@ -92,7 +92,7 @@
// Set fields.
dst->status = 0;
dst->unknown1 = 0;
- dst->fields[PP1DB_DATFIELD_PATHNAME].value.str = ucs2dup(filepath_skiproot(src->filename, path_to_root));
+ dst->fields[PP1DB_DATFIELD_PATHNAME].value.str = ucs2dup(filepath_skiproot(src->filename, path_to_root, 0));
filepath_remove_filespec(dst->fields[PP1DB_DATFIELD_PATHNAME].value.str);
filepath_addslash(dst->fields[PP1DB_DATFIELD_PATHNAME].value.str);
filepath_encode(dst->fields[PP1DB_DATFIELD_PATHNAME].value.str);
@@ -110,7 +110,7 @@
dst->fields[PP1DB_DATFIELD_YEAR].value.dword = ucs2toi(src->date);
}
dst->fields[PP1DB_DATFIELD_FILESIZE].value.dword = src->filesize;
- dst->fields[PP1DB_DATFIELD_UNKNOWN4].value.dword = src->ts_update;
+ dst->fields[PP1DB_DATFIELD_UNKNOWN4].value.dword = (uint32_t)src->ts_update;
dst->fields[PP1DB_DATFIELD_UNKNOWN5].value.str = ucs2dup(ucs2cs_empty);
dst->fields[PP1DB_DATFIELD_UNKNOWN6].value.str = ucs2dup(ucs2cs_empty);
dst->fields[PP1DB_DATFIELD_UNKNOWN7].value.str = ucs2dup(ucs2cs_empty);
Modified: trunk/pmplib/lib/pmp_portalplayer1/model_sirius_s50.c
===================================================================
--- trunk/pmplib/lib/pmp_portalplayer1/model_sirius_s50.c 2007-02-28 08:17:04 UTC (rev 401)
+++ trunk/pmplib/lib/pmp_portalplayer1/model_sirius_s50.c 2007-02-28 12:21:46 UTC (rev 402)
@@ -105,7 +105,7 @@
// Set fields.
dst->status = 0;
dst->unknown1 = 0;
- dst->fields[PP1DB_DATFIELD_PATHNAME].value.str = ucs2dup(filepath_skiproot(src->filename, path_to_root));
+ dst->fields[PP1DB_DATFIELD_PATHNAME].value.str = ucs2dup(filepath_skiproot(src->filename, path_to_root, 0));
filepath_remove_filespec(dst->fields[PP1DB_DATFIELD_PATHNAME].value.str);
filepath_addslash(dst->fields[PP1DB_DATFIELD_PATHNAME].value.str);
filepath_encode(dst->fields[PP1DB_DATFIELD_PATHNAME].value.str);
Modified: trunk/pmplib/lib/pmp_portalplayer1/playlist.c
===================================================================
--- trunk/pmplib/lib/pmp_portalplayer1/playlist.c 2007-02-28 08:17:04 UTC (rev 401)
+++ trunk/pmplib/lib/pmp_portalplayer1/playlist.c 2007-02-28 12:21:46 UTC (rev 402)
@@ -85,7 +85,7 @@
for (i = 0;i < num_mediafiles;i++) {
if (mediafiles[i][0]) {
ucs2char_t filename[MAX_PATH];
- ucs2cpy(filename, filepath_skiproot(mediafiles[i], path_to_root));
+ ucs2cpy(filename, filepath_skiproot(mediafiles[i], path_to_root, 0));
filepath_encode(filename);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ny...@us...> - 2007-02-28 08:17:04
|
Revision: 401
http://svn.sourceforge.net/pmplib/?rev=401&view=rev
Author: nyaochi
Date: 2007-02-28 00:17:04 -0800 (Wed, 28 Feb 2007)
Log Message:
-----------
Added reader/dumper for "Play Count" file.
Modified Paths:
--------------
trunk/pmplib/lib/pmp_ipod/ipod.c
trunk/pmplib/lib/pmp_ipod/ipod.h
trunk/pmplib/lib/pmp_ipod/pmp_ipod.c
trunk/pmplib/lib/pmp_ipod/pmp_ipod.vcproj
Added Paths:
-----------
trunk/pmplib/lib/pmp_ipod/playcounts.c
trunk/pmplib/lib/pmp_ipod/playcounts.h
Modified: trunk/pmplib/lib/pmp_ipod/ipod.c
===================================================================
--- trunk/pmplib/lib/pmp_ipod/ipod.c 2007-02-27 15:20:57 UTC (rev 400)
+++ trunk/pmplib/lib/pmp_ipod/ipod.c 2007-02-28 08:17:04 UTC (rev 401)
@@ -39,6 +39,7 @@
#include "ipod.h"
#include "ipodprop.h"
#include "itunesdb.h"
+#include "playcounts.h"
#define COMP(a, b) ((a)>(b))-((a)<(b))
@@ -47,6 +48,7 @@
"apple_ipod", "Apple", "iPod", "UM",
"---", "---",
"iPod_Control\\iTunes\\iTunesDB",
+ "iPod_Control\\iTunes\\Play Counts",
".mp3\0.m4a\0",
{PMPCODEC_MPEGLAYER3, PMPCODEC_MPEG4AUDIO, 0, 0, 0, 0, 0, 0},
"iPod_Control", "iPod_Control\\Music", "Playlists",
@@ -56,6 +58,7 @@
NULL, NULL,
NULL,
NULL,
+ NULL,
{0, 0, 0, 0, 0, 0, 0, 0},
NULL, NULL, NULL,
},
@@ -155,19 +158,23 @@
void ipod_init(ipod_t* ipod)
{
- ipod->itunesdb = calloc(1, sizeof(itunesdb_chunk_t));
+ ipod->itunesdb = (itunesdb_chunk_t*)calloc(1, sizeof(itunesdb_chunk_t));
+ ipod->pcs = (playcounts_t*)calloc(1, sizeof(playcounts_t));
}
void ipod_finish(ipod_t* ipod)
{
+ playcounts_finish(ipod->pcs);
itunesdb_finish(ipod->itunesdb);
+ free(ipod->pcs);
free(ipod->itunesdb);
}
-result_t ipod_read(ipod_t* ipod, const ucs2char_t* itunesdb)
+result_t ipod_read(ipod_t* ipod, const ucs2char_t* itunesdb, const ucs2char_t* playcounts)
{
FILE *fp = NULL;
+ /* Read iTunesDB. */
fp = ucs2fopen(itunesdb, "rb");
if (fp) {
serializer_t sio;
@@ -179,12 +186,28 @@
serialize_init_read(&sio, buffer, (size_t)size);
itunesdb_read(ipod->itunesdb, &sio);
- serialize_finish(&sio);
+ serialize_finish(&sio); /* This will free the buffer. */
+ } else {
+ return 1;
+ }
- return 0;
+ /* Read "Play Counts". */
+ fp = ucs2fopen(playcounts, "rb");
+ if (fp) {
+ serializer_t sio;
+ uint8_t* buffer = NULL;
+ long size = 0;
+
+ fread_all(fp, &buffer, &size);
+ fclose(fp);
+
+ serialize_init_read(&sio, buffer, (size_t)size);
+ playcounts_serialize(ipod->pcs, &sio);
+ serialize_finish(&sio); /* This will free the buffer. */
} else {
return 1;
}
+ return 0;
}
result_t ipod_write(ipod_t* ipod, const ucs2char_t* itunesdb)
@@ -212,7 +235,15 @@
{
serializer_t sio;
serialize_init_dump(&sio, fpo, 2);
+
+ fprintf(fpo, "[iTunesDB]\n");
itunesdb_repr(ipod->itunesdb, 0, &sio);
+ fprintf(fpo, "\n");
+
+ fprintf(fpo, "[Play Counts]\n");
+ playcounts_serialize(ipod->pcs, &sio);
+ fprintf(fpo, "\n");
+
serialize_finish(&sio);
return 0;
}
Modified: trunk/pmplib/lib/pmp_ipod/ipod.h
===================================================================
--- trunk/pmplib/lib/pmp_ipod/ipod.h 2007-02-27 15:20:57 UTC (rev 400)
+++ trunk/pmplib/lib/pmp_ipod/ipod.h 2007-02-28 08:17:04 UTC (rev 401)
@@ -34,6 +34,7 @@
const char *min_version;
const char *max_version;
const char *itunesdb_filename;
+ const char *playcounts_filename;
const char *extensions;
uint32_t codecs[8];
const char *path_to_system;
@@ -44,8 +45,12 @@
struct tag_itunesdb_chunk;
typedef struct tag_itunesdb_chunk itunesdb_chunk_t;
+struct tag_playcounts;
+typedef struct tag_playcounts playcounts_t;
+
typedef struct {
itunesdb_chunk_t* itunesdb;
+ playcounts_t* pcs;
} ipod_t;
const ipod_descriptor_t* ipod_detect(const ucs2char_t* path_to_device, const char *id, pmp_device_information_t* ptr_info);
@@ -54,7 +59,7 @@
void ipod_init(ipod_t* ipod);
void ipod_finish(ipod_t* ipod);
result_t ipod_set(ipod_t* ipod, const pmp_music_record_t* records, int num_records, const pmp_playlist_t* playlists, int num_playlists);
-result_t ipod_read(ipod_t* ipod, const ucs2char_t* itunesdb);
+result_t ipod_read(ipod_t* ipod, const ucs2char_t* itunesdb, const ucs2char_t* playcounts);
result_t ipod_write(ipod_t* ipod, const ucs2char_t* itunesdb);
result_t ipod_dump(ipod_t* ipod, FILE *fpo);
Added: trunk/pmplib/lib/pmp_ipod/playcounts.c
===================================================================
--- trunk/pmplib/lib/pmp_ipod/playcounts.c (rev 0)
+++ trunk/pmplib/lib/pmp_ipod/playcounts.c 2007-02-28 08:17:04 UTC (rev 401)
@@ -0,0 +1,147 @@
+/*
+ * Reader and dumper for "Play Counts" file.
+ *
+ * Copyright (c) 2005-2007 Naoaki Okazaki
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+/* $Id:$ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif/*HAVE_CONFIG_H*/
+
+#include <os.h>
+#include <stdio.h>
+#include <stdlib.h>
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif/*HAVE_STRING_H*/
+#include <pmplib/ucs2char.h>
+
+#include "ipod.h"
+#include "serialize.h"
+#include "util.h"
+#include "playcounts.h"
+
+static void playcount_init(playcount_entry_t* entry)
+{
+ memset(entry, 0, sizeof(*entry));
+}
+
+static int playcount_serialize(playcount_entry_t* entry, const playcounts_t* pcs, serializer_t* sio)
+{
+ size_t begin = serialize_tell(sio);
+
+ if (serialize_uint32le(sio, "play_count", "%u", &entry->play_count)) return 1;
+ if (serialize_uint32le(sio, "last_played", "%u", &entry->last_played)) return 1;
+ if (serialize_uint32le(sio, "audio_bookmark", "%u", &entry->audio_bookmark)) return 1;
+
+ if (serialize_reading(sio) && begin + pcs->entry_size <= serialize_tell(sio)) return 0;
+ if (serialize_uint32le(sio, "rating", "%u", &entry->rating)) return 1;
+
+ if (serialize_reading(sio) && begin + pcs->entry_size <= serialize_tell(sio)) return 0;
+ if (serialize_uint32le(sio, "unknown", "%u", &entry->unknown)) return 1;
+
+ if (serialize_reading(sio) && begin + pcs->entry_size <= serialize_tell(sio)) return 0;
+ if (serialize_uint32le(sio, "skip_count", "%u", &entry->skip_count)) return 1;
+ if (serialize_uint32le(sio, "last_skipped", "%u", &entry->last_skipped)) return 1;
+
+ /* Padding data if any. */
+ if (serialize_reading(sio)) {
+ if (serialize_tell(sio) < begin + pcs->entry_size) {
+ entry->padding_size = pcs->entry_size - (serialize_tell(sio) - begin);
+ entry->padding = (uint8_t*)calloc(entry->padding_size, 1);
+ }
+ }
+ if (entry->padding) {
+ if (serialize_uint8_array(sio, "padding", "%02X ", entry->padding, entry->padding_size)) return 1;
+ }
+
+ return 0;
+}
+
+void playcounts_init(playcounts_t* pcs)
+{
+ memset(pcs, 0, sizeof(*pcs));
+ strncpy(pcs->id, "mhdp", 4);
+ pcs->header_size = 0x60;
+ pcs->entry_size = 0x1C;
+}
+
+void playcounts_finish(playcounts_t* pcs)
+{
+ free(pcs->entries);
+}
+
+int playcounts_serialize(playcounts_t* pcs, serializer_t* sio)
+{
+ uint32_t i;
+ size_t begin = serialize_tell(sio);
+
+ if (serialize_reading(sio)) {
+ if (serialize_uint8_array(sio, "id", "%c ", pcs->id, sizeof(pcs->id))) return 1;
+ } else if (serialize_dumping(sio)) {
+ serialize_indent(sio);
+ fprintf(sio->fp, "Chunk %c%c%c%c = {\n", pcs->id[0], pcs->id[1], pcs->id[2], pcs->id[3]);
+ }
+ serialize_indent_ascend(sio);
+
+ if (serialize_uint32le(sio, "header_size", "%u", &pcs->header_size)) return 1;
+ if (serialize_uint32le(sio, "entry_size", "%u", &pcs->entry_size)) return 1;
+ if (serialize_uint32le(sio, "num_entries", "%u", &pcs->num_entries)) return 1;
+
+ /* Padding data if any. */
+ if (serialize_reading(sio)) {
+ if (serialize_tell(sio) < begin + pcs->header_size) {
+ pcs->padding_size = pcs->header_size - (serialize_tell(sio) - begin);
+ pcs->padding = (uint8_t*)calloc(pcs->padding_size, 1);
+ }
+ }
+ if (pcs->padding) {
+ if (serialize_uint8_array(sio, "padding", "%02X ", pcs->padding, pcs->padding_size)) return 1;
+ }
+
+ if (serialize_reading(sio)) {
+ pcs->entries = (playcount_entry_t*)calloc(pcs->num_entries, sizeof(playcount_entry_t));
+ for (i = 0;i < pcs->num_entries;++i) {
+ playcount_init(&pcs->entries[i]);
+ }
+ }
+
+ for (i = 0;i < pcs->num_entries;++i) {
+ if (serialize_dumping(sio)) {
+ serialize_indent(sio);
+ fprintf(sio->fp, "entry (%d) = {\n", i);
+ serialize_indent_ascend(sio);
+ }
+ if (playcount_serialize(&pcs->entries[i], pcs, sio)) return 1;
+ if (serialize_dumping(sio)) {
+ serialize_indent_descend(sio);
+ serialize_indent(sio);
+ fprintf(sio->fp, "}\n");
+ }
+ }
+
+ serialize_indent_descend(sio);
+ if (serialize_dumping(sio)) {
+ serialize_indent(sio);
+ fprintf(sio->fp, "}\n");
+ }
+
+ return 0;
+}
Property changes on: trunk/pmplib/lib/pmp_ipod/playcounts.c
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: trunk/pmplib/lib/pmp_ipod/playcounts.h
===================================================================
--- trunk/pmplib/lib/pmp_ipod/playcounts.h (rev 0)
+++ trunk/pmplib/lib/pmp_ipod/playcounts.h 2007-02-28 08:17:04 UTC (rev 401)
@@ -0,0 +1,54 @@
+/*
+ * Reader and dumper for "Play Counts" file.
+ *
+ * Copyright (c) 2005-2007 Naoaki Okazaki
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+/* $Id:$ */
+
+#ifndef __PLAYCOUNTS_H__
+#define __PLAYCOUNTS_H__
+
+typedef struct {
+ uint32_t play_count;
+ uint32_t last_played;
+ uint32_t audio_bookmark;
+ uint32_t rating;
+ uint32_t unknown;
+ uint32_t skip_count;
+ uint32_t last_skipped;
+
+ int32_t padding_size;
+ uint8_t* padding;
+} playcount_entry_t;
+
+struct tag_playcounts {
+ int8_t id[4];
+ uint32_t header_size;
+ uint32_t entry_size;
+ uint32_t num_entries;
+ int32_t padding_size;
+ uint8_t* padding;
+ playcount_entry_t* entries;
+};
+
+void playcounts_init(playcounts_t* pcs);
+void playcounts_finish(playcounts_t* pcs);
+int playcounts_serialize(playcounts_t* pcs, serializer_t* sio);
+
+#endif/*__PLAYCOUNTS_H__*/
Property changes on: trunk/pmplib/lib/pmp_ipod/playcounts.h
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Modified: trunk/pmplib/lib/pmp_ipod/pmp_ipod.c
===================================================================
--- trunk/pmplib/lib/pmp_ipod/pmp_ipod.c 2007-02-27 15:20:57 UTC (rev 400)
+++ trunk/pmplib/lib/pmp_ipod/pmp_ipod.c 2007-02-28 08:17:04 UTC (rev 401)
@@ -145,16 +145,25 @@
memset(info, 0, sizeof(*info));
}
-static void set_filenames(ucs2char_t *itunesdb, pmp_t *pmp)
+static void set_filenames(ucs2char_t *itunesdb, ucs2char_t* playcounts, pmp_t *pmp)
{
ucs2char_t* ucs2 = NULL;
pmp_internal_t* pmpi = (pmp_internal_t*)pmp->instance;
- ucs2cpy(itunesdb, pmp->info.path_to_root);
- filepath_addslash(itunesdb);
- ucs2 = mbsdupucs2(pmpi->decl->itunesdb_filename);
- ucs2cat(itunesdb, ucs2);
- ucs2free(ucs2);
+ if (itunesdb) {
+ ucs2cpy(itunesdb, pmp->info.path_to_root);
+ filepath_addslash(itunesdb);
+ ucs2 = mbsdupucs2(pmpi->decl->itunesdb_filename);
+ ucs2cat(itunesdb, ucs2);
+ ucs2free(ucs2);
+ }
+ if (playcounts) {
+ ucs2cpy(playcounts, pmp->info.path_to_root);
+ filepath_addslash(playcounts);
+ ucs2 = mbsdupucs2(pmpi->decl->playcounts_filename);
+ ucs2cat(playcounts, ucs2);
+ ucs2free(ucs2);
+ }
}
@@ -404,13 +413,13 @@
result_t ret = 0;
pmp_t* pmp = music->pmp;
pmp_music_internal_t* pmpmi = (pmp_music_internal_t*)music->instance;
- ucs2char_t itunesdb[MAX_PATH];
+ ucs2char_t itunesdb[MAX_PATH], playcounts[MAX_PATH];
// Initialize ipod library.
ipod_init(&ipod);
// Read the music database.
- set_filenames(itunesdb, music->pmp);
+ set_filenames(itunesdb, playcounts, music->pmp);
if (pmp->flag & PMPOF_MUSIC_DB_WRITE) {
ipod_set(&ipod, pmpmi->records, pmpmi->num_records, pmpmi->playlists, pmpmi->num_playlists);
@@ -458,14 +467,14 @@
{
ipod_t ipod;
result_t ret = 0;
- ucs2char_t itunesdb[MAX_PATH];
+ ucs2char_t itunesdb[MAX_PATH], playcounts[MAX_PATH];
// Initialize IP3DB.
ipod_init(&ipod);
// Read the music database.
- set_filenames(itunesdb, music->pmp);
- ret = ipod_read(&ipod, itunesdb);
+ set_filenames(itunesdb, playcounts, music->pmp);
+ ret = ipod_read(&ipod, itunesdb, playcounts);
if (ret) {
goto exit_this;
}
Modified: trunk/pmplib/lib/pmp_ipod/pmp_ipod.vcproj
===================================================================
--- trunk/pmplib/lib/pmp_ipod/pmp_ipod.vcproj 2007-02-27 15:20:57 UTC (rev 400)
+++ trunk/pmplib/lib/pmp_ipod/pmp_ipod.vcproj 2007-02-28 08:17:04 UTC (rev 401)
@@ -186,6 +186,10 @@
>
</File>
<File
+ RelativePath=".\playcounts.c"
+ >
+ </File>
+ <File
RelativePath=".\pmp_ipod.c"
>
</File>
@@ -216,6 +220,10 @@
>
</File>
<File
+ RelativePath=".\playcounts.h"
+ >
+ </File>
+ <File
RelativePath=".\serialize.h"
>
</File>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|