mirror of
https://github.com/taglib/taglib.git
synced 2026-06-07 23:09:49 -04:00
Compare commits
60 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d8e5077961 | ||
|
|
6422054540 | ||
|
|
1b878102f0 | ||
|
|
0a85f9b227 | ||
|
|
31f3109b47 | ||
|
|
76f8ff388f | ||
|
|
7627ae48ed | ||
|
|
b2a6768704 | ||
|
|
7d270a7e20 | ||
|
|
bf53dc6131 | ||
|
|
ff8b6a91e7 | ||
|
|
1a82419872 | ||
|
|
5a3265d031 | ||
|
|
a27199b772 | ||
|
|
6c27a32de8 | ||
|
|
11abffc0f6 | ||
|
|
2aea23aed2 | ||
|
|
e8ef0e0a4b | ||
|
|
520da50bc5 | ||
|
|
c0a909b709 | ||
|
|
8d09f12847 | ||
|
|
710166e32d | ||
|
|
01054009ac | ||
|
|
7d8aa7b8bd | ||
|
|
98a57744c3 | ||
|
|
8c4b484e67 | ||
|
|
2166d703e0 | ||
|
|
887f3b28e5 | ||
|
|
6a9db50c03 | ||
|
|
07d95e0dc0 | ||
|
|
a9acca5d81 | ||
|
|
dadfe79799 | ||
|
|
552185a8b8 | ||
|
|
46eacaeba4 | ||
|
|
455e827e1e | ||
|
|
c08e0b1357 | ||
|
|
f3016c0892 | ||
|
|
f8f7cb0904 | ||
|
|
d037b8c908 | ||
|
|
c349ba3a31 | ||
|
|
bb006e41d7 | ||
|
|
ab2267f9aa | ||
|
|
73662037eb | ||
|
|
aa339eba87 | ||
|
|
45a3bdb695 | ||
|
|
5a155ef4ce | ||
|
|
184a151d41 | ||
|
|
cc2ccbc20c | ||
|
|
fa46185ca4 | ||
|
|
fffff35ca5 | ||
|
|
31894f47f6 | ||
|
|
c1e3d65b68 | ||
|
|
a8ecbbaef4 | ||
|
|
24575aab23 | ||
|
|
c04b24a2f5 | ||
|
|
013fbbf22c | ||
|
|
5350bc8501 | ||
|
|
92a1a00624 | ||
|
|
8afbf6c92a | ||
|
|
9976155aa9 |
@@ -8,12 +8,12 @@ root = true
|
||||
insert_final_newline = true
|
||||
|
||||
# 2 space indentation
|
||||
[*.{h,cpp,tcc,cmake}]
|
||||
[*.{h,cpp,tcc,cmake,yml}]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
|
||||
# Trim traling whitespaces
|
||||
[*.{h,cpp,tcc,cmake}]
|
||||
[*.{h,cpp,tcc,cmake,yml}]
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
# UTF-8 without BOM
|
||||
|
||||
18
.travis.yml
18
.travis.yml
@@ -1,12 +1,28 @@
|
||||
language: cpp
|
||||
|
||||
sudo: false
|
||||
|
||||
os:
|
||||
- linux
|
||||
- osx
|
||||
|
||||
compiler:
|
||||
- gcc
|
||||
- clang
|
||||
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- libcppunit-dev
|
||||
- libcppunit-dev
|
||||
- zlib1g-dev
|
||||
|
||||
matrix:
|
||||
exclude:
|
||||
- os: osx
|
||||
compiler: gcc
|
||||
|
||||
install:
|
||||
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then brew install cppunit; fi
|
||||
|
||||
script: cmake -DBUILD_TESTS=ON -DBUILD_EXAMPLES=ON -DBUILD_BINDINGS=ON . && make && make check
|
||||
|
||||
|
||||
4
AUTHORS
4
AUTHORS
@@ -2,6 +2,8 @@ Scott Wheeler <wheeler@kde.org>
|
||||
Author, maintainer
|
||||
Lukas Lalinsky <lalinsky@gmail.com>
|
||||
Implementation of multiple new file formats, many bug fixes, maintainer
|
||||
Tsuda Kageyu <tsuda.kageyu@gmail.com>
|
||||
A lot of bug fixes and performance improvements, maintainer.
|
||||
Ismael Orenstein <orenstein@kde.org>
|
||||
Xing header implementation
|
||||
Allan Sandfeld Jensen <kde@carewolf.org>
|
||||
@@ -10,8 +12,6 @@ Teemu Tervo <teemu.tervo@gmx.net>
|
||||
Numerous bug reports and fixes
|
||||
Mathias Panzenböck <grosser.meister.morti@gmx.net>
|
||||
Mod, S3M, IT and XM metadata implementations
|
||||
Tsuda Kageyu <tsuda.kageyu@gmail.com>
|
||||
A lot of fixes and improvements, i.e. memory copy reduction etc.
|
||||
|
||||
Please send all patches and questions to taglib-devel@kde.org rather than to
|
||||
individual developers!
|
||||
|
||||
@@ -34,6 +34,13 @@ if(NOT ${SIZEOF_DOUBLE} EQUAL 8)
|
||||
message(FATAL_ERROR "TagLib requires that double is 64-bit wide.")
|
||||
endif()
|
||||
|
||||
# Enable check_cxx_source_compiles() to work with Boost "header-only" libraries.
|
||||
|
||||
find_package(Boost)
|
||||
if(Boost_FOUND)
|
||||
set(CMAKE_REQUIRED_INCLUDES "${CMAKE_REQUIRED_INCLUDES};${Boost_INCLUDE_DIRS}")
|
||||
endif()
|
||||
|
||||
# Determine which kind of atomic operations your compiler supports.
|
||||
|
||||
check_cxx_source_compiles("
|
||||
@@ -47,15 +54,12 @@ check_cxx_source_compiles("
|
||||
" HAVE_STD_ATOMIC)
|
||||
|
||||
if(NOT HAVE_STD_ATOMIC)
|
||||
check_cxx_source_compiles("
|
||||
#include <boost/atomic.hpp>
|
||||
int main() {
|
||||
boost::atomic<unsigned int> x(1);
|
||||
x.fetch_add(1);
|
||||
x.fetch_sub(1);
|
||||
return 0;
|
||||
}
|
||||
" HAVE_BOOST_ATOMIC)
|
||||
find_package(Boost COMPONENTS atomic)
|
||||
if(Boost_ATOMIC_FOUND)
|
||||
set(HAVE_BOOST_ATOMIC 1)
|
||||
else()
|
||||
set(HAVE_BOOST_ATOMIC 0)
|
||||
endif()
|
||||
|
||||
if(NOT HAVE_BOOST_ATOMIC)
|
||||
check_cxx_source_compiles("
|
||||
@@ -221,6 +225,15 @@ if(NOT ZLIB_SOURCE)
|
||||
else()
|
||||
set(HAVE_ZLIB 0)
|
||||
endif()
|
||||
|
||||
if(NOT HAVE_ZLIB)
|
||||
find_package(Boost COMPONENTS iostreams zlib)
|
||||
if(Boost_IOSTREAMS_FOUND AND Boost_ZLIB_FOUND)
|
||||
set(HAVE_BOOST_ZLIB 1)
|
||||
else()
|
||||
set(HAVE_BOOST_ZLIB 0)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Determine whether CppUnit is installed.
|
||||
|
||||
18
NEWS
18
NEWS
@@ -1,6 +1,20 @@
|
||||
TagLib 1.11 (Jan 30, 2016)
|
||||
TagLib 1.11 (Apr 29, 2016)
|
||||
==========================
|
||||
|
||||
1.11:
|
||||
|
||||
* Fixed reading APE items with long keys.
|
||||
* Fixed reading ID3v2 SYLT frames when description is empty.
|
||||
|
||||
1.11 BETA 2:
|
||||
|
||||
* Better handling of PCM WAV files with a 'fact' chunk.
|
||||
* Better handling of corrupted APE tags.
|
||||
* Efficient decoding of unsynchronized ID3v2 frames.
|
||||
* Fixed text encoding when saving certain frames in ID3v2.3 tags.
|
||||
* Fixed updating the size of RIFF files when removing chunks.
|
||||
* Several smaller bug fixes and performance improvements.
|
||||
|
||||
1.11 BETA:
|
||||
|
||||
* New API for creating FileRef from IOStream.
|
||||
@@ -30,7 +44,7 @@ TagLib 1.11 (Jan 30, 2016)
|
||||
* Fixed updating the comment field of Vorbis comments.
|
||||
* Fixed reading date and time in ID3v2.3 tags.
|
||||
* Marked ByteVector::null and ByteVector::isNull() deprecated.
|
||||
* Marked String::null and ByteVector::isNull() deprecated.
|
||||
* Marked String::null and String::isNull() deprecated.
|
||||
* Marked XiphComment::removeField() deprecated.
|
||||
* Marked Ogg::Page::getCopyWithNewPageSequenceNumber() deprecated. It returns null.
|
||||
* Marked custom integer types deprecated.
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace
|
||||
bool unicodeStrings = true;
|
||||
bool stringManagementEnabled = true;
|
||||
|
||||
inline char *stringToCharArray(const String &s)
|
||||
char *stringToCharArray(const String &s)
|
||||
{
|
||||
const std::string str = s.to8Bit(unicodeStrings);
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace
|
||||
#endif
|
||||
}
|
||||
|
||||
inline String charArrayToString(const char *s)
|
||||
String charArrayToString(const char *s)
|
||||
{
|
||||
return String(s, unicodeStrings ? String::UTF8 : String::Latin1);
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ TAGLIB_C_EXPORT TagLib_File *taglib_file_new_type(const char *filename, TagLib_F
|
||||
TAGLIB_C_EXPORT void taglib_file_free(TagLib_File *file);
|
||||
|
||||
/*!
|
||||
* Returns true if the file is open and readble and valid information for
|
||||
* Returns true if the file is open and readable and valid information for
|
||||
* the Tag and / or AudioProperties was found.
|
||||
*/
|
||||
|
||||
@@ -137,7 +137,7 @@ TAGLIB_C_EXPORT BOOL taglib_file_is_valid(const TagLib_File *file);
|
||||
TAGLIB_C_EXPORT TagLib_Tag *taglib_file_tag(const TagLib_File *file);
|
||||
|
||||
/*!
|
||||
* Returns a pointer to the the audio properties associated with this file. This
|
||||
* Returns a pointer to the audio properties associated with this file. This
|
||||
* will be freed automatically when the file is freed.
|
||||
*/
|
||||
TAGLIB_C_EXPORT const TagLib_AudioProperties *taglib_file_audioproperties(const TagLib_File *file);
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
|
||||
/* Defined if zlib is installed */
|
||||
#cmakedefine HAVE_ZLIB 1
|
||||
#cmakedefine HAVE_BOOST_ZLIB 1
|
||||
|
||||
/* Indicates whether debug messages are shown even in release mode */
|
||||
#cmakedefine TRACE_IN_RELEASE 1
|
||||
|
||||
@@ -32,6 +32,10 @@ elseif(HAVE_ZLIB_SOURCE)
|
||||
include_directories(${ZLIB_SOURCE})
|
||||
endif()
|
||||
|
||||
if(HAVE_BOOST_BYTESWAP OR HAVE_BOOST_ATOMIC OR HAVE_BOOST_ZLIB)
|
||||
include_directories(${Boost_INCLUDE_DIR})
|
||||
endif()
|
||||
|
||||
set(tag_HDRS
|
||||
tag.h
|
||||
fileref.h
|
||||
@@ -305,6 +309,7 @@ set(toolkit_SRCS
|
||||
toolkit/tpropertymap.cpp
|
||||
toolkit/trefcounter.cpp
|
||||
toolkit/tdebuglistener.cpp
|
||||
toolkit/tzlib.cpp
|
||||
)
|
||||
|
||||
if(NOT WIN32)
|
||||
@@ -343,6 +348,14 @@ if(ZLIB_FOUND)
|
||||
target_link_libraries(tag ${ZLIB_LIBRARIES})
|
||||
endif()
|
||||
|
||||
if(HAVE_BOOST_ATOMIC)
|
||||
target_link_libraries(tag ${Boost_ATOMIC_LIBRARY})
|
||||
endif()
|
||||
|
||||
if(HAVE_BOOST_ZLIB)
|
||||
target_link_libraries(tag ${Boost_IOSTREAMS_LIBRARY} ${Boost_ZLIB_LIBRARY})
|
||||
endif()
|
||||
|
||||
set_target_properties(tag PROPERTIES
|
||||
VERSION ${TAGLIB_SOVERSION_MAJOR}.${TAGLIB_SOVERSION_MINOR}.${TAGLIB_SOVERSION_PATCH}
|
||||
SOVERSION ${TAGLIB_SOVERSION_MAJOR}
|
||||
|
||||
@@ -34,7 +34,9 @@ using namespace APE;
|
||||
class APE::Item::ItemPrivate
|
||||
{
|
||||
public:
|
||||
ItemPrivate() : type(Text), readOnly(false) {}
|
||||
ItemPrivate() :
|
||||
type(Text),
|
||||
readOnly(false) {}
|
||||
|
||||
Item::ItemTypes type;
|
||||
String key;
|
||||
@@ -74,8 +76,9 @@ APE::Item::Item(const String &key, const ByteVector &value, bool binary) :
|
||||
d->type = Binary;
|
||||
d->value = value;
|
||||
}
|
||||
else
|
||||
else {
|
||||
d->text.append(value);
|
||||
}
|
||||
}
|
||||
|
||||
APE::Item::Item(const Item &item) :
|
||||
@@ -181,9 +184,8 @@ void APE::Item::appendValues(const StringList &values)
|
||||
|
||||
int APE::Item::size() const
|
||||
{
|
||||
// SFB: Why is d->key.size() used when size() returns the length in UniChars and not UTF-8?
|
||||
int result = 8 + d->key.size() /* d->key.data(String::UTF8).size() */ + 1;
|
||||
switch (d->type) {
|
||||
int result = 8 + d->key.size() + 1;
|
||||
switch(d->type) {
|
||||
case Text:
|
||||
if(!d->text.isEmpty()) {
|
||||
StringList::ConstIterator it = d->text.begin();
|
||||
@@ -250,7 +252,10 @@ void APE::Item::parse(const ByteVector &data)
|
||||
const unsigned int valueLength = data.toUInt(0, false);
|
||||
const unsigned int flags = data.toUInt(4, false);
|
||||
|
||||
d->key = String(data.mid(8), String::UTF8);
|
||||
// An item key can contain ASCII characters from 0x20 up to 0x7E, not UTF-8.
|
||||
// We assume that the validity of the given key has been checked.
|
||||
|
||||
d->key = String(&data[8], String::Latin1);
|
||||
|
||||
const ByteVector value = data.mid(8 + d->key.size() + 1, valueLength);
|
||||
|
||||
@@ -288,7 +293,7 @@ ByteVector APE::Item::render() const
|
||||
|
||||
data.append(ByteVector::fromUInt(value.size(), false));
|
||||
data.append(ByteVector::fromUInt(flags, false));
|
||||
data.append(d->key.data(String::UTF8));
|
||||
data.append(d->key.data(String::Latin1));
|
||||
data.append(ByteVector('\0'));
|
||||
data.append(value);
|
||||
|
||||
|
||||
@@ -133,7 +133,7 @@ unsigned int APE::Properties::sampleFrames() const
|
||||
|
||||
namespace
|
||||
{
|
||||
inline int headerVersion(const ByteVector &header)
|
||||
int headerVersion(const ByteVector &header)
|
||||
{
|
||||
if(header.size() < 6 || !header.startsWith("MAC "))
|
||||
return -1;
|
||||
|
||||
@@ -35,6 +35,8 @@
|
||||
#include <tstring.h>
|
||||
#include <tmap.h>
|
||||
#include <tpropertymap.h>
|
||||
#include <tdebug.h>
|
||||
#include <tutils.h>
|
||||
|
||||
#include "apetag.h"
|
||||
#include "apefooter.h"
|
||||
@@ -43,6 +45,32 @@
|
||||
using namespace TagLib;
|
||||
using namespace APE;
|
||||
|
||||
namespace
|
||||
{
|
||||
bool isKeyValid(const char *key, size_t length)
|
||||
{
|
||||
const char *invalidKeys[] = { "ID3", "TAG", "OGGS", "MP+", 0 };
|
||||
|
||||
if(length < 2 || length > 255)
|
||||
return false;
|
||||
|
||||
// only allow printable ASCII including space (32..126)
|
||||
|
||||
for(const char *p = key; p < key + length; ++p) {
|
||||
const int c = static_cast<unsigned char>(*p);
|
||||
if(c < 32 || c > 126)
|
||||
return false;
|
||||
}
|
||||
|
||||
for(size_t i = 0; invalidKeys[i] != 0; ++i) {
|
||||
if(Utils::equalsIgnoreCase(key, invalidKeys[i]))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
class APE::Tag::TagPrivate
|
||||
{
|
||||
public:
|
||||
@@ -268,16 +296,11 @@ PropertyMap APE::Tag::setProperties(const PropertyMap &origProps)
|
||||
|
||||
bool APE::Tag::checkKey(const String &key)
|
||||
{
|
||||
if(key.size() < 2 || key.size() > 16)
|
||||
return false;
|
||||
for(String::ConstIterator it = key.begin(); it != key.end(); it++)
|
||||
// only allow printable ASCII including space (32..127)
|
||||
if (*it < 32 || *it >= 128)
|
||||
return false;
|
||||
String upperKey = key.upper();
|
||||
if (upperKey=="ID3" || upperKey=="TAG" || upperKey=="OGGS" || upperKey=="MP+")
|
||||
return false;
|
||||
return true;
|
||||
if(!key.isLatin1())
|
||||
return false;
|
||||
|
||||
const std::string data = key.to8Bit(false);
|
||||
return isKeyValid(data.c_str(), data.size());
|
||||
}
|
||||
|
||||
APE::Footer *APE::Tag::footer() const
|
||||
@@ -299,31 +322,39 @@ void APE::Tag::addValue(const String &key, const String &value, bool replace)
|
||||
{
|
||||
if(replace)
|
||||
removeItem(key);
|
||||
if(!key.isEmpty() && !value.isEmpty()) {
|
||||
if(!replace && d->itemListMap.contains(key)) {
|
||||
// Text items may contain more than one value
|
||||
if(APE::Item::Text == d->itemListMap.begin()->second.type())
|
||||
d->itemListMap[key.upper()].appendValue(value);
|
||||
// Binary or locator items may have only one value
|
||||
else
|
||||
setItem(key, Item(key, value));
|
||||
}
|
||||
else
|
||||
setItem(key, Item(key, value));
|
||||
}
|
||||
|
||||
if(value.isEmpty())
|
||||
return;
|
||||
|
||||
// Text items may contain more than one value.
|
||||
// Binary or locator items may have only one value, hence always replaced.
|
||||
|
||||
ItemListMap::Iterator it = d->itemListMap.find(key.upper());
|
||||
|
||||
if(it != d->itemListMap.end() && it->second.type() == Item::Text)
|
||||
it->second.appendValue(value);
|
||||
else
|
||||
setItem(key, Item(key, value));
|
||||
}
|
||||
|
||||
void APE::Tag::setData(const String &key, const ByteVector &value)
|
||||
{
|
||||
removeItem(key);
|
||||
if(!key.isEmpty() && !value.isEmpty())
|
||||
setItem(key, Item(key, value, true));
|
||||
|
||||
if(value.isEmpty())
|
||||
return;
|
||||
|
||||
setItem(key, Item(key, value, true));
|
||||
}
|
||||
|
||||
void APE::Tag::setItem(const String &key, const Item &item)
|
||||
{
|
||||
if(!key.isEmpty())
|
||||
d->itemListMap.insert(key.upper(), item);
|
||||
if(!checkKey(key)) {
|
||||
debug("APE::Tag::setItem() - Couldn't set an item due to an invalid key.");
|
||||
return;
|
||||
}
|
||||
|
||||
d->itemListMap[key.upper()] = item;
|
||||
}
|
||||
|
||||
bool APE::Tag::isEmpty() const
|
||||
@@ -378,11 +409,26 @@ void APE::Tag::parse(const ByteVector &data)
|
||||
unsigned int pos = 0;
|
||||
|
||||
for(unsigned int i = 0; i < d->footer.itemCount() && pos <= data.size() - 11; i++) {
|
||||
APE::Item item;
|
||||
item.parse(data.mid(pos));
|
||||
|
||||
d->itemListMap.insert(item.key().upper(), item);
|
||||
const int nullPos = data.find('\0', pos + 8);
|
||||
if(nullPos < 0) {
|
||||
debug("APE::Tag::parse() - Couldn't find a key/value separator. Stopped parsing.");
|
||||
return;
|
||||
}
|
||||
|
||||
pos += item.size();
|
||||
const unsigned int keyLength = nullPos - pos - 8;
|
||||
const unsigned int valLegnth = data.toUInt(pos, false);
|
||||
|
||||
if(isKeyValid(&data[pos + 8], keyLength)){
|
||||
APE::Item item;
|
||||
item.parse(data.mid(pos));
|
||||
|
||||
d->itemListMap.insert(item.key().upper(), item);
|
||||
}
|
||||
else {
|
||||
debug("APE::Tag::parse() - Skipped an item due to an invalid key.");
|
||||
}
|
||||
|
||||
pos += keyLength + valLegnth + 9;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,65 +34,68 @@ namespace TagLib
|
||||
{
|
||||
namespace ASF
|
||||
{
|
||||
|
||||
inline unsigned short readWORD(File *file, bool *ok = 0)
|
||||
namespace
|
||||
{
|
||||
const ByteVector v = file->readBlock(2);
|
||||
if(v.size() != 2) {
|
||||
if(ok) *ok = false;
|
||||
return 0;
|
||||
}
|
||||
if(ok) *ok = true;
|
||||
return v.toUShort(false);
|
||||
}
|
||||
|
||||
inline unsigned int readDWORD(File *file, bool *ok = 0)
|
||||
{
|
||||
const ByteVector v = file->readBlock(4);
|
||||
if(v.size() != 4) {
|
||||
if(ok) *ok = false;
|
||||
return 0;
|
||||
}
|
||||
if(ok) *ok = true;
|
||||
return v.toUInt(false);
|
||||
}
|
||||
|
||||
inline long long readQWORD(File *file, bool *ok = 0)
|
||||
{
|
||||
const ByteVector v = file->readBlock(8);
|
||||
if(v.size() != 8) {
|
||||
if(ok) *ok = false;
|
||||
return 0;
|
||||
}
|
||||
if(ok) *ok = true;
|
||||
return v.toLongLong(false);
|
||||
}
|
||||
|
||||
inline String readString(File *file, int length)
|
||||
{
|
||||
ByteVector data = file->readBlock(length);
|
||||
unsigned int size = data.size();
|
||||
while (size >= 2) {
|
||||
if(data[size - 1] != '\0' || data[size - 2] != '\0') {
|
||||
break;
|
||||
inline unsigned short readWORD(File *file, bool *ok = 0)
|
||||
{
|
||||
const ByteVector v = file->readBlock(2);
|
||||
if(v.size() != 2) {
|
||||
if(ok) *ok = false;
|
||||
return 0;
|
||||
}
|
||||
size -= 2;
|
||||
if(ok) *ok = true;
|
||||
return v.toUShort(false);
|
||||
}
|
||||
if(size != data.size()) {
|
||||
data.resize(size);
|
||||
}
|
||||
return String(data, String::UTF16LE);
|
||||
}
|
||||
|
||||
inline ByteVector renderString(const String &str, bool includeLength = false)
|
||||
{
|
||||
ByteVector data = str.data(String::UTF16LE) + ByteVector::fromShort(0, false);
|
||||
if(includeLength) {
|
||||
data = ByteVector::fromShort(data.size(), false) + data;
|
||||
inline unsigned int readDWORD(File *file, bool *ok = 0)
|
||||
{
|
||||
const ByteVector v = file->readBlock(4);
|
||||
if(v.size() != 4) {
|
||||
if(ok) *ok = false;
|
||||
return 0;
|
||||
}
|
||||
if(ok) *ok = true;
|
||||
return v.toUInt(false);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
inline long long readQWORD(File *file, bool *ok = 0)
|
||||
{
|
||||
const ByteVector v = file->readBlock(8);
|
||||
if(v.size() != 8) {
|
||||
if(ok) *ok = false;
|
||||
return 0;
|
||||
}
|
||||
if(ok) *ok = true;
|
||||
return v.toLongLong(false);
|
||||
}
|
||||
|
||||
inline String readString(File *file, int length)
|
||||
{
|
||||
ByteVector data = file->readBlock(length);
|
||||
unsigned int size = data.size();
|
||||
while (size >= 2) {
|
||||
if(data[size - 1] != '\0' || data[size - 2] != '\0') {
|
||||
break;
|
||||
}
|
||||
size -= 2;
|
||||
}
|
||||
if(size != data.size()) {
|
||||
data.resize(size);
|
||||
}
|
||||
return String(data, String::UTF16LE);
|
||||
}
|
||||
|
||||
inline ByteVector renderString(const String &str, bool includeLength = false)
|
||||
{
|
||||
ByteVector data = str.data(String::UTF16LE) + ByteVector::fromShort(0, false);
|
||||
if(includeLength) {
|
||||
data = ByteVector::fromShort(data.size(), false) + data;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -62,42 +62,42 @@ namespace
|
||||
// Templatized internal functions. T should be String or IOStream*.
|
||||
|
||||
template <typename T>
|
||||
inline FileName toFileName(T arg)
|
||||
FileName toFileName(T arg)
|
||||
{
|
||||
debug("FileRef::toFileName<T>(): This version should never be called.");
|
||||
return FileName(L"");
|
||||
}
|
||||
|
||||
template <>
|
||||
inline FileName toFileName<IOStream *>(IOStream *arg)
|
||||
FileName toFileName<IOStream *>(IOStream *arg)
|
||||
{
|
||||
return arg->name();
|
||||
}
|
||||
|
||||
template <>
|
||||
inline FileName toFileName<FileName>(FileName arg)
|
||||
FileName toFileName<FileName>(FileName arg)
|
||||
{
|
||||
return arg;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline File *resolveFileType(T arg, bool readProperties,
|
||||
AudioProperties::ReadStyle style)
|
||||
File *resolveFileType(T arg, bool readProperties,
|
||||
AudioProperties::ReadStyle style)
|
||||
{
|
||||
debug("FileRef::resolveFileType<T>(): This version should never be called.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
template <>
|
||||
inline File *resolveFileType<IOStream *>(IOStream *arg, bool readProperties,
|
||||
AudioProperties::ReadStyle style)
|
||||
File *resolveFileType<IOStream *>(IOStream *arg, bool readProperties,
|
||||
AudioProperties::ReadStyle style)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
template <>
|
||||
inline File *resolveFileType<FileName>(FileName arg, bool readProperties,
|
||||
AudioProperties::ReadStyle style)
|
||||
File *resolveFileType<FileName>(FileName arg, bool readProperties,
|
||||
AudioProperties::ReadStyle style)
|
||||
{
|
||||
ResolverList::ConstIterator it = fileTypeResolvers.begin();
|
||||
for(; it != fileTypeResolvers.end(); ++it) {
|
||||
|
||||
@@ -128,13 +128,16 @@ namespace TagLib {
|
||||
audioPropertiesStyle = AudioProperties::Average);
|
||||
|
||||
/*!
|
||||
* Construct a FileRef from an opened \a IOStream. If \a readAudioProperties is true then
|
||||
* the audio properties will be read using \a audioPropertiesStyle. If
|
||||
* \a readAudioProperties is false then \a audioPropertiesStyle will be
|
||||
* Construct a FileRef from an opened \a IOStream. If \a readAudioProperties
|
||||
* is true then the audio properties will be read using \a audioPropertiesStyle.
|
||||
* If \a readAudioProperties is false then \a audioPropertiesStyle will be
|
||||
* ignored.
|
||||
*
|
||||
* Also see the note in the class documentation about why you may not want to
|
||||
* use this method in your application.
|
||||
*
|
||||
* \note TagLib will *not* take ownership of the stream, the caller is
|
||||
* responsible for deleting it after the File object.
|
||||
*/
|
||||
explicit FileRef(IOStream* stream,
|
||||
bool readAudioProperties = true,
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
/***************************************************************************
|
||||
* This library is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* 2.1 as published by the Free Software Foundation. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, but *
|
||||
@@ -15,10 +15,15 @@
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library; if not, write to the Free Software *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, *
|
||||
* MA 02110-1301 USA *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||
* 02110-1301 USA *
|
||||
* *
|
||||
* Alternatively, this file is available under the Mozilla Public *
|
||||
* License Version 1.1. You may obtain a copy of the License at *
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "tstringlist.h"
|
||||
#include "itfile.h"
|
||||
#include "tdebug.h"
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
/***************************************************************************
|
||||
* This library is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* 2.1 as published by the Free Software Foundation. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, but *
|
||||
@@ -15,10 +15,15 @@
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library; if not, write to the Free Software *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, *
|
||||
* MA 02110-1301 USA *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||
* 02110-1301 USA *
|
||||
* *
|
||||
* Alternatively, this file is available under the Mozilla Public *
|
||||
* License Version 1.1. You may obtain a copy of the License at *
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "itproperties.h"
|
||||
|
||||
using namespace TagLib;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
/***************************************************************************
|
||||
* This library is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* 2.1 as published by the Free Software Foundation. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, but *
|
||||
@@ -15,8 +15,12 @@
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library; if not, write to the Free Software *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, *
|
||||
* MA 02110-1301 USA *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||
* 02110-1301 USA *
|
||||
* *
|
||||
* Alternatively, this file is available under the Mozilla Public *
|
||||
* License Version 1.1. You may obtain a copy of the License at *
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef TAGLIB_ITPROPERTIES_H
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
/***************************************************************************
|
||||
* This library is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* 2.1 as published by the Free Software Foundation. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, but *
|
||||
@@ -15,10 +15,15 @@
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library; if not, write to the Free Software *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, *
|
||||
* MA 02110-1301 USA *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||
* 02110-1301 USA *
|
||||
* *
|
||||
* Alternatively, this file is available under the Mozilla Public *
|
||||
* License Version 1.1. You may obtain a copy of the License at *
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "modfile.h"
|
||||
#include "tstringlist.h"
|
||||
#include "tdebug.h"
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
/***************************************************************************
|
||||
* This library is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* 2.1 as published by the Free Software Foundation. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, but *
|
||||
@@ -15,8 +15,12 @@
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library; if not, write to the Free Software *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, *
|
||||
* MA 02110-1301 USA *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||
* 02110-1301 USA *
|
||||
* *
|
||||
* Alternatively, this file is available under the Mozilla Public *
|
||||
* License Version 1.1. You may obtain a copy of the License at *
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef TAGLIB_MODFILE_H
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
/***************************************************************************
|
||||
* This library is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* 2.1 as published by the Free Software Foundation. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, but *
|
||||
@@ -15,10 +15,15 @@
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library; if not, write to the Free Software *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, *
|
||||
* MA 02110-1301 USA *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||
* 02110-1301 USA *
|
||||
* *
|
||||
* Alternatively, this file is available under the Mozilla Public *
|
||||
* License Version 1.1. You may obtain a copy of the License at *
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "tdebug.h"
|
||||
#include "modfilebase.h"
|
||||
|
||||
@@ -49,7 +54,7 @@ bool Mod::FileBase::readString(String &s, unsigned long size)
|
||||
{
|
||||
data.resize(index);
|
||||
}
|
||||
data.replace((char) 0xff, ' ');
|
||||
data.replace('\xff', ' ');
|
||||
|
||||
s = data;
|
||||
return true;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
/***************************************************************************
|
||||
* This library is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* 2.1 as published by the Free Software Foundation. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, but *
|
||||
@@ -15,8 +15,12 @@
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library; if not, write to the Free Software *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, *
|
||||
* MA 02110-1301 USA *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||
* 02110-1301 USA *
|
||||
* *
|
||||
* Alternatively, this file is available under the Mozilla Public *
|
||||
* License Version 1.1. You may obtain a copy of the License at *
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef TAGLIB_MODFILEBASE_H
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
/***************************************************************************
|
||||
* This library is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* 2.1 as published by the Free Software Foundation. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, but *
|
||||
@@ -15,10 +15,15 @@
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library; if not, write to the Free Software *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, *
|
||||
* MA 02110-1301 USA *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||
* 02110-1301 USA *
|
||||
* *
|
||||
* Alternatively, this file is available under the Mozilla Public *
|
||||
* License Version 1.1. You may obtain a copy of the License at *
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "modproperties.h"
|
||||
|
||||
using namespace TagLib;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
/***************************************************************************
|
||||
* This library is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* 2.1 as published by the Free Software Foundation. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, but *
|
||||
@@ -15,8 +15,12 @@
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library; if not, write to the Free Software *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, *
|
||||
* MA 02110-1301 USA *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||
* 02110-1301 USA *
|
||||
* *
|
||||
* Alternatively, this file is available under the Mozilla Public *
|
||||
* License Version 1.1. You may obtain a copy of the License at *
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef TAGLIB_MODPROPERTIES_H
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
/***************************************************************************
|
||||
* This library is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* 2.1 as published by the Free Software Foundation. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, but *
|
||||
@@ -15,10 +15,15 @@
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library; if not, write to the Free Software *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, *
|
||||
* MA 02110-1301 USA *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||
* 02110-1301 USA *
|
||||
* *
|
||||
* Alternatively, this file is available under the Mozilla Public *
|
||||
* License Version 1.1. You may obtain a copy of the License at *
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "modtag.h"
|
||||
#include "tstringlist.h"
|
||||
#include "tpropertymap.h"
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
/***************************************************************************
|
||||
* This library is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* 2.1 as published by the Free Software Foundation. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, but *
|
||||
@@ -15,8 +15,12 @@
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library; if not, write to the Free Software *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, *
|
||||
* MA 02110-1301 USA *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||
* 02110-1301 USA *
|
||||
* *
|
||||
* Alternatively, this file is available under the Mozilla Public *
|
||||
* License Version 1.1. You may obtain a copy of the License at *
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef TAGLIB_MODTAG_H
|
||||
@@ -50,39 +54,39 @@ namespace TagLib {
|
||||
* Returns the track name; if no track name is present in the tag
|
||||
* String::null will be returned.
|
||||
*/
|
||||
String title() const;
|
||||
virtual String title() const;
|
||||
|
||||
/*!
|
||||
* Not supported by module files. Therefore always returns String::null.
|
||||
*/
|
||||
String artist() const;
|
||||
virtual String artist() const;
|
||||
|
||||
/*!
|
||||
* Not supported by module files. Therefore always returns String::null.
|
||||
*/
|
||||
String album() const;
|
||||
virtual String album() const;
|
||||
|
||||
/*!
|
||||
* Returns the track comment derived from the instrument/sample/pattern
|
||||
* names; if no comment is present in the tag String::null will be
|
||||
* returned.
|
||||
*/
|
||||
String comment() const;
|
||||
virtual String comment() const;
|
||||
|
||||
/*!
|
||||
* Not supported by module files. Therefore always returns String::null.
|
||||
*/
|
||||
String genre() const;
|
||||
virtual String genre() const;
|
||||
|
||||
/*!
|
||||
* Not supported by module files. Therefore always returns 0.
|
||||
*/
|
||||
unsigned int year() const;
|
||||
virtual unsigned int year() const;
|
||||
|
||||
/*!
|
||||
* Not supported by module files. Therefore always returns 0.
|
||||
*/
|
||||
unsigned int track() const;
|
||||
virtual unsigned int track() const;
|
||||
|
||||
/*!
|
||||
* Returns the name of the tracker used to create/edit the module file.
|
||||
@@ -101,17 +105,17 @@ namespace TagLib {
|
||||
* Mod 20 characters, S3M 27 characters, IT 25 characters and XM 20
|
||||
* characters.
|
||||
*/
|
||||
void setTitle(const String &title);
|
||||
virtual void setTitle(const String &title);
|
||||
|
||||
/*!
|
||||
* Not supported by module files and therefore ignored.
|
||||
*/
|
||||
void setArtist(const String &artist);
|
||||
virtual void setArtist(const String &artist);
|
||||
|
||||
/*!
|
||||
* Not supported by module files and therefore ignored.
|
||||
*/
|
||||
void setAlbum(const String &album);
|
||||
virtual void setAlbum(const String &album);
|
||||
|
||||
/*!
|
||||
* Sets the comment to \a comment. If \a comment is String::null then
|
||||
@@ -130,22 +134,22 @@ namespace TagLib {
|
||||
* Mod 22 characters, S3M 27 characters, IT 25 characters and XM 22
|
||||
* characters.
|
||||
*/
|
||||
void setComment(const String &comment);
|
||||
virtual void setComment(const String &comment);
|
||||
|
||||
/*!
|
||||
* Not supported by module files and therefore ignored.
|
||||
*/
|
||||
void setGenre(const String &genre);
|
||||
virtual void setGenre(const String &genre);
|
||||
|
||||
/*!
|
||||
* Not supported by module files and therefore ignored.
|
||||
*/
|
||||
void setYear(unsigned int year);
|
||||
virtual void setYear(unsigned int year);
|
||||
|
||||
/*!
|
||||
* Not supported by module files and therefore ignored.
|
||||
*/
|
||||
void setTrack(unsigned int track);
|
||||
virtual void setTrack(unsigned int track);
|
||||
|
||||
/*!
|
||||
* Sets the tracker name to \a trackerName. If \a trackerName is
|
||||
|
||||
@@ -23,10 +23,6 @@
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <climits>
|
||||
|
||||
#include <tdebug.h>
|
||||
|
||||
@@ -34,7 +34,7 @@ using namespace TagLib;
|
||||
|
||||
namespace
|
||||
{
|
||||
inline bool checkValid(const MP4::AtomList &list)
|
||||
bool checkValid(const MP4::AtomList &list)
|
||||
{
|
||||
for(MP4::AtomList::ConstIterator it = list.begin(); it != list.end(); ++it) {
|
||||
|
||||
|
||||
@@ -50,24 +50,24 @@ namespace TagLib {
|
||||
public:
|
||||
Tag();
|
||||
Tag(TagLib::File *file, Atoms *atoms);
|
||||
~Tag();
|
||||
virtual ~Tag();
|
||||
bool save();
|
||||
|
||||
String title() const;
|
||||
String artist() const;
|
||||
String album() const;
|
||||
String comment() const;
|
||||
String genre() const;
|
||||
unsigned int year() const;
|
||||
unsigned int track() const;
|
||||
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;
|
||||
|
||||
void setTitle(const String &value);
|
||||
void setArtist(const String &value);
|
||||
void setAlbum(const String &value);
|
||||
void setComment(const String &value);
|
||||
void setGenre(const String &value);
|
||||
void setYear(unsigned int value);
|
||||
void setTrack(unsigned int value);
|
||||
virtual void setTitle(const String &value);
|
||||
virtual void setArtist(const String &value);
|
||||
virtual void setAlbum(const String &value);
|
||||
virtual void setComment(const String &value);
|
||||
virtual void setGenre(const String &value);
|
||||
virtual void setYear(unsigned int value);
|
||||
virtual void setTrack(unsigned int value);
|
||||
|
||||
virtual bool isEmpty() const;
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/***************************************************************************
|
||||
copyright : (C) 2002 - 2008 by Scott Wheeler
|
||||
email : wheeler@kde.org
|
||||
|
||||
copyright : (C) 2006 by Aaron VonderHaar
|
||||
email : avh4@users.sourceforge.net
|
||||
***************************************************************************/
|
||||
@@ -26,6 +27,7 @@
|
||||
***************************************************************************/
|
||||
|
||||
#include <tdebug.h>
|
||||
#include <tstringlist.h>
|
||||
|
||||
#include "generalencapsulatedobjectframe.h"
|
||||
|
||||
@@ -151,15 +153,21 @@ void GeneralEncapsulatedObjectFrame::parseFields(const ByteVector &data)
|
||||
|
||||
ByteVector GeneralEncapsulatedObjectFrame::renderFields() const
|
||||
{
|
||||
StringList sl;
|
||||
sl.append(d->fileName);
|
||||
sl.append(d->description);
|
||||
|
||||
const String::Type encoding = checkTextEncoding(sl, d->textEncoding);
|
||||
|
||||
ByteVector data;
|
||||
|
||||
data.append(char(d->textEncoding));
|
||||
data.append(char(encoding));
|
||||
data.append(d->mimeType.data(String::Latin1));
|
||||
data.append(textDelimiter(String::Latin1));
|
||||
data.append(d->fileName.data(d->textEncoding));
|
||||
data.append(textDelimiter(d->textEncoding));
|
||||
data.append(d->description.data(d->textEncoding));
|
||||
data.append(textDelimiter(d->textEncoding));
|
||||
data.append(d->fileName.data(encoding));
|
||||
data.append(textDelimiter(encoding));
|
||||
data.append(d->description.data(encoding));
|
||||
data.append(textDelimiter(encoding));
|
||||
data.append(d->data);
|
||||
|
||||
return data;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/***************************************************************************
|
||||
copyright : (C) 2002 - 2008 by Scott Wheeler
|
||||
email : wheeler@kde.org
|
||||
|
||||
copyright : (C) 2006 by Aaron VonderHaar
|
||||
email : avh4@users.sourceforge.net
|
||||
***************************************************************************/
|
||||
|
||||
@@ -24,9 +24,10 @@
|
||||
***************************************************************************/
|
||||
|
||||
#include <tdebug.h>
|
||||
#include <tstringlist.h>
|
||||
#include <id3v2tag.h>
|
||||
|
||||
#include "ownershipframe.h"
|
||||
#include <id3v2tag.h>
|
||||
|
||||
using namespace TagLib;
|
||||
using namespace ID3v2;
|
||||
@@ -113,24 +114,24 @@ void OwnershipFrame::setTextEncoding(String::Type encoding)
|
||||
void OwnershipFrame::parseFields(const ByteVector &data)
|
||||
{
|
||||
int pos = 0;
|
||||
|
||||
|
||||
// Get the text encoding
|
||||
d->textEncoding = String::Type(data[0]);
|
||||
pos += 1;
|
||||
|
||||
|
||||
// Read the price paid this is a null terminate string
|
||||
d->pricePaid = readStringField(data, String::Latin1, &pos);
|
||||
|
||||
|
||||
// If we don't have at least 8 bytes left then don't parse the rest of the
|
||||
// data
|
||||
if(data.size() - pos < 8) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Read the date purchased YYYYMMDD
|
||||
d->datePurchased = String(data.mid(pos, 8));
|
||||
pos += 8;
|
||||
|
||||
|
||||
// Read the seller
|
||||
if(d->textEncoding == String::Latin1)
|
||||
d->seller = Tag::latin1StringHandler()->parse(data.mid(pos));
|
||||
@@ -140,14 +141,19 @@ void OwnershipFrame::parseFields(const ByteVector &data)
|
||||
|
||||
ByteVector OwnershipFrame::renderFields() const
|
||||
{
|
||||
StringList sl;
|
||||
sl.append(d->seller);
|
||||
|
||||
const String::Type encoding = checkTextEncoding(sl, d->textEncoding);
|
||||
|
||||
ByteVector v;
|
||||
|
||||
v.append(char(d->textEncoding));
|
||||
|
||||
v.append(char(encoding));
|
||||
v.append(d->pricePaid.data(String::Latin1));
|
||||
v.append(textDelimiter(String::Latin1));
|
||||
v.append(d->datePurchased.data(String::Latin1));
|
||||
v.append(d->seller.data(d->textEncoding));
|
||||
|
||||
v.append(d->seller.data(encoding));
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
|
||||
@@ -158,7 +158,7 @@ void SynchronizedLyricsFrame::parseFields(const ByteVector &data)
|
||||
int pos = 6;
|
||||
|
||||
d->description = readStringField(data, d->textEncoding, &pos);
|
||||
if(d->description.isEmpty())
|
||||
if(pos == 6)
|
||||
return;
|
||||
|
||||
/*
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/***************************************************************************
|
||||
copyright : (C) 2002 - 2008 by Scott Wheeler
|
||||
email : wheeler@kde.org
|
||||
|
||||
copyright : (C) 2006 by Urs Fleisch
|
||||
email : ufleisch@users.sourceforge.net
|
||||
***************************************************************************/
|
||||
@@ -168,13 +169,19 @@ void UnsynchronizedLyricsFrame::parseFields(const ByteVector &data)
|
||||
|
||||
ByteVector UnsynchronizedLyricsFrame::renderFields() const
|
||||
{
|
||||
StringList sl;
|
||||
sl.append(d->description);
|
||||
sl.append(d->text);
|
||||
|
||||
const String::Type encoding = checkTextEncoding(sl, d->textEncoding);
|
||||
|
||||
ByteVector v;
|
||||
|
||||
v.append(char(d->textEncoding));
|
||||
v.append(char(encoding));
|
||||
v.append(d->language.size() == 3 ? d->language : "XXX");
|
||||
v.append(d->description.data(d->textEncoding));
|
||||
v.append(textDelimiter(d->textEncoding));
|
||||
v.append(d->text.data(d->textEncoding));
|
||||
v.append(d->description.data(encoding));
|
||||
v.append(textDelimiter(encoding));
|
||||
v.append(d->text.data(encoding));
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/***************************************************************************
|
||||
copyright : (C) 2002 - 2008 by Scott Wheeler
|
||||
email : wheeler@kde.org
|
||||
|
||||
copyright : (C) 2006 by Urs Fleisch
|
||||
email : ufleisch@users.sourceforge.net
|
||||
***************************************************************************/
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/***************************************************************************
|
||||
copyright : (C) 2002 - 2008 by Scott Wheeler
|
||||
email : wheeler@kde.org
|
||||
|
||||
copyright : (C) 2006 by Urs Fleisch
|
||||
email : ufleisch@users.sourceforge.net
|
||||
***************************************************************************/
|
||||
|
||||
@@ -23,22 +23,16 @@
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_ZLIB
|
||||
#include <zlib.h>
|
||||
#endif
|
||||
|
||||
#include <bitset>
|
||||
|
||||
#include <tdebug.h>
|
||||
#include <tstringlist.h>
|
||||
#include <tzlib.h>
|
||||
|
||||
#include "id3v2tag.h"
|
||||
#include "id3v2frame.h"
|
||||
#include "id3v2synchdata.h"
|
||||
|
||||
#include "tpropertymap.h"
|
||||
#include "frames/textidentificationframe.h"
|
||||
#include "frames/urllinkframe.h"
|
||||
@@ -97,10 +91,10 @@ unsigned int Frame::headerSize(unsigned int version)
|
||||
|
||||
ByteVector Frame::textDelimiter(String::Type t)
|
||||
{
|
||||
ByteVector d = char(0);
|
||||
if(t == String::UTF16 || t == String::UTF16BE || t == String::UTF16LE)
|
||||
d.append(char(0));
|
||||
return d;
|
||||
return ByteVector(2, '\0');
|
||||
else
|
||||
return ByteVector(1, '\0');
|
||||
}
|
||||
|
||||
const String Frame::instrumentPrefix("PERFORMER:");
|
||||
@@ -251,60 +245,21 @@ ByteVector Frame::fieldData(const ByteVector &frameData) const
|
||||
frameDataOffset += 4;
|
||||
}
|
||||
|
||||
#if HAVE_ZLIB
|
||||
if(d->header->compression() &&
|
||||
!d->header->encryption())
|
||||
{
|
||||
if(zlib::isAvailable() && d->header->compression() && !d->header->encryption()) {
|
||||
if(frameData.size() <= frameDataOffset) {
|
||||
debug("Compressed frame doesn't have enough data to decode");
|
||||
return ByteVector();
|
||||
}
|
||||
|
||||
z_stream stream = {};
|
||||
|
||||
if(inflateInit(&stream) != Z_OK)
|
||||
return ByteVector();
|
||||
|
||||
ByteVector inData = frameData;
|
||||
|
||||
stream.avail_in = static_cast<uInt>(inData.size() - frameDataOffset);
|
||||
stream.next_in = reinterpret_cast<Bytef *>(inData.data() + frameDataOffset);
|
||||
|
||||
static const unsigned int chunkSize = 1024;
|
||||
|
||||
ByteVector outData;
|
||||
ByteVector chunk(chunkSize);
|
||||
|
||||
do {
|
||||
stream.avail_out = static_cast<uInt>(chunk.size());
|
||||
stream.next_out = reinterpret_cast<Bytef *>(chunk.data());
|
||||
|
||||
int result = inflate(&stream, Z_NO_FLUSH);
|
||||
|
||||
if(result == Z_STREAM_ERROR ||
|
||||
result == Z_NEED_DICT ||
|
||||
result == Z_DATA_ERROR ||
|
||||
result == Z_MEM_ERROR)
|
||||
{
|
||||
if(result != Z_STREAM_ERROR)
|
||||
inflateEnd(&stream);
|
||||
debug("Error reading compressed stream");
|
||||
return ByteVector();
|
||||
}
|
||||
|
||||
outData.append(stream.avail_out == 0 ? chunk : chunk.mid(0, chunk.size() - stream.avail_out));
|
||||
} while(stream.avail_out == 0);
|
||||
|
||||
inflateEnd(&stream);
|
||||
|
||||
if(frameDataLength != outData.size())
|
||||
const ByteVector outData = zlib::decompress(frameData.mid(frameDataOffset));
|
||||
if(!outData.isEmpty() && frameDataLength != outData.size()) {
|
||||
debug("frameDataLength does not match the data length returned by zlib");
|
||||
}
|
||||
|
||||
return outData;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
return frameData.mid(frameDataOffset, frameDataLength);
|
||||
|
||||
return frameData.mid(frameDataOffset, frameDataLength);
|
||||
}
|
||||
|
||||
String Frame::readStringField(const ByteVector &data, String::Type encoding, int *position)
|
||||
|
||||
@@ -23,11 +23,8 @@
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <tdebug.h>
|
||||
#include <tzlib.h>
|
||||
|
||||
#include "id3v2framefactory.h"
|
||||
#include "id3v2synchdata.h"
|
||||
@@ -105,13 +102,14 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
FrameFactory FrameFactory::factory;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// public members
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
FrameFactory *FrameFactory::instance()
|
||||
{
|
||||
static FrameFactory factory;
|
||||
return &factory;
|
||||
}
|
||||
|
||||
@@ -174,12 +172,11 @@ Frame *FrameFactory::createFrame(const ByteVector &origData, Header *tagHeader)
|
||||
// TagLib doesn't mess with encrypted frames, so just treat them
|
||||
// as unknown frames.
|
||||
|
||||
#if !defined(HAVE_ZLIB) || HAVE_ZLIB == 0
|
||||
if(header->compression()) {
|
||||
if(!zlib::isAvailable() && header->compression()) {
|
||||
debug("Compressed frames are currently not supported.");
|
||||
return new UnknownFrame(data, header);
|
||||
}
|
||||
#endif
|
||||
|
||||
if(header->encryption()) {
|
||||
debug("Encrypted frames are currently not supported.");
|
||||
return new UnknownFrame(data, header);
|
||||
@@ -542,4 +539,3 @@ bool FrameFactory::updateFrame(Frame::Header *header) const
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -66,7 +66,6 @@ namespace TagLib {
|
||||
{
|
||||
public:
|
||||
static FrameFactory *instance();
|
||||
|
||||
/*!
|
||||
* Create a frame based on \a data. \a synchSafeInts should only be set
|
||||
* false if we are parsing an old tag (v2.3 or older) that does not support
|
||||
@@ -153,6 +152,8 @@ namespace TagLib {
|
||||
FrameFactory(const FrameFactory &);
|
||||
FrameFactory &operator=(const FrameFactory &);
|
||||
|
||||
static FrameFactory factory;
|
||||
|
||||
class FrameFactoryPrivate;
|
||||
FrameFactoryPrivate *d;
|
||||
};
|
||||
|
||||
@@ -74,11 +74,25 @@ ByteVector SynchData::fromUInt(unsigned int value)
|
||||
|
||||
ByteVector SynchData::decode(const ByteVector &data)
|
||||
{
|
||||
ByteVector result = data;
|
||||
// We have this optimized method instead of using ByteVector::replace(),
|
||||
// since it makes a great difference when decoding huge unsynchronized frames.
|
||||
|
||||
ByteVector pattern(2, char(0));
|
||||
pattern[0] = '\xFF';
|
||||
pattern[1] = '\x00';
|
||||
ByteVector result(data.size());
|
||||
|
||||
return result.replace(pattern, '\xFF');
|
||||
ByteVector::ConstIterator src = data.begin();
|
||||
ByteVector::Iterator dst = result.begin();
|
||||
|
||||
while(src < data.end() - 1) {
|
||||
*dst++ = *src++;
|
||||
|
||||
if(*(src - 1) == '\xff' && *src == '\x00')
|
||||
src++;
|
||||
}
|
||||
|
||||
if(src < data.end())
|
||||
*dst++ = *src++;
|
||||
|
||||
result.resize(static_cast<unsigned int>(dst - result.begin()));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -23,10 +23,6 @@
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include <tfile.h>
|
||||
@@ -470,7 +466,7 @@ ByteVector ID3v2::Tag::render() const
|
||||
|
||||
void ID3v2::Tag::downgradeFrames(FrameList *frames, FrameList *newFrames) const
|
||||
{
|
||||
#ifdef NO_ITUNES_HACKS
|
||||
#ifdef NO_ITUNES_HACKS
|
||||
const char *unsupportedFrames[] = {
|
||||
"ASPI", "EQU2", "RVA2", "SEEK", "SIGN", "TDRL", "TDTG",
|
||||
"TMOO", "TPRO", "TSOA", "TSOT", "TSST", "TSOP", 0
|
||||
|
||||
@@ -34,25 +34,27 @@ namespace TagLib
|
||||
{
|
||||
namespace MPEG
|
||||
{
|
||||
|
||||
/*!
|
||||
* MPEG frames can be recognized by the bit pattern 11111111 111, so the
|
||||
* first byte is easy to check for, however checking to see if the second byte
|
||||
* starts with \e 111 is a bit more tricky, hence these functions.
|
||||
*/
|
||||
|
||||
inline bool firstSyncByte(unsigned char byte)
|
||||
namespace
|
||||
{
|
||||
return (byte == 0xFF);
|
||||
|
||||
/*!
|
||||
* MPEG frames can be recognized by the bit pattern 11111111 111, so the
|
||||
* first byte is easy to check for, however checking to see if the second byte
|
||||
* starts with \e 111 is a bit more tricky, hence these functions.
|
||||
*/
|
||||
inline bool firstSyncByte(unsigned char byte)
|
||||
{
|
||||
return (byte == 0xFF);
|
||||
}
|
||||
|
||||
inline bool secondSynchByte(unsigned char byte)
|
||||
{
|
||||
// 0xFF is possible in theory, but it's very unlikely be a header.
|
||||
|
||||
return (byte != 0xFF && ((byte & 0xE0) == 0xE0));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
inline bool secondSynchByte(unsigned char byte)
|
||||
{
|
||||
// 0xFF is possible in theory, but it's very unlikely be a header.
|
||||
|
||||
return (byte != 0xFF && ((byte & 0xE0) == 0xE0));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ using namespace TagLib;
|
||||
namespace
|
||||
{
|
||||
// Returns the first packet index of the right next page to the given one.
|
||||
inline unsigned int nextPacketIndex(const Ogg::Page *page)
|
||||
unsigned int nextPacketIndex(const Ogg::Page *page)
|
||||
{
|
||||
if(page->header()->lastPacketCompleted())
|
||||
return page->firstPacketIndex() + page->packetCount();
|
||||
@@ -262,12 +262,13 @@ void Ogg::File::writePacket(unsigned int i, const ByteVector &packet)
|
||||
// TODO: This pagination method isn't accurate for what's being done here.
|
||||
// This should account for real possibilities like non-aligned packets and such.
|
||||
|
||||
const List<Page *> pages = Page::paginate(packets,
|
||||
Page::SinglePagePerGroup,
|
||||
firstPage->header()->streamSerialNumber(),
|
||||
firstPage->pageSequenceNumber(),
|
||||
firstPage->header()->firstPacketContinued(),
|
||||
lastPage->header()->lastPacketCompleted());
|
||||
List<Page *> pages = Page::paginate(packets,
|
||||
Page::SinglePagePerGroup,
|
||||
firstPage->header()->streamSerialNumber(),
|
||||
firstPage->pageSequenceNumber(),
|
||||
firstPage->header()->firstPacketContinued(),
|
||||
lastPage->header()->lastPacketCompleted());
|
||||
pages.setAutoDelete(true);
|
||||
|
||||
// Write the pages.
|
||||
|
||||
|
||||
@@ -48,11 +48,14 @@ class RIFF::File::FilePrivate
|
||||
public:
|
||||
FilePrivate(Endianness endianness) :
|
||||
endianness(endianness),
|
||||
size(0) {}
|
||||
size(0),
|
||||
sizeOffset(0) {}
|
||||
|
||||
const Endianness endianness;
|
||||
|
||||
unsigned int size;
|
||||
long sizeOffset;
|
||||
|
||||
std::vector<Chunk> chunks;
|
||||
};
|
||||
|
||||
@@ -97,31 +100,50 @@ unsigned int RIFF::File::chunkCount() const
|
||||
|
||||
unsigned int RIFF::File::chunkDataSize(unsigned int i) const
|
||||
{
|
||||
if(i >= d->chunks.size()) {
|
||||
debug("RIFF::File::chunkPadding() - Index out of range. Returning 0.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
return d->chunks[i].size;
|
||||
}
|
||||
|
||||
unsigned int RIFF::File::chunkOffset(unsigned int i) const
|
||||
{
|
||||
if(i >= d->chunks.size()) {
|
||||
debug("RIFF::File::chunkPadding() - Index out of range. Returning 0.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
return d->chunks[i].offset;
|
||||
}
|
||||
|
||||
unsigned int RIFF::File::chunkPadding(unsigned int i) const
|
||||
{
|
||||
if(i >= d->chunks.size()) {
|
||||
debug("RIFF::File::chunkPadding() - Index out of range. Returning 0.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
return d->chunks[i].padding;
|
||||
}
|
||||
|
||||
ByteVector RIFF::File::chunkName(unsigned int i) const
|
||||
{
|
||||
if(i >= chunkCount())
|
||||
if(i >= d->chunks.size()) {
|
||||
debug("RIFF::File::chunkName() - Index out of range. Returning an empty vector.");
|
||||
return ByteVector();
|
||||
}
|
||||
|
||||
return d->chunks[i].name;
|
||||
}
|
||||
|
||||
ByteVector RIFF::File::chunkData(unsigned int i)
|
||||
{
|
||||
if(i >= chunkCount())
|
||||
if(i >= d->chunks.size()) {
|
||||
debug("RIFF::File::chunkData() - Index out of range. Returning an empty vector.");
|
||||
return ByteVector();
|
||||
}
|
||||
|
||||
seek(d->chunks[i].offset);
|
||||
return readBlock(d->chunks[i].size);
|
||||
@@ -129,22 +151,33 @@ ByteVector RIFF::File::chunkData(unsigned int i)
|
||||
|
||||
void RIFF::File::setChunkData(unsigned int i, const ByteVector &data)
|
||||
{
|
||||
// First we update the global size
|
||||
|
||||
d->size += ((data.size() + 1) & ~1) - (d->chunks[i].size + d->chunks[i].padding);
|
||||
insert(ByteVector::fromUInt(d->size, d->endianness == BigEndian), 4, 4);
|
||||
if(i >= d->chunks.size()) {
|
||||
debug("RIFF::File::setChunkData() - Index out of range.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Now update the specific chunk
|
||||
|
||||
writeChunk(chunkName(i), data, d->chunks[i].offset - 8, d->chunks[i].size + d->chunks[i].padding + 8);
|
||||
std::vector<Chunk>::iterator it = d->chunks.begin();
|
||||
std::advance(it, i);
|
||||
|
||||
d->chunks[i].size = data.size();
|
||||
d->chunks[i].padding = (data.size() & 0x01) ? 1 : 0;
|
||||
const int originalSize = it->size + it->padding;
|
||||
|
||||
writeChunk(it->name, data, it->offset - 8, it->size + it->padding + 8);
|
||||
|
||||
it->size = data.size();
|
||||
it->padding = data.size() % 1;
|
||||
|
||||
const int diff = it->size + it->padding - originalSize;
|
||||
|
||||
// Now update the internal offsets
|
||||
|
||||
for(i++; i < d->chunks.size(); i++)
|
||||
d->chunks[i].offset = d->chunks[i-1].offset + 8 + d->chunks[i-1].size + d->chunks[i-1].padding;
|
||||
for(++it; it != d->chunks.end(); ++it)
|
||||
it->offset += diff;
|
||||
|
||||
// Update the global size.
|
||||
|
||||
updateGlobalSize();
|
||||
}
|
||||
|
||||
void RIFF::File::setChunkData(const ByteVector &name, const ByteVector &data)
|
||||
@@ -175,37 +208,49 @@ void RIFF::File::setChunkData(const ByteVector &name, const ByteVector &data, bo
|
||||
|
||||
// Couldn't find an existing chunk, so let's create a new one.
|
||||
|
||||
unsigned long offset = d->chunks.back().offset + d->chunks.back().size;
|
||||
// Adjust the padding of the last chunk to place the new chunk at even position.
|
||||
|
||||
// First we update the global size
|
||||
Chunk &last = d->chunks.back();
|
||||
|
||||
d->size += (offset & 1) + data.size() + 8;
|
||||
insert(ByteVector::fromUInt(d->size, d->endianness == BigEndian), 4, 4);
|
||||
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.
|
||||
offset--;
|
||||
removeBlock(offset, 1);
|
||||
}
|
||||
else {
|
||||
insert(ByteVector("\0", 1), offset, 0);
|
||||
last.padding = 1;
|
||||
offset++;
|
||||
}
|
||||
}
|
||||
|
||||
// Now add the chunk to the file
|
||||
// Now add the chunk to the file.
|
||||
|
||||
writeChunk(name, data, offset, std::max<long>(0, length() - offset), (offset & 1) ? 1 : 0);
|
||||
writeChunk(name, data, offset, 0);
|
||||
|
||||
// And update our internal structure
|
||||
|
||||
if(offset & 1) {
|
||||
d->chunks.back().padding = 1;
|
||||
offset++;
|
||||
}
|
||||
|
||||
Chunk chunk;
|
||||
chunk.name = name;
|
||||
chunk.size = data.size();
|
||||
chunk.offset = offset + 8;
|
||||
chunk.padding = (data.size() & 0x01) ? 1 : 0;
|
||||
chunk.name = name;
|
||||
chunk.size = data.size();
|
||||
chunk.offset = offset + 8;
|
||||
chunk.padding = data.size() % 2;
|
||||
|
||||
d->chunks.push_back(chunk);
|
||||
|
||||
// Update the global size.
|
||||
|
||||
updateGlobalSize();
|
||||
}
|
||||
|
||||
void RIFF::File::removeChunk(unsigned int i)
|
||||
{
|
||||
if(i >= d->chunks.size())
|
||||
if(i >= d->chunks.size()) {
|
||||
debug("RIFF::File::removeChunk() - Index out of range.");
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<Chunk>::iterator it = d->chunks.begin();
|
||||
std::advance(it, i);
|
||||
@@ -216,6 +261,10 @@ void RIFF::File::removeChunk(unsigned int i)
|
||||
|
||||
for(; it != d->chunks.end(); ++it)
|
||||
it->offset -= removeSize;
|
||||
|
||||
// Update the global size.
|
||||
|
||||
updateGlobalSize();
|
||||
}
|
||||
|
||||
void RIFF::File::removeChunk(const ByteVector &name)
|
||||
@@ -233,17 +282,24 @@ void RIFF::File::removeChunk(const ByteVector &name)
|
||||
void RIFF::File::read()
|
||||
{
|
||||
const bool bigEndian = (d->endianness == BigEndian);
|
||||
const long baseOffset = tell();
|
||||
|
||||
seek(baseOffset + 4);
|
||||
long offset = tell();
|
||||
|
||||
offset += 4;
|
||||
d->sizeOffset = offset;
|
||||
|
||||
seek(offset);
|
||||
d->size = readBlock(4).toUInt(bigEndian);
|
||||
|
||||
seek(baseOffset + 12);
|
||||
offset += 8;
|
||||
seek(offset);
|
||||
|
||||
// + 8: chunk header at least, fix for additional junk bytes
|
||||
while(tell() + 8 <= length()) {
|
||||
ByteVector chunkName = readBlock(4);
|
||||
unsigned int chunkSize = readBlock(4).toUInt(bigEndian);
|
||||
while(offset + 8 <= length()) {
|
||||
|
||||
seek(offset);
|
||||
const ByteVector chunkName = readBlock(4);
|
||||
const unsigned int chunkSize = readBlock(4).toUInt(bigEndian);
|
||||
|
||||
if(!isValidChunkName(chunkName)) {
|
||||
debug("RIFF::File::read() -- Chunk '" + chunkName + "' has invalid ID");
|
||||
@@ -257,24 +313,26 @@ void RIFF::File::read()
|
||||
break;
|
||||
}
|
||||
|
||||
offset += 8;
|
||||
|
||||
Chunk chunk;
|
||||
chunk.name = chunkName;
|
||||
chunk.size = chunkSize;
|
||||
chunk.offset = tell();
|
||||
chunk.name = chunkName;
|
||||
chunk.size = chunkSize;
|
||||
chunk.offset = offset;
|
||||
|
||||
seek(chunk.size, Current);
|
||||
offset += chunk.size;
|
||||
|
||||
seek(offset);
|
||||
|
||||
// Check padding
|
||||
|
||||
// check padding
|
||||
chunk.padding = 0;
|
||||
long uPosNotPadded = tell();
|
||||
if((uPosNotPadded & 0x01) != 0) {
|
||||
ByteVector iByte = readBlock(1);
|
||||
if((iByte.size() != 1) || (iByte[0] != 0)) {
|
||||
// not well formed, re-seek
|
||||
seek(uPosNotPadded, Beginning);
|
||||
}
|
||||
else {
|
||||
|
||||
if(offset & 1) {
|
||||
const ByteVector iByte = readBlock(1);
|
||||
if(iByte.size() == 1 && iByte[0] == '\0') {
|
||||
chunk.padding = 1;
|
||||
offset++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -283,18 +341,26 @@ void RIFF::File::read()
|
||||
}
|
||||
|
||||
void RIFF::File::writeChunk(const ByteVector &name, const ByteVector &data,
|
||||
unsigned long offset, unsigned long replace,
|
||||
unsigned int leadingPadding)
|
||||
unsigned long offset, unsigned long replace)
|
||||
{
|
||||
ByteVector combined;
|
||||
if(leadingPadding) {
|
||||
combined.append(ByteVector(leadingPadding, '\x00'));
|
||||
}
|
||||
|
||||
combined.append(name);
|
||||
combined.append(ByteVector::fromUInt(data.size(), d->endianness == BigEndian));
|
||||
combined.append(data);
|
||||
if((data.size() & 0x01) != 0) {
|
||||
combined.append('\x00');
|
||||
}
|
||||
|
||||
if(data.size() & 1)
|
||||
combined.resize(combined.size() + 1, '\0');
|
||||
|
||||
insert(combined, offset, replace);
|
||||
}
|
||||
|
||||
void RIFF::File::updateGlobalSize()
|
||||
{
|
||||
const Chunk first = d->chunks.front();
|
||||
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);
|
||||
insert(data, d->sizeOffset, 4);
|
||||
}
|
||||
|
||||
@@ -145,8 +145,12 @@ namespace TagLib {
|
||||
|
||||
void read();
|
||||
void writeChunk(const ByteVector &name, const ByteVector &data,
|
||||
unsigned long offset, unsigned long replace = 0,
|
||||
unsigned int leadingPadding = 0);
|
||||
unsigned long offset, unsigned long replace = 0);
|
||||
|
||||
/*!
|
||||
* Update the global RIFF size based on the current internal structure.
|
||||
*/
|
||||
void updateGlobalSize();
|
||||
|
||||
class FilePrivate;
|
||||
FilePrivate *d;
|
||||
|
||||
@@ -34,18 +34,23 @@ namespace TagLib
|
||||
{
|
||||
namespace RIFF
|
||||
{
|
||||
inline bool isValidChunkName(const ByteVector &name)
|
||||
namespace
|
||||
{
|
||||
if(name.size() != 4)
|
||||
return false;
|
||||
|
||||
for(ByteVector::ConstIterator it = name.begin(); it != name.end(); ++it) {
|
||||
const int c = static_cast<unsigned char>(*it);
|
||||
if(c < 32 || 127 < c)
|
||||
inline bool isValidChunkName(const ByteVector &name)
|
||||
{
|
||||
if(name.size() != 4)
|
||||
return false;
|
||||
|
||||
for(ByteVector::ConstIterator it = name.begin(); it != name.end(); ++it) {
|
||||
const int c = static_cast<unsigned char>(*it);
|
||||
if(c < 32 || 127 < c)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -192,7 +192,7 @@ void RIFF::WAV::Properties::read(File *file)
|
||||
d->sampleRate = data.toUInt(4, false);
|
||||
d->bitsPerSample = data.toShort(14, false);
|
||||
|
||||
if(totalSamples > 0)
|
||||
if(d->format != FORMAT_PCM)
|
||||
d->sampleFrames = totalSamples;
|
||||
else if(d->channels > 0 && d->bitsPerSample > 0)
|
||||
d->sampleFrames = streamLength / (d->channels * ((d->bitsPerSample + 7) / 8));
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
/***************************************************************************
|
||||
* This library is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* 2.1 as published by the Free Software Foundation. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, but *
|
||||
@@ -15,10 +15,15 @@
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library; if not, write to the Free Software *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, *
|
||||
* MA 02110-1301 USA *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||
* 02110-1301 USA *
|
||||
* *
|
||||
* Alternatively, this file is available under the Mozilla Public *
|
||||
* License Version 1.1. You may obtain a copy of the License at *
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "s3mfile.h"
|
||||
#include "tstringlist.h"
|
||||
#include "tdebug.h"
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
/***************************************************************************
|
||||
* This library is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* 2.1 as published by the Free Software Foundation. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, but *
|
||||
@@ -15,8 +15,12 @@
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library; if not, write to the Free Software *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, *
|
||||
* MA 02110-1301 USA *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||
* 02110-1301 USA *
|
||||
* *
|
||||
* Alternatively, this file is available under the Mozilla Public *
|
||||
* License Version 1.1. You may obtain a copy of the License at *
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef TAGLIB_S3MFILE_H
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
/***************************************************************************
|
||||
* This library is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* 2.1 as published by the Free Software Foundation. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, but *
|
||||
@@ -15,10 +15,15 @@
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library; if not, write to the Free Software *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, *
|
||||
* MA 02110-1301 USA *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||
* 02110-1301 USA *
|
||||
* *
|
||||
* Alternatively, this file is available under the Mozilla Public *
|
||||
* License Version 1.1. You may obtain a copy of the License at *
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "s3mproperties.h"
|
||||
|
||||
using namespace TagLib;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
/***************************************************************************
|
||||
* This library is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* 2.1 as published by the Free Software Foundation. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, but *
|
||||
@@ -15,8 +15,12 @@
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library; if not, write to the Free Software *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, *
|
||||
* MA 02110-1301 USA *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||
* 02110-1301 USA *
|
||||
* *
|
||||
* Alternatively, this file is available under the Mozilla Public *
|
||||
* License Version 1.1. You may obtain a copy of the License at *
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef TAGLIB_S3MPROPERTIES_H
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
#define TAGLIB_MINOR_VERSION 11
|
||||
#define TAGLIB_PATCH_VERSION 0
|
||||
|
||||
#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 1))
|
||||
#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 1)) || defined(__clang__)
|
||||
#define TAGLIB_IGNORE_MISSING_DESTRUCTOR _Pragma("GCC diagnostic ignored \"-Wnon-virtual-dtor\"")
|
||||
#else
|
||||
#define TAGLIB_IGNORE_MISSING_DESTRUCTOR
|
||||
|
||||
@@ -23,10 +23,6 @@
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <limits>
|
||||
@@ -37,8 +33,8 @@
|
||||
|
||||
#include <tstring.h>
|
||||
#include <tdebug.h>
|
||||
#include "trefcounter.h"
|
||||
#include "tutils.h"
|
||||
#include <trefcounter.h>
|
||||
#include <tutils.h>
|
||||
|
||||
#include "tbytevector.h"
|
||||
|
||||
@@ -475,18 +471,34 @@ bool ByteVector::endsWith(const ByteVector &pattern) const
|
||||
return containsAt(pattern, size() - pattern.size());
|
||||
}
|
||||
|
||||
ByteVector &ByteVector::replace(char oldByte, char newByte)
|
||||
{
|
||||
detach();
|
||||
|
||||
for(ByteVector::Iterator it = begin(); it != end(); ++it) {
|
||||
if(*it == oldByte)
|
||||
*it = newByte;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
ByteVector &ByteVector::replace(const ByteVector &pattern, const ByteVector &with)
|
||||
{
|
||||
// TODO: This takes O(n!) time in the worst case. Rewrite it to run in O(n) time.
|
||||
|
||||
if(pattern.size() == 0 || pattern.size() > size())
|
||||
return *this;
|
||||
|
||||
if(pattern.size() == 1 && with.size() == 1)
|
||||
return replace(pattern[0], with[0]);
|
||||
|
||||
const size_t withSize = with.size();
|
||||
const size_t patternSize = pattern.size();
|
||||
const ptrdiff_t diff = withSize - patternSize;
|
||||
|
||||
size_t offset = 0;
|
||||
while (true)
|
||||
{
|
||||
while (true) {
|
||||
offset = find(pattern, offset);
|
||||
if(offset == static_cast<size_t>(-1)) // Use npos in taglib2.
|
||||
break;
|
||||
@@ -538,12 +550,16 @@ int ByteVector::endsWithPartialMatch(const ByteVector &pattern) const
|
||||
|
||||
ByteVector &ByteVector::append(const ByteVector &v)
|
||||
{
|
||||
if(v.d->length != 0) {
|
||||
detach();
|
||||
unsigned int originalSize = size();
|
||||
resize(originalSize + v.size());
|
||||
::memcpy(data() + originalSize, v.data(), v.size());
|
||||
}
|
||||
if(v.isEmpty())
|
||||
return *this;
|
||||
|
||||
detach();
|
||||
|
||||
const unsigned int originalSize = size();
|
||||
const unsigned int appendSize = v.size();
|
||||
|
||||
resize(originalSize + appendSize);
|
||||
::memcpy(data() + originalSize, v.data(), appendSize);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -179,6 +179,12 @@ namespace TagLib {
|
||||
*/
|
||||
bool endsWith(const ByteVector &pattern) const;
|
||||
|
||||
/*!
|
||||
* Replaces \a oldByte with \a newByte and returns a reference to the
|
||||
* ByteVector after the operation. This \e does modify the vector.
|
||||
*/
|
||||
ByteVector &replace(char oldByte, char newByte);
|
||||
|
||||
/*!
|
||||
* Replaces \a pattern with \a with and returns a reference to the ByteVector
|
||||
* after the operation. This \e does modify the vector.
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace
|
||||
|
||||
const FileHandle InvalidFileHandle = INVALID_HANDLE_VALUE;
|
||||
|
||||
inline FileHandle openFile(const FileName &path, bool readOnly)
|
||||
FileHandle openFile(const FileName &path, bool readOnly)
|
||||
{
|
||||
const DWORD access = readOnly ? GENERIC_READ : (GENERIC_READ | GENERIC_WRITE);
|
||||
|
||||
@@ -59,12 +59,12 @@ namespace
|
||||
return InvalidFileHandle;
|
||||
}
|
||||
|
||||
inline void closeFile(FileHandle file)
|
||||
void closeFile(FileHandle file)
|
||||
{
|
||||
CloseHandle(file);
|
||||
}
|
||||
|
||||
inline size_t readFile(FileHandle file, ByteVector &buffer)
|
||||
size_t readFile(FileHandle file, ByteVector &buffer)
|
||||
{
|
||||
DWORD length;
|
||||
if(ReadFile(file, buffer.data(), static_cast<DWORD>(buffer.size()), &length, NULL))
|
||||
@@ -73,7 +73,7 @@ namespace
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline size_t writeFile(FileHandle file, const ByteVector &buffer)
|
||||
size_t writeFile(FileHandle file, const ByteVector &buffer)
|
||||
{
|
||||
DWORD length;
|
||||
if(WriteFile(file, buffer.data(), static_cast<DWORD>(buffer.size()), &length, NULL))
|
||||
@@ -94,22 +94,22 @@ namespace
|
||||
|
||||
const FileHandle InvalidFileHandle = 0;
|
||||
|
||||
inline FileHandle openFile(const FileName &path, bool readOnly)
|
||||
FileHandle openFile(const FileName &path, bool readOnly)
|
||||
{
|
||||
return fopen(path, readOnly ? "rb" : "rb+");
|
||||
}
|
||||
|
||||
inline void closeFile(FileHandle file)
|
||||
void closeFile(FileHandle file)
|
||||
{
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
inline size_t readFile(FileHandle file, ByteVector &buffer)
|
||||
size_t readFile(FileHandle file, ByteVector &buffer)
|
||||
{
|
||||
return fread(buffer.data(), sizeof(char), buffer.size(), file);
|
||||
}
|
||||
|
||||
inline size_t writeFile(FileHandle file, const ByteVector &buffer)
|
||||
size_t writeFile(FileHandle file, const ByteVector &buffer)
|
||||
{
|
||||
return fwrite(buffer.data(), sizeof(char), buffer.size(), file);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
/***************************************************************************
|
||||
* This library is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* 2.1 as published by the Free Software Foundation. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, but *
|
||||
@@ -15,10 +15,15 @@
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library; if not, write to the Free Software *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, *
|
||||
* MA 02110-1301 USA *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||
* 02110-1301 USA *
|
||||
* *
|
||||
* Alternatively, this file is available under the Mozilla Public *
|
||||
* License Version 1.1. You may obtain a copy of the License at *
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "tpropertymap.h"
|
||||
using namespace TagLib;
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
/***************************************************************************
|
||||
* This library is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* 2.1 as published by the Free Software Foundation. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, but *
|
||||
@@ -15,8 +15,12 @@
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library; if not, write to the Free Software *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, *
|
||||
* MA 02110-1301 USA *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||
* 02110-1301 USA *
|
||||
* *
|
||||
* Alternatively, this file is available under the Mozilla Public *
|
||||
* License Version 1.1. You may obtain a copy of the License at *
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef TAGLIB_PROPERTYMAP_H_
|
||||
|
||||
@@ -25,16 +25,6 @@
|
||||
|
||||
// This class assumes that std::basic_string<T> has a contiguous and null-terminated buffer.
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "tstring.h"
|
||||
#include "tdebug.h"
|
||||
#include "tstringlist.h"
|
||||
#include "trefcounter.h"
|
||||
#include "tutils.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <cerrno>
|
||||
#include <climits>
|
||||
@@ -47,12 +37,18 @@
|
||||
# include "unicode.h"
|
||||
#endif
|
||||
|
||||
#include <tdebug.h>
|
||||
#include <tstringlist.h>
|
||||
#include <trefcounter.h>
|
||||
#include <tutils.h>
|
||||
|
||||
#include "tstring.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
using namespace TagLib;
|
||||
|
||||
inline size_t UTF16toUTF8(
|
||||
const wchar_t *src, size_t srcLength, char *dst, size_t dstLength)
|
||||
size_t UTF16toUTF8(const wchar_t *src, size_t srcLength, char *dst, size_t dstLength)
|
||||
{
|
||||
size_t len = 0;
|
||||
|
||||
@@ -84,8 +80,7 @@ namespace
|
||||
return len;
|
||||
}
|
||||
|
||||
inline size_t UTF8toUTF16(
|
||||
const char *src, size_t srcLength, wchar_t *dst, size_t dstLength)
|
||||
size_t UTF8toUTF16(const char *src, size_t srcLength, wchar_t *dst, size_t dstLength)
|
||||
{
|
||||
size_t len = 0;
|
||||
|
||||
@@ -118,7 +113,7 @@ namespace
|
||||
}
|
||||
|
||||
// Returns the native format of std::wstring.
|
||||
inline String::Type wcharByteOrder()
|
||||
String::Type wcharByteOrder()
|
||||
{
|
||||
if(Utils::systemByteOrder() == Utils::LittleEndian)
|
||||
return String::UTF16LE;
|
||||
@@ -128,7 +123,7 @@ namespace
|
||||
|
||||
// Converts a Latin-1 string into UTF-16(without BOM/CPU byte order)
|
||||
// and copies it to the internal buffer.
|
||||
inline void copyFromLatin1(std::wstring &data, const char *s, size_t length)
|
||||
void copyFromLatin1(std::wstring &data, const char *s, size_t length)
|
||||
{
|
||||
data.resize(length);
|
||||
|
||||
@@ -138,7 +133,7 @@ namespace
|
||||
|
||||
// Converts a UTF-8 string into UTF-16(without BOM/CPU byte order)
|
||||
// and copies it to the internal buffer.
|
||||
inline void copyFromUTF8(std::wstring &data, const char *s, size_t length)
|
||||
void copyFromUTF8(std::wstring &data, const char *s, size_t length)
|
||||
{
|
||||
data.resize(length);
|
||||
|
||||
@@ -150,7 +145,7 @@ namespace
|
||||
|
||||
// Converts a UTF-16 (with BOM), UTF-16LE or UTF16-BE string into
|
||||
// UTF-16(without BOM/CPU byte order) and copies it to the internal buffer.
|
||||
inline void copyFromUTF16(std::wstring &data, const wchar_t *s, size_t length, String::Type t)
|
||||
void copyFromUTF16(std::wstring &data, const wchar_t *s, size_t length, String::Type t)
|
||||
{
|
||||
bool swap;
|
||||
if(t == String::UTF16) {
|
||||
@@ -184,7 +179,7 @@ namespace
|
||||
|
||||
// Converts a UTF-16 (with BOM), UTF-16LE or UTF16-BE string into
|
||||
// UTF-16(without BOM/CPU byte order) and copies it to the internal buffer.
|
||||
inline void copyFromUTF16(std::wstring &data, const char *s, size_t length, String::Type t)
|
||||
void copyFromUTF16(std::wstring &data, const char *s, size_t length, String::Type t)
|
||||
{
|
||||
bool swap;
|
||||
if(t == String::UTF16) {
|
||||
|
||||
@@ -55,218 +55,237 @@ namespace TagLib
|
||||
{
|
||||
namespace Utils
|
||||
{
|
||||
|
||||
/*!
|
||||
* Reverses the order of bytes in an 16-bit integer.
|
||||
*/
|
||||
inline unsigned short byteSwap(unsigned short x)
|
||||
namespace
|
||||
{
|
||||
|
||||
/*!
|
||||
* Reverses the order of bytes in an 16-bit integer.
|
||||
*/
|
||||
inline unsigned short byteSwap(unsigned short x)
|
||||
{
|
||||
#if defined(HAVE_BOOST_BYTESWAP)
|
||||
|
||||
return boost::endian::endian_reverse(static_cast<uint16_t>(x));
|
||||
return boost::endian::endian_reverse(static_cast<uint16_t>(x));
|
||||
|
||||
#elif defined(HAVE_GCC_BYTESWAP)
|
||||
|
||||
return __builtin_bswap16(x);
|
||||
return __builtin_bswap16(x);
|
||||
|
||||
#elif defined(HAVE_MSC_BYTESWAP)
|
||||
|
||||
return _byteswap_ushort(x);
|
||||
return _byteswap_ushort(x);
|
||||
|
||||
#elif defined(HAVE_GLIBC_BYTESWAP)
|
||||
|
||||
return __bswap_16(x);
|
||||
return __bswap_16(x);
|
||||
|
||||
#elif defined(HAVE_MAC_BYTESWAP)
|
||||
|
||||
return OSSwapInt16(x);
|
||||
return OSSwapInt16(x);
|
||||
|
||||
#elif defined(HAVE_OPENBSD_BYTESWAP)
|
||||
|
||||
return swap16(x);
|
||||
return swap16(x);
|
||||
|
||||
#else
|
||||
|
||||
return ((x >> 8) & 0xff) | ((x & 0xff) << 8);
|
||||
return ((x >> 8) & 0xff) | ((x & 0xff) << 8);
|
||||
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* Reverses the order of bytes in an 32-bit integer.
|
||||
*/
|
||||
inline unsigned int byteSwap(unsigned int x)
|
||||
{
|
||||
/*!
|
||||
* Reverses the order of bytes in an 32-bit integer.
|
||||
*/
|
||||
inline unsigned int byteSwap(unsigned int x)
|
||||
{
|
||||
#if defined(HAVE_BOOST_BYTESWAP)
|
||||
|
||||
return boost::endian::endian_reverse(static_cast<uint32_t>(x));
|
||||
return boost::endian::endian_reverse(static_cast<uint32_t>(x));
|
||||
|
||||
#elif defined(HAVE_GCC_BYTESWAP)
|
||||
|
||||
return __builtin_bswap32(x);
|
||||
return __builtin_bswap32(x);
|
||||
|
||||
#elif defined(HAVE_MSC_BYTESWAP)
|
||||
|
||||
return _byteswap_ulong(x);
|
||||
return _byteswap_ulong(x);
|
||||
|
||||
#elif defined(HAVE_GLIBC_BYTESWAP)
|
||||
|
||||
return __bswap_32(x);
|
||||
return __bswap_32(x);
|
||||
|
||||
#elif defined(HAVE_MAC_BYTESWAP)
|
||||
|
||||
return OSSwapInt32(x);
|
||||
return OSSwapInt32(x);
|
||||
|
||||
#elif defined(HAVE_OPENBSD_BYTESWAP)
|
||||
|
||||
return swap32(x);
|
||||
return swap32(x);
|
||||
|
||||
#else
|
||||
|
||||
return ((x & 0xff000000u) >> 24)
|
||||
| ((x & 0x00ff0000u) >> 8)
|
||||
| ((x & 0x0000ff00u) << 8)
|
||||
| ((x & 0x000000ffu) << 24);
|
||||
return ((x & 0xff000000u) >> 24)
|
||||
| ((x & 0x00ff0000u) >> 8)
|
||||
| ((x & 0x0000ff00u) << 8)
|
||||
| ((x & 0x000000ffu) << 24);
|
||||
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* Reverses the order of bytes in an 64-bit integer.
|
||||
*/
|
||||
inline unsigned long long byteSwap(unsigned long long x)
|
||||
{
|
||||
/*!
|
||||
* Reverses the order of bytes in an 64-bit integer.
|
||||
*/
|
||||
inline unsigned long long byteSwap(unsigned long long x)
|
||||
{
|
||||
#if defined(HAVE_BOOST_BYTESWAP)
|
||||
|
||||
return boost::endian::endian_reverse(static_cast<uint64_t>(x));
|
||||
return boost::endian::endian_reverse(static_cast<uint64_t>(x));
|
||||
|
||||
#elif defined(HAVE_GCC_BYTESWAP)
|
||||
|
||||
return __builtin_bswap64(x);
|
||||
return __builtin_bswap64(x);
|
||||
|
||||
#elif defined(HAVE_MSC_BYTESWAP)
|
||||
|
||||
return _byteswap_uint64(x);
|
||||
return _byteswap_uint64(x);
|
||||
|
||||
#elif defined(HAVE_GLIBC_BYTESWAP)
|
||||
|
||||
return __bswap_64(x);
|
||||
return __bswap_64(x);
|
||||
|
||||
#elif defined(HAVE_MAC_BYTESWAP)
|
||||
|
||||
return OSSwapInt64(x);
|
||||
return OSSwapInt64(x);
|
||||
|
||||
#elif defined(HAVE_OPENBSD_BYTESWAP)
|
||||
|
||||
return swap64(x);
|
||||
return swap64(x);
|
||||
|
||||
#else
|
||||
|
||||
return ((x & 0xff00000000000000ull) >> 56)
|
||||
| ((x & 0x00ff000000000000ull) >> 40)
|
||||
| ((x & 0x0000ff0000000000ull) >> 24)
|
||||
| ((x & 0x000000ff00000000ull) >> 8)
|
||||
| ((x & 0x00000000ff000000ull) << 8)
|
||||
| ((x & 0x0000000000ff0000ull) << 24)
|
||||
| ((x & 0x000000000000ff00ull) << 40)
|
||||
| ((x & 0x00000000000000ffull) << 56);
|
||||
return ((x & 0xff00000000000000ull) >> 56)
|
||||
| ((x & 0x00ff000000000000ull) >> 40)
|
||||
| ((x & 0x0000ff0000000000ull) >> 24)
|
||||
| ((x & 0x000000ff00000000ull) >> 8)
|
||||
| ((x & 0x00000000ff000000ull) << 8)
|
||||
| ((x & 0x0000000000ff0000ull) << 24)
|
||||
| ((x & 0x000000000000ff00ull) << 40)
|
||||
| ((x & 0x00000000000000ffull) << 56);
|
||||
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* Returns a formatted string just like standard sprintf(), but makes use of
|
||||
* safer functions such as snprintf() if available.
|
||||
*/
|
||||
inline String formatString(const char *format, ...)
|
||||
{
|
||||
// Sufficient buffer size for the current internal uses.
|
||||
// Consider changing this value when you use this function.
|
||||
/*!
|
||||
* Returns a formatted string just like standard sprintf(), but makes use of
|
||||
* safer functions such as snprintf() if available.
|
||||
*/
|
||||
inline String formatString(const char *format, ...)
|
||||
{
|
||||
// Sufficient buffer size for the current internal uses.
|
||||
// Consider changing this value when you use this function.
|
||||
|
||||
static const size_t BufferSize = 128;
|
||||
static const size_t BufferSize = 128;
|
||||
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
|
||||
char buf[BufferSize];
|
||||
int length;
|
||||
char buf[BufferSize];
|
||||
int length;
|
||||
|
||||
#if defined(HAVE_VSNPRINTF)
|
||||
|
||||
length = vsnprintf(buf, BufferSize, format, args);
|
||||
length = vsnprintf(buf, BufferSize, format, args);
|
||||
|
||||
#elif defined(HAVE_VSPRINTF_S)
|
||||
|
||||
length = vsprintf_s(buf, format, args);
|
||||
length = vsprintf_s(buf, format, args);
|
||||
|
||||
#else
|
||||
|
||||
// The last resort. May cause a buffer overflow.
|
||||
// The last resort. May cause a buffer overflow.
|
||||
|
||||
length = vsprintf(buf, format, args);
|
||||
if(length >= BufferSize) {
|
||||
debug("Utils::formatString() - Buffer overflow! Returning an empty string.");
|
||||
length = -1;
|
||||
}
|
||||
length = vsprintf(buf, format, args);
|
||||
if(length >= BufferSize) {
|
||||
debug("Utils::formatString() - Buffer overflow! Returning an empty string.");
|
||||
length = -1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
va_end(args);
|
||||
va_end(args);
|
||||
|
||||
if(length > 0)
|
||||
return String(buf);
|
||||
else
|
||||
return String();
|
||||
if(length > 0)
|
||||
return String(buf);
|
||||
else
|
||||
return String();
|
||||
}
|
||||
|
||||
/*!
|
||||
* Returns whether the two strings s1 and s2 are equal, ignoring the case of
|
||||
* the characters.
|
||||
*
|
||||
* We took the trouble to define this one here, since there are some
|
||||
* incompatible variations of case insensitive strcmp().
|
||||
*/
|
||||
inline bool equalsIgnoreCase(const char *s1, const char *s2)
|
||||
{
|
||||
while(*s1 != '\0' && *s2 != '\0' && ::tolower(*s1) == ::tolower(*s2)) {
|
||||
s1++;
|
||||
s2++;
|
||||
}
|
||||
|
||||
return (*s1 == '\0' && *s2 == '\0');
|
||||
}
|
||||
|
||||
/*!
|
||||
* The types of byte order of the running system.
|
||||
*/
|
||||
enum ByteOrder
|
||||
{
|
||||
//! Little endian systems.
|
||||
LittleEndian,
|
||||
//! Big endian systems.
|
||||
BigEndian
|
||||
};
|
||||
|
||||
/*!
|
||||
* Returns the integer byte order of the system.
|
||||
*/
|
||||
inline ByteOrder systemByteOrder()
|
||||
{
|
||||
union {
|
||||
int i;
|
||||
char c;
|
||||
} u;
|
||||
|
||||
u.i = 1;
|
||||
if(u.c == 1)
|
||||
return LittleEndian;
|
||||
else
|
||||
return BigEndian;
|
||||
}
|
||||
|
||||
/*!
|
||||
* Returns the IEEE754 byte order of the system.
|
||||
*/
|
||||
inline ByteOrder floatByteOrder()
|
||||
{
|
||||
union {
|
||||
double d;
|
||||
char c;
|
||||
} u;
|
||||
|
||||
// 1.0 is stored in memory like 0x3FF0000000000000 in canonical form.
|
||||
// So the first byte is zero if little endian.
|
||||
|
||||
u.d = 1.0;
|
||||
if(u.c == 0)
|
||||
return LittleEndian;
|
||||
else
|
||||
return BigEndian;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* The types of byte order of the running system.
|
||||
*/
|
||||
enum ByteOrder
|
||||
{
|
||||
//! Little endian systems.
|
||||
LittleEndian,
|
||||
//! Big endian systems.
|
||||
BigEndian
|
||||
};
|
||||
|
||||
/*!
|
||||
* Returns the integer byte order of the system.
|
||||
*/
|
||||
inline ByteOrder systemByteOrder()
|
||||
{
|
||||
union {
|
||||
int i;
|
||||
char c;
|
||||
} u;
|
||||
|
||||
u.i = 1;
|
||||
if(u.c == 1)
|
||||
return LittleEndian;
|
||||
else
|
||||
return BigEndian;
|
||||
}
|
||||
|
||||
/*!
|
||||
* Returns the IEEE754 byte order of the system.
|
||||
*/
|
||||
inline ByteOrder floatByteOrder()
|
||||
{
|
||||
union {
|
||||
double d;
|
||||
char c;
|
||||
} u;
|
||||
|
||||
// 1.0 is stored in memory like 0x3FF0000000000000 in canonical form.
|
||||
// So the first byte is zero if little endian.
|
||||
|
||||
u.d = 1.0;
|
||||
if(u.c == 0)
|
||||
return LittleEndian;
|
||||
else
|
||||
return BigEndian;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
142
taglib/toolkit/tzlib.cpp
Normal file
142
taglib/toolkit/tzlib.cpp
Normal file
@@ -0,0 +1,142 @@
|
||||
/***************************************************************************
|
||||
copyright : (C) 2016 by Tsuda Kageyu
|
||||
email : tsuda.kageyu@gmail.com
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* This library is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* 2.1 as published by the Free Software Foundation. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, but *
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
|
||||
* Lesser General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library; if not, write to the Free Software *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||
* 02110-1301 USA *
|
||||
* *
|
||||
* Alternatively, this file is available under the Mozilla Public *
|
||||
* License Version 1.1. You may obtain a copy of the License at *
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_ZLIB)
|
||||
# include <zlib.h>
|
||||
#elif defined(HAVE_BOOST_ZLIB)
|
||||
# include <boost/iostreams/filtering_streambuf.hpp>
|
||||
# include <boost/iostreams/filter/zlib.hpp>
|
||||
#endif
|
||||
|
||||
#include <tstring.h>
|
||||
#include <tdebug.h>
|
||||
|
||||
#include "tzlib.h"
|
||||
|
||||
using namespace TagLib;
|
||||
|
||||
bool zlib::isAvailable()
|
||||
{
|
||||
#if defined(HAVE_ZLIB) || defined(HAVE_BOOST_ZLIB)
|
||||
|
||||
return true;
|
||||
|
||||
#else
|
||||
|
||||
return false;
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
ByteVector zlib::decompress(const ByteVector &data)
|
||||
{
|
||||
#if defined(HAVE_ZLIB)
|
||||
|
||||
z_stream stream = {};
|
||||
|
||||
if(inflateInit(&stream) != Z_OK) {
|
||||
debug("zlib::decompress() - Failed to initizlize zlib.");
|
||||
return ByteVector();
|
||||
}
|
||||
|
||||
ByteVector inData = data;
|
||||
|
||||
stream.avail_in = static_cast<uInt>(inData.size());
|
||||
stream.next_in = reinterpret_cast<Bytef *>(inData.data());
|
||||
|
||||
const unsigned int chunkSize = 1024;
|
||||
|
||||
ByteVector outData;
|
||||
|
||||
do {
|
||||
const size_t offset = outData.size();
|
||||
outData.resize(outData.size() + chunkSize);
|
||||
|
||||
stream.avail_out = static_cast<uInt>(chunkSize);
|
||||
stream.next_out = reinterpret_cast<Bytef *>(outData.data() + offset);
|
||||
|
||||
const int result = inflate(&stream, Z_NO_FLUSH);
|
||||
|
||||
if(result == Z_STREAM_ERROR ||
|
||||
result == Z_NEED_DICT ||
|
||||
result == Z_DATA_ERROR ||
|
||||
result == Z_MEM_ERROR)
|
||||
{
|
||||
if(result != Z_STREAM_ERROR)
|
||||
inflateEnd(&stream);
|
||||
|
||||
debug("zlib::decompress() - Error reading compressed stream.");
|
||||
return ByteVector();
|
||||
}
|
||||
|
||||
outData.resize(outData.size() - stream.avail_out);
|
||||
} while(stream.avail_out == 0);
|
||||
|
||||
inflateEnd(&stream);
|
||||
|
||||
return outData;
|
||||
|
||||
#elif defined(HAVE_BOOST_ZLIB)
|
||||
|
||||
using namespace boost::iostreams;
|
||||
|
||||
struct : public sink
|
||||
{
|
||||
ByteVector data;
|
||||
|
||||
typedef char char_type;
|
||||
typedef sink_tag category;
|
||||
|
||||
std::streamsize write(char const* s, std::streamsize n)
|
||||
{
|
||||
const unsigned int originalSize = data.size();
|
||||
|
||||
data.resize(static_cast<unsigned int>(originalSize + n));
|
||||
::memcpy(data.data() + originalSize, s, static_cast<size_t>(n));
|
||||
|
||||
return n;
|
||||
}
|
||||
} sink;
|
||||
|
||||
try {
|
||||
zlib_decompressor().write(sink, data.data(), data.size());
|
||||
}
|
||||
catch(const zlib_error &) {
|
||||
debug("zlib::decompress() - Error reading compressed stream.");
|
||||
return ByteVector();
|
||||
}
|
||||
|
||||
return sink.data;
|
||||
|
||||
#else
|
||||
|
||||
return ByteVector();
|
||||
|
||||
#endif
|
||||
}
|
||||
54
taglib/toolkit/tzlib.h
Normal file
54
taglib/toolkit/tzlib.h
Normal file
@@ -0,0 +1,54 @@
|
||||
/***************************************************************************
|
||||
copyright : (C) 2016 by Tsuda Kageyu
|
||||
email : tsuda.kageyu@gmail.com
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* This library is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* 2.1 as published by the Free Software Foundation. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, but *
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
|
||||
* Lesser General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library; if not, write to the Free Software *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||
* 02110-1301 USA *
|
||||
* *
|
||||
* Alternatively, this file is available under the Mozilla Public *
|
||||
* License Version 1.1. You may obtain a copy of the License at *
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef TAGLIB_TZLIB_H
|
||||
#define TAGLIB_TZLIB_H
|
||||
|
||||
#include <tbytevector.h>
|
||||
|
||||
// THIS FILE IS NOT A PART OF THE TAGLIB API
|
||||
|
||||
#ifndef DO_NOT_DOCUMENT // tell Doxygen not to document this header
|
||||
|
||||
namespace TagLib {
|
||||
|
||||
namespace zlib {
|
||||
|
||||
/*!
|
||||
* Returns whether or not zlib is installed and ready to use.
|
||||
*/
|
||||
bool isAvailable();
|
||||
|
||||
/*!
|
||||
* Decompress \a data by zlib.
|
||||
*/
|
||||
ByteVector decompress(const ByteVector &data);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
/***************************************************************************
|
||||
* This library is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* 2.1 as published by the Free Software Foundation. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, but *
|
||||
@@ -15,8 +15,12 @@
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library; if not, write to the Free Software *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, *
|
||||
* MA 02110-1301 USA *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||
* 02110-1301 USA *
|
||||
* *
|
||||
* Alternatively, this file is available under the Mozilla Public *
|
||||
* License Version 1.1. You may obtain a copy of the License at *
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include "tstringlist.h"
|
||||
@@ -130,7 +134,7 @@ public:
|
||||
if(index > -1) {
|
||||
data.resize(index);
|
||||
}
|
||||
data.replace((char) 0xff, ' ');
|
||||
data.replace('\xff', ' ');
|
||||
value = data;
|
||||
return count;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
/***************************************************************************
|
||||
* This library is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* 2.1 as published by the Free Software Foundation. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, but *
|
||||
@@ -15,8 +15,12 @@
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library; if not, write to the Free Software *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, *
|
||||
* MA 02110-1301 USA *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||
* 02110-1301 USA *
|
||||
* *
|
||||
* Alternatively, this file is available under the Mozilla Public *
|
||||
* License Version 1.1. You may obtain a copy of the License at *
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef TAGLIB_XMFILE_H
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
/***************************************************************************
|
||||
copyright :(C) 2011 by Mathias Panzenböck
|
||||
copyright : (C) 2011 by Mathias Panzenböck
|
||||
email : grosser.meister.morti@gmx.net
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* This library is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* 2.1 as published by the Free Software Foundation. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, but *
|
||||
@@ -15,10 +15,15 @@
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library; if not, write to the Free Software *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, *
|
||||
* MA 02110-1301 USA *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||
* 02110-1301 USA *
|
||||
* *
|
||||
* Alternatively, this file is available under the Mozilla Public *
|
||||
* License Version 1.1. You may obtain a copy of the License at *
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "xmproperties.h"
|
||||
|
||||
using namespace TagLib;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
/***************************************************************************
|
||||
* This library is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* 2.1 as published by the Free Software Foundation. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, but *
|
||||
@@ -15,8 +15,12 @@
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library; if not, write to the Free Software *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, *
|
||||
* MA 02110-1301 USA *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||
* 02110-1301 USA *
|
||||
* *
|
||||
* Alternatively, this file is available under the Mozilla Public *
|
||||
* License Version 1.1. You may obtain a copy of the License at *
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef TAGLIB_XMPROPERTIES_H
|
||||
|
||||
BIN
tests/data/pcm_with_fact_chunk.wav
Normal file
BIN
tests/data/pcm_with_fact_chunk.wav
Normal file
Binary file not shown.
@@ -1,3 +1,28 @@
|
||||
/***************************************************************************
|
||||
copyright : (C) 2007 by Lukas Lalinsky
|
||||
email : lukas@oxygene.sk
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* This library is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* 2.1 as published by the Free Software Foundation. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, but *
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
|
||||
* Lesser General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library; if not, write to the Free Software *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||
* 02110-1301 USA *
|
||||
* *
|
||||
* Alternatively, this file is available under the Mozilla Public *
|
||||
* License Version 1.1. You may obtain a copy of the License at *
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <fstream>
|
||||
|
||||
@@ -1,3 +1,28 @@
|
||||
/***************************************************************************
|
||||
copyright : (C) 2009 by Lukas Lalinsky
|
||||
email : lukas@oxygene.sk
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* This library is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* 2.1 as published by the Free Software Foundation. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, but *
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
|
||||
* Lesser General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library; if not, write to the Free Software *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||
* 02110-1301 USA *
|
||||
* *
|
||||
* Alternatively, this file is available under the Mozilla Public *
|
||||
* License Version 1.1. You may obtain a copy of the License at *
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include <string>
|
||||
#include <stdio.h>
|
||||
#include <tag.h>
|
||||
|
||||
@@ -1,3 +1,28 @@
|
||||
/***************************************************************************
|
||||
copyright : (C) 2010 by Lukas Lalinsky
|
||||
email : lukas@oxygene.sk
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* This library is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* 2.1 as published by the Free Software Foundation. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, but *
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
|
||||
* Lesser General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library; if not, write to the Free Software *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||
* 02110-1301 USA *
|
||||
* *
|
||||
* Alternatively, this file is available under the Mozilla Public *
|
||||
* License Version 1.1. You may obtain a copy of the License at *
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include <string>
|
||||
#include <stdio.h>
|
||||
#include <apetag.h>
|
||||
|
||||
@@ -1,3 +1,28 @@
|
||||
/***************************************************************************
|
||||
copyright : (C) 2010 by Lukas Lalinsky
|
||||
email : lukas@oxygene.sk
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* This library is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* 2.1 as published by the Free Software Foundation. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, but *
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
|
||||
* Lesser General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library; if not, write to the Free Software *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||
* 02110-1301 USA *
|
||||
* *
|
||||
* Alternatively, this file is available under the Mozilla Public *
|
||||
* License Version 1.1. You may obtain a copy of the License at *
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include <string>
|
||||
#include <stdio.h>
|
||||
#include <tag.h>
|
||||
@@ -97,6 +122,11 @@ public:
|
||||
CPPUNIT_ASSERT_EQUAL((unsigned int)2, unsuccessful.size());
|
||||
CPPUNIT_ASSERT(unsuccessful.contains("A"));
|
||||
CPPUNIT_ASSERT(unsuccessful.contains("MP+"));
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL((unsigned int)2, tag.itemListMap().size());
|
||||
tag.addValue("VALID KEY", "Test Value 1");
|
||||
tag.addValue("INVALID KEY \x7f", "Test Value 2");
|
||||
CPPUNIT_ASSERT_EQUAL((unsigned int)3, tag.itemListMap().size());
|
||||
}
|
||||
|
||||
void testTextBinary()
|
||||
|
||||
@@ -1,3 +1,28 @@
|
||||
/***************************************************************************
|
||||
copyright : (C) 2008 by Lukas Lalinsky
|
||||
email : lukas@oxygene.sk
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* This library is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* 2.1 as published by the Free Software Foundation. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, but *
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
|
||||
* Lesser General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library; if not, write to the Free Software *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||
* 02110-1301 USA *
|
||||
* *
|
||||
* Alternatively, this file is available under the Mozilla Public *
|
||||
* License Version 1.1. You may obtain a copy of the License at *
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include <string>
|
||||
#include <stdio.h>
|
||||
#include <tag.h>
|
||||
|
||||
@@ -1,28 +1,30 @@
|
||||
/* Copyright (C) 2003 Scott Wheeler <wheeler@kde.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/***************************************************************************
|
||||
copyright : (C) 2007 by Lukas Lalinsky
|
||||
email : lukas@oxygene.sk
|
||||
***************************************************************************/
|
||||
|
||||
#include <cstring>
|
||||
/***************************************************************************
|
||||
* This library is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* 2.1 as published by the Free Software Foundation. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, but *
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
|
||||
* Lesser General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library; if not, write to the Free Software *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||
* 02110-1301 USA *
|
||||
* *
|
||||
* Alternatively, this file is available under the Mozilla Public *
|
||||
* License Version 1.1. You may obtain a copy of the License at *
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#define _USE_MATH_DEFINES
|
||||
#include <cmath>
|
||||
#include <tbytevector.h>
|
||||
#include <tbytevectorlist.h>
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
@@ -36,90 +38,35 @@ class TestByteVector : public CppUnit::TestFixture
|
||||
CPPUNIT_TEST(testByteVector);
|
||||
CPPUNIT_TEST(testFind1);
|
||||
CPPUNIT_TEST(testFind2);
|
||||
CPPUNIT_TEST(testFind3);
|
||||
CPPUNIT_TEST(testRfind1);
|
||||
CPPUNIT_TEST(testRfind2);
|
||||
CPPUNIT_TEST(testRfind3);
|
||||
CPPUNIT_TEST(testToHex);
|
||||
CPPUNIT_TEST(testNumericCoversion);
|
||||
CPPUNIT_TEST(testIntegerConversion);
|
||||
CPPUNIT_TEST(testFloatingPointConversion);
|
||||
CPPUNIT_TEST(testReplace);
|
||||
CPPUNIT_TEST(testIterator);
|
||||
CPPUNIT_TEST(testResize);
|
||||
CPPUNIT_TEST(testAppend);
|
||||
CPPUNIT_TEST(testAppend1);
|
||||
CPPUNIT_TEST(testAppend2);
|
||||
CPPUNIT_TEST(testBase64);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
public:
|
||||
|
||||
void testConversion(unsigned int i, unsigned char a, unsigned char b, unsigned char c, unsigned char d)
|
||||
{
|
||||
ByteVector v(4, 0);
|
||||
|
||||
v[3] = a;
|
||||
v[2] = b;
|
||||
v[1] = c;
|
||||
v[0] = d;
|
||||
CPPUNIT_ASSERT(v.toUInt(false) == i);
|
||||
|
||||
v[0] = a;
|
||||
v[1] = b;
|
||||
v[2] = c;
|
||||
v[3] = d;
|
||||
CPPUNIT_ASSERT(v.toUInt() == i);
|
||||
}
|
||||
|
||||
void testByteVector()
|
||||
{
|
||||
ByteVector v("foobar");
|
||||
|
||||
CPPUNIT_ASSERT(v.find("ob") == 2);
|
||||
CPPUNIT_ASSERT(v.find('b') == 3);
|
||||
|
||||
ByteVector n(4, 0);
|
||||
n[0] = 1;
|
||||
CPPUNIT_ASSERT(n.toUInt(true) == 16777216);
|
||||
CPPUNIT_ASSERT(n.toUInt(false) == 1);
|
||||
CPPUNIT_ASSERT(ByteVector::fromUInt(16777216, true) == n);
|
||||
CPPUNIT_ASSERT(ByteVector::fromUInt(1, false) == n);
|
||||
|
||||
CPPUNIT_ASSERT(ByteVector::fromUInt(0xa0).toUInt() == 0xa0);
|
||||
|
||||
testConversion(0x000000a0, 0x00, 0x00, 0x00, 0xa0);
|
||||
testConversion(0xd50bf072, 0xd5, 0x0b, 0xf0, 0x72);
|
||||
|
||||
ByteVector intVector(2, 0);
|
||||
intVector[0] = char(0xfc);
|
||||
intVector[1] = char(0x00);
|
||||
CPPUNIT_ASSERT(intVector.toShort() == -1024);
|
||||
intVector[0] = char(0x04);
|
||||
intVector[1] = char(0x00);
|
||||
CPPUNIT_ASSERT(intVector.toShort() == 1024);
|
||||
|
||||
CPPUNIT_ASSERT(ByteVector::fromLongLong(1).toLongLong() == 1);
|
||||
CPPUNIT_ASSERT(ByteVector::fromLongLong(0).toLongLong() == 0);
|
||||
CPPUNIT_ASSERT(ByteVector::fromLongLong(0xffffffffffffffffLL).toLongLong() == -1);
|
||||
CPPUNIT_ASSERT(ByteVector::fromLongLong(0xfffffffffffffffeLL).toLongLong() == -2);
|
||||
CPPUNIT_ASSERT(ByteVector::fromLongLong(1024).toLongLong() == 1024);
|
||||
|
||||
ByteVector a1("foo");
|
||||
a1.append("bar");
|
||||
CPPUNIT_ASSERT(a1 == "foobar");
|
||||
|
||||
ByteVector a2("foo");
|
||||
a2.append("b");
|
||||
CPPUNIT_ASSERT(a2 == "foob");
|
||||
|
||||
ByteVector a3;
|
||||
a3.append("b");
|
||||
CPPUNIT_ASSERT(a3 == "b");
|
||||
|
||||
ByteVector s1("foo");
|
||||
CPPUNIT_ASSERT(ByteVectorList::split(s1, " ").size() == 1);
|
||||
|
||||
ByteVector s2("f");
|
||||
CPPUNIT_ASSERT(ByteVectorList::split(s2, " ").size() == 1);
|
||||
|
||||
CPPUNIT_ASSERT(ByteVector().size() == 0);
|
||||
CPPUNIT_ASSERT(ByteVector("asdf").clear().size() == 0);
|
||||
CPPUNIT_ASSERT(ByteVector("asdf").clear() == ByteVector());
|
||||
CPPUNIT_ASSERT(ByteVector().isEmpty());
|
||||
CPPUNIT_ASSERT_EQUAL(0U, ByteVector().size());
|
||||
CPPUNIT_ASSERT(ByteVector("asdf").clear().isEmpty());
|
||||
CPPUNIT_ASSERT_EQUAL(0U, ByteVector("asdf").clear().size());
|
||||
CPPUNIT_ASSERT_EQUAL(ByteVector(), ByteVector("asdf").clear());
|
||||
|
||||
ByteVector i("blah blah");
|
||||
ByteVector j("blah");
|
||||
@@ -160,6 +107,20 @@ public:
|
||||
CPPUNIT_ASSERT_EQUAL(-1, ByteVector("\x01\x02", 2).find("\x01\x03"));
|
||||
}
|
||||
|
||||
void testFind3()
|
||||
{
|
||||
CPPUNIT_ASSERT_EQUAL(4, ByteVector("....SggO."). find('S'));
|
||||
CPPUNIT_ASSERT_EQUAL(4, ByteVector("....SggO."). find('S', 0));
|
||||
CPPUNIT_ASSERT_EQUAL(4, ByteVector("....SggO."). find('S', 1));
|
||||
CPPUNIT_ASSERT_EQUAL(4, ByteVector("....SggO."). find('S', 2));
|
||||
CPPUNIT_ASSERT_EQUAL(4, ByteVector("....SggO."). find('S', 3));
|
||||
CPPUNIT_ASSERT_EQUAL(4, ByteVector("....SggO."). find('S', 4));
|
||||
CPPUNIT_ASSERT_EQUAL(-1, ByteVector("....SggO."). find('S', 5));
|
||||
CPPUNIT_ASSERT_EQUAL(-1, ByteVector("....SggO."). find('S', 6));
|
||||
CPPUNIT_ASSERT_EQUAL(-1, ByteVector("....SggO."). find('S', 7));
|
||||
CPPUNIT_ASSERT_EQUAL(-1, ByteVector("....SggO."). find('S', 8));
|
||||
}
|
||||
|
||||
void testRfind1()
|
||||
{
|
||||
CPPUNIT_ASSERT_EQUAL(1, ByteVector(".OggS....").rfind("OggS", 0));
|
||||
@@ -196,6 +157,20 @@ public:
|
||||
CPPUNIT_ASSERT_EQUAL(10, r4.rfind("OggS", 12));
|
||||
}
|
||||
|
||||
void testRfind3()
|
||||
{
|
||||
CPPUNIT_ASSERT_EQUAL(1, ByteVector(".OggS....").rfind('O', 0));
|
||||
CPPUNIT_ASSERT_EQUAL(1, ByteVector(".OggS....").rfind('O', 1));
|
||||
CPPUNIT_ASSERT_EQUAL(1, ByteVector(".OggS....").rfind('O', 2));
|
||||
CPPUNIT_ASSERT_EQUAL(1, ByteVector(".OggS....").rfind('O', 3));
|
||||
CPPUNIT_ASSERT_EQUAL(1, ByteVector(".OggS....").rfind('O', 4));
|
||||
CPPUNIT_ASSERT_EQUAL(1, ByteVector(".OggS....").rfind('O', 5));
|
||||
CPPUNIT_ASSERT_EQUAL(1, ByteVector(".OggS....").rfind('O', 6));
|
||||
CPPUNIT_ASSERT_EQUAL(1, ByteVector(".OggS....").rfind('O', 7));
|
||||
CPPUNIT_ASSERT_EQUAL(1, ByteVector(".OggS....").rfind('O', 8));
|
||||
CPPUNIT_ASSERT_EQUAL(1, ByteVector(".OggS....").rfind('O'));
|
||||
}
|
||||
|
||||
void testToHex()
|
||||
{
|
||||
ByteVector v("\xf0\xe1\xd2\xc3\xb4\xa5\x96\x87\x78\x69\x5a\x4b\x3c\x2d\x1e\x0f", 16);
|
||||
@@ -203,50 +178,71 @@ public:
|
||||
CPPUNIT_ASSERT_EQUAL(ByteVector("f0e1d2c3b4a5968778695a4b3c2d1e0f"), v.toHex());
|
||||
}
|
||||
|
||||
void testNumericCoversion()
|
||||
void testIntegerConversion()
|
||||
{
|
||||
CPPUNIT_ASSERT_EQUAL((unsigned short)0xFFFF, ByteVector("\xff\xff", 2).toUShort());
|
||||
CPPUNIT_ASSERT_EQUAL((unsigned short)0x0001, ByteVector("\x00\x01", 2).toUShort());
|
||||
CPPUNIT_ASSERT_EQUAL((unsigned short)0x0100, ByteVector("\x00\x01", 2).toUShort(false));
|
||||
CPPUNIT_ASSERT_EQUAL((unsigned short)0xFF01, ByteVector("\xFF\x01", 2).toUShort());
|
||||
CPPUNIT_ASSERT_EQUAL((unsigned short)0x01FF, ByteVector("\xFF\x01", 2).toUShort(false));
|
||||
const ByteVector data("\x00\xff\x01\xff\x00\xff\x01\xff\x00\xff\x01\xff\x00\xff", 14);
|
||||
|
||||
const unsigned char PI32LE[] = { 0x00, 0xdb, 0x0f, 0x49, 0x40 };
|
||||
const unsigned char PI32BE[] = { 0x00, 0x40, 0x49, 0x0f, 0xdb };
|
||||
const unsigned char PI64LE[] = { 0x00, 0x18, 0x2d, 0x44, 0x54, 0xfb, 0x21, 0x09, 0x40 };
|
||||
const unsigned char PI64BE[] = { 0x00, 0x40, 0x09, 0x21, 0xfb, 0x54, 0x44, 0x2d, 0x18 };
|
||||
const unsigned char PI80LE[] = { 0x00, 0x00, 0xc0, 0x68, 0x21, 0xa2, 0xda, 0x0f, 0xc9, 0x00, 0x40 };
|
||||
const unsigned char PI80BE[] = { 0x00, 0x40, 0x00, 0xc9, 0x0f, 0xda, 0xa2, 0x21, 0x68, 0xc0, 0x00 };
|
||||
CPPUNIT_ASSERT_EQUAL((short)0x00ff, data.toShort());
|
||||
CPPUNIT_ASSERT_EQUAL((short)0xff00, data.toShort(false));
|
||||
CPPUNIT_ASSERT_EQUAL((short)0xff01, data.toShort(5U));
|
||||
CPPUNIT_ASSERT_EQUAL((short)0x01ff, data.toShort(5U, false));
|
||||
CPPUNIT_ASSERT_EQUAL((short)0xff, data.toShort(13U));
|
||||
CPPUNIT_ASSERT_EQUAL((short)0xff, data.toShort(13U, false));
|
||||
|
||||
ByteVector pi32le(reinterpret_cast<const char*>(PI32LE), 5);
|
||||
CPPUNIT_ASSERT_EQUAL(31415, static_cast<int>(pi32le.toFloat32LE(1) * 10000));
|
||||
CPPUNIT_ASSERT_EQUAL((unsigned short)0x00ff, data.toUShort());
|
||||
CPPUNIT_ASSERT_EQUAL((unsigned short)0xff00, data.toUShort(false));
|
||||
CPPUNIT_ASSERT_EQUAL((unsigned short)0xff01, data.toUShort(5U));
|
||||
CPPUNIT_ASSERT_EQUAL((unsigned short)0x01ff, data.toUShort(5U, false));
|
||||
CPPUNIT_ASSERT_EQUAL((unsigned short)0xff, data.toUShort(13U));
|
||||
CPPUNIT_ASSERT_EQUAL((unsigned short)0xff, data.toUShort(13U, false));
|
||||
|
||||
ByteVector pi32be(reinterpret_cast<const char*>(PI32BE), 5);
|
||||
CPPUNIT_ASSERT_EQUAL(31415, static_cast<int>(pi32be.toFloat32BE(1) * 10000));
|
||||
CPPUNIT_ASSERT_EQUAL(0x00ff01ffU, data.toUInt());
|
||||
CPPUNIT_ASSERT_EQUAL(0xff01ff00U, data.toUInt(false));
|
||||
CPPUNIT_ASSERT_EQUAL(0xff01ff00U, data.toUInt(5U));
|
||||
CPPUNIT_ASSERT_EQUAL(0x00ff01ffU, data.toUInt(5U, false));
|
||||
CPPUNIT_ASSERT_EQUAL(0x00ffU, data.toUInt(12U));
|
||||
CPPUNIT_ASSERT_EQUAL(0xff00U, data.toUInt(12U, false));
|
||||
|
||||
ByteVector pi64le(reinterpret_cast<const char*>(PI64LE), 9);
|
||||
CPPUNIT_ASSERT_EQUAL(31415, static_cast<int>(pi64le.toFloat64LE(1) * 10000));
|
||||
CPPUNIT_ASSERT_EQUAL(0x00ff01U, data.toUInt(0U, 3U));
|
||||
CPPUNIT_ASSERT_EQUAL(0x01ff00U, data.toUInt(0U, 3U, false));
|
||||
CPPUNIT_ASSERT_EQUAL(0xff01ffU, data.toUInt(5U, 3U));
|
||||
CPPUNIT_ASSERT_EQUAL(0xff01ffU, data.toUInt(5U, 3U, false));
|
||||
CPPUNIT_ASSERT_EQUAL(0x00ffU, data.toUInt(12U, 3U));
|
||||
CPPUNIT_ASSERT_EQUAL(0xff00U, data.toUInt(12U, 3U, false));
|
||||
|
||||
ByteVector pi64be(reinterpret_cast<const char*>(PI64BE), 9);
|
||||
CPPUNIT_ASSERT_EQUAL(31415, static_cast<int>(pi64be.toFloat64BE(1) * 10000));
|
||||
CPPUNIT_ASSERT_EQUAL((long long)0x00ff01ff00ff01ffULL, data.toLongLong());
|
||||
CPPUNIT_ASSERT_EQUAL((long long)0xff01ff00ff01ff00ULL, data.toLongLong(false));
|
||||
CPPUNIT_ASSERT_EQUAL((long long)0xff01ff00ff01ff00ULL, data.toLongLong(5U));
|
||||
CPPUNIT_ASSERT_EQUAL((long long)0x00ff01ff00ff01ffULL, data.toLongLong(5U, false));
|
||||
CPPUNIT_ASSERT_EQUAL((long long)0x00ffU, data.toLongLong(12U));
|
||||
CPPUNIT_ASSERT_EQUAL((long long)0xff00U, data.toLongLong(12U, false));
|
||||
}
|
||||
|
||||
ByteVector pi80le(reinterpret_cast<const char*>(PI80LE), 11);
|
||||
CPPUNIT_ASSERT_EQUAL(31415, static_cast<int>(pi80le.toFloat80LE(1) * 10000));
|
||||
void testFloatingPointConversion()
|
||||
{
|
||||
const double Tolerance = 1.0e-7;
|
||||
|
||||
ByteVector pi80be(reinterpret_cast<const char*>(PI80BE), 11);
|
||||
CPPUNIT_ASSERT_EQUAL(31415, static_cast<int>(pi80be.toFloat80BE(1) * 10000));
|
||||
const ByteVector pi32le("\xdb\x0f\x49\x40", 4);
|
||||
CPPUNIT_ASSERT(::abs(pi32le.toFloat32LE(0) - M_PI) < Tolerance);
|
||||
CPPUNIT_ASSERT_EQUAL(pi32le, ByteVector::fromFloat32LE(pi32le.toFloat32LE(0)));
|
||||
|
||||
ByteVector pi32le2 = ByteVector::fromFloat32LE(pi32le.toFloat32LE(1));
|
||||
CPPUNIT_ASSERT(memcmp(pi32le.data() + 1, pi32le2.data(), 4) == 0);
|
||||
const ByteVector pi32be("\x40\x49\x0f\xdb", 4);
|
||||
CPPUNIT_ASSERT(::abs(pi32be.toFloat32BE(0) - M_PI) < Tolerance);
|
||||
CPPUNIT_ASSERT_EQUAL(pi32be, ByteVector::fromFloat32BE(pi32be.toFloat32BE(0)));
|
||||
|
||||
ByteVector pi32be2 = ByteVector::fromFloat32BE(pi32be.toFloat32BE(1));
|
||||
CPPUNIT_ASSERT(memcmp(pi32be.data() + 1, pi32be2.data(), 4) == 0);
|
||||
const ByteVector pi64le("\x18\x2d\x44\x54\xfb\x21\x09\x40", 8);
|
||||
CPPUNIT_ASSERT(::abs(pi64le.toFloat64LE(0) - M_PI) < Tolerance);
|
||||
CPPUNIT_ASSERT_EQUAL(pi64le, ByteVector::fromFloat64LE(pi64le.toFloat64LE(0)));
|
||||
|
||||
ByteVector pi64le2 = ByteVector::fromFloat64LE(pi64le.toFloat64LE(1));
|
||||
CPPUNIT_ASSERT(memcmp(pi64le.data() + 1, pi64le2.data(), 8) == 0);
|
||||
const ByteVector pi64be("\x40\x09\x21\xfb\x54\x44\x2d\x18", 8);
|
||||
CPPUNIT_ASSERT(::abs(pi64be.toFloat64BE(0) - M_PI) < Tolerance);
|
||||
CPPUNIT_ASSERT_EQUAL(pi64be, ByteVector::fromFloat64BE(pi64be.toFloat64BE(0)));
|
||||
|
||||
ByteVector pi64be2 = ByteVector::fromFloat64BE(pi64be.toFloat64BE(1));
|
||||
CPPUNIT_ASSERT(memcmp(pi64be.data() + 1, pi64be2.data(), 8) == 0);
|
||||
const ByteVector pi80le("\x00\xc0\x68\x21\xa2\xda\x0f\xc9\x00\x40", 10);
|
||||
CPPUNIT_ASSERT(::abs(pi80le.toFloat80LE(0) - M_PI) < Tolerance);
|
||||
|
||||
const ByteVector pi80be("\x40\x00\xc9\x0f\xda\xa2\x21\x68\xc0\x00", 10);
|
||||
CPPUNIT_ASSERT(::abs(pi80be.toFloat80BE(0) - M_PI) < Tolerance);
|
||||
}
|
||||
|
||||
void testReplace()
|
||||
@@ -270,31 +266,50 @@ public:
|
||||
ByteVector a("abcdabf");
|
||||
a.replace(ByteVector("a"), ByteVector("x"));
|
||||
CPPUNIT_ASSERT_EQUAL(ByteVector("xbcdxbf"), a);
|
||||
a.replace(ByteVector("x"), ByteVector("a"));
|
||||
CPPUNIT_ASSERT_EQUAL(ByteVector("abcdabf"), a);
|
||||
}
|
||||
{
|
||||
ByteVector a("abcdabf");
|
||||
a.replace('a', 'x');
|
||||
CPPUNIT_ASSERT_EQUAL(ByteVector("xbcdxbf"), a);
|
||||
a.replace('x', 'a');
|
||||
CPPUNIT_ASSERT_EQUAL(ByteVector("abcdabf"), a);
|
||||
}
|
||||
{
|
||||
ByteVector a("abcdabf");
|
||||
a.replace(ByteVector("ab"), ByteVector("xy"));
|
||||
CPPUNIT_ASSERT_EQUAL(ByteVector("xycdxyf"), a);
|
||||
a.replace(ByteVector("xy"), ByteVector("ab"));
|
||||
CPPUNIT_ASSERT_EQUAL(ByteVector("abcdabf"), a);
|
||||
}
|
||||
{
|
||||
ByteVector a("abcdabf");
|
||||
a.replace(ByteVector("a"), ByteVector("<a>"));
|
||||
CPPUNIT_ASSERT_EQUAL(ByteVector("<a>bcd<a>bf"), a);
|
||||
a.replace(ByteVector("<a>"), ByteVector("a"));
|
||||
CPPUNIT_ASSERT_EQUAL(ByteVector("abcdabf"), a);
|
||||
}
|
||||
{
|
||||
ByteVector a("abcdabf");
|
||||
a.replace(ByteVector("ab"), ByteVector("x"));
|
||||
CPPUNIT_ASSERT_EQUAL(ByteVector("xcdxf"), a);
|
||||
a.replace(ByteVector("b"), ByteVector("<b>"));
|
||||
CPPUNIT_ASSERT_EQUAL(ByteVector("a<b>cda<b>f"), a);
|
||||
a.replace(ByteVector("<b>"), ByteVector("b"));
|
||||
CPPUNIT_ASSERT_EQUAL(ByteVector("abcdabf"), a);
|
||||
}
|
||||
{
|
||||
ByteVector a("abcdabf");
|
||||
a.replace(ByteVector("ab"), ByteVector());
|
||||
CPPUNIT_ASSERT_EQUAL(ByteVector("cdf"), a);
|
||||
ByteVector a("abcdabc");
|
||||
a.replace(ByteVector("c"), ByteVector("<c>"));
|
||||
CPPUNIT_ASSERT_EQUAL(ByteVector("ab<c>dab<c>"), a);
|
||||
a.replace(ByteVector("<c>"), ByteVector("c"));
|
||||
CPPUNIT_ASSERT_EQUAL(ByteVector("abcdabc"), a);
|
||||
}
|
||||
{
|
||||
ByteVector a("abcdabf");
|
||||
a.replace(ByteVector("bf"), ByteVector("x"));
|
||||
CPPUNIT_ASSERT_EQUAL(ByteVector("abcdax"), a);
|
||||
ByteVector a("abcdaba");
|
||||
a.replace(ByteVector("a"), ByteVector("<a>"));
|
||||
CPPUNIT_ASSERT_EQUAL(ByteVector("<a>bcd<a>b<a>"), a);
|
||||
a.replace(ByteVector("<a>"), ByteVector("a"));
|
||||
CPPUNIT_ASSERT_EQUAL(ByteVector("abcdaba"), a);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -389,18 +404,49 @@ public:
|
||||
CPPUNIT_ASSERT_EQUAL(-1, c.find('C'));
|
||||
}
|
||||
|
||||
void testAppend()
|
||||
void testAppend1()
|
||||
{
|
||||
ByteVector v1("taglib");
|
||||
ByteVector v2 = v1;
|
||||
ByteVector v1("foo");
|
||||
v1.append("bar");
|
||||
CPPUNIT_ASSERT_EQUAL(ByteVector("foobar"), v1);
|
||||
|
||||
v1.append("ABC");
|
||||
CPPUNIT_ASSERT_EQUAL(ByteVector("taglibABC"), v1);
|
||||
v1.append('1');
|
||||
v1.append('2');
|
||||
v1.append('3');
|
||||
CPPUNIT_ASSERT_EQUAL(ByteVector("taglibABC123"), v1);
|
||||
CPPUNIT_ASSERT_EQUAL(ByteVector("taglib"), v2);
|
||||
ByteVector v2("foo");
|
||||
v2.append("b");
|
||||
CPPUNIT_ASSERT_EQUAL(ByteVector("foob"), v2);
|
||||
|
||||
ByteVector v3;
|
||||
v3.append("b");
|
||||
CPPUNIT_ASSERT_EQUAL(ByteVector("b"), v3);
|
||||
|
||||
ByteVector v4("foo");
|
||||
v4.append(v1);
|
||||
CPPUNIT_ASSERT_EQUAL(ByteVector("foofoobar"), v4);
|
||||
|
||||
ByteVector v5("foo");
|
||||
v5.append('b');
|
||||
CPPUNIT_ASSERT_EQUAL(ByteVector("foob"), v5);
|
||||
|
||||
ByteVector v6;
|
||||
v6.append('b');
|
||||
CPPUNIT_ASSERT_EQUAL(ByteVector("b"), v6);
|
||||
|
||||
ByteVector v7("taglib");
|
||||
ByteVector v8 = v7;
|
||||
|
||||
v7.append("ABC");
|
||||
CPPUNIT_ASSERT_EQUAL(ByteVector("taglibABC"), v7);
|
||||
v7.append('1');
|
||||
v7.append('2');
|
||||
v7.append('3');
|
||||
CPPUNIT_ASSERT_EQUAL(ByteVector("taglibABC123"), v7);
|
||||
CPPUNIT_ASSERT_EQUAL(ByteVector("taglib"), v8);
|
||||
}
|
||||
|
||||
void testAppend2()
|
||||
{
|
||||
ByteVector a("1234");
|
||||
a.append(a);
|
||||
CPPUNIT_ASSERT_EQUAL(ByteVector("12341234"), a);
|
||||
}
|
||||
|
||||
void testBase64()
|
||||
@@ -428,7 +474,7 @@ public:
|
||||
CPPUNIT_ASSERT_EQUAL(e3, s3.toBase64());
|
||||
|
||||
// Decode
|
||||
CPPUNIT_ASSERT_EQUAL(sempty, eempty.toBase64());
|
||||
CPPUNIT_ASSERT_EQUAL(sempty, ByteVector::fromBase64(eempty));
|
||||
CPPUNIT_ASSERT_EQUAL(s0, ByteVector::fromBase64(e0));
|
||||
CPPUNIT_ASSERT_EQUAL(s1, ByteVector::fromBase64(e1));
|
||||
CPPUNIT_ASSERT_EQUAL(s2, ByteVector::fromBase64(e2));
|
||||
|
||||
@@ -1,3 +1,28 @@
|
||||
/***************************************************************************
|
||||
copyright : (C) 2009 by Lukas Lalinsky
|
||||
email : lukas@oxygene.sk
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* This library is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* 2.1 as published by the Free Software Foundation. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, but *
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
|
||||
* Lesser General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library; if not, write to the Free Software *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||
* 02110-1301 USA *
|
||||
* *
|
||||
* Alternatively, this file is available under the Mozilla Public *
|
||||
* License Version 1.1. You may obtain a copy of the License at *
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include <tbytevector.h>
|
||||
#include <tbytevectorlist.h>
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
@@ -1,3 +1,28 @@
|
||||
/***************************************************************************
|
||||
copyright : (C) 2011 by Lukas Lalinsky
|
||||
email : lukas@oxygene.sk
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* This library is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* 2.1 as published by the Free Software Foundation. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, but *
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
|
||||
* Lesser General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library; if not, write to the Free Software *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||
* 02110-1301 USA *
|
||||
* *
|
||||
* Alternatively, this file is available under the Mozilla Public *
|
||||
* License Version 1.1. You may obtain a copy of the License at *
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include <tbytevectorstream.h>
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
/***************************************************************************
|
||||
copyright : (C) 2014 by Lukas Lalinsky
|
||||
email : lukas@oxygene.sk
|
||||
copyright : (C) 2015 by Tsuda Kageyu
|
||||
email : tsuda.kageyu@gmail.com
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* This library is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* 2.1 as published by the Free Software Foundation. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, but *
|
||||
@@ -15,8 +15,12 @@
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library; if not, write to the Free Software *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, *
|
||||
* MA 02110-1301 USA *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||
* 02110-1301 USA *
|
||||
* *
|
||||
* Alternatively, this file is available under the Mozilla Public *
|
||||
* License Version 1.1. You may obtain a copy of the License at *
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include <tfile.h>
|
||||
|
||||
@@ -1,3 +1,28 @@
|
||||
/***************************************************************************
|
||||
copyright : (C) 2007 by Lukas Lalinsky
|
||||
email : lukas@oxygene.sk
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* This library is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* 2.1 as published by the Free Software Foundation. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, but *
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
|
||||
* Lesser General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library; if not, write to the Free Software *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||
* 02110-1301 USA *
|
||||
* *
|
||||
* Alternatively, this file is available under the Mozilla Public *
|
||||
* License Version 1.1. You may obtain a copy of the License at *
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include <string>
|
||||
#include <stdio.h>
|
||||
#include <tag.h>
|
||||
@@ -5,6 +30,15 @@
|
||||
#include <oggflacfile.h>
|
||||
#include <vorbisfile.h>
|
||||
#include <mpegfile.h>
|
||||
#include <mpcfile.h>
|
||||
#include <asffile.h>
|
||||
#include <speexfile.h>
|
||||
#include <flacfile.h>
|
||||
#include <trueaudiofile.h>
|
||||
#include <mp4file.h>
|
||||
#include <wavfile.h>
|
||||
#include <apefile.h>
|
||||
#include <aifffile.h>
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
#include "utils.h"
|
||||
#include <tfilestream.h>
|
||||
@@ -42,12 +76,15 @@ class TestFileRef : public CppUnit::TestFixture
|
||||
CPPUNIT_TEST(testTrueAudio);
|
||||
CPPUNIT_TEST(testAPE);
|
||||
CPPUNIT_TEST(testWav);
|
||||
CPPUNIT_TEST(testAIFF_1);
|
||||
CPPUNIT_TEST(testAIFF_2);
|
||||
CPPUNIT_TEST(testUnsupported);
|
||||
CPPUNIT_TEST(testFileResolver);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
public:
|
||||
|
||||
template <typename T>
|
||||
void fileRefSave(const string &filename, const string &ext)
|
||||
{
|
||||
ScopedFileCopy copy(filename, ext);
|
||||
@@ -55,6 +92,7 @@ public:
|
||||
|
||||
{
|
||||
FileRef f(newname.c_str());
|
||||
CPPUNIT_ASSERT(dynamic_cast<T*>(f.file()));
|
||||
CPPUNIT_ASSERT(!f.isNull());
|
||||
f.tag()->setArtist("test artist");
|
||||
f.tag()->setTitle("test title");
|
||||
@@ -94,6 +132,7 @@ public:
|
||||
{
|
||||
FileStream fs(newname.c_str());
|
||||
FileRef f(&fs);
|
||||
CPPUNIT_ASSERT(dynamic_cast<T*>(f.file()));
|
||||
CPPUNIT_ASSERT(!f.isNull());
|
||||
CPPUNIT_ASSERT_EQUAL(f.tag()->artist(), String("ttest artist"));
|
||||
CPPUNIT_ASSERT_EQUAL(f.tag()->title(), String("ytest title"));
|
||||
@@ -106,81 +145,87 @@ public:
|
||||
|
||||
void testMusepack()
|
||||
{
|
||||
fileRefSave("click", ".mpc");
|
||||
fileRefSave<MPC::File>("click", ".mpc");
|
||||
}
|
||||
|
||||
void testASF()
|
||||
{
|
||||
fileRefSave("silence-1", ".wma");
|
||||
fileRefSave<ASF::File>("silence-1", ".wma");
|
||||
}
|
||||
|
||||
void testVorbis()
|
||||
{
|
||||
fileRefSave("empty", ".ogg");
|
||||
fileRefSave<Ogg::Vorbis::File>("empty", ".ogg");
|
||||
}
|
||||
|
||||
void testSpeex()
|
||||
{
|
||||
fileRefSave("empty", ".spx");
|
||||
fileRefSave<Ogg::Speex::File>("empty", ".spx");
|
||||
}
|
||||
|
||||
void testFLAC()
|
||||
{
|
||||
fileRefSave("no-tags", ".flac");
|
||||
fileRefSave<FLAC::File>("no-tags", ".flac");
|
||||
}
|
||||
|
||||
void testMP3()
|
||||
{
|
||||
fileRefSave("xing", ".mp3");
|
||||
fileRefSave<MPEG::File>("xing", ".mp3");
|
||||
}
|
||||
|
||||
void testTrueAudio()
|
||||
{
|
||||
fileRefSave("empty", ".tta");
|
||||
fileRefSave<TrueAudio::File>("empty", ".tta");
|
||||
}
|
||||
|
||||
void testMP4_1()
|
||||
{
|
||||
fileRefSave("has-tags", ".m4a");
|
||||
fileRefSave<MP4::File>("has-tags", ".m4a");
|
||||
}
|
||||
|
||||
void testMP4_2()
|
||||
{
|
||||
fileRefSave("no-tags", ".m4a");
|
||||
fileRefSave<MP4::File>("no-tags", ".m4a");
|
||||
}
|
||||
|
||||
void testMP4_3()
|
||||
{
|
||||
fileRefSave("no-tags", ".3g2");
|
||||
fileRefSave<MP4::File>("no-tags", ".3g2");
|
||||
}
|
||||
|
||||
void testMP4_4()
|
||||
{
|
||||
fileRefSave("blank_video", ".m4v");
|
||||
fileRefSave<MP4::File>("blank_video", ".m4v");
|
||||
}
|
||||
|
||||
void testWav()
|
||||
{
|
||||
fileRefSave("empty", ".wav");
|
||||
fileRefSave<RIFF::WAV::File>("empty", ".wav");
|
||||
}
|
||||
|
||||
void testOGA_FLAC()
|
||||
{
|
||||
FileRef f(TEST_FILE_PATH_C("empty_flac.oga"));
|
||||
CPPUNIT_ASSERT(dynamic_cast<Ogg::Vorbis::File *>(f.file()) == NULL);
|
||||
CPPUNIT_ASSERT(dynamic_cast<Ogg::FLAC::File *>(f.file()) != NULL);
|
||||
fileRefSave<Ogg::FLAC::File>("empty_flac", ".oga");
|
||||
}
|
||||
|
||||
void testOGA_Vorbis()
|
||||
{
|
||||
FileRef f(TEST_FILE_PATH_C("empty_vorbis.oga"));
|
||||
CPPUNIT_ASSERT(dynamic_cast<Ogg::Vorbis::File *>(f.file()) != NULL);
|
||||
CPPUNIT_ASSERT(dynamic_cast<Ogg::FLAC::File *>(f.file()) == NULL);
|
||||
fileRefSave<Ogg::Vorbis::File>("empty_vorbis", ".oga");
|
||||
}
|
||||
|
||||
void testAPE()
|
||||
{
|
||||
fileRefSave("mac-399", ".ape");
|
||||
fileRefSave<APE::File>("mac-399", ".ape");
|
||||
}
|
||||
|
||||
void testAIFF_1()
|
||||
{
|
||||
fileRefSave<RIFF::AIFF::File>("empty", ".aiff");
|
||||
}
|
||||
|
||||
void testAIFF_2()
|
||||
{
|
||||
fileRefSave<RIFF::AIFF::File>("alaw", ".aifc");
|
||||
}
|
||||
|
||||
void testUnsupported()
|
||||
|
||||
@@ -1,3 +1,28 @@
|
||||
/***************************************************************************
|
||||
copyright : (C) 2009 by Lukas Lalinsky
|
||||
email : lukas@oxygene.sk
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* This library is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* 2.1 as published by the Free Software Foundation. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, but *
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
|
||||
* Lesser General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library; if not, write to the Free Software *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||
* 02110-1301 USA *
|
||||
* *
|
||||
* Alternatively, this file is available under the Mozilla Public *
|
||||
* License Version 1.1. You may obtain a copy of the License at *
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include <string>
|
||||
#include <stdio.h>
|
||||
#include <tag.h>
|
||||
|
||||
@@ -1,3 +1,28 @@
|
||||
/***************************************************************************
|
||||
copyright : (C) 2010 by Lukas Lalinsky
|
||||
email : lukas@oxygene.sk
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* This library is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* 2.1 as published by the Free Software Foundation. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, but *
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
|
||||
* Lesser General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library; if not, write to the Free Software *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||
* 02110-1301 USA *
|
||||
* *
|
||||
* Alternatively, this file is available under the Mozilla Public *
|
||||
* License Version 1.1. You may obtain a copy of the License at *
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include <string>
|
||||
#include <stdio.h>
|
||||
#include <tag.h>
|
||||
|
||||
@@ -1,3 +1,28 @@
|
||||
/***************************************************************************
|
||||
copyright : (C) 2012 by Lukas Lalinsky
|
||||
email : lukas@oxygene.sk
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* This library is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* 2.1 as published by the Free Software Foundation. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, but *
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
|
||||
* Lesser General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library; if not, write to the Free Software *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||
* 02110-1301 USA *
|
||||
* *
|
||||
* Alternatively, this file is available under the Mozilla Public *
|
||||
* License Version 1.1. You may obtain a copy of the License at *
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include <string>
|
||||
#include <stdio.h>
|
||||
#include <tag.h>
|
||||
|
||||
@@ -1,3 +1,28 @@
|
||||
/***************************************************************************
|
||||
copyright : (C) 2007 by Lukas Lalinsky
|
||||
email : lukas@oxygene.sk
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* This library is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* 2.1 as published by the Free Software Foundation. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, but *
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
|
||||
* Lesser General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library; if not, write to the Free Software *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||
* 02110-1301 USA *
|
||||
* *
|
||||
* Alternatively, this file is available under the Mozilla Public *
|
||||
* License Version 1.1. You may obtain a copy of the License at *
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include <string>
|
||||
#include <stdio.h>
|
||||
#include <tstring.h>
|
||||
|
||||
@@ -1,6 +1,27 @@
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
/***************************************************************************
|
||||
copyright : (C) 2007 by Lukas Lalinsky
|
||||
email : lukas@oxygene.sk
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* This library is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* 2.1 as published by the Free Software Foundation. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, but *
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
|
||||
* Lesser General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library; if not, write to the Free Software *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||
* 02110-1301 USA *
|
||||
* *
|
||||
* Alternatively, this file is available under the Mozilla Public *
|
||||
* License Version 1.1. You may obtain a copy of the License at *
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include <string>
|
||||
#include <stdio.h>
|
||||
@@ -23,6 +44,7 @@
|
||||
#include <tableofcontentsframe.h>
|
||||
#include <tdebug.h>
|
||||
#include <tpropertymap.h>
|
||||
#include <tzlib.h>
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
#include "utils.h"
|
||||
|
||||
@@ -45,7 +67,8 @@ class TestID3v2 : public CppUnit::TestFixture
|
||||
{
|
||||
CPPUNIT_TEST_SUITE(TestID3v2);
|
||||
CPPUNIT_TEST(testUnsynchDecode);
|
||||
CPPUNIT_TEST(testDowngradeUTF8ForID3v23);
|
||||
CPPUNIT_TEST(testDowngradeUTF8ForID3v23_1);
|
||||
CPPUNIT_TEST(testDowngradeUTF8ForID3v23_2);
|
||||
CPPUNIT_TEST(testUTF16BEDelimiter);
|
||||
CPPUNIT_TEST(testUTF16Delimiter);
|
||||
CPPUNIT_TEST(testReadStringField);
|
||||
@@ -71,6 +94,7 @@ class TestID3v2 : public CppUnit::TestFixture
|
||||
CPPUNIT_TEST(testParseOwnershipFrame);
|
||||
CPPUNIT_TEST(testRenderOwnershipFrame);
|
||||
CPPUNIT_TEST(testParseSynchronizedLyricsFrame);
|
||||
CPPUNIT_TEST(testParseSynchronizedLyricsFrameWithEmptyDescritpion);
|
||||
CPPUNIT_TEST(testRenderSynchronizedLyricsFrame);
|
||||
CPPUNIT_TEST(testParseEventTimingCodesFrame);
|
||||
CPPUNIT_TEST(testRenderEventTimingCodesFrame);
|
||||
@@ -105,7 +129,7 @@ public:
|
||||
CPPUNIT_ASSERT_EQUAL(String("My babe just cares for me"), f.tag()->title());
|
||||
}
|
||||
|
||||
void testDowngradeUTF8ForID3v23()
|
||||
void testDowngradeUTF8ForID3v23_1()
|
||||
{
|
||||
ScopedFileCopy copy("xing", ".mp3");
|
||||
string newname = copy.fileName();
|
||||
@@ -129,6 +153,27 @@ public:
|
||||
CPPUNIT_ASSERT_EQUAL(String::UTF16, f2.textEncoding());
|
||||
}
|
||||
|
||||
void testDowngradeUTF8ForID3v23_2()
|
||||
{
|
||||
ScopedFileCopy copy("xing", ".mp3");
|
||||
|
||||
ID3v2::UnsynchronizedLyricsFrame *f
|
||||
= new ID3v2::UnsynchronizedLyricsFrame(String::UTF8);
|
||||
f->setText("Foo");
|
||||
|
||||
MPEG::File file(copy.fileName().c_str());
|
||||
file.ID3v2Tag(true)->addFrame(f);
|
||||
file.save(MPEG::File::ID3v2, true, 3);
|
||||
CPPUNIT_ASSERT(file.hasID3v2Tag());
|
||||
|
||||
ByteVector data = f->render();
|
||||
CPPUNIT_ASSERT_EQUAL((unsigned int)(4+4+2+1+3+2+2+6+2), data.size());
|
||||
|
||||
ID3v2::UnsynchronizedLyricsFrame f2(data);
|
||||
CPPUNIT_ASSERT_EQUAL(String("Foo"), f2.text());
|
||||
CPPUNIT_ASSERT_EQUAL(String::UTF16, f2.textEncoding());
|
||||
}
|
||||
|
||||
void testUTF16BEDelimiter()
|
||||
{
|
||||
ID3v2::TextIdentificationFrame f(ByteVector("TPE1"), String::UTF16BE);
|
||||
@@ -204,7 +249,7 @@ public:
|
||||
"d\x00"
|
||||
"\x00", 14);
|
||||
ID3v2::AttachedPictureFrame *frame =
|
||||
static_cast<TagLib::ID3v2::AttachedPictureFrame*>(factory->createFrame(data, (unsigned int)2));
|
||||
dynamic_cast<TagLib::ID3v2::AttachedPictureFrame*>(factory->createFrame(data, (unsigned int)2));
|
||||
|
||||
CPPUNIT_ASSERT(frame);
|
||||
CPPUNIT_ASSERT_EQUAL(String("image/jpeg"), frame->mimeType());
|
||||
@@ -224,8 +269,8 @@ public:
|
||||
"\x01"
|
||||
"d\x00"
|
||||
"\x00", 14);
|
||||
ID3v2::AttachedPictureFrame *frame =
|
||||
static_cast<TagLib::ID3v2::AttachedPictureFrame*>(factory->createFrame(data, (unsigned int)2));
|
||||
ID3v2::UnknownFrame *frame =
|
||||
dynamic_cast<TagLib::ID3v2::UnknownFrame*>(factory->createFrame(data, (unsigned int)2));
|
||||
|
||||
CPPUNIT_ASSERT(frame);
|
||||
|
||||
@@ -483,6 +528,35 @@ public:
|
||||
CPPUNIT_ASSERT_EQUAL((unsigned int)4567, stl[1].time);
|
||||
}
|
||||
|
||||
void testParseSynchronizedLyricsFrameWithEmptyDescritpion()
|
||||
{
|
||||
ID3v2::SynchronizedLyricsFrame f(
|
||||
ByteVector("SYLT" // Frame ID
|
||||
"\x00\x00\x00\x21" // Frame size
|
||||
"\x00\x00" // Frame flags
|
||||
"\x00" // Text encoding
|
||||
"eng" // Language
|
||||
"\x02" // Time stamp format
|
||||
"\x01" // Content type
|
||||
"\x00" // Content descriptor
|
||||
"Example\x00" // 1st text
|
||||
"\x00\x00\x04\xd2" // 1st time stamp
|
||||
"Lyrics\x00" // 2nd text
|
||||
"\x00\x00\x11\xd7", 40)); // 2nd time stamp
|
||||
CPPUNIT_ASSERT_EQUAL(String::Latin1, f.textEncoding());
|
||||
CPPUNIT_ASSERT_EQUAL(ByteVector("eng", 3), f.language());
|
||||
CPPUNIT_ASSERT_EQUAL(ID3v2::SynchronizedLyricsFrame::AbsoluteMilliseconds,
|
||||
f.timestampFormat());
|
||||
CPPUNIT_ASSERT_EQUAL(ID3v2::SynchronizedLyricsFrame::Lyrics, f.type());
|
||||
CPPUNIT_ASSERT(f.description().isEmpty());
|
||||
ID3v2::SynchronizedLyricsFrame::SynchedTextList stl = f.synchedText();
|
||||
CPPUNIT_ASSERT_EQUAL((unsigned int)2, stl.size());
|
||||
CPPUNIT_ASSERT_EQUAL(String("Example"), stl[0].text);
|
||||
CPPUNIT_ASSERT_EQUAL((unsigned int)1234, stl[0].time);
|
||||
CPPUNIT_ASSERT_EQUAL(String("Lyrics"), stl[1].text);
|
||||
CPPUNIT_ASSERT_EQUAL((unsigned int)4567, stl[1].time);
|
||||
}
|
||||
|
||||
void testRenderSynchronizedLyricsFrame()
|
||||
{
|
||||
ID3v2::SynchronizedLyricsFrame f;
|
||||
@@ -589,7 +663,7 @@ public:
|
||||
"\x00" // Encoding
|
||||
"(22)Death Metal", 26); // Text
|
||||
ID3v2::TextIdentificationFrame *frame =
|
||||
static_cast<TagLib::ID3v2::TextIdentificationFrame*>(factory->createFrame(data, (unsigned int)3));
|
||||
dynamic_cast<TagLib::ID3v2::TextIdentificationFrame*>(factory->createFrame(data, (unsigned int)3));
|
||||
CPPUNIT_ASSERT_EQUAL((unsigned int)1, frame->fieldList().size());
|
||||
CPPUNIT_ASSERT_EQUAL(String("Death Metal"), frame->fieldList()[0]);
|
||||
|
||||
@@ -608,7 +682,7 @@ public:
|
||||
"\x00" // Encoding
|
||||
"(4)Eurodisco", 23); // Text
|
||||
ID3v2::TextIdentificationFrame *frame =
|
||||
static_cast<TagLib::ID3v2::TextIdentificationFrame*>(factory->createFrame(data, (unsigned int)3));
|
||||
dynamic_cast<TagLib::ID3v2::TextIdentificationFrame*>(factory->createFrame(data, (unsigned int)3));
|
||||
CPPUNIT_ASSERT_EQUAL((unsigned int)2, frame->fieldList().size());
|
||||
CPPUNIT_ASSERT_EQUAL(String("4"), frame->fieldList()[0]);
|
||||
CPPUNIT_ASSERT_EQUAL(String("Eurodisco"), frame->fieldList()[1]);
|
||||
@@ -627,7 +701,7 @@ public:
|
||||
"\0" // Encoding
|
||||
"14\0Eurodisco", 23); // Text
|
||||
ID3v2::TextIdentificationFrame *frame =
|
||||
static_cast<TagLib::ID3v2::TextIdentificationFrame*>(factory->createFrame(data, (unsigned int)4));
|
||||
dynamic_cast<TagLib::ID3v2::TextIdentificationFrame*>(factory->createFrame(data, (unsigned int)4));
|
||||
CPPUNIT_ASSERT_EQUAL((unsigned int)2, frame->fieldList().size());
|
||||
CPPUNIT_ASSERT_EQUAL(String("14"), frame->fieldList()[0]);
|
||||
CPPUNIT_ASSERT_EQUAL(String("Eurodisco"), frame->fieldList()[1]);
|
||||
@@ -683,11 +757,11 @@ public:
|
||||
}
|
||||
{
|
||||
MPEG::File bar(newname.c_str());
|
||||
tf = static_cast<ID3v2::TextIdentificationFrame *>(bar.ID3v2Tag()->frameList("TDOR").front());
|
||||
tf = dynamic_cast<ID3v2::TextIdentificationFrame *>(bar.ID3v2Tag()->frameList("TDOR").front());
|
||||
CPPUNIT_ASSERT(tf);
|
||||
CPPUNIT_ASSERT_EQUAL((unsigned int)1, tf->fieldList().size());
|
||||
CPPUNIT_ASSERT_EQUAL(String("2011"), tf->fieldList().front());
|
||||
tf = static_cast<ID3v2::TextIdentificationFrame *>(bar.ID3v2Tag()->frameList("TDRC").front());
|
||||
tf = dynamic_cast<ID3v2::TextIdentificationFrame *>(bar.ID3v2Tag()->frameList("TDRC").front());
|
||||
CPPUNIT_ASSERT(tf);
|
||||
CPPUNIT_ASSERT_EQUAL((unsigned int)1, tf->fieldList().size());
|
||||
CPPUNIT_ASSERT_EQUAL(String("2012-04-17T12:01"), tf->fieldList().front());
|
||||
@@ -720,26 +794,23 @@ public:
|
||||
MPEG::File f(TEST_FILE_PATH_C("compressed_id3_frame.mp3"), false);
|
||||
CPPUNIT_ASSERT(f.ID3v2Tag()->frameListMap().contains("APIC"));
|
||||
|
||||
#ifdef HAVE_ZLIB
|
||||
if(zlib::isAvailable()) {
|
||||
ID3v2::AttachedPictureFrame *frame
|
||||
= dynamic_cast<TagLib::ID3v2::AttachedPictureFrame*>(f.ID3v2Tag()->frameListMap()["APIC"].front());
|
||||
CPPUNIT_ASSERT(frame);
|
||||
CPPUNIT_ASSERT_EQUAL(String("image/bmp"), frame->mimeType());
|
||||
CPPUNIT_ASSERT_EQUAL(ID3v2::AttachedPictureFrame::Other, frame->type());
|
||||
CPPUNIT_ASSERT_EQUAL(String(""), frame->description());
|
||||
CPPUNIT_ASSERT_EQUAL((unsigned int)86414, frame->picture().size());
|
||||
}
|
||||
else {
|
||||
// Skip the test if ZLIB is not installed.
|
||||
// The message "Compressed frames are currently not supported." will be displayed.
|
||||
|
||||
ID3v2::AttachedPictureFrame *frame
|
||||
= dynamic_cast<TagLib::ID3v2::AttachedPictureFrame*>(f.ID3v2Tag()->frameListMap()["APIC"].front());
|
||||
CPPUNIT_ASSERT(frame);
|
||||
CPPUNIT_ASSERT_EQUAL(String("image/bmp"), frame->mimeType());
|
||||
CPPUNIT_ASSERT_EQUAL(ID3v2::AttachedPictureFrame::Other, frame->type());
|
||||
CPPUNIT_ASSERT_EQUAL(String(""), frame->description());
|
||||
CPPUNIT_ASSERT_EQUAL((unsigned int)86414, frame->picture().size());
|
||||
|
||||
#else
|
||||
|
||||
// Skip the test if ZLIB is not installed.
|
||||
// The message "Compressed frames are currently not supported." will be displayed.
|
||||
|
||||
ID3v2::UnknownFrame *frame
|
||||
= dynamic_cast<TagLib::ID3v2::UnknownFrame*>(f.ID3v2Tag()->frameListMap()["APIC"].front());
|
||||
CPPUNIT_ASSERT(frame);
|
||||
|
||||
#endif
|
||||
ID3v2::UnknownFrame *frame
|
||||
= dynamic_cast<TagLib::ID3v2::UnknownFrame*>(f.ID3v2Tag()->frameListMap()["APIC"].front());
|
||||
CPPUNIT_ASSERT(frame);
|
||||
}
|
||||
}
|
||||
|
||||
void testW000()
|
||||
|
||||
@@ -1,3 +1,28 @@
|
||||
/***************************************************************************
|
||||
copyright : (C) 2012 by Tsuda Kageyu
|
||||
email : tsuda.kageyu@gmail.com
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* This library is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* 2.1 as published by the Free Software Foundation. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, but *
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
|
||||
* Lesser General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library; if not, write to the Free Software *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||
* 02110-1301 USA *
|
||||
* *
|
||||
* Alternatively, this file is available under the Mozilla Public *
|
||||
* License Version 1.1. You may obtain a copy of the License at *
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include <string>
|
||||
#include <stdio.h>
|
||||
#include <infotag.h>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
/***************************************************************************
|
||||
* This library is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* 2.1 as published by the Free Software Foundation. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, but *
|
||||
@@ -15,8 +15,12 @@
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library; if not, write to the Free Software *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, *
|
||||
* MA 02110-1301 USA *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||
* 02110-1301 USA *
|
||||
* *
|
||||
* Alternatively, this file is available under the Mozilla Public *
|
||||
* License Version 1.1. You may obtain a copy of the License at *
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include <itfile.h>
|
||||
|
||||
@@ -1,26 +1,27 @@
|
||||
/* Copyright (C) 2003 Scott Wheeler <wheeler@kde.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/***************************************************************************
|
||||
copyright : (C) 2007 by Lukas Lalinsky
|
||||
email : lukas@oxygene.sk
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* This library is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* 2.1 as published by the Free Software Foundation. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, but *
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
|
||||
* Lesser General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library; if not, write to the Free Software *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||
* 02110-1301 USA *
|
||||
* *
|
||||
* Alternatively, this file is available under the Mozilla Public *
|
||||
* License Version 1.1. You may obtain a copy of the License at *
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include <tlist.h>
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
@@ -1,3 +1,28 @@
|
||||
/***************************************************************************
|
||||
copyright : (C) 2007 by Lukas Lalinsky
|
||||
email : lukas@oxygene.sk
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* This library is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* 2.1 as published by the Free Software Foundation. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, but *
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
|
||||
* Lesser General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library; if not, write to the Free Software *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||
* 02110-1301 USA *
|
||||
* *
|
||||
* Alternatively, this file is available under the Mozilla Public *
|
||||
* License Version 1.1. You may obtain a copy of the License at *
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include <tstring.h>
|
||||
#include <tmap.h>
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
/***************************************************************************
|
||||
* This library is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* 2.1 as published by the Free Software Foundation. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, but *
|
||||
@@ -15,8 +15,12 @@
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library; if not, write to the Free Software *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, *
|
||||
* MA 02110-1301 USA *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||
* 02110-1301 USA *
|
||||
* *
|
||||
* Alternatively, this file is available under the Mozilla Public *
|
||||
* License Version 1.1. You may obtain a copy of the License at *
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include <modfile.h>
|
||||
|
||||
@@ -1,3 +1,28 @@
|
||||
/***************************************************************************
|
||||
copyright : (C) 2008 by Lukas Lalinsky
|
||||
email : lukas@oxygene.sk
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* This library is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* 2.1 as published by the Free Software Foundation. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, but *
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
|
||||
* Lesser General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library; if not, write to the Free Software *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||
* 02110-1301 USA *
|
||||
* *
|
||||
* Alternatively, this file is available under the Mozilla Public *
|
||||
* License Version 1.1. You may obtain a copy of the License at *
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include <string>
|
||||
#include <stdio.h>
|
||||
#include <tag.h>
|
||||
|
||||
@@ -1,3 +1,28 @@
|
||||
/***************************************************************************
|
||||
copyright : (C) 2009 by Lukas Lalinsky
|
||||
email : lukas@oxygene.sk
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* This library is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* 2.1 as published by the Free Software Foundation. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, but *
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
|
||||
* Lesser General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library; if not, write to the Free Software *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||
* 02110-1301 USA *
|
||||
* *
|
||||
* Alternatively, this file is available under the Mozilla Public *
|
||||
* License Version 1.1. You may obtain a copy of the License at *
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include <string>
|
||||
#include <stdio.h>
|
||||
#include <tag.h>
|
||||
|
||||
@@ -1,3 +1,28 @@
|
||||
/***************************************************************************
|
||||
copyright : (C) 2009 by Lukas Lalinsky
|
||||
email : lukas@oxygene.sk
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* This library is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* 2.1 as published by the Free Software Foundation. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, but *
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
|
||||
* Lesser General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library; if not, write to the Free Software *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||
* 02110-1301 USA *
|
||||
* *
|
||||
* Alternatively, this file is available under the Mozilla Public *
|
||||
* License Version 1.1. You may obtain a copy of the License at *
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include <string>
|
||||
#include <stdio.h>
|
||||
#include <tag.h>
|
||||
|
||||
@@ -1,3 +1,28 @@
|
||||
/***************************************************************************
|
||||
copyright : (C) 2012 by Lukas Lalinsky
|
||||
email : lukas@oxygene.sk
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* This library is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* 2.1 as published by the Free Software Foundation. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, but *
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
|
||||
* Lesser General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library; if not, write to the Free Software *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||
* 02110-1301 USA *
|
||||
* *
|
||||
* Alternatively, this file is available under the Mozilla Public *
|
||||
* License Version 1.1. You may obtain a copy of the License at *
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include <string>
|
||||
#include <stdio.h>
|
||||
#include <apetag.h>
|
||||
|
||||
@@ -1,3 +1,28 @@
|
||||
/***************************************************************************
|
||||
copyright : (C) 2007 by Lukas Lalinsky
|
||||
email : lukas@oxygene.sk
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* This library is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* 2.1 as published by the Free Software Foundation. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, but *
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
|
||||
* Lesser General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library; if not, write to the Free Software *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||
* 02110-1301 USA *
|
||||
* *
|
||||
* Alternatively, this file is available under the Mozilla Public *
|
||||
* License Version 1.1. You may obtain a copy of the License at *
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include <string>
|
||||
#include <stdio.h>
|
||||
#include <tstring.h>
|
||||
|
||||
@@ -1,3 +1,28 @@
|
||||
/***************************************************************************
|
||||
copyright : (C) 2009 by Lukas Lalinsky
|
||||
email : lukas@oxygene.sk
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* This library is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* 2.1 as published by the Free Software Foundation. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, but *
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
|
||||
* Lesser General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library; if not, write to the Free Software *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||
* 02110-1301 USA *
|
||||
* *
|
||||
* Alternatively, this file is available under the Mozilla Public *
|
||||
* License Version 1.1. You may obtain a copy of the License at *
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include <string>
|
||||
#include <stdio.h>
|
||||
#include <tag.h>
|
||||
|
||||
@@ -1,3 +1,28 @@
|
||||
/***************************************************************************
|
||||
copyright : (C) 2009 by Lukas Lalinsky
|
||||
email : lukas@oxygene.sk
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* This library is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* 2.1 as published by the Free Software Foundation. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, but *
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
|
||||
* Lesser General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library; if not, write to the Free Software *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||
* 02110-1301 USA *
|
||||
* *
|
||||
* Alternatively, this file is available under the Mozilla Public *
|
||||
* License Version 1.1. You may obtain a copy of the License at *
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include <string>
|
||||
#include <stdio.h>
|
||||
#include <tag.h>
|
||||
|
||||
@@ -1,3 +1,28 @@
|
||||
/***************************************************************************
|
||||
copyright : (C) 2012 by Lukas Lalinsky
|
||||
email : lukas@oxygene.sk
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* This library is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* 2.1 as published by the Free Software Foundation. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, but *
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
|
||||
* Lesser General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library; if not, write to the Free Software *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||
* 02110-1301 USA *
|
||||
* *
|
||||
* Alternatively, this file is available under the Mozilla Public *
|
||||
* License Version 1.1. You may obtain a copy of the License at *
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include <string>
|
||||
#include <stdio.h>
|
||||
#include <tag.h>
|
||||
|
||||
@@ -1,3 +1,28 @@
|
||||
/***************************************************************************
|
||||
copyright : (C) 2012 by Michael Helmling
|
||||
email : helmling@mathematik.uni-kl.de
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* This library is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* 2.1 as published by the Free Software Foundation. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, but *
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
|
||||
* Lesser General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library; if not, write to the Free Software *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||
* 02110-1301 USA *
|
||||
* *
|
||||
* Alternatively, this file is available under the Mozilla Public *
|
||||
* License Version 1.1. You may obtain a copy of the License at *
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include <tpropertymap.h>
|
||||
#include <tag.h>
|
||||
#include <id3v1tag.h>
|
||||
|
||||
@@ -1,3 +1,28 @@
|
||||
/***************************************************************************
|
||||
copyright : (C) 2009 by Lukas Lalinsky
|
||||
email : lukas@oxygene.sk
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* This library is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* 2.1 as published by the Free Software Foundation. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, but *
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
|
||||
* Lesser General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library; if not, write to the Free Software *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||
* 02110-1301 USA *
|
||||
* *
|
||||
* Alternatively, this file is available under the Mozilla Public *
|
||||
* License Version 1.1. You may obtain a copy of the License at *
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include <string>
|
||||
#include <stdio.h>
|
||||
#include <tag.h>
|
||||
@@ -186,7 +211,7 @@ public:
|
||||
CPPUNIT_ASSERT_EQUAL((unsigned int)(3), f.chunkDataSize(3));
|
||||
CPPUNIT_ASSERT_EQUAL(ByteVector("TEST"), f.chunkName(3));
|
||||
CPPUNIT_ASSERT_EQUAL((unsigned int)(1), f.chunkPadding(3));
|
||||
CPPUNIT_ASSERT_EQUAL((unsigned int)(4411 - 8), f.riffSize());
|
||||
CPPUNIT_ASSERT_EQUAL((unsigned int)(4412 - 8), f.riffSize());
|
||||
}
|
||||
{
|
||||
PublicRIFF f(filename.c_str());
|
||||
@@ -209,6 +234,8 @@ public:
|
||||
|
||||
PublicRIFF f(filename.c_str());
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(5928U, f.riffSize());
|
||||
CPPUNIT_ASSERT_EQUAL(5936L, f.length());
|
||||
CPPUNIT_ASSERT_EQUAL(ByteVector("COMM"), f.chunkName(0));
|
||||
CPPUNIT_ASSERT_EQUAL((unsigned int)(0x000C + 8), f.chunkOffset(0));
|
||||
CPPUNIT_ASSERT_EQUAL(ByteVector("SSND"), f.chunkName(1));
|
||||
@@ -218,6 +245,8 @@ public:
|
||||
|
||||
const ByteVector data(0x400, ' ');
|
||||
f.setChunkData("SSND", data);
|
||||
CPPUNIT_ASSERT_EQUAL(1070U, f.riffSize());
|
||||
CPPUNIT_ASSERT_EQUAL(1078L, f.length());
|
||||
CPPUNIT_ASSERT_EQUAL((unsigned int)(0x000C + 8), f.chunkOffset(0));
|
||||
CPPUNIT_ASSERT_EQUAL((unsigned int)(0x0026 + 8), f.chunkOffset(1));
|
||||
CPPUNIT_ASSERT_EQUAL((unsigned int)(0x042E + 8), f.chunkOffset(2));
|
||||
@@ -230,6 +259,8 @@ public:
|
||||
CPPUNIT_ASSERT_EQUAL(ByteVector("TEST"), f.readBlock(4));
|
||||
|
||||
f.setChunkData(0, data);
|
||||
CPPUNIT_ASSERT_EQUAL(2076U, f.riffSize());
|
||||
CPPUNIT_ASSERT_EQUAL(2084L, f.length());
|
||||
CPPUNIT_ASSERT_EQUAL((unsigned int)(0x000C + 8), f.chunkOffset(0));
|
||||
CPPUNIT_ASSERT_EQUAL((unsigned int)(0x0414 + 8), f.chunkOffset(1));
|
||||
CPPUNIT_ASSERT_EQUAL((unsigned int)(0x081C + 8), f.chunkOffset(2));
|
||||
@@ -242,6 +273,8 @@ public:
|
||||
CPPUNIT_ASSERT_EQUAL(ByteVector("TEST"), f.readBlock(4));
|
||||
|
||||
f.removeChunk("SSND");
|
||||
CPPUNIT_ASSERT_EQUAL(1044U, f.riffSize());
|
||||
CPPUNIT_ASSERT_EQUAL(1052L, f.length());
|
||||
CPPUNIT_ASSERT_EQUAL((unsigned int)(0x000C + 8), f.chunkOffset(0));
|
||||
CPPUNIT_ASSERT_EQUAL((unsigned int)(0x0414 + 8), f.chunkOffset(1));
|
||||
|
||||
@@ -251,6 +284,8 @@ public:
|
||||
CPPUNIT_ASSERT_EQUAL(ByteVector("TEST"), f.readBlock(4));
|
||||
|
||||
f.removeChunk(0);
|
||||
CPPUNIT_ASSERT_EQUAL(12U, f.riffSize());
|
||||
CPPUNIT_ASSERT_EQUAL(20L, f.length());
|
||||
CPPUNIT_ASSERT_EQUAL((unsigned int)(0x000C + 8), f.chunkOffset(0));
|
||||
|
||||
f.seek(f.chunkOffset(0) - 8);
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
/***************************************************************************
|
||||
* This library is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* 2.1 as published by the Free Software Foundation. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, but *
|
||||
@@ -15,8 +15,12 @@
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library; if not, write to the Free Software *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, *
|
||||
* MA 02110-1301 USA *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||
* 02110-1301 USA *
|
||||
* *
|
||||
* Alternatively, this file is available under the Mozilla Public *
|
||||
* License Version 1.1. You may obtain a copy of the License at *
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include <s3mfile.h>
|
||||
|
||||
@@ -1,3 +1,28 @@
|
||||
/***************************************************************************
|
||||
copyright : (C) 2015 by Tsuda Kageyu
|
||||
email : tsuda.kageyu@gmail.com
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* This library is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* 2.1 as published by the Free Software Foundation. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, but *
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
|
||||
* Lesser General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library; if not, write to the Free Software *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||
* 02110-1301 USA *
|
||||
* *
|
||||
* Alternatively, this file is available under the Mozilla Public *
|
||||
* License Version 1.1. You may obtain a copy of the License at *
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include <speexfile.h>
|
||||
#include <oggpageheader.h>
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
@@ -1,26 +1,27 @@
|
||||
/* Copyright (C) 2003 Scott Wheeler <wheeler@kde.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/***************************************************************************
|
||||
copyright : (C) 2007 by Lukas Lalinsky
|
||||
email : lukas@oxygene.sk
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* This library is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* 2.1 as published by the Free Software Foundation. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, but *
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
|
||||
* Lesser General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library; if not, write to the Free Software *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||
* 02110-1301 USA *
|
||||
* *
|
||||
* Alternatively, this file is available under the Mozilla Public *
|
||||
* License Version 1.1. You may obtain a copy of the License at *
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include <tstring.h>
|
||||
#include <string.h>
|
||||
@@ -42,9 +43,11 @@ class TestString : public CppUnit::TestFixture
|
||||
CPPUNIT_TEST(testAppendCharDetach);
|
||||
CPPUNIT_TEST(testAppendStringDetach);
|
||||
CPPUNIT_TEST(testToInt);
|
||||
CPPUNIT_TEST(testFromInt);
|
||||
CPPUNIT_TEST(testSubstr);
|
||||
CPPUNIT_TEST(testNewline);
|
||||
CPPUNIT_TEST(testEncode);
|
||||
CPPUNIT_TEST(testEncodeNonLatin1);
|
||||
CPPUNIT_TEST(testEncodeEmpty);
|
||||
CPPUNIT_TEST(testIterator);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
@@ -104,31 +107,12 @@ public:
|
||||
String unicode7(stduni, String::UTF16LE);
|
||||
CPPUNIT_ASSERT(unicode7[1] == L'\u2c67');
|
||||
|
||||
CPPUNIT_ASSERT(strcmp(String::number(0).toCString(), "0") == 0);
|
||||
CPPUNIT_ASSERT(strcmp(String::number(12345678).toCString(), "12345678") == 0);
|
||||
CPPUNIT_ASSERT(strcmp(String::number(-12345678).toCString(), "-12345678") == 0);
|
||||
|
||||
String n = "123";
|
||||
CPPUNIT_ASSERT(n.toInt() == 123);
|
||||
|
||||
n = "-123";
|
||||
CPPUNIT_ASSERT(n.toInt() == -123);
|
||||
|
||||
CPPUNIT_ASSERT(String("0").toInt() == 0);
|
||||
CPPUNIT_ASSERT(String("1").toInt() == 1);
|
||||
|
||||
CPPUNIT_ASSERT(String(" foo ").stripWhiteSpace() == String("foo"));
|
||||
CPPUNIT_ASSERT(String("foo ").stripWhiteSpace() == String("foo"));
|
||||
CPPUNIT_ASSERT(String(" foo").stripWhiteSpace() == String("foo"));
|
||||
|
||||
CPPUNIT_ASSERT(memcmp(String("foo").data(String::Latin1).data(), "foo", 3) == 0);
|
||||
CPPUNIT_ASSERT(memcmp(String("f").data(String::Latin1).data(), "f", 1) == 0);
|
||||
|
||||
// Check to make sure that the BOM is there and that the data size is correct
|
||||
|
||||
const ByteVector utf16 = unicode.data(String::UTF16);
|
||||
CPPUNIT_ASSERT(utf16.size() == 2 + (unicode.size() * 2));
|
||||
CPPUNIT_ASSERT(unicode == String(utf16, String::UTF16));
|
||||
}
|
||||
|
||||
void testUTF16Encode()
|
||||
@@ -246,6 +230,9 @@ public:
|
||||
CPPUNIT_ASSERT_EQUAL(String("123aa").toInt(), 123);
|
||||
CPPUNIT_ASSERT_EQUAL(String("-123aa").toInt(), -123);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(String("0000").toInt(), 0);
|
||||
CPPUNIT_ASSERT_EQUAL(String("0001").toInt(), 1);
|
||||
|
||||
String("2147483648").toInt(&ok);
|
||||
CPPUNIT_ASSERT_EQUAL(ok, false);
|
||||
|
||||
@@ -253,6 +240,13 @@ public:
|
||||
CPPUNIT_ASSERT_EQUAL(ok, false);
|
||||
}
|
||||
|
||||
void testFromInt()
|
||||
{
|
||||
CPPUNIT_ASSERT_EQUAL(String::number(0), String("0"));
|
||||
CPPUNIT_ASSERT_EQUAL(String::number(12345678), String("12345678"));
|
||||
CPPUNIT_ASSERT_EQUAL(String::number(-12345678), String("-12345678"));
|
||||
}
|
||||
|
||||
void testSubstr()
|
||||
{
|
||||
CPPUNIT_ASSERT_EQUAL(String("01"), String("0123456").substr(0, 2));
|
||||
@@ -276,41 +270,28 @@ public:
|
||||
CPPUNIT_ASSERT_EQUAL(L'\x0a', String(crlf)[4]);
|
||||
}
|
||||
|
||||
void testEncode()
|
||||
void testEncodeNonLatin1()
|
||||
{
|
||||
String jpn(L"\u65E5\u672C\u8A9E");
|
||||
ByteVector jpn1 = jpn.data(String::Latin1);
|
||||
ByteVector jpn2 = jpn.data(String::UTF8);
|
||||
ByteVector jpn3 = jpn.data(String::UTF16);
|
||||
ByteVector jpn4 = jpn.data(String::UTF16LE);
|
||||
ByteVector jpn5 = jpn.data(String::UTF16BE);
|
||||
std::string jpn6 = jpn.to8Bit(false);
|
||||
std::string jpn7 = jpn.to8Bit(true);
|
||||
const String jpn(L"\u65E5\u672C\u8A9E");
|
||||
CPPUNIT_ASSERT_EQUAL(ByteVector("\xE5\x2C\x9E"), jpn.data(String::Latin1));
|
||||
CPPUNIT_ASSERT_EQUAL(ByteVector("\xE6\x97\xA5\xE6\x9C\xAC\xE8\xAA\x9E"), jpn.data(String::UTF8));
|
||||
CPPUNIT_ASSERT_EQUAL(ByteVector("\xFF\xFE\xE5\x65\x2C\x67\x9E\x8A"), jpn.data(String::UTF16));
|
||||
CPPUNIT_ASSERT_EQUAL(ByteVector("\xE5\x65\x2C\x67\x9E\x8A"), jpn.data(String::UTF16LE));
|
||||
CPPUNIT_ASSERT_EQUAL(ByteVector("\x65\xE5\x67\x2C\x8A\x9E"), jpn.data(String::UTF16BE));
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("\xE5\x2C\x9E"), jpn.to8Bit(false));
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("\xE6\x97\xA5\xE6\x9C\xAC\xE8\xAA\x9E"), jpn.to8Bit(true));
|
||||
}
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(ByteVector("\xE5\x2C\x9E"), jpn1);
|
||||
CPPUNIT_ASSERT_EQUAL(ByteVector("\xE6\x97\xA5\xE6\x9C\xAC\xE8\xAA\x9E"), jpn2);
|
||||
CPPUNIT_ASSERT_EQUAL(ByteVector("\xFF\xFE\xE5\x65\x2C\x67\x9E\x8A"), jpn3);
|
||||
CPPUNIT_ASSERT_EQUAL(ByteVector("\xE5\x65\x2C\x67\x9E\x8A"), jpn4);
|
||||
CPPUNIT_ASSERT_EQUAL(ByteVector("\x65\xE5\x67\x2C\x8A\x9E"), jpn5);
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("\xE5\x2C\x9E"), jpn6);
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("\xE6\x97\xA5\xE6\x9C\xAC\xE8\xAA\x9E"), jpn7);
|
||||
|
||||
String empty;
|
||||
ByteVector empty1 = empty.data(String::Latin1);
|
||||
ByteVector empty2 = empty.data(String::UTF8);
|
||||
ByteVector empty3 = empty.data(String::UTF16);
|
||||
ByteVector empty4 = empty.data(String::UTF16LE);
|
||||
ByteVector empty5 = empty.data(String::UTF16BE);
|
||||
std::string empty6 = empty.to8Bit(false);
|
||||
std::string empty7 = empty.to8Bit(true);
|
||||
|
||||
CPPUNIT_ASSERT(empty1.isEmpty());
|
||||
CPPUNIT_ASSERT(empty2.isEmpty());
|
||||
CPPUNIT_ASSERT_EQUAL(ByteVector("\xFF\xFE"), empty3);
|
||||
CPPUNIT_ASSERT(empty4.isEmpty());
|
||||
CPPUNIT_ASSERT(empty5.isEmpty());
|
||||
CPPUNIT_ASSERT(empty6.empty());
|
||||
CPPUNIT_ASSERT(empty7.empty());
|
||||
void testEncodeEmpty()
|
||||
{
|
||||
const String empty;
|
||||
CPPUNIT_ASSERT(empty.data(String::Latin1).isEmpty());
|
||||
CPPUNIT_ASSERT(empty.data(String::UTF8).isEmpty());
|
||||
CPPUNIT_ASSERT_EQUAL(ByteVector("\xFF\xFE"), empty.data(String::UTF16));
|
||||
CPPUNIT_ASSERT(empty.data(String::UTF16LE).isEmpty());
|
||||
CPPUNIT_ASSERT(empty.data(String::UTF16BE).isEmpty());
|
||||
CPPUNIT_ASSERT(empty.to8Bit(false).empty());
|
||||
CPPUNIT_ASSERT(empty.to8Bit(true).empty());
|
||||
}
|
||||
|
||||
void testIterator()
|
||||
|
||||
@@ -1,26 +1,28 @@
|
||||
/* Copyright (C) 2003 Scott Wheeler <wheeler@kde.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/***************************************************************************
|
||||
copyright : (C) 2007 by Lukas Lalinsky
|
||||
email : lukas@oxygene.sk
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* This library is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* 2.1 as published by the Free Software Foundation. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, but *
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
|
||||
* Lesser General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library; if not, write to the Free Software *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||
* 02110-1301 USA *
|
||||
* *
|
||||
* Alternatively, this file is available under the Mozilla Public *
|
||||
* License Version 1.1. You may obtain a copy of the License at *
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include <id3v2synchdata.h>
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
@@ -38,6 +40,8 @@ class TestID3v2SynchData : public CppUnit::TestFixture
|
||||
CPPUNIT_TEST(testToUIntBrokenAndTooLarge);
|
||||
CPPUNIT_TEST(testDecode1);
|
||||
CPPUNIT_TEST(testDecode2);
|
||||
CPPUNIT_TEST(testDecode3);
|
||||
CPPUNIT_TEST(testDecode4);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
public:
|
||||
@@ -102,6 +106,22 @@ public:
|
||||
CPPUNIT_ASSERT_EQUAL(ByteVector("\xff\x44", 2), a);
|
||||
}
|
||||
|
||||
void testDecode3()
|
||||
{
|
||||
ByteVector a("\xff\xff\x00", 3);
|
||||
a = ID3v2::SynchData::decode(a);
|
||||
CPPUNIT_ASSERT_EQUAL((unsigned int)2, a.size());
|
||||
CPPUNIT_ASSERT_EQUAL(ByteVector("\xff\xff", 2), a);
|
||||
}
|
||||
|
||||
void testDecode4()
|
||||
{
|
||||
ByteVector a("\xff\xff\xff", 3);
|
||||
a = ID3v2::SynchData::decode(a);
|
||||
CPPUNIT_ASSERT_EQUAL((unsigned int)3, a.size());
|
||||
CPPUNIT_ASSERT_EQUAL(ByteVector("\xff\xff\xff", 3), a);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(TestID3v2SynchData);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user