Tag Parser
9.3.0
C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags
|
Go to the documentation of this file.
3 #include "../abstracttrack.h"
4 #include "../mediafileinfo.h"
7 #include <c++utilities/tests/testutils.h>
10 #include <cppunit/TestFixture.h>
11 #include <cppunit/extensions/HelperMacros.h>
16 using namespace CppUtilities::Literals;
19 using namespace CPPUNIT_NS;
27 CPPUNIT_TEST(testInitialStatus);
28 CPPUNIT_TEST(testFileSystemMethods);
29 CPPUNIT_TEST(testParsingUnsupportedFile);
30 CPPUNIT_TEST(testFullParseAndFurtherProperties);
31 CPPUNIT_TEST_SUITE_END();
34 void setUp()
override;
35 void tearDown()
override;
37 void testInitialStatus();
38 void testFileSystemMethods();
39 void testParsingUnsupportedFile();
40 void testPartialParsingAndTagCreationOfMp4File();
42 void testFullParseAndFurtherProperties();
74 CPPUNIT_ASSERT_EQUAL(
"unsupported.bin"s, file.
fileName());
75 CPPUNIT_ASSERT_EQUAL(
"unsupported"s, file.
fileName(
true));
77 CPPUNIT_ASSERT_EQUAL(
".bin"s, file.
extension());
78 CPPUNIT_ASSERT_EQUAL(
static_cast<std::uint64_t
>(0), file.
size());
81 CPPUNIT_ASSERT(file.
isOpen());
83 CPPUNIT_ASSERT_EQUAL(
static_cast<std::uint64_t
>(41), file.
size());
104 MediaFileInfo file(testFilePath(
"mtx-test-data/aac/he-aacv2-ps.m4a"));
110 CPPUNIT_ASSERT_THROW_MESSAGE(
"std::ios_base::failure thrown if file closed", file.
parseTracks(diag), std::ios_base::failure);
120 CPPUNIT_ASSERT_EQUAL(0_st, file.
trackCount());
123 "Parsing attachments is not implemented for the container format of the file.",
"parsing attachments") }),
125 CPPUNIT_ASSERT_EQUAL(DiagLevel::Information, diag.
level());
130 CPPUNIT_ASSERT_EQUAL(0_st, file.
id3v2Tags().size());
132 CPPUNIT_ASSERT(!file.
mp4Tag());
137 CPPUNIT_ASSERT_EQUAL(1_st, file.
id3v2Tags().size());
142 CPPUNIT_ASSERT(file.
mp4Tag());
148 MediaFileInfo file(testFilePath(
"matroska_wave1/test1.mkv"));
159 CPPUNIT_ASSERT_EQUAL(ContainerFormat::Matroska, file.
containerFormat());
165 CPPUNIT_ASSERT_EQUAL(1_st, file.
tags().size());
167 CPPUNIT_ASSERT(!file.
mp4Tag());
170 CPPUNIT_ASSERT_EQUAL(2_st, file.
trackCount());
172 CPPUNIT_ASSERT_EQUAL(0_st, file.
chapters().size());
174 CPPUNIT_ASSERT_EQUAL(0_st, file.
attachments().size());
179 diag.emplace_back(DiagLevel::Warning,
"warning",
"test");
180 CPPUNIT_ASSERT_EQUAL(DiagLevel::Warning, diag.
level());
181 diag.emplace_back(DiagLevel::Critical,
"error",
"test");
182 CPPUNIT_ASSERT_EQUAL(DiagLevel::Critical, diag.
level());
185 file.
tracks().back()->setLanguage(
"eng");
187 CPPUNIT_ASSERT_EQUAL(unordered_set<string>({}), file.
availableLanguages(MediaType::Text));
188 CPPUNIT_ASSERT_EQUAL(
"ID: 2422994868, type: Video"s, file.
tracks()[0]->label());
189 CPPUNIT_ASSERT_EQUAL(
"ID: 3653291187, type: Audio, language: English"s, file.
tracks()[1]->label());
190 CPPUNIT_ASSERT_EQUAL(
"MS-MPEG-4-480p / MP3-2ch-eng"s, file.
technicalSummary());
void invalidate()
Invalidates the file info manually.
static std::string containingDirectory(const std::string &path)
Returns the path of the directory containing the given file.
The Diagnostics class is a container for DiagMessage.
Contains all classes and functions of the TagInfo library.
static std::string extension(const std::string &path)
Returns the extension of the given file.
void open(bool readOnly=false)
Opens a std::fstream for the current file.
DiagLevel level() const
Returns the worst diag level present in the container.
void reportPathChanged(const std::string &newPath)
Call this function to report that the path changed.
bool isReadOnly() const
Indicates whether the last open()/reopen() call was read-only.
bool isOpen() const
Indicates whether a std::fstream is open for the current file.
The DiagMessage class holds an information, warning or error gathered during parsing or making.
static std::string fileName(const std::string &path, bool cutExtension=false)
Returns the file name of the given file.
std::uint64_t size() const
Returns size of the current file in bytes.
void close()
A possibly opened std::fstream will be closed.
static std::string pathWithoutExtension(const std::string &fullPath)
Returns a copy of the given path without the extension/suffix.