Rename TYPE_DEBUG_PLAYER to TYPE_DEBUG_VIDEO_VIEW.
[dcpomatic.git] / src / lib / kdm_with_metadata.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_KDM_WITH_METADATA_H
22 #define DCPOMATIC_KDM_WITH_METADATA_H
23
24 #ifdef DCPOMATIC_VARIANT_SWAROOP
25 #include "encrypted_ecinema_kdm.h"
26 #endif
27 #include <dcp/encrypted_kdm.h>
28 #include <dcp/name_format.h>
29 #include <boost/shared_ptr.hpp>
30
31 class Cinema;
32
33 class KDMWithMetadata
34 {
35 public:
36         KDMWithMetadata (dcp::NameFormat::Map const& name_values, void const* group, std::list<std::string> emails)
37                 : _name_values (name_values)
38                 , _group (group)
39                 , _emails (emails)
40         {}
41
42         virtual ~KDMWithMetadata () {}
43
44         virtual std::string kdm_as_xml () const = 0;
45         virtual void kdm_as_xml (boost::filesystem::path out) const = 0;
46
47         dcp::NameFormat::Map const& name_values () const {
48                 return _name_values;
49         }
50
51         boost::optional<std::string> get (char k) const;
52
53         void const* group () const {
54                 return _group;
55         }
56
57         std::list<std::string> emails () const {
58                 return _emails;
59         }
60
61 private:
62         dcp::NameFormat::Map _name_values;
63         void const* _group;
64         std::list<std::string> _emails;
65 };
66
67
68 typedef boost::shared_ptr<KDMWithMetadata> KDMWithMetadataPtr;
69
70
71 int write_files (
72         std::list<KDMWithMetadataPtr> screen_kdms, boost::filesystem::path directory,
73         dcp::NameFormat name_format, boost::function<bool (boost::filesystem::path)> confirm_overwrite
74         );
75
76
77 void make_zip_file (std::list<KDMWithMetadataPtr> kdms, boost::filesystem::path zip_file, dcp::NameFormat name_format);
78
79
80 std::list<std::list<KDMWithMetadataPtr> > collect (std::list<KDMWithMetadataPtr> kdms);
81
82
83 int write_directories (
84                 std::list<std::list<KDMWithMetadataPtr> > kdms,
85                 boost::filesystem::path directory,
86                 dcp::NameFormat container_name_format,
87                 dcp::NameFormat filename_format,
88                 boost::function<bool (boost::filesystem::path)> confirm_overwrite
89                 );
90
91
92 int write_zip_files (
93                 std::list<std::list<KDMWithMetadataPtr> > kdms,
94                 boost::filesystem::path directory,
95                 dcp::NameFormat container_name_format,
96                 dcp::NameFormat filename_format,
97                 boost::function<bool (boost::filesystem::path)> confirm_overwrite
98                 );
99
100
101 void email (
102                 std::list<std::list<KDMWithMetadataPtr> > kdms,
103                 dcp::NameFormat container_name_format,
104                 dcp::NameFormat filename_format,
105                 std::string cpl_name
106                 );
107
108
109 template <class T>
110 class SpecialKDMWithMetadata : public KDMWithMetadata
111 {
112 public:
113         SpecialKDMWithMetadata (dcp::NameFormat::Map const& name_values, void const* group, std::list<std::string> emails, T k)
114                 : KDMWithMetadata (name_values, group, emails)
115                 , kdm (k)
116         {}
117
118         std::string kdm_as_xml () const {
119                 return kdm.as_xml ();
120         }
121
122         void kdm_as_xml (boost::filesystem::path out) const {
123                 return kdm.as_xml (out);
124         }
125
126         T kdm;
127 };
128
129 typedef SpecialKDMWithMetadata<dcp::EncryptedKDM> DCPKDMWithMetadata;
130 #ifdef DCPOMATIC_VARIANT_SWAROOP
131 typedef SpecialKDMWithMetadata<EncryptedECinemaKDM> ECinemaKDMWithMetadata;
132 #endif
133
134 #endif
135