#include <dcp/subtitle_string.h>
#include "subrip_decoder.h"
+#include "subrip_content.h"
using std::list;
+using std::vector;
using boost::shared_ptr;
SubRipDecoder::SubRipDecoder (shared_ptr<const SubRipContent> content)
- : SubRip (content)
+ : SubtitleDecoder (content)
+ , SubRip (content)
, _next (0)
{
_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;
}
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,
}
text_subtitle (out);
- _next++;
+ ++_next;
return false;
}
+
+list<ContentTimePeriod>
+SubRipDecoder::subtitles_during (ContentTimePeriod p, bool starting) const
+{
+ /* XXX: inefficient */
+
+ list<ContentTimePeriod> d;
+
+ for (vector<SubRipSubtitle>::const_iterator i = _subtitles.begin(); i != _subtitles.end(); ++i) {
+ if ((starting && p.contains (i->period.from)) || (!starting && p.overlaps (i->period))) {
+ d.push_back (i->period);
+ }
+ }
+
+ return d;
+}