3 #include "../abstracttrack.h" 4 #include "../mpegaudio/mpegaudioframe.h" 5 #include "../mp4/mp4ids.h" 6 #include "../matroska/matroskacontainer.h" 8 #include <c++utilities/conversion/binaryconversion.h> 9 #include <c++utilities/conversion/stringconversion.h> 10 #include <c++utilities/io/misc.h> 33 void OverallTests::checkMkvTestfile1()
35 CPPUNIT_ASSERT_EQUAL(ContainerFormat::Matroska, m_fileInfo.containerFormat());
36 const auto tracks = m_fileInfo.tracks();
37 CPPUNIT_ASSERT_EQUAL(2_st, tracks.size());
38 for(
const auto &track : tracks) {
42 CPPUNIT_ASSERT_EQUAL(GeneralMediaFormat::MicrosoftMpeg4, track->format().general);
47 CPPUNIT_ASSERT_EQUAL(48000u, track->samplingFrequency());
50 CPPUNIT_FAIL(
"unknown track ID");
53 const auto tags = m_fileInfo.tags();
56 CPPUNIT_ASSERT(tags.size() == 1);
57 CPPUNIT_ASSERT(tags.front()->value(
KnownField::Title).toString() ==
"Big Buck Bunny - test 1");
59 CPPUNIT_ASSERT(tags.front()->value(
KnownField::Comment).toString() ==
"Matroska Validation File1, basic MPEG4.2 and MP3 with only SimpleBlock");
63 checkMkvTestMetaData();
66 CPPUNIT_ASSERT_EQUAL(0_st, tags.size());
68 CPPUNIT_ASSERT(m_fileInfo.worstNotificationTypeIncludingRelatedObjects() <= NotificationType::Information);
74 void OverallTests::checkMkvTestfile2()
76 CPPUNIT_ASSERT_EQUAL(ContainerFormat::Matroska, m_fileInfo.containerFormat());
77 const auto tracks = m_fileInfo.tracks();
78 CPPUNIT_ASSERT_EQUAL(2_st, tracks.size());
79 for(
const auto &track : tracks) {
84 CPPUNIT_ASSERT(track->displaySize() ==
Size(1354, 576));
89 CPPUNIT_ASSERT(track->samplingFrequency() == 48000);
92 CPPUNIT_FAIL(
"unknown track ID");
95 const auto tags = m_fileInfo.tags();
98 CPPUNIT_ASSERT(tags.size() == 1);
99 CPPUNIT_ASSERT(tags.front()->value(
KnownField::Title).toString() ==
"Elephant Dream - test 2");
101 CPPUNIT_ASSERT(tags.front()->value(
KnownField::Comment).toString() ==
"Matroska Validation File 2, 100,000 timecode scale, odd aspect ratio, and CRC-32. Codecs are AVC and AAC");
104 checkMkvTestMetaData();
107 CPPUNIT_ASSERT_EQUAL(0_st, tags.size());
109 CPPUNIT_ASSERT(m_fileInfo.worstNotificationTypeIncludingRelatedObjects() <= NotificationType::Information);
115 void OverallTests::checkMkvTestfile3()
117 CPPUNIT_ASSERT_EQUAL(ContainerFormat::Matroska, m_fileInfo.containerFormat());
118 const auto tracks = m_fileInfo.tracks();
119 CPPUNIT_ASSERT_EQUAL(2_st, tracks.size());
120 for(
const auto &track : tracks) {
121 switch(track->id()) {
125 CPPUNIT_ASSERT(track->displaySize() ==
Size(1024, 576));
130 CPPUNIT_ASSERT(track->samplingFrequency() == 48000);
133 CPPUNIT_FAIL(
"unknown track ID");
136 const auto tags = m_fileInfo.tags();
137 switch(m_tagStatus) {
139 CPPUNIT_ASSERT(tags.size() == 1);
140 CPPUNIT_ASSERT(tags.front()->value(
KnownField::Title).toString() ==
"Elephant Dream - test 3");
142 CPPUNIT_ASSERT(tags.front()->value(
KnownField::Comment).toString() ==
"Matroska Validation File 3, header stripping on the video track and no SimpleBlock");
145 checkMkvTestMetaData();
148 CPPUNIT_ASSERT_EQUAL(0_st, tags.size());
150 CPPUNIT_ASSERT(m_fileInfo.worstNotificationTypeIncludingRelatedObjects() <= NotificationType::Information);
158 void OverallTests::checkMkvTestfile4()
160 CPPUNIT_ASSERT_EQUAL(ContainerFormat::Matroska, m_fileInfo.containerFormat());
162 const auto tracks = m_fileInfo.tracks();
163 CPPUNIT_ASSERT_EQUAL(2_st, tracks.size());
164 for(
const auto &track : tracks) {
165 switch(track->id()) {
168 CPPUNIT_ASSERT(track->format() == GeneralMediaFormat::Theora);
169 CPPUNIT_ASSERT(track->displaySize() ==
Size(1280, 720));
173 CPPUNIT_ASSERT(track->format() == GeneralMediaFormat::Vorbis);
174 CPPUNIT_ASSERT(track->samplingFrequency() == 48000);
175 CPPUNIT_ASSERT(track->channelCount() == 2);
176 switch(m_tagStatus) {
179 CPPUNIT_ASSERT_EQUAL(
"und"s, track->language());
180 CPPUNIT_ASSERT_EQUAL(
string(), track->name());
181 CPPUNIT_ASSERT(track->isEnabled());
182 CPPUNIT_ASSERT(!track->isForced());
183 CPPUNIT_ASSERT(!track->isDefault());
186 CPPUNIT_ASSERT_EQUAL(
"ger"s, track->language());
187 CPPUNIT_ASSERT_EQUAL(
"the name"s, track->name());
188 CPPUNIT_ASSERT(track->isEnabled());
189 CPPUNIT_ASSERT(track->isForced());
190 CPPUNIT_ASSERT(track->isDefault());
195 CPPUNIT_FAIL(
"unknown track ID");
198 const auto tags = m_fileInfo.tags();
199 switch(m_tagStatus) {
202 CPPUNIT_ASSERT_EQUAL(0_st, tags.size());
205 checkMkvTestMetaData();
210 CPPUNIT_ASSERT(m_fileInfo.worstNotificationTypeIncludingRelatedObjects() <= NotificationType::Critical);
216 void OverallTests::checkMkvTestfile5()
218 CPPUNIT_ASSERT_EQUAL(ContainerFormat::Matroska, m_fileInfo.containerFormat());
219 const auto tracks = m_fileInfo.tracks();
220 CPPUNIT_ASSERT_EQUAL(11_st, tracks.size());
221 for(
const auto &track : tracks) {
222 switch(track->id()) {
226 CPPUNIT_ASSERT(track->displaySize() ==
Size(1024, 576));
231 CPPUNIT_ASSERT(track->samplingFrequency() == 48000);
235 CPPUNIT_ASSERT(track->mediaType() == MediaType::Text);
237 CPPUNIT_ASSERT(track->language() ==
"ger");
243 const auto tags = m_fileInfo.tags();
244 switch(m_tagStatus) {
246 CPPUNIT_ASSERT(tags.size() == 1);
247 CPPUNIT_ASSERT(tags.front()->value(
KnownField::Title).toString() ==
"Big Buck Bunny - test 8");
249 CPPUNIT_ASSERT(tags.front()->value(
KnownField::Comment).toString() ==
"Matroska Validation File 8, secondary audio commentary track, misc subtitle tracks");
252 checkMkvTestMetaData();
255 CPPUNIT_ASSERT_EQUAL(0_st, tags.size());
257 CPPUNIT_ASSERT(m_fileInfo.worstNotificationTypeIncludingRelatedObjects() <= NotificationType::Information);
263 void OverallTests::checkMkvTestfile6()
265 CPPUNIT_ASSERT_EQUAL(ContainerFormat::Matroska, m_fileInfo.containerFormat());
266 const auto tracks = m_fileInfo.tracks();
267 CPPUNIT_ASSERT_EQUAL(2_st, tracks.size());
268 for(
const auto &track : tracks) {
269 switch(track->id()) {
272 CPPUNIT_ASSERT(track->format() == GeneralMediaFormat::MicrosoftMpeg4);
273 CPPUNIT_ASSERT(track->pixelSize() ==
Size(854, 480));
278 CPPUNIT_ASSERT(track->samplingFrequency() == 48000);
279 CPPUNIT_ASSERT(track->channelConfig() ==
static_cast<byte
>(MpegChannelMode::Stereo));
282 CPPUNIT_FAIL(
"unknown track ID");
285 const auto tags = m_fileInfo.tags();
286 switch(m_tagStatus) {
288 CPPUNIT_ASSERT(tags.size() == 1);
289 CPPUNIT_ASSERT(tags.front()->value(
KnownField::Title).toString() ==
"Big Buck Bunny - test 6");
291 CPPUNIT_ASSERT(tags.front()->value(
KnownField::Comment).toString() ==
"Matroska Validation File 6, random length to code the size of Clusters and Blocks, no Cues for seeking");
294 checkMkvTestMetaData();
297 CPPUNIT_ASSERT_EQUAL(0_st, tags.size());
299 CPPUNIT_ASSERT(m_fileInfo.worstNotificationTypeIncludingRelatedObjects() <= NotificationType::Information);
305 void OverallTests::checkMkvTestfile7()
307 CPPUNIT_ASSERT_EQUAL(ContainerFormat::Matroska, m_fileInfo.containerFormat());
308 const auto tracks = m_fileInfo.tracks();
309 CPPUNIT_ASSERT_EQUAL(2_st, tracks.size());
310 for(
const auto &track : tracks) {
311 switch(track->id()) {
315 CPPUNIT_ASSERT(track->pixelSize() ==
Size(1024, 576));
316 CPPUNIT_ASSERT(!strcmp(track->chromaFormat(),
"YUV 4:2:0"));
321 CPPUNIT_ASSERT(track->samplingFrequency() == 48000);
325 CPPUNIT_FAIL(
"unknown track ID");
328 const auto tags = m_fileInfo.tags();
329 switch(m_tagStatus) {
331 CPPUNIT_ASSERT_EQUAL(1_st, tags.size());
332 CPPUNIT_ASSERT_EQUAL(
"Big Buck Bunny - test 7"s, tags.front()->value(
KnownField::Title).toString());
334 CPPUNIT_ASSERT_EQUAL(
"Matroska Validation File 7, junk elements are present at the beggining or end of clusters, the parser should skip it. There is also a damaged element at 451418"s, tags.front()->value(
KnownField::Comment).toString());
337 checkMkvTestMetaData();
340 CPPUNIT_ASSERT_EQUAL(0_st, tags.size());
343 for(
const Notification ¬ification : m_fileInfo.gatherRelatedNotifications()) {
344 if(notification.type() != NotificationType::Warning) {
347 CPPUNIT_ASSERT(startsWith(notification.context(),
"parsing header of EBML element 0xEA \"cue codec state\" at"));
348 CPPUNIT_ASSERT_EQUAL(
"Data of EBML element seems to be truncated; unable to parse siblings of that element."s, notification.message());
350 CPPUNIT_ASSERT(m_fileInfo.worstNotificationTypeIncludingRelatedObjects() <= NotificationType::Warning);
356 void OverallTests::checkMkvTestfile8()
358 CPPUNIT_ASSERT_EQUAL(ContainerFormat::Matroska, m_fileInfo.containerFormat());
359 const auto tracks = m_fileInfo.tracks();
360 CPPUNIT_ASSERT_EQUAL(2_st, tracks.size());
361 for(
const auto &track : tracks) {
362 switch(track->id()) {
366 CPPUNIT_ASSERT(track->pixelSize() ==
Size(1024, 576));
367 CPPUNIT_ASSERT(!strcmp(track->chromaFormat(),
"YUV 4:2:0"));
372 CPPUNIT_ASSERT(track->samplingFrequency() == 48000);
376 CPPUNIT_FAIL(
"unknown track ID");
379 const auto tags = m_fileInfo.tags();
380 switch(m_tagStatus) {
382 CPPUNIT_ASSERT_EQUAL(1_st, tags.size());
383 CPPUNIT_ASSERT_EQUAL(
"Big Buck Bunny - test 8"s, tags.front()->value(
KnownField::Title).toString());
385 CPPUNIT_ASSERT_EQUAL(
"Matroska Validation File 8, audio missing between timecodes 6.019s and 6.360s"s, tags.front()->value(
KnownField::Comment).toString());
388 checkMkvTestMetaData();
391 CPPUNIT_ASSERT_EQUAL(0_st, tags.size());
393 CPPUNIT_ASSERT(m_fileInfo.worstNotificationTypeIncludingRelatedObjects() <= NotificationType::Information);
399 void OverallTests::checkMkvTestfileHandbrakeChapters()
401 CPPUNIT_ASSERT_EQUAL(ContainerFormat::Matroska, m_fileInfo.containerFormat());
402 const auto tracks = m_fileInfo.tracks();
403 CPPUNIT_ASSERT_EQUAL(2_st, tracks.size());
404 for(
const auto &track : tracks) {
405 switch(track->id()) {
409 CPPUNIT_ASSERT_EQUAL(4.0, track->version());
410 CPPUNIT_ASSERT(track->pixelSize() ==
Size(1280, 544));
411 CPPUNIT_ASSERT(track->displaySize() ==
Size(1280, 544));
412 CPPUNIT_ASSERT(track->fps() == 23);
417 CPPUNIT_ASSERT(track->samplingFrequency() == 44100);
421 CPPUNIT_FAIL(argsToString(
"unknown track ID ", track->id()));
424 const auto chapters = m_fileInfo.chapters();
425 CPPUNIT_ASSERT_EQUAL(2_st, chapters.size());
426 for(
const auto &chapter : chapters) {
427 switch(chapter->id()) {
429 CPPUNIT_ASSERT(!strcmp(chapter->names().at(0).data(),
"Kapitel 01"));
430 CPPUNIT_ASSERT_EQUAL(0l, chapter->startTime().totalTicks());
431 CPPUNIT_ASSERT_EQUAL(15, chapter->endTime().seconds());
434 CPPUNIT_ASSERT(!strcmp(chapter->names().at(0).data(),
"Kapitel 02"));
435 CPPUNIT_ASSERT_EQUAL(15, chapter->startTime().seconds());
436 CPPUNIT_ASSERT_EQUAL(27, chapter->endTime().seconds());
439 CPPUNIT_FAIL(argsToString(
"unknown chapter ID ", chapter->id()));
442 const auto tags = m_fileInfo.tags();
443 switch(m_tagStatus) {
445 CPPUNIT_ASSERT_EQUAL(2_st, tags.size());
446 CPPUNIT_ASSERT(tags[0]->target().isEmpty());
447 CPPUNIT_ASSERT_EQUAL(
""s, static_cast<MatroskaTag *>(tags[0])->value(
"CREATION_TIME").toString());
449 CPPUNIT_ASSERT_EQUAL(2_st, tags[1]->target().tracks().at(0));
450 CPPUNIT_ASSERT_EQUAL(
"eng"s, tags[1]->value(KnownField::Language).toString());
453 checkMkvTestMetaData();
456 CPPUNIT_ASSERT_EQUAL(0_st, tags.size());
458 CPPUNIT_ASSERT(m_fileInfo.worstNotificationTypeIncludingRelatedObjects() <= NotificationType::Information);
464 void OverallTests::checkMkvTestfileNestedTags()
466 CPPUNIT_ASSERT_EQUAL(ContainerFormat::Matroska, m_fileInfo.containerFormat());
467 const auto tags = m_fileInfo.tags();
468 bool generalTagFound =
false;
469 switch(m_tagStatus) {
472 CPPUNIT_ASSERT_EQUAL(5_st, tags.size());
473 for(
const Tag *tag : tags) {
474 CPPUNIT_ASSERT(tag->type() == TagType::MatroskaTag);
475 const auto *mkvTag =
static_cast<const MatroskaTag *
>(tag);
476 const auto &target = mkvTag->
target();
477 if(target.level() == 50 && target.tracks().empty()) {
478 generalTagFound =
true;
480 const auto &fields = mkvTag->fields();
482 CPPUNIT_ASSERT(artistField != fields.end());
483 CPPUNIT_ASSERT_EQUAL(
"Test artist"s, artistField->second.value().toString());
484 const auto &nestedFields = artistField->second.nestedFields();
485 CPPUNIT_ASSERT_EQUAL(1_st, nestedFields.size());
486 CPPUNIT_ASSERT_EQUAL(
"ADDRESS"s, nestedFields[0].idToString());
487 CPPUNIT_ASSERT_EQUAL(
"Test address"s, nestedFields[0].value().toString());
490 CPPUNIT_ASSERT(generalTagFound);
493 CPPUNIT_ASSERT_EQUAL(0_st, tags.size());
498 for(
const Notification ¬ification : m_fileInfo.gatherRelatedNotifications()) {
499 if(notification.type() != NotificationType::Warning) {
502 CPPUNIT_ASSERT(startsWith(notification.message(),
"\"SimpleTag\"-element contains unknown element 0x44B4 at"));
504 CPPUNIT_ASSERT(m_fileInfo.worstNotificationTypeIncludingRelatedObjects() <= NotificationType::Warning);
510 void OverallTests::checkMkvTestMetaData()
513 const auto tags = m_fileInfo.tags();
514 const auto tracks = m_fileInfo.tracks();
515 CPPUNIT_ASSERT_EQUAL(2_st, tags.size());
516 CPPUNIT_ASSERT_EQUAL(m_testTitle.toString(), tags.front()->value(
KnownField::Title).toString());
518 CPPUNIT_ASSERT_EQUAL(m_testComment.toString(), tags.front()->value(
KnownField::Comment).toString());
519 CPPUNIT_ASSERT_EQUAL(30_st, tags[1]->target().level());
520 CPPUNIT_ASSERT_EQUAL(tracks.at(0)->id(), tags[1]->target().tracks().at(0));
521 CPPUNIT_ASSERT_EQUAL(m_testAlbum.toString(), tags[1]->value(
KnownField::Album).toString());
522 CPPUNIT_ASSERT_EQUAL(m_testPartNumber.toInteger(), tags[1]->value(KnownField::PartNumber).toInteger());
523 CPPUNIT_ASSERT_EQUAL(m_testTotalParts.toInteger(), tags[1]->value(KnownField::TotalParts).toInteger());
526 const auto attachments = m_fileInfo.attachments();
527 CPPUNIT_ASSERT_EQUAL(1_st, attachments.size());
528 CPPUNIT_ASSERT(attachments[0]->mimeType() ==
"image/png");
529 CPPUNIT_ASSERT(attachments[0]->name() ==
"cover.jpg");
531 CPPUNIT_ASSERT(attachmentData !=
nullptr);
532 if (m_testCover.empty()) {
533 m_testCover = readFile(testFilePath(
"matroska_wave1/logo3_256x256.png"), 20000);
535 CPPUNIT_ASSERT_EQUAL(m_testCover.size(),
static_cast<size_t>(attachmentData->
size()));
536 istream &attachmentSteam = attachmentData->
stream();
537 attachmentSteam.seekg(attachmentData->
startOffset());
538 for (
char expectedChar : m_testCover) {
539 CPPUNIT_ASSERT_EQUAL(expectedChar, static_cast<char>(attachmentSteam.get()));
546 void OverallTests::checkMkvConstraints()
550 CPPUNIT_ASSERT(m_fileInfo.container());
553 CPPUNIT_ASSERT_EQUAL(4096_st, m_fileInfo.paddingSize());
555 CPPUNIT_ASSERT(m_fileInfo.paddingSize() >= 1024);
556 CPPUNIT_ASSERT(m_fileInfo.paddingSize() <= (4096 + 1024));
558 if(!(m_mode &
RemoveTag) && (m_expectedTagPos != ElementPosition::Keep) && ((m_mode & ForceRewring) || (m_mode &
ForceTagPos))) {
559 CPPUNIT_ASSERT_EQUAL(m_expectedTagPos, m_fileInfo.container()->determineTagPosition());
562 CPPUNIT_ASSERT_EQUAL(m_expectedIndexPos, m_fileInfo.container()->determineIndexPosition());
570 void OverallTests::setMkvTestMetaData()
572 CPPUNIT_ASSERT_EQUAL(ContainerFormat::Matroska, m_fileInfo.containerFormat());
576 const string fileName(m_fileInfo.fileName());
577 if(fileName ==
"test4.mkv") {
582 CPPUNIT_ASSERT(track);
588 }
else if(fileName ==
"handbrake-chapters-2.mkv") {
590 m_fileInfo.removeTag(m_fileInfo.tags().at(1));
592 Tag *firstTag = m_fileInfo.tags().at(0);
597 trackIds.emplace_back(m_fileInfo.tracks().at(0)->id());
598 Tag *newTag = container->createTag(
TagTarget(30, trackIds));
599 CPPUNIT_ASSERT_MESSAGE(
"create tag", newTag);
601 newTag->
setValue(KnownField::PartNumber, m_testPartNumber);
602 newTag->
setValue(KnownField::TotalParts, m_testTotalParts);
605 CPPUNIT_ASSERT_MESSAGE(
"create attachment", attachment);
606 attachment->
setFile(TestUtilities::testFilePath(
"matroska_wave1/logo3_256x256.png"));
608 attachment->
setName(
"cover.jpg");
616 void OverallTests::createMkvWithNestedTags()
619 m_nestedTagsMkvPath = workingCopyPathMode(
"mtx-test-data/mkv/nested-tags.mkv", WorkingCopyMode::NoCopy);
620 remove(m_nestedTagsMkvPath.data());
622 cerr <<
"\n\n- Create testfile \"" << m_nestedTagsMkvPath <<
"\" with mkvmerge" << endl;
623 const string tagsMkvPath(testFilePath(
"mtx-test-data/mkv/tags.mkv"));
624 const string tagsXmlPath(testFilePath(
"mkv/nested-tags.xml"));
625 const char *
const mkvmergeArgs[] = {
626 "--ui-language en_US",
627 "--output", m_nestedTagsMkvPath.data(),
628 "--no-global-tags",
"--language",
"0:und",
"--default-track",
"0:yes",
"--language",
"1:und",
"--default-track",
"1:yes",
629 "(", tagsMkvPath.data(),
")",
630 "--global-tags", tagsXmlPath.data(),
"--track-order",
"0:0,0:1",
nullptr 632 string mkvmergeOutput, mkvmergeErrors;
633 int res = execHelperApp(
"/bin/mkvmerge", mkvmergeArgs, mkvmergeOutput, mkvmergeErrors);
634 cout << mkvmergeOutput << endl;
635 cerr << mkvmergeErrors << endl;
637 cerr <<
"- failure (exit code " << res <<
"); unable to test nested tags" << endl;
638 remove(m_nestedTagsMkvPath.data());
639 m_nestedTagsMkvPath.clear();
649 cerr << endl <<
"Matroska parser" << endl;
650 m_fileInfo.setForceFullParse(
false);
652 parseFile(TestUtilities::testFilePath(
"matroska_wave1/test1.mkv"), &OverallTests::checkMkvTestfile1);
653 parseFile(TestUtilities::testFilePath(
"matroska_wave1/test2.mkv"), &OverallTests::checkMkvTestfile2);
654 parseFile(TestUtilities::testFilePath(
"matroska_wave1/test3.mkv"), &OverallTests::checkMkvTestfile3);
655 parseFile(TestUtilities::testFilePath(
"matroska_wave1/test4.mkv"), &OverallTests::checkMkvTestfile4);
656 parseFile(TestUtilities::testFilePath(
"matroska_wave1/test5.mkv"), &OverallTests::checkMkvTestfile5);
657 parseFile(TestUtilities::testFilePath(
"matroska_wave1/test6.mkv"), &OverallTests::checkMkvTestfile6);
658 parseFile(TestUtilities::testFilePath(
"matroska_wave1/test7.mkv"), &OverallTests::checkMkvTestfile7);
659 parseFile(TestUtilities::testFilePath(
"matroska_wave1/test8.mkv"), &OverallTests::checkMkvTestfile8);
660 parseFile(TestUtilities::testFilePath(
"mtx-test-data/mkv/handbrake-chapters-2.mkv"), &OverallTests::checkMkvTestfileHandbrakeChapters);
661 createMkvWithNestedTags();
662 if(!m_nestedTagsMkvPath.empty()) {
663 parseFile(m_nestedTagsMkvPath, &OverallTests::checkMkvTestfileNestedTags);
675 void OverallTests::testMkvMakingWithDifferentSettings()
678 m_fileInfo.setForceFullParse(
true);
681 for(m_mode = 0; m_mode != 0x100; ++m_mode) {
687 m_fileInfo.setTagPosition(ElementPosition::Keep);
689 m_fileInfo.setTagPosition(m_mode &
TagsBeforeData ? ElementPosition::BeforeData : ElementPosition::AfterData);
695 m_fileInfo.setIndexPosition(ElementPosition::Keep);
697 m_fileInfo.setIndexPosition(m_mode &
IndexBeforeData ? ElementPosition::BeforeData : ElementPosition::AfterData);
700 m_fileInfo.setMinPadding(m_mode & PaddingConstraints ? 1024 : 0);
701 m_fileInfo.setMaxPadding(m_mode & PaddingConstraints ? (4096 + 1024) : static_cast<size_t>(-1));
702 m_fileInfo.setForceTagPosition(m_mode &
ForceTagPos);
706 list<string> testConditions;
707 if(m_mode & ForceRewring) {
708 testConditions.emplace_back(
"forcing rewrite");
710 if(m_mode & KeepTagPos) {
712 testConditions.emplace_back(
"removing tag");
714 testConditions.emplace_back(
"keeping tag position");
717 testConditions.emplace_back(
"tags before data");
719 testConditions.emplace_back(
"tags after data");
721 if(m_mode & KeepIndexPos) {
722 testConditions.emplace_back(
"keeping index position");
724 testConditions.emplace_back(
"index before data");
726 testConditions.emplace_back(
"index after data");
728 if(m_mode & PaddingConstraints) {
729 testConditions.emplace_back(
"padding constraints");
731 if(m_mode & ForceTagPos) {
732 testConditions.emplace_back(
"forcing tag position");
734 if(m_mode & ForceIndexPos) {
735 testConditions.emplace_back(
"forcing index position");
737 cerr << endl <<
"Matroska maker - testmode " << m_mode <<
": " << joinStrings(testConditions,
", ") << endl;
741 void (
OverallTests::*modifyRoutine)(void) = (m_mode &
RemoveTag) ? &OverallTests::removeAllTags : &OverallTests::setMkvTestMetaData;
742 makeFile(TestUtilities::workingCopyPath(
"matroska_wave1/test1.mkv"), modifyRoutine, &OverallTests::checkMkvTestfile1);
743 makeFile(TestUtilities::workingCopyPath(
"matroska_wave1/test2.mkv"), modifyRoutine, &OverallTests::checkMkvTestfile2);
744 makeFile(TestUtilities::workingCopyPath(
"matroska_wave1/test3.mkv"), modifyRoutine, &OverallTests::checkMkvTestfile3);
745 makeFile(TestUtilities::workingCopyPath(
"matroska_wave1/test4.mkv"), modifyRoutine, &OverallTests::checkMkvTestfile4);
746 makeFile(TestUtilities::workingCopyPath(
"matroska_wave1/test5.mkv"), modifyRoutine, &OverallTests::checkMkvTestfile5);
747 makeFile(TestUtilities::workingCopyPath(
"matroska_wave1/test6.mkv"), modifyRoutine, &OverallTests::checkMkvTestfile6);
748 makeFile(TestUtilities::workingCopyPath(
"matroska_wave1/test7.mkv"), modifyRoutine, &OverallTests::checkMkvTestfile7);
749 makeFile(TestUtilities::workingCopyPath(
"matroska_wave1/test8.mkv"), modifyRoutine, &OverallTests::checkMkvTestfile8);
750 makeFile(TestUtilities::workingCopyPath(
"mtx-test-data/mkv/handbrake-chapters-2.mkv"), modifyRoutine, &OverallTests::checkMkvTestfileHandbrakeChapters);
758 void OverallTests::testMkvMakingNestedTags()
760 createMkvWithNestedTags();
761 if(!m_nestedTagsMkvPath.empty()) {
762 cerr << endl <<
"Matroska maker - rewrite file with nested tags" << endl;
763 m_fileInfo.setMinPadding(0);
764 m_fileInfo.setMaxPadding(0);
765 m_fileInfo.setTagPosition(ElementPosition::BeforeData);
766 m_fileInfo.setIndexPosition(ElementPosition::BeforeData);
767 makeFile(m_nestedTagsMkvPath, &OverallTests::noop, &OverallTests::checkMkvTestfileNestedTags);
The OverallTests class tests reading and writing tags and parsing technical information for all suppo...
void testMkvParsing()
Tests the Matroska parser via MediaFileInfo.