2 Copyright (C) 2012 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 #include "subtitle_asset.h"
23 using namespace boost;
24 using namespace libdcp;
26 SubtitleAsset::SubtitleAsset (string directory, string xml)
27 : Asset (directory, xml)
28 , XMLFile (path().string(), "DCSubtitle")
30 _subtitle_id = string_node ("SubtitleID");
31 _movie_title = string_node ("MovieTitle");
32 _reel_number = int64_node ("ReelNumber");
33 _language = string_node ("Language");
35 ignore_node ("LoadFont");
37 _fonts = sub_nodes<Font> ("Font");
40 Font::Font (xmlpp::Node const * node)
43 _subtitles = sub_nodes<Subtitle> ("Subtitle");
46 Subtitle::Subtitle (xmlpp::Node const * node)
49 _in = time_attribute ("TimeIn");
50 _out = time_attribute ("TimeOut");
51 _texts = sub_nodes<Text> ("Text");
54 Text::Text (xmlpp::Node const * node)
58 _v_position = float_attribute ("VPosition");
61 list<shared_ptr<Text> >
62 SubtitleAsset::subtitles_at (Time t) const
64 for (list<shared_ptr<Font> >::const_iterator i = _fonts.begin(); i != _fonts.end(); ++i) {
65 list<shared_ptr<Text> > s = (*i)->subtitles_at (t);
71 return list<shared_ptr<Text> > ();
74 list<shared_ptr<Text> >
75 Font::subtitles_at (Time t) const
77 for (list<shared_ptr<Subtitle> >::const_iterator i = _subtitles.begin(); i != _subtitles.end(); ++i) {
78 if ((*i)->in() <= t && t <= (*i)->out()) {
79 return (*i)->texts ();
83 return list<shared_ptr<Text> > ();