Additional manual formatting to taglib sources

This commit is contained in:
Jonas Kvinge
2020-06-14 17:01:05 +02:00
parent 577b7d8ec8
commit ef34dce4dc
217 changed files with 7367 additions and 8204 deletions

View File

@@ -43,8 +43,10 @@
using namespace Strawberry_TagLib::TagLib;
namespace {
enum { TrueAudioID3v2Index = 0,
TrueAudioID3v1Index = 1 };
enum {
TrueAudioID3v2Index = 0,
TrueAudioID3v1Index = 1
};
}
class TrueAudio::File::FilePrivate {
@@ -53,7 +55,7 @@ class TrueAudio::File::FilePrivate {
ID3v2Location(-1),
ID3v2OriginalSize(0),
ID3v1Location(-1),
properties(0) {}
properties(nullptr) {}
~FilePrivate() {
delete properties;
@@ -75,40 +77,44 @@ class TrueAudio::File::FilePrivate {
////////////////////////////////////////////////////////////////////////////////
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);
return (id == "TTA");
}
////////////////////////////////////////////////////////////////////////////////
// public members
////////////////////////////////////////////////////////////////////////////////
TrueAudio::File::File(FileName file, bool readProperties, Properties::ReadStyle) : Strawberry_TagLib::TagLib::File(file),
d(new FilePrivate()) {
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)) {
TrueAudio::File::File(FileName file, ID3v2::FrameFactory *frameFactory, 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()) {
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)) {
TrueAudio::File::File(IOStream *stream, ID3v2::FrameFactory *frameFactory, bool readProperties, Properties::ReadStyle) : Strawberry_TagLib::TagLib::File(stream), d(new FilePrivate(frameFactory)) {
if (isOpen())
read(readProperties);
}
TrueAudio::File::~File() {
@@ -128,21 +134,20 @@ void TrueAudio::File::removeUnsupportedProperties(const StringList &unsupported)
}
PropertyMap TrueAudio::File::setProperties(const PropertyMap &properties) {
if (ID3v1Tag())
ID3v1Tag()->setProperties(properties);
return ID3v2Tag(true)->setProperties(properties);
}
TrueAudio::Properties *TrueAudio::File::audioProperties() const {
return d->properties;
}
void TrueAudio::File::setID3v2FrameFactory(const ID3v2::FrameFactory *factory) {
d->ID3v2FrameFactory = factory;
}
bool TrueAudio::File::save() {
if (readOnly()) {
debug("TrueAudio::File::save() -- File is read only.");
return false;
@@ -207,6 +212,7 @@ bool TrueAudio::File::save() {
}
return true;
}
ID3v1::Tag *TrueAudio::File::ID3v1Tag(bool create) {
@@ -218,14 +224,16 @@ ID3v2::Tag *TrueAudio::File::ID3v2Tag(bool create) {
}
void TrueAudio::File::strip(int tags) {
if (tags & ID3v1)
d->tag.set(TrueAudioID3v1Index, 0);
d->tag.set(TrueAudioID3v1Index, nullptr);
if (tags & ID3v2)
d->tag.set(TrueAudioID3v2Index, 0);
d->tag.set(TrueAudioID3v2Index, nullptr);
if (!ID3v1Tag())
ID3v2Tag(true);
}
bool TrueAudio::File::hasID3v1Tag() const {
@@ -241,6 +249,7 @@ bool TrueAudio::File::hasID3v2Tag() const {
////////////////////////////////////////////////////////////////////////////////
void TrueAudio::File::read(bool readProperties) {
// Look for an ID3v2 tag
d->ID3v2Location = Utils::findID3v2(this);
@@ -281,4 +290,5 @@ void TrueAudio::File::read(bool readProperties) {
d->properties = new Properties(readBlock(TrueAudio::HeaderSize), streamLength);
}
}

View File

@@ -49,29 +49,26 @@ class Tag;
//! 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.
*/
* This is implementation of TrueAudio metadata.
*
* This supports ID3v1 and ID3v2 tags as well as reading stream properties from the file.
*/
namespace TrueAudio {
//! 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.
*/
* 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:
/*!
* This set of flags is used for various operations and is suitable for
* being OR-ed together.
*/
* 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,
@@ -84,169 +81,140 @@ class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::File {
};
/*!
* 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.
*/
* 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);
/*!
* Constructs a TrueAudio file from \a file. If \a readProperties is true
* the file's audio properties will also be read.
*
* If this file contains and ID3v2 tag the frames will be created using
* \a frameFactory.
*
* \note In the current implementation, \a propertiesStyle is ignored.
*/
File(FileName file, ID3v2::FrameFactory *frameFactory,
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.
*
* If this file contains and ID3v2 tag the frames will be created using \a frameFactory.
*
* \note In the current implementation, \a propertiesStyle is ignored.
*/
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.
*
* \note TagLib will *not* take ownership of the stream, the caller is
* responsible for deleting it after the File object.
*
* \note In the current implementation, \a propertiesStyle is ignored.
*/
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.
*
* \note TagLib will *not* take ownership of the stream, the caller is responsible for deleting it after the File object.
*
* \note In the current implementation, \a propertiesStyle is ignored.
*/
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.
*
* \note TagLib will *not* take ownership of the stream, the caller is
* responsible for deleting it after the File object.
*
* If this file contains and ID3v2 tag the frames will be created using
* \a frameFactory.
*
* \note In the current implementation, \a propertiesStyle is ignored.
*/
File(IOStream *stream, 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.
*
* \note TagLib will *not* take ownership of the stream, the caller is responsible for deleting it after the File object.
*
* If this file contains and ID3v2 tag the frames will be created using \a frameFactory.
*
* \note In the current implementation, \a propertiesStyle is ignored.
*/
File(IOStream *stream, ID3v2::FrameFactory *frameFactory, bool readProperties = true, Properties::ReadStyle propertiesStyle = Properties::Average);
/*!
* Destroys this instance of the File.
*/
* Destroys this instance of the File.
*/
virtual ~File();
/*!
* Returns the Tag for this file.
*/
* Returns the Tag for this file.
*/
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.
*/
* 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;
/*!
* 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.
*/
* 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 &);
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.
*/
* Returns the TrueAudio::Properties for this file.
* If no audio properties were read then this will return a null pointer.
*/
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);
/*!
* Saves the file.
*/
* Saves the file.
*/
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
* if there is no valid ID3v1 tag. If \a create is true it will create
* an ID3v1 tag if one does not exist and returns a valid pointer.
*
* \note This may return a valid pointer regardless of whether or not the
* file on disk has an ID3v1 tag. Use hasID3v1Tag() to check if the file
* on disk actually has an ID3v1 tag.
*
* \note The Tag <b>is still</b> owned by the MPEG::File and should not be
* deleted by the user. It will be deleted when the file (object) is
* destroyed.
*
* \see hasID3v1Tag()
*/
* Returns a pointer to the ID3v1 tag of the file.
*
* If \a create is false (the default) this may return a null pointer if there is no valid ID3v1 tag.
* If \a create is true it will create an ID3v1 tag if one does not exist and returns a valid pointer.
*
* \note This may return a valid pointer regardless of whether or not the file on disk has an ID3v1 tag.
* Use hasID3v1Tag() to check if the file on disk actually has an ID3v1 tag.
*
* \note The Tag <b>is still</b> owned by the MPEG::File and should not be deleted by the user.
* It will be deleted when the file (object) is destroyed.
*
* \see hasID3v1Tag()
*/
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
* if there is no valid ID3v2 tag. If \a create is true it will create
* an ID3v2 tag if one does not exist and returns a valid pointer.
*
* \note This may return a valid pointer regardless of whether or not the
* file on disk has an ID3v2 tag. Use hasID3v2Tag() to check if the file
* on disk actually has an ID3v2 tag.
*
* \note The Tag <b>is still</b> owned by the MPEG::File and should not be
* deleted by the user. It will be deleted when the file (object) is
* destroyed.
*
* \see hasID3v2Tag()
*/
* Returns a pointer to the ID3v2 tag of the file.
*
* If \a create is false (the default) this may return a null pointer if there is no valid ID3v2 tag.
* If \a create is true it will create an ID3v2 tag if one does not exist and returns a valid pointer.
*
* \note This may return a valid pointer regardless of whether or not the file on disk has an ID3v2 tag.
* Use hasID3v2Tag() to check if the file on disk actually has an ID3v2 tag.
*
* \note The Tag <b>is still</b> owned by the MPEG::File and should not be deleted by the user.
* It will be deleted when the file (object) is destroyed.
*
* \see hasID3v2Tag()
*/
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.
*
* \note This will also invalidate pointers to the tags
* as their memory will be freed.
* \note In order to make the removal permanent save() still needs to be called
*/
* This will remove the tags that match the OR-ed together TagTypes from the file.
* By default it removes all tags.
*
* \note This will also invalidate pointers to the tags 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);
/*!
* Returns whether or not the file on disk actually has an ID3v1 tag.
*
* \see ID3v1Tag()
*/
* Returns whether or not the file on disk actually has an ID3v1 tag.
*
* \see ID3v1Tag()
*/
bool hasID3v1Tag() const;
/*!
* Returns whether or not the file on disk actually has an ID3v2 tag.
*
* \see ID3v2Tag()
*/
* Returns whether or not the file on disk actually has an ID3v2 tag.
*
* \see ID3v2Tag()
*/
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.
*/
* 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);
private:
@@ -258,6 +226,7 @@ class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::File {
class FilePrivate;
FilePrivate *d;
};
} // namespace TrueAudio
} // namespace TagLib
} // namespace Strawberry_TagLib

View File

@@ -59,8 +59,7 @@ class TrueAudio::Properties::PropertiesPrivate {
// 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);
}
@@ -68,10 +67,6 @@ TrueAudio::Properties::~Properties() {
delete d;
}
int TrueAudio::Properties::length() const {
return lengthInSeconds();
}
int TrueAudio::Properties::lengthInSeconds() const {
return d->length / 1000;
}
@@ -109,6 +104,7 @@ int TrueAudio::Properties::ttaVersion() const {
////////////////////////////////////////////////////////////////////////////////
void TrueAudio::Properties::read(const ByteVector &data, long streamLength) {
if (data.size() < 4) {
debug("TrueAudio::Properties::read() -- data is too short.");
return;
@@ -152,4 +148,5 @@ void TrueAudio::Properties::read(const ByteVector &data, long streamLength) {
d->bitrate = static_cast<int>(streamLength * 8.0 / length + 0.5);
}
}
}

View File

@@ -34,7 +34,6 @@
namespace Strawberry_TagLib {
namespace TagLib {
namespace TrueAudio {
class File;
@@ -44,78 +43,65 @@ static const unsigned int HeaderSize = 18;
//! An implementation of audio property reading for TrueAudio
/*!
* This reads the data from an TrueAudio stream found in the AudioProperties
* API.
*/
* This reads the data from an TrueAudio stream found in the AudioProperties API.
*/
class TAGLIB_EXPORT Properties : public AudioProperties {
public:
/*!
* Create an instance of TrueAudio::Properties with the data read from the
* ByteVector \a data.
*/
* Create an instance of TrueAudio::Properties with the data read from the ByteVector \a data.
*/
Properties(const ByteVector &data, long streamLength, ReadStyle style = Average);
/*!
* Destroys this TrueAudio::Properties instance.
*/
* Destroys this TrueAudio::Properties instance.
*/
virtual ~Properties();
/*!
* Returns the length of the file in seconds. The length is rounded down to
* the nearest whole second.
*
* \note This method is just an alias of lengthInSeconds().
*
* \deprecated
*/
virtual int length() const;
/*!
* Returns the length of the file in seconds. The length is rounded down to
* the nearest whole second.
*
* \see lengthInMilliseconds()
*/
* 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;
/*!
* Returns the length of the file in milliseconds.
*
* \see lengthInSeconds()
*/
* Returns the length of the file in milliseconds.
*
* \see lengthInSeconds()
*/
// BIC: make virtual
int lengthInMilliseconds() const;
/*!
* Returns the average bit rate of the file in kb/s.
*/
* Returns the average bit rate of the file in kb/s.
*/
virtual int bitrate() const;
/*!
* Returns the sample rate in Hz.
*/
* Returns the sample rate in Hz.
*/
virtual int sampleRate() const;
/*!
* Returns the number of audio channels.
*/
* Returns the number of audio channels.
*/
virtual int channels() const;
/*!
* Returns the number of bits per audio sample.
*/
* Returns the number of bits per audio sample.
*/
int bitsPerSample() const;
/*!
* Returns the total number of sample frames
*/
* Returns the total number of sample frames
*/
unsigned int sampleFrames() const;
/*!
* Returns the major version number.
*/
* Returns the major version number.
*/
int ttaVersion() const;
private:
@@ -127,6 +113,7 @@ class TAGLIB_EXPORT Properties : public AudioProperties {
class PropertiesPrivate;
PropertiesPrivate *d;
};
} // namespace TrueAudio
} // namespace TagLib
} // namespace Strawberry_TagLib