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>
57 std::string font () const {
61 bool italic () const {
65 Color color () const {
77 std::string text () const {
81 void set_text (std::string t) {
85 float v_position () const {
89 VAlign v_align () const {
93 Effect effect () const {
97 Color effect_color () const {
101 Time fade_up_time () const {
102 return _fade_up_time;
105 Time fade_down_time () const {
106 return _fade_down_time;
113 int size_in_pixels (int screen_height) const;
119 /** Size in points as if the screen height is 11 inches, so a 72pt font
120 * would be 1/11th of the screen height.
125 /** Vertical position as a proportion of the screen height from the top
126 * (between 0 and 100).
134 Time _fade_down_time;
137 bool operator== (Subtitle const & a, Subtitle const & b);
138 std::ostream& operator<< (std::ostream& s, Subtitle const & sub);
140 class SubtitleAsset : public Asset
143 SubtitleAsset (std::string directory, std::string xml_file);
144 SubtitleAsset (std::string directory, std::string movie_title, std::string language);
146 void write_to_cpl (xmlpp::Element *) const;
147 virtual bool equals (boost::shared_ptr<const Asset>, EqualityOptions, boost::function<void (NoteType, std::string)> note) const {
149 note (ERROR, "subtitle assets not compared yet");
153 std::string language () const {
157 std::list<boost::shared_ptr<Subtitle> > subtitles_during (Time from, Time to) const;
158 std::list<boost::shared_ptr<Subtitle> > const & subtitles () const {
162 void add (boost::shared_ptr<Subtitle>);
164 void read_xml (std::string);
165 void write_xml () const;
166 Glib::ustring xml_as_string () const;
170 std::string asdcp_kind () const {
175 std::string font_id_to_name (std::string id) const;
176 void read_mxf (std::string);
177 void read_xml (boost::shared_ptr<cxml::Document>);
180 std::list<boost::shared_ptr<parse::Font> > font_nodes;
181 std::list<boost::shared_ptr<parse::Text> > text_nodes;
182 std::list<boost::shared_ptr<parse::Subtitle> > subtitle_nodes;
185 void maybe_add_subtitle (std::string text, ParseState const & parse_state);
187 void examine_font_nodes (
188 boost::shared_ptr<const cxml::Node> xml,
189 std::list<boost::shared_ptr<parse::Font> > const & font_nodes,
190 ParseState& parse_state
193 void examine_text_nodes (
194 boost::shared_ptr<const cxml::Node> xml,
195 std::list<boost::shared_ptr<parse::Text> > const & text_nodes,
196 ParseState& parse_state
199 boost::optional<std::string> _movie_title;
200 /* strangely, this is sometimes a string */
201 std::string _reel_number;
202 std::string _language;
203 std::list<boost::shared_ptr<parse::LoadFont> > _load_font_nodes;
205 std::list<boost::shared_ptr<Subtitle> > _subtitles;