Make sound asset language optional.
authorCarl Hetherington <cth@carlh.net>
Thu, 8 Apr 2021 22:02:09 +0000 (00:02 +0200)
committerCarl Hetherington <cth@carlh.net>
Thu, 8 Apr 2021 22:02:09 +0000 (00:02 +0200)
src/sound_asset.cc
src/sound_asset.h
src/sound_asset_writer.cc
src/verify.cc

index fe0c5dd0447647875bd82131b5eeaee7b9bfb761..4f0166d8b90aefc5c978b3f552d34116496fa164 100644 (file)
@@ -63,11 +63,6 @@ using namespace dcp;
 
 SoundAsset::SoundAsset (boost::filesystem::path file)
        : Asset (file)
-       /* XXX: this is a fallback language, which will be used if we can't find the RFC5646SpokenLanguage
-        * in the MXF header.  Perhaps RFC5646SpokenLanguage is optional and we should just not write it
-        * if we don't know it.
-        */
-       , _language ("en-US")
 {
        ASDCP::PCM::MXFReader reader;
        auto r = reader.OpenRead (file.string().c_str());
index e58773e4c90adc7a35309a75dc6d3beefc05aac2..79edea96b7992dc15d05d30e319cb2073424a5b2 100644 (file)
@@ -102,7 +102,7 @@ public:
                return _intrinsic_duration;
        }
 
-       std::string language () const {
+       boost::optional<std::string> language () const {
                return _language;
        }
 
@@ -126,7 +126,7 @@ private:
        int64_t _intrinsic_duration = 0;
        int _channels = 0;      ///< number of channels
        int _sampling_rate = 0; ///< sampling rate in Hz
-       std::string _language;
+       boost::optional<std::string> _language;
 };
 
 
index 205a45ab2f9c2eb25e8d62dcad1795ff73fb5598..0d7d20744b0f1c961f6ab8633d8032511bdaa6bf 100644 (file)
@@ -127,7 +127,9 @@ SoundAssetWriter::start ()
 
                auto soundfield = new ASDCP::MXF::SoundfieldGroupLabelSubDescriptor(asdcp_smpte_dict);
                GenRandomValue (soundfield->MCALinkID);
-               soundfield->RFC5646SpokenLanguage = _asset->language();
+               if (auto lang = _asset->language()) {
+                       soundfield->RFC5646SpokenLanguage = *lang;
+               }
 
                const MCASoundField field = _asset->channels() > 10 ? MCASoundField::SEVEN_POINT_ONE : MCASoundField::FIVE_POINT_ONE;
 
@@ -162,7 +164,9 @@ SoundAssetWriter::start ()
                        channel->MCAChannelID = i + 1;
                        channel->MCATagSymbol = "ch" + channel_to_mca_id(dcp_channel, field);
                        channel->MCATagName = channel_to_mca_name(dcp_channel, field);
-                       channel->RFC5646SpokenLanguage = _asset->language();
+                       if (auto lang = _asset->language()) {
+                               channel->RFC5646SpokenLanguage = *lang;
+                       }
                        channel->MCALabelDictionaryID = channel_to_mca_universal_label(dcp_channel, field, asdcp_smpte_dict);
                        _state->mxf_writer.OP1aHeader().AddChildObject(channel);
                        essence_descriptor->SubDescriptors.push_back(channel->InstanceUID);
index 35ec69f83e9341014c6c1d523d6210b405c6be6c..e57439957aa8213cf63a0db1c2cc8738d90e6aef 100644 (file)
@@ -586,7 +586,9 @@ verify_main_sound_asset (
 
        stage ("Checking sound asset metadata", asset->file());
 
-       verify_language_tag (asset->language(), notes);
+       if (auto lang = asset->language()) {
+               verify_language_tag (*lang, notes);
+       }
        if (asset->sampling_rate() != 48000) {
                notes.push_back ({VerificationNote::Type::BV21_ERROR, VerificationNote::Code::INVALID_SOUND_FRAME_RATE, raw_convert<string>(asset->sampling_rate()), *asset->file()});
        }