Use cxml::ConstNodePtr.
[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 #include "util.h"
29
30 class Content;
31 class FFmpegContent;
32 class FFmpegDecoder;
33 class StillImageMagickContent;
34 class StillImageMagickDecoder;
35 class SndfileContent;
36 class SndfileDecoder;
37 class Job;
38 class Film;
39 class Region;
40
41 struct ContentSorter
42 {
43         bool operator() (boost::shared_ptr<Content> a, boost::shared_ptr<Content> b);
44 };
45
46 /** @class Playlist
47  *  @brief A set of Content objects with knowledge of how they should be arranged into
48  *  a DCP.
49  */
50 class Playlist : public boost::noncopyable
51 {
52 public:
53         Playlist ();
54         ~Playlist ();
55
56         void as_xml (xmlpp::Node *);
57         void set_from_xml (boost::shared_ptr<const Film>, cxml::ConstNodePtr, int, std::list<std::string> &);
58
59         void add (boost::shared_ptr<Content>);
60         void remove (boost::shared_ptr<Content>);
61         void remove (ContentList);
62         void move_earlier (boost::shared_ptr<Content>);
63         void move_later (boost::shared_ptr<Content>);
64
65         bool has_subtitles () const;
66
67         ContentList content () const;
68
69         std::string video_identifier () const;
70
71         DCPTime length () const;
72         
73         int best_dcp_frame_rate () const;
74         DCPTime video_end () const;
75         FrameRateChange active_frame_rate_change (DCPTime, int dcp_frame_rate) const;
76
77         void set_sequence_video (bool);
78         void maybe_sequence_video ();
79
80         void repeat (ContentList, int);
81
82         mutable boost::signals2::signal<void ()> Changed;
83         /** Third parameter is true if signals are currently being emitted frequently */
84         mutable boost::signals2::signal<void (boost::weak_ptr<Content>, int, bool)> ContentChanged;
85         
86 private:
87         void content_changed (boost::weak_ptr<Content>, int, bool);
88         void reconnect ();
89
90         /** List of content.  Kept sorted in position order. */
91         ContentList _content;
92         bool _sequence_video;
93         bool _sequencing_video;
94         std::list<boost::signals2::connection> _content_connections;
95 };
96
97 #endif