Various bits and pieces.
[dcpomatic.git] / src / lib / sndfile_content.cc
index 539b0dfb586a4926c47e4e1f3e6678966e254ad9..0f895c95e109b28ddd57b7007e3d6264fd33cd32 100644 (file)
@@ -1,3 +1,5 @@
+/* -*- c-basic-offset: 8; default-tab-width: 8; -*- */
+
 /*
     Copyright (C) 2013 Carl Hetherington <cth@carlh.net>
 
@@ -31,9 +33,9 @@ using std::cout;
 using boost::shared_ptr;
 using boost::lexical_cast;
 
-SndfileContent::SndfileContent (boost::filesystem::path f)
-       : Content (f)
-       , AudioContent (f)
+SndfileContent::SndfileContent (shared_ptr<const Film> f, boost::filesystem::path p)
+       : Content (f, p)
+       , AudioContent (f, p)
        , _audio_channels (0)
        , _audio_length (0)
        , _audio_frame_rate (0)
@@ -41,9 +43,9 @@ SndfileContent::SndfileContent (boost::filesystem::path f)
 
 }
 
-SndfileContent::SndfileContent (shared_ptr<const cxml::Node> node)
-       : Content (node)
-       , AudioContent (node)
+SndfileContent::SndfileContent (shared_ptr<const Film> f, shared_ptr<const cxml::Node> node)
+       : Content (f, node)
+       , AudioContent (f, node)
 {
        _audio_channels = node->number_child<int> ("AudioChannels");
        _audio_length = node->number_child<ContentAudioFrame> ("AudioLength");
@@ -68,7 +70,7 @@ SndfileContent::information () const
        s << String::compose (
                _("%1 channels, %2kHz, %3 samples"),
                audio_channels(),
-               audio_frame_rate() / 1000.0,
+               content_audio_frame_rate() / 1000.0,
                audio_length()
                );
        
@@ -91,10 +93,13 @@ SndfileContent::clone () const
 }
 
 void
-SndfileContent::examine (shared_ptr<Film> film, shared_ptr<Job> job, bool quick)
+SndfileContent::examine (shared_ptr<Job> job)
 {
        job->set_progress_unknown ();
-       Content::examine (film, job, quick);
+       Content::examine (job);
+
+       shared_ptr<const Film> film = _film.lock ();
+       assert (film);
 
        SndfileDecoder dec (film, shared_from_this());
 
@@ -120,3 +125,20 @@ SndfileContent::as_xml (xmlpp::Node* node) const
        node->add_child("AudioFrameRate")->add_child_text (lexical_cast<string> (_audio_frame_rate));
 }
 
+Time
+SndfileContent::length () const
+{
+       shared_ptr<const Film> film = _film.lock ();
+       assert (film);
+       
+       return film->audio_frames_to_time (audio_length ());
+}
+
+int
+SndfileContent::output_audio_frame_rate () const
+{
+       shared_ptr<const Film> film = _film.lock ();
+       assert (film);
+       
+       return film->dcp_audio_frame_rate ();
+}