diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/atmos_test.cc | 91 | ||||
| -rw-r--r-- | test/test.cc | 77 | ||||
| -rw-r--r-- | test/test.h | 1 | ||||
| -rw-r--r-- | test/wscript | 1 |
4 files changed, 170 insertions, 0 deletions
diff --git a/test/atmos_test.cc b/test/atmos_test.cc new file mode 100644 index 000000000..019e2d2fb --- /dev/null +++ b/test/atmos_test.cc @@ -0,0 +1,91 @@ +/* + Copyright (C) 2020 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/config.h" +#include "lib/content.h" +#include "lib/content_factory.h" +#include "lib/dcp_content.h" +#include "lib/film.h" +#include "test.h" +#include <boost/test/unit_test.hpp> +#include <iostream> + + +using std::string; +using std::vector; +using boost::optional; +using boost::shared_ptr; + + +BOOST_AUTO_TEST_CASE (atmos_passthrough_test) +{ + shared_ptr<Film> film = new_test_film2 ("atmos_passthrough_test"); + boost::filesystem::path ref = TestPaths::private_data / "atmos_asset.mxf"; + shared_ptr<Content> content = content_factory (TestPaths::private_data / "atmos_asset.mxf").front(); + film->examine_and_add_content (content); + BOOST_REQUIRE (!wait_for_jobs()); + + film->make_dcp (); + BOOST_REQUIRE (!wait_for_jobs()); + + BOOST_REQUIRE (mxf_atmos_files_same(ref, dcp_file(film, "atmos"), true)); +} + + +BOOST_AUTO_TEST_CASE (atmos_encrypted_passthrough_test) +{ + shared_ptr<Film> film = new_test_film2 ("atmos_encrypted_passthrough_test"); + boost::filesystem::path ref = TestPaths::private_data / "atmos_asset.mxf"; + shared_ptr<Content> content = content_factory (TestPaths::private_data / "atmos_asset.mxf").front(); + film->examine_and_add_content (content); + BOOST_REQUIRE (!wait_for_jobs()); + + film->set_encrypted (true); + film->_key = dcp::Key ("4fac12927eb122af1c2781aa91f3a4cc"); + film->make_dcp (); + BOOST_REQUIRE (!wait_for_jobs()); + + BOOST_REQUIRE (!mxf_atmos_files_same(ref, dcp_file(film, "atmos"))); + + dcp::EncryptedKDM kdm = film->make_kdm ( + Config::instance()->decryption_chain()->leaf(), + vector<string>(), + dcp_file(film, "cpl"), + dcp::LocalTime(), + dcp::LocalTime(), + dcp::MODIFIED_TRANSITIONAL_1, + false, + optional<int>() + ); + + shared_ptr<Film> film2 = new_test_film2 ("atmos_encrypted_passthrough_test2"); + shared_ptr<DCPContent> content2 (new DCPContent(film->dir(film->dcp_name()))); + content2->add_kdm (kdm); + film2->examine_and_add_content (content2); + BOOST_REQUIRE (!wait_for_jobs()); + + std::cout << "making 2nd dcp.\n"; + film2->make_dcp (); + BOOST_REQUIRE (!wait_for_jobs()); + + BOOST_CHECK (mxf_atmos_files_same(ref, dcp_file(film2, "atmos"), true)); +} + diff --git a/test/test.cc b/test/test.cc index 90decc2df..32d32f988 100644 --- a/test/test.cc +++ b/test/test.cc @@ -237,6 +237,83 @@ check_mxf_audio_file (boost::filesystem::path ref, boost::filesystem::path check } } + +/** @return true if the files are the same, otherwise false */ +bool +mxf_atmos_files_same (boost::filesystem::path ref, boost::filesystem::path check, bool verbose) +{ + ASDCP::ATMOS::MXFReader ref_reader; + BOOST_REQUIRE (!ASDCP_FAILURE(ref_reader.OpenRead(ref.string().c_str()))); + + ASDCP::ATMOS::AtmosDescriptor ref_desc; + BOOST_REQUIRE (!ASDCP_FAILURE(ref_reader.FillAtmosDescriptor(ref_desc))); + + ASDCP::ATMOS::MXFReader check_reader; + BOOST_REQUIRE (!ASDCP_FAILURE(check_reader.OpenRead(check.string().c_str()))); + + ASDCP::ATMOS::AtmosDescriptor check_desc; + BOOST_REQUIRE (!ASDCP_FAILURE(check_reader.FillAtmosDescriptor(check_desc))); + + if (ref_desc.EditRate.Numerator != check_desc.EditRate.Numerator) { + if (verbose) { + std::cout << "EditRate.Numerator differs.\n"; + } + return false; + } + if (ref_desc.EditRate.Denominator != check_desc.EditRate.Denominator) { + if (verbose) { + std::cout << "EditRate.Denominator differs.\n"; + } + return false; + } + if (ref_desc.ContainerDuration != check_desc.ContainerDuration) { + if (verbose) { + std::cout << "EditRate.ContainerDuration differs.\n"; + } + return false; + } + if (ref_desc.FirstFrame != check_desc.FirstFrame) { + if (verbose) { + std::cout << "EditRate.FirstFrame differs.\n"; + } + return false; + } + if (ref_desc.MaxChannelCount != check_desc.MaxChannelCount) { + if (verbose) { + std::cout << "EditRate.MaxChannelCount differs.\n"; + } + return false; + } + if (ref_desc.MaxObjectCount != check_desc.MaxObjectCount) { + if (verbose) { + std::cout << "EditRate.MaxObjectCount differs.\n"; + } + return false; + } + if (ref_desc.AtmosVersion != check_desc.AtmosVersion) { + if (verbose) { + std::cout << "EditRate.AtmosVersion differs.\n"; + } + return false; + } + + ASDCP::DCData::FrameBuffer ref_buffer (Kumu::Megabyte); + ASDCP::DCData::FrameBuffer check_buffer (Kumu::Megabyte); + for (size_t i = 0; i < ref_desc.ContainerDuration; ++i) { + ref_reader.ReadFrame (i, ref_buffer, 0); + check_reader.ReadFrame (i, check_buffer, 0); + if (memcmp(ref_buffer.RoData(), check_buffer.RoData(), ref_buffer.Size())) { + if (verbose) { + std::cout << "data differs.\n"; + } + return false; + } + } + + return true; +} + + void check_image (boost::filesystem::path ref, boost::filesystem::path check, double threshold) { diff --git a/test/test.h b/test/test.h index dd919b408..77108af46 100644 --- a/test/test.h +++ b/test/test.h @@ -43,6 +43,7 @@ extern void check_dcp (boost::filesystem::path, boost::shared_ptr<const Film>); extern void check_file (boost::filesystem::path ref, boost::filesystem::path check); extern void check_wav_file (boost::filesystem::path ref, boost::filesystem::path check); extern void check_mxf_audio_file (boost::filesystem::path ref, boost::filesystem::path check); +extern bool mxf_atmos_files_same (boost::filesystem::path ref, boost::filesystem::path check, bool verbose = false); extern void check_xml (boost::filesystem::path, boost::filesystem::path, std::list<std::string>); extern void check_file (boost::filesystem::path, boost::filesystem::path); extern void check_ffmpeg (boost::filesystem::path, boost::filesystem::path, int audio_tolerance); diff --git a/test/wscript b/test/wscript index 9c67eacc4..2ac62f633 100644 --- a/test/wscript +++ b/test/wscript @@ -45,6 +45,7 @@ def build(bld): obj.use = 'libdcpomatic2' obj.source = """ 4k_test.cc + atmos_test.cc audio_analysis_test.cc audio_buffers_test.cc audio_delay_test.cc |
