2 Copyright (C) 2013-2021 Carl Hetherington <cth@carlh.net>
4 This file is part of DCP-o-matic.
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.
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.
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/>.
22 #ifndef DCPOMATIC_PLAYLIST_H
23 #define DCPOMATIC_PLAYLIST_H
26 #include "change_signaller.h"
27 #include "dcpomatic_time.h"
28 #include "frame_rate_change.h"
30 #include <libcxml/cxml.h>
31 #include <boost/signals2.hpp>
32 #include <boost/thread.hpp>
41 bool operator() (std::shared_ptr<Content> a, std::shared_ptr<Content> b);
46 * @brief A set of Content objects with knowledge of how they should be arranged into
55 Playlist (Playlist const&) = delete;
56 Playlist& operator= (Playlist const&) = delete;
58 void as_xml (xmlpp::Node *, bool with_content_paths);
59 void set_from_xml (std::shared_ptr<const Film> film, cxml::ConstNodePtr node, int version, std::list<std::string>& notes);
61 void add (std::shared_ptr<const Film> film, std::shared_ptr<Content>);
62 void remove (std::shared_ptr<Content>);
63 void remove (ContentList);
64 void move_earlier (std::shared_ptr<const Film> film, std::shared_ptr<Content>);
65 void move_later (std::shared_ptr<const Film> film, std::shared_ptr<Content>);
67 ContentList content () const;
69 std::string video_identifier () const;
71 dcpomatic::DCPTime length (std::shared_ptr<const Film> film) const;
72 boost::optional<dcpomatic::DCPTime> start () const;
73 int64_t required_disk_space (std::shared_ptr<const Film> film, int j2k_bandwidth, int audio_channels, int audio_frame_rate) const;
75 int best_video_frame_rate () const;
76 dcpomatic::DCPTime video_end (std::shared_ptr<const Film> film) const;
77 dcpomatic::DCPTime text_end (std::shared_ptr<const Film> film) const;
78 FrameRateChange active_frame_rate_change (dcpomatic::DCPTime, int dcp_frame_rate) const;
79 std::string content_summary (std::shared_ptr<const Film> film, dcpomatic::DCPTimePeriod period) const;
80 std::pair<double, double> speed_up_range (int dcp_video_frame_rate) const;
82 void set_sequence (bool);
83 void maybe_sequence (std::shared_ptr<const Film> film);
85 void repeat (std::shared_ptr<const Film> film, ContentList, int);
87 /** Emitted when content has been added to or removed from the playlist; implies OrderChange */
88 mutable boost::signals2::signal<void (ChangeType)> Change;
89 mutable boost::signals2::signal<void ()> OrderChange;
90 /** Emitted when the length might have changed; may sometimes be emitted when it has not */
91 mutable boost::signals2::signal<void ()> LengthChange;
93 mutable boost::signals2::signal<void (ChangeType, std::weak_ptr<Content>, int, bool)> ContentChange;
96 void content_change (std::weak_ptr<const Film>, ChangeType, std::weak_ptr<Content>, int, bool);
98 void reconnect (std::shared_ptr<const Film> film);
100 mutable boost::mutex _mutex;
101 /** List of content. Kept sorted in position order. */
102 ContentList _content;
103 bool _sequence = true;
104 bool _sequencing = false;
105 std::list<boost::signals2::connection> _content_connections;