X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=test%2Fseek_zero_test.cc;h=682fa93555742461f93f556cd714231685c51c23;hb=9e4c091e6ef0f79fab10664e95240de2f14e5702;hp=22004bcb8c876a2ea37f09b8af688f476f2fbafe;hpb=09806bc8d6a48fc79d923ec1cdf6f90176bf8b6a;p=dcpomatic.git diff --git a/test/seek_zero_test.cc b/test/seek_zero_test.cc index 22004bcb8..682fa9355 100644 --- a/test/seek_zero_test.cc +++ b/test/seek_zero_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Carl Hetherington + Copyright (C) 2013-2014 Carl Hetherington This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,11 +28,15 @@ #include "lib/ratio.h" #include "lib/dcp_content_type.h" #include "lib/ffmpeg_decoder.h" +#include "lib/ffmpeg_audio_stream.h" +#include "lib/content_video.h" #include "test.h" using std::cout; +using std::list; using boost::shared_ptr; using boost::dynamic_pointer_cast; +using boost::optional; BOOST_AUTO_TEST_CASE (seek_zero_test) { @@ -45,13 +49,18 @@ BOOST_AUTO_TEST_CASE (seek_zero_test) film->examine_and_add_content (content); wait_for_jobs (); - FFmpegDecoder decoder (film, content, true, false); - shared_ptr a = dynamic_pointer_cast (decoder.peek ()); - decoder.seek (ContentTime(), true); - shared_ptr b = dynamic_pointer_cast (decoder.peek ()); + /* Work out the first video frame index that we will be given, taking into account + * the difference between first video and first audio. + */ + ContentTime video_delay = content->first_video().get() - content->audio_stream()->first_audio.get(); + if (video_delay < ContentTime ()) { + video_delay = ContentTime (); + } - /* a will be after no seek, and b after a seek to zero, which should - have the same effect. - */ - BOOST_CHECK_EQUAL (a->content_time, b->content_time); + VideoFrame const first_frame = video_delay.round_up (content->video_frame_rate ()).frames (content->video_frame_rate ()); + + FFmpegDecoder decoder (content, film->log()); + list a = decoder.get_video (first_frame, true); + BOOST_CHECK (a.size() == 1); + BOOST_CHECK_EQUAL (a.front().frame, first_frame); }