Some work on SubRip content length.
authorCarl Hetherington <cth@carlh.net>
Sun, 12 Jan 2014 22:55:02 +0000 (22:55 +0000)
committerCarl Hetherington <cth@carlh.net>
Sun, 12 Jan 2014 22:55:02 +0000 (22:55 +0000)
src/lib/subrip.cc
src/lib/subrip.h
src/lib/subrip_content.cc
src/lib/subrip_content.h

index 50931e12af030dfdfb383093a14cb9ee46dcf107..1fdadf87e485f79e7a7be0ea62ea22daa4ebed8c 100644 (file)
@@ -213,3 +213,14 @@ SubRip::convert_content (list<string> t)
 
        return pieces;
 }
+
+Time
+SubRip::length () const
+{
+       boost::mutex::scoped_lock lm (_mutex);
+       if (_subtitles.empty ()) {
+               return 0;
+       }
+
+       return _subtitles.back().to;
+}
index a8d8104c4f6bbe1b38111d9a4de152591f6eabb6..0f4fe5d294c557be548d8baef082b03fb728070a 100644 (file)
@@ -29,6 +29,8 @@ class SubRip
 public:
        SubRip (boost::shared_ptr<SubRipContent>);
 
+       Time length () const;
+
 private:
        friend class subrip_time_test;
        friend class subrip_coordinate_test;
index 79a1d49999acf8849fb007a68e0188ad29d81dff..74bba33bae44452bdc404bd0bef9a1ff10be54cf 100644 (file)
@@ -41,9 +41,12 @@ SubRipContent::SubRipContent (shared_ptr<const Film> film, shared_ptr<const cxml
 }
 
 void
-SubRipContent::examine (boost::shared_ptr<Job>)
+SubRipContent::examine (boost::shared_ptr<Job> 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
index 1551081b68acf9070e910f92cd8eb18dbd58e777..741e1a4c3ba5618f0ca94bbac0b9a69d798232b9 100644 (file)
@@ -32,4 +32,7 @@ public:
        void as_xml (xmlpp::Node *);
        Time full_length () const;
        std::string identifier () const;
+
+private:
+       Time _length;
 };