No-op: remove all trailing whitespace.
[dcpomatic.git] / src / lib / playlist.h
1 /*
2     Copyright (C) 2013 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 DCPOMATIC_PLAYLIST_H
21 #define DCPOMATIC_PLAYLIST_H
22
23 #include "ffmpeg_content.h"
24 #include "audio_mapping.h"
25 #include "util.h"
26 #include "frame_rate_change.h"
27 #include <boost/shared_ptr.hpp>
28 #include <boost/enable_shared_from_this.hpp>
29 #include <list>
30
31 class Content;
32 class FFmpegContent;
33 class FFmpegDecoder;
34 class StillImageMagickContent;
35 class StillImageMagickDecoder;
36 class SndfileContent;
37 class SndfileDecoder;
38 class Job;
39 class Film;
40 class Region;
41
42 struct ContentSorter
43 {
44         bool operator() (boost::shared_ptr<Content> a, boost::shared_ptr<Content> b);
45 };
46
47 /** @class Playlist
48  *  @brief A set of Content objects with knowledge of how they should be arranged into
49  *  a DCP.
50  */
51 class Playlist : public boost::noncopyable
52 {
53 public:
54         Playlist ();
55         ~Playlist ();
56
57         void as_xml (xmlpp::Node *);
58         void set_from_xml (boost::shared_ptr<const Film>, cxml::ConstNodePtr, int, std::list<std::string> &);
59
60         void add (boost::shared_ptr<Content>);
61         void remove (boost::shared_ptr<Content>);
62         void remove (ContentList);
63         void move_earlier (boost::shared_ptr<Content>);
64         void move_later (boost::shared_ptr<Content>);
65
66         ContentList content () const;
67
68         std::string video_identifier () const;
69
70         DCPTime length () const;
71
72         int best_dcp_frame_rate () const;
73         DCPTime video_end () const;
74         FrameRateChange active_frame_rate_change (DCPTime, int dcp_frame_rate) const;
75
76         void set_sequence_video (bool);
77         void maybe_sequence_video ();
78
79         void repeat (ContentList, int);
80
81         /** Emitted when content has been added to or removed from the playlist */
82         mutable boost::signals2::signal<void ()> Changed;
83         /** Emitted when something about a piece of our content has changed;
84          *  these emissions include when the position of the content changes.
85          *  Third parameter is true if signals are currently being emitted frequently.
86          */
87         mutable boost::signals2::signal<void (boost::weak_ptr<Content>, int, bool)> ContentChanged;
88
89 private:
90         void content_changed (boost::weak_ptr<Content>, int, bool);
91         void reconnect ();
92
93         /** List of content.  Kept sorted in position order. */
94         ContentList _content;
95         bool _sequence_video;
96         bool _sequencing_video;
97         std::list<boost::signals2::connection> _content_connections;
98 };
99
100 #endif