summaryrefslogtreecommitdiff
path: root/src/subtitle_asset.h
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2012-08-21 01:13:24 +0100
committerCarl Hetherington <cth@carlh.net>2012-08-21 01:13:24 +0100
commit8409171ec7d749a2426cca57cf6edd6714dc497d (patch)
treee20fd664c31b0a52e7fc60bdfd60f38639accd06 /src/subtitle_asset.h
parent4d91615b49a3246654baaf7a08f10f303b79b85a (diff)
De-hackify subtitle handling a bit.
Diffstat (limited to 'src/subtitle_asset.h')
-rw-r--r--src/subtitle_asset.h108
1 files changed, 70 insertions, 38 deletions
diff --git a/src/subtitle_asset.h b/src/subtitle_asset.h
index 6d584a0a..71ae1401 100644
--- a/src/subtitle_asset.h
+++ b/src/subtitle_asset.h
@@ -24,30 +24,64 @@
namespace libdcp
{
-class Text : public XMLNode
+class TextNode : public XMLNode
{
public:
- Text () {}
- Text (xmlpp::Node const * node);
+ TextNode () {}
+ TextNode (xmlpp::Node const * node);
- float v_position () const {
- return _v_position;
- }
+ float v_position;
+ std::string text;
+};
- std::string text () const {
- return _text;
- }
+class SubtitleNode : public XMLNode
+{
+public:
+ SubtitleNode () {}
+ SubtitleNode (xmlpp::Node const * node);
-private:
- float _v_position;
- std::string _text;
+ Time in;
+ Time out;
+ std::list<boost::shared_ptr<TextNode> > text_nodes;
+};
+
+class FontNode : public XMLNode
+{
+public:
+ FontNode () {}
+ FontNode (xmlpp::Node const * node);
+
+ std::string id;
+ int size;
+
+ std::list<boost::shared_ptr<SubtitleNode> > subtitle_nodes;
+};
+
+class LoadFontNode : public XMLNode
+{
+public:
+ LoadFontNode () {}
+ LoadFontNode (xmlpp::Node const * node);
+
+ std::string id;
+ std::string uri;
};
-class Subtitle : public XMLNode
+class Subtitle
{
public:
- Subtitle () {}
- Subtitle (xmlpp::Node const * node);
+ Subtitle (
+ std::string font,
+ int size,
+ Time in,
+ Time out,
+ float v_position,
+ std::string text
+ );
+
+ std::string font () const {
+ return _font;
+ }
Time in () const {
return _in;
@@ -57,32 +91,25 @@ public:
return _out;
}
- std::list<boost::shared_ptr<Text> > const & texts () const {
- return _texts;
+ std::string text () const {
+ return _text;
+ }
+
+ float v_position () const {
+ return _v_position;
}
+ int size_in_pixels (int screen_height) const;
+
private:
- std::list<boost::shared_ptr<Text> > _texts;
+ std::string _font;
+ int _size;
Time _in;
Time _out;
+ float _v_position;
+ std::string _text;
};
-class Font : public XMLNode
-{
-public:
- Font () {}
- Font (xmlpp::Node const * node);
-
- std::list<boost::shared_ptr<Subtitle> > const & subtitles () const {
- return _subtitles;
- }
-
- std::list<boost::shared_ptr<Text> > subtitles_at (Time t) const;
-
-private:
- std::list<boost::shared_ptr<Subtitle> > _subtitles;
-};
-
class SubtitleAsset : public Asset, public XMLFile
{
public:
@@ -90,6 +117,7 @@ public:
void write_to_cpl (std::ostream&) const {}
virtual std::list<std::string> equals (boost::shared_ptr<const Asset>, EqualityOptions) const {
+ /* XXX */
return std::list<std::string> ();
}
@@ -97,18 +125,22 @@ public:
return _language;
}
- std::list<boost::shared_ptr<Text> > subtitles_at (Time t) const;
+ std::list<boost::shared_ptr<Subtitle> > subtitles_at (Time t) const;
- std::list<boost::shared_ptr<Font> > const & fonts () const {
- return _fonts;
+ std::list<boost::shared_ptr<FontNode> > font_nodes () const {
+ return _font_nodes;
}
private:
+ std::string font_id_to_name (std::string id, std::list<boost::shared_ptr<LoadFontNode> > const & load_font_nodes) const;
+
std::string _subtitle_id;
std::string _movie_title;
int64_t _reel_number;
std::string _language;
- std::list<boost::shared_ptr<Font> > _fonts;
+ std::list<boost::shared_ptr<FontNode> > _font_nodes;
+
+ std::list<boost::shared_ptr<Subtitle> > _subtitles;
};
}