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)
37 , _has_subtitles (false)
43 DCPContent::DCPContent (shared_ptr<const Film> f, cxml::ConstNodePtr node, int version)
45 , VideoContent (f, node, version)
46 , SingleStreamAudioContent (f, node, version)
47 , SubtitleContent (f, node, version)
49 _name = node->string_child ("Name");
50 _has_subtitles = node->bool_child ("HasSubtitles");
51 _directory = node->string_child ("Directory");
55 DCPContent::read_directory (boost::filesystem::path p)
57 for (boost::filesystem::directory_iterator i(p); i != boost::filesystem::directory_iterator(); ++i) {
58 if (boost::filesystem::is_regular_file (i->path ())) {
59 _paths.push_back (i->path ());
60 } else if (boost::filesystem::is_directory (i->path ())) {
61 read_directory (i->path ());
67 DCPContent::examine (shared_ptr<Job> job)
69 job->set_progress_unknown ();
70 Content::examine (job);
72 shared_ptr<DCPExaminer> examiner (new DCPExaminer (shared_from_this ()));
73 take_from_video_examiner (examiner);
74 take_from_audio_examiner (examiner);
76 boost::mutex::scoped_lock lm (_mutex);
77 _name = examiner->name ();
78 _has_subtitles = examiner->has_subtitles ();
82 DCPContent::summary () const
84 boost::mutex::scoped_lock lm (_mutex);
85 return String::compose (_("%1 [DCP]"), _name);
89 DCPContent::technical_summary () const
91 return Content::technical_summary() + " - "
92 + VideoContent::technical_summary() + " - "
93 + AudioContent::technical_summary() + " - ";
97 DCPContent::as_xml (xmlpp::Node* node) const
99 node->add_child("Type")->add_child_text ("DCP");
101 Content::as_xml (node);
102 VideoContent::as_xml (node);
103 SingleStreamAudioContent::as_xml (node);
104 SubtitleContent::as_xml (node);
106 boost::mutex::scoped_lock lm (_mutex);
107 node->add_child("Name")->add_child_text (_name);
108 node->add_child("HasSubtitles")->add_child_text (_has_subtitles ? "1" : "0");
109 node->add_child("Directory")->add_child_text (_directory.string ());
113 DCPContent::full_length () const
115 shared_ptr<const Film> film = _film.lock ();
117 return DCPTime (video_length (), FrameRateChange (video_frame_rate (), film->video_frame_rate ()));
121 DCPContent::identifier () const
123 return SubtitleContent::identifier ();
127 DCPContent::has_subtitles () const
129 boost::mutex::scoped_lock lm (_mutex);
130 return _has_subtitles;