2 Copyright (C) 2013-2021 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/>.
23 #include "kdm_with_metadata.h"
26 #include <libxml++/libxml++.h>
27 #include <boost/algorithm/string.hpp>
28 #include <boost/date_time/posix_time/posix_time.hpp>
32 using std::make_shared;
33 using std::shared_ptr;
36 using boost::optional;
37 using namespace dcpomatic;
40 Screen::Screen (cxml::ConstNodePtr node)
43 for (auto i: node->node_children ("TrustedDevice")) {
44 if (boost::algorithm::starts_with(i->content(), "-----BEGIN CERTIFICATE-----")) {
45 trusted_devices.push_back (TrustedDevice(dcp::Certificate(i->content())));
47 trusted_devices.push_back (TrustedDevice(i->content()));
54 Screen::as_xml (xmlpp::Element* parent) const
56 KDMRecipient::as_xml (parent);
57 for (auto i: trusted_devices) {
58 parent->add_child("TrustedDevice")->add_child_text(i.as_string());
64 Screen::trusted_device_thumbprints () const
67 for (auto i: trusted_devices) {
68 t.push_back (i.thumbprint());
76 shared_ptr<const Film> film,
77 boost::filesystem::path cpl,
78 shared_ptr<const dcpomatic::Screen> screen,
79 boost::posix_time::ptime valid_from,
80 boost::posix_time::ptime valid_to,
81 dcp::Formulation formulation,
82 bool disable_forensic_marking_picture,
83 optional<int> disable_forensic_marking_audio
86 if (!screen->recipient) {
90 auto cinema = screen->cinema;
91 dcp::LocalTime const begin(valid_from, dcp::UTCOffset(cinema ? cinema->utc_offset_hour() : 0, cinema ? cinema->utc_offset_minute() : 0));
92 dcp::LocalTime const end (valid_to, dcp::UTCOffset(cinema ? cinema->utc_offset_hour() : 0, cinema ? cinema->utc_offset_minute() : 0));
94 auto const kdm = film->make_kdm (
95 screen->recipient.get(),
96 screen->trusted_device_thumbprints(),
101 disable_forensic_marking_picture,
102 disable_forensic_marking_audio
105 dcp::NameFormat::Map name_values;
107 name_values['c'] = cinema->name;
109 name_values['c'] = "";
111 name_values['s'] = screen->name;
112 name_values['f'] = kdm.content_title_text();
113 name_values['b'] = begin.date() + " " + begin.time_of_day(true, false);
114 name_values['e'] = end.date() + " " + end.time_of_day(true, false);
115 name_values['i'] = kdm.cpl_id();
117 return make_shared<KDMWithMetadata>(name_values, cinema.get(), cinema ? cinema->emails : list<string>(), kdm);