Ogg Speex: AudioProperties improvements

Add lengthInSeconds(), lengthInMilliseconds() properties. (#503)
Add bitrateNominal() property.
Remove some data members which are not needed to carry.
Add some tests for audio properties.
Add some supplementary comments.
This commit is contained in:
Tsuda Kageyu
2015-05-21 14:50:25 +09:00
parent 447a4739c5
commit 4dba88fa31
4 changed files with 125 additions and 22 deletions

View File

@ -65,6 +65,7 @@ SET(test_runner_SRCS
test_xm.cpp
test_mpc.cpp
test_opus.cpp
test_speex.cpp
)
INCLUDE_DIRECTORIES(${CPPUNIT_INCLUDE_DIR})

31
tests/test_speex.cpp Normal file
View File

@ -0,0 +1,31 @@
#include <speexfile.h>
#include <cppunit/extensions/HelperMacros.h>
#include "utils.h"
using namespace std;
using namespace TagLib;
class TestSpeex : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE(TestSpeex);
CPPUNIT_TEST(testAudioProperties);
CPPUNIT_TEST_SUITE_END();
public:
void testAudioProperties()
{
Ogg::Speex::File f(TEST_FILE_PATH_C("empty.spx"));
CPPUNIT_ASSERT(f.audioProperties());
CPPUNIT_ASSERT_EQUAL(3, f.audioProperties()->length());
CPPUNIT_ASSERT_EQUAL(3, f.audioProperties()->lengthInSeconds());
CPPUNIT_ASSERT_EQUAL(3685, f.audioProperties()->lengthInMilliseconds());
CPPUNIT_ASSERT_EQUAL(53, f.audioProperties()->bitrate());
CPPUNIT_ASSERT_EQUAL(-1, f.audioProperties()->bitrateNominal());
CPPUNIT_ASSERT_EQUAL(2, f.audioProperties()->channels());
CPPUNIT_ASSERT_EQUAL(44100, f.audioProperties()->sampleRate());
}
};
CPPUNIT_TEST_SUITE_REGISTRATION(TestSpeex);