Some tidying up.
[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 <libxml++/libxml++.h>
28 #include <boost/shared_ptr.hpp>
29 #include <boost/function.hpp>
30 #include <boost/date_time/posix_time/posix_time.hpp>
31 #include <boost/optional.hpp>
32 #include <boost/filesystem.hpp>
33 #include <list>
34
35 namespace dcp {
36         
37 class Content;
38 class Reel;
39 class XMLMetadata;
40 class MXFMetadata;
41 class Signer;
42 class KDM;
43         
44 /** @class CPL
45  *  @brief A Composition Playlist.
46  */
47 class CPL : public Asset
48 {
49 public:
50         CPL (std::string annotation_text, ContentKind content_kind);
51         CPL (boost::filesystem::path file);
52
53         std::string pkl_type () const {
54                 return "text/xml";
55         }
56
57         void add (boost::shared_ptr<Reel> reel);
58
59         std::string annotation_text () const {
60                 return _annotation_text;
61         }
62         
63         std::string content_title_text () const {
64                 return _content_title_text;
65         }
66         
67         /** @return the type of the content, used by media servers
68          *  to categorise things (e.g. feature, trailer, etc.)
69          */
70         ContentKind content_kind () const {
71                 return _content_kind;
72         }
73
74         std::list<boost::shared_ptr<Reel> > reels () const {
75                 return _reels;
76         }
77
78         std::list<boost::shared_ptr<const Content> > assets () const;
79
80         bool encrypted () const;
81
82         void set_mxf_keys (Key);
83
84         bool equals (CPL const & other, EqualityOptions options, boost::function<void (NoteType, std::string)> note) const;
85         
86         void write_xml (boost::filesystem::path file, Standard standard, XMLMetadata, boost::shared_ptr<const Signer>) const;
87         void write_to_assetmap (xmlpp::Node *) const;
88
89         void add (KDM const &);
90         
91 private:
92         
93         std::string _annotation_text;
94         std::string _issue_date;
95         std::string _creator;
96         std::string _content_title_text;
97         ContentKind _content_kind;
98         std::string _content_version_id;
99         std::string _content_version_label_text;
100         /** reels */
101         std::list<boost::shared_ptr<Reel> > _reels;
102
103         /** a SHA1 digest of our XML */
104         mutable std::string _digest;
105         /** length in bytes of the XML that we last wrote to disk */
106         mutable int64_t _length;
107 };
108
109 }
110
111 #endif