No-op; fix GPL address and use the explicit-program-name version.
[dcpomatic.git] / src / lib / subtitle_content.h
1 /*
2     Copyright (C) 2013-2016 Carl Hetherington <cth@carlh.net>
3
4     This file is part of DCP-o-matic.
5
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.
10
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.
15
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/>.
18
19 */
20
21 #ifndef DCPOMATIC_SUBTITLE_CONTENT_H
22 #define DCPOMATIC_SUBTITLE_CONTENT_H
23
24 #include "content_part.h"
25 #include <libcxml/cxml.h>
26 #include <dcp/types.h>
27 #include <boost/signals2.hpp>
28
29 class Font;
30
31 class SubtitleContentProperty
32 {
33 public:
34         static int const X_OFFSET;
35         static int const Y_OFFSET;
36         static int const X_SCALE;
37         static int const Y_SCALE;
38         static int const USE;
39         static int const BURN;
40         static int const LANGUAGE;
41         static int const FONTS;
42         static int const COLOUR;
43         static int const OUTLINE;
44         static int const OUTLINE_COLOUR;
45 };
46
47 class SubtitleContent : public ContentPart
48 {
49 public:
50         SubtitleContent (Content* parent);
51         SubtitleContent (Content* parent, std::vector<boost::shared_ptr<Content> >);
52
53         void as_xml (xmlpp::Node *) const;
54         std::string identifier () const;
55
56         bool has_image_subtitles () const {
57                 /* XXX */
58                 return true;
59         }
60
61         void add_font (boost::shared_ptr<Font> font);
62
63         void set_use (bool);
64         void set_burn (bool);
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);
70
71         bool use () const {
72                 boost::mutex::scoped_lock lm (_mutex);
73                 return _use;
74         }
75
76         bool burn () const {
77                 boost::mutex::scoped_lock lm (_mutex);
78                 return _burn;
79         }
80
81         double x_offset () const {
82                 boost::mutex::scoped_lock lm (_mutex);
83                 return _x_offset;
84         }
85
86         double y_offset () const {
87                 boost::mutex::scoped_lock lm (_mutex);
88                 return _y_offset;
89         }
90
91         double x_scale () const {
92                 boost::mutex::scoped_lock lm (_mutex);
93                 return _x_scale;
94         }
95
96         double y_scale () const {
97                 boost::mutex::scoped_lock lm (_mutex);
98                 return _y_scale;
99         }
100
101         std::list<boost::shared_ptr<Font> > fonts () const {
102                 boost::mutex::scoped_lock lm (_mutex);
103                 return _fonts;
104         }
105
106         std::string language () const {
107                 boost::mutex::scoped_lock lm (_mutex);
108                 return _language;
109         }
110
111         void set_colour (dcp::Colour);
112
113         dcp::Colour colour () const {
114                 boost::mutex::scoped_lock lm (_mutex);
115                 return _colour;
116         }
117
118         void set_outline (bool);
119
120         bool outline () const {
121                 boost::mutex::scoped_lock lm (_mutex);
122                 return _outline;
123         }
124
125         void set_outline_colour (dcp::Colour);
126
127         dcp::Colour outline_colour () const {
128                 boost::mutex::scoped_lock lm (_mutex);
129                 return _outline_colour;
130         }
131
132         static boost::shared_ptr<SubtitleContent> from_xml (Content* parent, cxml::ConstNodePtr, int version);
133
134 protected:
135         /** subtitle language (e.g. "German") or empty if it is not known */
136         std::string _language;
137
138 private:
139         friend struct ffmpeg_pts_offset_test;
140
141         SubtitleContent (Content* parent, cxml::ConstNodePtr, int version);
142         void font_changed ();
143         void connect_to_fonts ();
144
145         bool _use;
146         bool _burn;
147         /** x offset for placing subtitles, as a proportion of the container width;
148          * +ve is further right, -ve is further left.
149          */
150         double _x_offset;
151         /** y offset for placing subtitles, as a proportion of the container height;
152          *  +ve is further down the frame, -ve is further up.
153          */
154         double _y_offset;
155         /** x scale factor to apply to subtitles */
156         double _x_scale;
157         /** y scale factor to apply to subtitles */
158         double _y_scale;
159         std::list<boost::shared_ptr<Font> > _fonts;
160         dcp::Colour _colour;
161         bool _outline;
162         dcp::Colour _outline_colour;
163         std::list<boost::signals2::connection> _font_connections;
164 };
165
166 #endif