X-Git-Url: https://main.carlh.net/gitweb/?p=dcpomatic.git;a=blobdiff_plain;f=src%2Flib%2Fdecoder.cc;h=52949a0989d83be7895f2117591a3dc7fedadc17;hp=e538a51d4af06a65c718e4eae0a5c8dfee46c993;hb=df17bbd25da69fc38eb2dcd8b4a2531cf0bab0bc;hpb=a28ef704adf8c5bfa45b3d6285f741af64758ceb diff --git a/src/lib/decoder.cc b/src/lib/decoder.cc index e538a51d4..52949a098 100644 --- a/src/lib/decoder.cc +++ b/src/lib/decoder.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2015 Carl Hetherington + Copyright (C) 2012-2018 Carl Hetherington This file is part of DCP-o-matic. @@ -19,19 +19,59 @@ */ #include "decoder.h" -#include "decoder_part.h" +#include "video_decoder.h" +#include "audio_decoder.h" +#include "text_decoder.h" +#include #include using std::cout; using boost::optional; +using boost::shared_ptr; + +/** @return Earliest time of content that the next pass() will emit */ +ContentTime +Decoder::position () const +{ + optional pos; + + if (video && !video->ignore() && (!pos || video->position() < *pos)) { + pos = video->position(); + } + + if (audio && !audio->ignore() && (!pos || audio->position() < *pos)) { + pos = audio->position(); + } + + BOOST_FOREACH (shared_ptr i, caption) { + if (!i->ignore() && (!pos || i->position() < *pos)) { + pos = i->position(); + } + } + + return pos.get_value_or(ContentTime()); +} void -Decoder::maybe_seek (opional position, ContentTime time, bool accurate) +Decoder::seek (ContentTime, bool) { - if (position && (time >= position.get() && time < (position.get() + ContentTime::from_seconds(1)))) { - /* No need to seek: caller should just pass() */ - return; + if (video) { + video->seek (); + } + if (audio) { + audio->seek (); + } + BOOST_FOREACH (shared_ptr i, caption) { + i->seek (); } +} - seek (time, accurate); +shared_ptr +Decoder::only_caption () const +{ + DCPOMATIC_ASSERT (caption.size() < 2); + if (caption.empty ()) { + return shared_ptr (); + } + return caption.front (); }