Split audio; builds.
[dcpomatic.git] / src / lib / audio_content.h
1 /*
2     Copyright (C) 2013-2016 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 /** @file  src/lib/audio_content.h
21  *  @brief AudioContent and AudioContentProperty classes.
22  */
23
24 #ifndef DCPOMATIC_AUDIO_CONTENT_H
25 #define DCPOMATIC_AUDIO_CONTENT_H
26
27 #include "content_part.h"
28 #include "audio_stream.h"
29 #include "audio_mapping.h"
30
31 /** @class AudioContentProperty
32  *  @brief Names for properties of AudioContent.
33  */
34 class AudioContentProperty
35 {
36 public:
37         static int const AUDIO_STREAMS;
38         static int const AUDIO_GAIN;
39         static int const AUDIO_DELAY;
40         static int const AUDIO_VIDEO_FRAME_RATE;
41 };
42
43 class AudioContent : public ContentPart
44 {
45 public:
46         AudioContent (Content* parent, boost::shared_ptr<const Film>);
47         AudioContent (Content* parent, boost::shared_ptr<const Film>, cxml::ConstNodePtr);
48         AudioContent (Content* parent, boost::shared_ptr<const Film>, std::vector<boost::shared_ptr<Content> >);
49
50         void as_xml (xmlpp::Node *) const;
51         std::string technical_summary () const;
52
53         AudioMapping audio_mapping () const;
54         void set_audio_mapping (AudioMapping);
55         int resampled_audio_frame_rate () const;
56         bool has_rate_above_48k () const;
57         std::vector<std::string> audio_channel_names () const;
58
59         void set_audio_gain (double);
60         void set_audio_delay (int);
61
62         double audio_gain () const {
63                 boost::mutex::scoped_lock lm (_mutex);
64                 return _audio_gain;
65         }
66
67         int audio_delay () const {
68                 boost::mutex::scoped_lock lm (_mutex);
69                 return _audio_delay;
70         }
71
72         double audio_video_frame_rate () const;
73         void set_audio_video_frame_rate (double r);
74
75         std::string processing_description () const;
76
77         std::vector<AudioStreamPtr> streams () const {
78                 boost::mutex::scoped_lock lm (_mutex);
79                 return _streams;
80         }
81
82         void add_stream (AudioStreamPtr stream);
83         void set_stream (AudioStreamPtr stream);
84         void set_streams (std::vector<AudioStreamPtr> streams);
85         AudioStreamPtr stream () const;
86
87         void add_properties (std::list<UserProperty> &) const;
88
89 private:
90
91         /** Gain to apply to audio in dB */
92         double _audio_gain;
93         /** Delay to apply to audio (positive moves audio later) in milliseconds */
94         int _audio_delay;
95         boost::optional<double> _audio_video_frame_rate;
96         std::vector<AudioStreamPtr> _streams;
97 };
98
99 #endif