X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Ffilm.cc;h=48677ba613848f419864efe0e4307a6842c5bea9;hb=fad726e94700bccdae0d301d54cdb1eab51cc71f;hp=012495226656d5920258d80a27641c01e405171d;hpb=0b45af42b5a30c3a71d2e1de491843d125e46793;p=dcpomatic.git diff --git a/src/lib/film.cc b/src/lib/film.cc index 012495226..48677ba61 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -29,6 +29,10 @@ #include #include #include +#include +#include +#include +#include "cinema.h" #include "film.h" #include "format.h" #include "job.h" @@ -1388,12 +1392,66 @@ Film::audio_stream () const void Film::make_kdms ( - list >, + list > screens, boost::posix_time::ptime from, boost::posix_time::ptime until, string directory ) const { - + string const cd = Config::instance()->crypt_chain_directory (); + if (boost::filesystem::is_empty (cd)) { + libdcp::make_crypt_chain (cd); + } + + libdcp::CertificateChain chain; + + { + boost::filesystem::path p (cd); + p /= "ca.self-signed.pem"; + chain.add (shared_ptr (new libdcp::Certificate (p.string ()))); + } + + { + boost::filesystem::path p (cd); + p /= "intermediate.signed.pem"; + chain.add (shared_ptr (new libdcp::Certificate (p.string ()))); + } + + { + boost::filesystem::path p (cd); + p /= "leaf.signed.pem"; + chain.add (shared_ptr (new libdcp::Certificate (p.string ()))); + } + + boost::filesystem::path signer_key (cd); + signer_key /= "leaf.key"; + + /* Find the DCP to make the KDM for */ + string const dir = this->directory (); + list dcps; + for (boost::filesystem::directory_iterator i = boost::filesystem::directory_iterator(dir); i != boost::filesystem::directory_iterator(); ++i) { + if (boost::filesystem::is_directory (*i) && i->path().leaf() != "j2c" && i->path().leaf() != "wavs") { + dcps.push_back (i->path().string()); + } + } + + if (dcps.empty()) { + throw KDMError ("Could not find DCP to make KDM for"); + } else if (dcps.size() > 1) { + throw KDMError ("More than one possible DCP to make KDM for"); + } + + for (list >::iterator i = screens.begin(); i != screens.end(); ++i) { + + libdcp::DCP dcp (dcps.front ()); + dcp.read (); + + /* XXX: single CPL only */ + shared_ptr kdm = dcp.cpls().front()->make_kdm (chain, signer_key.string(), (*i)->certificate, from, until); + + boost::filesystem::path out = directory; + out /= "kdm.xml"; + kdm->write_to_file_formatted (out.string()); + } }