DCPOMATIC_ASSERT (film()->directory());
+ auto mapped = film()->mapped_audio_channels();
+ std::vector<dcp::Channel> extra_active_channels;
+ auto add_if_mapped = [mapped, &extra_active_channels](dcp::Channel channel) {
+ if (std::find(mapped.begin(), mapped.end(), static_cast<int>(channel)) != mapped.end()) {
+ extra_active_channels.push_back(channel);
+ }
+ };
+
+ add_if_mapped(dcp::Channel::HI);
+ add_if_mapped(dcp::Channel::VI);
+ add_if_mapped(dcp::Channel::BSL);
+ add_if_mapped(dcp::Channel::BSR);
+
/* Write the sound asset into the film directory so that we leave the creation
of the DCP directory until the last minute.
*/
_sound_asset_writer = _sound_asset->start_write (
film()->directory().get() / audio_asset_filename (_sound_asset, _reel_index, _reel_count, _content_summary),
- film()->audio_channels(),
+ extra_active_channels,
film()->contains_atmos_content() ? dcp::SoundAsset::AtmosSync::ENABLED : dcp::SoundAsset::AtmosSync::DISABLED,
film()->limit_to_smpte_bv20() ? dcp::SoundAsset::MCASubDescriptors::DISABLED : dcp::SoundAsset::MCASubDescriptors::ENABLED
);
--- /dev/null
+/*
+ Copyright (C) 2023 Carl Hetherington <cth@carlh.net>
+
+ This file is part of DCP-o-matic.
+
+ DCP-o-matic is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ DCP-o-matic is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+
+#include "lib/audio_content.h"
+#include "lib/constants.h"
+#include "lib/content.h"
+#include "lib/content_factory.h"
+#include "lib/film.h"
+#include "test.h"
+#include <libcxml/cxml.h>
+#include <boost/test/unit_test.hpp>
+
+
+using std::shared_ptr;
+using std::string;
+using std::vector;
+
+
+static
+void
+test_descriptors(vector<dcp::Channel> channels, vector<string> mca_tag_symbols, string group_name)
+{
+ auto content = content_factory("test/data/flat_red.png");
+ for (auto i = 0U; i < channels.size(); ++i) {
+ content.push_back(content_factory("test/data/C.wav").front());
+ }
+ auto film = new_test_film2("mca_subdescriptors_written_correctly", content);
+ film->set_interop(false);
+
+ int N = 1;
+ for (auto channel: channels) {
+ auto mapping = AudioMapping(1, MAX_DCP_AUDIO_CHANNELS);
+ mapping.set(0, channel, 1);
+ content[N]->audio->set_mapping(mapping);
+ ++N;
+ }
+
+ make_and_verify_dcp(film);
+
+ cxml::Document check("CompositionPlaylist", find_file(film->dir(film->dcp_name()), "cpl_"));
+ vector<string> cpl_mca_tag_symbols;
+
+ auto mca_sub_descriptors = check.node_child("ReelList")->node_child("Reel")->node_child("AssetList")->node_child("CompositionMetadataAsset")->node_child("MCASubDescriptors");
+
+ for (auto node: mca_sub_descriptors->node_children("AudioChannelLabelSubDescriptor")) {
+ cpl_mca_tag_symbols.push_back(node->string_child("MCATagSymbol"));
+ }
+
+ auto const cpl_group_name = mca_sub_descriptors->node_child("SoundfieldGroupLabelSubDescriptor")->string_child("MCATagSymbol");
+
+ BOOST_CHECK(cpl_mca_tag_symbols == mca_tag_symbols);
+ BOOST_CHECK(cpl_group_name == group_name);
+}
+
+
+BOOST_AUTO_TEST_CASE(mca_subdescriptors_written_correctly_mono)
+{
+ test_descriptors({ dcp::Channel::CENTRE }, { "chL", "chR", "chC", "chLFE", "chLs", "chRs" }, "sg51");
+}
+
+
+BOOST_AUTO_TEST_CASE(mca_subdescriptors_written_correctly_stereo)
+{
+ test_descriptors({ dcp::Channel::LEFT, dcp::Channel::RIGHT }, { "chL", "chR", "chC", "chLFE", "chLs", "chRs" }, "sg51");
+}
+
+
+BOOST_AUTO_TEST_CASE(mca_subdescriptors_written_correctly_51)
+{
+ test_descriptors(
+ {
+ dcp::Channel::LEFT,
+ dcp::Channel::RIGHT,
+ dcp::Channel::CENTRE,
+ dcp::Channel::LFE,
+ dcp::Channel::LS,
+ dcp::Channel::RS,
+ },
+ { "chL", "chR", "chC", "chLFE", "chLs", "chRs" },
+ "sg51"
+ );
+}
+
+
+BOOST_AUTO_TEST_CASE(mca_subdescriptors_written_correctly_51_with_hi_vi)
+{
+ test_descriptors(
+ {
+ dcp::Channel::LEFT,
+ dcp::Channel::RIGHT,
+ dcp::Channel::CENTRE,
+ dcp::Channel::LFE,
+ dcp::Channel::LS,
+ dcp::Channel::RS,
+ dcp::Channel::HI,
+ dcp::Channel::VI,
+ },
+ { "chL", "chR", "chC", "chLFE", "chLs", "chRs", "chHI", "chVIN" },
+ "sg51"
+ );
+}
+
+
+BOOST_AUTO_TEST_CASE(mca_subdescriptors_written_correctly_71)
+{
+ test_descriptors(
+ {
+ dcp::Channel::LEFT,
+ dcp::Channel::RIGHT,
+ dcp::Channel::CENTRE,
+ dcp::Channel::LFE,
+ dcp::Channel::LS,
+ dcp::Channel::RS,
+ dcp::Channel::BSL,
+ dcp::Channel::BSR,
+ },
+ { "chL", "chR", "chC", "chLFE", "chLss", "chRss", "chLrs", "chRrs" },
+ "sg71"
+ );
+}
+
+
+BOOST_AUTO_TEST_CASE(mca_subdescriptors_written_correctly_71_with_hi_vi)
+{
+ test_descriptors(
+ {
+ dcp::Channel::LEFT,
+ dcp::Channel::RIGHT,
+ dcp::Channel::CENTRE,
+ dcp::Channel::LFE,
+ dcp::Channel::LS,
+ dcp::Channel::RS,
+ dcp::Channel::HI,
+ dcp::Channel::VI,
+ dcp::Channel::BSL,
+ dcp::Channel::BSR,
+ },
+ { "chL", "chR", "chC", "chLFE", "chLss", "chRss", "chHI", "chVIN", "chLrs", "chRrs" },
+ "sg71"
+ );
+}