summaryrefslogtreecommitdiff
path: root/src/cpl.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/cpl.cc')
-rw-r--r--src/cpl.cc90
1 files changed, 9 insertions, 81 deletions
diff --git a/src/cpl.cc b/src/cpl.cc
index 27481939..dc092d3d 100644
--- a/src/cpl.cc
+++ b/src/cpl.cc
@@ -398,82 +398,6 @@ CPL::read_composition_metadata_asset(cxml::ConstNodePtr node, vector<dcp::Verifi
}
-vector<MCASubDescriptor>
-CPL::create_mca_subdescriptors(shared_ptr<const SoundAsset> asset) const
-{
- vector<MCASubDescriptor> descriptors;
-
- auto reader = asset->start_read();
-
- ASDCP::MXF::SoundfieldGroupLabelSubDescriptor* soundfield;
- ASDCP::Result_t r = reader->reader()->OP1aHeader().GetMDObjectByType(
- asdcp_smpte_dict->ul(ASDCP::MDD_SoundfieldGroupLabelSubDescriptor),
- reinterpret_cast<ASDCP::MXF::InterchangeObject**>(&soundfield)
- );
-
- if (KM_SUCCESS(r)) {
- MCASubDescriptor descriptor("SoundfieldGroupLabelSubDescriptor");
- char buffer[64];
- soundfield->InstanceUID.EncodeString(buffer, sizeof(buffer));
- descriptor.instance_id = buffer;
- soundfield->MCALabelDictionaryID.EncodeString(buffer, sizeof(buffer));
- descriptor.mca_label_dictionary_id = "urn:smpte:ul:" + string(buffer);
- soundfield->MCALinkID.EncodeString(buffer, sizeof(buffer));
- descriptor.mca_link_id = buffer;
- soundfield->MCATagSymbol.EncodeString(buffer, sizeof(buffer));
- descriptor.mca_tag_symbol = buffer;
- if (!soundfield->MCATagName.empty()) {
- soundfield->MCATagName.get().EncodeString(buffer, sizeof(buffer));
- descriptor.mca_tag_name = buffer;
- }
- if (!soundfield->RFC5646SpokenLanguage.empty()) {
- soundfield->RFC5646SpokenLanguage.get().EncodeString(buffer, sizeof(buffer));
- descriptor.rfc5646_spoken_language = buffer;
- }
-
- descriptors.push_back(descriptor);
-
- /* Find the MCA subdescriptors in the MXF so that we can also write them here */
- list<ASDCP::MXF::InterchangeObject*> channels;
- auto r = reader->reader()->OP1aHeader().GetMDObjectsByType(
- asdcp_smpte_dict->ul(ASDCP::MDD_AudioChannelLabelSubDescriptor),
- channels
- );
-
- for (auto i: channels) {
- MCASubDescriptor descriptor("AudioChannelLabelSubDescriptor");
- auto channel = reinterpret_cast<ASDCP::MXF::AudioChannelLabelSubDescriptor*>(i);
- channel->InstanceUID.EncodeString(buffer, sizeof(buffer));
- descriptor.instance_id = buffer;
- channel->MCALabelDictionaryID.EncodeString(buffer, sizeof(buffer));
- descriptor.mca_label_dictionary_id = "urn:smpte:ul:" + string(buffer);
- channel->MCALinkID.EncodeString(buffer, sizeof(buffer));
- descriptor.mca_link_id = string(buffer);
- channel->MCATagSymbol.EncodeString(buffer, sizeof(buffer));
- descriptor.mca_tag_symbol = buffer;
- if (!channel->MCATagName.empty()) {
- channel->MCATagName.get().EncodeString(buffer, sizeof(buffer));
- descriptor.mca_tag_name = buffer;
- }
- if (!channel->MCAChannelID.empty()) {
- descriptor.mca_channel_id = fmt::to_string(channel->MCAChannelID.get());
- }
- if (!channel->RFC5646SpokenLanguage.empty()) {
- channel->RFC5646SpokenLanguage.get().EncodeString(buffer, sizeof(buffer));
- descriptor.rfc5646_spoken_language = buffer;
- }
- if (!channel->SoundfieldGroupLinkID.empty()) {
- channel->SoundfieldGroupLinkID.get().EncodeString(buffer, sizeof(buffer));
- descriptor.soundfield_group_link_id = buffer;
- }
- descriptors.push_back(descriptor);
- }
- }
-
- return descriptors;
-}
-
-
/** Write a CompositionMetadataAsset node as a child of @param node provided
* the required metadata is stored in the object. If any required metadata
* is missing this method will do nothing.
@@ -595,22 +519,26 @@ CPL::maybe_write_composition_metadata_asset(xmlpp::Element* node) const
}
if (_profile == Profile::SMPTE_BV21) {
- vector<MCASubDescriptor> descriptors;
+ pair<MCASubDescriptor, vector<MCASubDescriptor>> descriptors;
if (!_mca_sub_descriptors.empty()) {
/* We read these in, so reproduce them */
- descriptors = _mca_sub_descriptors;
+ descriptors.first = _mca_sub_descriptors[0];
+ for (size_t i = 1; i < _mca_sub_descriptors.size(); ++i) {
+ descriptors.second.push_back(_mca_sub_descriptors[i]);
+ }
} else if (_reels.front()->main_sound()) {
if (auto asset = _reels.front()->main_sound()->asset()) {
- descriptors = create_mca_subdescriptors(asset);
+ descriptors = create_mca_subdescriptors({}, 14, {});
}
}
- if (!descriptors.empty()) {
+ if (!descriptors.second.empty()) {
auto mca_subs = cxml::add_child(meta, "mca:MCASubDescriptors");
mca_subs->set_namespace_declaration(mca_sub_descriptors_ns, "mca");
mca_subs->set_namespace_declaration(smpte_395_ns, "r0");
mca_subs->set_namespace_declaration(smpte_335_ns, "r1");
- for (auto const& descriptor: descriptors) {
+ descriptors.first.as_xml(mca_subs);
+ for (auto const& descriptor: descriptors.second) {
descriptor.as_xml(mca_subs);
}
}