From 93439dbc6d93dafd88e80d51d6473c8d97aa02c7 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 28 May 2014 23:25:11 +0100 Subject: Modify KDM generation to work with CPLs rather than DCPs, and allow user to specify a particular CPL to use. Tidy up the KDM dialog a bit. --- src/lib/film.cc | 28 +++++++++++----------------- src/lib/film.h | 6 +++--- src/lib/kdm.cc | 20 ++++++++++---------- src/lib/kdm.h | 6 +++--- src/lib/types.h | 15 +++++++++++++++ 5 files changed, 42 insertions(+), 33 deletions(-) (limited to 'src/lib') diff --git a/src/lib/film.cc b/src/lib/film.cc index 5fde0447a..1b5b2b366 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -766,11 +766,11 @@ Film::j2c_path (int f, Eyes e, bool t) const return file (p); } -/** @return List of subdirectories (not full paths) containing DCPs that can be successfully libdcp::DCP::read() */ -list -Film::dcps () const +/** Find all the DCPs in our directory that can be libdcp::DCP::read() and return details of their CPLs */ +vector +Film::cpls () const { - list out; + vector out; boost::filesystem::path const dir = directory (); for (boost::filesystem::directory_iterator i = boost::filesystem::directory_iterator(dir); i != boost::filesystem::directory_iterator(); ++i) { @@ -782,7 +782,11 @@ Film::dcps () const try { libdcp::DCP dcp (*i); dcp.read (); - out.push_back (i->path().leaf ()); + out.push_back ( + CPLSummary ( + i->path().leaf().string(), dcp.cpls().front()->id(), dcp.cpls().front()->name(), dcp.cpls().front()->filename() + ) + ); } catch (...) { } @@ -982,28 +986,18 @@ Film::frame_size () const libdcp::KDM Film::make_kdm ( shared_ptr target, - boost::filesystem::path dcp_dir, + boost::filesystem::path cpl_file, boost::posix_time::ptime from, boost::posix_time::ptime until ) const { shared_ptr signer = make_signer (); - libdcp::DCP dcp (dir (dcp_dir.string ())); - - try { - dcp.read (); - } catch (...) { - throw KDMError (_("Could not read DCP to make KDM for")); - } - time_t now = time (0); struct tm* tm = localtime (&now); string const issue_date = libdcp::tm_to_string (tm); - dcp.cpls().front()->set_mxf_keys (key ()); - - return libdcp::KDM (dcp.cpls().front(), signer, target, from, until, "DCP-o-matic", issue_date); + return libdcp::KDM (cpl_file, signer, target, key (), from, until, "DCP-o-matic", issue_date); } list diff --git a/src/lib/film.h b/src/lib/film.h index 162b67b35..06c770efa 100644 --- a/src/lib/film.h +++ b/src/lib/film.h @@ -98,7 +98,7 @@ public: libdcp::Size full_frame () const; libdcp::Size frame_size () const; - std::list dcps () const; + std::vector cpls () const; boost::shared_ptr make_player () const; boost::shared_ptr playlist () const; @@ -123,14 +123,14 @@ public: libdcp::KDM make_kdm ( boost::shared_ptr target, - boost::filesystem::path dcp, + boost::filesystem::path cpl_file, boost::posix_time::ptime from, boost::posix_time::ptime until ) const; std::list make_kdms ( std::list >, - boost::filesystem::path dcp, + boost::filesystem::path cpl_file, boost::posix_time::ptime from, boost::posix_time::ptime until ) const; diff --git a/src/lib/kdm.cc b/src/lib/kdm.cc index 2a8e191e7..d5d5ec0a0 100644 --- a/src/lib/kdm.cc +++ b/src/lib/kdm.cc @@ -102,12 +102,12 @@ static list make_screen_kdms ( shared_ptr film, list > screens, - boost::filesystem::path dcp, + boost::filesystem::path cpl, boost::posix_time::ptime from, boost::posix_time::ptime to ) { - list kdms = film->make_kdms (screens, dcp, from, to); + list kdms = film->make_kdms (screens, cpl, from, to); list screen_kdms; @@ -126,12 +126,12 @@ static list make_cinema_kdms ( shared_ptr film, list > screens, - boost::filesystem::path dcp, + boost::filesystem::path cpl, boost::posix_time::ptime from, boost::posix_time::ptime to ) { - list screen_kdms = make_screen_kdms (film, screens, dcp, from, to); + list screen_kdms = make_screen_kdms (film, screens, cpl, from, to); list cinema_kdms; while (!screen_kdms.empty ()) { @@ -171,13 +171,13 @@ void write_kdm_files ( shared_ptr film, list > screens, - boost::filesystem::path dcp, + boost::filesystem::path cpl, boost::posix_time::ptime from, boost::posix_time::ptime to, boost::filesystem::path directory ) { - list screen_kdms = make_screen_kdms (film, screens, dcp, from, to); + list screen_kdms = make_screen_kdms (film, screens, cpl, from, to); /* Write KDMs to the specified directory */ for (list::iterator i = screen_kdms.begin(); i != screen_kdms.end(); ++i) { @@ -191,13 +191,13 @@ void write_kdm_zip_files ( shared_ptr film, list > screens, - boost::filesystem::path dcp, + boost::filesystem::path cpl, boost::posix_time::ptime from, boost::posix_time::ptime to, boost::filesystem::path directory ) { - list cinema_kdms = make_cinema_kdms (film, screens, dcp, from, to); + list cinema_kdms = make_cinema_kdms (film, screens, cpl, from, to); for (list::const_iterator i = cinema_kdms.begin(); i != cinema_kdms.end(); ++i) { boost::filesystem::path path = directory; @@ -210,12 +210,12 @@ void email_kdms ( shared_ptr film, list > screens, - boost::filesystem::path dcp, + boost::filesystem::path cpl, boost::posix_time::ptime from, boost::posix_time::ptime to ) { - list cinema_kdms = make_cinema_kdms (film, screens, dcp, from, to); + list cinema_kdms = make_cinema_kdms (film, screens, cpl, from, to); for (list::const_iterator i = cinema_kdms.begin(); i != cinema_kdms.end(); ++i) { diff --git a/src/lib/kdm.h b/src/lib/kdm.h index c4fd43d49..8aacd7b72 100644 --- a/src/lib/kdm.h +++ b/src/lib/kdm.h @@ -26,7 +26,7 @@ class Film; extern void write_kdm_files ( boost::shared_ptr film, std::list > screens, - boost::filesystem::path dcp, + boost::filesystem::path cpl, boost::posix_time::ptime from, boost::posix_time::ptime to, boost::filesystem::path directory @@ -35,7 +35,7 @@ extern void write_kdm_files ( extern void write_kdm_zip_files ( boost::shared_ptr film, std::list > screens, - boost::filesystem::path dcp, + boost::filesystem::path cpl, boost::posix_time::ptime from, boost::posix_time::ptime to, boost::filesystem::path directory @@ -44,7 +44,7 @@ extern void write_kdm_zip_files ( extern void email_kdms ( boost::shared_ptr film, std::list > screens, - boost::filesystem::path dcp, + boost::filesystem::path cpl, boost::posix_time::ptime from, boost::posix_time::ptime to ); diff --git a/src/lib/types.h b/src/lib/types.h index 3fab302fc..4eb3d927e 100644 --- a/src/lib/types.h +++ b/src/lib/types.h @@ -138,6 +138,21 @@ struct Crop void as_xml (xmlpp::Node *) const; }; +struct CPLSummary +{ + CPLSummary (std::string d, std::string i, std::string a, boost::filesystem::path f) + : dcp_directory (d) + , cpl_id (i) + , cpl_annotation_text (a) + , cpl_file (f) + {} + + std::string dcp_directory; + std::string cpl_id; + std::string cpl_annotation_text; + boost::filesystem::path cpl_file; +}; + extern bool operator== (Crop const & a, Crop const & b); extern bool operator!= (Crop const & a, Crop const & b); -- cgit v1.2.3