2 Copyright (C) 2014-2016 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 "text_subtitle_content.h"
22 #include "text_subtitle.h"
25 #include "raw_convert.h"
26 #include "subtitle_content.h"
27 #include <libxml++/libxml++.h>
34 using boost::shared_ptr;
36 std::string const TextSubtitleContent::font_id = "font";
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 (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) const
80 node->add_child("Type")->add_child_text ("TextSubtitle");
81 Content::as_xml (node);
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);