Add support for Ogg Opus

This commit is contained in:
Lukáš Lalinský
2012-10-13 08:55:23 +02:00
parent 1e660dda71
commit 5e7b1da632
11 changed files with 579 additions and 1 deletions

View File

@ -16,6 +16,8 @@ INCLUDE_DIRECTORIES(
${CMAKE_CURRENT_SOURCE_DIR}/../taglib/ogg
${CMAKE_CURRENT_SOURCE_DIR}/../taglib/ogg/vorbis
${CMAKE_CURRENT_SOURCE_DIR}/../taglib/ogg/flac
${CMAKE_CURRENT_SOURCE_DIR}/../taglib/ogg/speex
${CMAKE_CURRENT_SOURCE_DIR}/../taglib/ogg/opus
${CMAKE_CURRENT_SOURCE_DIR}/../taglib/flac
${CMAKE_CURRENT_SOURCE_DIR}/../taglib/wavpack
${CMAKE_CURRENT_SOURCE_DIR}/../taglib/mod
@ -60,6 +62,7 @@ SET(test_runner_SRCS
test_it.cpp
test_xm.cpp
test_mpc.cpp
test_opus.cpp
)
INCLUDE_DIRECTORIES(${CPPUNIT_INCLUDE_DIR})

Binary file not shown.

61
tests/test_opus.cpp Normal file
View File

@ -0,0 +1,61 @@
#include <cppunit/extensions/HelperMacros.h>
#include <string>
#include <stdio.h>
#include <tag.h>
#include <tbytevectorlist.h>
#include <opusfile.h>
#include "utils.h"
using namespace std;
using namespace TagLib;
class TestOpus : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE(TestOpus);
CPPUNIT_TEST(testProperties);
CPPUNIT_TEST(testReadComments);
CPPUNIT_TEST(testWriteComments);
CPPUNIT_TEST_SUITE_END();
public:
void testProperties()
{
Ogg::Opus::File f(TEST_FILE_PATH_C("correctness_gain_silent_output.opus"));
CPPUNIT_ASSERT_EQUAL(7, f.audioProperties()->length());
CPPUNIT_ASSERT_EQUAL(0, f.audioProperties()->bitrate());
CPPUNIT_ASSERT_EQUAL(1, f.audioProperties()->channels());
CPPUNIT_ASSERT_EQUAL(48000, f.audioProperties()->sampleRate());
CPPUNIT_ASSERT_EQUAL(48000, ((Ogg::Opus::Properties *)f.audioProperties())->inputSampleRate());
}
void testReadComments()
{
Ogg::Opus::File f(TEST_FILE_PATH_C("correctness_gain_silent_output.opus"));
CPPUNIT_ASSERT_EQUAL(StringList("Xiph.Org Opus testvectormaker"), f.tag()->fieldListMap()["ENCODER"]);
CPPUNIT_ASSERT(f.tag()->fieldListMap().contains("TESTDESCRIPTION"));
CPPUNIT_ASSERT(!f.tag()->fieldListMap().contains("ARTIST"));
CPPUNIT_ASSERT_EQUAL(String("libopus 0.9.11-66-g64c2dd7"), f.tag()->vendorID());
}
void testWriteComments()
{
ScopedFileCopy copy("correctness_gain_silent_output", ".opus");
string filename = copy.fileName();
Ogg::Opus::File *f = new Ogg::Opus::File(filename.c_str());
f->tag()->setArtist("Your Tester");
f->save();
delete f;
f = new Ogg::Opus::File(filename.c_str());
CPPUNIT_ASSERT_EQUAL(StringList("Xiph.Org Opus testvectormaker"), f->tag()->fieldListMap()["ENCODER"]);
CPPUNIT_ASSERT(f->tag()->fieldListMap().contains("TESTDESCRIPTION"));
CPPUNIT_ASSERT_EQUAL(StringList("Your Tester"), f->tag()->fieldListMap()["ARTIST"]);
CPPUNIT_ASSERT_EQUAL(String("libopus 0.9.11-66-g64c2dd7"), f->tag()->vendorID());
delete f;
}
};
CPPUNIT_TEST_SUITE_REGISTRATION(TestOpus);