[prev in list] [next in list] [prev in thread] [next in thread] 

List:       taglib-devel
Subject:    Re: Constructing an ID3v2::Frame without a file
From:       Kevin André <hyperquantum () gmail ! com>
Date:       2019-08-08 22:05:44
Message-ID: CAG599pC6dA+s22iZaC-52t5MqLH-mbMWtgsOb=_VK=v3RM1sYQ () mail ! gmail ! com
[Download RAW message or body]

Hi Fred,

On Thu, Aug 8, 2019 at 10:29 PM Fred Gleason <fredg@paravelsystems.com> wrote:
> I have a use case where I need to parse an incoming data stream for ID3
> v2.3 tags. There are no files in this scenario, the source data is
> purely in memory (a sequence of QByteArrays, to be exact). However, all
> of the public constructors in TagLib appear to expect some sort of file
> to operate on, so I've been at a bit of a loss on how to proceed.

If the source data is a whole file that was simply loaded into memory,
you can use ByteVector and ByteVectorStream like this:

  TagLib::ByteVector scratch = /* create ByteVector from QByteArray or so */;
  TagLib::ByteVectorStream stream(scratch);
  TagLib::MPEG::File tagFile(&stream, TagLib::ID3v2::FrameFactory::instance());
  /* ... do some operations on the File object, read tags, modify them ... */
  scratch = *stream.data(); /* get the modified data */

ByteVectorStream makes a copy of the ByteVector and doesn't modify the
original instance, hence the assignment at the end. Only necessary if
you want to modify the File object and then do any further processing
of the raw data.

All of this is assuming that you actually have a whole file somehow.
I don't know if it is possible to process frames independently.


- Kevin
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic