Take Film pointer out of Content.
[dcpomatic.git] / src / lib / audio_content.h
1 /*
2     Copyright (C) 2013-2016 Carl Hetherington <cth@carlh.net>
3
4     This file is part of DCP-o-matic.
5
6     DCP-o-matic 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     DCP-o-matic 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 DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
18
19 */
20
21 /** @file  src/lib/audio_content.h
22  *  @brief AudioContent and AudioContentProperty classes.
23  */
24
25 #ifndef DCPOMATIC_AUDIO_CONTENT_H
26 #define DCPOMATIC_AUDIO_CONTENT_H
27
28 #include "content_part.h"
29 #include "audio_stream.h"
30 #include "audio_mapping.h"
31
32 /** @class AudioContentProperty
33  *  @brief Names for properties of AudioContent.
34  */
35 class AudioContentProperty
36 {
37 public:
38         static int const STREAMS;
39         static int const GAIN;
40         static int const DELAY;
41 };
42
43 class AudioContent : public ContentPart
44 {
45 public:
46         explicit AudioContent (Content* parent);
47         AudioContent (Content* parent, std::vector<boost::shared_ptr<Content> >);
48
49         void as_xml (xmlpp::Node *) const;
50         std::string technical_summary () const;
51         void take_settings_from (boost::shared_ptr<const AudioContent> c);
52
53         AudioMapping mapping () const;
54         void set_mapping (AudioMapping);
55         int resampled_frame_rate (boost::shared_ptr<const Film> film) const;
56         bool has_rate_above_48k () const;
57         std::vector<std::string> channel_names () const;
58
59         void set_gain (double);
60         void set_delay (int);
61
62         double gain () const {
63                 boost::mutex::scoped_lock lm (_mutex);
64                 return _gain;
65         }
66
67         int delay () const {
68                 boost::mutex::scoped_lock lm (_mutex);
69                 return _delay;
70         }
71
72         std::string processing_description (boost::shared_ptr<const Film> film) const;
73
74         std::vector<AudioStreamPtr> streams () const {
75                 boost::mutex::scoped_lock lm (_mutex);
76                 return _streams;
77         }
78
79         void add_stream (AudioStreamPtr stream);
80         void set_stream (AudioStreamPtr stream);
81         void set_streams (std::vector<AudioStreamPtr> streams);
82         AudioStreamPtr stream () const;
83
84         void add_properties (boost::shared_ptr<const Film> film, std::list<UserProperty> &) const;
85
86         void modify_position (boost::shared_ptr<const Film> film, DCPTime& pos) const;
87         void modify_trim_start (ContentTime& pos) const;
88
89         static boost::shared_ptr<AudioContent> from_xml (Content* parent, cxml::ConstNodePtr, int version);
90
91 private:
92
93         AudioContent (Content* parent, cxml::ConstNodePtr);
94
95         /** Gain to apply to audio in dB */
96         double _gain;
97         /** Delay to apply to audio (positive moves audio later) in milliseconds */
98         int _delay;
99         std::vector<AudioStreamPtr> _streams;
100 };
101
102 #endif