Merge master and multifarious hackery.
[dcpomatic.git] / src / lib / playlist.h
1 /* -*- c-basic-offset: 8; default-tab-width: 8; -*- */
2
3 /*
4     Copyright (C) 2013 Carl Hetherington <cth@carlh.net>
5
6     This program 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     This program 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 this program; if not, write to the Free Software
18     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19
20 */
21
22 #ifndef DCPOMATIC_PLAYLIST_H
23 #define DCPOMATIC_PLAYLIST_H
24
25 #include <list>
26 #include <boost/shared_ptr.hpp>
27 #include <boost/enable_shared_from_this.hpp>
28 #include "video_source.h"
29 #include "audio_source.h"
30 #include "video_sink.h"
31 #include "audio_sink.h"
32 #include "ffmpeg_content.h"
33 #include "audio_mapping.h"
34
35 class Content;
36 class FFmpegContent;
37 class FFmpegDecoder;
38 class ImageMagickContent;
39 class ImageMagickDecoder;
40 class SndfileContent;
41 class SndfileDecoder;
42 class Job;
43 class Film;
44 class Region;
45
46 /** @class Playlist
47  *  @brief A set of content files (video and audio), with knowledge of how they should be arranged into
48  *  a DCP.
49  *
50  * This class holds Content objects, and it knows how they should be arranged.  At the moment
51  * the ordering is implicit; video content is placed sequentially, and audio content is taken
52  * from the video unless any sound-only files are present.  If sound-only files exist, they
53  * are played simultaneously (i.e. they can be split up into multiple files for different channels)
54  */
55
56 class Playlist
57 {
58 public:
59         Playlist ();
60         Playlist (boost::shared_ptr<const Playlist>);
61         ~Playlist ();
62
63         void as_xml (xmlpp::Node *);
64         void set_from_xml (boost::shared_ptr<const Film>, boost::shared_ptr<const cxml::Node>);
65
66         void add (boost::shared_ptr<Content>);
67         void remove (boost::shared_ptr<Content>);
68
69         bool has_subtitles () const;
70
71         typedef std::vector<boost::shared_ptr<Content> > ContentList;
72         
73         ContentList content () const {
74                 return _content;
75         }
76
77         std::string audio_digest () const;
78         std::string video_digest () const;
79
80         int loop () const {
81                 return _loop;
82         }
83         
84         void set_loop (int l);
85
86         Time length () const;
87         int best_dcp_frame_rate () const;
88
89         mutable boost::signals2::signal<void ()> Changed;
90         mutable boost::signals2::signal<void (boost::weak_ptr<Content>, int)> ContentChanged;
91         
92 private:
93         void content_changed (boost::weak_ptr<Content>, int);
94         void reconnect ();
95
96         ContentList _content;
97         int _loop;
98         std::list<boost::signals2::connection> _content_connections;
99 };
100
101 #endif