Remove unused code.
[dcpomatic.git] / src / lib / sndfile_content.cc
1 /*
2     Copyright (C) 2013-2014 Carl Hetherington <cth@carlh.net>
3
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.
8
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.
13
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.
17
18 */
19
20 #include <libcxml/cxml.h>
21 #include <dcp/raw_convert.h>
22 #include "sndfile_content.h"
23 #include "sndfile_decoder.h"
24 #include "film.h"
25 #include "compose.hpp"
26 #include "job.h"
27 #include "util.h"
28 #include "safe_stringstream.h"
29
30 #include "i18n.h"
31
32 using std::string;
33 using std::cout;
34 using boost::shared_ptr;
35 using dcp::raw_convert;
36
37 SndfileContent::SndfileContent (shared_ptr<const Film> f, boost::filesystem::path p)
38         : Content (f, p)
39         , SingleStreamAudioContent (f, p)
40 {
41
42 }
43
44 SndfileContent::SndfileContent (shared_ptr<const Film> f, cxml::ConstNodePtr node, int version)
45         : Content (f, node)
46         , SingleStreamAudioContent (f, node, version)
47 {
48         
49 }
50
51 void
52 SndfileContent::as_xml (xmlpp::Node* node) const
53 {
54         node->add_child("Type")->add_child_text ("Sndfile");
55         Content::as_xml (node);
56         SingleStreamAudioContent::as_xml (node);
57 }
58
59
60 string
61 SndfileContent::summary () const
62 {
63         /* Get the string() here so that the name does not have quotes around it */
64         return String::compose (_("%1 [audio]"), path_summary ());
65 }
66
67 string
68 SndfileContent::technical_summary () const
69 {
70         return Content::technical_summary() + " - "
71                 + AudioContent::technical_summary ()
72                 + " - sndfile";
73 }
74
75 bool
76 SndfileContent::valid_file (boost::filesystem::path f)
77 {
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");
82 }
83
84 void
85 SndfileContent::examine (shared_ptr<Job> job, bool calculate_digest)
86 {
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);
91 }
92
93 DCPTime
94 SndfileContent::full_length () const
95 {
96         shared_ptr<const Film> film = _film.lock ();
97         DCPOMATIC_ASSERT (film);
98         return DCPTime (audio_length(), film->active_frame_rate_change (position ()));
99 }
100