2 Copyright (C) 2014-2015 Carl Hetherington <cth@carlh.net>
4 This file is part of DCP-o-matic.
6 DCP-o-matic is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 DCP-o-matic is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
21 /** @file test/ffmpeg_decoder_seek_test.cc
22 * @brief Check seek() with FFmpegDecoder.
23 * @ingroup selfcontained
25 * This doesn't check that the contents of those frames are right, which
29 #include "lib/ffmpeg_content.h"
30 #include "lib/ffmpeg_decoder.h"
32 #include "lib/null_log.h"
33 #include "lib/piece_video.h"
34 #include "lib/video_decoder.h"
36 #include <boost/test/unit_test.hpp>
37 #include <boost/filesystem.hpp>
44 using std::make_shared;
45 using std::shared_ptr;
47 using boost::optional;
48 #if BOOST_VERSION >= 106100
49 using namespace boost::placeholders;
51 using namespace dcpomatic;
53 static optional<Frame> stored_frame;
63 check (shared_ptr<FFmpegDecoder> decoder, int frame)
65 BOOST_REQUIRE (decoder->ffmpeg_content()->video_frame_rate ());
66 decoder->seek (ContentTime::from_frames(frame, decoder->ffmpeg_content()->video_frame_rate().get()), true);
68 while (!decoder->done() && !stored_frame) {
71 BOOST_CHECK (*stored_frame <= frame);
75 test (boost::filesystem::path file, vector<int> frames)
77 auto path = TestPaths::private_data() / file;
78 BOOST_REQUIRE (boost::filesystem::exists (path));
80 auto film = new_test_film ("ffmpeg_decoder_seek_test_" + file.string());
81 auto content = make_shared<FFmpegContent>(path);
82 film->examine_and_add_content (content);
83 BOOST_REQUIRE (!wait_for_jobs());
84 auto decoder = make_shared<FFmpegDecoder>(film, content);
85 decoder->video->Data.connect (bind (&store, _2));
87 for (auto i: frames) {
92 BOOST_AUTO_TEST_CASE (ffmpeg_decoder_seek_test)
94 vector<int> frames = { 0, 42, 999, 0 };
95 test ("boon_telly.mkv", frames);
96 test ("Sintel_Trailer1.480p.DivX_Plus_HD.mkv", frames);
98 frames = { 15, 42, 999, 15 };
99 test ("prophet_long_clip.mkv", frames);