Merge master.
[dcpomatic.git] / src / lib / audio_content.h
1 /*
2     Copyright (C) 2013-2014 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_mapping.h"
29
30 namespace cxml {
31         class Node;
32 }
33
34 class AudioContentProperty
35 {
36 public:
37         static int const AUDIO_CHANNELS;
38         static int const AUDIO_LENGTH;
39         static int const AUDIO_FRAME_RATE;
40         static int const AUDIO_GAIN;
41         static int const AUDIO_DELAY;
42         static int const AUDIO_MAPPING;
43 };
44
45 /** @class AudioContent
46  *  @brief Parent class for content which may contain audio data.
47  */
48 class AudioContent : public virtual Content
49 {
50 public:
51         typedef int64_t Frame;
52         
53         AudioContent (boost::shared_ptr<const Film>);
54         AudioContent (boost::shared_ptr<const Film>, DCPTime);
55         AudioContent (boost::shared_ptr<const Film>, boost::filesystem::path);
56         AudioContent (boost::shared_ptr<const Film>, cxml::ConstNodePtr);
57         AudioContent (boost::shared_ptr<const Film>, std::vector<boost::shared_ptr<Content> >);
58
59         void as_xml (xmlpp::Node *) const;
60         std::string technical_summary () const;
61
62         /** @return number of audio channels in the content */
63         virtual int audio_channels () const = 0;
64         /** @return the length of the audio in the content */
65         virtual ContentTime audio_length () const = 0;
66         /** @return the frame rate of the content */
67         virtual int audio_frame_rate () const = 0;
68         virtual AudioMapping audio_mapping () const = 0;
69         virtual void set_audio_mapping (AudioMapping);
70         virtual boost::filesystem::path audio_analysis_path () const;
71
72         int resampled_audio_frame_rate () const;
73
74         boost::signals2::connection analyse_audio (boost::function<void()>);
75
76         void set_audio_gain (double);
77         void set_audio_delay (int);
78         
79         double audio_gain () const {
80                 boost::mutex::scoped_lock lm (_mutex);
81                 return _audio_gain;
82         }
83
84         int audio_delay () const {
85                 boost::mutex::scoped_lock lm (_mutex);
86                 return _audio_delay;
87         }
88
89 private:
90         /** Gain to apply to audio in dB */
91         double _audio_gain;
92         /** Delay to apply to audio (positive moves audio later) in milliseconds */
93         int _audio_delay;
94 };
95
96 #endif