Merge master.
[dcpomatic.git] / src / lib / subrip_decoder.cc
index e832c2d849d7d09a47de30a8027301d8e9cf380c..3d971fd4b4fe8516ec43d5b7111b9f095b6176be 100644 (file)
@@ -22,6 +22,7 @@
 #include "subrip_content.h"
 
 using std::list;
+using std::vector;
 using boost::shared_ptr;
 
 SubRipDecoder::SubRipDecoder (shared_ptr<const SubRipContent> content)
@@ -39,7 +40,7 @@ SubRipDecoder::seek (ContentTime time, bool accurate)
        
        _next = 0;
        list<SubRipSubtitlePiece>::const_iterator i = _subtitles[_next].pieces.begin();
-       while (i != _subtitles[_next].pieces.end() && _subtitles[_next].from < time) {
+       while (i != _subtitles[_next].pieces.end() && _subtitles[_next].period.from < time) {
                ++i;
        }
        
@@ -60,8 +61,8 @@ SubRipDecoder::pass ()
                                i->italic,
                                dcp::Color (255, 255, 255),
                                72,
-                               dcp::Time (rint (_subtitles[_next].from.seconds() * 250)),
-                               dcp::Time (rint (_subtitles[_next].to.seconds() * 250)),
+                               dcp::Time (rint (_subtitles[_next].period.from.seconds() * 250)),
+                               dcp::Time (rint (_subtitles[_next].period.to.seconds() * 250)),
                                0.9,
                                dcp::BOTTOM,
                                i->text,
@@ -77,3 +78,17 @@ SubRipDecoder::pass ()
        _next++;
        return false;
 }
+
+bool
+SubRipDecoder::has_subtitle_during (ContentTimePeriod p) const
+{
+       /* XXX: inefficient */
+
+       for (vector<SubRipSubtitle>::const_iterator i = _subtitles.begin(); i != _subtitles.end(); ++i) {
+               if (p.overlaps (i->period)) {
+                       return true;
+               }
+       }
+
+       return false;
+}