Skip to content

Commit

Permalink
[nplb] Revamp SbMediaCanPlayMimeAndKeySystem.MinimumSupport (#748)
Browse files Browse the repository at this point in the history
Updates the test to check for minimum format support aligned to the 2024
hardware requirements.

b/287674893
  • Loading branch information
osagie98 authored Jun 30, 2023
1 parent b3cde72 commit 541a158
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 39 deletions.
3 changes: 3 additions & 0 deletions starboard/android/shared/test_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@

# TODO: b/288107692 This test crashed on arm64 after NDK 25 upgrade, re-enable it.
'PixelTest.TooManyGlyphs',

# TODO: Filter this test on a per-device basis.
'SbMediaCanPlayMimeAndKeySystem.MinimumSupport',
],
}
# pylint: enable=line-too-long
Expand Down
110 changes: 71 additions & 39 deletions starboard/nplb/media_can_play_mime_and_key_system_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,25 @@ bool IsKeySystemWithAttributesSupported() {
return false;
}

typedef enum DeviceType {
kDeviceTypeFHD,
kDeviceType4k,
kDeviceType8k,
} DeviceType;

DeviceType GetDeviceType() {
if (SbMediaCanPlayMimeAndKeySystem(
"video/mp4; codecs=\"av01.0.16M.08\"; width=7680; height=4320", "") ==
kSbMediaSupportTypeProbably) {
return kDeviceType8k;
} else if (SbMediaCanPlayMimeAndKeySystem(
"video/webm; codecs=\"vp9\"; width=3840; height=2160", "") ==
kSbMediaSupportTypeProbably) {
return kDeviceType4k;
}
return kDeviceTypeFHD;
}

TEST(SbMediaCanPlayMimeAndKeySystem, SunnyDay) {
// Vp9
SbMediaCanPlayMimeAndKeySystem(
Expand Down Expand Up @@ -220,53 +239,66 @@ TEST(SbMediaCanPlayMimeAndKeySystem, Invalid) {
}

TEST(SbMediaCanPlayMimeAndKeySystem, MinimumSupport) {
// H.264 High Profile Level 4.2
SbMediaSupportType result = SbMediaCanPlayMimeAndKeySystem(
std::vector<const char*> params_fhd{
"video/mp4; codecs=\"avc1.4d002a\"; width=1920; height=1080; "
"framerate=30",
"video/mp4; codecs=\"avc1.64002a\"; width=1920; height=1080; "
"framerate=30; bitrate=20000000",
"");
ASSERT_EQ(result, kSbMediaSupportTypeProbably);
"framerate=30",
"video/webm; codecs=\"vp9\"; width=1920; height=1080; framerate=30",
"video/webm; codecs=\"vp09.02.41.10.01.09.16.09.00\"; width=1920; "
"height=1080; framerate=30",
"video/mp4; codecs=\"av01.0.09M.08\"; width=1920; height=1080; "
"framerate=30",
};

// H.264 Main Profile Level 4.2
result = SbMediaCanPlayMimeAndKeySystem(
std::vector<const char*> params_4k{
"video/mp4; codecs=\"avc1.4d002a\"; width=1920; height=1080; "
"framerate=30;",
"");
ASSERT_EQ(result, kSbMediaSupportTypeProbably);

result = SbMediaCanPlayMimeAndKeySystem(
"video/mp4; codecs=\"avc1.4d002a\"; width=0; height=0; "
"framerate=0; bitrate=0",
"");
ASSERT_EQ(result, kSbMediaSupportTypeProbably);

result = SbMediaCanPlayMimeAndKeySystem(
"video/mp4; codecs=\"avc1.4d002a\"; width=-0; height=-0; "
"framerate=-0; bitrate=-0",
"");
ASSERT_EQ(result, kSbMediaSupportTypeProbably);
"framerate=30",
"video/mp4; codecs=\"avc1.64002a\"; width=1920; height=1080; "
"framerate=30",
"video/webm; codecs=\"vp9\"; width=3840; height=2160; framerate=30",
"video/webm; codecs=\"vp09.02.51.10.01.09.16.09.00\"; width=3840; "
"height=2160; framerate=30",
"video/mp4; codecs=\"av01.0.12M.08\"; width=3840; height=2160; "
"framerate=30",
"video/mp4; codecs=\"av01.0.13M.10.0.110.09.16.09.0\"; width=3840; "
"height=2160; framerate=30",
};

// H.264 Main Profile Level 2.1
result = SbMediaCanPlayMimeAndKeySystem(
"video/mp4; codecs=\"avc1.4d0015\"; width=432; height=240; "
"framerate=15;",
"");
ASSERT_EQ(result, kSbMediaSupportTypeProbably);
std::vector<const char*> params_8k{
"video/mp4; codecs=\"avc1.4d002a\"; width=1920; height=1080; "
"framerate=30",
"video/mp4; codecs=\"avc1.64002a\"; width=1920; height=1080; "
"framerate=30",
"video/webm; codecs=\"vp9\"; width=3840; height=2160; framerate=60",
"video/webm; codecs=\"vp09.02.51.10.01.09.16.09.00\"; width=3840; "
"height=2160; framerate=60",
"video/mp4; codecs=\"av01.0.16M.08\"; width=7680; height=4320; "
"framerate=30",
"video/mp4; codecs=\"av01.0.17M.10.0.110.09.16.09.0\"; width=7680; "
"height=4320; framerate=30",
};

// AV1 Main Profile 1080p
result = SbMediaCanPlayMimeAndKeySystem(
"video/mp4; codecs=\"av01.0.09M.08\"; width=1920; height=1080; "
"framerate=30; bitrate=20000000",
"");
DeviceType device_type = GetDeviceType();
std::vector<const char*> mime_params;
switch (device_type) {
case kDeviceType8k:
mime_params = params_8k;
break;
case kDeviceType4k:
mime_params = params_4k;
break;
default:
mime_params = params_fhd;
}

// VP9 1080p
result = SbMediaCanPlayMimeAndKeySystem(
"video/webm; codecs=\"vp9\"; width=1920; height=1080; framerate=60; "
"bitrate=20000000",
"");
for (auto& param : mime_params) {
SbMediaSupportType support = SbMediaCanPlayMimeAndKeySystem(param, "");
EXPECT_TRUE(support == kSbMediaSupportTypeProbably);
}

// AAC-LC
result = SbMediaCanPlayMimeAndKeySystem(
SbMediaSupportType result = SbMediaCanPlayMimeAndKeySystem(
"audio/mp4; codecs=\"mp4a.40.2\"; channels=2; bitrate=256000;", "");
ASSERT_EQ(result, kSbMediaSupportTypeProbably);

Expand Down
3 changes: 3 additions & 0 deletions starboard/raspi/shared/test_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
'SbSystemGetPropertyTest.FLAKY_ReturnsRequired',
# Failure tracked by b/287666606.
'VerticalVideoTests/VerticalVideoTest.WriteSamples*',

# Enable once verified on the platform.
'SbMediaCanPlayMimeAndKeySystem.MinimumSupport',
],
'player_filter_tests': [
# The implementations for the raspberry pi (0 and 2) are incomplete
Expand Down
3 changes: 3 additions & 0 deletions starboard/win/win32/test_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@
'Semaphore.ThreadTakesWait_TimeExpires',
# Failure tracked by b/287666606.
'VerticalVideoTests/VerticalVideoTest.WriteSamples*',

# Enable once verified on the platform.
'SbMediaCanPlayMimeAndKeySystem.MinimumSupport',
],
'player_filter_tests': [
# These tests fail on our VMs for win-win32 builds due to missing
Expand Down

0 comments on commit 541a158

Please sign in to comment.