2 Copyright (C) 2013-2014 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 <dcp/raw_convert.h>
22 #include "sndfile_content.h"
23 #include "sndfile_decoder.h"
25 #include "compose.hpp"
28 #include "safe_stringstream.h"
34 using boost::shared_ptr;
35 using dcp::raw_convert;
37 SndfileContent::SndfileContent (shared_ptr<const Film> f, boost::filesystem::path p)
39 , SingleStreamAudioContent (f, p)
44 SndfileContent::SndfileContent (shared_ptr<const Film> f, cxml::ConstNodePtr node, int version)
46 , SingleStreamAudioContent (f, node, version)
52 SndfileContent::as_xml (xmlpp::Node* node) const
54 node->add_child("Type")->add_child_text ("Sndfile");
55 Content::as_xml (node);
56 SingleStreamAudioContent::as_xml (node);
61 SndfileContent::summary () const
63 /* Get the string() here so that the name does not have quotes around it */
64 return String::compose (_("%1 [audio]"), path_summary ());
68 SndfileContent::technical_summary () const
70 return Content::technical_summary() + " - "
71 + AudioContent::technical_summary ()
76 SndfileContent::valid_file (boost::filesystem::path f)
78 /* XXX: more extensions */
79 string ext = f.extension().string();
80 transform (ext.begin(), ext.end(), ext.begin(), ::tolower);
81 return (ext == ".wav" || ext == ".aif" || ext == ".aiff");
85 SndfileContent::examine (shared_ptr<Job> job, bool calculate_digest)
87 job->set_progress_unknown ();
88 Content::examine (job, calculate_digest);
89 shared_ptr<AudioExaminer> dec (new SndfileDecoder (shared_from_this()));
90 take_from_audio_examiner (dec);
94 SndfileContent::full_length () const
96 shared_ptr<const Film> film = _film.lock ();
97 DCPOMATIC_ASSERT (film);
98 return DCPTime (audio_length(), film->active_frame_rate_change (position ()));