From 2da55dbe6da21975612584365db17db2ae9935b8 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sun, 2 Apr 2023 23:10:24 +0200 Subject: Pass MainSoundConfiguration object rather than a string. I guess originally it was a string mostly because it's not very well defined, and Interop seemingly does whatever it wants. This basic change also means that things are checked more carefully, and so we must be more relaxed with some things seen in the wild that I can't find contradictions for in the standard (and also with the case of channel IDs, which does seem to be mentioned in the standard). --- src/cpl.cc | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src/cpl.cc') diff --git a/src/cpl.cc b/src/cpl.cc index c862a853..86b738d9 100644 --- a/src/cpl.cc +++ b/src/cpl.cc @@ -288,7 +288,16 @@ CPL::read_composition_metadata_asset (cxml::ConstNodePtr node) _luminance = Luminance (lum); } - _main_sound_configuration = node->optional_string_child("MainSoundConfiguration"); + if (auto msc = node->optional_string_child("MainSoundConfiguration")) { + try { + _main_sound_configuration = MainSoundConfiguration(*msc); + } catch (MainSoundConfigurationError& e) { + /* With Interop DCPs this node may not make any sense, but that's OK */ + if (_standard == dcp::Standard::SMPTE) { + throw e; + } + } + } auto sr = node->optional_string_child("MainSoundSampleRate"); if (sr) { @@ -492,7 +501,9 @@ CPL::maybe_write_composition_metadata_asset(xmlpp::Element* node, bool include_m _luminance->as_xml (meta, "meta"); } - meta->add_child("MainSoundConfiguration", "meta")->add_child_text(*_main_sound_configuration); + if (_main_sound_configuration) { + meta->add_child("MainSoundConfiguration", "meta")->add_child_text(_main_sound_configuration->to_string()); + } meta->add_child("MainSoundSampleRate", "meta")->add_child_text(raw_convert(*_main_sound_sample_rate) + " 1"); auto stored = meta->add_child("MainPictureStoredArea", "meta"); -- cgit v1.2.3