mirror of
https://github.com/taglib/taglib.git
synced 2025-07-18 21:14:23 -04:00
Add DSF and DSDIFF file types management (#878)
* Add DSF and DSDIFF file types management * Fixes for some build chains * unit64_t replaced by unsigned long long, warning fixes * Remove C++11 extension incompatible with some build chains (enumeration in a nested name specifier) * Change typedef types (uint, ulong, ...) to standard types remove BUILD_FRAMEWORK changes from this pull request * Replace deprecated String::null and ByteVector::null by String() and ByteVector() Styling update, thanks to FestusHagen * Restyling * Restyling to reduce length of excessively long lines * Add to detectByExtension * Added `isSupported(IOStream *stream)` to `DSF::File` and `DSDIFF::File`
This commit is contained in:
committed by
Stephen F. Booth
parent
bfed3797a0
commit
d71398c953
@ -24,6 +24,8 @@ INCLUDE_DIRECTORIES(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../taglib/s3m
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../taglib/it
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../taglib/xm
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../taglib/dsf
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../taglib/dsdiff
|
||||
)
|
||||
|
||||
SET(test_runner_SRCS
|
||||
@ -66,6 +68,8 @@ SET(test_runner_SRCS
|
||||
test_mpc.cpp
|
||||
test_opus.cpp
|
||||
test_speex.cpp
|
||||
test_dsf.cpp
|
||||
test_dsdiff.cpp
|
||||
)
|
||||
|
||||
INCLUDE_DIRECTORIES(${CPPUNIT_INCLUDE_DIR})
|
||||
|
BIN
tests/data/empty10ms.dff
Normal file
BIN
tests/data/empty10ms.dff
Normal file
Binary file not shown.
BIN
tests/data/empty10ms.dsf
Normal file
BIN
tests/data/empty10ms.dsf
Normal file
Binary file not shown.
116
tests/test_dsdiff.cpp
Normal file
116
tests/test_dsdiff.cpp
Normal file
@ -0,0 +1,116 @@
|
||||
#include <string>
|
||||
#include <stdio.h>
|
||||
#include <tag.h>
|
||||
#include <tbytevectorlist.h>
|
||||
#include <dsdifffile.h>
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
#include "utils.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace TagLib;
|
||||
|
||||
class TestDSDIFF : public CppUnit::TestFixture
|
||||
{
|
||||
CPPUNIT_TEST_SUITE(TestDSDIFF);
|
||||
CPPUNIT_TEST(testProperties);
|
||||
CPPUNIT_TEST(testTags);
|
||||
CPPUNIT_TEST(testSaveID3v2);
|
||||
CPPUNIT_TEST(testRepeatedSave);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
public:
|
||||
|
||||
void testProperties()
|
||||
{
|
||||
DSDIFF::File f(TEST_FILE_PATH_C("empty10ms.dff"));
|
||||
CPPUNIT_ASSERT(f.audioProperties());
|
||||
CPPUNIT_ASSERT_EQUAL(0, f.audioProperties()->length());
|
||||
CPPUNIT_ASSERT_EQUAL(0, f.audioProperties()->lengthInSeconds());
|
||||
CPPUNIT_ASSERT_EQUAL(10, f.audioProperties()->lengthInMilliseconds());
|
||||
CPPUNIT_ASSERT_EQUAL(5644, f.audioProperties()->bitrate());
|
||||
CPPUNIT_ASSERT_EQUAL(2, f.audioProperties()->channels());
|
||||
CPPUNIT_ASSERT_EQUAL(2822400, f.audioProperties()->sampleRate());
|
||||
CPPUNIT_ASSERT_EQUAL(1, f.audioProperties()->bitsPerSample());
|
||||
CPPUNIT_ASSERT_EQUAL((long long)28224, f.audioProperties()->sampleCount());
|
||||
}
|
||||
|
||||
void testTags()
|
||||
{
|
||||
ScopedFileCopy copy("empty10ms", ".dff");
|
||||
string newname = copy.fileName();
|
||||
|
||||
DSDIFF::File *f = new DSDIFF::File(newname.c_str());
|
||||
CPPUNIT_ASSERT_EQUAL(String(""), f->tag()->artist());
|
||||
f->tag()->setArtist("The Artist");
|
||||
f->save();
|
||||
delete f;
|
||||
|
||||
f = new DSDIFF::File(newname.c_str());
|
||||
CPPUNIT_ASSERT_EQUAL(String("The Artist"), f->tag()->artist());
|
||||
delete f;
|
||||
}
|
||||
|
||||
void testSaveID3v2()
|
||||
{
|
||||
ScopedFileCopy copy("empty10ms", ".dff");
|
||||
string newname = copy.fileName();
|
||||
|
||||
{
|
||||
DSDIFF::File f(newname.c_str());
|
||||
CPPUNIT_ASSERT(!f.hasID3v2Tag());
|
||||
|
||||
f.tag()->setTitle(L"TitleXXX");
|
||||
f.save();
|
||||
CPPUNIT_ASSERT(f.hasID3v2Tag());
|
||||
}
|
||||
{
|
||||
DSDIFF::File f(newname.c_str());
|
||||
CPPUNIT_ASSERT(f.hasID3v2Tag());
|
||||
CPPUNIT_ASSERT_EQUAL(String(L"TitleXXX"), f.tag()->title());
|
||||
|
||||
f.tag()->setTitle("");
|
||||
f.save();
|
||||
CPPUNIT_ASSERT(!f.hasID3v2Tag());
|
||||
}
|
||||
{
|
||||
DSDIFF::File f(newname.c_str());
|
||||
CPPUNIT_ASSERT(!f.hasID3v2Tag());
|
||||
f.tag()->setTitle(L"TitleXXX");
|
||||
f.save();
|
||||
CPPUNIT_ASSERT(f.hasID3v2Tag());
|
||||
}
|
||||
{
|
||||
DSDIFF::File f(newname.c_str());
|
||||
CPPUNIT_ASSERT(f.hasID3v2Tag());
|
||||
CPPUNIT_ASSERT_EQUAL(String(L"TitleXXX"), f.tag()->title());
|
||||
}
|
||||
}
|
||||
|
||||
void testRepeatedSave()
|
||||
{
|
||||
ScopedFileCopy copy("empty10ms", ".dff");
|
||||
string newname = copy.fileName();
|
||||
|
||||
{
|
||||
DSDIFF::File f(newname.c_str());
|
||||
CPPUNIT_ASSERT_EQUAL(String(""), f.tag()->title());
|
||||
f.tag()->setTitle("NEW TITLE");
|
||||
f.save();
|
||||
CPPUNIT_ASSERT_EQUAL(String("NEW TITLE"), f.tag()->title());
|
||||
f.tag()->setTitle("NEW TITLE 2");
|
||||
f.save();
|
||||
CPPUNIT_ASSERT_EQUAL(String("NEW TITLE 2"), f.tag()->title());
|
||||
CPPUNIT_ASSERT_EQUAL(8252L, f.length());
|
||||
f.save();
|
||||
CPPUNIT_ASSERT_EQUAL(8252L, f.length());
|
||||
}
|
||||
{
|
||||
DSDIFF::File f(newname.c_str());
|
||||
CPPUNIT_ASSERT_EQUAL(String("NEW TITLE 2"), f.tag()->title());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(TestDSDIFF);
|
57
tests/test_dsf.cpp
Normal file
57
tests/test_dsf.cpp
Normal file
@ -0,0 +1,57 @@
|
||||
#include <string>
|
||||
#include <stdio.h>
|
||||
#include <tag.h>
|
||||
#include <tbytevectorlist.h>
|
||||
#include <dsffile.h>
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
#include "utils.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace TagLib;
|
||||
|
||||
class TestDSF : public CppUnit::TestFixture
|
||||
{
|
||||
CPPUNIT_TEST_SUITE(TestDSF);
|
||||
CPPUNIT_TEST(testBasic);
|
||||
CPPUNIT_TEST(testTags);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
public:
|
||||
|
||||
void testBasic()
|
||||
{
|
||||
DSF::File f(TEST_FILE_PATH_C("empty10ms.dsf"));
|
||||
CPPUNIT_ASSERT(f.audioProperties());
|
||||
CPPUNIT_ASSERT_EQUAL(0, f.audioProperties()->length());
|
||||
CPPUNIT_ASSERT_EQUAL(0, f.audioProperties()->lengthInSeconds());
|
||||
CPPUNIT_ASSERT_EQUAL(10, f.audioProperties()->lengthInMilliseconds());
|
||||
CPPUNIT_ASSERT_EQUAL(5645, f.audioProperties()->bitrate());
|
||||
CPPUNIT_ASSERT_EQUAL(2, f.audioProperties()->channels());
|
||||
CPPUNIT_ASSERT_EQUAL(2822400, f.audioProperties()->sampleRate());
|
||||
CPPUNIT_ASSERT_EQUAL(1, f.audioProperties()->formatVersion());
|
||||
CPPUNIT_ASSERT_EQUAL(0, f.audioProperties()->formatID());
|
||||
CPPUNIT_ASSERT_EQUAL(2, f.audioProperties()->channelType());
|
||||
CPPUNIT_ASSERT_EQUAL(1, f.audioProperties()->bitsPerSample());
|
||||
CPPUNIT_ASSERT_EQUAL((long long)28224, f.audioProperties()->sampleCount());
|
||||
CPPUNIT_ASSERT_EQUAL(4096, f.audioProperties()->blockSizePerChannel());
|
||||
}
|
||||
|
||||
void testTags()
|
||||
{
|
||||
ScopedFileCopy copy("empty10ms", ".dsf");
|
||||
string newname = copy.fileName();
|
||||
|
||||
DSF::File *f = new DSF::File(newname.c_str());
|
||||
CPPUNIT_ASSERT_EQUAL(String(""), f->tag()->artist());
|
||||
f->tag()->setArtist("The Artist");
|
||||
f->save();
|
||||
delete f;
|
||||
|
||||
f = new DSF::File(newname.c_str());
|
||||
CPPUNIT_ASSERT_EQUAL(String("The Artist"), f->tag()->artist());
|
||||
delete f;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(TestDSF);
|
@ -39,6 +39,8 @@
|
||||
#include <wavfile.h>
|
||||
#include <apefile.h>
|
||||
#include <aifffile.h>
|
||||
#include <dsffile.h>
|
||||
#include <dsdifffile.h>
|
||||
#include <tfilestream.h>
|
||||
#include <tbytevectorstream.h>
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
@ -79,6 +81,8 @@ class TestFileRef : public CppUnit::TestFixture
|
||||
CPPUNIT_TEST(testWav);
|
||||
CPPUNIT_TEST(testAIFF_1);
|
||||
CPPUNIT_TEST(testAIFF_2);
|
||||
CPPUNIT_TEST(testDSF);
|
||||
CPPUNIT_TEST(testDSDIFF);
|
||||
CPPUNIT_TEST(testUnsupported);
|
||||
CPPUNIT_TEST(testCreate);
|
||||
CPPUNIT_TEST(testFileResolver);
|
||||
@ -288,6 +292,16 @@ public:
|
||||
{
|
||||
fileRefSave<RIFF::AIFF::File>("alaw", ".aifc");
|
||||
}
|
||||
|
||||
void testDSF()
|
||||
{
|
||||
fileRefSave<DSF::File>("empty10ms",".dsf");
|
||||
}
|
||||
|
||||
void testDSDIFF()
|
||||
{
|
||||
fileRefSave<DSDIFF::File>("empty10ms",".dff");
|
||||
}
|
||||
|
||||
void testUnsupported()
|
||||
{
|
||||
|
Reference in New Issue
Block a user