Skip to content

Commit d31e739

Browse files
committed
add audioFormatExtended version
1 parent 77fc3ba commit d31e739

File tree

7 files changed

+62
-1
lines changed

7 files changed

+62
-1
lines changed

include/adm/document.hpp

+11-1
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,24 @@
22
#pragma once
33

44
#include <memory>
5+
#include <string>
56
#include <vector>
67
#include "adm/elements.hpp"
78
#include "adm/detail/auto_base.hpp"
89
#include "adm/detail/id_assigner.hpp"
10+
#include "adm/detail/named_type.hpp"
911
#include "adm/export.h"
1012

1113
namespace adm {
1214

15+
/// tag for version
16+
struct VersionTag {};
17+
/// NamedType for audioFormatExtended version attribute
18+
using Version = detail::NamedType<std::string, VersionTag>;
19+
1320
namespace detail {
14-
using DocumentBase = HasParameters<OptionalParameter<ProfileList>>;
21+
using DocumentBase = HasParameters<OptionalParameter<ProfileList>,
22+
OptionalParameter<Version>>;
1523
}
1624

1725
/**
@@ -266,6 +274,8 @@ namespace adm {
266274

267275
using detail::DocumentBase::get;
268276
using detail::DocumentBase::has;
277+
using detail::DocumentBase::isDefault;
278+
using detail::DocumentBase::unset;
269279

270280
friend class detail::AddWrapperMethods<Document>;
271281

src/private/xml_parser.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ namespace adm {
9797
resolveReference(streamFormatChannelFormatRef_);
9898
resolveReference(streamFormatPackFormatRef_);
9999
resolveReferences(streamFormatTrackFormatRefs_);
100+
101+
setOptionalAttribute<Version>(root, "version", document_);
100102
} else {
101103
throw error::XmlParsingError("audioFormatExtended node not found");
102104
}

src/private/xml_writer.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ namespace adm {
3838
root = xmlDocument.addEbuStructure();
3939
}
4040
// clang-format off
41+
root.addOptionalAttribute<Version>(document, "version");
4142
root.addOptionalElement<ProfileList>(document, "profileList", &formatProfileList);
4243
root.addBaseElements<AudioProgramme, AudioProgrammeId>(document, "audioProgramme", &formatAudioProgramme);
4344
root.addBaseElements<AudioContent, AudioContentId>(document, "audioContent", &formatAudioContent);

tests/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ add_adm_test("route_tracer_tests")
6969
add_adm_test("screen_edge_lock_tests")
7070
add_adm_test("speaker_position_tests")
7171
add_adm_test("type_descriptor_tests")
72+
add_adm_test("version_tests")
7273
add_adm_test("xml_audio_block_format_objects_tests")
7374
add_adm_test("xml_loudness_metadata_tests")
7475
add_adm_test("xml_parser_audio_block_format_direct_speakers_tests")

tests/test_data/version.accepted.xml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<ebuCoreMain xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns="urn:ebu:metadata-schema:ebuCore_2014" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" schema="EBU_CORE_20140201.xsd" xml:lang="en">
3+
<coreMetadata>
4+
<format>
5+
<audioFormatExtended version="ITU-R_BS.2076-2"/>
6+
</format>
7+
</coreMetadata>
8+
</ebuCoreMain>
9+
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<ebuCoreMain>
3+
<coreMetadata>
4+
<format>
5+
<audioFormatExtended version="ITU-R_BS.2076-2">
6+
</audioFormatExtended>
7+
</format>
8+
</coreMetadata>
9+
</ebuCoreMain>

tests/version_tests.cpp

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#include <catch2/catch.hpp>
2+
#include "adm/elements/profile_list.hpp"
3+
#include "helper/parameter_checks.hpp"
4+
#include "adm/document.hpp"
5+
#include "adm/parse.hpp"
6+
#include "adm/write.hpp"
7+
#include "helper/file_comparator.hpp"
8+
9+
using namespace adm;
10+
using namespace adm_test;
11+
12+
TEST_CASE("version") {
13+
auto document = Document::create();
14+
15+
check_optional_param<Version>(document,
16+
canBeSetTo(Version{"ITU-R_BS.2076-2"}));
17+
}
18+
19+
TEST_CASE("xml/version") {
20+
auto document = parseXml("xml_parser/version.xml");
21+
22+
REQUIRE(document->has<Version>());
23+
REQUIRE(document->get<Version>().get() == "ITU-R_BS.2076-2");
24+
25+
std::stringstream xml;
26+
writeXml(xml, document);
27+
28+
CHECK_THAT(xml.str(), EqualsXmlFile("version"));
29+
}

0 commit comments

Comments
 (0)