itunes mp4 files

Martin Aumueller aumuell at reserv.at
Sun Jan 15 17:45:19 CET 2006


Hi Jochen & others,

thank you for making the code available and for doing the work - seems
to have been quite a lot of it...

I just tried your code out and as far as I can see it works fine for
tag reading. I just noticed one problem: non-ascii characters get
garbled because those are stored as UTF8 in the m4a file, but
constructing a TagLib::String assumes a different encoding. This can
be easily fixed by supplying String::UTF8 as additional parameter to
the constructor - see the attached diff in file m4a/mp4file.cpp.

As I am about to submit this to the amaroK svn repository for (in the
end) replacing the libmp4v2 based m4a metadata code, I had to make
some additional changes: there were some namespace problems when
compiled standalone, so I had to change all those itunes*box.h files
and boxfactory.cpp to explicitly use File from the correct namespace.

Keep up the good work - I'm looking forward to tag writing support :)

BTW, I made an error when generating this diff, so you would have to
use patch -R to apply it.

Martin

On 1/14/06, Jochen Issing <jochen at isign-softart.de> wrote:
> Here is the link:
>
> http://isign-softart.de/taglib/taglib-1.4_delivery_1_0.tar.bz2
>
> I modified the testing routine to use an MP4::Tag, so that I can test all
> supported fields, not only the common ones. Therefore you should get a bit
> more output...
>
> Best Regards,
>
> jochen
>
> On Saturday 14 January 2006 00:01, Michael Pyne wrote:
> > On Monday 09 January 2006 17:21, Jochen Issing wrote:
> > > > The features are for now read only of almost all supported mp4 itunes
> > > > fields, cover is left out for now, but could be included as well. No
> > > > AudioProperties support yet, but will be my upcoming work. Write
> > > > support will be last step for implementation, because this will be the
> > > > most difficult part for me, especially rearding the offset tables,
> > > > which I do not need to touch now.
> >
> > Hey, this is pretty awesome. :)  (Sorry for the late reply, btw)
> >
> > > > Besides that the code is not completely cleaned up (some #if
> > > > 0-statements), because I might need those in future work. I tried to do
> > > > as much Doxygen comments as I was able to do - the License Header is
> > > > missing in some files as well.
> >
> > May I ask how you're doing this work?  There is existing code out there to
> > merge MPEG-4 into TagLib but it is derived from mplayer (or libfaad, I
> > forget which) and is thus license incompatible.
> >
> > If your work were to make its way to TagLib it would have to carry the same
> > (or less restrictive) license.
> >
> > But if you managed to write the code by reverse-engineering the format or
> > using documentation (i.e. not just reimplementing from other code), that
> > would probably be OK.
> >
> > > > Please give me your opinion on the code, if the coding rules are
> > > > matched good enough, if the structure is Ok or whatever. At least, give
> > > > it a try! ;-)
> >
> > Um, where *is* the code?
-------------- next part --------------
diff -c ./boxfactory.cpp /home/ma/src/taglib-1.4-mp4/taglib-1.4/taglib/m4a/boxfactory.cpp
*** ./boxfactory.cpp	2006-01-15 12:25:52.000000000 +0100
--- /home/ma/src/taglib-1.4-mp4/taglib-1.4/taglib/m4a/boxfactory.cpp	2006-01-08 19:07:35.000000000 +0100
***************
*** 30,41 ****
  }
  
  //! factory function
! MP4::Mp4IsoBox* MP4::BoxFactory::createInstance( TagLib::File* anyfile, MP4::Fourcc fourcc, uint size, long offset ) const
  {
-   MP4::File * file = dynamic_cast<MP4::File *>(anyfile);
-   if(!file)
-       return 0;
- 
    switch( fourcc )
    {
    case 0x6d6f6f76: // 'moov'
--- 30,37 ----
  }
  
  //! factory function
! MP4::Mp4IsoBox* MP4::BoxFactory::createInstance( TagLib::File* file, MP4::Fourcc fourcc, uint size, long offset ) const
  {
    switch( fourcc )
    {
    case 0x6d6f6f76: // 'moov'
diff -c ./itunesalbbox.h /home/ma/src/taglib-1.4-mp4/taglib-1.4/taglib/m4a/itunesalbbox.h
*** ./itunesalbbox.h	2006-01-15 12:35:41.000000000 +0100
--- /home/ma/src/taglib-1.4-mp4/taglib-1.4/taglib/m4a/itunesalbbox.h	2006-01-05 18:31:46.000000000 +0100
***************
*** 11,17 ****
      class ITunesAlbBox: public Mp4IsoBox
      {
      public:
!       ITunesAlbBox( TagLib::File* file, MP4::Fourcc fourcc, uint size, long offset );
        ~ITunesAlbBox();
  
      private:
--- 11,17 ----
      class ITunesAlbBox: public Mp4IsoBox
      {
      public:
!       ITunesAlbBox( File* file, MP4::Fourcc fourcc, uint size, long offset );
        ~ITunesAlbBox();
  
      private:
diff -c ./itunesartbox.h /home/ma/src/taglib-1.4-mp4/taglib-1.4/taglib/m4a/itunesartbox.h
*** ./itunesartbox.h	2006-01-15 12:35:57.000000000 +0100
--- /home/ma/src/taglib-1.4-mp4/taglib-1.4/taglib/m4a/itunesartbox.h	2006-01-05 18:25:14.000000000 +0100
***************
*** 11,17 ****
      class ITunesArtBox: public Mp4IsoBox
      {
      public:
!       ITunesArtBox( TagLib::File* file, MP4::Fourcc fourcc, uint size, long offset );
        ~ITunesArtBox();
  
      private:
--- 11,17 ----
      class ITunesArtBox: public Mp4IsoBox
      {
      public:
!       ITunesArtBox( File* file, MP4::Fourcc fourcc, uint size, long offset );
        ~ITunesArtBox();
  
      private:
diff -c ./itunescmtbox.h /home/ma/src/taglib-1.4-mp4/taglib-1.4/taglib/m4a/itunescmtbox.h
*** ./itunescmtbox.h	2006-01-15 12:36:01.000000000 +0100
--- /home/ma/src/taglib-1.4-mp4/taglib-1.4/taglib/m4a/itunescmtbox.h	2006-01-06 19:21:40.000000000 +0100
***************
*** 11,17 ****
      class ITunesCmtBox: public Mp4IsoBox
      {
      public:
!       ITunesCmtBox( TagLib::File* file, MP4::Fourcc fourcc, uint size, long offset );
        ~ITunesCmtBox();
  
      private:
--- 11,17 ----
      class ITunesCmtBox: public Mp4IsoBox
      {
      public:
!       ITunesCmtBox( File* file, MP4::Fourcc fourcc, uint size, long offset );
        ~ITunesCmtBox();
  
      private:
diff -c ./itunesdatabox.h /home/ma/src/taglib-1.4-mp4/taglib-1.4/taglib/m4a/itunesdatabox.h
*** ./itunesdatabox.h	2006-01-15 12:35:30.000000000 +0100
--- /home/ma/src/taglib-1.4-mp4/taglib-1.4/taglib/m4a/itunesdatabox.h	2006-01-05 18:58:18.000000000 +0100
***************
*** 11,17 ****
      class ITunesDataBox: public Mp4IsoFullBox
      {
      public:
!       ITunesDataBox( TagLib::File* file, MP4::Fourcc fourcc, uint size, long offset );
        ~ITunesDataBox();
  
        //! get the internal data, which can be txt or binary data as well
--- 11,17 ----
      class ITunesDataBox: public Mp4IsoFullBox
      {
      public:
!       ITunesDataBox( File* file, MP4::Fourcc fourcc, uint size, long offset );
        ~ITunesDataBox();
  
        //! get the internal data, which can be txt or binary data as well
diff -c ./itunesdaybox.h /home/ma/src/taglib-1.4-mp4/taglib-1.4/taglib/m4a/itunesdaybox.h
*** ./itunesdaybox.h	2006-01-15 12:34:19.000000000 +0100
--- /home/ma/src/taglib-1.4-mp4/taglib-1.4/taglib/m4a/itunesdaybox.h	2006-01-05 18:41:10.000000000 +0100
***************
*** 11,17 ****
      class ITunesDayBox: public Mp4IsoBox
      {
      public:
!       ITunesDayBox( TagLib::File* file, MP4::Fourcc fourcc, uint size, long offset );
        ~ITunesDayBox();
  
      private:
--- 11,17 ----
      class ITunesDayBox: public Mp4IsoBox
      {
      public:
!       ITunesDayBox( File* file, MP4::Fourcc fourcc, uint size, long offset );
        ~ITunesDayBox();
  
      private:
diff -c ./itunesdiskbox.h /home/ma/src/taglib-1.4-mp4/taglib-1.4/taglib/m4a/itunesdiskbox.h
*** ./itunesdiskbox.h	2006-01-15 12:35:52.000000000 +0100
--- /home/ma/src/taglib-1.4-mp4/taglib-1.4/taglib/m4a/itunesdiskbox.h	2006-01-06 20:23:37.000000000 +0100
***************
*** 11,17 ****
      class ITunesDiskBox: public Mp4IsoBox
      {
      public:
!       ITunesDiskBox( TagLib::File* file, MP4::Fourcc fourcc, uint size, long offset );
        ~ITunesDiskBox();
  
      private:
--- 11,17 ----
      class ITunesDiskBox: public Mp4IsoBox
      {
      public:
!       ITunesDiskBox( File* file, MP4::Fourcc fourcc, uint size, long offset );
        ~ITunesDiskBox();
  
      private:
diff -c ./itunesgenbox.h /home/ma/src/taglib-1.4-mp4/taglib-1.4/taglib/m4a/itunesgenbox.h
*** ./itunesgenbox.h	2006-01-15 12:35:25.000000000 +0100
--- /home/ma/src/taglib-1.4-mp4/taglib-1.4/taglib/m4a/itunesgenbox.h	2006-01-05 18:35:59.000000000 +0100
***************
*** 11,17 ****
      class ITunesGenBox: public Mp4IsoBox
      {
      public:
!       ITunesGenBox( TagLib::File* file, MP4::Fourcc fourcc, uint size, long offset );
        ~ITunesGenBox();
  
      private:
--- 11,17 ----
      class ITunesGenBox: public Mp4IsoBox
      {
      public:
!       ITunesGenBox( File* file, MP4::Fourcc fourcc, uint size, long offset );
        ~ITunesGenBox();
  
      private:
diff -c ./itunesgrpbox.h /home/ma/src/taglib-1.4-mp4/taglib-1.4/taglib/m4a/itunesgrpbox.h
*** ./itunesgrpbox.h	2006-01-15 12:35:45.000000000 +0100
--- /home/ma/src/taglib-1.4-mp4/taglib-1.4/taglib/m4a/itunesgrpbox.h	2006-01-06 19:36:06.000000000 +0100
***************
*** 11,17 ****
      class ITunesGrpBox: public Mp4IsoBox
      {
      public:
!       ITunesGrpBox( TagLib::File* file, MP4::Fourcc fourcc, uint size, long offset );
        ~ITunesGrpBox();
  
      private:
--- 11,17 ----
      class ITunesGrpBox: public Mp4IsoBox
      {
      public:
!       ITunesGrpBox( File* file, MP4::Fourcc fourcc, uint size, long offset );
        ~ITunesGrpBox();
  
      private:
diff -c ./itunesnambox.h /home/ma/src/taglib-1.4-mp4/taglib-1.4/taglib/m4a/itunesnambox.h
*** ./itunesnambox.h	2006-01-15 12:35:38.000000000 +0100
--- /home/ma/src/taglib-1.4-mp4/taglib-1.4/taglib/m4a/itunesnambox.h	2006-01-05 16:51:50.000000000 +0100
***************
*** 11,17 ****
      class ITunesNamBox: public Mp4IsoBox
      {
      public:
!       ITunesNamBox( TagLib::File* file, MP4::Fourcc fourcc, uint size, long offset );
        ~ITunesNamBox();
  
      private:
--- 11,17 ----
      class ITunesNamBox: public Mp4IsoBox
      {
      public:
!       ITunesNamBox( File* file, MP4::Fourcc fourcc, uint size, long offset );
        ~ITunesNamBox();
  
      private:
diff -c ./itunestmpobox.h /home/ma/src/taglib-1.4-mp4/taglib-1.4/taglib/m4a/itunestmpobox.h
*** ./itunestmpobox.h	2006-01-15 12:35:21.000000000 +0100
--- /home/ma/src/taglib-1.4-mp4/taglib-1.4/taglib/m4a/itunestmpobox.h	2006-01-06 19:46:01.000000000 +0100
***************
*** 11,17 ****
      class ITunesTmpoBox: public Mp4IsoBox
      {
      public:
!       ITunesTmpoBox( TagLib::File* file, MP4::Fourcc fourcc, uint size, long offset );
        ~ITunesTmpoBox();
  
      private:
--- 11,17 ----
      class ITunesTmpoBox: public Mp4IsoBox
      {
      public:
!       ITunesTmpoBox( File* file, MP4::Fourcc fourcc, uint size, long offset );
        ~ITunesTmpoBox();
  
      private:
diff -c ./itunestrknbox.h /home/ma/src/taglib-1.4-mp4/taglib-1.4/taglib/m4a/itunestrknbox.h
*** ./itunestrknbox.h	2006-01-15 12:35:34.000000000 +0100
--- /home/ma/src/taglib-1.4-mp4/taglib-1.4/taglib/m4a/itunestrknbox.h	2006-01-05 18:38:25.000000000 +0100
***************
*** 11,17 ****
      class ITunesTrknBox: public Mp4IsoBox
      {
      public:
!       ITunesTrknBox( TagLib::File* file, MP4::Fourcc fourcc, uint size, long offset );
        ~ITunesTrknBox();
  
      private:
--- 11,17 ----
      class ITunesTrknBox: public Mp4IsoBox
      {
      public:
!       ITunesTrknBox( File* file, MP4::Fourcc fourcc, uint size, long offset );
        ~ITunesTrknBox();
  
      private:
diff -c ./ituneswrtbox.h /home/ma/src/taglib-1.4-mp4/taglib-1.4/taglib/m4a/ituneswrtbox.h
*** ./ituneswrtbox.h	2006-01-15 12:35:49.000000000 +0100
--- /home/ma/src/taglib-1.4-mp4/taglib-1.4/taglib/m4a/ituneswrtbox.h	2006-01-06 20:21:28.000000000 +0100
***************
*** 11,17 ****
      class ITunesWrtBox: public Mp4IsoBox
      {
      public:
!       ITunesWrtBox( TagLib::File* file, MP4::Fourcc fourcc, uint size, long offset );
        ~ITunesWrtBox();
  
      private:
--- 11,17 ----
      class ITunesWrtBox: public Mp4IsoBox
      {
      public:
!       ITunesWrtBox( File* file, MP4::Fourcc fourcc, uint size, long offset );
        ~ITunesWrtBox();
  
      private:
diff -c ./mp4file.cpp /home/ma/src/taglib-1.4-mp4/taglib-1.4/taglib/m4a/mp4file.cpp
*** ./mp4file.cpp	2006-01-15 17:04:02.000000000 +0100
--- /home/ma/src/taglib-1.4-mp4/taglib-1.4/taglib/m4a/mp4file.cpp	2006-01-09 23:17:12.000000000 +0100
***************
*** 1,6 ****
  #include <tbytevector.h>
  #include <tstring.h>
! //#include <tdebug.h>
  #include "tlist.h"
  
  #include "mp4itunestag.h"
--- 1,6 ----
  #include <tbytevector.h>
  #include <tstring.h>
! #include <tdebug.h>
  #include "tlist.h"
  
  #include "mp4itunestag.h"
--- 26,31 ----
***************
*** 152,158 ****
    if( databox != 0 )
    {
      // convert data to string
!     TagLib::String datastring( databox->data(), String::UTF8 );
      // check if string was set
      if( !(datastring == "") )
        mp4tag.setTitle( datastring );
--- 151,157 ----
    if( databox != 0 )
    {
      // convert data to string
!     TagLib::String datastring( databox->data() );
      // check if string was set
      if( !(datastring == "") )
        mp4tag.setTitle( datastring );
***************
*** 162,168 ****
    if( databox != 0 )
    {
      // convert data to string
!     TagLib::String datastring( databox->data(), String::UTF8 );
      // check if string was set
      if( !(datastring == "") )
        mp4tag.setArtist( datastring );
--- 161,167 ----
    if( databox != 0 )
    {
      // convert data to string
!     TagLib::String datastring( databox->data() );
      // check if string was set
      if( !(datastring == "") )
        mp4tag.setArtist( datastring );
***************
*** 172,178 ****
    if( databox != 0 )
    {
      // convert data to string
!     TagLib::String datastring( databox->data(), String::UTF8 );
      // check if string was set
      if( !(datastring == "") )
        mp4tag.setAlbum( datastring );
--- 171,177 ----
    if( databox != 0 )
    {
      // convert data to string
!     TagLib::String datastring( databox->data() );
      // check if string was set
      if( !(datastring == "") )
        mp4tag.setAlbum( datastring );
***************
*** 182,188 ****
    if( databox != 0 )
    {
      // convert data to string
!     TagLib::String datastring( databox->data(), String::UTF8 );
      // check if string was set
      if( !(datastring == "") )
        mp4tag.setGenre( datastring );
--- 181,187 ----
    if( databox != 0 )
    {
      // convert data to string
!     TagLib::String datastring( databox->data() );
      // check if string was set
      if( !(datastring == "") )
        mp4tag.setGenre( datastring );
***************
*** 192,198 ****
    if( databox != 0 )
    {
      // convert data to string
!     TagLib::String datastring( databox->data(), String::UTF8 );
      // check if string was set
      if( !(datastring == "") )
        mp4tag.setYear( datastring.toInt() );
--- 191,197 ----
    if( databox != 0 )
    {
      // convert data to string
!     TagLib::String datastring( databox->data() );
      // check if string was set
      if( !(datastring == "") )
        mp4tag.setYear( datastring.toInt() );
***************
*** 219,225 ****
    if( databox != 0 )
    {
      // convert data to string
!     TagLib::String datastring( databox->data(), String::UTF8 );
      // check if string was set
      if( !(datastring == "") )
        mp4tag.setComment( datastring );
--- 218,224 ----
    if( databox != 0 )
    {
      // convert data to string
!     TagLib::String datastring( databox->data() );
      // check if string was set
      if( !(datastring == "") )
        mp4tag.setComment( datastring );
***************
*** 229,235 ****
    if( databox != 0 )
    {
      // convert data to string
!     TagLib::String datastring( databox->data(), String::UTF8 );
      // check if string was set
      if( !(datastring == "") )
        mp4tag.setGrouping( datastring );
--- 228,234 ----
    if( databox != 0 )
    {
      // convert data to string
!     TagLib::String datastring( databox->data() );
      // check if string was set
      if( !(datastring == "") )
        mp4tag.setGrouping( datastring );
***************
*** 239,245 ****
    if( databox != 0 )
    {
      // convert data to string
!     TagLib::String datastring( databox->data(), String::UTF8 );
      // check if string was set
      if( !(datastring == "") )
        mp4tag.setComposer( datastring );
--- 238,244 ----
    if( databox != 0 )
    {
      // convert data to string
!     TagLib::String datastring( databox->data() );
      // check if string was set
      if( !(datastring == "") )
        mp4tag.setComposer( datastring );
diff -c ./mp4file.h /home/ma/src/taglib-1.4-mp4/taglib-1.4/taglib/m4a/mp4file.h
*** ./mp4file.h	2006-01-15 12:22:26.000000000 +0100
--- /home/ma/src/taglib-1.4-mp4/taglib-1.4/taglib/m4a/mp4file.h	2006-01-08 19:18:49.000000000 +0100
***************
*** 29,36 ****
  
  namespace TagLib {
  
-   typedef unsigned long long ulonglong;
- 
    class Tag;
  
    namespace MP4
--- 29,34 ----
diff -c ./mp4mvhdbox.h /home/ma/src/taglib-1.4-mp4/taglib-1.4/taglib/m4a/mp4mvhdbox.h
*** ./mp4mvhdbox.h	2006-01-15 12:23:30.000000000 +0100
--- /home/ma/src/taglib-1.4-mp4/taglib-1.4/taglib/m4a/mp4mvhdbox.h	2006-01-08 14:53:45.000000000 +0100
***************
*** 3,9 ****
  
  #include "mp4isofullbox.h"
  #include "mp4fourcc.h"
- #include "mp4file.h" // ulonglong
  
  namespace TagLib
  {
--- 3,8 ----


More information about the taglib-devel mailing list