diff options
| author | Carl Hetherington <cth@carlh.net> | 2020-09-06 20:10:13 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2020-09-21 21:57:18 +0200 |
| commit | cdc8bc6a7da0b4f8c3dbfcf560fea61473cf1ca3 (patch) | |
| tree | 6f6fc0c6b7897e6d3bd48fcc27e0e5eb08fc92b9 /test | |
| parent | 445f2495fbb0885132d3a6c8e7a1e135cbac3cce (diff) | |
Support MCA sound channel tags in MXF/CPL.
Diffstat (limited to 'test')
| -rw-r--r-- | test/cpl_metadata_test.cc | 18 | ||||
| -rw-r--r-- | test/dcp_test.cc | 9 | ||||
| -rw-r--r-- | test/encryption_test.cc | 4 | ||||
| -rw-r--r-- | test/mca_test.cc | 86 | ||||
| -rw-r--r-- | test/ref/cpl_metadata_test1.xml | 2 | ||||
| -rw-r--r-- | test/ref/cpl_metadata_test2.xml | 2 | ||||
| -rw-r--r-- | test/sync_test.cc | 6 | ||||
| -rw-r--r-- | test/test.cc | 14 | ||||
| -rw-r--r-- | test/test.h | 2 | ||||
| -rw-r--r-- | test/wscript | 1 |
10 files changed, 119 insertions, 25 deletions
diff --git a/test/cpl_metadata_test.cc b/test/cpl_metadata_test.cc index 216ef600..5082b8f6 100644 --- a/test/cpl_metadata_test.cc +++ b/test/cpl_metadata_test.cc @@ -66,7 +66,7 @@ BOOST_AUTO_TEST_CASE (main_sound_configuration_test1) dcp::MainSoundConfiguration msc("51/L,R,C,LFE,-,-"); BOOST_CHECK_EQUAL (msc.to_string(), "51/L,R,C,LFE,-,-"); BOOST_CHECK_EQUAL (msc.channels(), 6); - BOOST_CHECK_EQUAL (msc.field(), dcp::MainSoundConfiguration::FIVE_POINT_ONE); + BOOST_CHECK_EQUAL (msc.field(), dcp::FIVE_POINT_ONE); BOOST_CHECK_EQUAL (msc.mapping(0).get(), dcp::LEFT); BOOST_CHECK_EQUAL (msc.mapping(1).get(), dcp::RIGHT); BOOST_CHECK_EQUAL (msc.mapping(2).get(), dcp::CENTRE); @@ -81,7 +81,7 @@ BOOST_AUTO_TEST_CASE (main_sound_configuration_test2) dcp::MainSoundConfiguration msc("71/L,R,C,LFE,-,-"); BOOST_CHECK_EQUAL (msc.to_string(), "71/L,R,C,LFE,-,-"); BOOST_CHECK_EQUAL (msc.channels(), 6); - BOOST_CHECK_EQUAL (msc.field(), dcp::MainSoundConfiguration::SEVEN_POINT_ONE); + BOOST_CHECK_EQUAL (msc.field(), dcp::SEVEN_POINT_ONE); BOOST_CHECK_EQUAL (msc.mapping(0).get(), dcp::LEFT); BOOST_CHECK_EQUAL (msc.mapping(1).get(), dcp::RIGHT); BOOST_CHECK_EQUAL (msc.mapping(2).get(), dcp::CENTRE); @@ -96,7 +96,7 @@ BOOST_AUTO_TEST_CASE (main_sound_configuration_test3) dcp::MainSoundConfiguration msc("71/L,-,C,LFE,Lss,Rss"); BOOST_CHECK_EQUAL (msc.to_string(), "71/L,-,C,LFE,Lss,Rss"); BOOST_CHECK_EQUAL (msc.channels(), 6); - BOOST_CHECK_EQUAL (msc.field(), dcp::MainSoundConfiguration::SEVEN_POINT_ONE); + BOOST_CHECK_EQUAL (msc.field(), dcp::SEVEN_POINT_ONE); BOOST_CHECK_EQUAL (msc.mapping(0).get(), dcp::LEFT); BOOST_CHECK (!msc.mapping(1)); BOOST_CHECK_EQUAL (msc.mapping(2).get(), dcp::CENTRE); @@ -111,7 +111,7 @@ BOOST_AUTO_TEST_CASE (main_sound_configuration_test4) dcp::MainSoundConfiguration msc("71/L,-,C,LFE,Lss,Rss,-,-,-,-,-,-,-,-,-"); BOOST_CHECK_EQUAL (msc.to_string(), "71/L,-,C,LFE,Lss,Rss,-,-,-,-,-,-,-,-,-"); BOOST_CHECK_EQUAL (msc.channels(), 15); - BOOST_CHECK_EQUAL (msc.field(), dcp::MainSoundConfiguration::SEVEN_POINT_ONE); + BOOST_CHECK_EQUAL (msc.field(), dcp::SEVEN_POINT_ONE); BOOST_CHECK_EQUAL (msc.mapping(0).get(), dcp::LEFT); BOOST_CHECK (!msc.mapping(1)); BOOST_CHECK_EQUAL (msc.mapping(2).get(), dcp::CENTRE); @@ -126,10 +126,10 @@ BOOST_AUTO_TEST_CASE (main_sound_configuration_test4) BOOST_AUTO_TEST_CASE (main_sound_configuration_test5) { - dcp::MainSoundConfiguration msc("71/L,-,C,LFE,Lss,Rss,HI,VIN,-,-,Lrs,Rrs,DBOX,Sync,Sign"); - BOOST_CHECK_EQUAL (msc.to_string(), "71/L,-,C,LFE,Lss,Rss,HI,VIN,-,-,Lrs,Rrs,DBOX,Sync,Sign"); + dcp::MainSoundConfiguration msc("71/L,-,C,LFE,Lss,Rss,HI,VIN,-,-,Lrs,Rrs,DBOX,FSKSync,SLVS"); + BOOST_CHECK_EQUAL (msc.to_string(), "71/L,-,C,LFE,Lss,Rss,HI,VIN,-,-,Lrs,Rrs,DBOX,FSKSync,SLVS"); BOOST_CHECK_EQUAL (msc.channels(), 15); - BOOST_CHECK_EQUAL (msc.field(), dcp::MainSoundConfiguration::SEVEN_POINT_ONE); + BOOST_CHECK_EQUAL (msc.field(), dcp::SEVEN_POINT_ONE); BOOST_CHECK_EQUAL (msc.mapping(0).get(), dcp::LEFT); BOOST_CHECK (!msc.mapping(1)); BOOST_CHECK_EQUAL (msc.mapping(2).get(), dcp::CENTRE); @@ -267,7 +267,7 @@ BOOST_AUTO_TEST_CASE (cpl_metadata_write_test1) cpl.set_facility ("the-facility"); cpl.set_luminance (dcp::Luminance(4.5, dcp::Luminance::FOOT_LAMBERT)); - dcp::MainSoundConfiguration msc(dcp::MainSoundConfiguration::SEVEN_POINT_ONE, 16); + dcp::MainSoundConfiguration msc(dcp::SEVEN_POINT_ONE, 16); msc.set_mapping (0, dcp::LEFT); msc.set_mapping (1, dcp::RIGHT); msc.set_mapping (2, dcp::CENTRE); @@ -338,7 +338,7 @@ BOOST_AUTO_TEST_CASE (cpl_metadata_write_test2) cpl.set_issue_date ("2020-08-28T13:35:06+02:00"); cpl.set_content_version (dcp::ContentVersion("id", "version")); - dcp::MainSoundConfiguration msc(dcp::MainSoundConfiguration::SEVEN_POINT_ONE, 16); + dcp::MainSoundConfiguration msc(dcp::SEVEN_POINT_ONE, 16); msc.set_mapping (0, dcp::LEFT); msc.set_mapping (1, dcp::RIGHT); msc.set_mapping (2, dcp::CENTRE); diff --git a/test/dcp_test.cc b/test/dcp_test.cc index a6efe024..610b175e 100644 --- a/test/dcp_test.cc +++ b/test/dcp_test.cc @@ -52,6 +52,7 @@ #include <boost/test/unit_test.hpp> using std::string; +using std::vector; using boost::shared_ptr; @@ -103,9 +104,9 @@ BOOST_AUTO_TEST_CASE (dcp_test2) } picture_writer->finalize (); - shared_ptr<dcp::SoundAsset> ms (new dcp::SoundAsset (dcp::Fraction (24, 1), 48000, 1, dcp::SMPTE)); + shared_ptr<dcp::SoundAsset> ms (new dcp::SoundAsset(dcp::Fraction(24, 1), 48000, 1, dcp::LanguageTag("en-GB"), dcp::SMPTE)); ms->set_metadata (mxf_meta); - shared_ptr<dcp::SoundAssetWriter> sound_writer = ms->start_write ("build/test/DCP/dcp_test2/audio.mxf"); + shared_ptr<dcp::SoundAssetWriter> sound_writer = ms->start_write ("build/test/DCP/dcp_test2/audio.mxf", vector<dcp::Channel>()); SF_INFO info; info.format = 0; @@ -199,9 +200,9 @@ BOOST_AUTO_TEST_CASE (dcp_test5) } picture_writer->finalize (); - shared_ptr<dcp::SoundAsset> ms (new dcp::SoundAsset (dcp::Fraction (24, 1), 48000, 1, dcp::SMPTE)); + shared_ptr<dcp::SoundAsset> ms (new dcp::SoundAsset(dcp::Fraction(24, 1), 48000, 1, dcp::LanguageTag("en-GB"), dcp::SMPTE)); ms->set_metadata (mxf_meta); - shared_ptr<dcp::SoundAssetWriter> sound_writer = ms->start_write ("build/test/DCP/dcp_test5/audio.mxf"); + shared_ptr<dcp::SoundAssetWriter> sound_writer = ms->start_write ("build/test/DCP/dcp_test5/audio.mxf", vector<dcp::Channel>()); SF_INFO info; info.format = 0; diff --git a/test/encryption_test.cc b/test/encryption_test.cc index c452c07b..2793e8ad 100644 --- a/test/encryption_test.cc +++ b/test/encryption_test.cc @@ -98,10 +98,10 @@ BOOST_AUTO_TEST_CASE (encryption_test) } writer->finalize (); - shared_ptr<dcp::SoundAsset> ms (new dcp::SoundAsset (dcp::Fraction (24, 1), 48000, 1, dcp::SMPTE)); + shared_ptr<dcp::SoundAsset> ms (new dcp::SoundAsset (dcp::Fraction (24, 1), 48000, 1, dcp::LanguageTag("en-GB"), dcp::SMPTE)); ms->set_metadata (mxf_metadata); ms->set_key (key); - shared_ptr<dcp::SoundAssetWriter> sound_writer = ms->start_write ("build/test/DCP/encryption_test/audio.mxf"); + shared_ptr<dcp::SoundAssetWriter> sound_writer = ms->start_write ("build/test/DCP/encryption_test/audio.mxf", vector<dcp::Channel>()); SF_INFO info; info.format = 0; diff --git a/test/mca_test.cc b/test/mca_test.cc new file mode 100644 index 00000000..f1d05423 --- /dev/null +++ b/test/mca_test.cc @@ -0,0 +1,86 @@ +/* + Copyright (C) 2020 Carl Hetherington <cth@carlh.net> + + This file is part of libdcp. + + libdcp 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. + + libdcp 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 libdcp. If not, see <http://www.gnu.org/licenses/>. + + In addition, as a special exception, the copyright holders give + permission to link the code of portions of this program with the + OpenSSL library under certain conditions as described in each + individual source file, and distribute linked combinations + including the two. + + You must obey the GNU General Public License in all respects + for all of the code used other than OpenSSL. If you modify + file(s) with this exception, you may extend this exception to your + version of the file(s), but you are not obligated to do so. If you + do not wish to do so, delete this exception statement from your + version. If you delete this exception statement from all source + files in the program, then also delete it here. +*/ + + +#include "compose.hpp" +#include "cpl.h" +#include "reel.h" +#include "reel_sound_asset.h" +#include "sound_asset.h" +#include "test.h" +#include <libcxml/cxml.h> +#include <libxml++/libxml++.h> +#include <boost/test/unit_test.hpp> + + +using std::list; +using std::string; +using boost::shared_ptr; + + +/** Check that when we read a MXF and write its MCA metadata to a CPL we get the same answer + * as the original MXF for that CPL (for a couple of different MXFs). + */ +BOOST_AUTO_TEST_CASE (parse_mca_descriptors_from_mxf_test) +{ + for (int i = 1; i < 3; ++i) { + shared_ptr<dcp::SoundAsset> sound_asset(new dcp::SoundAsset(private_test / "data" / dcp::String::compose("51_sound_with_mca_%1.mxf", i))); + shared_ptr<dcp::ReelSoundAsset> reel_sound_asset(new dcp::ReelSoundAsset(sound_asset, 0)); + shared_ptr<dcp::Reel> reel(new dcp::Reel()); + reel->add (black_picture_asset(dcp::String::compose("build/test/parse_mca_descriptors_from_mxf_test%1", i), 24)); + reel->add (reel_sound_asset); + + dcp::CPL cpl("", dcp::FEATURE); + cpl.add (reel); + cpl.set_main_sound_configuration("51/L,R,C,LFE,Ls,Rs"); + cpl.set_main_sound_sample_rate(48000); + cpl.set_main_picture_stored_area(dcp::Size(1998, 1080)); + cpl.set_main_picture_active_area(dcp::Size(1998, 1080)); + cpl.write_xml (dcp::String::compose("build/test/parse_mca_descriptors_from_mxf_test%1/cpl.xml", i), dcp::SMPTE, shared_ptr<dcp::CertificateChain>()); + + cxml::Document ref("CompositionPlaylist", private_test / dcp::String::compose("51_sound_with_mca_%1.cpl", i)); + cxml::Document check("CompositionPlaylist", dcp::String::compose("build/test/parse_mca_descriptors_from_mxf_test%1/cpl.xml", i)); + + list<string> ignore; + check_xml ( + dynamic_cast<xmlpp::Element*>( + ref.node_child("ReelList")->node_children("Reel").front()->node_child("AssetList")->node_child("CompositionMetadataAsset")->node_child("MCASubDescriptors")->node() + ), + dynamic_cast<xmlpp::Element*>( + check.node_child("ReelList")->node_children("Reel").front()->node_child("AssetList")->node_child("CompositionMetadataAsset")->node_child("MCASubDescriptors")->node() + ), + ignore, + true + ); + } +} diff --git a/test/ref/cpl_metadata_test1.xml b/test/ref/cpl_metadata_test1.xml index b734edbb..5d49e765 100644 --- a/test/ref/cpl_metadata_test1.xml +++ b/test/ref/cpl_metadata_test1.xml @@ -55,7 +55,7 @@ </ContentVersion> </meta:AlternateContentVersionList> <meta:Luminance units="foot-lambert">4.5</meta:Luminance> - <meta:MainSoundConfiguration>71/L,R,C,LFE,-,-,-,-,-,-,-,-,-,Sync,-,-</meta:MainSoundConfiguration> + <meta:MainSoundConfiguration>71/L,R,C,LFE,-,-,-,-,-,-,-,-,-,FSKSync,-,-</meta:MainSoundConfiguration> <meta:MainSoundSampleRate>48000 1</meta:MainSoundSampleRate> <meta:MainPictureStoredArea> <meta:Width>1998</meta:Width> diff --git a/test/ref/cpl_metadata_test2.xml b/test/ref/cpl_metadata_test2.xml index d61a7113..a7b20ff3 100644 --- a/test/ref/cpl_metadata_test2.xml +++ b/test/ref/cpl_metadata_test2.xml @@ -32,7 +32,7 @@ <EditRate>24 1</EditRate> <IntrinsicDuration>24</IntrinsicDuration> <meta:FullContentTitleText/> - <meta:MainSoundConfiguration>71/L,R,C,LFE,-,-,-,-,-,-,-,-,-,Sync,-,-</meta:MainSoundConfiguration> + <meta:MainSoundConfiguration>71/L,R,C,LFE,-,-,-,-,-,-,-,-,-,FSKSync,-,-</meta:MainSoundConfiguration> <meta:MainSoundSampleRate>48000 1</meta:MainSoundSampleRate> <meta:MainPictureStoredArea> <meta:Width>1998</meta:Width> diff --git a/test/sync_test.cc b/test/sync_test.cc index 9fe6a304..0bffdb83 100644 --- a/test/sync_test.cc +++ b/test/sync_test.cc @@ -109,7 +109,7 @@ BOOST_AUTO_TEST_CASE (sync_test1) } } - shared_ptr<dcp::SoundAssetWriter> writer = asset.start_write ("build/test/foo.mxf", true); + shared_ptr<dcp::SoundAssetWriter> writer = asset.start_write ("build/test/foo.mxf", vector<dcp::Channel>(), true); /* Compare the sync bits made by SoundAssetWriter to the "proper" ones in the MXF */ BOOST_CHECK (ref == writer->create_sync_packets()); @@ -120,11 +120,11 @@ BOOST_AUTO_TEST_CASE (sync_test2) { /* Make a MXF with the same ID as atmos_pcm.mxf and write a frame of random stuff */ int const channels = 14; - dcp::SoundAsset asset (dcp::Fraction(24, 1), 48000, channels, dcp::SMPTE); + dcp::SoundAsset asset (dcp::Fraction(24, 1), 48000, channels, dcp::LanguageTag("en-GB"), dcp::SMPTE); asset._id = "e004046e09234f90a4ae4355e7e83506"; boost::system::error_code ec; boost::filesystem::remove ("build/test/foo.mxf", ec); - shared_ptr<dcp::SoundAssetWriter> writer = asset.start_write ("build/test/foo.mxf", true); + shared_ptr<dcp::SoundAssetWriter> writer = asset.start_write ("build/test/foo.mxf", vector<dcp::Channel>(), true); int const frames = 2000; float** junk = new float*[channels]; diff --git a/test/test.cc b/test/test.cc index dd143264..62013687 100644 --- a/test/test.cc +++ b/test/test.cc @@ -95,12 +95,12 @@ struct TestConfig }; void -check_xml (xmlpp::Element* ref, xmlpp::Element* test, list<string> ignore) +check_xml (xmlpp::Element* ref, xmlpp::Element* test, list<string> ignore_tags, bool ignore_whitespace) { BOOST_CHECK_EQUAL (ref->get_name (), test->get_name ()); BOOST_CHECK_EQUAL (ref->get_namespace_prefix (), test->get_namespace_prefix ()); - if (find (ignore.begin(), ignore.end(), ref->get_name()) != ignore.end ()) { + if (find(ignore_tags.begin(), ignore_tags.end(), ref->get_name()) != ignore_tags.end()) { return; } @@ -121,14 +121,20 @@ check_xml (xmlpp::Element* ref, xmlpp::Element* test, list<string> ignore) xmlpp::Element* test_el = dynamic_cast<xmlpp::Element*> (*l); BOOST_CHECK ((ref_el && test_el) || (!ref_el && !test_el)); if (ref_el && test_el) { - check_xml (ref_el, test_el, ignore); + check_xml (ref_el, test_el, ignore_tags, ignore_whitespace); } xmlpp::ContentNode* ref_cn = dynamic_cast<xmlpp::ContentNode*> (*k); xmlpp::ContentNode* test_cn = dynamic_cast<xmlpp::ContentNode*> (*l); BOOST_CHECK ((ref_cn && test_cn) || (!ref_cn && !test_cn)); if (ref_cn && test_cn) { - BOOST_CHECK_EQUAL (ref_cn->get_content(), test_cn->get_content ()); + if ( + !ignore_whitespace || + ref_cn->get_content().find_first_not_of(" \t\r\n") != string::npos || + test_cn->get_content().find_first_not_of(" \t\r\n") != string::npos) { + + BOOST_CHECK_EQUAL (ref_cn->get_content(), test_cn->get_content ()); + } } ++k; diff --git a/test/test.h b/test/test.h index 95827af7..9009a58b 100644 --- a/test/test.h +++ b/test/test.h @@ -40,7 +40,7 @@ namespace dcp { extern boost::filesystem::path private_test; extern boost::filesystem::path xsd_test; -extern void check_xml (xmlpp::Element* ref, xmlpp::Element* test, std::list<std::string> ignore); +extern void check_xml (xmlpp::Element* ref, xmlpp::Element* test, std::list<std::string> ignore_tags, bool ignore_whitespace = false); extern void check_xml (std::string ref, std::string test, std::list<std::string> ignore); extern void check_file (boost::filesystem::path ref, boost::filesystem::path check); extern boost::shared_ptr<dcp::MonoPictureAsset> simple_picture (boost::filesystem::path path, std::string suffix); diff --git a/test/wscript b/test/wscript index 5fd2f430..aa134bde 100644 --- a/test/wscript +++ b/test/wscript @@ -84,6 +84,7 @@ def build(bld): local_time_test.cc make_digest_test.cc markers_test.cc + mca_test.cc kdm_test.cc key_test.cc language_tag_test.cc |
