2 Copyright (C) 2013-2020 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 #ifndef DCPOMATIC_CAPTION_CONTENT_H
22 #define DCPOMATIC_CAPTION_CONTENT_H
24 #include "content_part.h"
25 #include "dcp_text_track.h"
26 #include <libcxml/cxml.h>
27 #include <dcp/types.h>
28 #include <boost/signals2.hpp>
34 class TextContentProperty
37 static int const X_OFFSET;
38 static int const Y_OFFSET;
39 static int const X_SCALE;
40 static int const Y_SCALE;
42 static int const BURN;
43 static int const FONTS;
44 static int const COLOUR;
45 static int const EFFECT;
46 static int const EFFECT_COLOUR;
47 static int const LINE_SPACING;
48 static int const FADE_IN;
49 static int const FADE_OUT;
50 static int const OUTLINE_WIDTH;
51 static int const TYPE;
52 static int const DCP_TRACK;
55 /** @class TextContent
56 * @brief Description of how some text content should be presented.
58 * There are `bitmap' subtitles and `plain' subtitles (plain text),
59 * and not all of the settings in this class correspond to both types.
61 class TextContent : public ContentPart
64 TextContent (Content* parent, TextType type, TextType original_type);
65 TextContent (Content* parent, std::vector<std::shared_ptr<Content> >);
66 TextContent (Content* parent, cxml::ConstNodePtr, int version);
68 void as_xml (xmlpp::Node *) const;
69 std::string identifier () const;
70 void take_settings_from (std::shared_ptr<const TextContent> c);
72 void add_font (std::shared_ptr<dcpomatic::Font> font);
76 void set_x_offset (double);
77 void set_y_offset (double);
78 void set_x_scale (double);
79 void set_y_scale (double);
80 void set_colour (dcp::Colour);
82 void set_effect (dcp::Effect);
84 void set_effect_colour (dcp::Colour);
85 void unset_effect_colour ();
86 void set_line_spacing (double s);
87 void set_fade_in (dcpomatic::ContentTime);
88 void unset_fade_in ();
89 void set_fade_out (dcpomatic::ContentTime);
90 void set_outline_width (int);
91 void unset_fade_out ();
92 void set_type (TextType type);
93 void set_dcp_track (DCPTextTrack track);
94 void unset_dcp_track ();
97 boost::mutex::scoped_lock lm (_mutex);
102 boost::mutex::scoped_lock lm (_mutex);
106 double x_offset () const {
107 boost::mutex::scoped_lock lm (_mutex);
111 double y_offset () const {
112 boost::mutex::scoped_lock lm (_mutex);
116 double x_scale () const {
117 boost::mutex::scoped_lock lm (_mutex);
121 double y_scale () const {
122 boost::mutex::scoped_lock lm (_mutex);
126 std::list<std::shared_ptr<dcpomatic::Font> > fonts () const {
127 boost::mutex::scoped_lock lm (_mutex);
131 boost::optional<dcp::Colour> colour () const {
132 boost::mutex::scoped_lock lm (_mutex);
136 boost::optional<dcp::Effect> effect () const {
137 boost::mutex::scoped_lock lm (_mutex);
141 boost::optional<dcp::Colour> effect_colour () const {
142 boost::mutex::scoped_lock lm (_mutex);
143 return _effect_colour;
146 double line_spacing () const {
147 boost::mutex::scoped_lock lm (_mutex);
148 return _line_spacing;
151 boost::optional<dcpomatic::ContentTime> fade_in () const {
152 boost::mutex::scoped_lock lm (_mutex);
156 boost::optional<dcpomatic::ContentTime> fade_out () const {
157 boost::mutex::scoped_lock lm (_mutex);
161 int outline_width () const {
162 boost::mutex::scoped_lock lm (_mutex);
163 return _outline_width;
166 TextType type () const {
167 boost::mutex::scoped_lock lm (_mutex);
171 TextType original_type () const {
172 boost::mutex::scoped_lock lm (_mutex);
173 return _original_type;
176 boost::optional<DCPTextTrack> dcp_track () const {
177 boost::mutex::scoped_lock lm (_mutex);
181 static std::list<std::shared_ptr<TextContent> > from_xml (Content* parent, cxml::ConstNodePtr, int version);
184 friend struct ffmpeg_pts_offset_test;
186 void font_changed ();
187 void connect_to_fonts ();
189 std::list<boost::signals2::connection> _font_connections;
193 /** x offset for placing subtitles, as a proportion of the container width;
194 * +ve is further right, -ve is further left.
197 /** y offset for placing subtitles, as a proportion of the container height;
198 * +ve is further down the frame, -ve is further up.
201 /** x scale factor to apply to subtitles */
203 /** y scale factor to apply to subtitles */
205 std::list<std::shared_ptr<dcpomatic::Font> > _fonts;
206 boost::optional<dcp::Colour> _colour;
207 boost::optional<dcp::Effect> _effect;
208 boost::optional<dcp::Colour> _effect_colour;
209 /** scaling factor for line spacing; 1 is "standard", < 1 is closer together, > 1 is further apart */
210 double _line_spacing;
211 boost::optional<dcpomatic::ContentTime> _fade_in;
212 boost::optional<dcpomatic::ContentTime> _fade_out;
214 /** what these captions will be used for in the output DCP (not necessarily what
215 * they were originally).
218 /** the original type of these captions in their content */
219 TextType _original_type;
220 /** the track of closed captions that this content should be put in, or empty to put in the default (only) track */
221 boost::optional<DCPTextTrack> _dcp_track;