aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorUrs Fleisch <ufleisch@users.sourceforge.net>2020-12-21 13:31:24 +0100
committerUrs Fleisch <ufleisch@users.sourceforge.net>2020-12-21 13:31:24 +0100
commit3d71ea1ad263e399952810a442522efc7f36ef62 (patch)
treea3371e7fd28f8bf00c5a7b73a03a9b3586df61a9 /tests
parent02c8995273568fc420df0805ac3eb98f13ef503b (diff)
ALAC: Test properties of file without bitrate
Diffstat (limited to 'tests')
-rw-r--r--tests/test_mp4.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/test_mp4.cpp b/tests/test_mp4.cpp
index 9e52de2b..13c17b22 100644
--- a/tests/test_mp4.cpp
+++ b/tests/test_mp4.cpp
@@ -28,10 +28,12 @@
#include <tag.h>
#include <mp4tag.h>
#include <tbytevectorlist.h>
+#include <tbytevectorstream.h>
#include <tpropertymap.h>
#include <mp4atom.h>
#include <mp4file.h>
#include <cppunit/extensions/HelperMacros.h>
+#include "plainfile.h"
#include "utils.h"
using namespace std;
@@ -42,6 +44,7 @@ class TestMP4 : public CppUnit::TestFixture
CPPUNIT_TEST_SUITE(TestMP4);
CPPUNIT_TEST(testPropertiesAAC);
CPPUNIT_TEST(testPropertiesALAC);
+ CPPUNIT_TEST(testPropertiesALACWithoutBitrate);
CPPUNIT_TEST(testPropertiesM4V);
CPPUNIT_TEST(testFreeForm);
CPPUNIT_TEST(testCheckValid);
@@ -92,6 +95,28 @@ public:
CPPUNIT_ASSERT_EQUAL(MP4::Properties::ALAC, f.audioProperties()->codec());
}
+ void testPropertiesALACWithoutBitrate()
+ {
+ ByteVector alacData = PlainFile(TEST_FILE_PATH_C("empty_alac.m4a")).readAll();
+ CPPUNIT_ASSERT_GREATER(474U, alacData.size());
+ CPPUNIT_ASSERT_EQUAL(ByteVector("alac"), alacData.mid(446, 4));
+ // Set the bitrate to zero
+ for (int offset = 470; offset < 474; ++offset) {
+ alacData[offset] = 0;
+ }
+ ByteVectorStream alacStream(alacData);
+ MP4::File f(&alacStream);
+ CPPUNIT_ASSERT(f.audioProperties());
+ CPPUNIT_ASSERT_EQUAL(3, f.audioProperties()->lengthInSeconds());
+ CPPUNIT_ASSERT_EQUAL(3705, f.audioProperties()->lengthInMilliseconds());
+ CPPUNIT_ASSERT_EQUAL(2, f.audioProperties()->bitrate());
+ CPPUNIT_ASSERT_EQUAL(2, f.audioProperties()->channels());
+ CPPUNIT_ASSERT_EQUAL(44100, f.audioProperties()->sampleRate());
+ CPPUNIT_ASSERT_EQUAL(16, f.audioProperties()->bitsPerSample());
+ CPPUNIT_ASSERT_EQUAL(false, f.audioProperties()->isEncrypted());
+ CPPUNIT_ASSERT_EQUAL(MP4::Properties::ALAC, f.audioProperties()->codec());
+ }
+
void testPropertiesM4V()
{
MP4::File f(TEST_FILE_PATH_C("blank_video.m4v"));