Format taglib sources
This commit is contained in:
140
3rdparty/taglib/trueaudio/trueaudiofile.cpp
vendored
140
3rdparty/taglib/trueaudio/trueaudiofile.cpp
vendored
@@ -42,23 +42,20 @@
|
||||
|
||||
using namespace Strawberry_TagLib::TagLib;
|
||||
|
||||
namespace
|
||||
{
|
||||
enum { TrueAudioID3v2Index = 0, TrueAudioID3v1Index = 1 };
|
||||
namespace {
|
||||
enum { TrueAudioID3v2Index = 0,
|
||||
TrueAudioID3v1Index = 1 };
|
||||
}
|
||||
|
||||
class TrueAudio::File::FilePrivate
|
||||
{
|
||||
public:
|
||||
explicit FilePrivate(const ID3v2::FrameFactory *frameFactory = ID3v2::FrameFactory::instance()) :
|
||||
ID3v2FrameFactory(frameFactory),
|
||||
ID3v2Location(-1),
|
||||
ID3v2OriginalSize(0),
|
||||
ID3v1Location(-1),
|
||||
properties(0) {}
|
||||
class TrueAudio::File::FilePrivate {
|
||||
public:
|
||||
explicit FilePrivate(const ID3v2::FrameFactory *frameFactory = ID3v2::FrameFactory::instance()) : ID3v2FrameFactory(frameFactory),
|
||||
ID3v2Location(-1),
|
||||
ID3v2OriginalSize(0),
|
||||
ID3v1Location(-1),
|
||||
properties(0) {}
|
||||
|
||||
~FilePrivate()
|
||||
{
|
||||
~FilePrivate() {
|
||||
delete properties;
|
||||
}
|
||||
|
||||
@@ -77,8 +74,7 @@ public:
|
||||
// static members
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool TrueAudio::File::isSupported(IOStream *stream)
|
||||
{
|
||||
bool TrueAudio::File::isSupported(IOStream *stream) {
|
||||
// A TrueAudio file has to start with "TTA". An ID3v2 tag may precede.
|
||||
|
||||
const ByteVector id = Utils::readHeader(stream, 3, true);
|
||||
@@ -89,98 +85,82 @@ bool TrueAudio::File::isSupported(IOStream *stream)
|
||||
// public members
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
TrueAudio::File::File(FileName file, bool readProperties, Properties::ReadStyle) :
|
||||
Strawberry_TagLib::TagLib::File(file),
|
||||
d(new FilePrivate())
|
||||
{
|
||||
if(isOpen())
|
||||
TrueAudio::File::File(FileName file, bool readProperties, Properties::ReadStyle) : Strawberry_TagLib::TagLib::File(file),
|
||||
d(new FilePrivate()) {
|
||||
if (isOpen())
|
||||
read(readProperties);
|
||||
}
|
||||
|
||||
TrueAudio::File::File(FileName file, ID3v2::FrameFactory *frameFactory,
|
||||
bool readProperties, Properties::ReadStyle) :
|
||||
Strawberry_TagLib::TagLib::File(file),
|
||||
d(new FilePrivate(frameFactory))
|
||||
{
|
||||
if(isOpen())
|
||||
bool readProperties, Properties::ReadStyle) : Strawberry_TagLib::TagLib::File(file),
|
||||
d(new FilePrivate(frameFactory)) {
|
||||
if (isOpen())
|
||||
read(readProperties);
|
||||
}
|
||||
|
||||
TrueAudio::File::File(IOStream *stream, bool readProperties, Properties::ReadStyle) :
|
||||
Strawberry_TagLib::TagLib::File(stream),
|
||||
d(new FilePrivate())
|
||||
{
|
||||
if(isOpen())
|
||||
TrueAudio::File::File(IOStream *stream, bool readProperties, Properties::ReadStyle) : Strawberry_TagLib::TagLib::File(stream),
|
||||
d(new FilePrivate()) {
|
||||
if (isOpen())
|
||||
read(readProperties);
|
||||
}
|
||||
|
||||
TrueAudio::File::File(IOStream *stream, ID3v2::FrameFactory *frameFactory,
|
||||
bool readProperties, Properties::ReadStyle) :
|
||||
Strawberry_TagLib::TagLib::File(stream),
|
||||
d(new FilePrivate(frameFactory))
|
||||
{
|
||||
if(isOpen())
|
||||
bool readProperties, Properties::ReadStyle) : Strawberry_TagLib::TagLib::File(stream),
|
||||
d(new FilePrivate(frameFactory)) {
|
||||
if (isOpen())
|
||||
read(readProperties);
|
||||
}
|
||||
|
||||
TrueAudio::File::~File()
|
||||
{
|
||||
TrueAudio::File::~File() {
|
||||
delete d;
|
||||
}
|
||||
|
||||
Strawberry_TagLib::TagLib::Tag *TrueAudio::File::tag() const
|
||||
{
|
||||
Strawberry_TagLib::TagLib::Tag *TrueAudio::File::tag() const {
|
||||
return &d->tag;
|
||||
}
|
||||
|
||||
PropertyMap TrueAudio::File::properties() const
|
||||
{
|
||||
PropertyMap TrueAudio::File::properties() const {
|
||||
return d->tag.properties();
|
||||
}
|
||||
|
||||
void TrueAudio::File::removeUnsupportedProperties(const StringList &unsupported)
|
||||
{
|
||||
void TrueAudio::File::removeUnsupportedProperties(const StringList &unsupported) {
|
||||
d->tag.removeUnsupportedProperties(unsupported);
|
||||
}
|
||||
|
||||
PropertyMap TrueAudio::File::setProperties(const PropertyMap &properties)
|
||||
{
|
||||
if(ID3v1Tag())
|
||||
PropertyMap TrueAudio::File::setProperties(const PropertyMap &properties) {
|
||||
if (ID3v1Tag())
|
||||
ID3v1Tag()->setProperties(properties);
|
||||
|
||||
return ID3v2Tag(true)->setProperties(properties);
|
||||
}
|
||||
|
||||
TrueAudio::Properties *TrueAudio::File::audioProperties() const
|
||||
{
|
||||
TrueAudio::Properties *TrueAudio::File::audioProperties() const {
|
||||
return d->properties;
|
||||
}
|
||||
|
||||
void TrueAudio::File::setID3v2FrameFactory(const ID3v2::FrameFactory *factory)
|
||||
{
|
||||
void TrueAudio::File::setID3v2FrameFactory(const ID3v2::FrameFactory *factory) {
|
||||
d->ID3v2FrameFactory = factory;
|
||||
}
|
||||
|
||||
bool TrueAudio::File::save()
|
||||
{
|
||||
if(readOnly()) {
|
||||
bool TrueAudio::File::save() {
|
||||
if (readOnly()) {
|
||||
debug("TrueAudio::File::save() -- File is read only.");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Update ID3v2 tag
|
||||
|
||||
if(ID3v2Tag() && !ID3v2Tag()->isEmpty()) {
|
||||
if (ID3v2Tag() && !ID3v2Tag()->isEmpty()) {
|
||||
|
||||
// ID3v2 tag is not empty. Update the old one or create a new one.
|
||||
|
||||
if(d->ID3v2Location < 0)
|
||||
if (d->ID3v2Location < 0)
|
||||
d->ID3v2Location = 0;
|
||||
|
||||
const ByteVector data = ID3v2Tag()->render();
|
||||
insert(data, d->ID3v2Location, d->ID3v2OriginalSize);
|
||||
|
||||
if(d->ID3v1Location >= 0)
|
||||
if (d->ID3v1Location >= 0)
|
||||
d->ID3v1Location += (static_cast<long>(data.size()) - d->ID3v2OriginalSize);
|
||||
|
||||
d->ID3v2OriginalSize = data.size();
|
||||
@@ -189,10 +169,10 @@ bool TrueAudio::File::save()
|
||||
|
||||
// ID3v2 tag is empty. Remove the old one.
|
||||
|
||||
if(d->ID3v2Location >= 0) {
|
||||
if (d->ID3v2Location >= 0) {
|
||||
removeBlock(d->ID3v2Location, d->ID3v2OriginalSize);
|
||||
|
||||
if(d->ID3v1Location >= 0)
|
||||
if (d->ID3v1Location >= 0)
|
||||
d->ID3v1Location -= d->ID3v2OriginalSize;
|
||||
|
||||
d->ID3v2Location = -1;
|
||||
@@ -202,11 +182,11 @@ bool TrueAudio::File::save()
|
||||
|
||||
// Update ID3v1 tag
|
||||
|
||||
if(ID3v1Tag() && !ID3v1Tag()->isEmpty()) {
|
||||
if (ID3v1Tag() && !ID3v1Tag()->isEmpty()) {
|
||||
|
||||
// ID3v1 tag is not empty. Update the old one or create a new one.
|
||||
|
||||
if(d->ID3v1Location >= 0) {
|
||||
if (d->ID3v1Location >= 0) {
|
||||
seek(d->ID3v1Location);
|
||||
}
|
||||
else {
|
||||
@@ -220,7 +200,7 @@ bool TrueAudio::File::save()
|
||||
|
||||
// ID3v1 tag is empty. Remove the old one.
|
||||
|
||||
if(d->ID3v1Location >= 0) {
|
||||
if (d->ID3v1Location >= 0) {
|
||||
truncate(d->ID3v1Location);
|
||||
d->ID3v1Location = -1;
|
||||
}
|
||||
@@ -229,35 +209,30 @@ bool TrueAudio::File::save()
|
||||
return true;
|
||||
}
|
||||
|
||||
ID3v1::Tag *TrueAudio::File::ID3v1Tag(bool create)
|
||||
{
|
||||
ID3v1::Tag *TrueAudio::File::ID3v1Tag(bool create) {
|
||||
return d->tag.access<ID3v1::Tag>(TrueAudioID3v1Index, create);
|
||||
}
|
||||
|
||||
ID3v2::Tag *TrueAudio::File::ID3v2Tag(bool create)
|
||||
{
|
||||
ID3v2::Tag *TrueAudio::File::ID3v2Tag(bool create) {
|
||||
return d->tag.access<ID3v2::Tag>(TrueAudioID3v2Index, create);
|
||||
}
|
||||
|
||||
void TrueAudio::File::strip(int tags)
|
||||
{
|
||||
if(tags & ID3v1)
|
||||
void TrueAudio::File::strip(int tags) {
|
||||
if (tags & ID3v1)
|
||||
d->tag.set(TrueAudioID3v1Index, 0);
|
||||
|
||||
if(tags & ID3v2)
|
||||
if (tags & ID3v2)
|
||||
d->tag.set(TrueAudioID3v2Index, 0);
|
||||
|
||||
if(!ID3v1Tag())
|
||||
if (!ID3v1Tag())
|
||||
ID3v2Tag(true);
|
||||
}
|
||||
|
||||
bool TrueAudio::File::hasID3v1Tag() const
|
||||
{
|
||||
bool TrueAudio::File::hasID3v1Tag() const {
|
||||
return (d->ID3v1Location >= 0);
|
||||
}
|
||||
|
||||
bool TrueAudio::File::hasID3v2Tag() const
|
||||
{
|
||||
bool TrueAudio::File::hasID3v2Tag() const {
|
||||
return (d->ID3v2Location >= 0);
|
||||
}
|
||||
|
||||
@@ -265,13 +240,12 @@ bool TrueAudio::File::hasID3v2Tag() const
|
||||
// private members
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void TrueAudio::File::read(bool readProperties)
|
||||
{
|
||||
void TrueAudio::File::read(bool readProperties) {
|
||||
// Look for an ID3v2 tag
|
||||
|
||||
d->ID3v2Location = Utils::findID3v2(this);
|
||||
|
||||
if(d->ID3v2Location >= 0) {
|
||||
if (d->ID3v2Location >= 0) {
|
||||
d->tag.set(TrueAudioID3v2Index, new ID3v2::Tag(this, d->ID3v2Location, d->ID3v2FrameFactory));
|
||||
d->ID3v2OriginalSize = ID3v2Tag()->header()->completeTagSize();
|
||||
}
|
||||
@@ -280,24 +254,24 @@ void TrueAudio::File::read(bool readProperties)
|
||||
|
||||
d->ID3v1Location = Utils::findID3v1(this);
|
||||
|
||||
if(d->ID3v1Location >= 0)
|
||||
if (d->ID3v1Location >= 0)
|
||||
d->tag.set(TrueAudioID3v1Index, new ID3v1::Tag(this, d->ID3v1Location));
|
||||
|
||||
if(d->ID3v1Location < 0)
|
||||
if (d->ID3v1Location < 0)
|
||||
ID3v2Tag(true);
|
||||
|
||||
// Look for TrueAudio metadata
|
||||
|
||||
if(readProperties) {
|
||||
if (readProperties) {
|
||||
|
||||
long streamLength;
|
||||
|
||||
if(d->ID3v1Location >= 0)
|
||||
if (d->ID3v1Location >= 0)
|
||||
streamLength = d->ID3v1Location;
|
||||
else
|
||||
streamLength = length();
|
||||
|
||||
if(d->ID3v2Location >= 0) {
|
||||
if (d->ID3v2Location >= 0) {
|
||||
seek(d->ID3v2Location + d->ID3v2OriginalSize);
|
||||
streamLength -= (d->ID3v2Location + d->ID3v2OriginalSize);
|
||||
}
|
||||
|
||||
150
3rdparty/taglib/trueaudio/trueaudiofile.h
vendored
150
3rdparty/taglib/trueaudio/trueaudiofile.h
vendored
@@ -36,59 +36,63 @@
|
||||
namespace Strawberry_TagLib {
|
||||
namespace TagLib {
|
||||
|
||||
class Tag;
|
||||
class Tag;
|
||||
|
||||
namespace ID3v2 { class Tag; class FrameFactory; }
|
||||
namespace ID3v1 { class Tag; }
|
||||
namespace ID3v2 {
|
||||
class Tag;
|
||||
class FrameFactory;
|
||||
} // namespace ID3v2
|
||||
namespace ID3v1 {
|
||||
class Tag;
|
||||
}
|
||||
|
||||
//! An implementation of TrueAudio metadata
|
||||
//! An implementation of TrueAudio metadata
|
||||
|
||||
/*!
|
||||
/*!
|
||||
* This is implementation of TrueAudio metadata.
|
||||
*
|
||||
* This supports ID3v1 and ID3v2 tags as well as reading stream
|
||||
* properties from the file.
|
||||
*/
|
||||
|
||||
namespace TrueAudio {
|
||||
namespace TrueAudio {
|
||||
|
||||
//! An implementation of TagLib::File with TrueAudio specific methods
|
||||
//! An implementation of TagLib::File with TrueAudio specific methods
|
||||
|
||||
/*!
|
||||
/*!
|
||||
* This implements and provides an interface for TrueAudio files to the
|
||||
* TagLib::Tag and TagLib::AudioProperties interfaces by way of implementing
|
||||
* the abstract TagLib::File API as well as providing some additional
|
||||
* information specific to TrueAudio files.
|
||||
*/
|
||||
|
||||
class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::File
|
||||
{
|
||||
public:
|
||||
/*!
|
||||
class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::File {
|
||||
public:
|
||||
/*!
|
||||
* This set of flags is used for various operations and is suitable for
|
||||
* being OR-ed together.
|
||||
*/
|
||||
enum TagTypes {
|
||||
//! Empty set. Matches no tag types.
|
||||
NoTags = 0x0000,
|
||||
//! Matches ID3v1 tags.
|
||||
ID3v1 = 0x0001,
|
||||
//! Matches ID3v2 tags.
|
||||
ID3v2 = 0x0002,
|
||||
//! Matches all tag types.
|
||||
AllTags = 0xffff
|
||||
};
|
||||
enum TagTypes {
|
||||
//! Empty set. Matches no tag types.
|
||||
NoTags = 0x0000,
|
||||
//! Matches ID3v1 tags.
|
||||
ID3v1 = 0x0001,
|
||||
//! Matches ID3v2 tags.
|
||||
ID3v2 = 0x0002,
|
||||
//! Matches all tag types.
|
||||
AllTags = 0xffff
|
||||
};
|
||||
|
||||
/*!
|
||||
/*!
|
||||
* Constructs a TrueAudio file from \a file. If \a readProperties is true
|
||||
* the file's audio properties will also be read.
|
||||
*
|
||||
* \note In the current implementation, \a propertiesStyle is ignored.
|
||||
*/
|
||||
File(FileName file, bool readProperties = true,
|
||||
Properties::ReadStyle propertiesStyle = Properties::Average);
|
||||
File(FileName file, bool readProperties = true,
|
||||
Properties::ReadStyle propertiesStyle = Properties::Average);
|
||||
|
||||
/*!
|
||||
/*!
|
||||
* Constructs a TrueAudio file from \a file. If \a readProperties is true
|
||||
* the file's audio properties will also be read.
|
||||
*
|
||||
@@ -97,11 +101,11 @@ namespace TagLib {
|
||||
*
|
||||
* \note In the current implementation, \a propertiesStyle is ignored.
|
||||
*/
|
||||
File(FileName file, ID3v2::FrameFactory *frameFactory,
|
||||
bool readProperties = true,
|
||||
Properties::ReadStyle propertiesStyle = Properties::Average);
|
||||
File(FileName file, ID3v2::FrameFactory *frameFactory,
|
||||
bool readProperties = true,
|
||||
Properties::ReadStyle propertiesStyle = Properties::Average);
|
||||
|
||||
/*!
|
||||
/*!
|
||||
* Constructs a TrueAudio file from \a stream. If \a readProperties is true
|
||||
* the file's audio properties will also be read.
|
||||
*
|
||||
@@ -110,10 +114,10 @@ namespace TagLib {
|
||||
*
|
||||
* \note In the current implementation, \a propertiesStyle is ignored.
|
||||
*/
|
||||
File(IOStream *stream, bool readProperties = true,
|
||||
Properties::ReadStyle propertiesStyle = Properties::Average);
|
||||
File(IOStream *stream, bool readProperties = true,
|
||||
Properties::ReadStyle propertiesStyle = Properties::Average);
|
||||
|
||||
/*!
|
||||
/*!
|
||||
* Constructs a TrueAudio file from \a stream. If \a readProperties is true
|
||||
* the file's audio properties will also be read.
|
||||
*
|
||||
@@ -125,56 +129,56 @@ namespace TagLib {
|
||||
*
|
||||
* \note In the current implementation, \a propertiesStyle is ignored.
|
||||
*/
|
||||
File(IOStream *stream, ID3v2::FrameFactory *frameFactory,
|
||||
bool readProperties = true,
|
||||
Properties::ReadStyle propertiesStyle = Properties::Average);
|
||||
File(IOStream *stream, ID3v2::FrameFactory *frameFactory,
|
||||
bool readProperties = true,
|
||||
Properties::ReadStyle propertiesStyle = Properties::Average);
|
||||
|
||||
/*!
|
||||
/*!
|
||||
* Destroys this instance of the File.
|
||||
*/
|
||||
virtual ~File();
|
||||
virtual ~File();
|
||||
|
||||
/*!
|
||||
/*!
|
||||
* Returns the Tag for this file.
|
||||
*/
|
||||
virtual Strawberry_TagLib::TagLib::Tag *tag() const;
|
||||
virtual Strawberry_TagLib::TagLib::Tag *tag() const;
|
||||
|
||||
/*!
|
||||
/*!
|
||||
* Implements the unified property interface -- export function.
|
||||
* If the file contains both ID3v1 and v2 tags, only ID3v2 will be
|
||||
* converted to the PropertyMap.
|
||||
*/
|
||||
PropertyMap properties() const;
|
||||
PropertyMap properties() const;
|
||||
|
||||
/*!
|
||||
/*!
|
||||
* Implements the unified property interface -- import function.
|
||||
* Creates in ID3v2 tag if necessary. If an ID3v1 tag exists, it will
|
||||
* be updated as well, within the limitations of ID3v1.
|
||||
*/
|
||||
PropertyMap setProperties(const PropertyMap &);
|
||||
PropertyMap setProperties(const PropertyMap &);
|
||||
|
||||
void removeUnsupportedProperties(const StringList &properties);
|
||||
void removeUnsupportedProperties(const StringList &properties);
|
||||
|
||||
/*!
|
||||
/*!
|
||||
* Returns the TrueAudio::Properties for this file. If no audio properties
|
||||
* were read then this will return a null pointer.
|
||||
*/
|
||||
virtual Properties *audioProperties() const;
|
||||
virtual Properties *audioProperties() const;
|
||||
|
||||
/*!
|
||||
/*!
|
||||
* Set the ID3v2::FrameFactory to something other than the default.
|
||||
*
|
||||
* \see ID3v2FrameFactory
|
||||
* \deprecated This value should be passed in via the constructor
|
||||
*/
|
||||
TAGLIB_DEPRECATED void setID3v2FrameFactory(const ID3v2::FrameFactory *factory);
|
||||
TAGLIB_DEPRECATED void setID3v2FrameFactory(const ID3v2::FrameFactory *factory);
|
||||
|
||||
/*!
|
||||
/*!
|
||||
* Saves the file.
|
||||
*/
|
||||
virtual bool save();
|
||||
virtual bool save();
|
||||
|
||||
/*!
|
||||
/*!
|
||||
* Returns a pointer to the ID3v1 tag of the file.
|
||||
*
|
||||
* If \a create is false (the default) this may return a null pointer
|
||||
@@ -191,9 +195,9 @@ namespace TagLib {
|
||||
*
|
||||
* \see hasID3v1Tag()
|
||||
*/
|
||||
ID3v1::Tag *ID3v1Tag(bool create = false);
|
||||
ID3v1::Tag *ID3v1Tag(bool create = false);
|
||||
|
||||
/*!
|
||||
/*!
|
||||
* Returns a pointer to the ID3v2 tag of the file.
|
||||
*
|
||||
* If \a create is false (the default) this may return a null pointer
|
||||
@@ -210,9 +214,9 @@ namespace TagLib {
|
||||
*
|
||||
* \see hasID3v2Tag()
|
||||
*/
|
||||
ID3v2::Tag *ID3v2Tag(bool create = false);
|
||||
ID3v2::Tag *ID3v2Tag(bool create = false);
|
||||
|
||||
/*!
|
||||
/*!
|
||||
* This will remove the tags that match the OR-ed together TagTypes from the
|
||||
* file. By default it removes all tags.
|
||||
*
|
||||
@@ -220,42 +224,42 @@ namespace TagLib {
|
||||
* as their memory will be freed.
|
||||
* \note In order to make the removal permanent save() still needs to be called
|
||||
*/
|
||||
void strip(int tags = AllTags);
|
||||
void strip(int tags = AllTags);
|
||||
|
||||
/*!
|
||||
/*!
|
||||
* Returns whether or not the file on disk actually has an ID3v1 tag.
|
||||
*
|
||||
* \see ID3v1Tag()
|
||||
*/
|
||||
bool hasID3v1Tag() const;
|
||||
bool hasID3v1Tag() const;
|
||||
|
||||
/*!
|
||||
/*!
|
||||
* Returns whether or not the file on disk actually has an ID3v2 tag.
|
||||
*
|
||||
* \see ID3v2Tag()
|
||||
*/
|
||||
bool hasID3v2Tag() const;
|
||||
bool hasID3v2Tag() const;
|
||||
|
||||
/*!
|
||||
/*!
|
||||
* Returns whether or not the given \a stream can be opened as a TrueAudio
|
||||
* file.
|
||||
*
|
||||
* \note This method is designed to do a quick check. The result may
|
||||
* not necessarily be correct.
|
||||
*/
|
||||
static bool isSupported(IOStream *stream);
|
||||
static bool isSupported(IOStream *stream);
|
||||
|
||||
private:
|
||||
File(const File &);
|
||||
File &operator=(const File &);
|
||||
private:
|
||||
File(const File &);
|
||||
File &operator=(const File &);
|
||||
|
||||
void read(bool readProperties);
|
||||
void read(bool readProperties);
|
||||
|
||||
class FilePrivate;
|
||||
FilePrivate *d;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
class FilePrivate;
|
||||
FilePrivate *d;
|
||||
};
|
||||
} // namespace TrueAudio
|
||||
} // namespace TagLib
|
||||
} // namespace Strawberry_TagLib
|
||||
|
||||
#endif
|
||||
|
||||
@@ -36,17 +36,15 @@
|
||||
|
||||
using namespace Strawberry_TagLib::TagLib;
|
||||
|
||||
class TrueAudio::Properties::PropertiesPrivate
|
||||
{
|
||||
public:
|
||||
PropertiesPrivate() :
|
||||
version(0),
|
||||
length(0),
|
||||
bitrate(0),
|
||||
sampleRate(0),
|
||||
channels(0),
|
||||
bitsPerSample(0),
|
||||
sampleFrames(0) {}
|
||||
class TrueAudio::Properties::PropertiesPrivate {
|
||||
public:
|
||||
PropertiesPrivate() : version(0),
|
||||
length(0),
|
||||
bitrate(0),
|
||||
sampleRate(0),
|
||||
channels(0),
|
||||
bitsPerSample(0),
|
||||
sampleFrames(0) {}
|
||||
|
||||
int version;
|
||||
int length;
|
||||
@@ -61,60 +59,48 @@ public:
|
||||
// public members
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
TrueAudio::Properties::Properties(const ByteVector &data, long streamLength, ReadStyle style) :
|
||||
AudioProperties(style),
|
||||
d(new PropertiesPrivate())
|
||||
{
|
||||
TrueAudio::Properties::Properties(const ByteVector &data, long streamLength, ReadStyle style) : AudioProperties(style),
|
||||
d(new PropertiesPrivate()) {
|
||||
read(data, streamLength);
|
||||
}
|
||||
|
||||
TrueAudio::Properties::~Properties()
|
||||
{
|
||||
TrueAudio::Properties::~Properties() {
|
||||
delete d;
|
||||
}
|
||||
|
||||
int TrueAudio::Properties::length() const
|
||||
{
|
||||
int TrueAudio::Properties::length() const {
|
||||
return lengthInSeconds();
|
||||
}
|
||||
|
||||
int TrueAudio::Properties::lengthInSeconds() const
|
||||
{
|
||||
int TrueAudio::Properties::lengthInSeconds() const {
|
||||
return d->length / 1000;
|
||||
}
|
||||
|
||||
int TrueAudio::Properties::lengthInMilliseconds() const
|
||||
{
|
||||
int TrueAudio::Properties::lengthInMilliseconds() const {
|
||||
return d->length;
|
||||
}
|
||||
|
||||
int TrueAudio::Properties::bitrate() const
|
||||
{
|
||||
int TrueAudio::Properties::bitrate() const {
|
||||
return d->bitrate;
|
||||
}
|
||||
|
||||
int TrueAudio::Properties::sampleRate() const
|
||||
{
|
||||
int TrueAudio::Properties::sampleRate() const {
|
||||
return d->sampleRate;
|
||||
}
|
||||
|
||||
int TrueAudio::Properties::bitsPerSample() const
|
||||
{
|
||||
int TrueAudio::Properties::bitsPerSample() const {
|
||||
return d->bitsPerSample;
|
||||
}
|
||||
|
||||
int TrueAudio::Properties::channels() const
|
||||
{
|
||||
int TrueAudio::Properties::channels() const {
|
||||
return d->channels;
|
||||
}
|
||||
|
||||
unsigned int TrueAudio::Properties::sampleFrames() const
|
||||
{
|
||||
unsigned int TrueAudio::Properties::sampleFrames() const {
|
||||
return d->sampleFrames;
|
||||
}
|
||||
|
||||
int TrueAudio::Properties::ttaVersion() const
|
||||
{
|
||||
int TrueAudio::Properties::ttaVersion() const {
|
||||
return d->version;
|
||||
}
|
||||
|
||||
@@ -122,14 +108,13 @@ int TrueAudio::Properties::ttaVersion() const
|
||||
// private members
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void TrueAudio::Properties::read(const ByteVector &data, long streamLength)
|
||||
{
|
||||
if(data.size() < 4) {
|
||||
void TrueAudio::Properties::read(const ByteVector &data, long streamLength) {
|
||||
if (data.size() < 4) {
|
||||
debug("TrueAudio::Properties::read() -- data is too short.");
|
||||
return;
|
||||
}
|
||||
|
||||
if(!data.startsWith("TTA")) {
|
||||
if (!data.startsWith("TTA")) {
|
||||
debug("TrueAudio::Properties::read() -- invalid header signature.");
|
||||
return;
|
||||
}
|
||||
@@ -141,8 +126,8 @@ void TrueAudio::Properties::read(const ByteVector &data, long streamLength)
|
||||
|
||||
// According to http://en.true-audio.com/TTA_Lossless_Audio_Codec_-_Format_Description
|
||||
// TTA2 headers are in development, and have a different format
|
||||
if(1 == d->version) {
|
||||
if(data.size() < 18) {
|
||||
if (1 == d->version) {
|
||||
if (data.size() < 18) {
|
||||
debug("TrueAudio::Properties::read() -- data is too short.");
|
||||
return;
|
||||
}
|
||||
@@ -161,9 +146,9 @@ void TrueAudio::Properties::read(const ByteVector &data, long streamLength)
|
||||
|
||||
d->sampleFrames = data.toUInt(pos, false);
|
||||
|
||||
if(d->sampleFrames > 0 && d->sampleRate > 0) {
|
||||
if (d->sampleFrames > 0 && d->sampleRate > 0) {
|
||||
const double length = d->sampleFrames * 1000.0 / d->sampleRate;
|
||||
d->length = static_cast<int>(length + 0.5);
|
||||
d->length = static_cast<int>(length + 0.5);
|
||||
d->bitrate = static_cast<int>(streamLength * 8.0 / length + 0.5);
|
||||
}
|
||||
}
|
||||
|
||||
83
3rdparty/taglib/trueaudio/trueaudioproperties.h
vendored
83
3rdparty/taglib/trueaudio/trueaudioproperties.h
vendored
@@ -35,34 +35,33 @@
|
||||
namespace Strawberry_TagLib {
|
||||
namespace TagLib {
|
||||
|
||||
namespace TrueAudio {
|
||||
namespace TrueAudio {
|
||||
|
||||
class File;
|
||||
class File;
|
||||
|
||||
static const unsigned int HeaderSize = 18;
|
||||
static const unsigned int HeaderSize = 18;
|
||||
|
||||
//! An implementation of audio property reading for TrueAudio
|
||||
//! An implementation of audio property reading for TrueAudio
|
||||
|
||||
/*!
|
||||
/*!
|
||||
* This reads the data from an TrueAudio stream found in the AudioProperties
|
||||
* API.
|
||||
*/
|
||||
|
||||
class TAGLIB_EXPORT Properties : public AudioProperties
|
||||
{
|
||||
public:
|
||||
/*!
|
||||
class TAGLIB_EXPORT Properties : public AudioProperties {
|
||||
public:
|
||||
/*!
|
||||
* Create an instance of TrueAudio::Properties with the data read from the
|
||||
* ByteVector \a data.
|
||||
*/
|
||||
Properties(const ByteVector &data, long streamLength, ReadStyle style = Average);
|
||||
Properties(const ByteVector &data, long streamLength, ReadStyle style = Average);
|
||||
|
||||
/*!
|
||||
/*!
|
||||
* Destroys this TrueAudio::Properties instance.
|
||||
*/
|
||||
virtual ~Properties();
|
||||
virtual ~Properties();
|
||||
|
||||
/*!
|
||||
/*!
|
||||
* Returns the length of the file in seconds. The length is rounded down to
|
||||
* the nearest whole second.
|
||||
*
|
||||
@@ -70,66 +69,66 @@ namespace TagLib {
|
||||
*
|
||||
* \deprecated
|
||||
*/
|
||||
virtual int length() const;
|
||||
virtual int length() const;
|
||||
|
||||
/*!
|
||||
/*!
|
||||
* Returns the length of the file in seconds. The length is rounded down to
|
||||
* the nearest whole second.
|
||||
*
|
||||
* \see lengthInMilliseconds()
|
||||
*/
|
||||
// BIC: make virtual
|
||||
int lengthInSeconds() const;
|
||||
// BIC: make virtual
|
||||
int lengthInSeconds() const;
|
||||
|
||||
/*!
|
||||
/*!
|
||||
* Returns the length of the file in milliseconds.
|
||||
*
|
||||
* \see lengthInSeconds()
|
||||
*/
|
||||
// BIC: make virtual
|
||||
int lengthInMilliseconds() const;
|
||||
// BIC: make virtual
|
||||
int lengthInMilliseconds() const;
|
||||
|
||||
/*!
|
||||
/*!
|
||||
* Returns the average bit rate of the file in kb/s.
|
||||
*/
|
||||
virtual int bitrate() const;
|
||||
virtual int bitrate() const;
|
||||
|
||||
/*!
|
||||
/*!
|
||||
* Returns the sample rate in Hz.
|
||||
*/
|
||||
virtual int sampleRate() const;
|
||||
virtual int sampleRate() const;
|
||||
|
||||
/*!
|
||||
/*!
|
||||
* Returns the number of audio channels.
|
||||
*/
|
||||
virtual int channels() const;
|
||||
virtual int channels() const;
|
||||
|
||||
/*!
|
||||
/*!
|
||||
* Returns the number of bits per audio sample.
|
||||
*/
|
||||
int bitsPerSample() const;
|
||||
int bitsPerSample() const;
|
||||
|
||||
/*!
|
||||
/*!
|
||||
* Returns the total number of sample frames
|
||||
*/
|
||||
unsigned int sampleFrames() const;
|
||||
unsigned int sampleFrames() const;
|
||||
|
||||
/*!
|
||||
/*!
|
||||
* Returns the major version number.
|
||||
*/
|
||||
int ttaVersion() const;
|
||||
int ttaVersion() const;
|
||||
|
||||
private:
|
||||
Properties(const Properties &);
|
||||
Properties &operator=(const Properties &);
|
||||
private:
|
||||
Properties(const Properties &);
|
||||
Properties &operator=(const Properties &);
|
||||
|
||||
void read(const ByteVector &data, long streamLength);
|
||||
void read(const ByteVector &data, long streamLength);
|
||||
|
||||
class PropertiesPrivate;
|
||||
PropertiesPrivate *d;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
class PropertiesPrivate;
|
||||
PropertiesPrivate *d;
|
||||
};
|
||||
} // namespace TrueAudio
|
||||
} // namespace TagLib
|
||||
} // namespace Strawberry_TagLib
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user