summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2013-09-19 21:39:01 +0100
committerCarl Hetherington <cth@carlh.net>2013-09-19 21:39:01 +0100
commitcd6fd2ab18bdc1364ede3a33773df4e3ad719efa (patch)
treeca7007518c890a37f2dd85493e7ee5ce27ffc4a0 /src/lib
parent8446a529b08d754c7ffe968baef54e5c115c26a5 (diff)
Various KDM and encryption fixes.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/cinema.h47
-rw-r--r--src/lib/config.cc10
-rw-r--r--src/lib/config.h1
-rw-r--r--src/lib/film.cc13
-rw-r--r--src/lib/film.h6
-rw-r--r--src/lib/util.cc15
-rw-r--r--src/lib/util.h1
-rw-r--r--src/lib/writer.cc17
-rw-r--r--src/lib/wscript1
9 files changed, 96 insertions, 15 deletions
diff --git a/src/lib/cinema.h b/src/lib/cinema.h
index 6f426ae8d..251bb5d61 100644
--- a/src/lib/cinema.h
+++ b/src/lib/cinema.h
@@ -1,5 +1,31 @@
+/*
+ Copyright (C) 2013 Carl Hetherington <cth@carlh.net>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include <boost/enable_shared_from_this.hpp>
#include <libdcp/certificates.h>
+class Cinema;
+
+namespace cxml {
+ class Node;
+}
+
class Screen
{
public:
@@ -7,20 +33,37 @@ public:
: name (n)
, certificate (cert)
{}
+
+ Screen (boost::shared_ptr<const cxml::Node>);
+
+ void as_xml (xmlpp::Element *) const;
+ boost::shared_ptr<Cinema> cinema;
std::string name;
boost::shared_ptr<libdcp::Certificate> certificate;
};
-class Cinema
+class Cinema : public boost::enable_shared_from_this<Cinema>
{
public:
Cinema (std::string const & n, std::string const & e)
: name (n)
, email (e)
{}
+
+ Cinema (boost::shared_ptr<const cxml::Node>);
+
+ void as_xml (xmlpp::Element *) const;
+
+ void add_screen (boost::shared_ptr<Screen>);
+ void remove_screen (boost::shared_ptr<Screen>);
std::string name;
std::string email;
- std::list<boost::shared_ptr<Screen> > screens;
+ std::list<boost::shared_ptr<Screen> > screens () const {
+ return _screens;
+ }
+
+private:
+ std::list<boost::shared_ptr<Screen> > _screens;
};
diff --git a/src/lib/config.cc b/src/lib/config.cc
index 7d945c897..a72e1a9e4 100644
--- a/src/lib/config.cc
+++ b/src/lib/config.cc
@@ -32,6 +32,7 @@
#include "dcp_content_type.h"
#include "sound_processor.h"
#include "colour_conversion.h"
+#include "cinema.h"
#include "i18n.h"
@@ -128,6 +129,11 @@ Config::read ()
for (list<shared_ptr<cxml::Node> >::iterator i = cc.begin(); i != cc.end(); ++i) {
_colour_conversions.push_back (PresetColourConversion (*i));
}
+
+ list<shared_ptr<cxml::Node> > cin = f.node_children ("Cinema");
+ for (list<shared_ptr<cxml::Node> >::iterator i = cin.begin(); i != cin.end(); ++i) {
+ _cinemas.push_back (shared_ptr<Cinema> (new Cinema (*i)));
+ }
}
void
@@ -280,6 +286,10 @@ Config::write () const
i->as_xml (root->add_child ("ColourConversion"));
}
+ for (list<shared_ptr<Cinema> >::const_iterator i = _cinemas.begin(); i != _cinemas.end(); ++i) {
+ (*i)->as_xml (root->add_child ("Cinema"));
+ }
+
doc.write_to_file_formatted (file(false).string ());
}
diff --git a/src/lib/config.h b/src/lib/config.h
index 8c80f9679..3e8a975d6 100644
--- a/src/lib/config.h
+++ b/src/lib/config.h
@@ -275,7 +275,6 @@ private:
libdcp::XMLMetadata _dcp_metadata;
int _default_j2k_bandwidth;
std::vector<PresetColourConversion> _colour_conversions;
-
std::list<boost::shared_ptr<Cinema> > _cinemas;
/** Singleton instance, or 0 */
diff --git a/src/lib/film.cc b/src/lib/film.cc
index aacc5a4cc..1e76dac2c 100644
--- a/src/lib/film.cc
+++ b/src/lib/film.cc
@@ -96,10 +96,10 @@ Film::Film (boost::filesystem::path dir)
, _resolution (RESOLUTION_2K)
, _scaler (Scaler::from_id ("bicubic"))
, _with_subtitles (false)
+ , _encrypted (false)
, _j2k_bandwidth (Config::instance()->default_j2k_bandwidth ())
, _dci_metadata (Config::instance()->default_dci_metadata ())
, _video_frame_rate (24)
- , _encrypted (false)
, _audio_channels (MAX_AUDIO_CHANNELS)
, _three_d (false)
, _sequence_video (true)
@@ -346,6 +346,7 @@ Film::write_metadata () const
root->add_child("SequenceVideo")->add_child_text (_sequence_video ? "1" : "0");
root->add_child("Interop")->add_child_text (_interop ? "1" : "0");
root->add_child("Encrypted")->add_child_text (_encrypted ? "1" : "0");
+ root->add_child("Key")->add_child_text (_key.hex ());
_playlist->as_xml (root->add_child ("Playlist"));
doc.write_to_file_formatted (file ("metadata.xml"));
@@ -395,7 +396,7 @@ Film::read_metadata ()
_sequence_video = f.bool_child ("SequenceVideo");
_three_d = f.bool_child ("ThreeD");
_interop = f.bool_child ("Interop");
-
+ _key = libdcp::Key (f.string_child ("Key"));
_playlist->set_from_xml (shared_from_this(), f.node_child ("Playlist"));
_dirty = false;
@@ -910,19 +911,19 @@ Film::make_kdms (
{
boost::filesystem::path p (sd);
p /= "ca.self-signed.pem";
- chain.add (shared_ptr<libdcp::Certificate> (new libdcp::Certificate (p.string ())));
+ 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.string ())));
+ 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.string ())));
+ chain.add (shared_ptr<libdcp::Certificate> (new libdcp::Certificate (p)));
}
boost::filesystem::path signer_key (sd);
@@ -950,12 +951,12 @@ Film::make_kdms (
libdcp::DCP dcp (dcps.front ());
dcp.read ();
- /* XXX: single CPL only */
shared_ptr<xmlpp::Document> kdm = dcp.cpls().front()->make_kdm (
signer, (*i)->certificate, from, until, _interop, libdcp::MXFMetadata (), Config::instance()->dcp_metadata ()
);
boost::filesystem::path out = directory;
+ out /= tidy_for_filename ((*i)->cinema->name) + "_" + tidy_for_filename ((*i)->name);
out /= "kdm.xml";
kdm->write_to_file_formatted (out.string());
}
diff --git a/src/lib/film.h b/src/lib/film.h
index 809eabdaa..26623e69e 100644
--- a/src/lib/film.h
+++ b/src/lib/film.h
@@ -31,6 +31,7 @@
#include <boost/signals2.hpp>
#include <boost/enable_shared_from_this.hpp>
#include <boost/filesystem.hpp>
+#include <libdcp/key.h>
#include "util.h"
#include "types.h"
#include "dci_metadata.h"
@@ -121,6 +122,10 @@ public:
std::string directory
) const;
+ libdcp::Key key () const {
+ return _key;
+ }
+
/** Identifiers for the parts of our state;
used for signalling changes.
*/
@@ -296,6 +301,7 @@ private:
bool _three_d;
bool _sequence_video;
bool _interop;
+ libdcp::Key _key;
/** true if our state has changed since we last saved it */
mutable bool _dirty;
diff --git a/src/lib/util.cc b/src/lib/util.cc
index b8bc1fc9e..4e4493ac7 100644
--- a/src/lib/util.cc
+++ b/src/lib/util.cc
@@ -800,3 +800,18 @@ valid_image_file (boost::filesystem::path f)
return (ext == ".tif" || ext == ".tiff" || ext == ".jpg" || ext == ".jpeg" || ext == ".png" || ext == ".bmp" || ext == ".tga");
}
+string
+tidy_for_filename (string f)
+{
+ string t;
+ for (size_t i = 0; i < f.length(); ++i) {
+ if (isalpha (f[i]) || f[i] == '_' || f[i] == '-') {
+ t += f[i];
+ } else {
+ t += '_';
+ }
+ }
+
+ return t;
+}
+
diff --git a/src/lib/util.h b/src/lib/util.h
index a83426206..b5c94d994 100644
--- a/src/lib/util.h
+++ b/src/lib/util.h
@@ -70,6 +70,7 @@ extern bool valid_image_file (boost::filesystem::path);
#ifdef DCPOMATIC_WINDOWS
extern boost::filesystem::path mo_path ();
#endif
+extern std::string tidy_for_filename (std::string);
struct FrameRateConversion
{
diff --git a/src/lib/writer.cc b/src/lib/writer.cc
index 4f93373f7..37376ca23 100644
--- a/src/lib/writer.cc
+++ b/src/lib/writer.cc
@@ -79,8 +79,7 @@ Writer::Writer (shared_ptr<const Film> f, shared_ptr<Job> j)
_film->internal_video_mxf_dir (),
_film->internal_video_mxf_filename (),
_film->video_frame_rate (),
- _film->container()->size (_film->full_frame ()),
- _film->encrypted ()
+ _film->container()->size (_film->full_frame ())
)
);
@@ -90,13 +89,16 @@ Writer::Writer (shared_ptr<const Film> f, shared_ptr<Job> j)
_film->internal_video_mxf_dir (),
_film->internal_video_mxf_filename (),
_film->video_frame_rate (),
- _film->container()->size (_film->full_frame ()),
- _film->encrypted ()
+ _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 ());
_sound_asset.reset (
@@ -105,10 +107,13 @@ Writer::Writer (shared_ptr<const Film> f, shared_ptr<Job> j)
_film->audio_mxf_filename (),
_film->video_frame_rate (),
_film->audio_channels (),
- _film->audio_frame_rate (),
- _film->encrypted ()
+ _film->audio_frame_rate ()
)
);
+
+ if (_film->encrypted ()) {
+ _sound_asset->set_key (_film->key ());
+ }
_sound_asset_writer = _sound_asset->start_write (_film->interop ());
diff --git a/src/lib/wscript b/src/lib/wscript
index 6c45d8b1e..e91666f7f 100644
--- a/src/lib/wscript
+++ b/src/lib/wscript
@@ -8,6 +8,7 @@ sources = """
audio_content.cc
audio_decoder.cc
audio_mapping.cc
+ cinema.cc
colour_conversion.cc
config.cc
content.cc