d->tag = new FLAC::Tag(new Ogg::XiphComment);
if(readProperties)
- d->properties = new Properties(this, propertiesStyle);
+ d->properties = new Properties(streamInfoData(), streamLength(), propertiesStyle);
}
ByteVector FLAC::File::streamInfoData()
*/
void setID3v2FrameFactory(const ID3v2::FrameFactory *factory);
- /*!
- * Returns the block of data used by FLAC::Properties for parsing the
- * stream properties.
- */
- ByteVector streamInfoData();
-
/*!
* Returns the length of the audio-stream, used by FLAC::Properties for
* calculating the bitrate.
void scan();
long findID3v2();
long findID3v1();
+ ByteVector streamInfoData();
ByteVector xiphCommentData();
class FilePrivate;
class FLAC::Properties::PropertiesPrivate
{
public:
- PropertiesPrivate(File *f, ReadStyle s) :
- file(f),
+ PropertiesPrivate(ByteVector d, long st, ReadStyle s) :
+ data(d),
+ streamLength(st),
style(s),
length(0),
bitrate(0),
sampleWidth(0),
channels(0) {}
- File *file;
+ ByteVector data;
+ long streamLength;
ReadStyle style;
int length;
int bitrate;
// public members
////////////////////////////////////////////////////////////////////////////////
-FLAC::Properties::Properties(File *file, ReadStyle style) : AudioProperties(style)
+FLAC::Properties::Properties(ByteVector data, long streamLength, ReadStyle style) : AudioProperties(style)
{
- d = new PropertiesPrivate(file, style);
+ d = new PropertiesPrivate(data, streamLength, style);
read();
}
void FLAC::Properties::read()
{
- // Get the identification header.
-
- ByteVector data = d->file->streamInfoData();
-
int pos = 0;
// Minimum block size (in samples)
// Maximum frame size (in bytes)
pos += 3;
- uint flags = data.mid(pos, 4).toUInt(true);
+ uint flags = d->data.mid(pos, 4).toUInt(true);
d->sampleRate = flags >> 12;
d->channels = ((flags >> 9) & 7) + 1;
d->sampleWidth = ((flags >> 4) & 31) + 1;
uint highlength = (((flags & 0xf) << 28) / d->sampleRate) << 4;
pos += 4;
- d->length = (data.mid(pos, 4).toUInt(true)) / d->sampleRate + highlength;
+ d->length = (d->data.mid(pos, 4).toUInt(true)) / d->sampleRate + highlength;
pos += 4;
// Uncompressed bitrate:
- // d->bitrate = ((d->sampleRate * d->channels) / 1000) * d->sampleWidth;
+ //d->bitrate = ((d->sampleRate * d->channels) / 1000) * d->sampleWidth;
// Real bitrate:
- d->bitrate = ((d->file->streamLength()*8L) / d->length)/1000;
-
+ if (d->length)
+ d->bitrate = ((d->streamLength*8L) / d->length)/1000;
+ else
+ d->bitrate = 0;
}
public:
/*!
* Create an instance of FLAC::Properties with the data read from the
- * FLAC::File \a file.
+ * ByteVector \a data.
+ * BIC: API changed since last stable release
*/
- Properties(File *file, ReadStyle style = Average);
+ Properties(ByteVector data, long streamLength, ReadStyle style = Average);
/*!
* Destroys this FLAC::Properties instance.