diff options
| author | Carl Hetherington <cth@carlh.net> | 2013-10-03 18:04:31 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2013-10-03 18:04:31 +0100 |
| commit | 568e553f506809e753c78a0e0cbad5906bc002b1 (patch) | |
| tree | 4cd234309105ce1f9fc571148d984100738826e7 /src/lib | |
| parent | c869563a1414c869ac15f8d590217a45c7739996 (diff) | |
KDM / libdcp API changes.
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/film.cc | 77 | ||||
| -rw-r--r-- | src/lib/film.h | 7 | ||||
| -rw-r--r-- | src/lib/util.cc | 37 | ||||
| -rw-r--r-- | src/lib/util.h | 5 | ||||
| -rw-r--r-- | src/lib/writer.cc | 45 |
5 files changed, 92 insertions, 79 deletions
diff --git a/src/lib/film.cc b/src/lib/film.cc index 8252b492c..bceaef96e 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -895,42 +895,14 @@ Film::full_frame () const return libdcp::Size (); } -list<libdcp::KDM> -Film::make_kdms ( - list<shared_ptr<Screen> > screens, +libdcp::KDM +Film::make_kdm ( + shared_ptr<libdcp::Certificate> target, boost::posix_time::ptime from, boost::posix_time::ptime until ) const { - boost::filesystem::path const sd = Config::instance()->signer_chain_directory (); - if (boost::filesystem::is_empty (sd)) { - libdcp::make_signer_chain (sd); - } - - libdcp::CertificateChain chain; - - { - boost::filesystem::path p (sd); - p /= "ca.self-signed.pem"; - chain.add (shared_ptr<libdcp::Certificate> (new libdcp::Certificate (p))); - } - - { - boost::filesystem::path p (sd); - p /= "intermediate.signed.pem"; - chain.add (shared_ptr<libdcp::Certificate> (new libdcp::Certificate (p))); - } - - { - boost::filesystem::path p (sd); - p /= "leaf.signed.pem"; - chain.add (shared_ptr<libdcp::Certificate> (new libdcp::Certificate (p))); - } - - boost::filesystem::path signer_key (sd); - signer_key /= "leaf.key"; - - shared_ptr<const Signer> signer (new Signer (chain, signer_key)); + shared_ptr<const Signer> signer = make_signer (); /* Find the DCP to make the KDM for */ string const dir = this->directory (); @@ -947,25 +919,34 @@ Film::make_kdms ( throw KDMError (_("More than one possible DCP to make KDM for")); } + libdcp::DCP dcp (dcps.front ()); + + 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); +} + +list<libdcp::KDM> +Film::make_kdms ( + list<shared_ptr<Screen> > screens, + boost::posix_time::ptime from, + boost::posix_time::ptime until + ) const +{ list<libdcp::KDM> kdms; for (list<shared_ptr<Screen> >::iterator i = screens.begin(); i != screens.end(); ++i) { - - libdcp::DCP dcp (dcps.front ()); - - 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 ()); - - kdms.push_back (libdcp::KDM (dcp.cpls().front(), signer, (*i)->certificate, from, until, "DCP-o-matic", issue_date)); + kdms.push_back (make_kdm ((*i)->certificate, from, until)); } return kdms; diff --git a/src/lib/film.h b/src/lib/film.h index a30a630b9..01fccf7d1 100644 --- a/src/lib/film.h +++ b/src/lib/film.h @@ -116,6 +116,13 @@ public: bool has_subtitles () const; OutputVideoFrame best_video_frame_rate () const; + libdcp::KDM + make_kdm ( + boost::shared_ptr<libdcp::Certificate> target, + boost::posix_time::ptime from, + boost::posix_time::ptime until + ) const; + std::list<libdcp::KDM> make_kdms ( std::list<boost::shared_ptr<Screen> >, boost::posix_time::ptime from, diff --git a/src/lib/util.cc b/src/lib/util.cc index 6746b4773..ae3de2d6b 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -46,6 +46,8 @@ #include <magick/version.h> #include <libdcp/version.h> #include <libdcp/util.h> +#include <libdcp/signer_chain.h> +#include <libdcp/signer.h> extern "C" { #include <libavcodec/avcodec.h> #include <libavformat/avformat.h> @@ -816,3 +818,38 @@ tidy_for_filename (string f) return t; } + +shared_ptr<const libdcp::Signer> +make_signer () +{ + boost::filesystem::path const sd = Config::instance()->signer_chain_directory (); + if (boost::filesystem::is_empty (sd)) { + libdcp::make_signer_chain (sd); + } + + libdcp::CertificateChain chain; + + { + boost::filesystem::path p (sd); + p /= "ca.self-signed.pem"; + chain.add (shared_ptr<libdcp::Certificate> (new libdcp::Certificate (p))); + } + + { + boost::filesystem::path p (sd); + p /= "intermediate.signed.pem"; + chain.add (shared_ptr<libdcp::Certificate> (new libdcp::Certificate (p))); + } + + { + boost::filesystem::path p (sd); + p /= "leaf.signed.pem"; + chain.add (shared_ptr<libdcp::Certificate> (new libdcp::Certificate (p))); + } + + boost::filesystem::path signer_key (sd); + signer_key /= "leaf.key"; + + return shared_ptr<const libdcp::Signer> (new libdcp::Signer (chain, signer_key)); +} + diff --git a/src/lib/util.h b/src/lib/util.h index b5c94d994..377b3b785 100644 --- a/src/lib/util.h +++ b/src/lib/util.h @@ -51,6 +51,10 @@ extern "C" { /** The maximum number of audio channels that we can cope with */ #define MAX_AUDIO_CHANNELS 6 +namespace libdcp { + class Signer; +} + class Job; extern std::string seconds_to_hms (int); @@ -71,6 +75,7 @@ extern bool valid_image_file (boost::filesystem::path); extern boost::filesystem::path mo_path (); #endif extern std::string tidy_for_filename (std::string); +boost::shared_ptr<const libdcp::Signer> make_signer (); struct FrameRateConversion { diff --git a/src/lib/writer.cc b/src/lib/writer.cc index 37376ca23..caa37c211 100644 --- a/src/lib/writer.cc +++ b/src/lib/writer.cc @@ -19,12 +19,13 @@ #include <fstream> #include <cerrno> -#include <libdcp/picture_asset.h> #include <libdcp/sound_asset.h> #include <libdcp/picture_frame.h> #include <libdcp/reel.h> #include <libdcp/dcp.h> #include <libdcp/cpl.h> +#include <libdcp/mono_picture_asset.h> +#include <libdcp/stereo_picture_asset.h> #include "writer.h" #include "compose.hpp" #include "film.h" @@ -74,48 +75,30 @@ Writer::Writer (shared_ptr<const Film> f, shared_ptr<Job> j) */ if (_film->three_d ()) { - _picture_asset.reset ( - new libdcp::StereoPictureAsset ( - _film->internal_video_mxf_dir (), - _film->internal_video_mxf_filename (), - _film->video_frame_rate (), - _film->container()->size (_film->full_frame ()) - ) - ); - + _picture_asset.reset (new libdcp::StereoPictureAsset (_film->internal_video_mxf_dir (), _film->internal_video_mxf_filename ())); } else { - _picture_asset.reset ( - new libdcp::MonoPictureAsset ( - _film->internal_video_mxf_dir (), - _film->internal_video_mxf_filename (), - _film->video_frame_rate (), - _film->container()->size (_film->full_frame ()) - ) - ); - + _picture_asset.reset (new libdcp::MonoPictureAsset (_film->internal_video_mxf_dir (), _film->internal_video_mxf_filename ())); } + _picture_asset->set_edit_rate (_film->video_frame_rate ()); + _picture_asset->set_size (_film->container()->size (_film->full_frame ())); + if (_film->encrypted ()) { _picture_asset->set_key (_film->key ()); } - _picture_asset_writer = _picture_asset->start_write (_first_nonexistant_frame > 0, _film->interop ()); + _picture_asset_writer = _picture_asset->start_write (_first_nonexistant_frame > 0); - _sound_asset.reset ( - new libdcp::SoundAsset ( - _film->dir (_film->dcp_name()), - _film->audio_mxf_filename (), - _film->video_frame_rate (), - _film->audio_channels (), - _film->audio_frame_rate () - ) - ); + _sound_asset.reset (new libdcp::SoundAsset (_film->dir (_film->dcp_name()), _film->audio_mxf_filename ())); + _sound_asset->set_edit_rate (_film->video_frame_rate ()); + _sound_asset->set_channels (_film->audio_channels ()); + _sound_asset->set_sampling_rate (_film->audio_frame_rate ()); if (_film->encrypted ()) { _sound_asset->set_key (_film->key ()); } - _sound_asset_writer = _sound_asset->start_write (_film->interop ()); + _sound_asset_writer = _sound_asset->start_write (); _thread = new boost::thread (boost::bind (&Writer::thread, this)); @@ -413,7 +396,7 @@ Writer::finish () libdcp::XMLMetadata meta = Config::instance()->dcp_metadata (); meta.set_issue_date_now (); - dcp.write_xml (_film->interop (), meta); + dcp.write_xml (_film->interop (), meta, make_signer ()); _film->log()->log (String::compose (N_("Wrote %1 FULL, %2 FAKE, %3 REPEAT; %4 pushed to disk"), _full_written, _fake_written, _repeat_written, _pushed_to_disk)); } |
