More noncopyable.
[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 <list>
24 #include <boost/shared_ptr.hpp>
25 #include <boost/enable_shared_from_this.hpp>
26 #include "ffmpeg_content.h"
27 #include "audio_mapping.h"
28
29 class Content;
30 class FFmpegContent;
31 class FFmpegDecoder;
32 class ImageMagickContent;
33 class ImageMagickDecoder;
34 class SndfileContent;
35 class SndfileDecoder;
36 class Job;
37 class Film;
38 class Region;
39
40 /** @class Playlist
41  *  @brief A set of content files (video and audio), with knowledge of how they should be arranged into
42  *  a DCP.
43  *
44  * This class holds Content objects, and it knows how they should be arranged.  At the moment
45  * the ordering is implicit; video content is placed sequentially, and audio content is taken
46  * from the video unless any sound-only files are present.  If sound-only files exist, they
47  * are played simultaneously (i.e. they can be split up into multiple files for different channels)
48  */
49
50 struct ContentSorter
51 {
52         bool operator() (boost::shared_ptr<Content> a, boost::shared_ptr<Content> b);
53 };
54
55 class Playlist : public boost::noncopyable
56 {
57 public:
58         Playlist ();
59         ~Playlist ();
60
61         void as_xml (xmlpp::Node *);
62         void set_from_xml (boost::shared_ptr<const Film>, boost::shared_ptr<const cxml::Node>);
63
64         void add (boost::shared_ptr<Content>);
65         void remove (boost::shared_ptr<Content>);
66
67         bool has_subtitles () const;
68
69         typedef std::vector<boost::shared_ptr<Content> > ContentList;
70         
71         ContentList content () const {
72                 return _content;
73         }
74
75         std::string video_identifier () const;
76
77         int loop () const {
78                 return _loop;
79         }
80         
81         void set_loop (int l);
82
83         Time length () const;
84         int best_dcp_frame_rate () const;
85         Time video_end () const;
86
87         void set_sequence_video (bool);
88         void maybe_sequence_video ();
89
90         mutable boost::signals2::signal<void ()> Changed;
91         /** Third parameter is true if signals are currently being emitted frequently */
92         mutable boost::signals2::signal<void (boost::weak_ptr<Content>, int, bool)> ContentChanged;
93         
94 private:
95         void content_changed (boost::weak_ptr<Content>, int, bool);
96         void reconnect ();
97
98         ContentList _content;
99         int _loop;
100         bool _sequence_video;
101         bool _sequencing_video;
102         std::list<boost::signals2::connection> _content_connections;
103 };
104
105 #endif