Adapt most changes from taglib2
This commit is contained in:
47
3rdparty/taglib/riff/aiff/aifffile.cpp
vendored
47
3rdparty/taglib/riff/aiff/aifffile.cpp
vendored
@@ -23,12 +23,14 @@
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include <tbytevector.h>
|
||||
#include <tdebug.h>
|
||||
#include <id3v2tag.h>
|
||||
#include <tstringlist.h>
|
||||
#include <tpropertymap.h>
|
||||
#include <tagutils.h>
|
||||
#include <memory>
|
||||
|
||||
#include "tbytevector.h"
|
||||
#include "tdebug.h"
|
||||
#include "id3v2tag.h"
|
||||
#include "tstringlist.h"
|
||||
#include "tpropertymap.h"
|
||||
#include "tagutils.h"
|
||||
|
||||
#include "aifffile.h"
|
||||
|
||||
@@ -36,15 +38,10 @@ using namespace Strawberry_TagLib::TagLib;
|
||||
|
||||
class RIFF::AIFF::File::FilePrivate {
|
||||
public:
|
||||
FilePrivate() : properties(nullptr), tag(nullptr), hasID3v2(false) {}
|
||||
FilePrivate() : hasID3v2(false) {}
|
||||
|
||||
~FilePrivate() {
|
||||
delete properties;
|
||||
delete tag;
|
||||
}
|
||||
|
||||
AudioProperties *properties;
|
||||
ID3v2::Tag *tag;
|
||||
std::unique_ptr<AudioProperties> properties;
|
||||
std::unique_ptr<ID3v2::Tag> tag;
|
||||
|
||||
bool hasID3v2;
|
||||
};
|
||||
@@ -83,23 +80,11 @@ RIFF::AIFF::File::~File() {
|
||||
}
|
||||
|
||||
ID3v2::Tag *RIFF::AIFF::File::tag() const {
|
||||
return d->tag;
|
||||
}
|
||||
|
||||
PropertyMap RIFF::AIFF::File::properties() const {
|
||||
return d->tag->properties();
|
||||
}
|
||||
|
||||
void RIFF::AIFF::File::removeUnsupportedProperties(const StringList &properties) {
|
||||
d->tag->removeUnsupportedProperties(properties);
|
||||
}
|
||||
|
||||
PropertyMap RIFF::AIFF::File::setProperties(const PropertyMap &properties) {
|
||||
return d->tag->setProperties(properties);
|
||||
return d->tag.get();
|
||||
}
|
||||
|
||||
RIFF::AIFF::AudioProperties *RIFF::AIFF::File::audioProperties() const {
|
||||
return d->properties;
|
||||
return d->properties.get();
|
||||
}
|
||||
|
||||
bool RIFF::AIFF::File::save() {
|
||||
@@ -147,7 +132,7 @@ void RIFF::AIFF::File::read(bool readProperties) {
|
||||
const ByteVector name = chunkName(i);
|
||||
if (name == "ID3 " || name == "id3 ") {
|
||||
if (!d->tag) {
|
||||
d->tag = new ID3v2::Tag(this, chunkOffset(i));
|
||||
d->tag.reset(new ID3v2::Tag(this, chunkOffset(i)));
|
||||
d->hasID3v2 = true;
|
||||
}
|
||||
else {
|
||||
@@ -157,9 +142,9 @@ void RIFF::AIFF::File::read(bool readProperties) {
|
||||
}
|
||||
|
||||
if (!d->tag)
|
||||
d->tag = new ID3v2::Tag();
|
||||
d->tag.reset(new ID3v2::Tag());
|
||||
|
||||
if (readProperties)
|
||||
d->properties = new AudioProperties(this, AudioProperties::Average);
|
||||
d->properties.reset(new AudioProperties(this, AudioProperties::Average));
|
||||
|
||||
}
|
||||
|
||||
24
3rdparty/taglib/riff/aiff/aifffile.h
vendored
24
3rdparty/taglib/riff/aiff/aifffile.h
vendored
@@ -78,7 +78,7 @@ class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::RIFF::File {
|
||||
/*!
|
||||
* Destroys this instance of the File.
|
||||
*/
|
||||
virtual ~File();
|
||||
~File() override;
|
||||
|
||||
/*!
|
||||
* Returns the Tag for this file.
|
||||
@@ -88,32 +88,18 @@ class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::RIFF::File {
|
||||
*
|
||||
* \see hasID3v2Tag()
|
||||
*/
|
||||
virtual ID3v2::Tag *tag() const;
|
||||
|
||||
/*!
|
||||
* Implements the unified property interface -- export function.
|
||||
* This method forwards to ID3v2::Tag::properties().
|
||||
*/
|
||||
PropertyMap properties() const;
|
||||
|
||||
void removeUnsupportedProperties(const StringList &properties);
|
||||
|
||||
/*!
|
||||
* Implements the unified property interface -- import function.
|
||||
* This method forwards to ID3v2::Tag::setProperties().
|
||||
*/
|
||||
PropertyMap setProperties(const PropertyMap &);
|
||||
ID3v2::Tag *tag() const override;
|
||||
|
||||
/*!
|
||||
* Returns the AIFF::AudioProperties for this file.
|
||||
* If no audio properties were read then this will return a null pointer.
|
||||
*/
|
||||
virtual AudioProperties *audioProperties() const;
|
||||
AudioProperties *audioProperties() const override;
|
||||
|
||||
/*!
|
||||
* Saves the file.
|
||||
*/
|
||||
virtual bool save();
|
||||
bool save() override;
|
||||
|
||||
/*!
|
||||
* Save using a specific ID3v2 version (e.g. v3)
|
||||
@@ -136,7 +122,7 @@ class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::RIFF::File {
|
||||
static bool isSupported(IOStream *stream);
|
||||
|
||||
private:
|
||||
explicit File(const File &);
|
||||
File(const File &);
|
||||
File &operator=(const File &);
|
||||
|
||||
void read(bool readProperties);
|
||||
|
||||
12
3rdparty/taglib/riff/aiff/aiffproperties.cpp
vendored
12
3rdparty/taglib/riff/aiff/aiffproperties.cpp
vendored
@@ -23,8 +23,8 @@
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include <tstring.h>
|
||||
#include <tdebug.h>
|
||||
#include "tstring.h"
|
||||
#include "tdebug.h"
|
||||
#include "aifffile.h"
|
||||
#include "aiffproperties.h"
|
||||
|
||||
@@ -55,7 +55,7 @@ class RIFF::AIFF::AudioProperties::AudioPropertiesPrivate {
|
||||
// public members
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
RIFF::AIFF::AudioProperties::AudioProperties(File *file, ReadStyle style) : Strawberry_TagLib::TagLib::AudioProperties(style), d(new AudioPropertiesPrivate()) {
|
||||
RIFF::AIFF::AudioProperties::AudioProperties(File *file, ReadStyle) : Strawberry_TagLib::TagLib::AudioProperties(), d(new AudioPropertiesPrivate()) {
|
||||
read(file);
|
||||
}
|
||||
|
||||
@@ -137,9 +137,9 @@ void RIFF::AIFF::AudioProperties::read(File *file) {
|
||||
return;
|
||||
}
|
||||
|
||||
d->channels = data.toShort(0U);
|
||||
d->sampleFrames = data.toUInt(2U);
|
||||
d->bitsPerSample = data.toShort(6U);
|
||||
d->channels = data.toUInt16BE(0);
|
||||
d->sampleFrames = data.toUInt32BE(2);
|
||||
d->bitsPerSample = data.toUInt16BE(6);
|
||||
|
||||
const long double sampleRate = data.toFloat80BE(8);
|
||||
if (sampleRate >= 1.0)
|
||||
|
||||
15
3rdparty/taglib/riff/aiff/aiffproperties.h
vendored
15
3rdparty/taglib/riff/aiff/aiffproperties.h
vendored
@@ -52,36 +52,36 @@ class TAGLIB_EXPORT AudioProperties : public Strawberry_TagLib::TagLib::AudioPro
|
||||
/*!
|
||||
* Destroys this AIFF::AudioProperties instance.
|
||||
*/
|
||||
virtual ~AudioProperties();
|
||||
~AudioProperties() override;
|
||||
|
||||
/*!
|
||||
* Returns the length of the file in seconds. The length is rounded down to the nearest whole second.
|
||||
*
|
||||
* \see lengthInMilliseconds()
|
||||
*/
|
||||
virtual int lengthInSeconds() const;
|
||||
int lengthInSeconds() const override;
|
||||
|
||||
/*!
|
||||
* Returns the length of the file in milliseconds.
|
||||
*
|
||||
* \see lengthInSeconds()
|
||||
*/
|
||||
virtual int lengthInMilliseconds() const;
|
||||
int lengthInMilliseconds() const override;
|
||||
|
||||
/*!
|
||||
* Returns the average bit rate of the file in kb/s.
|
||||
*/
|
||||
virtual int bitrate() const;
|
||||
int bitrate() const override;
|
||||
|
||||
/*!
|
||||
* Returns the sample rate in Hz.
|
||||
*/
|
||||
virtual int sampleRate() const;
|
||||
int sampleRate() const override;
|
||||
|
||||
/*!
|
||||
* Returns the number of audio channels.
|
||||
*/
|
||||
virtual int channels() const;
|
||||
int channels() const override;
|
||||
|
||||
/*!
|
||||
* Returns the number of bits per audio sample.
|
||||
@@ -117,9 +117,6 @@ class TAGLIB_EXPORT AudioProperties : public Strawberry_TagLib::TagLib::AudioPro
|
||||
String compressionName() const;
|
||||
|
||||
private:
|
||||
explicit AudioProperties(const AudioProperties&);
|
||||
AudioProperties &operator=(const AudioProperties&);
|
||||
|
||||
void read(File *file);
|
||||
|
||||
class AudioPropertiesPrivate;
|
||||
|
||||
62
3rdparty/taglib/riff/rifffile.cpp
vendored
62
3rdparty/taglib/riff/rifffile.cpp
vendored
@@ -26,30 +26,46 @@
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
|
||||
#include <tbytevector.h>
|
||||
#include <tdebug.h>
|
||||
#include <tstring.h>
|
||||
#include "tbytevector.h"
|
||||
#include "tdebug.h"
|
||||
#include "tstring.h"
|
||||
|
||||
#include "rifffile.h"
|
||||
#include "riffutils.h"
|
||||
|
||||
using namespace Strawberry_TagLib::TagLib;
|
||||
|
||||
namespace {
|
||||
struct Chunk {
|
||||
ByteVector name;
|
||||
unsigned int offset;
|
||||
long long offset;
|
||||
unsigned int size;
|
||||
unsigned int padding;
|
||||
};
|
||||
|
||||
unsigned int toUInt32(const ByteVector &v, size_t offset, ByteOrder endian) {
|
||||
if (endian == BigEndian)
|
||||
return v.toUInt32BE(offset);
|
||||
else
|
||||
return v.toUInt32LE(offset);
|
||||
}
|
||||
|
||||
ByteVector fromUInt32(size_t value, ByteOrder endian) {
|
||||
if (endian == BigEndian)
|
||||
return ByteVector::fromUInt32BE(value);
|
||||
else
|
||||
return ByteVector::fromUInt32LE(value);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
class RIFF::File::FilePrivate {
|
||||
public:
|
||||
explicit FilePrivate(Endianness _endianness) : endianness(_endianness), size(0), sizeOffset(0) {}
|
||||
explicit FilePrivate(ByteOrder _endianness) : endianness(_endianness), size(0), sizeOffset(0) {}
|
||||
|
||||
const Endianness endianness;
|
||||
const ByteOrder endianness;
|
||||
|
||||
unsigned int size;
|
||||
long sizeOffset;
|
||||
long long sizeOffset;
|
||||
|
||||
std::vector<Chunk> chunks;
|
||||
};
|
||||
@@ -66,12 +82,12 @@ RIFF::File::~File() {
|
||||
// protected members
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
RIFF::File::File(FileName file, Endianness endianness) : Strawberry_TagLib::TagLib::File(file), d(new FilePrivate(endianness)) {
|
||||
RIFF::File::File(FileName file, ByteOrder endianness) : Strawberry_TagLib::TagLib::File(file), d(new FilePrivate(endianness)) {
|
||||
if (isOpen())
|
||||
read();
|
||||
}
|
||||
|
||||
RIFF::File::File(IOStream *stream, Endianness endianness) : Strawberry_TagLib::TagLib::File(stream), d(new FilePrivate(endianness)) {
|
||||
RIFF::File::File(IOStream *stream, ByteOrder endianness) : Strawberry_TagLib::TagLib::File(stream), d(new FilePrivate(endianness)) {
|
||||
if (isOpen())
|
||||
read();
|
||||
}
|
||||
@@ -80,8 +96,8 @@ unsigned int RIFF::File::riffSize() const {
|
||||
return d->size;
|
||||
}
|
||||
|
||||
unsigned int RIFF::File::chunkCount() const {
|
||||
return static_cast<unsigned int>(d->chunks.size());
|
||||
size_t RIFF::File::chunkCount() const {
|
||||
return d->chunks.size();
|
||||
}
|
||||
|
||||
unsigned int RIFF::File::chunkDataSize(unsigned int i) const {
|
||||
@@ -95,7 +111,7 @@ unsigned int RIFF::File::chunkDataSize(unsigned int i) const {
|
||||
|
||||
}
|
||||
|
||||
unsigned int RIFF::File::chunkOffset(unsigned int i) const {
|
||||
long long RIFF::File::chunkOffset(unsigned int i) const {
|
||||
|
||||
if (i >= d->chunks.size()) {
|
||||
debug("RIFF::File::chunkOffset() - Index out of range. Returning 0.");
|
||||
@@ -164,7 +180,7 @@ void RIFF::File::setChunkData(unsigned int i, const ByteVector &data) {
|
||||
// Now update the internal offsets
|
||||
|
||||
for (++it; it != d->chunks.end(); ++it)
|
||||
it->offset += static_cast<int>(diff);
|
||||
it->offset += diff;
|
||||
|
||||
// Update the global size.
|
||||
|
||||
@@ -203,7 +219,7 @@ void RIFF::File::setChunkData(const ByteVector &name, const ByteVector &data, bo
|
||||
|
||||
Chunk &last = d->chunks.back();
|
||||
|
||||
long offset = last.offset + last.size + last.padding;
|
||||
long long offset = last.offset + last.size + last.padding;
|
||||
if (offset & 1) {
|
||||
if (last.padding == 1) {
|
||||
last.padding = 0; // This should not happen unless the file is corrupted.
|
||||
@@ -247,7 +263,7 @@ void RIFF::File::removeChunk(unsigned int i) {
|
||||
std::vector<Chunk>::iterator it = d->chunks.begin();
|
||||
std::advance(it, i);
|
||||
|
||||
const unsigned int removeSize = it->size + it->padding + 8;
|
||||
const size_t removeSize = it->size + it->padding + 8;
|
||||
removeBlock(it->offset - 8, removeSize);
|
||||
it = d->chunks.erase(it);
|
||||
|
||||
@@ -275,15 +291,13 @@ void RIFF::File::removeChunk(const ByteVector &name) {
|
||||
|
||||
void RIFF::File::read() {
|
||||
|
||||
const bool bigEndian = (d->endianness == BigEndian);
|
||||
|
||||
long offset = tell();
|
||||
long long offset = tell();
|
||||
|
||||
offset += 4;
|
||||
d->sizeOffset = offset;
|
||||
|
||||
seek(offset);
|
||||
d->size = readBlock(4).toUInt(bigEndian);
|
||||
d->size = toUInt32(readBlock(4), 0, d->endianness);
|
||||
|
||||
offset += 8;
|
||||
|
||||
@@ -292,7 +306,7 @@ void RIFF::File::read() {
|
||||
|
||||
seek(offset);
|
||||
const ByteVector chunkName = readBlock(4);
|
||||
const unsigned int chunkSize = readBlock(4).toUInt(bigEndian);
|
||||
const unsigned int chunkSize = toUInt32(readBlock(4), 0, d->endianness);
|
||||
|
||||
if (!isValidChunkName(chunkName)) {
|
||||
debug("RIFF::File::read() -- Chunk '" + chunkName + "' has invalid ID");
|
||||
@@ -300,7 +314,7 @@ void RIFF::File::read() {
|
||||
break;
|
||||
}
|
||||
|
||||
if (static_cast<long long>(offset) + 8 + chunkSize > length()) {
|
||||
if (offset + 8 + chunkSize > length()) {
|
||||
debug("RIFF::File::read() -- Chunk '" + chunkName + "' has invalid size (larger than the file size)");
|
||||
setValid(false);
|
||||
break;
|
||||
@@ -341,12 +355,12 @@ void RIFF::File::read() {
|
||||
|
||||
}
|
||||
|
||||
void RIFF::File::writeChunk(const ByteVector &name, const ByteVector &data, unsigned long offset, unsigned long replace) {
|
||||
void RIFF::File::writeChunk(const ByteVector &name, const ByteVector &data, long long offset, size_t replace) {
|
||||
|
||||
ByteVector combined;
|
||||
|
||||
combined.append(name);
|
||||
combined.append(ByteVector::fromUInt(data.size(), d->endianness == BigEndian));
|
||||
combined.append(fromUInt32(data.size(), d->endianness));
|
||||
combined.append(data);
|
||||
|
||||
if (data.size() & 1)
|
||||
@@ -362,7 +376,7 @@ void RIFF::File::updateGlobalSize() {
|
||||
const Chunk last = d->chunks.back();
|
||||
d->size = last.offset + last.size + last.padding - first.offset + 12;
|
||||
|
||||
const ByteVector data = ByteVector::fromUInt(d->size, d->endianness == BigEndian);
|
||||
const ByteVector data = fromUInt32(d->size, d->endianness);
|
||||
insert(data, d->sizeOffset, 4);
|
||||
|
||||
}
|
||||
|
||||
19
3rdparty/taglib/riff/rifffile.h
vendored
19
3rdparty/taglib/riff/rifffile.h
vendored
@@ -49,16 +49,11 @@ class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::File {
|
||||
/*!
|
||||
* Destroys this instance of the File.
|
||||
*/
|
||||
virtual ~File();
|
||||
~File() override;
|
||||
|
||||
protected:
|
||||
enum Endianness {
|
||||
BigEndian,
|
||||
LittleEndian
|
||||
};
|
||||
|
||||
explicit File(FileName file, Endianness endianness);
|
||||
explicit File(IOStream *stream, Endianness endianness);
|
||||
explicit File(FileName file, ByteOrder endianness);
|
||||
explicit File(IOStream *stream, ByteOrder endianness);
|
||||
|
||||
/*!
|
||||
* \return The size of the main RIFF chunk.
|
||||
@@ -68,12 +63,12 @@ class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::File {
|
||||
/*!
|
||||
* \return The number of chunks in the file.
|
||||
*/
|
||||
unsigned int chunkCount() const;
|
||||
size_t chunkCount() const;
|
||||
|
||||
/*!
|
||||
* \return The offset within the file for the selected chunk number.
|
||||
*/
|
||||
unsigned int chunkOffset(unsigned int i) const;
|
||||
long long chunkOffset(unsigned int i) const;
|
||||
|
||||
/*!
|
||||
* \return The size of the chunk data.
|
||||
@@ -140,11 +135,11 @@ class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::File {
|
||||
void removeChunk(const ByteVector &name);
|
||||
|
||||
private:
|
||||
explicit File(const File&);
|
||||
File(const File&);
|
||||
File &operator=(const File&);
|
||||
|
||||
void read();
|
||||
void writeChunk(const ByteVector &name, const ByteVector &data, unsigned long offset, unsigned long replace = 0);
|
||||
void writeChunk(const ByteVector &name, const ByteVector &data, long long offset, size_t replace = 0);
|
||||
|
||||
/*!
|
||||
* Update the global RIFF size based on the current internal structure.
|
||||
|
||||
80
3rdparty/taglib/riff/wav/infotag.cpp
vendored
80
3rdparty/taglib/riff/wav/infotag.cpp
vendored
@@ -23,9 +23,11 @@
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include <tdebug.h>
|
||||
#include <tfile.h>
|
||||
#include "tdebug.h"
|
||||
#include "tfile.h"
|
||||
#include "tpicturemap.h"
|
||||
|
||||
#include "rifffile.h"
|
||||
#include "infotag.h"
|
||||
#include "riffutils.h"
|
||||
|
||||
@@ -33,31 +35,28 @@ using namespace Strawberry_TagLib::TagLib;
|
||||
using namespace RIFF::Info;
|
||||
|
||||
namespace {
|
||||
const RIFF::Info::StringHandler defaultStringHandler;
|
||||
const RIFF::Info::StringHandler *stringHandler = &defaultStringHandler;
|
||||
class DefaultStringHandler : public Strawberry_TagLib::TagLib::StringHandler {
|
||||
public:
|
||||
explicit DefaultStringHandler() : Strawberry_TagLib::TagLib::StringHandler() {}
|
||||
|
||||
String parse(const ByteVector &data) const override {
|
||||
return String(data, String::UTF8);
|
||||
}
|
||||
|
||||
ByteVector render(const String &s) const override {
|
||||
return s.data(String::UTF8);
|
||||
}
|
||||
};
|
||||
|
||||
const DefaultStringHandler defaultStringHandler;
|
||||
const Strawberry_TagLib::TagLib::StringHandler *stringHandler = &defaultStringHandler;
|
||||
} // namespace
|
||||
|
||||
class RIFF::Info::Tag::TagPrivate {
|
||||
public:
|
||||
FieldListMap fieldListMap;
|
||||
FieldMap fieldMap;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// StringHandler implementation
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
StringHandler::StringHandler() {}
|
||||
|
||||
StringHandler::~StringHandler() {}
|
||||
|
||||
String RIFF::Info::StringHandler::parse(const ByteVector &data) const {
|
||||
return String(data, String::UTF8);
|
||||
}
|
||||
|
||||
ByteVector RIFF::Info::StringHandler::render(const String &s) const {
|
||||
return s.data(String::UTF8);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// public members
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -100,6 +99,10 @@ unsigned int RIFF::Info::Tag::track() const {
|
||||
return fieldText("IPRT").toInt();
|
||||
}
|
||||
|
||||
Strawberry_TagLib::TagLib::PictureMap RIFF::Info::Tag::pictures() const {
|
||||
return PictureMap();
|
||||
}
|
||||
|
||||
void RIFF::Info::Tag::setTitle(const String &s) {
|
||||
setFieldText("INAM", s);
|
||||
}
|
||||
@@ -124,28 +127,30 @@ void RIFF::Info::Tag::setYear(unsigned int i) {
|
||||
if (i != 0)
|
||||
setFieldText("ICRD", String::number(i));
|
||||
else
|
||||
d->fieldListMap.erase("ICRD");
|
||||
d->fieldMap.erase("ICRD");
|
||||
}
|
||||
|
||||
void RIFF::Info::Tag::setTrack(unsigned int i) {
|
||||
if (i != 0)
|
||||
setFieldText("IPRT", String::number(i));
|
||||
else
|
||||
d->fieldListMap.erase("IPRT");
|
||||
d->fieldMap.erase("IPRT");
|
||||
}
|
||||
|
||||
void RIFF::Info::Tag::setPictures(const PictureMap&) {}
|
||||
|
||||
bool RIFF::Info::Tag::isEmpty() const {
|
||||
return d->fieldListMap.isEmpty();
|
||||
return d->fieldMap.isEmpty();
|
||||
}
|
||||
|
||||
FieldListMap RIFF::Info::Tag::fieldListMap() const {
|
||||
return d->fieldListMap;
|
||||
FieldMap RIFF::Info::Tag::fieldMap() const {
|
||||
return d->fieldMap;
|
||||
}
|
||||
|
||||
String RIFF::Info::Tag::fieldText(const ByteVector &id) const {
|
||||
|
||||
if (d->fieldListMap.contains(id))
|
||||
return String(d->fieldListMap[id]);
|
||||
if (d->fieldMap.contains(id))
|
||||
return String(d->fieldMap[id]);
|
||||
else
|
||||
return String();
|
||||
|
||||
@@ -158,7 +163,7 @@ void RIFF::Info::Tag::setFieldText(const ByteVector &id, const String &s) {
|
||||
return;
|
||||
|
||||
if (!s.isEmpty())
|
||||
d->fieldListMap[id] = s;
|
||||
d->fieldMap[id] = s;
|
||||
else
|
||||
removeField(id);
|
||||
|
||||
@@ -166,8 +171,8 @@ void RIFF::Info::Tag::setFieldText(const ByteVector &id, const String &s) {
|
||||
|
||||
void RIFF::Info::Tag::removeField(const ByteVector &id) {
|
||||
|
||||
if (d->fieldListMap.contains(id))
|
||||
d->fieldListMap.erase(id);
|
||||
if (d->fieldMap.contains(id))
|
||||
d->fieldMap.erase(id);
|
||||
|
||||
}
|
||||
|
||||
@@ -175,14 +180,13 @@ ByteVector RIFF::Info::Tag::render() const {
|
||||
|
||||
ByteVector data("INFO");
|
||||
|
||||
FieldListMap::ConstIterator it = d->fieldListMap.begin();
|
||||
for (; it != d->fieldListMap.end(); ++it) {
|
||||
for (FieldMap::ConstIterator it = d->fieldMap.begin(); it != d->fieldMap.end(); ++it) {
|
||||
ByteVector text = stringHandler->render(it->second);
|
||||
if (text.isEmpty())
|
||||
continue;
|
||||
|
||||
data.append(it->first);
|
||||
data.append(ByteVector::fromUInt(text.size() + 1, false));
|
||||
data.append(ByteVector::fromUInt32LE(text.size() + 1));
|
||||
data.append(text);
|
||||
|
||||
do {
|
||||
@@ -197,7 +201,7 @@ ByteVector RIFF::Info::Tag::render() const {
|
||||
|
||||
}
|
||||
|
||||
void RIFF::Info::Tag::setStringHandler(const StringHandler *handler) {
|
||||
void RIFF::Info::Tag::setStringHandler(const Strawberry_TagLib::TagLib::StringHandler *handler) {
|
||||
|
||||
if (handler)
|
||||
stringHandler = handler;
|
||||
@@ -212,16 +216,16 @@ void RIFF::Info::Tag::setStringHandler(const StringHandler *handler) {
|
||||
|
||||
void RIFF::Info::Tag::parse(const ByteVector &data) {
|
||||
|
||||
unsigned int p = 4;
|
||||
size_t p = 4;
|
||||
while (p < data.size()) {
|
||||
const unsigned int size = data.toUInt(p + 4, false);
|
||||
const unsigned int size = data.toUInt32LE(p + 4);
|
||||
if (size > data.size() - p - 8)
|
||||
break;
|
||||
|
||||
const ByteVector id = data.mid(p, 4);
|
||||
if (isValidChunkName(id)) {
|
||||
const String text = stringHandler->parse(data.mid(p + 8, size));
|
||||
d->fieldListMap[id] = text;
|
||||
d->fieldMap[id] = text;
|
||||
}
|
||||
|
||||
p += ((size + 1) & ~1) + 8;
|
||||
|
||||
76
3rdparty/taglib/riff/wav/infotag.h
vendored
76
3rdparty/taglib/riff/wav/infotag.h
vendored
@@ -30,6 +30,7 @@
|
||||
#include "tmap.h"
|
||||
#include "tstring.h"
|
||||
#include "tstringlist.h"
|
||||
#include "tstringhandler.h"
|
||||
#include "tbytevector.h"
|
||||
#include "taglib_export.h"
|
||||
|
||||
@@ -42,39 +43,9 @@ class File;
|
||||
namespace RIFF {
|
||||
namespace Info {
|
||||
|
||||
typedef Map<ByteVector, String> FieldListMap;
|
||||
typedef Map<ByteVector, String> FieldMap;
|
||||
|
||||
//! A abstraction for the string to data encoding in Info tags.
|
||||
|
||||
/*!
|
||||
* RIFF INFO tag has no clear definitions about character encodings.
|
||||
* In practice, local encoding of each system is largely used and UTF-8 is popular too.
|
||||
*
|
||||
* Here is an option to read and write tags in your preferred encoding by subclassing this class,
|
||||
* reimplementing parse() and render() and setting your reimplementation as the default with Info::Tag::setStringHandler().
|
||||
*
|
||||
* \see ID3v1::Tag::setStringHandler()
|
||||
*/
|
||||
|
||||
class TAGLIB_EXPORT StringHandler {
|
||||
public:
|
||||
explicit StringHandler();
|
||||
~StringHandler();
|
||||
|
||||
/*!
|
||||
* Decode a string from \a data.
|
||||
* The default implementation assumes that \a data is an UTF-8 character array.
|
||||
*/
|
||||
virtual String parse(const ByteVector &data) const;
|
||||
|
||||
/*!
|
||||
* Encode a ByteVector with the data from \a s.
|
||||
* The default implementation assumes that \a s is an UTF-8 string.
|
||||
*/
|
||||
virtual ByteVector render(const String &s) const;
|
||||
};
|
||||
|
||||
//! The main class in the ID3v2 implementation
|
||||
//! The main class in the RIFF INFO tag implementation
|
||||
|
||||
/*!
|
||||
* This is the main class in the INFO tag implementation.
|
||||
@@ -96,27 +67,29 @@ class TAGLIB_EXPORT Tag : public Strawberry_TagLib::TagLib::Tag {
|
||||
*/
|
||||
explicit Tag(const ByteVector &data);
|
||||
|
||||
virtual ~Tag();
|
||||
~Tag() override;
|
||||
|
||||
// Reimplementations
|
||||
|
||||
virtual String title() const;
|
||||
virtual String artist() const;
|
||||
virtual String album() const;
|
||||
virtual String comment() const;
|
||||
virtual String genre() const;
|
||||
virtual unsigned int year() const;
|
||||
virtual unsigned int track() const;
|
||||
String title() const override;
|
||||
String artist() const override;
|
||||
String album() const override;
|
||||
String comment() const override;
|
||||
String genre() const override;
|
||||
unsigned int year() const override;
|
||||
unsigned int track() const override;
|
||||
PictureMap pictures() const override;
|
||||
|
||||
virtual void setTitle(const String &s);
|
||||
virtual void setArtist(const String &s);
|
||||
virtual void setAlbum(const String &s);
|
||||
virtual void setComment(const String &s);
|
||||
virtual void setGenre(const String &s);
|
||||
virtual void setYear(unsigned int i);
|
||||
virtual void setTrack(unsigned int i);
|
||||
void setTitle(const String &s) override;
|
||||
void setArtist(const String &s) override;
|
||||
void setAlbum(const String &s) override;
|
||||
void setComment(const String &s) override;
|
||||
void setGenre(const String &s) override;
|
||||
void setYear(unsigned int i) override;
|
||||
void setTrack(unsigned int i) override;
|
||||
void setPictures(const PictureMap&) override;
|
||||
|
||||
virtual bool isEmpty() const;
|
||||
bool isEmpty() const override;
|
||||
|
||||
/*!
|
||||
* Returns a copy of the internal fields of the tag.
|
||||
@@ -128,7 +101,7 @@ class TAGLIB_EXPORT Tag : public Strawberry_TagLib::TagLib::Tag {
|
||||
* \see setFieldText()
|
||||
* \see removeField()
|
||||
*/
|
||||
FieldListMap fieldListMap() const;
|
||||
FieldMap fieldMap() const;
|
||||
|
||||
/*
|
||||
* Gets the value of the field with the ID \a id.
|
||||
@@ -164,9 +137,8 @@ class TAGLIB_EXPORT Tag : public Strawberry_TagLib::TagLib::Tag {
|
||||
*
|
||||
* \note The caller is responsible for deleting the previous handler as needed after it is released.
|
||||
*
|
||||
* \see StringHandler
|
||||
*/
|
||||
static void setStringHandler(const StringHandler *handler);
|
||||
static void setStringHandler(const Strawberry_TagLib::TagLib::StringHandler *handler);
|
||||
|
||||
protected:
|
||||
/*!
|
||||
@@ -175,7 +147,7 @@ class TAGLIB_EXPORT Tag : public Strawberry_TagLib::TagLib::Tag {
|
||||
void parse(const ByteVector &data);
|
||||
|
||||
private:
|
||||
explicit Tag(const Tag&);
|
||||
Tag(const Tag&);
|
||||
Tag &operator=(const Tag&);
|
||||
|
||||
class TagPrivate;
|
||||
|
||||
38
3rdparty/taglib/riff/wav/wavfile.cpp
vendored
38
3rdparty/taglib/riff/wav/wavfile.cpp
vendored
@@ -23,11 +23,13 @@
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include <tbytevector.h>
|
||||
#include <tdebug.h>
|
||||
#include <tstringlist.h>
|
||||
#include <tpropertymap.h>
|
||||
#include <tagutils.h>
|
||||
#include <memory>
|
||||
|
||||
#include "tbytevector.h"
|
||||
#include "tdebug.h"
|
||||
#include "tstringlist.h"
|
||||
#include "tpropertymap.h"
|
||||
#include "tagutils.h"
|
||||
|
||||
#include "wavfile.h"
|
||||
#include "id3v2tag.h"
|
||||
@@ -45,14 +47,10 @@ enum {
|
||||
|
||||
class RIFF::WAV::File::FilePrivate {
|
||||
public:
|
||||
FilePrivate() : properties(nullptr), hasID3v2(false), hasInfo(false) {}
|
||||
explicit FilePrivate() : hasID3v2(false), hasInfo(false) {}
|
||||
|
||||
~FilePrivate() {
|
||||
delete properties;
|
||||
}
|
||||
|
||||
AudioProperties *properties;
|
||||
TagUnion tag;
|
||||
std::unique_ptr<AudioProperties> properties;
|
||||
DoubleTagUnion tag;
|
||||
|
||||
bool hasID3v2;
|
||||
bool hasInfo;
|
||||
@@ -93,8 +91,8 @@ RIFF::WAV::File::~File() {
|
||||
delete d;
|
||||
}
|
||||
|
||||
ID3v2::Tag *RIFF::WAV::File::tag() const {
|
||||
return ID3v2Tag();
|
||||
Strawberry_TagLib::TagLib::Tag *RIFF::WAV::File::tag() const {
|
||||
return &d->tag;
|
||||
}
|
||||
|
||||
ID3v2::Tag *RIFF::WAV::File::ID3v2Tag() const {
|
||||
@@ -117,14 +115,6 @@ void RIFF::WAV::File::strip(TagTypes tags) {
|
||||
|
||||
}
|
||||
|
||||
PropertyMap RIFF::WAV::File::properties() const {
|
||||
return d->tag.properties();
|
||||
}
|
||||
|
||||
void RIFF::WAV::File::removeUnsupportedProperties(const StringList &properties) {
|
||||
d->tag.removeUnsupportedProperties(properties);
|
||||
}
|
||||
|
||||
PropertyMap RIFF::WAV::File::setProperties(const PropertyMap &properties) {
|
||||
|
||||
InfoTag()->setProperties(properties);
|
||||
@@ -133,7 +123,7 @@ PropertyMap RIFF::WAV::File::setProperties(const PropertyMap &properties) {
|
||||
}
|
||||
|
||||
RIFF::WAV::AudioProperties *RIFF::WAV::File::audioProperties() const {
|
||||
return d->properties;
|
||||
return d->properties.get();
|
||||
}
|
||||
|
||||
bool RIFF::WAV::File::save() {
|
||||
@@ -223,7 +213,7 @@ void RIFF::WAV::File::read(bool readProperties) {
|
||||
d->tag.set(InfoIndex, new RIFF::Info::Tag());
|
||||
|
||||
if (readProperties)
|
||||
d->properties = new AudioProperties(this, AudioProperties::Average);
|
||||
d->properties.reset(new AudioProperties(this, AudioProperties::Average));
|
||||
}
|
||||
|
||||
void RIFF::WAV::File::removeTagChunks(TagTypes tags) {
|
||||
|
||||
20
3rdparty/taglib/riff/wav/wavfile.h
vendored
20
3rdparty/taglib/riff/wav/wavfile.h
vendored
@@ -90,14 +90,14 @@ class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::RIFF::File {
|
||||
/*!
|
||||
* Destroys this instance of the File.
|
||||
*/
|
||||
virtual ~File();
|
||||
~File() override;
|
||||
|
||||
/*!
|
||||
* Returns the ID3v2 Tag for this file.
|
||||
*
|
||||
* \note This method does not return all the tags for this file for backward compatibility. Will be fixed in TagLib 2.0.
|
||||
*/
|
||||
ID3v2::Tag *tag() const;
|
||||
Strawberry_TagLib::TagLib::Tag *tag() const override;
|
||||
|
||||
/*!
|
||||
* Returns the ID3v2 Tag for this file.
|
||||
@@ -127,30 +127,22 @@ class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::RIFF::File {
|
||||
*/
|
||||
void strip(TagTypes tags = AllTags);
|
||||
|
||||
/*!
|
||||
* Implements the unified property interface -- export function.
|
||||
* This method forwards to ID3v2::Tag::properties().
|
||||
*/
|
||||
PropertyMap properties() const;
|
||||
|
||||
void removeUnsupportedProperties(const StringList &properties);
|
||||
|
||||
/*!
|
||||
* Implements the unified property interface -- import function.
|
||||
* This method forwards to ID3v2::Tag::setProperties().
|
||||
*/
|
||||
PropertyMap setProperties(const PropertyMap &);
|
||||
PropertyMap setProperties(const PropertyMap &) override;
|
||||
|
||||
/*!
|
||||
* Returns the WAV::AudioProperties for this file. If no audio properties
|
||||
* were read then this will return a null pointer.
|
||||
*/
|
||||
virtual AudioProperties *audioProperties() const;
|
||||
AudioProperties *audioProperties() const override;
|
||||
|
||||
/*!
|
||||
* Saves the file.
|
||||
*/
|
||||
virtual bool save();
|
||||
bool save() override;
|
||||
|
||||
/*!
|
||||
* Save the file.
|
||||
@@ -181,7 +173,7 @@ class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::RIFF::File {
|
||||
static bool isSupported(IOStream *stream);
|
||||
|
||||
private:
|
||||
explicit File(const File&);
|
||||
File(const File&);
|
||||
File &operator=(const File&);
|
||||
|
||||
void read(bool readProperties);
|
||||
|
||||
30
3rdparty/taglib/riff/wav/wavproperties.cpp
vendored
30
3rdparty/taglib/riff/wav/wavproperties.cpp
vendored
@@ -23,7 +23,7 @@
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include <tdebug.h>
|
||||
#include "tdebug.h"
|
||||
#include "wavfile.h"
|
||||
#include "wavproperties.h"
|
||||
|
||||
@@ -39,13 +39,13 @@ enum WaveFormat {
|
||||
|
||||
class RIFF::WAV::AudioProperties::AudioPropertiesPrivate {
|
||||
public:
|
||||
AudioPropertiesPrivate() : format(0),
|
||||
length(0),
|
||||
bitrate(0),
|
||||
sampleRate(0),
|
||||
channels(0),
|
||||
bitsPerSample(0),
|
||||
sampleFrames(0) {}
|
||||
explicit AudioPropertiesPrivate() : format(0),
|
||||
length(0),
|
||||
bitrate(0),
|
||||
sampleRate(0),
|
||||
channels(0),
|
||||
bitsPerSample(0),
|
||||
sampleFrames(0) {}
|
||||
|
||||
int format;
|
||||
int length;
|
||||
@@ -60,7 +60,7 @@ class RIFF::WAV::AudioProperties::AudioPropertiesPrivate {
|
||||
// public members
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Strawberry_TagLib::TagLib::RIFF::WAV::AudioProperties::AudioProperties(File *file, ReadStyle style) : Strawberry_TagLib::TagLib::AudioProperties(style),d(new AudioPropertiesPrivate()) {
|
||||
Strawberry_TagLib::TagLib::RIFF::WAV::AudioProperties::AudioProperties(File *file, ReadStyle) : Strawberry_TagLib::TagLib::AudioProperties(), d(new AudioPropertiesPrivate()) {
|
||||
read(file);
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ void RIFF::WAV::AudioProperties::read(File *file) {
|
||||
}
|
||||
else if (name == "fact") {
|
||||
if (totalSamples == 0)
|
||||
totalSamples = file->chunkData(i).toUInt(0, false);
|
||||
totalSamples = file->chunkData(i).toUInt32LE(0);
|
||||
else
|
||||
debug("RIFF::WAV::AudioProperties::read() - Duplicate 'fact' chunk found.");
|
||||
}
|
||||
@@ -142,15 +142,15 @@ void RIFF::WAV::AudioProperties::read(File *file) {
|
||||
return;
|
||||
}
|
||||
|
||||
d->format = data.toShort(0, false);
|
||||
d->format = data.toUInt16LE(0);
|
||||
if (d->format != FORMAT_PCM && totalSamples == 0) {
|
||||
debug("RIFF::WAV::AudioProperties::read() - Non-PCM format, but 'fact' chunk not found.");
|
||||
return;
|
||||
}
|
||||
|
||||
d->channels = data.toShort(2, false);
|
||||
d->sampleRate = data.toUInt(4, false);
|
||||
d->bitsPerSample = data.toShort(14, false);
|
||||
d->channels = data.toUInt16LE(2);
|
||||
d->sampleRate = data.toUInt32LE(4);
|
||||
d->bitsPerSample = data.toUInt16LE(14);
|
||||
|
||||
if (d->format != FORMAT_PCM)
|
||||
d->sampleFrames = totalSamples;
|
||||
@@ -163,7 +163,7 @@ void RIFF::WAV::AudioProperties::read(File *file) {
|
||||
d->bitrate = static_cast<int>(streamLength * 8.0 / length + 0.5);
|
||||
}
|
||||
else {
|
||||
const unsigned int byteRate = data.toUInt(8, false);
|
||||
const unsigned int byteRate = data.toUInt32LE(8);
|
||||
if (byteRate > 0) {
|
||||
d->length = static_cast<int>(streamLength * 1000.0 / byteRate + 0.5);
|
||||
d->bitrate = static_cast<int>(byteRate * 8.0 / 1000.0 + 0.5);
|
||||
|
||||
17
3rdparty/taglib/riff/wav/wavproperties.h
vendored
17
3rdparty/taglib/riff/wav/wavproperties.h
vendored
@@ -51,12 +51,12 @@ class TAGLIB_EXPORT AudioProperties : public Strawberry_TagLib::TagLib::AudioPro
|
||||
/*!
|
||||
* Create an instance of WAV::AudioProperties with the data read from the WAV::File \a file.
|
||||
*/
|
||||
explicit AudioProperties(File *file, ReadStyle style);
|
||||
explicit AudioProperties(File *file, ReadStyle style = Average);
|
||||
|
||||
/*!
|
||||
* Destroys this WAV::AudioProperties instance.
|
||||
*/
|
||||
virtual ~AudioProperties();
|
||||
~AudioProperties() override;
|
||||
|
||||
/*!
|
||||
* Returns the length of the file in seconds.
|
||||
@@ -64,29 +64,29 @@ class TAGLIB_EXPORT AudioProperties : public Strawberry_TagLib::TagLib::AudioPro
|
||||
*
|
||||
* \see lengthInMilliseconds()
|
||||
*/
|
||||
virtual int lengthInSeconds() const;
|
||||
int lengthInSeconds() const override;
|
||||
|
||||
/*!
|
||||
* Returns the length of the file in milliseconds.
|
||||
*
|
||||
* \see lengthInSeconds()
|
||||
*/
|
||||
virtual int lengthInMilliseconds() const;
|
||||
int lengthInMilliseconds() const override;
|
||||
|
||||
/*!
|
||||
* Returns the average bit rate of the file in kb/s.
|
||||
*/
|
||||
virtual int bitrate() const;
|
||||
int bitrate() const override;
|
||||
|
||||
/*!
|
||||
* Returns the sample rate in Hz.
|
||||
*/
|
||||
virtual int sampleRate() const;
|
||||
int sampleRate() const override;
|
||||
|
||||
/*!
|
||||
* Returns the number of audio channels.
|
||||
*/
|
||||
virtual int channels() const;
|
||||
int channels() const override;
|
||||
|
||||
/*!
|
||||
* Returns the number of bits per audio sample.
|
||||
@@ -107,9 +107,6 @@ class TAGLIB_EXPORT AudioProperties : public Strawberry_TagLib::TagLib::AudioPro
|
||||
int format() const;
|
||||
|
||||
private:
|
||||
explicit AudioProperties(const AudioProperties&);
|
||||
AudioProperties &operator=(const AudioProperties&);
|
||||
|
||||
void read(File *file);
|
||||
|
||||
class AudioPropertiesPrivate;
|
||||
|
||||
Reference in New Issue
Block a user