2 Copyright (C) 2014-2018 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 "string_text_file_content.h"
23 #include "string_text_file.h"
26 #include "text_content.h"
27 #include <dcp/raw_convert.h>
28 #include <libxml++/libxml++.h>
35 using boost::shared_ptr;
36 using boost::optional;
37 using dcp::raw_convert;
38 using namespace dcpomatic;
40 StringTextFileContent::StringTextFileContent (boost::filesystem::path path)
43 text.push_back (shared_ptr<TextContent> (new TextContent (this, TEXT_OPEN_SUBTITLE, TEXT_UNKNOWN)));
46 StringTextFileContent::StringTextFileContent (cxml::ConstNodePtr node, int version)
48 , _length (node->number_child<ContentTime::Type> ("Length"))
50 text = TextContent::from_xml (this, node, version);
54 StringTextFileContent::examine (shared_ptr<const Film> film, shared_ptr<Job> job)
56 Content::examine (film, job);
57 StringTextFile s (shared_from_this ());
59 /* Default to turning these subtitles on */
60 only_text()->set_use (true);
62 boost::mutex::scoped_lock lm (_mutex);
63 _length = s.length ();
64 only_text()->add_font (shared_ptr<Font> (new Font (TEXT_FONT_ID)));
68 StringTextFileContent::summary () const
70 return path_summary() + " " + _("[subtitles]");
74 StringTextFileContent::technical_summary () const
76 return Content::technical_summary() + " - " + _("Text subtitles");
80 StringTextFileContent::as_xml (xmlpp::Node* node, bool with_paths) const
82 node->add_child("Type")->add_child_text ("TextSubtitle");
83 Content::as_xml (node, with_paths);
86 only_text()->as_xml (node);
89 node->add_child("Length")->add_child_text (raw_convert<string> (_length.get ()));
93 StringTextFileContent::full_length (shared_ptr<const Film> film) const
95 FrameRateChange const frc (film, shared_from_this());
96 return DCPTime (_length, frc);
100 StringTextFileContent::approximate_length () const
102 return DCPTime (_length, FrameRateChange());
106 StringTextFileContent::identifier () const
108 string s = Content::identifier ();
109 s += "_" + only_text()->identifier();