2 Copyright (C) 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.
21 #include "dcp_content.h"
22 #include "dcp_examiner.h"
25 #include "compose.hpp"
30 using boost::shared_ptr;
32 DCPContent::DCPContent (shared_ptr<const Film> f, boost::filesystem::path p)
35 , SingleStreamAudioContent (f)
42 DCPContent::DCPContent (shared_ptr<const Film> f, cxml::ConstNodePtr node, int version)
44 , VideoContent (f, node, version)
45 , SingleStreamAudioContent (f, node, version)
46 , SubtitleContent (f, node, version)
48 _name = node->string_child ("Name");
49 _directory = node->string_child ("Directory");
53 DCPContent::read_directory (boost::filesystem::path p)
55 for (boost::filesystem::directory_iterator i(p); i != boost::filesystem::directory_iterator(); ++i) {
56 if (boost::filesystem::is_regular_file (i->path ())) {
57 _paths.push_back (i->path ());
58 } else if (boost::filesystem::is_directory (i->path ())) {
59 read_directory (i->path ());
65 DCPContent::examine (shared_ptr<Job> job)
67 job->set_progress_unknown ();
68 Content::examine (job);
69 shared_ptr<DCPExaminer> examiner (new DCPExaminer (shared_from_this ()));
70 take_from_video_examiner (examiner);
71 take_from_audio_examiner (examiner);
73 boost::mutex::scoped_lock lm (_mutex);
74 _name = examiner->name ();
78 DCPContent::summary () const
80 boost::mutex::scoped_lock lm (_mutex);
81 return String::compose (_("%1 [DCP]"), _name);
85 DCPContent::technical_summary () const
87 return Content::technical_summary() + " - "
88 + VideoContent::technical_summary() + " - "
89 + AudioContent::technical_summary() + " - ";
93 DCPContent::as_xml (xmlpp::Node* node) const
95 node->add_child("Type")->add_child_text ("DCP");
97 Content::as_xml (node);
98 VideoContent::as_xml (node);
99 SingleStreamAudioContent::as_xml (node);
100 SubtitleContent::as_xml (node);
102 node->add_child("Name")->add_child_text (_name);
103 node->add_child("Directory")->add_child_text (_directory.string ());
107 DCPContent::full_length () const
109 shared_ptr<const Film> film = _film.lock ();
111 return DCPTime (video_length (), FrameRateChange (video_frame_rate (), film->video_frame_rate ()));
115 DCPContent::identifier () const
117 return SubtitleContent::identifier ();