Commit 895a0d76 authored by Xiaohan Wang's avatar Xiaohan Wang Committed by Commit Bot

media: Support AV1 in EME capability query

This CL updates the EME requestMediaKeySystemAccess() stack to support
AV1. For library CDMs, it needs to be signaled during CDM registration.

In the next CL, ClearKeyCdm will be updated to actually support AV1
playback.

TBR=sorin@chromium.org
Windows.

Bug: 884898
Test: Added new test cases. Also manually tested component installer on
Change-Id: I0222136c76682db51bcf021c6bd5db3c467c271e
Reviewed-on: https://chromium-review.googlesource.com/c/1241569
Commit-Queue: Xiaohan Wang <xhwang@chromium.org>
Reviewed-by: default avatarJohn Rummell <jrummell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#600638}
parent 56d26cfc
......@@ -116,6 +116,7 @@ const char kCdmSupportedCdmProxyProtocolsName[] =
// parameter |kCdmCodecsListName|.
const char kCdmSupportedCodecVp8[] = "vp8";
const char kCdmSupportedCodecVp9[] = "vp9.0";
const char kCdmSupportedCodecAv1[] = "av01";
#if BUILDFLAG(USE_PROPRIETARY_CODECS)
const char kCdmSupportedCodecAvc1[] = "avc1";
#endif
......@@ -216,6 +217,8 @@ bool GetCodecs(const base::DictionaryValue& manifest,
result.push_back(media::VideoCodec::kCodecVP8);
else if (codec == kCdmSupportedCodecVp9)
result.push_back(media::VideoCodec::kCodecVP9);
else if (codec == kCdmSupportedCodecAv1)
result.push_back(media::VideoCodec::kCodecAV1);
#if BUILDFLAG(USE_PROPRIETARY_CODECS)
else if (codec == kCdmSupportedCodecAvc1)
result.push_back(media::VideoCodec::kCodecH264);
......
......@@ -66,6 +66,12 @@ const char kTypeErrorResult[] = "TypeError";
#define EXPECT_UNSUPPORTED(test) EXPECT_EQ(kUnsupportedResult, test)
#define EXPECT_TYPEERROR(test) EXPECT_EQ(kTypeErrorResult, test)
#if BUILDFLAG(ENABLE_AV1_DECODER)
#define EXPECT_AV1 EXPECT_SUCCESS
#else
#define EXPECT_AV1 EXPECT_UNSUPPORTED
#endif
#if BUILDFLAG(USE_PROPRIETARY_CODECS)
#define EXPECT_PROPRIETARY EXPECT_SUCCESS
#else
......@@ -75,18 +81,22 @@ const char kTypeErrorResult[] = "TypeError";
// Expectations for External Clear Key.
#if BUILDFLAG(ENABLE_LIBRARY_CDMS)
#define EXPECT_ECK EXPECT_SUCCESS
#define EXPECT_ECK_AV1 EXPECT_AV1
#define EXPECT_ECK_PROPRIETARY EXPECT_PROPRIETARY
#else
#define EXPECT_ECK EXPECT_UNSUPPORTED
#define EXPECT_ECK_AV1 EXPECT_UNSUPPORTED
#define EXPECT_ECK_PROPRIETARY EXPECT_UNSUPPORTED
#endif // BUILDFLAG(ENABLE_LIBRARY_CDMS)
// Expectations for Widevine.
#if BUILDFLAG(BUNDLE_WIDEVINE_CDM)
#define EXPECT_WV_SUCCESS EXPECT_SUCCESS
#define EXPECT_WV_AV1 EXPECT_AV1
#define EXPECT_WV_PROPRIETARY EXPECT_PROPRIETARY
#else
#define EXPECT_WV_SUCCESS EXPECT_UNSUPPORTED
#define EXPECT_WV_AV1 EXPECT_UNSUPPORTED
#define EXPECT_WV_PROPRIETARY EXPECT_UNSUPPORTED
#endif // BUILDFLAG(BUNDLE_WIDEVINE_CDM)
......@@ -132,6 +142,9 @@ class EncryptedMediaSupportedTypesTest : public InProcessBrowserTest {
vp9_higher_profile_codecs_.push_back("vp09.02.10.10");
vp9_higher_profile_codecs_.push_back("vp09.03.10.10");
// AV1 codec string: https://aomediacodec.github.io/av1-isobmff/#codecsparam
av1_codecs_.push_back("av01.0.00M.10.0.112");
// Extended codecs are used, so make sure generic ones fail. These will be
// tested against all init data types as they should always fail to be
// supported.
......@@ -172,6 +185,7 @@ class EncryptedMediaSupportedTypesTest : public InProcessBrowserTest {
const CodecVector& vp9_higher_profile_codecs() const {
return vp9_higher_profile_codecs_;
}
const CodecVector& av1_codecs() const { return av1_codecs_; }
void SetUpDefaultCommandLine(base::CommandLine* command_line) override {
#if BUILDFLAG(ENABLE_LIBRARY_CDMS)
......@@ -314,8 +328,11 @@ class EncryptedMediaSupportedTypesTest : public InProcessBrowserTest {
video_capabilities.c_str(), session_type_string.c_str());
DVLOG(1) << "command: " << command;
return ExecuteCommand(browser()->tab_strip_model()->GetActiveWebContents(),
command);
auto result = ExecuteCommand(
browser()->tab_strip_model()->GetActiveWebContents(), command);
DVLOG(1) << "result: " << result;
return result;
}
std::string IsSessionTypeSupported(const std::string& key_system,
......@@ -381,6 +398,7 @@ class EncryptedMediaSupportedTypesTest : public InProcessBrowserTest {
CodecVector vp9_profile0_codecs_;
CodecVector invalid_codecs_;
CodecVector vp9_higher_profile_codecs_;
CodecVector av1_codecs_;
};
// For ClearKey, nothing additional is required.
......@@ -552,6 +570,8 @@ IN_PROC_BROWSER_TEST_F(EncryptedMediaSupportedTypesClearKeyTest, Video_WebM) {
vp9_profile0_codecs()));
EXPECT_SUCCESS(IsSupportedByKeySystem(kClearKey, kVideoWebMMimeType,
vp9_higher_profile_codecs()));
EXPECT_AV1(
IsSupportedByKeySystem(kClearKey, kVideoWebMMimeType, av1_codecs()));
// Non-video WebM codecs.
EXPECT_UNSUPPORTED(IsSupportedByKeySystem(kClearKey, kVideoWebMMimeType,
......@@ -594,6 +614,8 @@ IN_PROC_BROWSER_TEST_F(EncryptedMediaSupportedTypesClearKeyTest, Video_MP4) {
vp9_profile0_codecs()));
EXPECT_SUCCESS(IsSupportedByKeySystem(kClearKey, kVideoMP4MimeType,
vp9_higher_profile_codecs()));
EXPECT_AV1(
IsSupportedByKeySystem(kClearKey, kVideoWebMMimeType, av1_codecs()));
// High 10-bit Profile is supported when using ClearKey if it is supported for
// clear content on this platform.
......@@ -754,6 +776,8 @@ IN_PROC_BROWSER_TEST_F(EncryptedMediaSupportedTypesExternalClearKeyTest,
vp9_profile0_codecs()));
EXPECT_ECK(IsSupportedByKeySystem(kExternalClearKey, kVideoWebMMimeType,
vp9_higher_profile_codecs()));
EXPECT_ECK_AV1(IsSupportedByKeySystem(kExternalClearKey, kVideoWebMMimeType,
av1_codecs()));
// Non-video WebM codecs.
EXPECT_UNSUPPORTED(IsSupportedByKeySystem(
......@@ -798,6 +822,8 @@ IN_PROC_BROWSER_TEST_F(EncryptedMediaSupportedTypesExternalClearKeyTest,
vp9_profile0_codecs()));
EXPECT_ECK(IsSupportedByKeySystem(kExternalClearKey, kVideoMP4MimeType,
vp9_higher_profile_codecs()));
EXPECT_ECK_AV1(IsSupportedByKeySystem(kExternalClearKey, kVideoWebMMimeType,
av1_codecs()));
// High 10-bit Profile is not supported when using ExternalClearKey.
EXPECT_UNSUPPORTED(IsSupportedByKeySystem(
......@@ -973,6 +999,8 @@ IN_PROC_BROWSER_TEST_F(EncryptedMediaSupportedTypesWidevineTest, Video_WebM) {
// Invalid or non-Webm codecs.
EXPECT_UNSUPPORTED(IsSupportedByKeySystem(kWidevine, kVideoWebMMimeType,
vp9_higher_profile_codecs()));
EXPECT_UNSUPPORTED(
IsSupportedByKeySystem(kWidevine, kVideoWebMMimeType, av1_codecs()));
EXPECT_UNSUPPORTED(
IsSupportedByKeySystem(kWidevine, kVideoWebMMimeType, invalid_codecs()));
EXPECT_UNSUPPORTED(IsSupportedByKeySystem(kWidevine, kVideoWebMMimeType,
......@@ -1023,6 +1051,8 @@ IN_PROC_BROWSER_TEST_F(EncryptedMediaSupportedTypesWidevineTest, Video_MP4) {
// Invalid or non-MP4 codecs.
EXPECT_UNSUPPORTED(IsSupportedByKeySystem(kWidevine, kVideoMP4MimeType,
vp9_higher_profile_codecs()));
EXPECT_UNSUPPORTED(
IsSupportedByKeySystem(kWidevine, kVideoMP4MimeType, av1_codecs()));
EXPECT_UNSUPPORTED(
IsSupportedByKeySystem(kWidevine, kVideoMP4MimeType, invalid_codecs()));
EXPECT_UNSUPPORTED(IsSupportedByKeySystem(kWidevine, kVideoMP4MimeType,
......
......@@ -172,6 +172,9 @@ static SupportedCodecs GetSupportedCodecs(
// TODO(crbug.com/707127): Support VP9 higher profiles.
supported_codecs |= media::EME_CODEC_VP9_PROFILE0;
break;
case media::VideoCodec::kCodecAV1:
supported_codecs |= media::EME_CODEC_AV1;
break;
#if BUILDFLAG(USE_PROPRIETARY_CODECS)
case media::VideoCodec::kCodecH264:
supported_codecs |= media::EME_CODEC_AVC1;
......
......@@ -36,6 +36,7 @@ enum EmeCodec : uint32_t {
EME_CODEC_EAC3 = 1 << 11,
EME_CODEC_MPEG_H_AUDIO = 1 << 12,
EME_CODEC_FLAC = 1 << 13,
EME_CODEC_AV1 = 1 << 14,
};
// *_ALL values should only be used for masking, do not use them to specify
......@@ -63,6 +64,7 @@ constexpr SupportedCodecs GetMp4VideoCodecs() {
// VP9 codec can be in MP4. Legacy VP9 codec strings ("vp9" and "vp9.0") can
// not be in "video/mp4" mime type, but that is enforced by media::MimeUtil.
SupportedCodecs codecs = EME_CODEC_VP9_PROFILE0 | EME_CODEC_VP9_PROFILES123;
codecs |= EME_CODEC_AV1;
#if BUILDFLAG(USE_PROPRIETARY_CODECS)
codecs |= EME_CODEC_AVC1;
#if BUILDFLAG(ENABLE_HEVC_DEMUXING)
......@@ -84,7 +86,8 @@ constexpr SupportedCodecs EME_CODEC_WEBM_AUDIO_ALL =
EME_CODEC_OPUS | EME_CODEC_VORBIS;
constexpr SupportedCodecs EME_CODEC_WEBM_VIDEO_ALL =
EME_CODEC_VP8 | EME_CODEC_VP9_PROFILE0 | EME_CODEC_VP9_PROFILES123;
EME_CODEC_VP8 | EME_CODEC_VP9_PROFILE0 | EME_CODEC_VP9_PROFILES123 |
EME_CODEC_AV1;
constexpr SupportedCodecs EME_CODEC_WEBM_ALL =
EME_CODEC_WEBM_AUDIO_ALL | EME_CODEC_WEBM_VIDEO_ALL;
......
......@@ -108,6 +108,8 @@ EmeCodec ToVideoEmeCodec(VideoCodec codec, VideoCodecProfile profile) {
} else {
return EME_CODEC_NONE;
}
case kCodecAV1:
return EME_CODEC_AV1;
default:
DVLOG(1) << "Unsupported VideoCodec " << codec;
return EME_CODEC_NONE;
......
......@@ -264,11 +264,11 @@ bool ParseAv1CodecId(const std::string& codec_id,
uint8_t* level_idc,
VideoColorSpace* color_space) {
// The codecs parameter string for the AOM AV1 codec is as follows:
// See https://aomediacodec.github.io/av1-isobmff/#codecsparam.
//
// <sample entry4CC>.<profile>.<level><tier>.<bitDepth>.<monochrome>.
// <chromaSubsampling>.<colorPrimaries>.<transferCharacteristics>.
// <matrixCoefficients>.<videoFullRangeFlag>
//
std::vector<std::string> fields = base::SplitString(
codec_id, ".", base::KEEP_WHITESPACE, base::SPLIT_WANT_ALL);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment