diff options
| author | Carl Hetherington <cth@carlh.net> | 2014-12-20 22:25:55 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2014-12-20 22:25:55 +0000 |
| commit | 13a693315da47ee8c1306c92f9af2e95d4e6829e (patch) | |
| tree | 4eda98c12ba36b0df450f7d3000d1ec0f52925ac /src | |
| parent | 6e4224ae8c9efa7f9e56e511531b7f53d8bd4f9c (diff) | |
Basic comparison of subtitle assets; tweaks to InteropLoadFont.
Diffstat (limited to 'src')
| -rw-r--r-- | src/interop_load_font.cc | 19 | ||||
| -rw-r--r-- | src/interop_load_font.h | 4 | ||||
| -rw-r--r-- | src/interop_subtitle_content.cc | 45 | ||||
| -rw-r--r-- | src/interop_subtitle_content.h | 8 | ||||
| -rw-r--r-- | src/subtitle_content.cc | 32 | ||||
| -rw-r--r-- | src/subtitle_content.h | 6 |
6 files changed, 109 insertions, 5 deletions
diff --git a/src/interop_load_font.cc b/src/interop_load_font.cc index ec2653ef..c40d64c4 100644 --- a/src/interop_load_font.cc +++ b/src/interop_load_font.cc @@ -25,6 +25,13 @@ using boost::shared_ptr; using boost::optional; using namespace dcp; +InteropLoadFont::InteropLoadFont (string id_, string uri_) + : id (id_) + , uri (uri_) +{ + +} + InteropLoadFont::InteropLoadFont (shared_ptr<const cxml::Node> node) { optional<string> x = node->optional_string_attribute ("Id"); @@ -35,3 +42,15 @@ InteropLoadFont::InteropLoadFont (shared_ptr<const cxml::Node> node) uri = node->string_attribute ("URI"); } + +bool +dcp::operator== (InteropLoadFont const & a, InteropLoadFont const & b) +{ + return a.id == b.id && a.uri == b.uri; +} + +bool +dcp::operator!= (InteropLoadFont const & a, InteropLoadFont const & b) +{ + return !(a == b); +} diff --git a/src/interop_load_font.h b/src/interop_load_font.h index b6043bd0..61f63ffb 100644 --- a/src/interop_load_font.h +++ b/src/interop_load_font.h @@ -30,10 +30,14 @@ class InteropLoadFont { public: InteropLoadFont () {} + InteropLoadFont (std::string id, std::string uri); InteropLoadFont (boost::shared_ptr<const cxml::Node> node); std::string id; std::string uri; }; +bool operator== (InteropLoadFont const & a, InteropLoadFont const & b); +bool operator!= (InteropLoadFont const & a, InteropLoadFont const & b); + } diff --git a/src/interop_subtitle_content.cc b/src/interop_subtitle_content.cc index 25e49dd9..0fdee0b4 100644 --- a/src/interop_subtitle_content.cc +++ b/src/interop_subtitle_content.cc @@ -26,7 +26,9 @@ using std::list; using std::string; using boost::shared_ptr; +using boost::function; using boost::optional; +using boost::dynamic_pointer_cast; using namespace dcp; InteropSubtitleContent::InteropSubtitleContent (boost::filesystem::path file) @@ -165,3 +167,46 @@ InteropSubtitleContent::xml_as_string () const return doc.write_to_string_formatted ("UTF-8"); } +void +InteropSubtitleContent::add_font (string id, string uri) +{ + _load_font_nodes.push_back (shared_ptr<InteropLoadFont> (new InteropLoadFont (id, uri))); +} + +bool +InteropSubtitleContent::equals (shared_ptr<const Asset> other_asset, EqualityOptions options, function<void (NoteType, std::string)> note) const +{ + if (!SubtitleContent::equals (other_asset, options, note)) { + return false; + } + + shared_ptr<const InteropSubtitleContent> other = dynamic_pointer_cast<const InteropSubtitleContent> (other_asset); + if (!other) { + return false; + } + + list<shared_ptr<InteropLoadFont> >::const_iterator i = _load_font_nodes.begin (); + list<shared_ptr<InteropLoadFont> >::const_iterator j = other->_load_font_nodes.begin (); + + while (i != _load_font_nodes.end ()) { + if (j == _load_font_nodes.end ()) { + note (DCP_ERROR, "<LoadFont> nodes differ"); + return false; + } + + if (**i != **j) { + note (DCP_ERROR, "<LoadFont> nodes differ"); + return false; + } + + ++i; + ++j; + } + + if (_movie_title != other->_movie_title) { + note (DCP_ERROR, "Subtitle movie titles differ"); + return false; + } + + return true; +} diff --git a/src/interop_subtitle_content.h b/src/interop_subtitle_content.h index df834356..9dfde104 100644 --- a/src/interop_subtitle_content.h +++ b/src/interop_subtitle_content.h @@ -30,9 +30,17 @@ public: InteropSubtitleContent (std::string movie_title, std::string language); InteropSubtitleContent (boost::filesystem::path file); + bool equals ( + boost::shared_ptr<const Asset>, + EqualityOptions, + boost::function<void (NoteType, std::string)> note + ) const; + std::list<boost::shared_ptr<InteropLoadFont> > load_font_nodes () const { return _load_font_nodes; } + + void add_font (std::string id, std::string uri); Glib::ustring xml_as_string () const; diff --git a/src/subtitle_content.cc b/src/subtitle_content.cc index 7bc080b3..e2c3efb2 100644 --- a/src/subtitle_content.cc +++ b/src/subtitle_content.cc @@ -38,6 +38,8 @@ using std::stringstream; using std::cout; using boost::shared_ptr; using boost::optional; +using boost::function; +using boost::dynamic_pointer_cast; using namespace dcp; SubtitleContent::SubtitleContent (boost::filesystem::path file) @@ -184,3 +186,33 @@ SubtitleContent::latest_subtitle_out () const return t; } + +bool +SubtitleContent::equals (shared_ptr<const Asset> other_asset, EqualityOptions options, function<void (NoteType, std::string)> note) const +{ + if (!Asset::equals (other_asset, options, note)) { + return false; + } + + shared_ptr<const SubtitleContent> other = dynamic_pointer_cast<const SubtitleContent> (other_asset); + if (!other) { + return false; + } + + if (_reel_number != other->_reel_number) { + note (DCP_ERROR, "subtitle reel numbers differ"); + return false; + } + + if (_language != other->_language) { + note (DCP_ERROR, "subtitle languages differ"); + return false; + } + + if (_subtitles != other->_subtitles) { + note (DCP_ERROR, "subtitles differ"); + return false; + } + + return true; +} diff --git a/src/subtitle_content.h b/src/subtitle_content.h index 222d52cc..d5153a4c 100644 --- a/src/subtitle_content.h +++ b/src/subtitle_content.h @@ -46,11 +46,7 @@ public: 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; - } + ) const; std::string language () const { return _language; |
