X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Fsubtitle_asset.h;h=6d6186a030e1809454141f49d290f55bac797a2c;hb=a106199fe8e83e136d0ecdce32f3a593f62571a9;hp=72563470c982c1609a6fba31b35c6e68c4e11a7e;hpb=78979cc6ad60c03bfc2e3757722d8e18d670a4c3;p=libdcp.git diff --git a/src/subtitle_asset.h b/src/subtitle_asset.h index 72563470..6d6186a0 100644 --- a/src/subtitle_asset.h +++ b/src/subtitle_asset.h @@ -17,72 +17,23 @@ */ +#ifndef LIBDCP_SUBTITLE_ASSET_H +#define LIBDCP_SUBTITLE_ASSET_H + +#include #include "asset.h" -#include "xml.h" #include "dcp_time.h" namespace libdcp { -class FontNode; - -class TextNode : public XMLNode -{ -public: - TextNode () {} - TextNode (xmlpp::Node const * node); - - float v_position; - VAlign v_align; - std::string text; - Time fade_up_time; - Time fade_down_time; - -private: - Time fade_time (std::string name); - -}; - -class SubtitleNode : public XMLNode -{ -public: - SubtitleNode () {} - SubtitleNode (xmlpp::Node const * node); - - Time in; - Time out; - std::list > font_nodes; - std::list > text_nodes; -}; - -class FontNode : public XMLNode +namespace parse { -public: - FontNode () {} - FontNode (xmlpp::Node const * node); - FontNode (std::list > const & font_nodes); - - std::string id; - int size; - boost::optional italic; - boost::optional color; - boost::optional effect; - boost::optional effect_color; - - std::list > subtitle_nodes; - std::list > font_nodes; - std::list > text_nodes; -}; - -class LoadFontNode : public XMLNode -{ -public: - LoadFontNode () {} - LoadFontNode (xmlpp::Node const * node); - - std::string id; - std::string uri; -}; + class Font; + class Text; + class Subtitle; + class LoadFont; +} class Subtitle { @@ -161,9 +112,15 @@ private: std::string _font; bool _italic; Color _color; + /** Size in points as if the screen height is 11 inches, so a 72pt font + * would be 1/11th of the screen height. + */ int _size; Time _in; Time _out; + /** Vertical position as a proportion of the screen height from the top + * (between 0 and 1) + */ float _v_position; VAlign _v_align; std::string _text; @@ -176,15 +133,17 @@ private: bool operator== (Subtitle const & a, Subtitle const & b); std::ostream& operator<< (std::ostream& s, Subtitle const & sub); -class SubtitleAsset : public Asset, public XMLFile +class SubtitleAsset : public Asset { public: - SubtitleAsset (std::string directory, std::string xml); + SubtitleAsset (std::string directory, std::string xml_file); + SubtitleAsset (std::string directory, std::string movie_title, std::string language); - void write_to_cpl (std::ostream&) const {} - virtual std::list equals (boost::shared_ptr, EqualityOptions) const { + void write_to_cpl (xmlpp::Element *, bool) const; + virtual bool equals (boost::shared_ptr, EqualityOptions, boost::function note) const { /* XXX */ - return std::list (); + note (ERROR, "subtitle assets not compared yet"); + return true; } std::string language () const { @@ -196,28 +155,45 @@ public: return _subtitles; } + void add (boost::shared_ptr); + + void read_xml (std::string); + void write_xml () const; + void write_xml (std::ostream &) const; + private: std::string font_id_to_name (std::string id) const; + struct ParseState { + std::list > font_nodes; + std::list > text_nodes; + std::list > subtitle_nodes; + }; + + void maybe_add_subtitle (std::string text, ParseState const & parse_state); + void examine_font_nodes ( - std::list > const & font_nodes, - std::list >& current_font_nodes, - std::list >& current_subtitle_nodes + boost::shared_ptr xml, + std::list > const & font_nodes, + ParseState& parse_state ); void examine_text_nodes ( - boost::shared_ptr subtitle_node, - std::list > const & text_nodes, - std::list >& current_font_nodes + boost::shared_ptr xml, + std::list > const & text_nodes, + ParseState& parse_state ); - - std::string _subtitle_id; + std::string _movie_title; - int64_t _reel_number; + /* strangely, this is sometimes a string */ + std::string _reel_number; std::string _language; - std::list > _load_font_nodes; + std::list > _load_font_nodes; std::list > _subtitles; + bool _need_sort; }; } + +#endif