From aab6630b945371038cc49e456a766ae45cab1f47 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Fri, 8 Oct 2021 12:08:10 +0200 Subject: Fix problems when adding KDMs to a VF, before adding the OV. If we have a KDM which contains keys for all the assets referred to by a VF (even the ones in the OV) we would previously throw an exception because we tried to give the KDM to the resolved assets when it was given to the Reel. Here we change things so that the addition of KDMs to assets can be deferred if the asset is not yet resolved. --- test/test.cc | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'test/test.cc') diff --git a/test/test.cc b/test/test.cc index 3cb40aaf..f946c5dc 100644 --- a/test/test.cc +++ b/test/test.cc @@ -266,16 +266,19 @@ RNGFixer::~RNGFixer () shared_ptr -simple_picture (boost::filesystem::path path, string suffix, int frames) +simple_picture (boost::filesystem::path path, string suffix, int frames, optional key) { dcp::MXFMetadata mxf_meta; mxf_meta.company_name = "OpenDCP"; mxf_meta.product_name = "OpenDCP"; mxf_meta.product_version = "0.0.25"; - shared_ptr mp (new dcp::MonoPictureAsset (dcp::Fraction (24, 1), dcp::Standard::SMPTE)); + auto mp = make_shared(dcp::Fraction (24, 1), dcp::Standard::SMPTE); mp->set_metadata (mxf_meta); - shared_ptr picture_writer = mp->start_write (path / dcp::String::compose("video%1.mxf", suffix), false); + if (key) { + mp->set_key (*key); + } + auto picture_writer = mp->start_write (path / dcp::String::compose("video%1.mxf", suffix), false); dcp::Size const size (1998, 1080); auto image = make_shared(size); @@ -294,12 +297,15 @@ simple_picture (boost::filesystem::path path, string suffix, int frames) shared_ptr -simple_sound (boost::filesystem::path path, string suffix, dcp::MXFMetadata mxf_meta, string language, int frames, int sample_rate) +simple_sound (boost::filesystem::path path, string suffix, dcp::MXFMetadata mxf_meta, string language, int frames, int sample_rate, optional key) { int const channels = 6; /* Set a valid language, then overwrite it, so that the language parameter can be badly formed */ - shared_ptr ms (new dcp::SoundAsset(dcp::Fraction(24, 1), sample_rate, channels, dcp::LanguageTag("en-US"), dcp::Standard::SMPTE)); + auto ms = make_shared(dcp::Fraction(24, 1), sample_rate, channels, dcp::LanguageTag("en-US"), dcp::Standard::SMPTE); + if (key) { + ms->set_key (*key); + } ms->_language = language; ms->set_metadata (mxf_meta); shared_ptr sound_writer = ms->start_write (path / dcp::String::compose("audio%1.mxf", suffix)); @@ -327,7 +333,7 @@ simple_sound (boost::filesystem::path path, string suffix, dcp::MXFMetadata mxf_ shared_ptr -make_simple (boost::filesystem::path path, int reels, int frames, dcp::Standard standard) +make_simple (boost::filesystem::path path, int reels, int frames, dcp::Standard standard, optional key) { /* Some known metadata */ dcp::MXFMetadata mxf_meta; @@ -335,6 +341,8 @@ make_simple (boost::filesystem::path path, int reels, int frames, dcp::Standard mxf_meta.product_name = "OpenDCP"; mxf_meta.product_version = "0.0.25"; + auto constexpr sample_rate = 48000; + boost::filesystem::remove_all (path); boost::filesystem::create_directories (path); auto d = make_shared(path); @@ -347,7 +355,7 @@ make_simple (boost::filesystem::path path, int reels, int frames, dcp::Standard dcp::ContentVersion("urn:uuid:75ac29aa-42ac-1234-ecae-49251abefd11", "content-version-label-text") ); cpl->set_main_sound_configuration("51/L,R,C,LFE,Ls,Rs"); - cpl->set_main_sound_sample_rate(48000); + cpl->set_main_sound_sample_rate(sample_rate); cpl->set_main_picture_stored_area(dcp::Size(1998, 1080)); cpl->set_main_picture_active_area(dcp::Size(1998, 1080)); cpl->set_version_number(1); @@ -355,8 +363,8 @@ make_simple (boost::filesystem::path path, int reels, int frames, dcp::Standard for (int i = 0; i < reels; ++i) { string suffix = reels == 1 ? "" : dcp::String::compose("%1", i); - shared_ptr mp = simple_picture (path, suffix, frames); - shared_ptr ms = simple_sound (path, suffix, mxf_meta, "en-US", frames); + auto mp = simple_picture (path, suffix, frames, key); + auto ms = simple_sound (path, suffix, mxf_meta, "en-US", frames, sample_rate, key); auto reel = make_shared( shared_ptr(new dcp::ReelMonoPictureAsset(mp, 0)), -- cgit v1.2.3