Restore ffmpeg_decoder_seek_test.
authorCarl Hetherington <cth@carlh.net>
Wed, 1 Mar 2017 10:04:17 +0000 (10:04 +0000)
committerCarl Hetherington <cth@carlh.net>
Wed, 19 Apr 2017 22:04:32 +0000 (23:04 +0100)
test/ffmpeg_decoder_seek_test.cc
test/wscript

index 0e5b2963f89d60e6a004654413fb1acc8b87f546..46d82b0229679a297fc281829c421f59d412cf00 100644 (file)
@@ -19,8 +19,7 @@
 */
 
 /** @file  test/ffmpeg_decoder_seek_test.cc
- *  @brief Check that get_video() returns the frame indexes that we ask for
- *  for FFmpegDecoder.
+ *  @brief Check seek() with FFmpegDecoder.
  *
  *  This doesn't check that the contents of those frames are right, which
  *  it probably should.
 #include <boost/test/unit_test.hpp>
 #include <boost/filesystem.hpp>
 #include <vector>
+#include <iostream>
 
 using std::cerr;
 using std::vector;
 using std::list;
+using std::cout;
 using boost::shared_ptr;
 using boost::optional;
 
+static optional<ContentVideo> stored;
+static void
+store (ContentVideo v)
+{
+       stored = v;
+}
+
 static void
 check (shared_ptr<FFmpegDecoder> decoder, int frame)
 {
-       list<ContentVideo> v;
-       v = decoder->video->get (frame, true);
-       BOOST_CHECK (v.size() == 1);
-       BOOST_CHECK_EQUAL (v.front().frame.index(), frame);
+       BOOST_REQUIRE (decoder->ffmpeg_content()->video_frame_rate ());
+       decoder->seek (ContentTime::from_frames (frame, decoder->ffmpeg_content()->video_frame_rate().get()), true);
+       stored = optional<ContentVideo> ();
+       while (!decoder->pass() && !stored) {}
+       BOOST_CHECK (stored->frame <= frame);
 }
 
 static void
 test (boost::filesystem::path file, vector<int> frames)
 {
        boost::filesystem::path path = private_data / file;
-       if (!boost::filesystem::exists (path)) {
-               cerr << "Skipping test: " << path.string() << " not found.\n";
-               return;
-       }
+       BOOST_REQUIRE (boost::filesystem::exists (path));
 
        shared_ptr<Film> film = new_test_film ("ffmpeg_decoder_seek_test_" + file.string());
        shared_ptr<FFmpegContent> content (new FFmpegContent (film, path));
@@ -67,6 +73,7 @@ test (boost::filesystem::path file, vector<int> frames)
        wait_for_jobs ();
        shared_ptr<Log> log (new NullLog);
        shared_ptr<FFmpegDecoder> decoder (new FFmpegDecoder (content, log));
+       decoder->video->Data.connect (bind (&store, _1));
 
        for (vector<int>::const_iterator i = frames.begin(); i != frames.end(); ++i) {
                check (decoder, *i);
index df0a05c3542b7c8896b9c48170ef1a562830ec04..311994b618dbc69e77a3559c15839752550ecc97 100644 (file)
@@ -56,6 +56,7 @@ def build(bld):
                  ffmpeg_audio_only_test.cc
                  ffmpeg_audio_test.cc
                  ffmpeg_dcp_test.cc
+                 ffmpeg_decoder_seek_test.cc
                  ffmpeg_examiner_test.cc
                  ffmpeg_pts_offset_test.cc
                  file_group_test.cc
@@ -103,7 +104,6 @@ def build(bld):
     # resampler_test.cc
 
     # XXX
-    # ffmpeg_decoder_seek_test.cc
     # ffmpeg_decoder_sequential_test.cc
     # upmixer_a_test.cc
     # video_decoder_fill_test.cc