+void
+DCPDecoder::pass_texts (ContentTime next)
+{
+ list<shared_ptr<TextDecoder> >::const_iterator decoder = text.begin ();
+ if ((*_reel)->main_subtitle()) {
+ DCPOMATIC_ASSERT (decoder != text.end ());
+ pass_texts (
+ next, (*_reel)->main_subtitle()->asset(), _dcp_content->reference_text(TEXT_OPEN_SUBTITLE), (*_reel)->main_subtitle()->entry_point(), *decoder
+ );
+ ++decoder;
+ }
+ if ((*_reel)->closed_caption()) {
+ DCPOMATIC_ASSERT (decoder != text.end ());
+ pass_texts (
+ next, (*_reel)->closed_caption()->asset(), _dcp_content->reference_text(TEXT_CLOSED_CAPTION), (*_reel)->closed_caption()->entry_point(), *decoder
+ );
+ ++decoder;
+ }
+}
+
+void
+DCPDecoder::pass_texts (ContentTime next, shared_ptr<dcp::SubtitleAsset> asset, bool reference, int64_t entry_point, shared_ptr<TextDecoder> decoder)
+{
+ double const vfr = _dcp_content->active_video_frame_rate ();
+ /* Frame within the (played part of the) reel that is coming up next */
+ int64_t const frame = next.frames_round (vfr);
+
+ if (_decode_referenced || !reference) {
+ list<shared_ptr<dcp::Subtitle> > subs = asset->subtitles_during (
+ dcp::Time (entry_point + frame, vfr, vfr),
+ dcp::Time (entry_point + frame + 1, vfr, vfr),
+ true
+ );
+
+ BOOST_FOREACH (shared_ptr<dcp::Subtitle> i, subs) {
+ shared_ptr<dcp::SubtitleString> is = dynamic_pointer_cast<dcp::SubtitleString> (i);
+ if (is) {
+ list<dcp::SubtitleString> s;
+ s.push_back (*is);
+ decoder->emit_plain (
+ ContentTimePeriod (
+ ContentTime::from_frames (_offset - entry_point, vfr) + ContentTime::from_seconds (i->in().as_seconds ()),
+ ContentTime::from_frames (_offset - entry_point, vfr) + ContentTime::from_seconds (i->out().as_seconds ())
+ ),
+ s
+ );
+ }
+
+ /* XXX: image subtitles */
+ }
+ }
+}
+