2 Copyright (C) 2014-2016 Carl Hetherington <cth@carlh.net>
4 This file is part of DCP-o-matic.
6 DCP-o-matic is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 DCP-o-matic is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
21 #include "text_subtitle_content.h"
23 #include "text_subtitle.h"
26 #include "subtitle_content.h"
27 #include <dcp/raw_convert.h>
28 #include <libxml++/libxml++.h>
35 using boost::shared_ptr;
36 using dcp::raw_convert;
38 TextSubtitleContent::TextSubtitleContent (shared_ptr<const Film> film, boost::filesystem::path path)
39 : Content (film, path)
41 subtitle.reset (new SubtitleContent (this));
44 TextSubtitleContent::TextSubtitleContent (shared_ptr<const Film> film, cxml::ConstNodePtr node, int version)
45 : Content (film, node)
46 , _length (node->number_child<ContentTime::Type> ("Length"))
48 subtitle = SubtitleContent::from_xml (this, node, version);
52 TextSubtitleContent::examine (boost::shared_ptr<Job> job)
54 Content::examine (job);
55 TextSubtitle s (shared_from_this ());
57 /* Default to turning these subtitles on */
58 subtitle->set_use (true);
60 boost::mutex::scoped_lock lm (_mutex);
61 _length = s.length ();
62 subtitle->add_font (shared_ptr<Font> (new Font (TEXT_FONT_ID)));
66 TextSubtitleContent::summary () const
68 return path_summary() + " " + _("[subtitles]");
72 TextSubtitleContent::technical_summary () const
74 return Content::technical_summary() + " - " + _("Text subtitles");
78 TextSubtitleContent::as_xml (xmlpp::Node* node, bool with_paths) const
80 node->add_child("Type")->add_child_text ("TextSubtitle");
81 Content::as_xml (node, with_paths);
84 subtitle->as_xml (node);
87 node->add_child("Length")->add_child_text (raw_convert<string> (_length.get ()));
91 TextSubtitleContent::full_length () const
93 FrameRateChange const frc (active_video_frame_rate(), film()->video_frame_rate ());
94 return DCPTime (_length, frc);