Hello all,
I'm getting further on my way to getting the svn-tree to compile again
on my idiosyncratic setup. Doing this, I had to handle some deprecations
in the mp4 metadata-extraction bits of Melodie. libmp4v2 (version 1.9.0
was relased last thursday, actually [0]) started marking the old
metadata API as deprecated in r231. Porting to the new tags convenience
API was pretty straightforward and I have attached a patch that does
just this in a manner that should not disturb the behaviour with older
versions of the library.
Unfortunately, the header file for the newer versions is no longer mp4.h
but mp4v2/mp4v2.h. So if you are using a newer version, you have to
change that manually.
As for testing: I still seem to have problems with LanguageKit and
Smalltalk code such as Melodie is crashing on me [1]. So I put the
TLMusicFile class into a little tool and let it chomp on some mp4-files.
So far, everything seems to work as expected.
Cheers,
Niels
--
[0] http://code.google.com/p/mp4v2/
[1] I still need to take a systematic look at this one, but I'll keep
you updated as soon as I get to it.
Index: Services/User/Melodie/TLMusicFile.m
===================================================================
--- Services/User/Melodie/TLMusicFile.m (revision 4681)
+++ Services/User/Melodie/TLMusicFile.m (working copy)
@@ -36,15 +36,39 @@
#include <tag_c.h>
+
+//Newer versions need #include<mp4v2/mp4v2.h>.
#include <mp4.h>
+
+/*
+ * Since rev 231 the MP4(Get|Set)Metadata* functions are considered
+ * as deprecated. The tags convenience API shall be used instead.
+ */
+#if defined MP4V2_PROJECT_repo_rev && MP4V2_PROJECT_repo_rev >= 231
+ #define USE_MP4V2_TAGS_CONVENIENCE_API
+#else
+ #define USE_MP4V2_METADATA_API
+#endif
+
#import "TLMusicFile.h"
@implementation TLMusicFile
+
+#ifdef USE_MP4V2_METADATA_API
#define MP4_GET_STRING(var, name) if(MP4GetMetadata ## name(hFile, &value))\
{\
ASSIGN(var, [NSString stringWithUTF8String:value]);\
}
+#endif
+
+#ifdef USE_MP4V2_TAGS_CONVENIENCE_API
+#define MP4_GET_STRING(var, name) if(tags->name)\
+{\
+ ASSIGN(var, [NSString stringWithUTF8String:tags->name]);\
+}
+#endif
+
- (BOOL) mp4ReadTagsForFile: (NSString*) aPath
{
MP4FileHandle hFile = MP4Read([aPath UTF8String], 0);
@@ -52,6 +76,8 @@
{
return NO;
}
+
+ #ifdef USE_MP4V2_METADATA_API
char *value = NULL;
MP4_GET_STRING(album, Album)
MP4_GET_STRING(title, Name)
@@ -79,7 +105,59 @@
if (cover != nil)
hasCover = YES;
} */
+ #endif
+
+ #ifdef USE_MP4V2_TAGS_CONVENIENCE_API
+ /* Allocate a tag-structure */
+ const MP4Tags* tags = MP4TagsAlloc();
+ /* Populate it */
+ MP4TagsFetch(tags, hFile);
+
+ MP4_GET_STRING(album, album)
+ MP4_GET_STRING(title, name)
+ MP4_GET_STRING(artist, artist)
+ MP4_GET_STRING(comment, comments)
+ MP4_GET_STRING(genre, genre)
+ if (tags->track)
+ {
+ if (tags->track->index)
+ {
+ track = tags->track->index;
+ }
+ if (tags->track->total)
+ {
+ totalTracks = tags->track->total;
+ }
+ }
+ if (tags->releaseDate)
+ {
+ year = strtol(tags->releaseDate, NULL, 10);
+ }
+
+ /*
+ * FIXME: There can be more than one artwork. The number is stored in
+ * tags->artworkCount and each successive artwork seems to be accessed
+ * by incrementing the pointer returned by tags->artwork.
+ * Cf. examples/itmf/tags.c in libmp4v2.
+ */
+ if (tags->artwork)
+ {
+ // FIXME: probably can use dataWithBytesNoCopy
+ cover = [[NSImage alloc] initWithData:
+ [NSData dataWithBytes: tags->artwork->data
+ length: tags->artwork->size]];
+ if (cover != nil)
+ {
+ hasCover = YES;
+ }
+ }
+
+
+ /* Free the memory allocated for the tag-structure. */
+ MP4TagsFree(tags);
+ #endif
+
MP4Close(hFile);
return YES;
}
_______________________________________________
Etoile-dev mailing list
[email protected]
https://mail.gna.org/listinfo/etoile-dev