From c943bc82e8d585d85ca1b4832e258436fa7615ce Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sun, 12 Jan 2014 22:55:02 +0000 Subject: Some work on SubRip content length. --- src/lib/subrip.cc | 11 +++++++++++ src/lib/subrip.h | 2 ++ src/lib/subrip_content.cc | 12 +++++++++--- src/lib/subrip_content.h | 3 +++ 4 files changed, 25 insertions(+), 3 deletions(-) (limited to 'src/lib') diff --git a/src/lib/subrip.cc b/src/lib/subrip.cc index 50931e12a..1fdadf87e 100644 --- a/src/lib/subrip.cc +++ b/src/lib/subrip.cc @@ -213,3 +213,14 @@ SubRip::convert_content (list t) return pieces; } + +Time +SubRip::length () const +{ + boost::mutex::scoped_lock lm (_mutex); + if (_subtitles.empty ()) { + return 0; + } + + return _subtitles.back().to; +} diff --git a/src/lib/subrip.h b/src/lib/subrip.h index a8d8104c4..0f4fe5d29 100644 --- a/src/lib/subrip.h +++ b/src/lib/subrip.h @@ -29,6 +29,8 @@ class SubRip public: SubRip (boost::shared_ptr); + Time length () const; + private: friend class subrip_time_test; friend class subrip_coordinate_test; diff --git a/src/lib/subrip_content.cc b/src/lib/subrip_content.cc index 79a1d4999..74bba33ba 100644 --- a/src/lib/subrip_content.cc +++ b/src/lib/subrip_content.cc @@ -41,9 +41,12 @@ SubRipContent::SubRipContent (shared_ptr film, shared_ptr) +SubRipContent::examine (boost::shared_ptr job) { - + Content::examine (job); + SubRip s (shared_from_this ()); + boost::mutex::scoped_lock lm (_mutex); + _length = s.length (); } string @@ -75,7 +78,10 @@ SubRipContent::as_xml (xmlpp::Node* node) Time SubRipContent::full_length () const { - + /* XXX: this assumes that the timing of the SubRip file is appropriate + for the DCP's frame rate. + */ + return _length; } string diff --git a/src/lib/subrip_content.h b/src/lib/subrip_content.h index 1551081b6..741e1a4c3 100644 --- a/src/lib/subrip_content.h +++ b/src/lib/subrip_content.h @@ -32,4 +32,7 @@ public: void as_xml (xmlpp::Node *); Time full_length () const; std::string identifier () const; + +private: + Time _length; }; -- cgit v1.2.3