diff options
| author | Carl Hetherington <cth@carlh.net> | 2023-04-02 23:10:24 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2023-04-04 23:37:15 +0200 |
| commit | 2da55dbe6da21975612584365db17db2ae9935b8 (patch) | |
| tree | 732e00fbe2ff44a01644d0b7572c8fa346e97eba /src | |
| parent | 5adfa769c56f9594ffe895eb89bcbfb38c90c192 (diff) | |
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).
Diffstat (limited to 'src')
| -rw-r--r-- | src/cpl.cc | 15 | ||||
| -rw-r--r-- | src/cpl.h | 6 | ||||
| -rw-r--r-- | src/types.cc | 41 | ||||
| -rw-r--r-- | src/types.h | 5 |
4 files changed, 44 insertions, 23 deletions
@@ -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<string>(*_main_sound_sample_rate) + " 1"); auto stored = meta->add_child("MainPictureStoredArea", "meta"); @@ -283,11 +283,11 @@ public: _luminance = l; } - boost::optional<std::string> main_sound_configuration () const { + boost::optional<dcp::MainSoundConfiguration> main_sound_configuration () const { return _main_sound_configuration; } - void set_main_sound_configuration (std::string c) { + void set_main_sound_configuration(dcp::MainSoundConfiguration c) { _main_sound_configuration = c; } @@ -377,7 +377,7 @@ private: boost::optional<std::string> _distributor; boost::optional<std::string> _facility; boost::optional<Luminance> _luminance; - boost::optional<std::string> _main_sound_configuration; + boost::optional<MainSoundConfiguration> _main_sound_configuration; boost::optional<int> _main_sound_sample_rate; boost::optional<dcp::Size> _main_picture_stored_area; boost::optional<dcp::Size> _main_picture_active_area; diff --git a/src/types.cc b/src/types.cc index 153a73af..9b868197 100644 --- a/src/types.cc +++ b/src/types.cc @@ -473,8 +473,8 @@ MainSoundConfiguration::MainSoundConfiguration (string s) { vector<string> parts; boost::split (parts, s, boost::is_any_of("/")); - if (parts.size() != 2) { - throw MainSoundConfigurationError (s); + if (parts.empty()) { + throw MainSoundConfigurationError(s); } if (parts[0] == "51") { @@ -482,7 +482,14 @@ MainSoundConfiguration::MainSoundConfiguration (string s) } else if (parts[0] == "71") { _field = MCASoundField::SEVEN_POINT_ONE; } else { - throw MainSoundConfigurationError (s); + _field = MCASoundField::OTHER; + } + + if (parts.size() < 2) { + /* I think it's OK to just have the sound field descriptor with no channels, though + * to me it's not clear and I might be wrong. + */ + return; } vector<string> channels; @@ -590,31 +597,33 @@ dcp::string_to_status (string s) Channel dcp::mca_id_to_channel (string id) { - if (id == "L") { + transform(id.begin(), id.end(), id.begin(), ::tolower); + + if (id == "l") { return Channel::LEFT; - } else if (id == "R") { + } else if (id == "r") { return Channel::RIGHT; - } else if (id == "C") { + } else if (id == "c") { return Channel::CENTRE; - } else if (id == "LFE") { + } else if (id == "lfe") { return Channel::LFE; - } else if (id == "Ls" || id == "Lss") { + } else if (id == "ls" || id == "lss") { return Channel::LS; - } else if (id == "Rs" || id == "Rss") { + } else if (id == "rs" || id == "rss") { return Channel::RS; - } else if (id == "HI") { + } else if (id == "hi") { return Channel::HI; - } else if (id == "VIN") { + } else if (id == "vin") { return Channel::VI; - } else if (id == "Lrs") { + } else if (id == "lrs") { return Channel::BSL; - } else if (id == "Rrs") { + } else if (id == "rrs") { return Channel::BSR; - } else if (id == "DBOX") { + } else if (id == "dbox") { return Channel::MOTION_DATA; - } else if (id == "FSKSync") { + } else if (id == "sync" || id == "fsksync") { return Channel::SYNC_SIGNAL; - } else if (id == "SLVS") { + } else if (id == "slvs") { return Channel::SIGN_LANGUAGE; } diff --git a/src/types.h b/src/types.h index 5f955c4b..a670fdd5 100644 --- a/src/types.h +++ b/src/types.h @@ -119,7 +119,8 @@ std::vector<dcp::Channel> used_audio_channels (); enum class MCASoundField { FIVE_POINT_ONE, - SEVEN_POINT_ONE + SEVEN_POINT_ONE, + OTHER }; @@ -445,7 +446,7 @@ bool operator== (Luminance const& a, Luminance const& b); class MainSoundConfiguration { public: - MainSoundConfiguration (std::string); + explicit MainSoundConfiguration(std::string); MainSoundConfiguration (MCASoundField field_, int channels); MCASoundField field () const { |
