f6cb447f9a87f8eea6acd5cbdc07ae319d6baaad
[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 STREAMS;
38         static int const GAIN;
39         static int const DELAY;
40 };
41
42 class AudioContent : public ContentPart
43 {
44 public:
45         AudioContent (Content* parent);
46         AudioContent (Content* parent, std::vector<boost::shared_ptr<Content> >);
47
48         void as_xml (xmlpp::Node *) const;
49         std::string technical_summary () const;
50
51         AudioMapping mapping () const;
52         void set_mapping (AudioMapping);
53         int resampled_frame_rate () const;
54         bool has_rate_above_48k () const;
55         std::vector<std::string> channel_names () const;
56
57         void set_gain (double);
58         void set_delay (int);
59
60         double gain () const {
61                 boost::mutex::scoped_lock lm (_mutex);
62                 return _gain;
63         }
64
65         int delay () const {
66                 boost::mutex::scoped_lock lm (_mutex);
67                 return _delay;
68         }
69
70         std::string processing_description () const;
71
72         std::vector<AudioStreamPtr> streams () const {
73                 boost::mutex::scoped_lock lm (_mutex);
74                 return _streams;
75         }
76
77         void add_stream (AudioStreamPtr stream);
78         void set_stream (AudioStreamPtr stream);
79         void set_streams (std::vector<AudioStreamPtr> streams);
80         AudioStreamPtr stream () const;
81
82         void add_properties (std::list<UserProperty> &) const;
83
84         static boost::shared_ptr<AudioContent> from_xml (Content* parent, cxml::ConstNodePtr);
85
86 private:
87
88         AudioContent (Content* parent, cxml::ConstNodePtr);
89
90         /** Gain to apply to audio in dB */
91         double _gain;
92         /** Delay to apply to audio (positive moves audio later) in milliseconds */
93         int _delay;
94         std::vector<AudioStreamPtr> _streams;
95 };
96
97 #endif