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