Add OpenSSL licence exception.
[libdcp.git] / src / cpl.h
1 /*
2     Copyright (C) 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 /** @file  src/cpl.h
35  *  @brief CPL class.
36  */
37
38 #ifndef LIBDCP_CPL_H
39 #define LIBDCP_CPL_H
40
41 #include "types.h"
42 #include "certificate.h"
43 #include "key.h"
44 #include "asset.h"
45 #include "metadata.h"
46 #include <boost/shared_ptr.hpp>
47 #include <boost/function.hpp>
48 #include <boost/optional.hpp>
49 #include <boost/filesystem.hpp>
50 #include <list>
51
52 namespace dcp {
53
54 class ReelAsset;
55 class Reel;
56 class XMLMetadata;
57 class MXFMetadata;
58 class CertificateChain;
59 class DecryptedKDM;
60
61 /** @class CPL
62  *  @brief A Composition Playlist.
63  */
64 class CPL : public Asset
65 {
66 public:
67         CPL (std::string annotation_text, ContentKind content_kind);
68         explicit CPL (boost::filesystem::path file);
69
70         bool equals (
71                 boost::shared_ptr<const Asset> other,
72                 EqualityOptions options,
73                 NoteHandler note
74                 ) const;
75
76         void add (boost::shared_ptr<Reel> reel);
77         void add (DecryptedKDM const &);
78
79         /** @return contents of the &lt;AnnotationText&gt; node */
80         std::string annotation_text () const {
81                 return _annotation_text;
82         }
83
84         /** @return contents of the &lt;ContentTitleText&gt; node */
85         std::string content_title_text () const {
86                 return _content_title_text;
87         }
88
89         /** @return contents of the &lt;Id&gt; node within &lt;ContentVersion&gt; */
90         void set_content_version_id (std::string id) {
91                 _content_version_id = id;
92         }
93
94         /** @return contents of the &lt;LabelText&gt; node within &lt;ContentVersion&gt; */
95         void set_content_version_label_text (std::string text) {
96                 _content_version_label_text = text;
97         }
98
99         /** @return the type of the content, used by media servers
100          *  to categorise things (e.g. feature, trailer, etc.)
101          */
102         ContentKind content_kind () const {
103                 return _content_kind;
104         }
105
106         /** @return the reels in this CPL */
107         std::list<boost::shared_ptr<Reel> > reels () const {
108                 return _reels;
109         }
110
111         /** @return the ReelAssets in this CPL in all reels.
112          */
113         std::list<boost::shared_ptr<const ReelAsset> > reel_assets () const;
114
115         bool encrypted () const;
116
117         void set_metadata (XMLMetadata m) {
118                 _metadata = m;
119         }
120
121         void write_xml (
122                 boost::filesystem::path file,
123                 Standard standard,
124                 boost::shared_ptr<const CertificateChain>
125                 ) const;
126
127         void resolve_refs (std::list<boost::shared_ptr<Asset> >);
128
129         int64_t duration () const;
130
131         boost::optional<Standard> standard () const {
132                 return _standard;
133         }
134
135 protected:
136         /** @return type string for PKLs for this asset */
137         std::string pkl_type (Standard standard) const;
138
139 private:
140         std::string _annotation_text;               ///< &lt;AnnotationText&gt;
141         /** &lt;Issuer&gt;, &lt;Creator&gt; and &lt;IssueDate&gt;.  These are grouped
142          *  because they occur together in a few places.
143          */
144         XMLMetadata _metadata;
145         std::string _content_title_text;            ///< &lt;ContentTitleText&gt;
146         ContentKind _content_kind;                  ///< &lt;ContentKind&gt;
147         std::string _content_version_id;            ///< &lt;Id&gt; in &lt;ContentVersion&gt;
148         std::string _content_version_label_text;    ///< &lt;LabelText&gt; in &lt;ContentVersion&gt;
149         std::list<boost::shared_ptr<Reel> > _reels;
150
151         /** Standard of CPL that was read in */
152         boost::optional<Standard> _standard;
153 };
154
155 }
156
157 #endif