Skip to content

Commit

Permalink
[nplb] Add tests for vertical video
Browse files Browse the repository at this point in the history
b/248859788

Change-Id: I2f737a973b219360d106ebf89bfb7e329d0011b9
  • Loading branch information
osagie98 committed Jun 16, 2023
1 parent 12db664 commit fd44bb0
Show file tree
Hide file tree
Showing 9 changed files with 173 additions and 0 deletions.
1 change: 1 addition & 0 deletions starboard/nplb/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
160 changes: 160 additions & 0 deletions starboard/nplb/vertical_video_test.cc
Original file line number Diff line number Diff line change
@@ -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 <string>
#include <tuple>
#include <vector>

#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<SbPlayerTestConfig> {
};

void CheckVerticalResolutionSupport(const char* mime) {
SB_LOG_IF(WARNING, SbMediaCanPlayMimeAndKeySystem(mime, "") !=
kSbMediaSupportTypeProbably)
<< "Vertical video (" << mime
<< ") should be supported on this platform.";
}

std::vector<SbPlayerTestConfig> 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<const char*> 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<SbPlayerTestConfig> 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<SbPlayerTestConfig> GetSupportedTestConfigs() {
static std::vector<SbPlayerTestConfig> supported_configs;
if (supported_configs.size() > 0) {
return supported_configs;
}

std::vector<SbPlayerTestConfig> 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
2 changes: 2 additions & 0 deletions starboard/raspi/shared/test_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions starboard/shared/starboard/player/testdata/sha1_files.gni
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a4e1cc998dd27018aaa3d247c6316b248be2bbcb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
9a6a0747a9b9669ccade0ad36c8582f7a74a59f2
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
09568d08a3611271c2bde94fef610bfc88862961
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
461c333fdda619c5ac5df1d2ed4fdc5d75e604d4
2 changes: 2 additions & 0 deletions starboard/win/win32/test_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit fd44bb0

Please sign in to comment.