2 Copyright (C) 2013-2016 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 DCPOMATIC_SUBTITLE_CONTENT_H
21 #define DCPOMATIC_SUBTITLE_CONTENT_H
23 #include "content_part.h"
24 #include <libcxml/cxml.h>
25 #include <dcp/types.h>
26 #include <boost/signals2.hpp>
30 class SubtitleContentProperty
33 static int const X_OFFSET;
34 static int const Y_OFFSET;
35 static int const X_SCALE;
36 static int const Y_SCALE;
38 static int const BURN;
39 static int const LANGUAGE;
40 static int const FONTS;
41 static int const COLOUR;
42 static int const OUTLINE;
43 static int const OUTLINE_COLOUR;
46 class SubtitleContent : public ContentPart
49 SubtitleContent (Content* parent, boost::shared_ptr<const Film>);
50 SubtitleContent (Content* parent, boost::shared_ptr<const Film>, cxml::ConstNodePtr, int version);
51 SubtitleContent (Content* parent, boost::shared_ptr<const Film>, std::vector<boost::shared_ptr<Content> >);
53 void as_xml (xmlpp::Node *) const;
54 std::string identifier () const;
56 bool has_image_subtitles () const {
61 void add_font (boost::shared_ptr<Font> font);
65 void set_x_offset (double);
66 void set_y_offset (double);
67 void set_x_scale (double);
68 void set_y_scale (double);
69 void set_language (std::string language);
72 boost::mutex::scoped_lock lm (_mutex);
77 boost::mutex::scoped_lock lm (_mutex);
81 double x_offset () const {
82 boost::mutex::scoped_lock lm (_mutex);
86 double y_offset () const {
87 boost::mutex::scoped_lock lm (_mutex);
91 double x_scale () const {
92 boost::mutex::scoped_lock lm (_mutex);
96 double y_scale () const {
97 boost::mutex::scoped_lock lm (_mutex);
101 std::list<boost::shared_ptr<Font> > fonts () const {
102 boost::mutex::scoped_lock lm (_mutex);
106 std::string language () const {
107 boost::mutex::scoped_lock lm (_mutex);
111 void set_colour (dcp::Colour);
113 dcp::Colour colour () const {
114 boost::mutex::scoped_lock lm (_mutex);
118 void set_outline (bool);
120 bool outline () const {
121 boost::mutex::scoped_lock lm (_mutex);
125 void set_outline_colour (dcp::Colour);
127 dcp::Colour outline_colour () const {
128 boost::mutex::scoped_lock lm (_mutex);
129 return _outline_colour;
133 /** subtitle language (e.g. "German") or empty if it is not known */
134 std::string _language;
137 friend struct ffmpeg_pts_offset_test;
138 void font_changed ();
139 void connect_to_fonts ();
143 /** x offset for placing subtitles, as a proportion of the container width;
144 * +ve is further right, -ve is further left.
147 /** y offset for placing subtitles, as a proportion of the container height;
148 * +ve is further down the frame, -ve is further up.
151 /** x scale factor to apply to subtitles */
153 /** y scale factor to apply to subtitles */
155 std::list<boost::shared_ptr<Font> > _fonts;
158 dcp::Colour _outline_colour;
159 std::list<boost::signals2::connection> _font_connections;