#include <boost/algorithm/string.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/date_time.hpp>
+#include <libxml++/libxml++.h>
+#include <libdcp/crypt_chain.h>
+#include <libdcp/certificates.h>
+#include "cinema.h"
#include "film.h"
#include "format.h"
#include "job.h"
using std::setfill;
using std::min;
using std::make_pair;
+using std::list;
using std::cout;
using boost::shared_ptr;
using boost::lexical_cast;
, _with_subtitles (false)
, _subtitle_offset (0)
, _subtitle_scale (1)
+ , _encrypted (false)
, _colour_lut (0)
, _j2k_bandwidth (200000000)
, _frames_per_second (0)
, _with_subtitles (o._with_subtitles)
, _subtitle_offset (o._subtitle_offset)
, _subtitle_scale (o._subtitle_scale)
+ , _encrypted (o._encrypted)
, _colour_lut (o._colour_lut)
, _j2k_bandwidth (o._j2k_bandwidth)
, _audio_language (o._audio_language)
f << "with_subtitles " << _with_subtitles << "\n";
f << "subtitle_offset " << _subtitle_offset << "\n";
f << "subtitle_scale " << _subtitle_scale << "\n";
+ f << "encrypted " << _encrypted << "\n";
f << "colour_lut " << _colour_lut << "\n";
f << "j2k_bandwidth " << _j2k_bandwidth << "\n";
f << "audio_language " << _audio_language << "\n";
_subtitle_offset = atoi (v.c_str ());
} else if (k == "subtitle_scale") {
_subtitle_scale = atof (v.c_str ());
+ } else if (k == "encrypted") {
+ _encrypted = (v == "1");
} else if (k == "colour_lut") {
_colour_lut = atoi (v.c_str ());
} else if (k == "j2k_bandwidth") {
signal_changed (SUBTITLE_SCALE);
}
+void
+Film::set_encrypted (bool e)
+{
+ {
+ boost::mutex::scoped_lock lm (_state_mutex);
+ _encrypted = e;
+ }
+ signal_changed (ENCRYPTED);
+}
+
void
Film::set_colour_lut (int i)
{
return _external_audio_stream;
}
+
+void
+Film::make_kdms (
+ list<shared_ptr<Screen> > 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<libdcp::Certificate> (new libdcp::Certificate (p.string ())));
+ }
+
+ {
+ boost::filesystem::path p (cd);
+ p /= "intermediate.signed.pem";
+ chain.add (shared_ptr<libdcp::Certificate> (new libdcp::Certificate (p.string ())));
+ }
+
+ {
+ boost::filesystem::path p (cd);
+ p /= "leaf.signed.pem";
+ chain.add (shared_ptr<libdcp::Certificate> (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<string> 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<shared_ptr<Screen> >::iterator i = screens.begin(); i != screens.end(); ++i) {
+
+ libdcp::DCP dcp (dcps.front ());
+ dcp.read ();
+
+ /* XXX: single CPL only */
+ shared_ptr<xmlpp::Document> 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());
+ }
+}
+