]> granicus.if.org Git - taglib/commitdiff
Make reading an ID3v2 tag out of a RIFF chunk possible.
authorScott Wheeler <wheeler@kde.org>
Fri, 16 May 2008 05:08:51 +0000 (05:08 +0000)
committerScott Wheeler <wheeler@kde.org>
Fri, 16 May 2008 05:08:51 +0000 (05:08 +0000)
git-svn-id: svn://anonsvn.kde.org/home/kde/trunk/kdesupport/taglib@808235 283d02a7-25f6-0310-bc7c-ecb5cbfe19da

taglib/riff/aiff/aifffile.cpp
taglib/riff/rifffile.cpp
taglib/riff/rifffile.h

index 27fbb6ca3083078a130c6cdda7306010efb68ddb..cec725f5d07f27ba695e13101e83b47e1964704e 100644 (file)
@@ -38,15 +38,18 @@ using namespace TagLib;
 class RIFF::AIFF::File::FilePrivate
 {
 public:
-  FilePrivate()
+  FilePrivate() :
+    tag(0)
   {
 
   }
 
   ~FilePrivate()
   {
-
+    delete tag;
   }
+
+  ID3v2::Tag *tag;
 };
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -68,7 +71,7 @@ RIFF::AIFF::File::~File()
 
 ID3v2::Tag *RIFF::AIFF::File::tag() const
 {
-  return 0;
+  return d->tag;
 }
 
 RIFF::AIFF::Properties *RIFF::AIFF::File::audioProperties() const
@@ -92,7 +95,11 @@ bool RIFF::AIFF::File::save()
 
 void RIFF::AIFF::File::read(bool readProperties, Properties::ReadStyle /* propertiesStyle */)
 {
-  debug("Found " + String::number(chunkCount()) + " chunks.");
-  for(int i = 0; i < chunkCount(); i++)
-    debug("\t\"" + chunkName(i) + "\"");
+  for(uint i = 0; i < chunkCount(); i++) {
+    if(chunkName(i) == "ID3 ")
+      d->tag = new ID3v2::Tag(this, chunkOffset(i));
+  }
+
+  if(!d->tag)
+    d->tag = new ID3v2::Tag;
 }
index 3e9ad9d0a5fc1d73299cfa36d16194b070afff6a..1b3b9d84eef8f026fda1e1e57936477ec556f503 100644 (file)
@@ -43,6 +43,7 @@ public:
   ByteVector format;
 
   ByteVectorList chunkNames;
+  List<uint> chunkOffsets;
   List<uint> chunkSizes;
 };
 
@@ -73,6 +74,11 @@ uint RIFF::File::chunkCount() const
   return d->chunkNames.size();
 }
 
+uint RIFF::File::chunkOffset(uint i) const
+{
+  return d->chunkOffsets[i];
+}
+
 ByteVector RIFF::File::chunkName(uint i) const
 {
   if(i >= chunkCount())
@@ -117,6 +123,8 @@ void RIFF::File::read()
     d->chunkNames.append(chunkName);
     d->chunkSizes.append(chunkSize);
 
+    d->chunkOffsets.append(tell());
+
     seek(chunkSize, Current);
   }
 }
index 5949df1e1d1ddcc6258d19f228c690628b98e2d1..9bb510498f4e57a47f7fc772d1d4d31924a649c8 100644 (file)
@@ -58,6 +58,7 @@ namespace TagLib {
       File(FileName file, Endianness endianness);
 
       uint chunkCount() const;
+      uint chunkOffset(uint i) const;
       ByteVector chunkName(uint i) const;
       ByteVector chunkData(uint i);