summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2017-07-27 17:21:30 +0100
committerCarl Hetherington <cth@carlh.net>2017-07-27 17:21:30 +0100
commit3ad101373a6e189587e035d1b01389f52134af8a (patch)
tree3ec5f0ecd0686599d51aa1dc1cc21b5d98373ece
parent2f63654d5e452f2ab9ec90cd3449da4b113a3e94 (diff)
Add a new test.
-rw-r--r--test/player_test.cc41
1 files changed, 41 insertions, 0 deletions
diff --git a/test/player_test.cc b/test/player_test.cc
index 14a1fa0c6..8d557322a 100644
--- a/test/player_test.cc
+++ b/test/player_test.cc
@@ -31,6 +31,7 @@
#include "lib/player.h"
#include "lib/video_content.h"
#include "lib/image_content.h"
+#include "lib/text_subtitle_content.h"
#include "lib/content_factory.h"
#include "test.h"
#include <boost/test/unit_test.hpp>
@@ -145,3 +146,43 @@ BOOST_AUTO_TEST_CASE (player_subframe_test)
BOOST_REQUIRE_EQUAL (player->_silent._periods.size(), 1);
BOOST_CHECK (player->_silent._periods.front() == DCPTimePeriod(DCPTime(289920), DCPTime::from_frames(3 * 24 + 1, 24)));
}
+
+static Frame video_frames;
+static Frame audio_frames;
+
+static void
+video (shared_ptr<PlayerVideo>, DCPTime)
+{
+ ++video_frames;
+}
+
+static void
+audio (shared_ptr<AudioBuffers> audio, DCPTime)
+{
+ audio_frames += audio->frames();
+}
+
+/** Check with a video-only file that the video and audio emissions happen more-or-less together */
+BOOST_AUTO_TEST_CASE (player_interleave_test)
+{
+ shared_ptr<Film> film = new_test_film ("ffmpeg_transcoder_basic_test_subs");
+ film->set_name ("ffmpeg_transcoder_basic_test");
+ film->set_container (Ratio::from_id ("185"));
+ film->set_audio_channels (6);
+
+ shared_ptr<FFmpegContent> c (new FFmpegContent (film, "test/data/test.mp4"));
+ film->examine_and_add_content (c);
+ BOOST_REQUIRE (!wait_for_jobs ());
+
+ shared_ptr<TextSubtitleContent> s (new TextSubtitleContent (film, "test/data/subrip.srt"));
+ film->examine_and_add_content (s);
+ BOOST_REQUIRE (!wait_for_jobs ());
+
+ shared_ptr<Player> player (new Player(film, film->playlist()));
+ player->Video.connect (bind (&video, _1, _2));
+ player->Audio.connect (bind (&audio, _1, _2));
+ video_frames = audio_frames = 0;
+ while (!player->pass ()) {
+ BOOST_CHECK (abs(video_frames - (audio_frames / 2000)) < 8);
+ }
+}