2 Copyright (C) 2014 Carl Hetherington <cth@carlh.net>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #include <boost/test/unit_test.hpp>
22 #include <boost/filesystem.hpp>
23 #include "lib/ffmpeg_content.h"
24 #include "lib/ffmpeg_decoder.h"
31 using boost::shared_ptr;
32 using boost::optional;
35 check (FFmpegDecoder& decoder, int frame)
37 optional<ContentVideo> v;
38 v = decoder.get_video (frame, true);
40 BOOST_CHECK_EQUAL (v->frame, frame);
44 test (boost::filesystem::path file, vector<int> frames)
46 boost::filesystem::path path = private_data / file;
47 if (!boost::filesystem::exists (path)) {
48 cerr << "Skipping test: " << path.string() << " not found.\n";
52 shared_ptr<Film> film = new_test_film ("ffmpeg_decoder_seek_test_" + file.string());
53 shared_ptr<FFmpegContent> content (new FFmpegContent (film, path));
54 film->examine_and_add_content (content);
56 shared_ptr<Log> log (new NullLog);
57 FFmpegDecoder decoder (content, log);
59 for (vector<int>::const_iterator i = frames.begin(); i != frames.end(); ++i) {
64 BOOST_AUTO_TEST_CASE (ffmpeg_decoder_seek_test)
70 frames.push_back (42);
71 frames.push_back (999);
74 test ("boon_telly.mkv", frames);
75 test ("Sintel_Trailer1.480p.DivX_Plus_HD.mkv", frames);
78 frames.push_back (15);
79 frames.push_back (42);
80 frames.push_back (999);
81 frames.push_back (15);
83 test ("prophet_clip.mkv", frames);