1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
|
/*
Copyright (C) 2013-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
DCP-o-matic is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
DCP-o-matic is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef DCPOMATIC_CAPTION_CONTENT_H
#define DCPOMATIC_CAPTION_CONTENT_H
#include "content_part.h"
#include "dcp_text_track.h"
#include <libcxml/cxml.h>
#include <dcp/language_tag.h>
#include <dcp/types.h>
#include <boost/signals2.hpp>
namespace dcpomatic {
class Font;
}
class TextContentProperty
{
public:
static int const X_OFFSET;
static int const Y_OFFSET;
static int const X_SCALE;
static int const Y_SCALE;
static int const USE;
static int const BURN;
static int const FONTS;
static int const COLOUR;
static int const EFFECT;
static int const EFFECT_COLOUR;
static int const LINE_SPACING;
static int const FADE_IN;
static int const FADE_OUT;
static int const OUTLINE_WIDTH;
static int const TYPE;
static int const DCP_TRACK;
static int const LANGUAGE;
static int const LANGUAGE_IS_ADDITIONAL;
};
/** @class TextContent
* @brief Description of how some text content should be presented.
*
* There are `bitmap' subtitles and `plain' subtitles (plain text),
* and not all of the settings in this class correspond to both types.
*/
class TextContent : public ContentPart
{
public:
TextContent (Content* parent, TextType type, TextType original_type);
TextContent (Content* parent, std::vector<std::shared_ptr<Content>>);
TextContent (Content* parent, cxml::ConstNodePtr, int version, std::list<std::string>& notes);
void as_xml (xmlpp::Node *) const;
std::string identifier () const;
void take_settings_from (std::shared_ptr<const TextContent> c);
void clear_fonts ();
void add_font (std::shared_ptr<dcpomatic::Font> font);
std::shared_ptr<dcpomatic::Font> get_font(std::string id) const;
void set_use (bool);
void set_burn (bool);
void set_x_offset (double);
void set_y_offset (double);
void set_x_scale (double);
void set_y_scale (double);
void set_colour (dcp::Colour);
void unset_colour ();
void set_effect (dcp::Effect);
void unset_effect ();
void set_effect_colour (dcp::Colour);
void unset_effect_colour ();
void set_line_spacing (double s);
void set_fade_in (dcpomatic::ContentTime);
void unset_fade_in ();
void set_fade_out (dcpomatic::ContentTime);
void set_outline_width (int);
void unset_fade_out ();
void set_type (TextType type);
void set_dcp_track (DCPTextTrack track);
void unset_dcp_track ();
void set_language (boost::optional<dcp::LanguageTag> language = boost::none);
void set_language_is_additional (bool additional);
bool use () const {
boost::mutex::scoped_lock lm (_mutex);
return _use;
}
bool burn () const {
boost::mutex::scoped_lock lm (_mutex);
return _burn;
}
double x_offset () const {
boost::mutex::scoped_lock lm (_mutex);
return _x_offset;
}
double y_offset () const {
boost::mutex::scoped_lock lm (_mutex);
return _y_offset;
}
double x_scale () const {
boost::mutex::scoped_lock lm (_mutex);
return _x_scale;
}
double y_scale () const {
boost::mutex::scoped_lock lm (_mutex);
return _y_scale;
}
std::list<std::shared_ptr<dcpomatic::Font>> fonts () const {
boost::mutex::scoped_lock lm (_mutex);
return _fonts;
}
boost::optional<dcp::Colour> colour () const {
boost::mutex::scoped_lock lm (_mutex);
return _colour;
}
boost::optional<dcp::Effect> effect () const {
boost::mutex::scoped_lock lm (_mutex);
return _effect;
}
boost::optional<dcp::Colour> effect_colour () const {
boost::mutex::scoped_lock lm (_mutex);
return _effect_colour;
}
double line_spacing () const {
boost::mutex::scoped_lock lm (_mutex);
return _line_spacing;
}
boost::optional<dcpomatic::ContentTime> fade_in () const {
boost::mutex::scoped_lock lm (_mutex);
return _fade_in;
}
boost::optional<dcpomatic::ContentTime> fade_out () const {
boost::mutex::scoped_lock lm (_mutex);
return _fade_out;
}
int outline_width () const {
boost::mutex::scoped_lock lm (_mutex);
return _outline_width;
}
TextType type () const {
boost::mutex::scoped_lock lm (_mutex);
return _type;
}
TextType original_type () const {
boost::mutex::scoped_lock lm (_mutex);
return _original_type;
}
boost::optional<DCPTextTrack> dcp_track () const {
boost::mutex::scoped_lock lm (_mutex);
return _dcp_track;
}
boost::optional<dcp::LanguageTag> language () const {
boost::mutex::scoped_lock lm (_mutex);
return _language;
}
bool language_is_additional () const {
boost::mutex::scoped_lock lm (_mutex);
return _language_is_additional;
}
static std::vector<std::shared_ptr<TextContent>> from_xml(Content* parent, cxml::ConstNodePtr, int version, std::list<std::string>& notes);
private:
friend struct ffmpeg_pts_offset_test;
void font_changed ();
void connect_to_fonts ();
std::shared_ptr<dcpomatic::Font> get_font_unlocked(std::string id) const;
std::list<boost::signals2::connection> _font_connections;
bool _use;
bool _burn;
/** x offset for placing subtitles, as a proportion of the container width;
* +ve is further right, -ve is further left.
*/
double _x_offset;
/** y offset for placing subtitles, as a proportion of the container height;
* +ve is further down the frame, -ve is further up.
*/
double _y_offset;
/** x scale factor to apply to subtitles */
double _x_scale;
/** y scale factor to apply to subtitles */
double _y_scale;
std::list<std::shared_ptr<dcpomatic::Font>> _fonts;
boost::optional<dcp::Colour> _colour;
boost::optional<dcp::Effect> _effect;
boost::optional<dcp::Colour> _effect_colour;
/** scaling factor for line spacing; 1 is "standard", < 1 is closer together, > 1 is further apart */
double _line_spacing;
boost::optional<dcpomatic::ContentTime> _fade_in;
boost::optional<dcpomatic::ContentTime> _fade_out;
int _outline_width;
/** what these captions will be used for in the output DCP (not necessarily what
* they were originally).
*/
TextType _type;
/** the original type of these captions in their content */
TextType _original_type;
/** the track of closed captions that this content should be put in, or empty to put in the default (only) track */
boost::optional<DCPTextTrack> _dcp_track;
boost::optional<dcp::LanguageTag> _language;
bool _language_is_additional = false;
};
#endif
|