#include "content.h"
#include "dcp_time.h"
+#include "subtitle_string.h"
#include <libcxml/cxml.h>
namespace dcp
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";
- }
-
- virtual bool equals (boost::shared_ptr<const Content>, EqualityOptions, boost::function<void (NoteType, std::string)> note) const {
- /* XXX */
- note (ERROR, "subtitle content not compared yet");
- return true;
- }
+ bool equals (
+ boost::shared_ptr<const Asset>,
+ EqualityOptions,
+ 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;
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;
};
}