Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cherry pick PR #748: [nplb] Revamp SbMediaCanPlayMimeAndKeySystem.MinimumSupport #797

Merged
merged 1 commit into from
Jun 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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