Add EqualityOptions option to ignore differences in LoadFont nodes.
[libdcp.git] / src / mxf.h
1 /*
2     Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net>
3
4     This file is part of libdcp.
5
6     libdcp 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     libdcp 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 libdcp.  If not, see <http://www.gnu.org/licenses/>.
18
19     In addition, as a special exception, the copyright holders give
20     permission to link the code of portions of this program with the
21     OpenSSL library under certain conditions as described in each
22     individual source file, and distribute linked combinations
23     including the two.
24
25     You must obey the GNU General Public License in all respects
26     for all of the code used other than OpenSSL.  If you modify
27     file(s) with this exception, you may extend this exception to your
28     version of the file(s), but you are not obligated to do so.  If you
29     do not wish to do so, delete this exception statement from your
30     version.  If you delete this exception statement from all source
31     files in the program, then also delete it here.
32 */
33
34 #ifndef LIBDCP_MXF_H
35 #define LIBDCP_MXF_H
36
37 #include "asset.h"
38 #include "key.h"
39 #include "metadata.h"
40 #include "dcp_assert.h"
41
42 #include <boost/signals2.hpp>
43
44 namespace ASDCP {
45         class AESDecContext;
46         struct WriterInfo;
47 }
48
49 /* Undefine some stuff that the OS X 10.5 SDK defines */
50 #undef Key
51 #undef set_key
52
53 namespace dcp
54 {
55
56 class MXFMetadata;
57 class PictureAssetWriter;
58
59 /** @class MXF
60  *  @brief Parent for classes which represent MXF files.
61  */
62 class MXF
63 {
64 public:
65         MXF (Standard standard);
66         virtual ~MXF () {}
67
68         /** @return true if the data is encrypted */
69         bool encrypted () const {
70                 return static_cast<bool>(_key_id);
71         }
72
73         /** Set the ID of the key that is used for encryption/decryption.
74          *  @param i key ID.
75          */
76         void set_key_id (std::string i) {
77                 _key_id = i;
78         }
79
80         /** @return the ID of the key used for encryption/decryption, if there is one */
81         boost::optional<std::string> key_id () const {
82                 return _key_id;
83         }
84
85         virtual void set_key (Key);
86
87         /** @return encryption/decryption key, if one has been set */
88         boost::optional<Key> key () const {
89                 return _key;
90         }
91
92         /** Set the context ID to be used when encrypting.
93          *  @param id New ID.
94          */
95         void set_context_id (std::string id) {
96                 _context_id = id;
97         }
98
99         /** @return context ID used when encrypting; this starts off as a random value */
100         std::string context_id () const {
101                 return _context_id;
102         }
103
104         /** Set the metadata that is written to the MXF file.
105          *  @param m Metadata.
106          */
107         void set_metadata (MXFMetadata m) {
108                 _metadata = m;
109         }
110
111         /** @return metadata from the MXF file */
112         MXFMetadata metadata () const {
113                 return _metadata;
114         }
115
116         Standard standard () const {
117                 DCP_ASSERT (_standard);
118                 return *_standard;
119         }
120
121 protected:
122         template <class P, class Q>
123         friend void start (PictureAssetWriter* writer, boost::shared_ptr<P> state, Q* mxf, uint8_t const * data, int size);
124
125         MXF ();
126
127         std::string read_writer_info (ASDCP::WriterInfo const &);
128         /** Fill in a ADSCP::WriteInfo struct.
129          *  @param w struct to fill in.
130          */
131         void fill_writer_info (ASDCP::WriterInfo* w, std::string id) const;
132
133         /** ID of the key used for encryption/decryption, if there is one */
134         boost::optional<std::string> _key_id;
135         /** Key used for encryption/decryption, if there is one */
136         boost::optional<Key> _key;
137         std::string _context_id;
138         MXFMetadata _metadata;
139         boost::optional<Standard> _standard;
140 };
141
142 }
143
144 #endif