From 4ddd146759e5346bd6c4b4444ee1424327f14a2a Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Thu, 22 Dec 2022 01:59:11 +0100 Subject: Write OriginalFileName tags in PKL (DoM #2394). 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. --- src/asset.cc | 2 +- src/interop_subtitle_asset.cc | 2 +- src/pkl.cc | 7 +++++-- src/pkl.h | 11 +++++++++-- test/ref/DCP/dcp_test1/ASSETMAP.xml | 2 +- .../pkl_d199d58b-5ef8-4d49-b270-07e590ccb280.xml | 3 +++ test/ref/DCP/dcp_test2/ASSETMAP.xml | 2 +- .../pkl_d199d58b-5ef8-4d49-b270-07e590ccb280.xml | 3 +++ test/ref/DCP/dcp_test5/ASSETMAP.xml | 2 +- .../pkl_017b3de4-6dda-408d-b19b-6711354b0bc3.xml | 3 +++ test/ref/DCP/dcp_test7/ASSETMAP | 2 +- .../pkl_d199d58b-5ef8-4d49-b270-07e590ccb280.xml | 3 +++ test/ref/DCP/encryption_test/ASSETMAP.xml | 2 +- .../pkl_93887017-5d6a-4ee5-b5f4-161b06281d0e.xml | 17 ++++++++++------- test/ref/write_interop_subtitle_test3/ASSETMAP | 2 +- .../pkl_ac8d301c-e5d9-4343-b6f3-ba2668adbe56.xml | 3 +++ test/verify_test.cc | 4 ++-- 17 files changed, 49 insertions(+), 21 deletions(-) diff --git a/src/asset.cc b/src/asset.cc index 372779b1..c164a26b 100644 --- a/src/asset.cc +++ b/src/asset.cc @@ -98,7 +98,7 @@ Asset::add_to_pkl (shared_ptr 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()); } diff --git a/src/interop_subtitle_asset.cc b/src/interop_subtitle_asset.cc index ce3a4943..d58e16a3 100644 --- a/src/interop_subtitle_asset.cc +++ b/src/interop_subtitle_asset.cc @@ -290,7 +290,7 @@ InteropSubtitleAsset::add_to_pkl (shared_ptr pkl, boost::filesystem::path r auto im = dynamic_pointer_cast (i); if (im) { auto png_image = im->png_image (); - pkl->add_asset (im->id(), optional(), make_digest(png_image), png_image.size(), "image/png"); + pkl->add_asset(im->id(), optional(), make_digest(png_image), png_image.size(), "image/png", root.filename().string()); } } } diff --git a/src/pkl.cc b/src/pkl.cc index 5465d578..9ba716fb 100644 --- a/src/pkl.cc +++ b/src/pkl.cc @@ -87,9 +87,9 @@ PKL::PKL (boost::filesystem::path file) void -PKL::add_asset (std::string id, boost::optional annotation_text, std::string hash, int64_t size, std::string type) +PKL::add_asset(std::string id, boost::optional annotation_text, std::string hash, int64_t size, std::string type, std::string original_filename) { - _asset_list.push_back (make_shared(id, annotation_text, hash, size, type)); + _asset_list.push_back(make_shared(id, annotation_text, hash, size, type, original_filename)); } @@ -122,6 +122,9 @@ PKL::write_xml (boost::filesystem::path file, shared_ptr asset->add_child("Hash")->add_child_text (i->hash()); asset->add_child("Size")->add_child_text (raw_convert(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); diff --git a/src/pkl.h b/src/pkl.h index 8b1b88a3..8a1d07f9 100644 --- a/src/pkl.h +++ b/src/pkl.h @@ -66,7 +66,7 @@ public: boost::optional type (std::string id) const; void clear_assets(); - void add_asset (std::string id, boost::optional annotation_text, std::string hash, int64_t size, std::string type); + void add_asset(std::string id, boost::optional 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 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("Size")) , _type (node->string_child("Type")) + , _original_filename(node->optional_string_child("OriginalFileName")) {} - Asset (std::string id, boost::optional annotation_text, std::string hash, int64_t size, std::string type) + Asset(std::string id, boost::optional 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 annotation_text () const { @@ -109,11 +111,16 @@ public: return _type; } + boost::optional original_filename() const { + return _original_filename; + } + private: boost::optional _annotation_text; std::string _hash; int64_t _size = 0; std::string _type; + boost::optional _original_filename; }; std::vector> asset_list () const { diff --git a/test/ref/DCP/dcp_test1/ASSETMAP.xml b/test/ref/DCP/dcp_test1/ASSETMAP.xml index f805bb28..4e0d1e5a 100644 --- a/test/ref/DCP/dcp_test1/ASSETMAP.xml +++ b/test/ref/DCP/dcp_test1/ASSETMAP.xml @@ -15,7 +15,7 @@ pkl_d199d58b-5ef8-4d49-b270-07e590ccb280.xml 1 0 - 1179 + 1373 diff --git a/test/ref/DCP/dcp_test1/pkl_d199d58b-5ef8-4d49-b270-07e590ccb280.xml b/test/ref/DCP/dcp_test1/pkl_d199d58b-5ef8-4d49-b270-07e590ccb280.xml index dd963585..cedbb15b 100644 --- a/test/ref/DCP/dcp_test1/pkl_d199d58b-5ef8-4d49-b270-07e590ccb280.xml +++ b/test/ref/DCP/dcp_test1/pkl_d199d58b-5ef8-4d49-b270-07e590ccb280.xml @@ -12,6 +12,7 @@ tfX1mVIKJCVr1m7Y32Nzxf0+Rpw= 8559 text/xml + cpl_6affb8ee-0020-4dff-a53c-17652f6358ab.xml urn:uuid:5407b210-4441-4e97-8b16-8bdc7c12da54 @@ -19,6 +20,7 @@ wUmt8G+cFFKMGt0ueS9+F1S4uhc= 49240 application/mxf + video.mxf urn:uuid:97f0f352-5b77-48ee-a558-9df37717f4fa @@ -26,6 +28,7 @@ KcJb7S2K5cNm8RG4kfQD5FTeS0A= 881326 application/mxf + audio.mxf diff --git a/test/ref/DCP/dcp_test2/ASSETMAP.xml b/test/ref/DCP/dcp_test2/ASSETMAP.xml index e0adff1e..68d9a5cb 100644 --- a/test/ref/DCP/dcp_test2/ASSETMAP.xml +++ b/test/ref/DCP/dcp_test2/ASSETMAP.xml @@ -15,7 +15,7 @@ pkl_d199d58b-5ef8-4d49-b270-07e590ccb280.xml 1 0 - 1186 + 1380 diff --git a/test/ref/DCP/dcp_test2/pkl_d199d58b-5ef8-4d49-b270-07e590ccb280.xml b/test/ref/DCP/dcp_test2/pkl_d199d58b-5ef8-4d49-b270-07e590ccb280.xml index d1162163..44da5c43 100644 --- a/test/ref/DCP/dcp_test2/pkl_d199d58b-5ef8-4d49-b270-07e590ccb280.xml +++ b/test/ref/DCP/dcp_test2/pkl_d199d58b-5ef8-4d49-b270-07e590ccb280.xml @@ -12,6 +12,7 @@ 6F7kAEYbNdv6gz6PG5JcMjGF8kU= 1686 text/xml + cpl_6affb8ee-0020-4dff-a53c-17652f6358ab.xml urn:uuid:5407b210-4441-4e97-8b16-8bdc7c12da54 @@ -19,6 +20,7 @@ BUpeFS6X9j+X0z2TZWSsLMT4pE0= 63160 application/mxf + video.mxf urn:uuid:fc843acc-1ad9-4808-b9ed-33f5319e047d @@ -26,6 +28,7 @@ 3PtaGoYcvBdq5WYiK0cmeDwm8d0= 161326 application/mxf + audio.mxf diff --git a/test/ref/DCP/dcp_test5/ASSETMAP.xml b/test/ref/DCP/dcp_test5/ASSETMAP.xml index 42b8133b..79a3091c 100644 --- a/test/ref/DCP/dcp_test5/ASSETMAP.xml +++ b/test/ref/DCP/dcp_test5/ASSETMAP.xml @@ -15,7 +15,7 @@ pkl_017b3de4-6dda-408d-b19b-6711354b0bc3.xml 1 0 - 1186 + 1380 diff --git a/test/ref/DCP/dcp_test5/pkl_017b3de4-6dda-408d-b19b-6711354b0bc3.xml b/test/ref/DCP/dcp_test5/pkl_017b3de4-6dda-408d-b19b-6711354b0bc3.xml index 77d67c23..9b388774 100644 --- a/test/ref/DCP/dcp_test5/pkl_017b3de4-6dda-408d-b19b-6711354b0bc3.xml +++ b/test/ref/DCP/dcp_test5/pkl_017b3de4-6dda-408d-b19b-6711354b0bc3.xml @@ -12,6 +12,7 @@ kiv8PHo8XZc/lI2xk7qYghrP2SA= 2024 text/xml + cpl_6affb8ee-0020-4dff-a53c-17652f6358ab.xml urn:uuid:5407b210-4441-4e97-8b16-8bdc7c12da54 @@ -19,6 +20,7 @@ o3VmpdFsNUgF11oadcaGJ/IfO0M= 40144 application/mxf + video.mxf urn:uuid:97f0f352-5b77-48ee-a558-9df37717f4fa @@ -26,6 +28,7 @@ wLbXcpQtWt2IFMHIcibxwND667I= 161326 application/mxf + audio.mxf diff --git a/test/ref/DCP/dcp_test7/ASSETMAP b/test/ref/DCP/dcp_test7/ASSETMAP index f41b1366..86a6ff6a 100644 --- a/test/ref/DCP/dcp_test7/ASSETMAP +++ b/test/ref/DCP/dcp_test7/ASSETMAP @@ -15,7 +15,7 @@ pkl_d199d58b-5ef8-4d49-b270-07e590ccb280.xml 1 0 - 1253 + 1447 diff --git a/test/ref/DCP/dcp_test7/pkl_d199d58b-5ef8-4d49-b270-07e590ccb280.xml b/test/ref/DCP/dcp_test7/pkl_d199d58b-5ef8-4d49-b270-07e590ccb280.xml index 20bad65e..4180eb8d 100644 --- a/test/ref/DCP/dcp_test7/pkl_d199d58b-5ef8-4d49-b270-07e590ccb280.xml +++ b/test/ref/DCP/dcp_test7/pkl_d199d58b-5ef8-4d49-b270-07e590ccb280.xml @@ -12,6 +12,7 @@ Vsre14v3AhK6X2gUzeYF9G8GKo0= 1965 text/xml;asdcpKind=CPL + cpl_6affb8ee-0020-4dff-a53c-17652f6358ab.xml urn:uuid:5407b210-4441-4e97-8b16-8bdc7c12da54 @@ -19,6 +20,7 @@ wUmt8G+cFFKMGt0ueS9+F1S4uhc= 49240 application/x-smpte-mxf;asdcpKind=Picture + video.mxf urn:uuid:97f0f352-5b77-48ee-a558-9df37717f4fa @@ -26,6 +28,7 @@ KcJb7S2K5cNm8RG4kfQD5FTeS0A= 881326 application/x-smpte-mxf;asdcpKind=Sound + audio.mxf diff --git a/test/ref/DCP/encryption_test/ASSETMAP.xml b/test/ref/DCP/encryption_test/ASSETMAP.xml index cf6c74f5..902833dc 100644 --- a/test/ref/DCP/encryption_test/ASSETMAP.xml +++ b/test/ref/DCP/encryption_test/ASSETMAP.xml @@ -15,7 +15,7 @@ pkl_93887017-5d6a-4ee5-b5f4-161b06281d0e.xml 1 0 - 8708 + 8902 diff --git a/test/ref/DCP/encryption_test/pkl_93887017-5d6a-4ee5-b5f4-161b06281d0e.xml b/test/ref/DCP/encryption_test/pkl_93887017-5d6a-4ee5-b5f4-161b06281d0e.xml index 57421adc..db5b78f2 100644 --- a/test/ref/DCP/encryption_test/pkl_93887017-5d6a-4ee5-b5f4-161b06281d0e.xml +++ b/test/ref/DCP/encryption_test/pkl_93887017-5d6a-4ee5-b5f4-161b06281d0e.xml @@ -12,6 +12,7 @@ ocIgRDFtEn7QPxwcqXYVpSrTPpI= 9226 text/xml + cpl_6affb8ee-0020-4dff-a53c-17652f6358ab.xml urn:uuid:9a7fbb03-4078-4944-90b1-0d8a21c9d793 @@ -19,6 +20,7 @@ AVtX8wz76uG2Uw0Qbc9+DKnHUfw= 44008 application/mxf + video.mxf urn:uuid:ce300880-a425-40a6-adac-eb1e3f5643fc @@ -26,6 +28,7 @@ lS+FKcwLD7cRjgZMQ+hvGg/yJIc= 165454 application/mxf + audio.mxf @@ -46,15 +49,15 @@ - Gxo6VfxF8Guiq1+IFU2ePslEu00= + G6rpYhOo/0ZdBo+SI3UzyPQA/F0= - bzUioGIym79+2SaZ+V3zHOnZzoYR2L3NcW0yrre+FclIO2BB6XjdPnJJJPEHml9R -ATXtAOUIjYUZT5x+2B64dpclvIdikr4P72J6PQzHB+lvnrptoisOhFMa0Pnk1vCi -0o/WBHUCSDePU8Hl8OGK9GL+n/iXEZKfbpuAIRBIGayD1WE1CmTxGxVx28VTk+2H -klIbYhojVoj0AaaVN9xVvaq126Tmk4y1dILyPlNyYYVxzam7T1hlEHSj3E4i3StZ -r1vsK8I8EMWLrBio3ih44GwkJeM6N7PPI5kDeen7Mk7S4Btq+HtildekSmKRNkOc -odAqTC/SVvYtWvri7PldJQ== + tdapJHKPEmEa552oOg9s3/Q4TcnzIiNfd3U+xiSG5XGl+7K0n6JKbpNVgm4KpE0l +a7bVsu4Yp0ftCrcjxxczZ/puS7nVC/zcfk63miZcJKdXem0xt0AZJHEguwQq74Tc +48Efe1/MtIBCOtQErh2kcDVwXOUo6Nz0yW1g5PRQ5u9KlqQ67RLqDWRdX1OkWIUZ +Z2Iz2nSnTP4GDDHs5pX6xxZKNlgZIa5iYMBp97X1DGlGaQ2o/sbcUysE4g4oO+iU +cfRdkI68vj53hHWApxVGoAPAl4t8B6kMbLQAp1w4R/4ruLR9FKTffqRlUjOXtyiT +pQVNxwCU50/opyfv8v2v6w== diff --git a/test/ref/write_interop_subtitle_test3/ASSETMAP b/test/ref/write_interop_subtitle_test3/ASSETMAP index 8dfb256d..1fd41e81 100644 --- a/test/ref/write_interop_subtitle_test3/ASSETMAP +++ b/test/ref/write_interop_subtitle_test3/ASSETMAP @@ -15,7 +15,7 @@ pkl_ac8d301c-e5d9-4343-b6f3-ba2668adbe56.xml 1 0 - 1114 + 1326 diff --git a/test/ref/write_interop_subtitle_test3/pkl_ac8d301c-e5d9-4343-b6f3-ba2668adbe56.xml b/test/ref/write_interop_subtitle_test3/pkl_ac8d301c-e5d9-4343-b6f3-ba2668adbe56.xml index 362177c7..ae7644af 100644 --- a/test/ref/write_interop_subtitle_test3/pkl_ac8d301c-e5d9-4343-b6f3-ba2668adbe56.xml +++ b/test/ref/write_interop_subtitle_test3/pkl_ac8d301c-e5d9-4343-b6f3-ba2668adbe56.xml @@ -12,6 +12,7 @@ M9U2kzcnfcBAy7MrXZGKjA8hQRU= 1061 text/xml;asdcpKind=CPL + cpl_5407b210-4441-4e97-8b16-8bdc7c12da54.xml urn:uuid:a6c58cff-3e1e-4b38-acec-a42224475ef6 @@ -19,12 +20,14 @@ RmflhDu9QYUsNnBftdNlIEGdzG0= 438 text/xml;asdcpKind=Subtitle + subs.xml urn:uuid:dd015243-ab77-435c-a13d-690566885121 2vTylSKQ5MCQHbKPT4X+rlwfHk4= 44861 image/png + write_interop_subtitle_test3 diff --git a/test/verify_test.cc b/test/verify_test.cc index 1122f73b..d1319810 100644 --- a/test/verify_test.cc +++ b/test/verify_test.cc @@ -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 }, }); } -- cgit v1.2.3