Remove unnecessary stuff.
[libdcp.git] / src / subtitle_asset.h
1 /*
2     Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
3
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.
8
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.
13
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.
17
18 */
19
20 #include "asset.h"
21 #include "xml.h"
22 #include "dcp_time.h"
23
24 namespace libdcp
25 {
26
27 class TextNode : public XMLNode
28 {
29 public:
30         TextNode () {}
31         TextNode (xmlpp::Node const * node);
32
33         float v_position;
34         std::string text;
35 };
36
37 class SubtitleNode : public XMLNode
38 {
39 public:
40         SubtitleNode () {}
41         SubtitleNode (xmlpp::Node const * node);
42
43         Time in;
44         Time out;
45         std::list<boost::shared_ptr<TextNode> > text_nodes;
46 };
47
48 class FontNode : public XMLNode
49 {
50 public:
51         FontNode () {}
52         FontNode (xmlpp::Node const * node);
53
54         std::string id;
55         int size;
56         
57         std::list<boost::shared_ptr<SubtitleNode> > subtitle_nodes;
58 };
59
60 class LoadFontNode : public XMLNode
61 {
62 public:
63         LoadFontNode () {}
64         LoadFontNode (xmlpp::Node const * node);
65
66         std::string id;
67         std::string uri;
68 };
69
70 class Subtitle
71 {
72 public:
73         Subtitle (
74                 std::string font,
75                 int size,
76                 Time in,
77                 Time out,
78                 float v_position,
79                 std::string text
80                 );
81
82         std::string font () const {
83                 return _font;
84         }
85
86         Time in () const {
87                 return _in;
88         }
89
90         Time out () const {
91                 return _out;
92         }
93
94         std::string text () const {
95                 return _text;
96         }
97
98         float v_position () const {
99                 return _v_position;
100         }
101
102         int size_in_pixels (int screen_height) const;
103
104 private:
105         std::string _font;
106         int _size;
107         Time _in;
108         Time _out;
109         float _v_position;
110         std::string _text;
111 };
112
113 class SubtitleAsset : public Asset, public XMLFile
114 {
115 public:
116         SubtitleAsset (std::string directory, std::string xml);
117
118         void write_to_cpl (std::ostream&) const {}
119         virtual std::list<std::string> equals (boost::shared_ptr<const Asset>, EqualityOptions) const {
120                 /* XXX */
121                 return std::list<std::string> ();
122         }
123
124         std::string language () const {
125                 return _language;
126         }
127
128         std::list<boost::shared_ptr<Subtitle> > subtitles_at (Time t) const;
129
130 private:
131         std::string font_id_to_name (std::string id, std::list<boost::shared_ptr<LoadFontNode> > const & load_font_nodes) const;
132         
133         std::string _subtitle_id;
134         std::string _movie_title;
135         int64_t _reel_number;
136         std::string _language;
137
138         std::list<boost::shared_ptr<Subtitle> > _subtitles;
139 };
140
141 }