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/content_factory.h"
25 #include <dcp/warnings.h>
26 LIBDCP_DISABLE_WARNINGS
27 #include <asdcp/Metadata.h>
28 LIBDCP_ENABLE_WARNINGS
29 #include <dcp/sound_asset.h>
31 #include <boost/test/unit_test.hpp>
34 using std::shared_ptr;
38 has_cpl_mca_subdescriptors(shared_ptr<const Film> film)
40 auto cpl = dcp::file_to_string(find_file(film->dir(film->dcp_name()), "cpl_"));
41 return cpl.find("MCASubDescriptors") != std::string::npos;
46 has_mxf_mca_subdescriptors(shared_ptr<const Film> film)
48 /* One day hopefully libdcp will read these descriptors and we can find out from the SoundAsset
52 Kumu::FileReaderFactory factory;
53 ASDCP::PCM::MXFReader reader(factory);
54 auto r = reader.OpenRead(find_file(film->dir(film->dcp_name()), "pcm_").string());
55 BOOST_REQUIRE(!ASDCP_FAILURE(r));
57 ASDCP::MXF::WaveAudioDescriptor* essence_descriptor = nullptr;
58 auto const rr = reader.OP1aHeader().GetMDObjectByType(
59 dcp::asdcp_smpte_dict->ul(ASDCP::MDD_WaveAudioDescriptor),
60 reinterpret_cast<ASDCP::MXF::InterchangeObject**>(&essence_descriptor)
63 if (!KM_SUCCESS(rr)) {
67 return essence_descriptor->SubDescriptors.size() > 0;
71 BOOST_AUTO_TEST_CASE(bv21_extensions_used_when_not_limited)
73 auto picture = content_factory("test/data/flat_red.png");
74 auto sound = content_factory("test/data/sine_440.wav");
75 auto film = new_test_film2("bv21_extensions_used_when_not_limited", { picture.front(), sound.front() });
77 make_and_verify_dcp(film);
79 BOOST_CHECK(has_cpl_mca_subdescriptors(film));
80 BOOST_CHECK(has_mxf_mca_subdescriptors(film));
84 BOOST_AUTO_TEST_CASE(bv21_extensions_not_used_when_limited)
86 auto picture = content_factory("test/data/flat_red.png");
87 auto sound = content_factory("test/data/sine_440.wav");
88 auto film = new_test_film2("bv21_extensions_not_used_when_limited", { picture.front(), sound.front () });
89 film->set_limit_to_smpte_bv20(true);
91 make_and_verify_dcp(film);
93 BOOST_CHECK(!has_cpl_mca_subdescriptors(film));
94 BOOST_CHECK(!has_mxf_mca_subdescriptors(film));