Lots of padding bytes added when I add a PrivateFrame

Viraj Mody virajmody at gmail.com
Wed Dec 9 08:53:36 CET 2009


Hi,

I have an MPEG file with some existing ID3v2 Tags. I want to add my own PrivateFrame to the ID3v2 Tags of this file.
After adding the Frame, I noticed what appear to be several bytes of padding after the PrivateFrame I just added. Can someone suggest what might be wrong, or provide suggestions on how I avoid these padding bytes from bloating my header?

Here's my code. I have tried both alternatives below and they result in the same several bytes of empty padding:

  bool File::EmbedPrivateFrame( string path, string strPayload )
  {
      bool success = false;
      TagLib::MPEG::File f( path.c_str() );

      TagLib::ID3v2::Tag* tag = f.ID3v2Tag();
      if( tag != NULL )
      {
          TagLib::ID3v2::PrivateFrame* privFrame = new TagLib::ID3v2::PrivateFrame(); // don't delete - transfer ownership to tag
          privFrame->setOwner("www.foobar.com");
          privFrame->setData(strPayload.c_str());
          tag->addFrame( privFrame );
          success = f.save();
      }

      return success;
  }
  bool File::EmbedPrivateFrame( string path, string strPayload )
  {
      bool success = false;
      TagLib::MPEG::File f( path.c_str() );

      TagLib::ID3v2::Tag* tag = f.ID3v2Tag();
      if( tag != NULL )
      {
          TagLib::ByteVector data(strPayload.c_str(), strPayload.length());
          TagLib::ID3v2::PrivateFrame* privFrame = new TagLib::ID3v2::PrivateFrame(); // don't delete - transfer ownership to tag
          privFrame->setOwner("www.foobar.com");
          privFrame->setData(data);
          tag->addFrame( privFrame );
          success = f.save(TagLib::MPEG::File::AllTags);
      }

      return success;
  }

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.kde.org/pipermail/taglib-devel/attachments/20091208/78442ae8/attachment.htm 


More information about the taglib-devel mailing list