Fix handling of timing in SMPTE subtitles.
[libdcp.git] / src / subtitle_content.h
index 476f8fe480c07c515aa5a74ee1a1295db1be938a..0ef7b19d478a3e3438cadcf997c2160fae7c953e 100644 (file)
@@ -22,6 +22,7 @@
 
 #include "content.h"
 #include "dcp_time.h"
+#include "subtitle_string.h"
 #include <libcxml/cxml.h>
 
 namespace dcp
@@ -34,45 +35,59 @@ class Subtitle;
 class LoadFont;
 
 /** @class SubtitleContent
- *  @brief A representation of an XML file containing subtitles.
+ *  @brief A parent for classes representing a file containing subtitles.
  */
 class SubtitleContent : public Content
 {
 public:
+       SubtitleContent ();
        SubtitleContent (boost::filesystem::path file);
-       SubtitleContent (Fraction edit_rate, std::string movie_title, std::string language);
 
-       std::string pkl_type () const {
-               return "text/xml";
-       }
-       
        bool equals (
-               boost::shared_ptr<const Content>,
+               boost::shared_ptr<const Asset>,
                EqualityOptions,
-               boost::function<void (NoteType, std::string)> note
-               ) const {
-               /* XXX */
-               note (ERROR, "subtitle content not compared yet");
-               return true;
-       }
+               NoteHandler note
+               ) const;
 
        std::string language () const {
                return _language;
        }
 
-       std::list<boost::shared_ptr<SubtitleString> > subtitles_at (Time t) const;
-       std::list<boost::shared_ptr<SubtitleString> > const & subtitles () const {
+       std::list<SubtitleString> subtitles_during (Time from, Time to) const;
+       std::list<SubtitleString> const & subtitles () const {
                return _subtitles;
        }
 
-       void add (boost::shared_ptr<SubtitleString>);
+       void add (SubtitleString);
 
-       void write_xml () const;
-       Glib::ustring xml_as_string () const;
+       void write_xml (boost::filesystem::path) const;
+       virtual Glib::ustring xml_as_string () const {
+               /* XXX: this should be pure virtual when SMPTE writing is implemented */
+               return "";
+       }
 
-private:
-       std::string font_id_to_name (std::string id) const;
+       Time latest_subtitle_out () const;
+
+       virtual std::list<boost::shared_ptr<LoadFont> > load_font_nodes () const = 0;
+
+protected:
+       void parse_common (boost::shared_ptr<cxml::Document> xml, std::list<boost::shared_ptr<Font> > font_nodes);
+       
+       std::string pkl_type (Standard) const {
+               return "text/xml";
+       }
+
+       std::string asdcp_kind () const {
+               return "Subtitle";
+       }
+       
+       /* strangely, this is sometimes a string */
+       std::string _reel_number;
+       std::string _language;
+
+       std::list<SubtitleString> _subtitles;
 
+private:
        struct ParseState {
                std::list<boost::shared_ptr<Font> > font_nodes;
                std::list<boost::shared_ptr<Text> > text_nodes;
@@ -92,15 +107,6 @@ private:
                std::list<boost::shared_ptr<Text> > const & text_nodes,
                ParseState& parse_state
                );
-
-       std::string _movie_title;
-       /* strangely, this is sometimes a string */
-       std::string _reel_number;
-       std::string _language;
-       std::list<boost::shared_ptr<LoadFont> > _load_font_nodes;
-
-       std::list<boost::shared_ptr<SubtitleString> > _subtitles;
-       bool _need_sort;
 };
 
 }