2 Copyright (C) 2013-2020 Carl Hetherington <cth@carlh.net>
4 This file is part of DCP-o-matic.
6 DCP-o-matic is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 DCP-o-matic is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
22 #include "kdm_with_metadata.h"
25 #include <libxml++/libxml++.h>
26 #include <boost/algorithm/string.hpp>
27 #include <boost/date_time/posix_time/posix_time.hpp>
32 using std::shared_ptr;
33 using boost::optional;
34 using namespace dcpomatic;
36 Screen::Screen (cxml::ConstNodePtr node)
39 for (auto i: node->node_children ("TrustedDevice")) {
40 if (boost::algorithm::starts_with(i->content(), "-----BEGIN CERTIFICATE-----")) {
41 trusted_devices.push_back (TrustedDevice(dcp::Certificate(i->content())));
43 trusted_devices.push_back (TrustedDevice(i->content()));
49 Screen::as_xml (xmlpp::Element* parent) const
51 KDMRecipient::as_xml (parent);
52 for (auto i: trusted_devices) {
53 parent->add_child("TrustedDevice")->add_child_text(i.as_string());
58 Screen::trusted_device_thumbprints () const
61 for (auto i: trusted_devices) {
62 t.push_back (i.thumbprint());
70 shared_ptr<const Film> film,
71 boost::filesystem::path cpl,
72 shared_ptr<const dcpomatic::Screen> screen,
73 boost::posix_time::ptime valid_from,
74 boost::posix_time::ptime valid_to,
75 dcp::Formulation formulation,
76 bool disable_forensic_marking_picture,
77 optional<int> disable_forensic_marking_audio
80 if (!screen->recipient) {
81 return KDMWithMetadataPtr();
84 shared_ptr<const Cinema> cinema = screen->cinema;
85 dcp::LocalTime const begin(valid_from, cinema ? cinema->utc_offset_hour() : 0, cinema ? cinema->utc_offset_minute() : 0);
86 dcp::LocalTime const end (valid_to, cinema ? cinema->utc_offset_hour() : 0, cinema ? cinema->utc_offset_minute() : 0);
88 dcp::EncryptedKDM const kdm = film->make_kdm (
89 screen->recipient.get(),
90 screen->trusted_device_thumbprints(),
95 disable_forensic_marking_picture,
96 disable_forensic_marking_audio
99 dcp::NameFormat::Map name_values;
101 name_values['c'] = cinema->name;
103 name_values['s'] = screen->name;
104 name_values['f'] = film->name();
105 name_values['b'] = begin.date() + " " + begin.time_of_day(true, false);
106 name_values['e'] = end.date() + " " + end.time_of_day(true, false);
107 name_values['i'] = kdm.cpl_id();
109 return KDMWithMetadataPtr(new KDMWithMetadata(name_values, cinema.get(), cinema ? cinema->emails : list<string>(), kdm));