Missed update to private test repo version.
[dcpomatic.git] / src / lib / playlist.h
1 /*
2     Copyright (C) 2013-2018 Carl Hetherington <cth@carlh.net>
3
4     This file is part of DCP-o-matic.
5
6     DCP-o-matic 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     DCP-o-matic 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 DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
18
19 */
20
21 #ifndef DCPOMATIC_PLAYLIST_H
22 #define DCPOMATIC_PLAYLIST_H
23
24 #include "util.h"
25 #include "frame_rate_change.h"
26 #include "atomicity_checker.h"
27 #include <libcxml/cxml.h>
28 #include <boost/shared_ptr.hpp>
29 #include <boost/signals2.hpp>
30 #include <list>
31
32 class Film;
33
34 struct ContentSorter
35 {
36         bool operator() (boost::shared_ptr<Content> a, boost::shared_ptr<Content> b);
37 };
38
39 /** @class Playlist
40  *  @brief A set of Content objects with knowledge of how they should be arranged into
41  *  a DCP.
42  */
43 class Playlist : public boost::noncopyable
44 {
45 public:
46         Playlist ();
47         ~Playlist ();
48
49         void as_xml (xmlpp::Node *, bool with_content_paths);
50         void set_from_xml (boost::shared_ptr<const Film> film, cxml::ConstNodePtr node, int version, std::list<std::string>& notes);
51
52         void add (boost::shared_ptr<const Film> film, boost::shared_ptr<Content>);
53         void remove (boost::shared_ptr<Content>);
54         void remove (ContentList);
55         void move_earlier (boost::shared_ptr<const Film> film, boost::shared_ptr<Content>);
56         void move_later (boost::shared_ptr<const Film> film, boost::shared_ptr<Content>);
57
58         ContentList content () const;
59
60         std::string video_identifier () const;
61
62         DCPTime length (boost::shared_ptr<const Film> film) const;
63         boost::optional<DCPTime> start () const;
64         int64_t required_disk_space (boost::shared_ptr<const Film> film, int j2k_bandwidth, int audio_channels, int audio_frame_rate) const;
65
66         int best_video_frame_rate () const;
67         DCPTime video_end (boost::shared_ptr<const Film> film) const;
68         DCPTime text_end (boost::shared_ptr<const Film> film) const;
69         FrameRateChange active_frame_rate_change (DCPTime, int dcp_frame_rate) const;
70         std::string content_summary (boost::shared_ptr<const Film> film, DCPTimePeriod period) const;
71         std::pair<double, double> speed_up_range (int dcp_video_frame_rate) const;
72
73         void set_sequence (bool);
74         void maybe_sequence (boost::shared_ptr<const Film> film);
75
76         void repeat (boost::shared_ptr<const Film> film, ContentList, int);
77
78         /** Emitted when content has been added to or removed from the playlist; implies OrderChanged */
79         mutable boost::signals2::signal<void (ChangeType)> Change;
80         mutable boost::signals2::signal<void ()> OrderChanged;
81
82         mutable boost::signals2::signal<void (ChangeType, boost::weak_ptr<Content>, int, bool)> ContentChange;
83
84 private:
85         void content_change (boost::weak_ptr<const Film>, ChangeType, boost::weak_ptr<Content>, int, bool);
86         void disconnect ();
87         void reconnect (boost::shared_ptr<const Film> film);
88
89         mutable boost::mutex _mutex;
90         /** List of content.  Kept sorted in position order. */
91         ContentList _content;
92         bool _sequence;
93         bool _sequencing;
94         std::list<boost::signals2::connection> _content_connections;
95         AtomicityChecker _checker;
96 };
97
98 #endif