df6527ed094bc75883a7fda86496328e27aef557
[dcpomatic.git] / src / lib / audio_content.h
1 /*
2     Copyright (C) 2013-2015 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.h"
28 #include "audio_stream.h"
29 #include "audio_mapping.h"
30
31 namespace cxml {
32         class Node;
33 }
34
35 /** @class AudioContentProperty
36  *  @brief Names for properties of AudioContent.
37  */
38 class AudioContentProperty
39 {
40 public:
41         static int const AUDIO_STREAMS;
42         static int const AUDIO_GAIN;
43         static int const AUDIO_DELAY;
44 };
45
46 /** @class AudioContent
47  *  @brief Parent class for content which may contain audio data.
48  */
49 class AudioContent : public virtual Content
50 {
51 public:
52         AudioContent (boost::shared_ptr<const Film>);
53         AudioContent (boost::shared_ptr<const Film>, DCPTime);
54         AudioContent (boost::shared_ptr<const Film>, boost::filesystem::path);
55         AudioContent (boost::shared_ptr<const Film>, cxml::ConstNodePtr);
56         AudioContent (boost::shared_ptr<const Film>, std::vector<boost::shared_ptr<Content> >);
57
58         void as_xml (xmlpp::Node *) const;
59         std::string technical_summary () const;
60
61         virtual std::vector<AudioStreamPtr> audio_streams () const = 0;
62
63         AudioMapping audio_mapping () const;
64         void set_audio_mapping (AudioMapping);
65         int resampled_audio_frame_rate () const;
66         bool has_rate_above_48k () const;
67         std::vector<std::string> audio_channel_names () const;
68
69         void set_audio_gain (double);
70         void set_audio_delay (int);
71         
72         double audio_gain () const {
73                 boost::mutex::scoped_lock lm (_mutex);
74                 return _audio_gain;
75         }
76
77         int audio_delay () const {
78                 boost::mutex::scoped_lock lm (_mutex);
79                 return _audio_delay;
80         }
81
82         std::string processing_description () const;
83         
84 private:
85         /** Gain to apply to audio in dB */
86         double _audio_gain;
87         /** Delay to apply to audio (positive moves audio later) in milliseconds */
88         int _audio_delay;
89 };
90
91 #endif