Generalise sign language video tag handling and add test.
authorCarl Hetherington <cth@carlh.net>
Mon, 15 Apr 2024 21:29:13 +0000 (23:29 +0200)
committerCarl Hetherington <cth@carlh.net>
Mon, 15 Apr 2024 21:29:13 +0000 (23:29 +0200)
src/cpl.cc
test/cpl_metadata_test.cc
test/ref/cpl_metadata_test4.xml [new file with mode: 0644]

index 5467fef3b1db0b38ebf859e5d4adf623e7342dd7..da4e056377de9b3c6ac81ae886c61212c2f58309 100644 (file)
@@ -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");
 }
 
 
index 0ebf9078af6fb00b3be1656c2a1cc622691f646b..f704fc9a148a2077320b185c39c003f46b933259 100644 (file)
@@ -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 (file)
index 0000000..e445937
--- /dev/null
@@ -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>