diff --git a/starboard/nplb/BUILD.gn b/starboard/nplb/BUILD.gn index 4c94a99c6f47..8865ea7bc1e4 100644 --- a/starboard/nplb/BUILD.gn +++ b/starboard/nplb/BUILD.gn @@ -218,6 +218,7 @@ target(gtest_target_type, "nplb") { "user_get_current_test.cc", "user_get_property_test.cc", "user_get_signed_in_test.cc", + "vertical_video_test.cc", "window_create_test.cc", "window_destroy_test.cc", "window_get_diagonal_size_in_inches_test.cc", diff --git a/starboard/nplb/vertical_video_test.cc b/starboard/nplb/vertical_video_test.cc new file mode 100644 index 000000000000..335b355fd657 --- /dev/null +++ b/starboard/nplb/vertical_video_test.cc @@ -0,0 +1,160 @@ +// Copyright 2023 The Cobalt Authors. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include +#include +#include + +#include "starboard/common/log.h" +#include "starboard/media.h" +#include "starboard/nplb/player_test_fixture.h" +#include "starboard/nplb/player_test_util.h" +#include "starboard/player.h" +#include "starboard/shared/starboard/player/video_dmp_reader.h" +#include "starboard/time.h" +#include "testing/gtest/include/gtest/gtest.h" + +namespace starboard { +namespace nplb { +namespace { + +using shared::starboard::player::video_dmp::VideoDmpReader; +using ::testing::ValuesIn; + +typedef SbPlayerTestFixture::GroupedSamples GroupedSamples; + +class VerticalVideoTest : public ::testing::TestWithParam { +}; + +void CheckVerticalResolutionSupport(const char* mime) { + SB_LOG_IF(WARNING, SbMediaCanPlayMimeAndKeySystem(mime, "") != + kSbMediaSupportTypeProbably) + << "Vertical video (" << mime + << ") should be supported on this platform."; +} + +std::vector GetVerticalVideoTestConfigs() { + const char* kVideoFilenames[] = {"vertical_1080p_30_fps_137_avc.dmp", + "vertical_4k_30_fps_313_vp9.dmp", + "vertical_8k_30_fps_571_av1.dmp"}; + const char* kAudioFilename = "silence_aac_stereo.dmp"; + + const SbPlayerOutputMode kOutputModes[] = {kSbPlayerOutputModeDecodeToTexture, + kSbPlayerOutputModePunchOut}; + + std::vector video_files; + for (auto video_filename : kVideoFilenames) { + VideoDmpReader video_dmp_reader(video_filename, + VideoDmpReader::kEnableReadOnDemand); + SB_DCHECK(video_dmp_reader.number_of_video_buffers() > 0); + if (SbMediaCanPlayMimeAndKeySystem( + video_dmp_reader.video_mime_type().c_str(), "")) { + video_files.push_back(video_filename); + } + } + + VideoDmpReader audio_dmp_reader(kAudioFilename, + VideoDmpReader::kEnableReadOnDemand); + SbMediaAudioCodec audio_codec = audio_dmp_reader.audio_codec(); + + std::vector test_configs; + for (auto video_filename : video_files) { + SbMediaVideoCodec video_codec = kSbMediaVideoCodecNone; + VideoDmpReader video_dmp_reader(video_filename, + VideoDmpReader::kEnableReadOnDemand); + video_codec = video_dmp_reader.video_codec(); + + for (auto output_mode : kOutputModes) { + if (IsOutputModeSupported(output_mode, audio_codec, video_codec, "")) { + test_configs.push_back( + std::make_tuple(kAudioFilename, video_filename, output_mode, "")); + } + } + } + + return test_configs; +} + +TEST(VerticalVideoTest, CapabilityQuery) { + SbMediaSupportType support = SbMediaCanPlayMimeAndKeySystem( + "video/mp4; codecs=\"avc1.4d002a\"; width=1920; height=1080", ""); + if (support == kSbMediaSupportTypeProbably) { + CheckVerticalResolutionSupport( + "video/mp4; codecs=\"avc1.4d002a\"; width=608; height=1080"); + } + + support = SbMediaCanPlayMimeAndKeySystem( + "video/webm; codecs=\"vp9\"; width=2560; height=1440", ""); + if (support == kSbMediaSupportTypeProbably) { + CheckVerticalResolutionSupport( + "video/webm; codecs=\"vp9\"; width=810; height=1440"); + } + + support = SbMediaCanPlayMimeAndKeySystem( + "video/webm; codecs=\"vp9\"; width=3840; height=2160", ""); + if (support == kSbMediaSupportTypeProbably) { + CheckVerticalResolutionSupport( + "video/webm; codecs=\"vp9\"; width=1215; height=2160"); + } + + support = SbMediaCanPlayMimeAndKeySystem( + "video/mp4; codecs=\"av01.0.16M.08\"; width=7680; height=4320", ""); + if (support == kSbMediaSupportTypeProbably) { + CheckVerticalResolutionSupport( + "video/mp4; codecs=\"av01.0.16M.08\"; width=2430; height=4320"); + } +} + +TEST_P(VerticalVideoTest, WriteSamples) { + SbPlayerTestFixture player_fixture(GetParam()); + if (HasFatalFailure()) { + return; + } + + SB_DCHECK(player_fixture.HasVideo()); + SB_DCHECK(player_fixture.HasAudio()); + + int audio_samples_to_write = player_fixture.ConvertDurationToAudioBufferCount( + 200 * kSbTimeMillisecond); + int video_samples_to_write = player_fixture.ConvertDurationToVideoBufferCount( + 200 * kSbTimeMillisecond); + + GroupedSamples samples; + samples.AddVideoSamplesWithEOS(0, audio_samples_to_write); + samples.AddAudioSamplesWithEOS(0, video_samples_to_write); + + ASSERT_NO_FATAL_FAILURE(player_fixture.Write(samples)); + ASSERT_NO_FATAL_FAILURE(player_fixture.WaitForPlayerEndOfStream()); +} + +std::vector GetSupportedTestConfigs() { + static std::vector supported_configs; + if (supported_configs.size() > 0) { + return supported_configs; + } + + std::vector configs = GetVerticalVideoTestConfigs(); + supported_configs.insert(supported_configs.end(), configs.begin(), + configs.end()); + return supported_configs; +} + +INSTANTIATE_TEST_CASE_P(VerticalVideoTests, + VerticalVideoTest, + ValuesIn(GetSupportedTestConfigs()), + GetSbPlayerTestConfigName); + +} // namespace +} // namespace nplb +} // namespace starboard diff --git a/starboard/raspi/shared/test_filters.py b/starboard/raspi/shared/test_filters.py index 46d7da5a03fc..bf435817efd4 100644 --- a/starboard/raspi/shared/test_filters.py +++ b/starboard/raspi/shared/test_filters.py @@ -32,6 +32,8 @@ 'SbPlayerWriteSampleTests*', 'SbUndefinedBehaviorTest.CallThisPointerIsNullRainyDay', 'SbSystemGetPropertyTest.FLAKY_ReturnsRequired', + # Failure tracked by b/287666606. + 'VerticalVideoTests/VerticalVideoTest.WriteSamples*', ], 'player_filter_tests': [ # The implementations for the raspberry pi (0 and 2) are incomplete diff --git a/starboard/shared/starboard/player/testdata/sha1_files.gni b/starboard/shared/starboard/player/testdata/sha1_files.gni index f922d4c4c26a..2b3bb461fa42 100644 --- a/starboard/shared/starboard/player/testdata/sha1_files.gni +++ b/starboard/shared/starboard/player/testdata/sha1_files.gni @@ -25,7 +25,11 @@ sha1_files = [ "beneath_the_canopy_opus_stereo.dmp.sha1", "black_test_avc_1080p_30to60_fps.dmp.sha1", "heaac.dmp.sha1", + "silence_aac_stereo.dmp.sha1", "sintel_329_ec3.dmp.sha1", "sintel_381_ac3.dmp.sha1", "sintel_399_av1.dmp.sha1", + "vertical_4k_30_fps_313_vp9.dmp.sha1", + "vertical_8k_30_fps_571_av1.dmp.sha1", + "vertical_1080p_30_fps_137_avc.dmp.sha1", ] diff --git a/starboard/shared/starboard/player/testdata/silence_aac_stereo.dmp.sha1 b/starboard/shared/starboard/player/testdata/silence_aac_stereo.dmp.sha1 new file mode 100644 index 000000000000..9d312749b6bc --- /dev/null +++ b/starboard/shared/starboard/player/testdata/silence_aac_stereo.dmp.sha1 @@ -0,0 +1 @@ +a4e1cc998dd27018aaa3d247c6316b248be2bbcb diff --git a/starboard/shared/starboard/player/testdata/vertical_1080p_30_fps_137_avc.dmp.sha1 b/starboard/shared/starboard/player/testdata/vertical_1080p_30_fps_137_avc.dmp.sha1 new file mode 100644 index 000000000000..4b0461bfa781 --- /dev/null +++ b/starboard/shared/starboard/player/testdata/vertical_1080p_30_fps_137_avc.dmp.sha1 @@ -0,0 +1 @@ +9a6a0747a9b9669ccade0ad36c8582f7a74a59f2 diff --git a/starboard/shared/starboard/player/testdata/vertical_4k_30_fps_313_vp9.dmp.sha1 b/starboard/shared/starboard/player/testdata/vertical_4k_30_fps_313_vp9.dmp.sha1 new file mode 100644 index 000000000000..4be2726465df --- /dev/null +++ b/starboard/shared/starboard/player/testdata/vertical_4k_30_fps_313_vp9.dmp.sha1 @@ -0,0 +1 @@ +09568d08a3611271c2bde94fef610bfc88862961 diff --git a/starboard/shared/starboard/player/testdata/vertical_8k_30_fps_571_av1.dmp.sha1 b/starboard/shared/starboard/player/testdata/vertical_8k_30_fps_571_av1.dmp.sha1 new file mode 100644 index 000000000000..6e2f7150ecd1 --- /dev/null +++ b/starboard/shared/starboard/player/testdata/vertical_8k_30_fps_571_av1.dmp.sha1 @@ -0,0 +1 @@ +461c333fdda619c5ac5df1d2ed4fdc5d75e604d4 diff --git a/starboard/win/win32/test_filters.py b/starboard/win/win32/test_filters.py index 662240abee9e..6bf85fa8a368 100644 --- a/starboard/win/win32/test_filters.py +++ b/starboard/win/win32/test_filters.py @@ -43,6 +43,8 @@ 'SbSocketAddressTypes/SbSocketSetOptionsTest.RainyDayInvalidSocket/type_ipv6', # Flakiness is tracked in b/278276779. 'Semaphore.ThreadTakesWait_TimeExpires', + # Failure tracked by b/287666606. + 'VerticalVideoTests/VerticalVideoTest.WriteSamples*', ], 'player_filter_tests': [ # These tests fail on our VMs for win-win32 builds due to missing