2 Copyright (C) 2013-2015 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 "sndfile_content.h"
22 #include "sndfile_decoder.h"
24 #include "compose.hpp"
27 #include "safe_stringstream.h"
33 using boost::shared_ptr;
35 SndfileContent::SndfileContent (shared_ptr<const Film> f, boost::filesystem::path p)
37 , SingleStreamAudioContent (f, p)
42 SndfileContent::SndfileContent (shared_ptr<const Film> f, cxml::ConstNodePtr node, int version)
44 , SingleStreamAudioContent (f, node, version)
50 SndfileContent::as_xml (xmlpp::Node* node) const
52 node->add_child("Type")->add_child_text ("Sndfile");
53 Content::as_xml (node);
54 SingleStreamAudioContent::as_xml (node);
59 SndfileContent::summary () const
61 /* Get the string() here so that the name does not have quotes around it */
62 return String::compose (_("%1 [audio]"), path_summary ());
66 SndfileContent::technical_summary () const
68 return Content::technical_summary() + " - "
69 + AudioContent::technical_summary ()
74 SndfileContent::valid_file (boost::filesystem::path f)
76 /* XXX: more extensions */
77 string ext = f.extension().string();
78 transform (ext.begin(), ext.end(), ext.begin(), ::tolower);
79 return (ext == ".wav" || ext == ".aif" || ext == ".aiff");
83 SndfileContent::examine (shared_ptr<Job> job)
85 job->set_progress_unknown ();
86 Content::examine (job);
87 shared_ptr<AudioExaminer> dec (new SndfileDecoder (shared_from_this()));
88 take_from_audio_examiner (dec);
92 SndfileContent::full_length () const
94 shared_ptr<const Film> film = _film.lock ();
95 DCPOMATIC_ASSERT (film);
96 FrameRateChange const frc = film->active_frame_rate_change (position ());
97 return DCPTime::from_frames (audio_length() / frc.speed_up, audio_frame_rate ());