From 3c8e87575da3795aa31ed9653da72abb8ed88996 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sat, 21 Sep 2024 23:04:32 +0200 Subject: Remove unused references to boost::signals2. --- src/dcp.h | 1 - src/mono_picture_asset.cc | 1 + src/mxf.h | 1 - 3 files changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/dcp.h b/src/dcp.h index 21cc3aac..9f4c93de 100644 --- a/src/dcp.h +++ b/src/dcp.h @@ -49,7 +49,6 @@ #include "util.h" #include "verify.h" #include "version.h" -#include #include #include #include diff --git a/src/mono_picture_asset.cc b/src/mono_picture_asset.cc index a72fd7d4..5670591a 100644 --- a/src/mono_picture_asset.cc +++ b/src/mono_picture_asset.cc @@ -48,6 +48,7 @@ #include "mono_picture_frame.h" #include #include +#include using std::dynamic_pointer_cast; diff --git a/src/mxf.h b/src/mxf.h index 19d4a956..2e97afd7 100644 --- a/src/mxf.h +++ b/src/mxf.h @@ -45,7 +45,6 @@ #include "key.h" #include "metadata.h" #include "dcp_assert.h" -#include namespace ASDCP { -- cgit v1.2.3 From 6d1a7e90ec3244b8e532e03c5209d5e8448f422e Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sat, 21 Sep 2024 23:06:34 +0200 Subject: Remove unused change_extension(). It was added "for completeness" apparently but it would now cause complications in keeping it compatible with various boost versions, so just remove it as YAGNI. --- src/filesystem.cc | 8 -------- src/filesystem.h | 1 - 2 files changed, 9 deletions(-) (limited to 'src') diff --git a/src/filesystem.cc b/src/filesystem.cc index 428bb029..83c55ab0 100644 --- a/src/filesystem.cc +++ b/src/filesystem.cc @@ -293,14 +293,6 @@ dcp::filesystem::rename(boost::filesystem::path const& old_path, boost::filesyst } -/* We don't really need this but let's add it for completeness */ -boost::filesystem::path -dcp::filesystem::change_extension(boost::filesystem::path const& path, std::string const& new_extension) -{ - return boost::filesystem::change_extension(path, new_extension); -} - - #ifdef DCPOMATIC_WINDOWS dcp::filesystem::directory_iterator::directory_iterator(boost::filesystem::path const& path) diff --git a/src/filesystem.h b/src/filesystem.h index 53ec209d..30da1c3b 100644 --- a/src/filesystem.h +++ b/src/filesystem.h @@ -47,7 +47,6 @@ namespace filesystem boost::filesystem::path absolute(boost::filesystem::path const& path); boost::filesystem::path canonical(boost::filesystem::path const& path); boost::filesystem::path weakly_canonical(boost::filesystem::path const& path); -boost::filesystem::path change_extension(boost::filesystem::path const& from, std::string const& new_extension); void copy(boost::filesystem::path const& from, boost::filesystem::path const& to); void copy_file(boost::filesystem::path const& from, boost::filesystem::path const& to); void copy_file(boost::filesystem::path const& from, boost::filesystem::path const& to, boost::system::error_code& ec); -- cgit v1.2.3 From 6fba38bd59450e167e664153a31f41e97a500ffc Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sat, 21 Sep 2024 23:06:58 +0200 Subject: Support new boost versions (DoM #2867). --- src/filesystem.cc | 6 +++++- src/filesystem.h | 4 ++++ wscript | 9 +++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/filesystem.cc b/src/filesystem.cc index 83c55ab0..bdd15039 100644 --- a/src/filesystem.cc +++ b/src/filesystem.cc @@ -107,7 +107,11 @@ dcp::filesystem::copy_file(boost::filesystem::path const& from, boost::filesyste void +#ifdef LIBDCP_HAVE_COPY_OPTIONS +dcp::filesystem::copy_file(boost::filesystem::path const& from, boost::filesystem::path const& to, boost::filesystem::copy_options option) +#else dcp::filesystem::copy_file(boost::filesystem::path const& from, boost::filesystem::path const& to, boost::filesystem::copy_option option) +#endif { boost::filesystem::copy_file(dcp::filesystem::fix_long_path(from), dcp::filesystem::fix_long_path(to), option); } @@ -247,7 +251,7 @@ dcp::filesystem::create_symlink(boost::filesystem::path const& from, boost::file std::string dcp::filesystem::extension(boost::filesystem::path const& path) { - return boost::filesystem::extension(dcp::filesystem::fix_long_path(path)); + return dcp::filesystem::fix_long_path(path).extension().string(); } diff --git a/src/filesystem.h b/src/filesystem.h index 30da1c3b..1d434200 100644 --- a/src/filesystem.h +++ b/src/filesystem.h @@ -50,7 +50,11 @@ boost::filesystem::path weakly_canonical(boost::filesystem::path const& path); void copy(boost::filesystem::path const& from, boost::filesystem::path const& to); void copy_file(boost::filesystem::path const& from, boost::filesystem::path const& to); void copy_file(boost::filesystem::path const& from, boost::filesystem::path const& to, boost::system::error_code& ec); +#ifdef LIBDCP_HAVE_COPY_OPTIONS +void copy_file(boost::filesystem::path const& from, boost::filesystem::path const& to, boost::filesystem::copy_options ec); +#else void copy_file(boost::filesystem::path const& from, boost::filesystem::path const& to, boost::filesystem::copy_option ec); +#endif bool create_directory(boost::filesystem::path const& path); bool create_directory(boost::filesystem::path const& path, boost::system::error_code& ec); bool create_directories(boost::filesystem::path const& path); diff --git a/wscript b/wscript index 76fc166c..77cfa11f 100644 --- a/wscript +++ b/wscript @@ -227,6 +227,15 @@ def configure(conf): uselib='BOOST_FILESYSTEM', define_name='LIBDCP_HAVE_WEAKLY_CANONICAL') + conf.check_cxx(fragment=""" + #include \n + int main() { auto x = boost::filesystem::copy_options(); }\n + """, + mandatory=False, + msg='Checking for boost::filesystem::copy_options', + uselib='BOOST_FILESYSTEM', + define_name='LIBDCP_HAVE_COPY_OPTIONS') + conf.check_cxx(fragment=""" #include \n int main() { boost::gregorian::day_clock::local_day(); }\n -- cgit v1.2.3 From d82e972701165517517788b8b51eb089419a20cb Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 23 Sep 2024 20:49:33 +0200 Subject: Revert "Remove unused change_extension()." This reverts commit 6d1a7e90ec3244b8e532e03c5209d5e8448f422e. It is used in DCP-o-matic, contrary to the comment. --- src/filesystem.cc | 8 ++++++++ src/filesystem.h | 1 + 2 files changed, 9 insertions(+) (limited to 'src') diff --git a/src/filesystem.cc b/src/filesystem.cc index bdd15039..cb38ddfe 100644 --- a/src/filesystem.cc +++ b/src/filesystem.cc @@ -297,6 +297,14 @@ dcp::filesystem::rename(boost::filesystem::path const& old_path, boost::filesyst } +/* We don't really need this but let's add it for completeness */ +boost::filesystem::path +dcp::filesystem::change_extension(boost::filesystem::path const& path, std::string const& new_extension) +{ + return boost::filesystem::change_extension(path, new_extension); +} + + #ifdef DCPOMATIC_WINDOWS dcp::filesystem::directory_iterator::directory_iterator(boost::filesystem::path const& path) diff --git a/src/filesystem.h b/src/filesystem.h index 1d434200..679be1f9 100644 --- a/src/filesystem.h +++ b/src/filesystem.h @@ -47,6 +47,7 @@ namespace filesystem boost::filesystem::path absolute(boost::filesystem::path const& path); boost::filesystem::path canonical(boost::filesystem::path const& path); boost::filesystem::path weakly_canonical(boost::filesystem::path const& path); +boost::filesystem::path change_extension(boost::filesystem::path const& from, std::string const& new_extension); void copy(boost::filesystem::path const& from, boost::filesystem::path const& to); void copy_file(boost::filesystem::path const& from, boost::filesystem::path const& to); void copy_file(boost::filesystem::path const& from, boost::filesystem::path const& to, boost::system::error_code& ec); -- cgit v1.2.3 From 466a21fbf04f9b5ee1bcddc0f9cee6c454799006 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 23 Sep 2024 21:13:57 +0200 Subject: Another fix for new boost. --- src/filesystem.cc | 6 ++++++ wscript | 9 +++++++++ 2 files changed, 15 insertions(+) (limited to 'src') diff --git a/src/filesystem.cc b/src/filesystem.cc index cb38ddfe..98c3d1b7 100644 --- a/src/filesystem.cc +++ b/src/filesystem.cc @@ -301,7 +301,13 @@ dcp::filesystem::rename(boost::filesystem::path const& old_path, boost::filesyst boost::filesystem::path dcp::filesystem::change_extension(boost::filesystem::path const& path, std::string const& new_extension) { +#ifdef LIBDCP_HAVE_REPLACE_EXTENSION + auto copy = path; + copy.replace_extension(new_extension); + return copy; +#else return boost::filesystem::change_extension(path, new_extension); +#endif } diff --git a/wscript b/wscript index 77cfa11f..a45a72a4 100644 --- a/wscript +++ b/wscript @@ -236,6 +236,15 @@ def configure(conf): uselib='BOOST_FILESYSTEM', define_name='LIBDCP_HAVE_COPY_OPTIONS') + conf.check_cxx(fragment=""" + #include \n + int main() { boost::filesystem::path y = "foo"; y.replace_extension("bar"); }\n + """, + mandatory=False, + msg='Checking for boost::filesystem::replace_extension', + uselib='BOOST_FILESYSTEM', + define_name='LIBDCP_HAVE_REPLACE_EXTENSION') + conf.check_cxx(fragment=""" #include \n int main() { boost::gregorian::day_clock::local_day(); }\n -- cgit v1.2.3 From adae04e0984d294aa9a95394bfed584ce7e93469 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 23 Sep 2024 23:12:41 +0200 Subject: Fix the boost copy_option{,s} change a different way. The previous solution required the correct define to be present when including libdcp, which seems a bit awkward. --- src/filesystem.cc | 10 ++++++---- src/filesystem.h | 13 ++++++++----- 2 files changed, 14 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/filesystem.cc b/src/filesystem.cc index 98c3d1b7..4cbbc3d4 100644 --- a/src/filesystem.cc +++ b/src/filesystem.cc @@ -107,13 +107,15 @@ dcp::filesystem::copy_file(boost::filesystem::path const& from, boost::filesyste void +dcp::filesystem::copy_file(boost::filesystem::path const& from, boost::filesystem::path const& to, CopyOptions option) +{ #ifdef LIBDCP_HAVE_COPY_OPTIONS -dcp::filesystem::copy_file(boost::filesystem::path const& from, boost::filesystem::path const& to, boost::filesystem::copy_options option) + auto const options = option == CopyOptions::OVERWRITE_EXISTING ? boost::filesystem::copy_options::overwrite_existing : boost::filesystem::copy_options::none; #else -dcp::filesystem::copy_file(boost::filesystem::path const& from, boost::filesystem::path const& to, boost::filesystem::copy_option option) + auto const options = option == CopyOptions::OVERWRITE_EXISTING ? boost::filesystem::copy_option::overwrite_if_exists : boost::filesystem::copy_option::none; #endif -{ - boost::filesystem::copy_file(dcp::filesystem::fix_long_path(from), dcp::filesystem::fix_long_path(to), option); + + boost::filesystem::copy_file(dcp::filesystem::fix_long_path(from), dcp::filesystem::fix_long_path(to), options); } diff --git a/src/filesystem.h b/src/filesystem.h index 679be1f9..a06dc69e 100644 --- a/src/filesystem.h +++ b/src/filesystem.h @@ -51,11 +51,14 @@ boost::filesystem::path change_extension(boost::filesystem::path const& from, st void copy(boost::filesystem::path const& from, boost::filesystem::path const& to); void copy_file(boost::filesystem::path const& from, boost::filesystem::path const& to); void copy_file(boost::filesystem::path const& from, boost::filesystem::path const& to, boost::system::error_code& ec); -#ifdef LIBDCP_HAVE_COPY_OPTIONS -void copy_file(boost::filesystem::path const& from, boost::filesystem::path const& to, boost::filesystem::copy_options ec); -#else -void copy_file(boost::filesystem::path const& from, boost::filesystem::path const& to, boost::filesystem::copy_option ec); -#endif + +enum class CopyOptions +{ + NONE, + OVERWRITE_EXISTING +}; + +void copy_file(boost::filesystem::path const& from, boost::filesystem::path const& to, CopyOptions options); bool create_directory(boost::filesystem::path const& path); bool create_directory(boost::filesystem::path const& path, boost::system::error_code& ec); bool create_directories(boost::filesystem::path const& path); -- cgit v1.2.3 From 152266f6e65451a03521eb04b6a406b6e309e17a Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 23 Sep 2024 23:42:58 +0200 Subject: Allow but give an error when seeing a strange PKL namespace. DoM bug #2868 reports that Resolve made a DCP with the PKL namespace http://www.smpte-ra.org/schemas/2067-2/2016/PKL This seems wrong (google suggests that this is the namespace for IMF PKLs) but let's accept it and log an error instead of throwing an exception. --- src/dcp.cc | 2 +- src/pkl.cc | 18 +++++++++++++++++- src/pkl.h | 5 ++++- src/verify.cc | 2 ++ src/verify.h | 7 ++++++- 5 files changed, 30 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/dcp.cc b/src/dcp.cc index eb21b47d..af15081b 100644 --- a/src/dcp.cc +++ b/src/dcp.cc @@ -158,7 +158,7 @@ DCP::read (vector* notes, bool ignore_incorrect_picture_m } for (auto i: pkl_paths) { - _pkls.push_back(make_shared(i)); + _pkls.push_back(make_shared(i, notes)); } /* Now we have: diff --git a/src/pkl.cc b/src/pkl.cc index 57eda9da..1684ea5f 100644 --- a/src/pkl.cc +++ b/src/pkl.cc @@ -44,6 +44,7 @@ #include "raw_convert.h" #include "util.h" #include "warnings.h" +#include "verify.h" LIBDCP_DISABLE_WARNINGS #include LIBDCP_ENABLE_WARNINGS @@ -53,15 +54,18 @@ LIBDCP_ENABLE_WARNINGS using std::string; using std::shared_ptr; using std::make_shared; +using std::vector; using boost::optional; using namespace dcp; static string const pkl_interop_ns = "http://www.digicine.com/PROTO-ASDCP-PKL-20040311#"; static string const pkl_smpte_ns = "http://www.smpte-ra.org/schemas/429-8/2007/PKL"; +/* I don't know why Resolve are using this namespace but apparently they are */ +static string const pkl_resolve_smpte_ns = "http://www.smpte-ra.org/schemas/2067-2/2016/PKL"; -PKL::PKL (boost::filesystem::path file) +PKL::PKL(boost::filesystem::path file, vector* notes) : _file (file) { cxml::Document pkl ("PackingList"); @@ -71,6 +75,18 @@ PKL::PKL (boost::filesystem::path file) _standard = Standard::INTEROP; } else if (pkl.namespace_uri() == pkl_smpte_ns) { _standard = Standard::SMPTE; + } else if (pkl.namespace_uri() == pkl_resolve_smpte_ns) { + _standard = Standard::SMPTE; + if (notes) { + notes->push_back( + dcp::VerificationNote( + dcp::VerificationNote::Type::ERROR, + dcp::VerificationNote::Code::INVALID_PKL_NAMESPACE, + pkl.namespace_uri(), + file + ) + ); + } } else { boost::throw_exception(XMLError("Unrecognised packing list namespace " + pkl.namespace_uri())); } diff --git a/src/pkl.h b/src/pkl.h index d0a11188..e514095b 100644 --- a/src/pkl.h +++ b/src/pkl.h @@ -52,6 +52,9 @@ namespace dcp { +class VerificationNote; + + class PKL : public Object, public AssetList { public: @@ -59,7 +62,7 @@ public: : AssetList(standard, annotation_text, issue_date, issuer, creator) {} - explicit PKL (boost::filesystem::path file); + explicit PKL(boost::filesystem::path file, std::vector* notes = nullptr); boost::optional hash (std::string id) const; boost::optional type (std::string id) const; diff --git a/src/verify.cc b/src/verify.cc index ec8925f2..e5d2511d 100644 --- a/src/verify.cc +++ b/src/verify.cc @@ -2183,6 +2183,8 @@ dcp::note_to_string (VerificationNote note) return String::compose("The namespace %1 in CPL %2 is invalid", note.note().get(), note.file()->filename()); case VerificationNote::Code::MISSING_CPL_CONTENT_VERSION: return String::compose("The CPL %1 has no tag", note.note().get()); + case VerificationNote::Code::INVALID_PKL_NAMESPACE: + return String::compose("The namespace %1 in PKL %2 is invalid", note.note().get(), note.file()->filename()); } return ""; diff --git a/src/verify.h b/src/verify.h index 204d83b0..218d2ceb 100644 --- a/src/verify.h +++ b/src/verify.h @@ -487,7 +487,12 @@ public: * note contains the CPL ID * file contains the CPL filename */ - MISSING_CPL_CONTENT_VERSION + MISSING_CPL_CONTENT_VERSION, + /** The PKL namespace is not valid. + * note contains the invalid namespace + * file contains the PKL filename + */ + INVALID_PKL_NAMESPACE }; VerificationNote (Type type, Code code) -- cgit v1.2.3