Write 'f', 'b' and 'e' tags into all KDMWithMetadata when they are made.
[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, boost::shared_ptr<Cinema> cinema)
37                 : _name_values (name_values)
38                 , _cinema (cinema)
39         {}
40
41         virtual ~KDMWithMetadata () {}
42
43         virtual std::string kdm_as_xml () const = 0;
44         virtual void kdm_as_xml (boost::filesystem::path out) const = 0;
45         virtual std::string kdm_id () 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         boost::shared_ptr<Cinema> cinema () const {
54                 return _cinema;
55         }
56
57 private:
58         dcp::NameFormat::Map _name_values;
59         boost::shared_ptr<Cinema> _cinema;
60 };
61
62
63 typedef boost::shared_ptr<KDMWithMetadata> KDMWithMetadataPtr;
64
65
66 int write_files (
67         std::list<KDMWithMetadataPtr> screen_kdms, boost::filesystem::path directory,
68         dcp::NameFormat name_format, dcp::NameFormat::Map name_values,
69         boost::function<bool (boost::filesystem::path)> confirm_overwrite
70         );
71
72
73 void make_zip_file (std::list<KDMWithMetadataPtr> kdms, boost::filesystem::path zip_file, dcp::NameFormat name_format, dcp::NameFormat::Map name_values);
74
75
76 std::list<std::list<KDMWithMetadataPtr> > collect (std::list<KDMWithMetadataPtr> kdms);
77
78
79 int write_directories (
80                 std::list<std::list<KDMWithMetadataPtr> > cinema_kdms,
81                 boost::filesystem::path directory,
82                 dcp::NameFormat container_name_format,
83                 dcp::NameFormat filename_format,
84                 dcp::NameFormat::Map name_values,
85                 boost::function<bool (boost::filesystem::path)> confirm_overwrite
86                 );
87
88
89 int write_zip_files (
90                 std::list<std::list<KDMWithMetadataPtr> > cinema_kdms,
91                 boost::filesystem::path directory,
92                 dcp::NameFormat container_name_format,
93                 dcp::NameFormat filename_format,
94                 dcp::NameFormat::Map name_values,
95                 boost::function<bool (boost::filesystem::path)> confirm_overwrite
96                 );
97
98
99 void email (
100                 std::list<std::list<KDMWithMetadataPtr> > cinema_kdms,
101                 dcp::NameFormat container_name_format,
102                 dcp::NameFormat filename_format,
103                 dcp::NameFormat::Map name_values,
104                 std::string cpl_name
105                 );
106
107
108 class DCPKDMWithMetadata : public KDMWithMetadata
109 {
110 public:
111         DCPKDMWithMetadata (dcp::NameFormat::Map const& name_values, boost::shared_ptr<Cinema> cinema, dcp::EncryptedKDM k)
112                 : KDMWithMetadata (name_values, cinema)
113                 , kdm (k)
114         {}
115
116         std::string kdm_as_xml () const {
117                 return kdm.as_xml ();
118         }
119
120         void kdm_as_xml (boost::filesystem::path out) const {
121                 return kdm.as_xml (out);
122         }
123
124         std::string kdm_id () const {
125                 return kdm.cpl_id ();
126         }
127
128         dcp::EncryptedKDM kdm;
129 };
130
131 #ifdef DCPOMATIC_VARIANT_SWAROOP
132 class ECinemaKDMWithMetadata : public KDMWithMetadata
133 {
134 public:
135         ECinemaKDMWithMetadata (dcp::NameValues::Map const& name_values, boost::shared_ptr<Cinema> cinema, EncryptedECinemaKDM k)
136                 : KDMWithMetadata (name_values, cinema)
137                 , kdm (k)
138         {}
139
140         std::string kdm_as_xml () const {
141                 return kdm.as_xml ();
142         }
143
144         void kdm_as_xml (boost::filesystem::path out) const {
145                 return kdm.as_xml (out);
146         }
147
148         std::string kdm_id () const {
149                 return kdm.id ();
150         }
151
152         EncryptedECinemaKDM kdm;
153 };
154 #endif
155
156 #endif