Various fix-ups and warning fixes from OS X.
[libdcp.git] / src / mxf.h
1 /*
2     Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net>
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #ifndef LIBDCP_MXF_H
21 #define LIBDCP_MXF_H
22
23 #include "content.h"
24 #include "key.h"
25 #include "metadata.h"
26 #include <boost/signals2.hpp>
27
28 namespace ASDCP {
29         class AESEncContext;
30         class AESDecContext;
31 }
32
33 /* Undefine some stuff that the OS X 10.5 SDK defines */
34 #undef Key
35 #undef set_key
36
37 namespace dcp
38 {
39
40 class MXFMetadata;      
41
42 /** @class MXF
43  *  @brief Parent class for classes which represent MXF files.
44  */
45 class MXF : public Content
46 {
47 public:
48         MXF (Fraction edit_rate);
49         MXF (boost::filesystem::path file);
50         ~MXF ();
51
52         bool equals (
53                 boost::shared_ptr<const Asset> other,
54                 EqualityOptions opt,
55                 boost::function<void (NoteType, std::string)> note
56                 ) const;
57
58         /** Fill in a ADSCP::WriteInfo struct.
59          *  @param w struct to fill in.
60          *  @param standard INTEROP or SMPTE.
61          */
62         void fill_writer_info (ASDCP::WriterInfo* w, Standard standard);
63
64         /** @return true if the data is encrypted */
65         bool encrypted () const {
66                 return !_key_id.empty ();
67         }
68
69         /** Set the ID of the key that is used for encryption/decryption.
70          *  @param i key ID.
71          */
72         void set_key_id (std::string i) {
73                 _key_id = i;
74         }
75
76         /** @return the ID of the key used for encryption/decryption, or an empty string */
77         std::string key_id () const {
78                 return _key_id;
79         }
80
81         void set_key (Key);
82
83         /** @return encryption/decryption key, if one has been set */
84         boost::optional<Key> key () const {
85                 return _key;
86         }
87
88         /** @return encryption context, set up with any key that has been passed to set_key() */
89         ASDCP::AESEncContext* encryption_context () const {
90                 return _encryption_context;
91         }
92
93         /** Set the metadata that is written to the MXF file.
94          *  @param m Metadata.
95          */
96         void set_metadata (MXFMetadata m) {
97                 _metadata = m;
98         }
99
100         /** @return metadata from the MXF file */
101         MXFMetadata metadata () const {
102                 return _metadata;
103         }
104
105         Fraction edit_rate () const {
106                 return _edit_rate;
107         }
108
109         /** @return The total length of this content in video frames.
110          *  The amount of content presented may be less than this.
111          */
112         int64_t intrinsic_duration () const {
113                 return _intrinsic_duration;
114         }
115         
116 protected:
117         friend class MXFWriter;
118
119         std::string pkl_type (Standard standard) const;
120         void read_writer_info (ASDCP::WriterInfo const &);
121         
122         Fraction _edit_rate;
123         /** The total length of this content in video frames.  The amount of
124          *  content presented may be less than this.
125          */
126         int64_t _intrinsic_duration;
127         
128         ASDCP::AESEncContext* _encryption_context;
129         ASDCP::AESDecContext* _decryption_context;
130         /** ID of the key used for encryption/decryption, or an empty string */
131         std::string _key_id;
132         /** Key used for encryption/decryption, if there is one */
133         boost::optional<Key> _key;
134         MXFMetadata _metadata;
135 };
136
137 }
138
139 #endif