2 Copyright (C) 2013 Carl Hetherington <cth@carlh.net>
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.
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.
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.
20 #include <libcxml/cxml.h>
21 #include "audio_content.h"
22 #include "analyse_audio_job.h"
23 #include "job_manager.h"
27 using boost::shared_ptr;
28 using boost::lexical_cast;
29 using boost::dynamic_pointer_cast;
31 int const AudioContentProperty::AUDIO_CHANNELS = 200;
32 int const AudioContentProperty::AUDIO_LENGTH = 201;
33 int const AudioContentProperty::AUDIO_FRAME_RATE = 202;
34 int const AudioContentProperty::AUDIO_GAIN = 203;
35 int const AudioContentProperty::AUDIO_DELAY = 204;
36 int const AudioContentProperty::AUDIO_MAPPING = 205;
38 AudioContent::AudioContent (shared_ptr<const Film> f, Time s)
46 AudioContent::AudioContent (shared_ptr<const Film> f, boost::filesystem::path p)
54 AudioContent::AudioContent (shared_ptr<const Film> f, shared_ptr<const cxml::Node> node)
57 _audio_gain = node->number_child<float> ("AudioGain");
58 _audio_delay = node->number_child<int> ("AudioDelay");
62 AudioContent::as_xml (xmlpp::Node* node) const
64 boost::mutex::scoped_lock lm (_mutex);
65 node->add_child("AudioGain")->add_child_text (lexical_cast<string> (_audio_gain));
66 node->add_child("AudioDelay")->add_child_text (lexical_cast<string> (_audio_delay));
71 AudioContent::set_audio_gain (float g)
74 boost::mutex::scoped_lock lm (_mutex);
78 signal_changed (AudioContentProperty::AUDIO_GAIN);
82 AudioContent::set_audio_delay (int d)
85 boost::mutex::scoped_lock lm (_mutex);
89 signal_changed (AudioContentProperty::AUDIO_DELAY);
93 AudioContent::analyse_audio (boost::function<void()> finished)
95 shared_ptr<const Film> film = _film.lock ();
100 shared_ptr<AnalyseAudioJob> job (new AnalyseAudioJob (film, dynamic_pointer_cast<AudioContent> (shared_from_this())));
101 job->Finished.connect (finished);
102 JobManager::instance()->add (job);
105 boost::filesystem::path
106 AudioContent::audio_analysis_path () const
108 shared_ptr<const Film> film = _film.lock ();
110 return boost::filesystem::path ();
113 return film->audio_analysis_path (dynamic_pointer_cast<const AudioContent> (shared_from_this ()));
117 AudioContent::technical_summary () const
119 return String::compose ("audio: channels %1, length %2, raw rate %3, out rate %4", audio_channels(), audio_length(), content_audio_frame_rate(), output_audio_frame_rate());