diff options
| author | Carl Hetherington <cth@carlh.net> | 2024-04-15 23:29:13 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2024-04-15 23:29:13 +0200 |
| commit | f22433bfab1cae79a9f4cab7286a27ca09d11715 (patch) | |
| tree | 39662734baa8810f0ec56d3dff50d77bec6de6f7 | |
| parent | 0eff1f460e187c5d0e3f3829a266d8dc9ee000db (diff) | |
Generalise sign language video tag handling and add test.
| -rw-r--r-- | src/cpl.cc | 26 | ||||
| -rw-r--r-- | test/cpl_metadata_test.cc | 17 | ||||
| -rw-r--r-- | test/ref/cpl_metadata_test4.xml | 68 |
3 files changed, 103 insertions, 8 deletions
@@ -345,21 +345,31 @@ CPL::read_composition_metadata_asset (cxml::ConstNodePtr node) } auto eml = node->optional_node_child ("ExtensionMetadataList"); - if (eml) { + + auto extension_metadata = [eml](string scope, string name, string property) -> boost::optional<std::string> { + if (!eml) { + return {}; + } + for (auto i: eml->node_children("ExtensionMetadata")) { - auto name = i->optional_string_child("Name"); - if (name && *name == "Sign Language Video") { + auto xml_scope = i->optional_string_attribute("scope"); + auto xml_name = i->optional_string_child("Name"); + if (xml_scope && *xml_scope == scope && xml_name && *xml_name == name) { auto property_list = i->node_child("PropertyList"); for (auto j: property_list->node_children("Property")) { - auto name = j->optional_string_child("Name"); - auto value = j->optional_string_child("Value"); - if (name && value && *name == "Language Tag") { - _sign_language_video_language = *value; + auto property_name = j->optional_string_child("Name"); + auto property_value = j->optional_string_child("Value"); + if (property_name && property_value && *property_name == property) { + return property_value; } } } } - } + + return {}; + }; + + _sign_language_video_language = extension_metadata("http://isdcf.com/2017/10/SignLanguageVideo", "Sign Language Video", "Language Tag"); } diff --git a/test/cpl_metadata_test.cc b/test/cpl_metadata_test.cc index 0ebf9078..f704fc9a 100644 --- a/test/cpl_metadata_test.cc +++ b/test/cpl_metadata_test.cc @@ -450,3 +450,20 @@ BOOST_AUTO_TEST_CASE(check_that_missing_full_content_title_text_is_tolerated) { dcp::CPL cpl("test/ref/cpl_metadata_test3.xml"); } + + +BOOST_AUTO_TEST_CASE(check_sign_language_video_language) +{ + dcp::CPL cpl("test/ref/cpl_metadata_test3.xml"); + cpl.set_sign_language_video_language(dcp::LanguageTag("es-PT")); + cpl.write_xml("build/test/check_sign_language_video_language.xml", {}); + check_xml( + dcp::file_to_string("test/ref/cpl_metadata_test4.xml"), + dcp::file_to_string("build/test/check_sign_language_video_language.xml"), + {"Id"} + ); + + dcp::CPL check("build/test/check_sign_language_video_language.xml"); + BOOST_CHECK_EQUAL(check.sign_language_video_language().get_value_or(""), "es-PT"); + +} diff --git a/test/ref/cpl_metadata_test4.xml b/test/ref/cpl_metadata_test4.xml new file mode 100644 index 00000000..e4459375 --- /dev/null +++ b/test/ref/cpl_metadata_test4.xml @@ -0,0 +1,68 @@ +<?xml version="1.0" encoding="UTF-8"?> +<CompositionPlaylist xmlns="http://www.smpte-ra.org/schemas/429-7/2006/CPL"> + <Id>urn:uuid:81fb54df-e1bf-4647-8788-ea7ba154375b</Id> + <AnnotationText></AnnotationText> + <IssueDate>2020-08-28T13:35:06+02:00</IssueDate> + <Issuer>libdcp1.6.4devel</Issuer> + <Creator>libdcp1.6.4devel</Creator> + <ContentTitleText></ContentTitleText> + <ContentKind>feature</ContentKind> + <ContentVersion> + <Id>id</Id> + <LabelText>version</LabelText> + </ContentVersion> + <RatingList/> + <ReelList> + <Reel> + <Id>urn:uuid:46c3eb45-15e5-47d6-8684-d8641e4dc516</Id> + <AssetList> + <MainPicture> + <Id>urn:uuid:e98d059d-645f-4343-a30f-edc61d58b8e0</Id> + <EditRate>24 1</EditRate> + <IntrinsicDuration>24</IntrinsicDuration> + <EntryPoint>0</EntryPoint> + <Duration>24</Duration> + <Hash>JtPL3uT3jyKMLysaqgdBWQb/n2E=</Hash> + <FrameRate>24 1</FrameRate> + <ScreenAspectRatio>1998 1080</ScreenAspectRatio> + </MainPicture> + <meta:CompositionMetadataAsset xmlns:meta="http://www.smpte-ra.org/schemas/429-16/2014/CPL-Metadata"> + <Id>urn:uuid:d36f4bb3-c4fa-4a95-9915-6fec3110cd71</Id> + <EditRate>24 1</EditRate> + <IntrinsicDuration>24</IntrinsicDuration> + <meta:FullContentTitleText/> + <meta:MainSoundConfiguration>71/L,R,C,LFE,-,-,-,-,-,-,-,-,-,FSKSync,-,-</meta:MainSoundConfiguration> + <meta:MainSoundSampleRate>48000 1</meta:MainSoundSampleRate> + <meta:MainPictureStoredArea> + <meta:Width>1998</meta:Width> + <meta:Height>1080</meta:Height> + </meta:MainPictureStoredArea> + <meta:MainPictureActiveArea> + <meta:Width>1440</meta:Width> + <meta:Height>1080</meta:Height> + </meta:MainPictureActiveArea> + <meta:ExtensionMetadataList> + <meta:ExtensionMetadata scope="http://isdcf.com/ns/cplmd/app"> + <meta:Name>Application</meta:Name> + <meta:PropertyList> + <meta:Property> + <meta:Name>DCP Constraints Profile</meta:Name> + <meta:Value>SMPTE-RDD-52:2020-Bv2.1</meta:Value> + </meta:Property> + </meta:PropertyList> + </meta:ExtensionMetadata> + <meta:ExtensionMetadata scope="http://isdcf.com/2017/10/SignLanguageVideo"> + <meta:Name>Sign Language Video</meta:Name> + <meta:PropertyList> + <meta:Property> + <meta:Name>Language Tag</meta:Name> + <meta:Value>es-PT</meta:Value> + </meta:Property> + </meta:PropertyList> + </meta:ExtensionMetadata> + </meta:ExtensionMetadataList> + </meta:CompositionMetadataAsset> + </AssetList> + </Reel> + </ReelList> +</CompositionPlaylist> |
