Check for the presence of the drms atom in MP4 files
authorLukáš Lalinský <lalinsky@gmail.com>
Tue, 29 Mar 2011 13:41:17 +0000 (15:41 +0200)
committerLukáš Lalinský <lalinsky@gmail.com>
Tue, 29 Mar 2011 13:41:17 +0000 (15:41 +0200)
taglib/mp4/mp4atom.cpp
taglib/mp4/mp4atom.h
taglib/mp4/mp4properties.cpp
taglib/mp4/mp4properties.h

index 26d6d25a2a832ac6fa872befd9efbca41832f684..de42d3c47358e779904e01bcfd46df91b92c4010 100644 (file)
 
 using namespace TagLib;
 
-const char *MP4::Atom::containers[10] = {
+const char *MP4::Atom::containers[11] = {
     "moov", "udta", "mdia", "meta", "ilst",
     "stbl", "minf", "moof", "traf", "trak",
+    "stsd"
 };
 
 MP4::Atom::Atom(File *file)
@@ -82,6 +83,9 @@ MP4::Atom::Atom(File *file)
       if(name == "meta") {
         file->seek(4, File::Current);
       }
+      else if(name == "stsd") {
+        file->seek(8, File::Current);
+      }
       while(file->tell() < offset + length) {
         MP4::Atom *child = new MP4::Atom(file);
         children.append(child);
index 7d9dac28a420d51fb89df96831e5790a866c60d9..2c0de3d2b2d8aef78a8ab6c1397fd4c2eace3300 100644 (file)
@@ -53,8 +53,8 @@ namespace TagLib {
         TagLib::ByteVector name;
         AtomList children;
     private:
-        static const int numContainers = 10;
-        static const char *containers[10];
+        static const int numContainers = 11;
+        static const char *containers[11];
     };
 
     //! Root-level atoms
index a62bda99e87092c099899d476771afef288c8fd0..512b66b1b92ceb4ffb3f68f4ab9781b9dd639ce1 100644 (file)
@@ -40,13 +40,14 @@ using namespace TagLib;
 class MP4::Properties::PropertiesPrivate
 {
 public:
-  PropertiesPrivate() : length(0), bitrate(0), sampleRate(0), channels(0), bitsPerSample(0) {}
+  PropertiesPrivate() : length(0), bitrate(0), sampleRate(0), channels(0), bitsPerSample(0), encrypted(false) {}
 
   int length;
   int bitrate;
   int sampleRate;
   int channels;
   int bitsPerSample;
+  bool encrypted;
 };
 
 MP4::Properties::Properties(File *file, MP4::Atoms *atoms, ReadStyle style)
@@ -129,6 +130,11 @@ MP4::Properties::Properties(File *file, MP4::Atoms *atoms, ReadStyle style)
       }
     }
   }
+
+  MP4::Atom *drms = atom->find("drms");
+  if(drms) {
+    d->encrypted = true;
+  }
 }
 
 MP4::Properties::~Properties()
@@ -166,4 +172,10 @@ MP4::Properties::bitsPerSample() const
   return d->bitsPerSample;
 }
 
+bool
+MP4::Properties::isEncrypted() const
+{
+  return d->encrypted;
+}
+
 #endif
index ef813850b049b8613cf3c3e83a0ecbc675ffebcd..7906824d8f450a04b00d2e8ccde3ff0bfaf7808f 100644 (file)
@@ -48,6 +48,7 @@ namespace TagLib {
       virtual int sampleRate() const;
       virtual int channels() const;
       virtual int bitsPerSample() const;
+      bool isEncrypted() const;
 
     private:
       class PropertiesPrivate;