From eb28997f188c905af40054e4139251ebf1756ae4 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 14 Jan 2025 23:50:38 +0100 Subject: Make MainSoundConfiguration behave "correctly" with badly-formatted strings. Add some documentation for a design "principle" when handling malformatted data, and make MainSoundConfiguration adhere to that. --- src/cpl.cc | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'src/cpl.cc') diff --git a/src/cpl.cc b/src/cpl.cc index a701f4ba..42319c07 100644 --- a/src/cpl.cc +++ b/src/cpl.cc @@ -52,6 +52,7 @@ #include "reel_sound_asset.h" #include "reel_text_asset.h" #include "util.h" +#include "verify.h" #include "version.h" #include "warnings.h" #include "xml.h" @@ -175,7 +176,7 @@ CPL::CPL (boost::filesystem::path file, vector* notes) auto asset_list = reels.front()->node_child("AssetList"); auto metadata = asset_list->optional_node_child("CompositionMetadataAsset"); if (metadata) { - read_composition_metadata_asset (metadata); + read_composition_metadata_asset(metadata, notes); _read_composition_metadata = true; } } @@ -266,7 +267,7 @@ CPL::write_xml(boost::filesystem::path file, shared_ptr void -CPL::read_composition_metadata_asset (cxml::ConstNodePtr node) +CPL::read_composition_metadata_asset(cxml::ConstNodePtr node, vector* notes) { _cpl_metadata_id = remove_urn_uuid(node->string_child("Id")); @@ -310,13 +311,17 @@ CPL::read_composition_metadata_asset (cxml::ConstNodePtr node) } if (auto msc = node->optional_string_child("MainSoundConfiguration")) { - try { - _main_sound_configuration = MainSoundConfiguration(*msc); - } catch (MainSoundConfigurationError& e) { + _main_sound_configuration = MainSoundConfiguration(*msc); + if (!_main_sound_configuration->valid() && _standard == dcp::Standard::SMPTE && notes) { /* With Interop DCPs this node may not make any sense, but that's OK */ - if (_standard == dcp::Standard::SMPTE) { - throw e; - } + notes->push_back( + dcp::VerificationNote( + dcp::VerificationNote::Type::ERROR, + dcp::VerificationNote::Code::INVALID_MAIN_SOUND_CONFIGURATION, + fmt::format("{} could not be parsed", _main_sound_configuration->to_string()), + *_file + ).set_cpl_id(_id) + ); } } -- cgit v1.2.3