2 Copyright (C) 2012 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 #ifndef LIBDCP_SUBTITLE_ASSET_H
21 #define LIBDCP_SUBTITLE_ASSET_H
23 #include <libcxml/cxml.h>
58 std::string font () const {
62 bool italic () const {
66 Color color () const {
78 std::string text () const {
82 void set_text (std::string t) {
86 float v_position () const {
90 VAlign v_align () const {
94 HAlign h_align () const {
98 Effect effect () const {
102 Color effect_color () const {
103 return _effect_color;
106 Time fade_up_time () const {
107 return _fade_up_time;
110 Time fade_down_time () const {
111 return _fade_down_time;
118 int size_in_pixels (int screen_height) const;
124 /** Size in points as if the screen height is 11 inches, so a 72pt font
125 * would be 1/11th of the screen height.
130 /** Vertical position as a proportion of the screen height from the top
131 * (between 0 and 100).
140 Time _fade_down_time;
143 bool operator== (Subtitle const & a, Subtitle const & b);
144 std::ostream& operator<< (std::ostream& s, Subtitle const & sub);
146 class SubtitleAsset : public Asset
149 SubtitleAsset (std::string directory, std::string xml_file);
150 SubtitleAsset (std::string directory, std::string movie_title, std::string language);
152 void write_to_cpl (xmlpp::Element *) const;
153 virtual bool equals (boost::shared_ptr<const Asset>, EqualityOptions, boost::function<void (NoteType, std::string)> note) const {
155 note (ERROR, "subtitle assets not compared yet");
159 std::string language () const {
163 std::list<boost::shared_ptr<Subtitle> > subtitles_during (Time from, Time to) const;
164 std::list<boost::shared_ptr<Subtitle> > const & subtitles () const {
168 void add (boost::shared_ptr<Subtitle>);
170 void read_xml (std::string);
171 void write_xml () const;
172 Glib::ustring xml_as_string () const;
176 std::string asdcp_kind () const {
181 std::string font_id_to_name (std::string id) const;
182 void read_mxf (std::string);
183 void read_xml (boost::shared_ptr<cxml::Document>, bool smpte);
186 std::list<boost::shared_ptr<parse::Font> > font_nodes;
187 std::list<boost::shared_ptr<parse::Text> > text_nodes;
188 std::list<boost::shared_ptr<parse::Subtitle> > subtitle_nodes;
189 boost::shared_ptr<Subtitle> current;
192 void parse_node (xmlpp::Node* node, ParseState& parse_state, boost::optional<int> tcr);
193 void maybe_add_subtitle (std::string text, ParseState& parse_state);
195 boost::optional<std::string> _movie_title;
196 /* strangely, this is sometimes a string */
197 std::string _reel_number;
198 std::string _language;
199 std::list<boost::shared_ptr<parse::LoadFont> > _load_font_nodes;
201 std::list<boost::shared_ptr<Subtitle> > _subtitles;