Some missing copy constructors / operator= / noncopyable.
[dcpomatic.git] / src / lib / audio_content.cc
index a3942f64bf3d6455922c2742ca0834cc311b28b0..e93f348f42359aab632c3d9738c6689200a4a9cf 100644 (file)
@@ -1,5 +1,3 @@
-/* -*- c-basic-offset: 8; default-tab-width: 8; -*- */
-
 /*
     Copyright (C) 2013 Carl Hetherington <cth@carlh.net>
 
 
 #include <libcxml/cxml.h>
 #include "audio_content.h"
+#include "analyse_audio_job.h"
+#include "job_manager.h"
+#include "film.h"
 
 using std::string;
 using boost::shared_ptr;
 using boost::lexical_cast;
+using boost::dynamic_pointer_cast;
 
 int const AudioContentProperty::AUDIO_CHANNELS = 200;
 int const AudioContentProperty::AUDIO_LENGTH = 201;
 int const AudioContentProperty::AUDIO_FRAME_RATE = 202;
 int const AudioContentProperty::AUDIO_GAIN = 203;
 int const AudioContentProperty::AUDIO_DELAY = 204;
+int const AudioContentProperty::AUDIO_MAPPING = 205;
 
-AudioContent::AudioContent (Time s)
-       : Content (s)
+AudioContent::AudioContent (shared_ptr<const Film> f, Time s)
+       : Content (f, s)
        , _audio_gain (0)
        , _audio_delay (0)
 {
 
 }
 
-AudioContent::AudioContent (boost::filesystem::path f)
-       : Content (f)
+AudioContent::AudioContent (shared_ptr<const Film> f, boost::filesystem::path p)
+       : Content (f, p)
        , _audio_gain (0)
        , _audio_delay (0)
 {
 
 }
 
-AudioContent::AudioContent (shared_ptr<const cxml::Node> node)
-       : Content (node)
+AudioContent::AudioContent (shared_ptr<const Film> f, shared_ptr<const cxml::Node> node)
+       : Content (f, node)
 {
        _audio_gain = node->number_child<float> ("AudioGain");
        _audio_delay = node->number_child<int> ("AudioDelay");
@@ -94,3 +97,26 @@ AudioContent::set_audio_delay (int d)
        signal_changed (AudioContentProperty::AUDIO_DELAY);
 }
 
+void
+AudioContent::analyse_audio (boost::function<void()> finished)
+{
+       shared_ptr<const Film> film = _film.lock ();
+       if (!film) {
+               return;
+       }
+       
+       shared_ptr<AnalyseAudioJob> job (new AnalyseAudioJob (film, dynamic_pointer_cast<AudioContent> (shared_from_this())));
+       job->Finished.connect (finished);
+       JobManager::instance()->add (job);
+}
+
+boost::filesystem::path
+AudioContent::audio_analysis_path () const
+{
+       shared_ptr<const Film> film = _film.lock ();
+       if (!film) {
+               return boost::filesystem::path ();
+       }
+
+       return film->audio_analysis_path (dynamic_pointer_cast<const AudioContent> (shared_from_this ()));
+}