summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2014-01-12 22:55:02 +0000
committerCarl Hetherington <cth@carlh.net>2014-01-12 22:55:02 +0000
commitc943bc82e8d585d85ca1b4832e258436fa7615ce (patch)
tree395b66bf9560dc4e4e20ab7219c005f5078bf4cb /src/lib
parent7e2cf1a4a04828b5a57d5eb6869475a819005602 (diff)
Some work on SubRip content length.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/subrip.cc11
-rw-r--r--src/lib/subrip.h2
-rw-r--r--src/lib/subrip_content.cc12
-rw-r--r--src/lib/subrip_content.h3
4 files changed, 25 insertions, 3 deletions
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<string> 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<SubRipContent>);
+ 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<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
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;
};