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/foreach.hpp>
27 #include <boost/algorithm/string.hpp>
28 #include <boost/date_time/posix_time/posix_time.hpp>
33 using boost::shared_ptr;
34 using boost::optional;
35 using namespace dcpomatic;
37 Screen::Screen (cxml::ConstNodePtr node)
40 BOOST_FOREACH (cxml::ConstNodePtr i, node->node_children ("TrustedDevice")) {
41 if (boost::algorithm::starts_with(i->content(), "-----BEGIN CERTIFICATE-----")) {
42 trusted_devices.push_back (TrustedDevice(dcp::Certificate(i->content())));
44 trusted_devices.push_back (TrustedDevice(i->content()));
50 Screen::as_xml (xmlpp::Element* parent) const
52 KDMRecipient::as_xml (parent);
53 BOOST_FOREACH (TrustedDevice i, trusted_devices) {
54 parent->add_child("TrustedDevice")->add_child_text(i.as_string());
59 Screen::trusted_device_thumbprints () const
62 BOOST_FOREACH (TrustedDevice i, trusted_devices) {
63 t.push_back (i.thumbprint());
71 shared_ptr<const Film> film,
72 boost::filesystem::path cpl,
73 shared_ptr<const dcpomatic::Screen> screen,
74 boost::posix_time::ptime valid_from,
75 boost::posix_time::ptime valid_to,
76 dcp::Formulation formulation,
77 bool disable_forensic_marking_picture,
78 optional<int> disable_forensic_marking_audio
81 if (!screen->recipient) {
82 return KDMWithMetadataPtr();
85 shared_ptr<const Cinema> cinema = screen->cinema;
86 dcp::LocalTime const begin(valid_from, cinema ? cinema->utc_offset_hour() : 0, cinema ? cinema->utc_offset_minute() : 0);
87 dcp::LocalTime const end (valid_to, cinema ? cinema->utc_offset_hour() : 0, cinema ? cinema->utc_offset_minute() : 0);
89 dcp::EncryptedKDM const kdm = film->make_kdm (
90 screen->recipient.get(),
91 screen->trusted_device_thumbprints(),
96 disable_forensic_marking_picture,
97 disable_forensic_marking_audio
100 dcp::NameFormat::Map name_values;
102 name_values['c'] = cinema->name;
104 name_values['s'] = screen->name;
105 name_values['f'] = film->name();
106 name_values['b'] = begin.date() + " " + begin.time_of_day(true, false);
107 name_values['e'] = end.date() + " " + end.time_of_day(true, false);
108 name_values['i'] = kdm.cpl_id();
110 return KDMWithMetadataPtr(new DCPKDMWithMetadata(name_values, cinema.get(), cinema ? cinema->emails : list<string>(), kdm));