I've got a fix attached -- it's back to reading tags with the old API, with 
Unicode and the extra metadata (that wasn't being read before) added.

If someone could apply and test on Ubuntu, I'd duly appreciate it. Works on 
Arch :). Sorry for breaking trunk!

Bill

On Tuesday 18 May 2010 12:33:02 Bill Good wrote:
> Hi Tobias,
> Yep, it looks like I managed to introduce an dependency not in the Ubuntu
> repositories which isn't probably favorable since it's our 'supported'
> distribution.
> After some googling, it looks like Ubuntu is using a really old libmp4v2,
> from the now-defunct mpeg4ip library (mp4v2 is now maintained at [0]). So
> this would appear to be a Ubuntu bug, but Ubuntu already knows about it
> [1]. Apparently, all of this mess of libraries is solely MPL licensed, and
> solely- MPL licensed software is apparently GPL-incompatible [2] and [3]
> (according to the GNU lawyers, this includes linking) so I guess mixxx
> shouldn't be linking to it at all.
> 
> But anyway, I guess that's why Ubuntu is still shipping such old code [4].
> 
> Where to go from here: first priority ought to probably be fixing the
> build, so I'll work out a patch that uses the old tags interface and post
> it as a reply, deprecation warnings on properly updated distributions or
> not :). From there, we need to find a new way to read mp4 containers and
> tags -- taglib [5] looks like an optimal solution for the second part, and
> my knowledge of ssm4a doesn't actually extend to the first part, so I'll
> leave that problem unsolved for right now since at least it works, legally
> or not.
> 
> Bill
> 
> [0] http://code.google.com/p/mp4v2/
> [1] https://bugs.launchpad.net/ubuntu/+source/mpeg4ip/+bug/305245
> [2] http://www.mozilla.org/MPL/mpl-faq.html
> [3] http://www.gnu.org/licenses/license-list.html#GPLIncompatibleLicenses
> [4] http://osdir.com/ml/ubuntu-motu/2009-11/threads.html#00029
> [5] http://developer.kde.org/~wheeler/taglib.html
> 
> On Tuesday 18 May 2010 04:25:29 Tobias Rafreider wrote
> 
> > Hey all,
> > 
> > I wasn't able to compile trunk on Ubuntu 10.4 after m4a fixes have been
> > committed.
> > 
> > First #include <mp4v2/mp4v2.h> in soundsoucem4a.cpp should be replaced
> > the directive in soundsoucem4a.h, that is:
> > ===================
> > #ifdef __MP4V2__
> > 
> >      #include <mp4v2/mp4v2.h>
> > 
> > #else
> > 
> >      #include <mp4.h>
> > 
> > #endif
> > ====================
> > 
> > Now, Ubuntu can find the header files but still stops compilation at
> > line 165
> > === const MP4Tags *mp4tags = MP4TagsAlloc();===========
> > 
> > Thanks,
> > 
> > Tobias
> > 
> > -------------------------------------------------------------------------
> > -- ---
> > 
> > _______________________________________________
> > Mixxx-devel mailing list
> > Mixxx-devel@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/mixxx-devel
=== modified file 'mixxx/src/soundsourcem4a.cpp'
--- mixxx/src/soundsourcem4a.cpp	2010-05-18 04:11:09 +0000
+++ mixxx/src/soundsourcem4a.cpp	2010-05-18 18:10:12 +0000
@@ -15,7 +15,12 @@
  ***************************************************************************/
 
 #include <neaacdec.h>
-#include <mp4v2/mp4v2.h>
+
+#ifdef __MP4V2__
+    #include <mp4v2/mp4v2.h>
+#else
+    #include <mp4.h>
+#endif
 
 #ifdef __WINDOWS__
 #include <io.h>
@@ -162,7 +167,6 @@
     QString mp4FileName = Track->getLocation();
     QByteArray qbaFileName = mp4FileName.toUtf8();
     MP4FileHandle mp4file = MP4Read(qbaFileName.data());
-    const MP4Tags *mp4tags = MP4TagsAlloc();
 
     if (mp4file == MP4_INVALID_FILE_HANDLE) {
         qDebug() << "SSM4A::ParseHeader : " << mp4FileName
@@ -170,27 +174,72 @@
         return ERR;
     }
     
-    MP4TagsFetch(mp4tags, mp4file);
     Track->setType("m4a");
     
-    if (mp4tags->name)
-        Track->setTitle(QString::fromUtf8(mp4tags->name));
-    if (mp4tags->artist)
-        Track->setArtist(QString::fromUtf8(mp4tags->artist));
-    if (mp4tags->comments)
-        Track->setComment(QString::fromUtf8(mp4tags->comments));
-    if (mp4tags->album)
-        Track->setAlbum(QString::fromUtf8(mp4tags->album));
-    if (mp4tags->releaseDate)
-        Track->setYear(QString::fromUtf8(mp4tags->releaseDate));
-    if (mp4tags->genre)
-        Track->setGenre(QString::fromUtf8(mp4tags->genre));
-    if (mp4tags->track && mp4tags->track->index > 0)
-        Track->setTrackNumber(QString::number(mp4tags->track->index));
-
-    if (mp4tags->tempo && *mp4tags->tempo > 0) {
-        Track->setBpm(*mp4tags->tempo);
-        Track->setBpmConfirm(true);
+    char *value = NULL;
+    if (MP4GetMetadataName(mp4file, &value) && value != NULL) {
+        Track->setTitle(QString::fromUtf8(value));
+        MP4Free(value);
+        value = NULL;
+    }
+
+    if (MP4GetMetadataArtist(mp4file, &value) && value != NULL) {
+        Track->setArtist(QString::fromUtf8(value));
+        MP4Free(value);
+        value = NULL;
+    }
+
+    if (MP4GetMetadataComment(mp4file, &value) && value != NULL) {
+        Track->setComment(QString::fromUtf8(value));
+        MP4Free(value);
+        value = NULL;
+    }
+    
+    if (MP4GetMetadataAlbum(mp4file, &value) && value != NULL) {
+        Track->setAlbum(QString::fromUtf8(value));
+        MP4Free(value);
+        value = NULL;
+    }
+    
+    if (MP4GetMetadataYear(mp4file, &value) && value != NULL) {
+        Track->setYear(QString::fromUtf8(value));
+        MP4Free(value);
+        value = NULL;
+    }
+    
+    if (MP4GetMetadataGenre(mp4file, &value) && value != NULL) {
+        Track->setGenre(QString::fromUtf8(value));
+        MP4Free(value);
+        value = NULL;
+    }
+    
+#ifndef _MSC_VER
+    u_int16_t bpm = 0;
+    u_int16_t track = 0;
+    u_int16_t numTracks = 0; // don't actually use this but MP4GetMetadataTrack
+                             // barfs if you give it null
+#else
+    // MSVC doesn't know what a u_int16_t is, so we have to tell it
+    unsigned short bpm = 0;
+    unsigned short track = 0;
+    unsigned short numTracks = 0;
+#endif
+    if (MP4GetMetadataTempo(mp4file, &bpm)) {
+        if(bpm > 0) {
+#ifdef _MSC_VER
+            Q_ASSERT(sizeof(bpm)==2);   // Just making sure we're in bounds
+#endif
+            Track->setBpm(bpm);
+            Track->setBpmConfirm(true);
+        }
+    }
+    if (MP4GetMetadataTrack(mp4file, &track, &numTracks)) {
+        if(track > 0) {
+#ifdef _MSC_VER
+            Q_ASSERT(sizeof(track)==2);   // Just making sure we're in bounds
+#endif
+            Track->setTrackNumber(QString::number(track));
+        }
     }
 
     // We are only interested in first track for the initial dev iteration
@@ -210,7 +259,6 @@
     int bits_per_second = MP4GetTrackBitRate(mp4file, track_id);
     Track->setBitrate(bits_per_second/1000);
 
-    MP4TagsFree(mp4tags);
     MP4Close(mp4file);
     Track->setHeaderParsed(true);
     // FIXME: hard-coded to 2 channels - real value is not available until

------------------------------------------------------------------------------

_______________________________________________
Mixxx-devel mailing list
Mixxx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mixxx-devel

Reply via email to