Split CPL up into its own files.
[libdcp.git] / src / cpl.h
1 /*
2     Copyright (C) 2012 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 #include <list>
21 #include <boost/shared_ptr.hpp>
22 #include <boost/function.hpp>
23 #include "types.h"
24
25 namespace libdcp {
26
27 class AssetMap;
28 class Asset;
29 class Reel;
30
31 /** @brief A CPL within a DCP */
32 class CPL
33 {
34 public:
35         CPL (std::string directory, std::string name, ContentKind content_kind, int length, int frames_per_second);
36         CPL (std::string directory, std::string file, boost::shared_ptr<const AssetMap> asset_map, bool require_mxfs = true);
37
38         void add_reel (boost::shared_ptr<const Reel> reel);
39         
40         /** @return the length in frames */
41         int length () const {
42                 return _length;
43         }
44
45         /** @return the type of the content, used by media servers
46          *  to categorise things (e.g. feature, trailer, etc.)
47          */
48         ContentKind content_kind () const {
49                 return _content_kind;
50         }
51
52         std::list<boost::shared_ptr<const Reel> > reels () const {
53                 return _reels;
54         }
55
56         /** @return the CPL's name, as will be presented on projector
57          *  media servers and theatre management systems.
58          */
59         std::string name () const {
60                 return _name;
61         }
62
63         /** @return the number of frames per second */
64         int frames_per_second () const {
65                 return _fps;
66         }
67
68         std::list<boost::shared_ptr<const Asset> > assets () const;
69         
70         bool equals (CPL const & other, EqualityOptions options, boost::function<void (NoteType, std::string)> note) const;
71         
72         void write_xml () const;
73         void write_to_assetmap (std::ostream& s) const;
74         void write_to_pkl (std::ostream& s) const;
75         
76 private:
77         std::string _directory;
78         /** the name of the DCP */
79         std::string _name;
80         /** the content kind of the CPL */
81         ContentKind _content_kind;
82         /** length in frames */
83         mutable int _length;
84         /** frames per second */
85         int _fps;
86         /** reels */
87         std::list<boost::shared_ptr<const Reel> > _reels;
88
89         /** our UUID */
90         std::string _uuid;
91         /** a SHA1 digest of our XML */
92         mutable std::string _digest;
93 };
94
95 }