From 24e890682b3f2aa211277ad8b6b3591f2026d4be Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sat, 19 Nov 2016 00:31:37 +0000 Subject: Cope with offsets between video/audio/subtitle data in a muxed file. --- src/lib/decoder.cc | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) (limited to 'src/lib/decoder.cc') diff --git a/src/lib/decoder.cc b/src/lib/decoder.cc index cba674d04..50356da78 100644 --- a/src/lib/decoder.cc +++ b/src/lib/decoder.cc @@ -19,20 +19,42 @@ */ #include "decoder.h" +#include + +using std::cout; +using boost::optional; void -Decoder::maybe_seek (ContentTime time, bool accurate) +Decoder::maybe_seek (optional& position, ContentTime time, bool accurate) { - if (!_position) { + if (!position) { /* A seek has just happened */ return; } - if (time >= *_position && time < (*_position + ContentTime::from_seconds(1))) { + if (time >= *position && time < (*position + ContentTime::from_seconds(1))) { /* No need to seek: caller should just pass() */ return; } - _position.reset (); + position.reset (); seek (time, accurate); } + +void +Decoder::maybe_seek_video (ContentTime time, bool accurate) +{ + maybe_seek (_video_position, time, accurate); +} + +void +Decoder::maybe_seek_audio (ContentTime time, bool accurate) +{ + maybe_seek (_audio_position, time, accurate); +} + +void +Decoder::maybe_seek_subtitle (ContentTime time, bool accurate) +{ + maybe_seek (_subtitle_position, time, accurate); +} -- cgit v1.2.3