From cbd4450197a083bf58bda510e626f73ba583cb66 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sat, 21 Jul 2018 15:16:18 +0100 Subject: Basics of multiple captions per content so that DCPContent can hold subs and closed captions. --- src/lib/decoder.cc | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'src/lib/decoder.cc') diff --git a/src/lib/decoder.cc b/src/lib/decoder.cc index 70eb5b61a..2fddddc91 100644 --- a/src/lib/decoder.cc +++ b/src/lib/decoder.cc @@ -27,6 +27,7 @@ using std::cout; using boost::optional; +using boost::shared_ptr; /** @return Earliest time of content that the next pass() will emit */ ContentTime @@ -42,8 +43,10 @@ Decoder::position () const pos = audio->position(); } - if (caption && !caption->ignore() && (!pos || caption->position() < *pos)) { - pos = caption->position(); + BOOST_FOREACH (shared_ptr i, caption) { + if (!i->ignore() && (!pos || i->position() < *pos)) { + pos = i->position(); + } } return pos.get_value_or(ContentTime()); @@ -58,7 +61,17 @@ Decoder::seek (ContentTime, bool) if (audio) { audio->seek (); } - if (caption) { - caption->seek (); + BOOST_FOREACH (shared_ptr i, caption) { + i->seek (); } } + +shared_ptr +Decoder::only_caption () const +{ + DCPOMATIC_ASSERT (caption.size() < 2); + if (caption.empty ()) { + return shared_ptr (); + } + return caption.front (); +} -- cgit v1.2.3