Fix handling of timing in SMPTE subtitles.
[libdcp.git] / src / subtitle_content.h
index b05fe59c51aeda5034a290fcd41d6b413d8687ef..0ef7b19d478a3e3438cadcf997c2160fae7c953e 100644 (file)
@@ -35,36 +35,25 @@ class Subtitle;
 class LoadFont;
 
 /** @class SubtitleContent
- *  @brief A representation of an XML or MXF file containing subtitles.
- *
- *  XXX: perhaps this should inhert from MXF, or there should be different
- *  classes for XML and MXF subs.
+ *  @brief A parent for classes representing a file containing subtitles.
  */
 class SubtitleContent : public Content
 {
 public:
-       /** Construct a SubtitleContent.
-        *  @param file Filename.
-        *  @param mxf true if the file is an MXF file, false for XML.
-        */
-       SubtitleContent (boost::filesystem::path file, bool mxf);
-       SubtitleContent (std::string movie_title, std::string language);
+       SubtitleContent ();
+       SubtitleContent (boost::filesystem::path file);
 
        bool equals (
-               boost::shared_ptr<const Content>,
+               boost::shared_ptr<const Asset>,
                EqualityOptions,
-               boost::function<void (NoteType, std::string)> note
-               ) const {
-               /* XXX */
-               note (DCP_ERROR, "subtitle content not compared yet");
-               return true;
-       }
+               NoteHandler note
+               ) const;
 
        std::string language () const {
                return _language;
        }
 
-       std::list<SubtitleString> subtitles_at (Time t) const;
+       std::list<SubtitleString> subtitles_during (Time from, Time to) const;
        std::list<SubtitleString> const & subtitles () const {
                return _subtitles;
        }
@@ -72,11 +61,18 @@ public:
        void add (SubtitleString);
 
        void write_xml (boost::filesystem::path) const;
-       Glib::ustring xml_as_string () const;
+       virtual Glib::ustring xml_as_string () const {
+               /* XXX: this should be pure virtual when SMPTE writing is implemented */
+               return "";
+       }
 
        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";
        }
@@ -85,9 +81,13 @@ protected:
                return "Subtitle";
        }
        
-private:
-       std::string font_id_to_name (std::string id) const;
+       /* 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;
@@ -107,14 +107,6 @@ private:
                std::list<boost::shared_ptr<Text> > const & text_nodes,
                ParseState& parse_state
                );
-
-       boost::optional<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<SubtitleString> _subtitles;
 };
 
 }