Basic subtitle test works.
[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 Text : public XMLNode
28 {
29 public:
30         Text () {}
31         Text (xmlpp::Node const * node);
32
33         float v_position () const {
34                 return _v_position;
35         }
36
37         std::string text () const {
38                 return _text;
39         }
40
41 private:
42         float _v_position;
43         std::string _text;
44 };
45
46 class Subtitle : public XMLNode
47 {
48 public:
49         Subtitle () {}
50         Subtitle (xmlpp::Node const * node);
51
52         Time in () const {
53                 return _in;
54         }
55
56         Time out () const {
57                 return _out;
58         }
59
60         std::list<boost::shared_ptr<Text> > const & texts () const {
61                 return _texts;
62         }
63
64 private:
65         std::list<boost::shared_ptr<Text> > _texts;
66         Time _in;
67         Time _out;
68 };
69
70 class Font : public XMLNode
71 {
72 public:
73         Font () {}
74         Font (xmlpp::Node const * node);
75
76         std::list<boost::shared_ptr<Subtitle> > const & subtitles () const {
77                 return _subtitles;
78         }
79
80 private:
81         std::list<boost::shared_ptr<Subtitle> > _subtitles;
82 };
83         
84 class SubtitleAsset : public Asset, public XMLFile
85 {
86 public:
87         SubtitleAsset (std::string directory, std::string xml);
88
89         void write_to_cpl (std::ostream&) const {}
90         virtual std::list<std::string> equals (boost::shared_ptr<const Asset>, EqualityOptions) const {
91                 return std::list<std::string> ();
92         }
93
94         std::string language () const {
95                 return _language;
96         }
97
98         std::list<boost::shared_ptr<Font> > const & fonts () const {
99                 return _fonts;
100         }
101
102 private:
103         std::string _subtitle_id;
104         std::string _movie_title;
105         int64_t _reel_number;
106         std::string _language;
107         std::list<boost::shared_ptr<Font> > _fonts;
108 };
109
110 }