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 ASDCP::PCM::MXFReader reader;
53 auto r = reader.OpenRead(find_file(film->dir(film->dcp_name()), "pcm_").string());
54 BOOST_REQUIRE(!ASDCP_FAILURE(r));
56 ASDCP::MXF::WaveAudioDescriptor* essence_descriptor = nullptr;
57 auto const rr = reader.OP1aHeader().GetMDObjectByType(
58 dcp::asdcp_smpte_dict->ul(ASDCP::MDD_WaveAudioDescriptor),
59 reinterpret_cast<ASDCP::MXF::InterchangeObject**>(&essence_descriptor)
62 if (!KM_SUCCESS(rr)) {
66 return essence_descriptor->SubDescriptors.size() > 0;
70 BOOST_AUTO_TEST_CASE(bv21_extensions_used_when_not_limited)
72 auto picture = content_factory("test/data/flat_red.png");
73 auto sound = content_factory("test/data/sine_440.wav");
74 auto film = new_test_film2("bv21_extensions_used_when_not_limited", { picture.front(), sound.front() });
76 make_and_verify_dcp(film);
78 BOOST_CHECK(has_cpl_mca_subdescriptors(film));
79 BOOST_CHECK(has_mxf_mca_subdescriptors(film));
83 BOOST_AUTO_TEST_CASE(bv21_extensions_not_used_when_limited)
85 auto picture = content_factory("test/data/flat_red.png");
86 auto sound = content_factory("test/data/sine_440.wav");
87 auto film = new_test_film2("bv21_extensions_not_used_when_limited", { picture.front(), sound.front () });
88 film->set_limit_to_smpte_bv20(true);
90 make_and_verify_dcp(film);
92 BOOST_CHECK(!has_cpl_mca_subdescriptors(film));
93 BOOST_CHECK(!has_mxf_mca_subdescriptors(film));