Write OriginalFileName tags in PKL (DoM #2394).
authorCarl Hetherington <cth@carlh.net>
Thu, 22 Dec 2022 00:59:11 +0000 (01:59 +0100)
committerCarl Hetherington <cth@carlh.net>
Thu, 22 Dec 2022 22:43:03 +0000 (23:43 +0100)
Without these it EasyDCP gives errors like

"Id field in PKL must match uuid in asset"
"Each Id used in the PKL files must be unique or reference the same file"

which seem wrong but, as usual, here we are.

17 files changed:
src/asset.cc
src/interop_subtitle_asset.cc
src/pkl.cc
src/pkl.h
test/ref/DCP/dcp_test1/ASSETMAP.xml
test/ref/DCP/dcp_test1/pkl_d199d58b-5ef8-4d49-b270-07e590ccb280.xml
test/ref/DCP/dcp_test2/ASSETMAP.xml
test/ref/DCP/dcp_test2/pkl_d199d58b-5ef8-4d49-b270-07e590ccb280.xml
test/ref/DCP/dcp_test5/ASSETMAP.xml
test/ref/DCP/dcp_test5/pkl_017b3de4-6dda-408d-b19b-6711354b0bc3.xml
test/ref/DCP/dcp_test7/ASSETMAP
test/ref/DCP/dcp_test7/pkl_d199d58b-5ef8-4d49-b270-07e590ccb280.xml
test/ref/DCP/encryption_test/ASSETMAP.xml
test/ref/DCP/encryption_test/pkl_93887017-5d6a-4ee5-b5f4-161b06281d0e.xml
test/ref/write_interop_subtitle_test3/ASSETMAP
test/ref/write_interop_subtitle_test3/pkl_ac8d301c-e5d9-4343-b6f3-ba2668adbe56.xml
test/verify_test.cc

index 372779b134924f689370b46e0525577d2aaee8f8..c164a26b75d3aaf1def0af5fdb0b800e849315f6 100644 (file)
@@ -98,7 +98,7 @@ Asset::add_to_pkl (shared_ptr<PKL> pkl, path root) const
                return;
        }
 
-       pkl->add_asset (_id, _id, hash(), file_size(_file.get()), pkl_type(pkl->standard()));
+       pkl->add_asset(_id, _id, hash(), file_size(_file.get()), pkl_type(pkl->standard()), _file->filename().string());
 }
 
 
index ce3a494383869b432d706fb8d44666826342dc0a..d58e16a3fab0dcab721a5d8fd6ac7c7b985aee38 100644 (file)
@@ -290,7 +290,7 @@ InteropSubtitleAsset::add_to_pkl (shared_ptr<PKL> pkl, boost::filesystem::path r
                auto im = dynamic_pointer_cast<dcp::SubtitleImage> (i);
                if (im) {
                        auto png_image = im->png_image ();
-                       pkl->add_asset (im->id(), optional<string>(), make_digest(png_image), png_image.size(), "image/png");
+                       pkl->add_asset(im->id(), optional<string>(), make_digest(png_image), png_image.size(), "image/png", root.filename().string());
                }
        }
 }
index 5465d578b0ea002cb9cb3d59ac09f6331009a18f..9ba716fb6c69d385878dd6dfcf52725c21a362c5 100644 (file)
@@ -87,9 +87,9 @@ PKL::PKL (boost::filesystem::path file)
 
 
 void
-PKL::add_asset (std::string id, boost::optional<std::string> annotation_text, std::string hash, int64_t size, std::string type)
+PKL::add_asset(std::string id, boost::optional<std::string> annotation_text, std::string hash, int64_t size, std::string type, std::string original_filename)
 {
-       _asset_list.push_back (make_shared<Asset>(id, annotation_text, hash, size, type));
+       _asset_list.push_back(make_shared<Asset>(id, annotation_text, hash, size, type, original_filename));
 }
 
 
@@ -122,6 +122,9 @@ PKL::write_xml (boost::filesystem::path file, shared_ptr<const CertificateChain>
                asset->add_child("Hash")->add_child_text (i->hash());
                asset->add_child("Size")->add_child_text (raw_convert<string>(i->size()));
                asset->add_child("Type")->add_child_text (i->type());
+               if (auto filename = i->original_filename()) {
+                       asset->add_child("OriginalFileName")->add_child_text(*filename);
+               }
        }
 
        indent (pkl, 0);
index 8b1b88a33d2742cd616a3eb5442db62e6486a93a..8a1d07f941d289820d337b8d47bb88c2d1d65357 100644 (file)
--- a/src/pkl.h
+++ b/src/pkl.h
@@ -66,7 +66,7 @@ public:
        boost::optional<std::string> type (std::string id) const;
 
        void clear_assets();
-       void add_asset (std::string id, boost::optional<std::string> annotation_text, std::string hash, int64_t size, std::string type);
+       void add_asset(std::string id, boost::optional<std::string> annotation_text, std::string hash, int64_t size, std::string type, std::string original_filename);
        void write_xml (boost::filesystem::path file, std::shared_ptr<const CertificateChain> signer) const;
 
        /** @return the most recent disk file used to read or write this PKL, if there is one */
@@ -83,14 +83,16 @@ public:
                        , _hash (node->string_child("Hash"))
                        , _size (node->number_child<int64_t>("Size"))
                        , _type (node->string_child("Type"))
+                       , _original_filename(node->optional_string_child("OriginalFileName"))
                {}
 
-               Asset (std::string id, boost::optional<std::string> annotation_text, std::string hash, int64_t size, std::string type)
+               Asset(std::string id, boost::optional<std::string> annotation_text, std::string hash, int64_t size, std::string type, std::string original_filename)
                        : Object (id)
                        , _annotation_text (annotation_text)
                        , _hash (hash)
                        , _size (size)
                        , _type (type)
+                       , _original_filename(original_filename)
                {}
 
                boost::optional<std::string> annotation_text () const {
@@ -109,11 +111,16 @@ public:
                        return _type;
                }
 
+               boost::optional<std::string> original_filename() const {
+                       return _original_filename;
+               }
+
        private:
                boost::optional<std::string> _annotation_text;
                std::string _hash;
                int64_t _size = 0;
                std::string _type;
+               boost::optional<std::string> _original_filename;
        };
 
        std::vector<std::shared_ptr<Asset>> asset_list () const {
index f805bb28fa04b1fea351b1fd4bd655115e134a16..4e0d1e5aea384fe9cbcaa8de6cf280423c961890 100644 (file)
@@ -15,7 +15,7 @@
           <Path>pkl_d199d58b-5ef8-4d49-b270-07e590ccb280.xml</Path>
           <VolumeIndex>1</VolumeIndex>
           <Offset>0</Offset>
-          <Length>1179</Length>
+          <Length>1373</Length>
         </Chunk>
       </ChunkList>
     </Asset>
index dd963585682c471f29f0d0ac0382cd5377faf66f..cedbb15b29907007ba2f5024fc525597bdb50907 100644 (file)
@@ -12,6 +12,7 @@
       <Hash>tfX1mVIKJCVr1m7Y32Nzxf0+Rpw=</Hash>
       <Size>8559</Size>
       <Type>text/xml</Type>
+      <OriginalFileName>cpl_6affb8ee-0020-4dff-a53c-17652f6358ab.xml</OriginalFileName>
     </Asset>
     <Asset>
       <Id>urn:uuid:5407b210-4441-4e97-8b16-8bdc7c12da54</Id>
@@ -19,6 +20,7 @@
       <Hash>wUmt8G+cFFKMGt0ueS9+F1S4uhc=</Hash>
       <Size>49240</Size>
       <Type>application/mxf</Type>
+      <OriginalFileName>video.mxf</OriginalFileName>
     </Asset>
     <Asset>
       <Id>urn:uuid:97f0f352-5b77-48ee-a558-9df37717f4fa</Id>
@@ -26,6 +28,7 @@
       <Hash>KcJb7S2K5cNm8RG4kfQD5FTeS0A=</Hash>
       <Size>881326</Size>
       <Type>application/mxf</Type>
+      <OriginalFileName>audio.mxf</OriginalFileName>
     </Asset>
   </AssetList>
 </PackingList>
index e0adff1e54bd3d5a3643d77087af4312d989a37b..68d9a5cb797a9d4d0007da50a97f2282198ac914 100644 (file)
@@ -15,7 +15,7 @@
           <Path>pkl_d199d58b-5ef8-4d49-b270-07e590ccb280.xml</Path>
           <VolumeIndex>1</VolumeIndex>
           <Offset>0</Offset>
-          <Length>1186</Length>
+          <Length>1380</Length>
         </Chunk>
       </ChunkList>
     </Asset>
index d116216302131f2492300eaebaaf5758e5553dc1..44da5c43746dadcfe489ef8de7ceac8c788b12a6 100644 (file)
@@ -12,6 +12,7 @@
       <Hash>6F7kAEYbNdv6gz6PG5JcMjGF8kU=</Hash>
       <Size>1686</Size>
       <Type>text/xml</Type>
+      <OriginalFileName>cpl_6affb8ee-0020-4dff-a53c-17652f6358ab.xml</OriginalFileName>
     </Asset>
     <Asset>
       <Id>urn:uuid:5407b210-4441-4e97-8b16-8bdc7c12da54</Id>
@@ -19,6 +20,7 @@
       <Hash>BUpeFS6X9j+X0z2TZWSsLMT4pE0=</Hash>
       <Size>63160</Size>
       <Type>application/mxf</Type>
+      <OriginalFileName>video.mxf</OriginalFileName>
     </Asset>
     <Asset>
       <Id>urn:uuid:fc843acc-1ad9-4808-b9ed-33f5319e047d</Id>
@@ -26,6 +28,7 @@
       <Hash>3PtaGoYcvBdq5WYiK0cmeDwm8d0=</Hash>
       <Size>161326</Size>
       <Type>application/mxf</Type>
+      <OriginalFileName>audio.mxf</OriginalFileName>
     </Asset>
   </AssetList>
 </PackingList>
index 42b8133bea586e87553c556e60679fbe9944e1ee..79a3091cfe1945b738c7be9939b891b50ef1df06 100644 (file)
@@ -15,7 +15,7 @@
           <Path>pkl_017b3de4-6dda-408d-b19b-6711354b0bc3.xml</Path>
           <VolumeIndex>1</VolumeIndex>
           <Offset>0</Offset>
-          <Length>1186</Length>
+          <Length>1380</Length>
         </Chunk>
       </ChunkList>
     </Asset>
index 77d67c233616a64b848a122b8565b1cb93f753dd..9b3887745c956a5bfa9797021a10782b141dd236 100644 (file)
@@ -12,6 +12,7 @@
       <Hash>kiv8PHo8XZc/lI2xk7qYghrP2SA=</Hash>
       <Size>2024</Size>
       <Type>text/xml</Type>
+      <OriginalFileName>cpl_6affb8ee-0020-4dff-a53c-17652f6358ab.xml</OriginalFileName>
     </Asset>
     <Asset>
       <Id>urn:uuid:5407b210-4441-4e97-8b16-8bdc7c12da54</Id>
@@ -19,6 +20,7 @@
       <Hash>o3VmpdFsNUgF11oadcaGJ/IfO0M=</Hash>
       <Size>40144</Size>
       <Type>application/mxf</Type>
+      <OriginalFileName>video.mxf</OriginalFileName>
     </Asset>
     <Asset>
       <Id>urn:uuid:97f0f352-5b77-48ee-a558-9df37717f4fa</Id>
@@ -26,6 +28,7 @@
       <Hash>wLbXcpQtWt2IFMHIcibxwND667I=</Hash>
       <Size>161326</Size>
       <Type>application/mxf</Type>
+      <OriginalFileName>audio.mxf</OriginalFileName>
     </Asset>
   </AssetList>
 </PackingList>
index f41b136643007e030ec96a32e2a311886e29d00a..86a6ff6a49216bb8d3b2ae6d5b3bb9dc18fe44d7 100644 (file)
@@ -15,7 +15,7 @@
           <Path>pkl_d199d58b-5ef8-4d49-b270-07e590ccb280.xml</Path>
           <VolumeIndex>1</VolumeIndex>
           <Offset>0</Offset>
-          <Length>1253</Length>
+          <Length>1447</Length>
         </Chunk>
       </ChunkList>
     </Asset>
index 20bad65ea13cf1adedd30e340b57a80297e87822..4180eb8dab0d51ea0800bc1a5749a06e187774dc 100644 (file)
@@ -12,6 +12,7 @@
       <Hash>Vsre14v3AhK6X2gUzeYF9G8GKo0=</Hash>
       <Size>1965</Size>
       <Type>text/xml;asdcpKind=CPL</Type>
+      <OriginalFileName>cpl_6affb8ee-0020-4dff-a53c-17652f6358ab.xml</OriginalFileName>
     </Asset>
     <Asset>
       <Id>urn:uuid:5407b210-4441-4e97-8b16-8bdc7c12da54</Id>
@@ -19,6 +20,7 @@
       <Hash>wUmt8G+cFFKMGt0ueS9+F1S4uhc=</Hash>
       <Size>49240</Size>
       <Type>application/x-smpte-mxf;asdcpKind=Picture</Type>
+      <OriginalFileName>video.mxf</OriginalFileName>
     </Asset>
     <Asset>
       <Id>urn:uuid:97f0f352-5b77-48ee-a558-9df37717f4fa</Id>
@@ -26,6 +28,7 @@
       <Hash>KcJb7S2K5cNm8RG4kfQD5FTeS0A=</Hash>
       <Size>881326</Size>
       <Type>application/x-smpte-mxf;asdcpKind=Sound</Type>
+      <OriginalFileName>audio.mxf</OriginalFileName>
     </Asset>
   </AssetList>
 </PackingList>
index cf6c74f5ba8b026b23647f0cd0beba5053d124e6..902833dc5be900b3ec5a9d2efaeb475a991e8260 100644 (file)
@@ -15,7 +15,7 @@
           <Path>pkl_93887017-5d6a-4ee5-b5f4-161b06281d0e.xml</Path>
           <VolumeIndex>1</VolumeIndex>
           <Offset>0</Offset>
-          <Length>8708</Length>
+          <Length>8902</Length>
         </Chunk>
       </ChunkList>
     </Asset>
index 57421adc0d0d103cf4062ec316b5ea1b767ede56..db5b78f2a733d0229a94f0ad270004b7127974a8 100644 (file)
@@ -12,6 +12,7 @@
       <Hash>ocIgRDFtEn7QPxwcqXYVpSrTPpI=</Hash>
       <Size>9226</Size>
       <Type>text/xml</Type>
+      <OriginalFileName>cpl_6affb8ee-0020-4dff-a53c-17652f6358ab.xml</OriginalFileName>
     </Asset>
     <Asset>
       <Id>urn:uuid:9a7fbb03-4078-4944-90b1-0d8a21c9d793</Id>
@@ -19,6 +20,7 @@
       <Hash>AVtX8wz76uG2Uw0Qbc9+DKnHUfw=</Hash>
       <Size>44008</Size>
       <Type>application/mxf</Type>
+      <OriginalFileName>video.mxf</OriginalFileName>
     </Asset>
     <Asset>
       <Id>urn:uuid:ce300880-a425-40a6-adac-eb1e3f5643fc</Id>
@@ -26,6 +28,7 @@
       <Hash>lS+FKcwLD7cRjgZMQ+hvGg/yJIc=</Hash>
       <Size>165454</Size>
       <Type>application/mxf</Type>
+      <OriginalFileName>audio.mxf</OriginalFileName>
     </Asset>
   </AssetList>
   <Signer xmlns:dsig="http://www.w3.org/2000/09/xmldsig#">
           <dsig:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>
         </dsig:Transforms>
         <dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
-        <dsig:DigestValue>Gxo6VfxF8Guiq1+IFU2ePslEu00=</dsig:DigestValue>
+        <dsig:DigestValue>G6rpYhOo/0ZdBo+SI3UzyPQA/F0=</dsig:DigestValue>
       </dsig:Reference>
     </dsig:SignedInfo>
-    <dsig:SignatureValue>bzUioGIym79+2SaZ+V3zHOnZzoYR2L3NcW0yrre+FclIO2BB6XjdPnJJJPEHml9R
-ATXtAOUIjYUZT5x+2B64dpclvIdikr4P72J6PQzHB+lvnrptoisOhFMa0Pnk1vCi
-0o/WBHUCSDePU8Hl8OGK9GL+n/iXEZKfbpuAIRBIGayD1WE1CmTxGxVx28VTk+2H
-klIbYhojVoj0AaaVN9xVvaq126Tmk4y1dILyPlNyYYVxzam7T1hlEHSj3E4i3StZ
-r1vsK8I8EMWLrBio3ih44GwkJeM6N7PPI5kDeen7Mk7S4Btq+HtildekSmKRNkOc
-odAqTC/SVvYtWvri7PldJQ==</dsig:SignatureValue>
+    <dsig:SignatureValue>tdapJHKPEmEa552oOg9s3/Q4TcnzIiNfd3U+xiSG5XGl+7K0n6JKbpNVgm4KpE0l
+a7bVsu4Yp0ftCrcjxxczZ/puS7nVC/zcfk63miZcJKdXem0xt0AZJHEguwQq74Tc
+48Efe1/MtIBCOtQErh2kcDVwXOUo6Nz0yW1g5PRQ5u9KlqQ67RLqDWRdX1OkWIUZ
+Z2Iz2nSnTP4GDDHs5pX6xxZKNlgZIa5iYMBp97X1DGlGaQ2o/sbcUysE4g4oO+iU
+cfRdkI68vj53hHWApxVGoAPAl4t8B6kMbLQAp1w4R/4ruLR9FKTffqRlUjOXtyiT
+pQVNxwCU50/opyfv8v2v6w==</dsig:SignatureValue>
     <dsig:KeyInfo>
       <dsig:X509Data>
         <dsig:X509IssuerSerial>
index 8dfb256d47cea8a8b615c5c7434e25699ec3d594..1fd41e81e83ad35a38db7b2f69d972536fcb7e6a 100644 (file)
@@ -15,7 +15,7 @@
           <Path>pkl_ac8d301c-e5d9-4343-b6f3-ba2668adbe56.xml</Path>
           <VolumeIndex>1</VolumeIndex>
           <Offset>0</Offset>
-          <Length>1114</Length>
+          <Length>1326</Length>
         </Chunk>
       </ChunkList>
     </Asset>
index 362177c7b4b76361331c810adadcb73a37079309..ae7644afb50a3931caa7456c5b9563043eb5d6b4 100644 (file)
@@ -12,6 +12,7 @@
       <Hash>M9U2kzcnfcBAy7MrXZGKjA8hQRU=</Hash>
       <Size>1061</Size>
       <Type>text/xml;asdcpKind=CPL</Type>
+      <OriginalFileName>cpl_5407b210-4441-4e97-8b16-8bdc7c12da54.xml</OriginalFileName>
     </Asset>
     <Asset>
       <Id>urn:uuid:a6c58cff-3e1e-4b38-acec-a42224475ef6</Id>
       <Hash>RmflhDu9QYUsNnBftdNlIEGdzG0=</Hash>
       <Size>438</Size>
       <Type>text/xml;asdcpKind=Subtitle</Type>
+      <OriginalFileName>subs.xml</OriginalFileName>
     </Asset>
     <Asset>
       <Id>urn:uuid:dd015243-ab77-435c-a13d-690566885121</Id>
       <Hash>2vTylSKQ5MCQHbKPT4X+rlwfHk4=</Hash>
       <Size>44861</Size>
       <Type>image/png</Type>
+      <OriginalFileName>write_interop_subtitle_test3</OriginalFileName>
     </Asset>
   </AssetList>
 </PackingList>
index 1122f73b5f550c1e66f3b94735322f0495f42503..d1319810293c0d901f24018c52b9f0c73543198e 100644 (file)
@@ -458,9 +458,9 @@ BOOST_AUTO_TEST_CASE (verify_mismatched_picture_sound_hashes)
                        { dcp::VerificationNote::Type::ERROR, dcp::VerificationNote::Code::MISMATCHED_CPL_HASHES, dcp_test1_cpl_id, canonical(dir / dcp_test1_cpl) },
                        { dcp::VerificationNote::Type::ERROR, dcp::VerificationNote::Code::MISMATCHED_PICTURE_HASHES, canonical(dir / "video.mxf") },
                        { dcp::VerificationNote::Type::ERROR, dcp::VerificationNote::Code::MISMATCHED_SOUND_HASHES, canonical(dir / "audio.mxf") },
-                       { dcp::VerificationNote::Type::ERROR, dcp::VerificationNote::Code::INVALID_XML, "value 'xKcJb7S2K5cNm8RG4kfQD5FTeS0A=' is invalid Base64-encoded binary", canonical(dir / dcp_test1_pkl), 26 },
+                       { dcp::VerificationNote::Type::ERROR, dcp::VerificationNote::Code::INVALID_XML, "value 'xKcJb7S2K5cNm8RG4kfQD5FTeS0A=' is invalid Base64-encoded binary", canonical(dir / dcp_test1_pkl), 28 },
                        { dcp::VerificationNote::Type::ERROR, dcp::VerificationNote::Code::INVALID_XML, "value 'xtfX1mVIKJCVr1m7Y32Nzxf0+Rpw=' is invalid Base64-encoded binary", canonical(dir / dcp_test1_pkl), 12 },
-                       { dcp::VerificationNote::Type::ERROR, dcp::VerificationNote::Code::INVALID_XML, "value 'xwUmt8G+cFFKMGt0ueS9+F1S4uhc=' is invalid Base64-encoded binary", canonical(dir / dcp_test1_pkl), 19 },
+                       { dcp::VerificationNote::Type::ERROR, dcp::VerificationNote::Code::INVALID_XML, "value 'xwUmt8G+cFFKMGt0ueS9+F1S4uhc=' is invalid Base64-encoded binary", canonical(dir / dcp_test1_pkl), 20 },
                });
 }