Merge master; MXF subtitle stuff not included.
[libdcp.git] / src / cpl.h
1 /*
2     Copyright (C) 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_CPL_H
21 #define LIBDCP_CPL_H
22
23 #include "types.h"
24 #include "certificates.h"
25 #include "key.h"
26 #include "asset.h"
27 #include "metadata.h"
28 #include <libxml++/libxml++.h>
29 #include <boost/shared_ptr.hpp>
30 #include <boost/function.hpp>
31 #include <boost/date_time/posix_time/posix_time.hpp>
32 #include <boost/optional.hpp>
33 #include <boost/filesystem.hpp>
34 #include <list>
35
36 namespace dcp {
37         
38 class Content;
39 class Reel;
40 class XMLMetadata;
41 class MXFMetadata;
42 class Signer;
43 class KDM;
44         
45 /** @class CPL
46  *  @brief A Composition Playlist.
47  */
48 class CPL : public Asset
49 {
50 public:
51         CPL (std::string annotation_text, ContentKind content_kind);
52         CPL (boost::filesystem::path file);
53
54         bool equals (
55                 CPL const & other,
56                 EqualityOptions options,
57                 boost::function<void (NoteType, std::string)> note
58                 ) const;
59
60         void add (boost::shared_ptr<Reel> reel);
61         void add (KDM const &);
62
63         /** @return contents of the &lt;AnnotationText&gt; node */
64         std::string annotation_text () const {
65                 return _annotation_text;
66         }
67         
68         /** @return contents of the &lt;ContentTitleText&gt; node */
69         std::string content_title_text () const {
70                 return _content_title_text;
71         }
72
73         /** @return contents of the &lt;Id&gt; node within &lt;ContentVersion&gt; */
74         void set_content_version_id (std::string id) {
75                 _content_version_id = id;
76         }
77
78         /** @return contents of the &lt;LabelText&gt; node within &lt;ContentVersion&gt; */
79         void set_content_version_label_text (std::string text) {
80                 _content_version_label_text = text;
81         }
82         
83         /** @return the type of the content, used by media servers
84          *  to categorise things (e.g. feature, trailer, etc.)
85          */
86         ContentKind content_kind () const {
87                 return _content_kind;
88         }
89
90         /** @return the reels in this CPL */
91         std::list<boost::shared_ptr<Reel> > reels () const {
92                 return _reels;
93         }
94
95         /** @return the Content in this CPL across all its reels
96          *  (Content is picture, sound and subtitles)
97          */
98         std::list<boost::shared_ptr<const Content> > content () const;
99
100         bool encrypted () const;
101
102         void set_mxf_keys (Key);
103
104         void write_xml (
105                 boost::filesystem::path file,
106                 Standard standard,
107                 boost::shared_ptr<const Signer>
108                 ) const;
109
110         void resolve_refs (std::list<boost::shared_ptr<Object> >);
111
112 protected:
113         /** @return type string for PKLs for this asset */
114         std::string pkl_type (Standard standard) const;
115
116 private:
117         std::string _annotation_text;               ///< &lt;AnnotationText&gt;
118         /** &lt;Issuer&gt;, &lt;Creator&gt; and &lt;IssueDate&gt;.  These are grouped
119          *  because they occur together in a few places.
120          */
121         XMLMetadata _metadata;
122         std::string _content_title_text;            ///< &lt;ContentTitleText&gt;
123         ContentKind _content_kind;                  ///< &lt;ContentKind&gt;
124         std::string _content_version_id;            ///< &lt;Id&gt; in &lt;ContentVersion&gt;
125         std::string _content_version_label_text;    ///< &lt;LabelText&gt; in &lt;ContentVersion&gt;
126         std::list<boost::shared_ptr<Reel> > _reels;
127 };
128
129 }
130
131 #endif