Some basics of AudioMapping.
[dcpomatic.git] / src / lib / sndfile_content.h
1 /* -*- c-basic-offset: 8; default-tab-width: 8; -*- */
2
3 /*
4     Copyright (C) 2013 Carl Hetherington <cth@carlh.net>
5
6     This program 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     This program 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 this program; if not, write to the Free Software
18     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19
20 */
21
22 extern "C" {
23 #include <libavutil/audioconvert.h>
24 }
25 #include "audio_content.h"
26
27 namespace cxml {
28         class Node;
29 }
30
31 class SndfileContent : public AudioContent
32 {
33 public:
34         SndfileContent (boost::filesystem::path);
35         SndfileContent (boost::shared_ptr<const cxml::Node>);
36
37         boost::shared_ptr<SndfileContent> shared_from_this () {
38                 return boost::dynamic_pointer_cast<SndfileContent> (Content::shared_from_this ());
39         }
40         
41         void examine (boost::shared_ptr<Film>, boost::shared_ptr<Job>, bool);
42         std::string summary () const;
43         std::string information () const;
44         void as_xml (xmlpp::Node *) const;
45         boost::shared_ptr<Content> clone () const;
46         Time length (boost::shared_ptr<const Film>) const;
47
48         /* AudioContent */
49         int audio_channels () const {
50                 boost::mutex::scoped_lock lm (_mutex);
51                 return _audio_channels;
52         }
53         
54         ContentAudioFrame audio_length () const {
55                 boost::mutex::scoped_lock lm (_mutex);
56                 return _audio_length;
57         }
58         
59         int content_audio_frame_rate () const {
60                 boost::mutex::scoped_lock lm (_mutex);
61                 return _audio_frame_rate;
62         }
63
64         int output_audio_frame_rate (boost::shared_ptr<const Film>) const;
65         
66         AudioMapping audio_mapping () const {
67                 boost::mutex::scoped_lock lm (_mutex);
68                 return _mapping;
69         }
70         
71         static bool valid_file (boost::filesystem::path);
72
73 private:
74         int _audio_channels;
75         ContentAudioFrame _audio_length;
76         int _audio_frame_rate;
77         AudioMapping _mapping;
78 };