if ((*_reel)->main_subtitle() && (_decode_referenced || !_dcp_content->reference_subtitle())) {
int64_t const entry_point = (*_reel)->main_subtitle()->entry_point ();
- list<dcp::SubtitleString> subs = (*_reel)->main_subtitle()->asset()->subtitles_during (
+ list<shared_ptr<dcp::Subtitle> > subs = (*_reel)->main_subtitle()->asset()->subtitles_during (
dcp::Time (entry_point + frame, vfr, vfr),
dcp::Time (entry_point + frame + 1, vfr, vfr),
true
);
- BOOST_FOREACH (dcp::SubtitleString i, subs) {
- list<dcp::SubtitleString> s;
- s.push_back (i);
- subtitle->emit_text (
- 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
- );
+ 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);
+ subtitle->emit_text (
+ 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 */
}
}
}
/*
- Copyright (C) 2014-2016 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2014-2018 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
using std::list;
using std::cout;
using boost::shared_ptr;
+using boost::dynamic_pointer_cast;
using boost::bind;
DCPSubtitleDecoder::DCPSubtitleDecoder (shared_ptr<const DCPSubtitleContent> content, shared_ptr<Log> log)
Decoder::seek (time, accurate);
_next = _subtitles.begin ();
- list<dcp::SubtitleString>::const_iterator i = _subtitles.begin ();
- while (i != _subtitles.end() && ContentTime::from_seconds (_next->in().as_seconds()) < time) {
+ list<shared_ptr<dcp::Subtitle> >::const_iterator i = _subtitles.begin ();
+ while (i != _subtitles.end() && ContentTime::from_seconds ((*_next)->in().as_seconds()) < time) {
++i;
}
}
ContentTimePeriod const p = content_time_period (*_next);
while (_next != _subtitles.end () && content_time_period (*_next) == p) {
- s.push_back (*_next);
- ++_next;
+ shared_ptr<dcp::SubtitleString> ns = dynamic_pointer_cast<dcp::SubtitleString>(*_next);
+ if (ns) {
+ s.push_back (*ns);
+ ++_next;
+ }
+
+ /* XXX: image subtitles */
}
subtitle->emit_text (p, s);
}
ContentTimePeriod
-DCPSubtitleDecoder::content_time_period (dcp::SubtitleString s) const
+DCPSubtitleDecoder::content_time_period (shared_ptr<dcp::Subtitle> s) const
{
return ContentTimePeriod (
- ContentTime::from_seconds (s.in().as_seconds ()),
- ContentTime::from_seconds (s.out().as_seconds ())
+ ContentTime::from_seconds (s->in().as_seconds ()),
+ ContentTime::from_seconds (s->out().as_seconds ())
);
}
void seek (ContentTime time, bool accurate);
private:
- ContentTimePeriod content_time_period (dcp::SubtitleString s) const;
+ ContentTimePeriod content_time_period (boost::shared_ptr<dcp::Subtitle> s) const;
- std::list<dcp::SubtitleString> _subtitles;
- std::list<dcp::SubtitleString>::const_iterator _next;
+ std::list<boost::shared_ptr<dcp::Subtitle> > _subtitles;
+ std::list<boost::shared_ptr<dcp::Subtitle> >::const_iterator _next;
};
BOOST_FOREACH (SubtitleString i, subs.text) {
i.set_in (i.in() - dcp::Time (_period.from.seconds(), i.in().tcr));
i.set_out (i.out() - dcp::Time (_period.from.seconds(), i.out().tcr));
- _subtitle_asset->add (i);
+ _subtitle_asset->add (shared_ptr<dcp::Subtitle>(new dcp::SubtitleString(i)));
}
}