From: Carl Hetherington Date: Sat, 7 Jul 2018 23:54:04 +0000 (+0100) Subject: Fix build with shared_ptr dcp::Subtitle and subclasses. X-Git-Tag: v2.13.35~8 X-Git-Url: https://git.carlh.net/gitweb/?a=commitdiff_plain;h=64a6a87dd4a3fd43665242b8a8b2b35a675a7839;hp=ccc093b159c61e811e24f427860b72343185681e;p=dcpomatic.git Fix build with shared_ptr dcp::Subtitle and subclasses. --- diff --git a/src/lib/dcp_decoder.cc b/src/lib/dcp_decoder.cc index 2433ad0fb..9893cf7fc 100644 --- a/src/lib/dcp_decoder.cc +++ b/src/lib/dcp_decoder.cc @@ -198,22 +198,27 @@ DCPDecoder::pass_subtitles (ContentTime next) if ((*_reel)->main_subtitle() && (_decode_referenced || !_dcp_content->reference_subtitle())) { int64_t const entry_point = (*_reel)->main_subtitle()->entry_point (); - list subs = (*_reel)->main_subtitle()->asset()->subtitles_during ( + list > 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 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 i, subs) { + shared_ptr is = dynamic_pointer_cast (i); + if (is) { + list 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 */ } } } diff --git a/src/lib/dcp_subtitle_decoder.cc b/src/lib/dcp_subtitle_decoder.cc index 965f9db61..46256e93e 100644 --- a/src/lib/dcp_subtitle_decoder.cc +++ b/src/lib/dcp_subtitle_decoder.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2014-2016 Carl Hetherington + Copyright (C) 2014-2018 Carl Hetherington This file is part of DCP-o-matic. @@ -26,6 +26,7 @@ using std::list; using std::cout; using boost::shared_ptr; +using boost::dynamic_pointer_cast; using boost::bind; DCPSubtitleDecoder::DCPSubtitleDecoder (shared_ptr content, shared_ptr log) @@ -47,8 +48,8 @@ DCPSubtitleDecoder::seek (ContentTime time, bool accurate) Decoder::seek (time, accurate); _next = _subtitles.begin (); - list::const_iterator i = _subtitles.begin (); - while (i != _subtitles.end() && ContentTime::from_seconds (_next->in().as_seconds()) < time) { + list >::const_iterator i = _subtitles.begin (); + while (i != _subtitles.end() && ContentTime::from_seconds ((*_next)->in().as_seconds()) < time) { ++i; } } @@ -71,8 +72,13 @@ DCPSubtitleDecoder::pass () ContentTimePeriod const p = content_time_period (*_next); while (_next != _subtitles.end () && content_time_period (*_next) == p) { - s.push_back (*_next); - ++_next; + shared_ptr ns = dynamic_pointer_cast(*_next); + if (ns) { + s.push_back (*ns); + ++_next; + } + + /* XXX: image subtitles */ } subtitle->emit_text (p, s); @@ -80,10 +86,10 @@ DCPSubtitleDecoder::pass () } ContentTimePeriod -DCPSubtitleDecoder::content_time_period (dcp::SubtitleString s) const +DCPSubtitleDecoder::content_time_period (shared_ptr 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 ()) ); } diff --git a/src/lib/dcp_subtitle_decoder.h b/src/lib/dcp_subtitle_decoder.h index 359d19145..0756a278f 100644 --- a/src/lib/dcp_subtitle_decoder.h +++ b/src/lib/dcp_subtitle_decoder.h @@ -32,8 +32,8 @@ public: void seek (ContentTime time, bool accurate); private: - ContentTimePeriod content_time_period (dcp::SubtitleString s) const; + ContentTimePeriod content_time_period (boost::shared_ptr s) const; - std::list _subtitles; - std::list::const_iterator _next; + std::list > _subtitles; + std::list >::const_iterator _next; }; diff --git a/src/lib/reel_writer.cc b/src/lib/reel_writer.cc index 16c20a536..7fca9e245 100644 --- a/src/lib/reel_writer.cc +++ b/src/lib/reel_writer.cc @@ -557,7 +557,7 @@ ReelWriter::write (PlayerSubtitles subs) 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(new dcp::SubtitleString(i))); } }