diff --git a/starboard/nplb/BUILD.gn b/starboard/nplb/BUILD.gn index 4c94a99c6f47..e65fbf5fa408 100644 --- a/starboard/nplb/BUILD.gn +++ b/starboard/nplb/BUILD.gn @@ -96,6 +96,7 @@ target(gtest_target_type, "nplb") { "media_buffer_test.cc", "media_can_play_mime_and_key_system_test.cc", "media_configuration_test.cc", + "media_set_audio_write_duration_test.cc", "memory_allocate_aligned_test.cc", "memory_allocate_test.cc", "memory_deallocate_aligned_test.cc", diff --git a/starboard/nplb/media_set_audio_write_duration_test.cc b/starboard/nplb/media_set_audio_write_duration_test.cc index af89f56ef556..abb7f697c927 100644 --- a/starboard/nplb/media_set_audio_write_duration_test.cc +++ b/starboard/nplb/media_set_audio_write_duration_test.cc @@ -26,13 +26,11 @@ #include "starboard/testing/fake_graphics_context_provider.h" #include "testing/gtest/include/gtest/gtest.h" -#if SB_API_VERSION < 15 - namespace starboard { namespace nplb { namespace { -using ::shared::starboard::player::video_dmp::VideoDmpReader; +using shared::starboard::player::video_dmp::VideoDmpReader; using ::starboard::testing::FakeGraphicsContextProvider; using ::testing::ValuesIn; @@ -42,8 +40,7 @@ const SbTime kSmallWaitInterval = 10 * kSbTimeMillisecond; class SbMediaSetAudioWriteDurationTest : public ::testing::TestWithParam { public: - SbMediaSetAudioWriteDurationTest() - : dmp_reader_(ResolveTestFileName(GetParam()).c_str()) {} + SbMediaSetAudioWriteDurationTest() : dmp_reader_(GetParam()) {} void TryToWritePendingSample() { { @@ -79,11 +76,11 @@ class SbMediaSetAudioWriteDurationTest pending_decoder_status_ = nullopt; } - CallSbPlayerWriteSamples(player, kSbMediaTypeAudio, dmp_reader_.get(), - index_, 1); + CallSbPlayerWriteSamples(player, kSbMediaTypeAudio, &dmp_reader_, index_, + 1); + last_input_timestamp_ = + dmp_reader_.GetPlayerSampleInfo(kSbMediaTypeAudio, index_).timestamp; ++index_; - - last_input_timestamp_ = player_sample_info.timestamp; } void PlayerStatus(SbPlayer player, SbPlayerState state, int ticket) { @@ -103,27 +100,30 @@ class SbMediaSetAudioWriteDurationTest } SbPlayer CreatePlayer() { - SbMediaAudioSampleInfo audio_sample_info = dmp_reader_.audio_sample_info(); - SbMediaAudioCodec kAudioCodec = dmp_reader_.audio_codec(); - SbDrmSystem kDrmSystem = kSbDrmSystemInvalid; + SbMediaAudioCodec audio_codec = dmp_reader_.audio_codec(); - last_input_timestamp_ = - dmp_reader_.GetPlayerSampleInfo(kSbMediaTypeAudio, 0).timestamp; - first_input_timestamp_ = last_input_timestamp_; + PlayerCreationParam creation_param = CreatePlayerCreationParam( + audio_codec, kSbMediaVideoCodecNone, kSbPlayerOutputModeInvalid); + + SbPlayerCreationParam param = {}; + creation_param.ConvertTo(¶m); - SbPlayerCreationParam creation_param = CreatePlayerCreationParam( - audio_sample_info.codec, kSbMediaVideoCodecNone, - SbPlayerGetPreferredOutputMode(&creation_param)); - creation_param.audio_sample_info = audio_sample_info; + creation_param.output_mode = SbPlayerGetPreferredOutputMode(¶m); EXPECT_NE(creation_param.output_mode, kSbPlayerOutputModeInvalid); - SbPlayer player = SbPlayerCreate( - fake_graphics_context_provider_.window(), &creation_param, + SbPlayer player = CallSbPlayerCreate( + fake_graphics_context_provider_.window(), kSbMediaVideoCodecNone, + audio_codec, kSbDrmSystemInvalid, &dmp_reader_.audio_stream_info(), "", DummyDeallocateSampleFunc, DecoderStatusFunc, PlayerStatusFunc, - DummyErrorFunc, this /* context */, + DummyErrorFunc, this /* context */, creation_param.output_mode, fake_graphics_context_provider_.decoder_target_provider()); EXPECT_TRUE(SbPlayerIsValid(player)); + + last_input_timestamp_ = + dmp_reader_.GetPlayerSampleInfo(kSbMediaTypeAudio, 0).timestamp; + first_input_timestamp_ = last_input_timestamp_; + return player; } @@ -183,7 +183,9 @@ TEST_P(SbMediaSetAudioWriteDurationTest, WriteLimitedInput) { ASSERT_NE(dmp_reader_.audio_codec(), kSbMediaAudioCodecNone); ASSERT_GT(dmp_reader_.number_of_audio_buffers(), 0); +#if SB_API_VERSION < 15 SbMediaSetAudioWriteDuration(kDuration); +#endif // SB_API_VERSION < 15 SbPlayer player = CreatePlayer(); WaitForPlayerState(kSbPlayerStateInitialized); @@ -224,7 +226,9 @@ TEST_P(SbMediaSetAudioWriteDurationTest, WriteContinuedLimitedInput) { ASSERT_NE(dmp_reader_.audio_codec(), kSbMediaAudioCodecNone); ASSERT_GT(dmp_reader_.number_of_audio_buffers(), 0); +#if SB_API_VERSION < 15 SbMediaSetAudioWriteDuration(kDuration); +#endif // SB_API_VERSION < 15 // This directly impacts the runtime of the test. total_duration_ = 15 * kSbTimeSecond; @@ -277,11 +281,9 @@ std::vector GetSupportedTests() { } for (auto filename : kFilenames) { - VideoDmpReader dmp_reader(ResolveTestFileName(filename).c_str()); + VideoDmpReader dmp_reader(filename); SB_DCHECK(dmp_reader.number_of_audio_buffers() > 0); - const SbMediaAudioSampleInfo* audio_sample_info = - &dmp_reader.audio_sample_info(); if (SbMediaIsAudioSupported(dmp_reader.audio_codec(), nullptr, dmp_reader.audio_bitrate())) { test_params.push_back(filename); @@ -297,5 +299,3 @@ INSTANTIATE_TEST_CASE_P(SbMediaSetAudioWriteDurationTests, } // namespace } // namespace nplb } // namespace starboard - -#endif // SB_API_VERSION < 15 diff --git a/starboard/win/win32/test_filters.py b/starboard/win/win32/test_filters.py index 662240abee9e..a6548f3d1a52 100644 --- a/starboard/win/win32/test_filters.py +++ b/starboard/win/win32/test_filters.py @@ -29,6 +29,7 @@ # performs an optimization that defeats the SB_C_NOINLINE 'noinline' # attribute. 'SbSystemGetStackTest.SunnyDayStackDirection', + 'SbMediaSetAudioWriteDurationTests/SbMediaSetAudioWriteDurationTest.WriteContinuedLimitedInput*', # Failures tracked by b/256160416. 'SbSystemGetPathTest.ReturnsRequiredPaths',