2 Copyright (C) 2023 Carl Hetherington <cth@carlh.net>
4 This file is part of DCP-o-matic.
6 DCP-o-matic is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 DCP-o-matic is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
22 #include "lib/audio_content.h"
23 #include "lib/constants.h"
24 #include "lib/content.h"
25 #include "lib/content_factory.h"
28 #include <libcxml/cxml.h>
29 #include <boost/test/unit_test.hpp>
32 using std::shared_ptr;
39 test_descriptors(int mxf_channels, vector<dcp::Channel> active_channels, vector<string> mca_tag_symbols, string group_name)
41 auto content = content_factory("test/data/flat_red.png");
42 for (auto i = 0; i < mxf_channels; ++i) {
43 content.push_back(content_factory("test/data/C.wav").front());
45 auto film = new_test_film2("mca_subdescriptors_written_correctly", content);
46 film->set_interop(false);
47 film->set_audio_channels(mxf_channels);
50 for (auto channel: active_channels) {
51 auto mapping = AudioMapping(1, MAX_DCP_AUDIO_CHANNELS);
52 mapping.set(0, channel, 1);
53 content[N]->audio->set_mapping(mapping);
57 make_and_verify_dcp(film);
59 cxml::Document check("CompositionPlaylist", find_file(film->dir(film->dcp_name()), "cpl_"));
60 vector<string> cpl_mca_tag_symbols;
62 auto mca_sub_descriptors = check.node_child("ReelList")->node_child("Reel")->node_child("AssetList")->node_child("CompositionMetadataAsset")->node_child("MCASubDescriptors");
64 for (auto node: mca_sub_descriptors->node_children("AudioChannelLabelSubDescriptor")) {
65 cpl_mca_tag_symbols.push_back(node->string_child("MCATagSymbol"));
68 auto const cpl_group_name = mca_sub_descriptors->node_child("SoundfieldGroupLabelSubDescriptor")->string_child("MCATagSymbol");
70 BOOST_CHECK(cpl_mca_tag_symbols == mca_tag_symbols);
71 BOOST_CHECK(cpl_group_name == group_name);
75 /* This seems like an impossible case but let's check it anyway */
76 BOOST_AUTO_TEST_CASE(mca_subdescriptors_written_correctly_mono_in_2_channel)
78 test_descriptors(2, { dcp::Channel::CENTRE }, { "chL", "chR" }, "sg51");
82 BOOST_AUTO_TEST_CASE(mca_subdescriptors_written_correctly_mono_in_6_channel)
84 test_descriptors(6, { dcp::Channel::CENTRE }, { "chL", "chR", "chC", "chLFE", "chLs", "chRs" }, "sg51");
88 /* If we only have two channels in the MXF we shouldn't see any extra descriptors */
89 BOOST_AUTO_TEST_CASE(mca_subdescriptors_written_correctly_stereo_in_2_channel)
91 test_descriptors(2, { dcp::Channel::LEFT, dcp::Channel::RIGHT }, { "chL", "chR" }, "sg51");
95 BOOST_AUTO_TEST_CASE(mca_subdescriptors_written_correctly_stereo_in_6_channel)
97 test_descriptors(6, { dcp::Channel::LEFT, dcp::Channel::RIGHT }, { "chL", "chR", "chC", "chLFE", "chLs", "chRs" }, "sg51");
101 BOOST_AUTO_TEST_CASE(mca_subdescriptors_written_correctly_51)
107 dcp::Channel::CENTRE,
112 { "chL", "chR", "chC", "chLFE", "chLs", "chRs" },
118 BOOST_AUTO_TEST_CASE(mca_subdescriptors_written_correctly_51_with_hi_vi)
124 dcp::Channel::CENTRE,
131 { "chL", "chR", "chC", "chLFE", "chLs", "chRs", "chHI", "chVIN" },
137 BOOST_AUTO_TEST_CASE(mca_subdescriptors_written_correctly_71)
143 dcp::Channel::CENTRE,
150 { "chL", "chR", "chC", "chLFE", "chLss", "chRss", "chLrs", "chRrs" },
156 BOOST_AUTO_TEST_CASE(mca_subdescriptors_written_correctly_71_with_hi_vi)
162 dcp::Channel::CENTRE,
171 { "chL", "chR", "chC", "chLFE", "chLss", "chRss", "chHI", "chVIN", "chLrs", "chRrs" },