Extract common code out into kdm_for_screen()
[dcpomatic.git] / src / lib / screen.h
1 /*
2     Copyright (C) 2013-2019 Carl Hetherington <cth@carlh.net>
3
4     This file is part of DCP-o-matic.
5
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.
10
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.
15
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/>.
18
19 */
20
21 #ifndef DCPOMATIC_SCREEN_H
22 #define DCPOMATIC_SCREEN_H
23
24 #include "kdm_with_metadata.h"
25 #include <dcp/certificate.h>
26 #include <libcxml/cxml.h>
27 #include <boost/optional.hpp>
28 #include <string>
29
30 class Cinema;
31 class Film;
32
33 class TrustedDevice
34 {
35 public:
36         explicit TrustedDevice (std::string);
37         explicit TrustedDevice (dcp::Certificate);
38
39         boost::optional<dcp::Certificate> certificate () const {
40                 return _certificate;
41         }
42
43         std::string thumbprint () const;
44         std::string as_string () const;
45
46 private:
47         boost::optional<dcp::Certificate> _certificate;
48         boost::optional<std::string> _thumbprint;
49 };
50
51 namespace dcpomatic {
52
53 /** @class Screen
54  *  @brief A representation of a Screen for KDM generation.
55  *
56  *  This is the name of the screen, the certificate of its
57  *  `recipient' (i.e. the mediablock) and the certificates/thumbprints
58  *  of any trusted devices.
59  */
60 class Screen
61 {
62 public:
63         Screen (std::string const & na, std::string const & no, boost::optional<dcp::Certificate> rec, std::vector<TrustedDevice> td)
64                 : name (na)
65                 , notes (no)
66                 , recipient (rec)
67                 , trusted_devices (td)
68         {}
69
70         explicit Screen (cxml::ConstNodePtr);
71
72         void as_xml (xmlpp::Element *) const;
73         std::vector<std::string> trusted_device_thumbprints () const;
74
75         boost::shared_ptr<Cinema> cinema;
76         std::string name;
77         std::string notes;
78         boost::optional<dcp::Certificate> recipient;
79         std::vector<TrustedDevice> trusted_devices;
80 };
81
82 }
83
84 KDMWithMetadataPtr
85 kdm_for_screen (
86         boost::shared_ptr<const Film> film,
87         boost::filesystem::path cpl,
88         boost::shared_ptr<const dcpomatic::Screen> screen,
89         boost::posix_time::ptime valid_from,
90         boost::posix_time::ptime valid_to,
91         dcp::Formulation formulation,
92         bool disable_forensic_marking_picture,
93         boost::optional<int> disable_forensic_marking_audio
94         );
95
96
97 #endif