From: Carl Hetherington Date: Thu, 27 Jul 2017 16:21:30 +0000 (+0100) Subject: Add a new test. X-Git-Tag: v2.11.15~2 X-Git-Url: https://git.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=3ad101373a6e189587e035d1b01389f52134af8a Add a new test. --- 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 @@ -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, DCPTime) +{ + ++video_frames; +} + +static void +audio (shared_ptr 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 = 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 c (new FFmpegContent (film, "test/data/test.mp4")); + film->examine_and_add_content (c); + BOOST_REQUIRE (!wait_for_jobs ()); + + shared_ptr s (new TextSubtitleContent (film, "test/data/subrip.srt")); + film->examine_and_add_content (s); + BOOST_REQUIRE (!wait_for_jobs ()); + + shared_ptr 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); + } +}