2 Copyright (C) 2012-2015 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 LIBDCP_SUBTITLE_ASSET_H
21 #define LIBDCP_SUBTITLE_ASSET_H
25 #include "subtitle_string.h"
26 #include <libcxml/cxml.h>
41 /** @class SubtitleAsset
42 * @brief A parent for classes representing a file containing subtitles.
44 class SubtitleAsset : public Asset
48 SubtitleAsset (boost::filesystem::path file);
51 boost::shared_ptr<const Asset>,
56 std::list<SubtitleString> subtitles_during (Time from, Time to) const;
57 std::list<SubtitleString> const & subtitles () const {
61 void add (SubtitleString);
63 virtual void write (boost::filesystem::path) const = 0;
64 virtual Glib::ustring xml_as_string () const = 0;
66 Time latest_subtitle_out () const;
68 virtual std::list<boost::shared_ptr<LoadFontNode> > load_font_nodes () const = 0;
71 void parse_common (boost::shared_ptr<cxml::Document> xml, std::list<boost::shared_ptr<FontNode> > font_nodes);
73 virtual std::string pkl_type (Standard) const = 0;
75 std::string asdcp_kind () const {
79 void subtitles_as_xml (xmlpp::Element* root, int time_code_rate, std::string xmlns) const;
81 std::list<SubtitleString> _subtitles;
85 std::list<boost::shared_ptr<FontNode> > font_nodes;
86 std::list<boost::shared_ptr<TextNode> > text_nodes;
87 std::list<boost::shared_ptr<SubtitleNode> > subtitle_nodes;
90 void maybe_add_subtitle (std::string text, ParseState const & parse_state);
92 void examine_font_nodes (
93 boost::shared_ptr<const cxml::Node> xml,
94 std::list<boost::shared_ptr<FontNode> > const & font_nodes,
95 ParseState& parse_state
98 void examine_text_nodes (
99 boost::shared_ptr<const cxml::Node> xml,
100 std::list<boost::shared_ptr<TextNode> > const & text_nodes,
101 ParseState& parse_state