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