Guest User

taglib-m4a-key-patch

a guest
Nov 8th, 2017
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 2.33 KB | None | 0 0
  1. diff --git a/taglib-1.9.1/taglib/mp4/mp4atom.cpp b/taglib-1.9.1/taglib/mp4/mp4atom.cpp
  2. index 7b87a4796d..2ae5c386c7 100644
  3. --- a/taglib-1.9.1/taglib/mp4/mp4atom.cpp
  4. +++ b/taglib-1.9.1/taglib/mp4/mp4atom.cpp
  5. @@ -29,10 +29,10 @@
  6.  
  7.  using namespace TagLib;
  8.  
  9. -const char *MP4::Atom::containers[11] = {
  10. +const char *MP4::Atom::containers[12] = {
  11.      "moov", "udta", "mdia", "meta", "ilst",
  12.      "stbl", "minf", "moof", "traf", "trak",
  13. -    "stsd"
  14. +    "stsd", "Xtra"
  15.  };
  16.  
  17.  MP4::Atom::Atom(File *file)
  18. diff --git a/taglib-1.9.1/taglib/mp4/mp4atom.h b/taglib-1.9.1/taglib/mp4/mp4atom.h
  19. index ea5091a8b4..1eaf23ca4a 100644
  20. --- a/taglib-1.9.1/taglib/mp4/mp4atom.h
  21. +++ b/taglib-1.9.1/taglib/mp4/mp4atom.h
  22. @@ -87,8 +87,8 @@ namespace TagLib {
  23.          TagLib::ByteVector name;
  24.          AtomList children;
  25.      private:
  26. -        static const int numContainers = 11;
  27. -        static const char *containers[11];
  28. +        static const int numContainers = 12;
  29. +        static const char *containers[12];
  30.      };
  31.  
  32.      //! Root-level atoms
  33. diff --git a/taglib-1.9.1/taglib/mp4/mp4tag.cpp b/taglib-1.9.1/taglib/mp4/mp4tag.cpp
  34. index bbe3301d97..29f205353d 100644
  35. --- a/taglib-1.9.1/taglib/mp4/mp4tag.cpp
  36. +++ b/taglib-1.9.1/taglib/mp4/mp4tag.cpp
  37. @@ -95,6 +95,35 @@ MP4::Tag::Tag(TagLib::File *file, MP4::Atoms *atoms)
  38.        parseText(atom, file);
  39.      }
  40.    }
  41. +
  42. +  MP4::Atom *xtra = atoms->find("moov", "udta", "Xtra");
  43. +  if(!xtra) {
  44. +     //debug("Atom moov.udta.Xtra not found.");
  45. +     return;
  46. +  }
  47. +  else {
  48. +     for(unsigned int i = 0; i < xtra->children.size(); i++) {
  49. +         MP4::Atom *atom = xtra->children[i];
  50. +         file->seek(atom->offset + 8);
  51. +         ByteVector data = file->readBlock(atom->length - 8);
  52. +         String name = String(data.data(), String::UTF8);
  53. +         if(name == "WM/InitialKey") {
  54. +             unsigned int pos = name.size();
  55. +             const unsigned int length = static_cast<unsigned int>(data.mid(pos, 4).toUInt());
  56. +             pos += 4;
  57. +             for(unsigned int item = 0; item < length; ++item) {
  58. +                 // 4 bytes for block length
  59. +                 pos += 4;
  60. +                 // another 2 bytes for encoding
  61. +                 pos += 2;
  62. +                 StringList valueList;
  63. +                 String value = String(data.mid(pos), String::UTF16LE);
  64. +                 valueList.append(value);
  65. +                 addItem(String("WM/InitialKey"), valueList);
  66. +             }
  67. +         }
  68. +     }
  69. +  }
  70.  }
  71.  
  72.  MP4::Tag::~Tag()
Advertisement
Add Comment
Please, Sign In to add comment