Commit 2c68c2d3 authored by Xiaohan Wang's avatar Xiaohan Wang Committed by Commit Bot

media: Refactor EME VP9 profiles 1/2/3 support

Currently there's a special logic in mime_util_internal.cc that
encrypted VP9 profiles 1/2/3 are generally not supported. In this CL,
this logic is removed, so that each key system has the opportunity to
declare whether VP9 profiles 1/2/3 are supported.

To do so, EME_CODEC_LEGACY_VP9 is replaced by EME_CODEC_VP9_PROFILE0,
which is used for both legacy VP9 ("vp9" and "vp9.0") and new multi-part
VP9 profile 0 ("vp09.00.*"). EME_CODEC_VP9_PROFILES123 is added for
VP9 profiles 1/2/3.

Since External Clear Key (ECK) key system supports all codecs, now VP9
profiles 1/2/3 are supported by ECK. Browser tests are updated to
reflect this.

Bug: 707127
Test: Updated test cases
Change-Id: Ia6cdabde0edc4680d0bfa0f8a74a7b8e4151d4e1
Reviewed-on: https://chromium-review.googlesource.com/c/1274893Reviewed-by: default avatarChrome Cunningham <chcunningham@chromium.org>
Reviewed-by: default avatarSergey Volk <servolk@chromium.org>
Reviewed-by: default avatarDan Sanders <sandersd@chromium.org>
Commit-Queue: Xiaohan Wang <xhwang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#599861}
parent 8c257639
......@@ -81,9 +81,13 @@ const char kWebMVorbisAudioOnly[] = "audio/webm; codecs=\"vorbis\"";
const char kWebMVorbisAudioVp8Video[] = "video/webm; codecs=\"vorbis, vp8\"";
const char kWebMOpusAudioVp9Video[] = "video/webm; codecs=\"opus, vp9\"";
const char kWebMVp9VideoOnly[] = "video/webm; codecs=\"vp9\"";
const char kWebMVp9Profile2VideoOnly[] =
"video/webm; codecs=\"vp09.02.10.10.01.02.02.02.00\"";
const char kMp4FlacAudioOnly[] = "audio/mp4; codecs=\"flac\"";
const char kMp4Vp9VideoOnly[] =
"video/mp4; codecs=\"vp09.00.10.08.01.02.02.02.00\"";
const char kMp4Vp9Profile2VideoOnly[] =
"video/mp4; codecs=\"vp09.02.10.10.01.02.02.02.00\"";
#if BUILDFLAG(ENABLE_LIBRARY_CDMS)
const char kWebMVp8VideoOnly[] = "video/webm; codecs=\"vp8\"";
#endif
......@@ -563,9 +567,8 @@ IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VP9Profile2Video_WebM) {
return;
}
#endif
// TODO(crbug.com/707127): Support VP9 Profile2 query and update mime type.
TestSimplePlayback("bear-320x240-v-vp9_profile2_subsample_cenc-v.webm",
kWebMVp9VideoOnly);
kWebMVp9Profile2VideoOnly);
}
// TODO(xhwang): Test is flaky. https://crbug.com/890124.
......@@ -609,9 +612,8 @@ IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoOnly_MP4_VP9Profile2) {
return;
}
#endif
// TODO(crbug.com/707127): Support VP9 Profile2 query and update mime type.
TestSimplePlayback("bear-320x240-v-vp9_profile2_subsample_cenc-v.mp4",
kMp4Vp9VideoOnly);
kMp4Vp9Profile2VideoOnly);
}
IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, InvalidResponseKeyError) {
......
......@@ -100,8 +100,8 @@ class EncryptedMediaSupportedTypesTest : public InProcessBrowserTest {
video_webm_codecs_.push_back("vp8");
video_webm_codecs_.push_back("vp8.0");
video_webm_codecs_.push_back("vp9");
video_webm_codecs_.push_back("vp9.0");
video_webm_codecs_.push_back("vp9"); // Legacy VP9 only supported in WebM
video_webm_codecs_.push_back("vp9.0"); // Legacy VP9 only supported in WebM
audio_mp4_codecs_.push_back("mp4a.40.2");
......@@ -121,9 +121,16 @@ class EncryptedMediaSupportedTypesTest : public InProcessBrowserTest {
invalid_codecs_.push_back("hev1.1.6.L93.B0");
#endif
// Codecs allowed by both MP4 and WebM.
// New multi-part VP9 codecs are allowed in both MP4 and WebM.
// For vp9 codec string format, see https://www.webmproject.org/vp9/mp4/
video_common_codecs_.push_back("vp09.00.10.08");
vp9_profile0_codecs_.push_back("vp09.00.10.08");
// VP9 profile 1/2/3 are supported in WebM and MP4 with ClearKey
// and ExternalClearKey.
// TODO(crbug.com/707128): Add support in Widevine CDM.
vp9_higher_profile_codecs_.push_back("vp09.01.10.08");
vp9_higher_profile_codecs_.push_back("vp09.02.10.10");
vp9_higher_profile_codecs_.push_back("vp09.03.10.10");
// 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
......@@ -143,19 +150,13 @@ class EncryptedMediaSupportedTypesTest : public InProcessBrowserTest {
invalid_codecs_.push_back("hev1.");
invalid_codecs_.push_back("hvc1");
invalid_codecs_.push_back("hvc1.");
// Non-zero VP9 profiles are supported in WebM and MP4 with ClearKey.
// Widevine support will eventually be added. See http://crbug.com/707128
clear_key_exclusive_video_common_codecs_.push_back("vp09.01.10.08");
clear_key_exclusive_video_common_codecs_.push_back("vp09.02.10.10");
clear_key_exclusive_video_common_codecs_.push_back("vp09.03.10.10");
}
typedef std::vector<std::string> CodecVector;
const CodecVector& no_codecs() const { return no_codecs_; }
const CodecVector& video_common_codecs() const {
return video_common_codecs_;
const CodecVector& vp9_profile0_codecs() const {
return vp9_profile0_codecs_;
}
const CodecVector& audio_webm_codecs() const { return audio_webm_codecs_; }
const CodecVector& video_webm_codecs() const { return video_webm_codecs_; }
......@@ -168,8 +169,8 @@ class EncryptedMediaSupportedTypesTest : public InProcessBrowserTest {
return video_mp4_hi10p_codecs_;
}
const CodecVector& invalid_codecs() const { return invalid_codecs_; }
const CodecVector& clear_key_exclusive_video_common_codecs() const {
return clear_key_exclusive_video_common_codecs_;
const CodecVector& vp9_higher_profile_codecs() const {
return vp9_higher_profile_codecs_;
}
void SetUpDefaultCommandLine(base::CommandLine* command_line) override {
......@@ -377,9 +378,9 @@ class EncryptedMediaSupportedTypesTest : public InProcessBrowserTest {
CodecVector audio_mp4_flac_codecs_;
CodecVector video_mp4_codecs_;
CodecVector video_mp4_hi10p_codecs_;
CodecVector video_common_codecs_;
CodecVector vp9_profile0_codecs_;
CodecVector invalid_codecs_;
CodecVector clear_key_exclusive_video_common_codecs_;
CodecVector vp9_higher_profile_codecs_;
};
// For ClearKey, nothing additional is required.
......@@ -548,10 +549,9 @@ IN_PROC_BROWSER_TEST_F(EncryptedMediaSupportedTypesClearKeyTest, Video_WebM) {
EXPECT_SUCCESS(IsSupportedByKeySystem(kClearKey, kVideoWebMMimeType,
video_webm_codecs()));
EXPECT_SUCCESS(IsSupportedByKeySystem(kClearKey, kVideoWebMMimeType,
video_common_codecs()));
EXPECT_SUCCESS(
IsSupportedByKeySystem(kClearKey, kVideoWebMMimeType,
clear_key_exclusive_video_common_codecs()));
vp9_profile0_codecs()));
EXPECT_SUCCESS(IsSupportedByKeySystem(kClearKey, kVideoWebMMimeType,
vp9_higher_profile_codecs()));
// Non-video WebM codecs.
EXPECT_UNSUPPORTED(IsSupportedByKeySystem(kClearKey, kVideoWebMMimeType,
......@@ -591,9 +591,9 @@ IN_PROC_BROWSER_TEST_F(EncryptedMediaSupportedTypesClearKeyTest, Video_MP4) {
EXPECT_PROPRIETARY(
IsSupportedByKeySystem(kClearKey, kVideoMP4MimeType, video_mp4_codecs()));
EXPECT_SUCCESS(IsSupportedByKeySystem(kClearKey, kVideoMP4MimeType,
video_common_codecs()));
EXPECT_SUCCESS(IsSupportedByKeySystem(
kClearKey, kVideoMP4MimeType, clear_key_exclusive_video_common_codecs()));
vp9_profile0_codecs()));
EXPECT_SUCCESS(IsSupportedByKeySystem(kClearKey, kVideoMP4MimeType,
vp9_higher_profile_codecs()));
// High 10-bit Profile is supported when using ClearKey if it is supported for
// clear content on this platform.
......@@ -751,9 +751,9 @@ IN_PROC_BROWSER_TEST_F(EncryptedMediaSupportedTypesExternalClearKeyTest,
EXPECT_ECK(IsSupportedByKeySystem(kExternalClearKey, kVideoWebMMimeType,
video_webm_codecs()));
EXPECT_ECK(IsSupportedByKeySystem(kExternalClearKey, kVideoWebMMimeType,
video_common_codecs()));
EXPECT_ECK(IsSupportedByKeySystem(kClearKey, kVideoWebMMimeType,
clear_key_exclusive_video_common_codecs()));
vp9_profile0_codecs()));
EXPECT_ECK(IsSupportedByKeySystem(kExternalClearKey, kVideoWebMMimeType,
vp9_higher_profile_codecs()));
// Non-video WebM codecs.
EXPECT_UNSUPPORTED(IsSupportedByKeySystem(
......@@ -795,7 +795,9 @@ IN_PROC_BROWSER_TEST_F(EncryptedMediaSupportedTypesExternalClearKeyTest,
EXPECT_ECK_PROPRIETARY(IsSupportedByKeySystem(
kExternalClearKey, kVideoMP4MimeType, video_mp4_codecs()));
EXPECT_ECK(IsSupportedByKeySystem(kExternalClearKey, kVideoMP4MimeType,
video_common_codecs()));
vp9_profile0_codecs()));
EXPECT_ECK(IsSupportedByKeySystem(kExternalClearKey, kVideoMP4MimeType,
vp9_higher_profile_codecs()));
// High 10-bit Profile is not supported when using ExternalClearKey.
EXPECT_UNSUPPORTED(IsSupportedByKeySystem(
......@@ -806,9 +808,6 @@ IN_PROC_BROWSER_TEST_F(EncryptedMediaSupportedTypesExternalClearKeyTest,
kExternalClearKey, kVideoMP4MimeType, audio_mp4_codecs()));
// Invalid or non-MP4 codecs.
EXPECT_UNSUPPORTED(
IsSupportedByKeySystem(kExternalClearKey, kVideoMP4MimeType,
clear_key_exclusive_video_common_codecs()));
EXPECT_UNSUPPORTED(IsSupportedByKeySystem(
kExternalClearKey, kVideoMP4MimeType, invalid_codecs()));
EXPECT_UNSUPPORTED(IsSupportedByKeySystem(
......@@ -965,16 +964,15 @@ IN_PROC_BROWSER_TEST_F(EncryptedMediaSupportedTypesWidevineTest, Video_WebM) {
EXPECT_WV_SUCCESS(IsSupportedByKeySystem(kWidevine, kVideoWebMMimeType,
video_webm_codecs()));
EXPECT_WV_SUCCESS(IsSupportedByKeySystem(kWidevine, kVideoWebMMimeType,
video_common_codecs()));
vp9_profile0_codecs()));
// Non-video WebM codecs.
EXPECT_UNSUPPORTED(IsSupportedByKeySystem(kWidevine, kVideoWebMMimeType,
audio_webm_codecs()));
// Invalid or non-Webm codecs.
EXPECT_UNSUPPORTED(
IsSupportedByKeySystem(kWidevine, kVideoWebMMimeType,
clear_key_exclusive_video_common_codecs()));
EXPECT_UNSUPPORTED(IsSupportedByKeySystem(kWidevine, kVideoWebMMimeType,
vp9_higher_profile_codecs()));
EXPECT_UNSUPPORTED(
IsSupportedByKeySystem(kWidevine, kVideoWebMMimeType, invalid_codecs()));
EXPECT_UNSUPPORTED(IsSupportedByKeySystem(kWidevine, kVideoWebMMimeType,
......@@ -1010,7 +1008,7 @@ IN_PROC_BROWSER_TEST_F(EncryptedMediaSupportedTypesWidevineTest, Video_MP4) {
EXPECT_WV_PROPRIETARY(
IsSupportedByKeySystem(kWidevine, kVideoMP4MimeType, video_mp4_codecs()));
EXPECT_WV_SUCCESS(IsSupportedByKeySystem(kWidevine, kVideoMP4MimeType,
video_common_codecs()));
vp9_profile0_codecs()));
// High 10-bit Profile is not supported when using Widevine.
EXPECT_UNSUPPORTED(IsSupportedByKeySystem(kWidevine, kVideoMP4MimeType,
......@@ -1023,8 +1021,8 @@ IN_PROC_BROWSER_TEST_F(EncryptedMediaSupportedTypesWidevineTest, Video_MP4) {
audio_mp4_flac_codecs()));
// Invalid or non-MP4 codecs.
EXPECT_UNSUPPORTED(IsSupportedByKeySystem(
kWidevine, kVideoMP4MimeType, clear_key_exclusive_video_common_codecs()));
EXPECT_UNSUPPORTED(IsSupportedByKeySystem(kWidevine, kVideoMP4MimeType,
vp9_higher_profile_codecs()));
EXPECT_UNSUPPORTED(
IsSupportedByKeySystem(kWidevine, kVideoMP4MimeType, invalid_codecs()));
EXPECT_UNSUPPORTED(IsSupportedByKeySystem(kWidevine, kVideoMP4MimeType,
......
......@@ -169,8 +169,8 @@ static SupportedCodecs GetSupportedCodecs(
supported_codecs |= media::EME_CODEC_VP8;
break;
case media::VideoCodec::kCodecVP9:
supported_codecs |= media::EME_CODEC_LEGACY_VP9;
supported_codecs |= media::EME_CODEC_VP9;
// TODO(crbug.com/707127): Support VP9 higher profiles.
supported_codecs |= media::EME_CODEC_VP9_PROFILE0;
break;
#if BUILDFLAG(USE_PROPRIETARY_CODECS)
case media::VideoCodec::kCodecH264:
......
......@@ -113,8 +113,9 @@ class PlayReadyKeySystemProperties : public ::media::KeySystemProperties {
#if BUILDFLAG(IS_CAST_USING_CMA_BACKEND)
SupportedCodecs GetCastEmeSupportedCodecs() {
SupportedCodecs codecs = ::media::EME_CODEC_AAC | ::media::EME_CODEC_AVC1 |
::media::EME_CODEC_VP9 | ::media::EME_CODEC_VP8 |
::media::EME_CODEC_LEGACY_VP9;
::media::EME_CODEC_VP9_PROFILE0 |
::media::EME_CODEC_VP9_PROFILES123 |
::media::EME_CODEC_VP8;
#if !BUILDFLAG(DISABLE_SECURE_FLAC_OPUS_DECODING)
codecs |= ::media::EME_CODEC_FLAC | ::media::EME_CODEC_OPUS;
......
......@@ -38,9 +38,9 @@ struct CodecInfo {
const CodecInfo<media::VideoCodec> kVideoCodecsToQuery[] = {
{media::EME_CODEC_VP8, media::kCodecVP8, "video/webm"},
{media::EME_CODEC_LEGACY_VP9, media::kCodecVP9, "video/webm"},
{media::EME_CODEC_VP9, media::kCodecVP9, "video/webm"},
{media::EME_CODEC_VP9, media::kCodecVP9, "video/mp4"},
// TODO(crbug.com/707127): Support query for VP9 profile 1/2/3 on Android.
{media::EME_CODEC_VP9_PROFILE0, media::kCodecVP9, "video/webm"},
{media::EME_CODEC_VP9_PROFILE0, media::kCodecVP9, "video/mp4"},
#if BUILDFLAG(USE_PROPRIETARY_CODECS)
{media::EME_CODEC_AVC1, media::kCodecH264, "video/mp4"},
#if BUILDFLAG(ENABLE_HEVC_DEMUXING)
......
......@@ -70,7 +70,7 @@ std::string WidevineKeySystemProperties::GetKeySystemName() const {
bool WidevineKeySystemProperties::IsSupportedInitDataType(
EmeInitDataType init_data_type) const {
// Here we assume that support for a container imples support for the
// Here we assume that support for a container implies support for the
// associated initialization data type. KeySystems handles validating
// |init_data_type| x |container| pairings.
if (init_data_type == EmeInitDataType::WEBM)
......
......@@ -45,6 +45,7 @@ const char kExternalClearKeyKeySystem[] = "org.chromium.externalclearkey";
#endif
// Supported media types.
const char kWebMVorbisAudioOnly[] = "audio/webm; codecs=\"vorbis\"";
const char kWebMOpusAudioOnly[] = "audio/webm; codecs=\"opus\"";
const char kWebMVp8VideoOnly[] = "video/webm; codecs=\"vp8\"";
......@@ -54,11 +55,19 @@ const char kWebMVorbisAudioVp8Video[] = "video/webm; codecs=\"vorbis, vp8\"";
const char kMp4FlacAudioOnly[] = "audio/mp4; codecs=\"flac\"";
const char kMp4Vp9VideoOnly[] =
"video/mp4; codecs=\"vp09.00.10.08.01.02.02.02.00\"";
#if BUILDFLAG(USE_PROPRIETARY_CODECS)
const char kMp4Avc1VideoOnly[] = "video/mp4; codecs=\"avc1.64001E\"";
const char kMp4AacAudioOnly[] = "audio/mp4; codecs=\"mp4a.40.2\"";
#endif // BUILDFLAG(USE_PROPRIETARY_CODECS)
#if !defined(OS_ANDROID)
const char kWebMVp9Profile2VideoOnly[] =
"video/webm; codecs=\"vp09.02.10.10.01.02.02.02.00\"";
const char kMp4Vp9Profile2VideoOnly[] =
"video/mp4; codecs=\"vp09.02.10.10.01.02.02.02.00\"";
#endif // !defined(OS_ANDROID)
// EME-specific test results and errors.
const char kEmeKeyError[] = "KEYERROR";
const char kEmeNotSupportedError[] = "NOTSUPPORTEDERROR";
......@@ -272,12 +281,11 @@ IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoClearAudio_WebM_Opus) {
TestSimplePlayback("bear-320x240-opus-av_enc-v.webm", kWebMOpusAudioVp9Video);
}
// TODO(crbug.com/707127): Decide when it's supported on Android. Also support
// VP9 Profile2 query and update the mime type.
// TODO(crbug.com/707127): Decide when it's supported on Android.
#if !defined(OS_ANDROID)
IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VP9Profile2Video_WebM) {
TestSimplePlayback("bear-320x240-v-vp9_profile2_subsample_cenc-v.webm",
kWebMVp9VideoOnly);
kWebMVp9Profile2VideoOnly);
}
#endif
......@@ -295,8 +303,7 @@ IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoOnly_MP4_VP9) {
TestSimplePlayback("bear-320x240-v_frag-vp9-cenc.mp4", kMp4Vp9VideoOnly);
}
// TODO(crbug.com/707127): Decide when it's supported on Android. Also support
// VP9 Profile2 query and update the mime type.
// TODO(crbug.com/707127): Decide when it's supported on Android.
#if !defined(OS_ANDROID)
IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoOnly_MP4_VP9Profile2) {
// MP4 without MSE is not support yet, http://crbug.com/170793.
......@@ -305,7 +312,7 @@ IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoOnly_MP4_VP9Profile2) {
return;
}
TestSimplePlayback("bear-320x240-v-vp9_profile2_subsample_cenc-v.mp4",
kMp4Vp9VideoOnly);
kMp4Vp9Profile2VideoOnly);
}
#endif
......
......@@ -16,18 +16,19 @@ namespace media {
// http://w3c.github.io/encrypted-media/initdata-format-registry.html#registry
enum class EmeInitDataType { UNKNOWN, WEBM, CENC, KEYIDS, MAX = KEYIDS };
// Defines bitmask values that specify codecs used in Encrypted Media Extension
// (EME). Each value represents a codec within a specific container.
// Defines bitmask values that specify codecs used in Encrypted Media Extensions
// (EME). Generally codec profiles are not specified and it is assumed that the
// profile support for encrypted playback is the same as for clear playback.
// The only exception is VP9 where we have older CDMs only supporting profile 0.
enum EmeCodec : uint32_t {
EME_CODEC_NONE = 0,
EME_CODEC_OPUS = 1 << 0,
EME_CODEC_VORBIS = 1 << 1,
EME_CODEC_VP8 = 1 << 2,
EME_CODEC_LEGACY_VP9 = 1 << 3,
EME_CODEC_VP9_PROFILE0 = 1 << 3,
EME_CODEC_AAC = 1 << 4,
// AVC1 is shared by MP4 and MP2T.
EME_CODEC_AVC1 = 1 << 5,
EME_CODEC_VP9 = 1 << 6, // New multi-part VP9 for WebM and MP4.
EME_CODEC_VP9_PROFILES123 = 1 << 6, // VP9 profiles 1/2/3
EME_CODEC_HEVC = 1 << 7,
EME_CODEC_DOLBY_VISION_AVC = 1 << 8,
EME_CODEC_DOLBY_VISION_HEVC = 1 << 9,
......@@ -42,6 +43,8 @@ enum EmeCodec : uint32_t {
using SupportedCodecs = uint32_t;
namespace {
constexpr SupportedCodecs GetMp4AudioCodecs() {
SupportedCodecs codecs = EME_CODEC_FLAC;
#if BUILDFLAG(USE_PROPRIETARY_CODECS)
......@@ -57,8 +60,9 @@ constexpr SupportedCodecs GetMp4AudioCodecs() {
}
constexpr SupportedCodecs GetMp4VideoCodecs() {
// VP9 is supported in MP4, but legacy VP9 is not.
SupportedCodecs codecs = EME_CODEC_VP9;
// 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;
#if BUILDFLAG(USE_PROPRIETARY_CODECS)
codecs |= EME_CODEC_AVC1;
#if BUILDFLAG(ENABLE_HEVC_DEMUXING)
......@@ -74,12 +78,13 @@ constexpr SupportedCodecs GetMp4VideoCodecs() {
return codecs;
}
} // namespace
constexpr SupportedCodecs EME_CODEC_WEBM_AUDIO_ALL =
EME_CODEC_OPUS | EME_CODEC_VORBIS;
// Both VP9 and legacy VP9 are supported in WebM.
constexpr SupportedCodecs EME_CODEC_WEBM_VIDEO_ALL =
EME_CODEC_VP8 | EME_CODEC_LEGACY_VP9 | EME_CODEC_VP9;
EME_CODEC_VP8 | EME_CODEC_VP9_PROFILE0 | EME_CODEC_VP9_PROFILES123;
constexpr SupportedCodecs EME_CODEC_WEBM_ALL =
EME_CODEC_WEBM_AUDIO_ALL | EME_CODEC_WEBM_VIDEO_ALL;
......
......@@ -57,15 +57,19 @@ struct NameToCodec {
};
// Mapping between codec names and enum values.
// TODO(crbug.com/724362): Convert codecs into enums directly to avoid this map.
static const NameToCodec kCodecMap[] = {
{"opus", EME_CODEC_OPUS}, // Opus.
{"vorbis", EME_CODEC_VORBIS}, // Vorbis.
{"vp8", EME_CODEC_VP8}, // VP8.
{"vp8.0", EME_CODEC_VP8}, // VP8.
{"vp9", EME_CODEC_LEGACY_VP9}, // VP9.
{"vp9.0", EME_CODEC_LEGACY_VP9}, // VP9.
{"vp09", EME_CODEC_VP9}, // New multi-part VP9 for WebM and MP4.
{"flac", EME_CODEC_FLAC}, // FLAC.
{"opus", EME_CODEC_OPUS}, // Opus
{"vorbis", EME_CODEC_VORBIS}, // Vorbis
{"vp8", EME_CODEC_VP8}, // VP8
{"vp8.0", EME_CODEC_VP8}, // VP8
{"vp9", EME_CODEC_VP9_PROFILE0}, // Legacy VP9
{"vp9.0", EME_CODEC_VP9_PROFILE0}, // Legacy VP9
// "vp09.00.*" is replaced by "vp09-profile0" to avoid ambiguity. See
// OverrideVp9Profile0() in key_system_config_selector.cc.
{"vp09-profile0", EME_CODEC_VP9_PROFILE0}, // VP9 profile 0
{"vp09", EME_CODEC_VP9_PROFILES123}, // VP9 profile 1/2/3
{"flac", EME_CODEC_FLAC}, // FLAC
#if BUILDFLAG(USE_PROPRIETARY_CODECS)
{"mp4a", EME_CODEC_AAC}, // AAC.
#if BUILDFLAG(ENABLE_AC3_EAC3_AUDIO_DEMUXING)
......@@ -606,7 +610,7 @@ EmeConfigRule KeySystemsImpl::GetContentTypeConfigRule(
SupportedCodecs mime_type_codec_mask =
GetCodecMaskForMimeType(container_mime_type);
if ((key_system_codec_mask & mime_type_codec_mask) == 0) {
DVLOG(2) << " Container " << container_mime_type << " not supported by "
DVLOG(2) << "Container " << container_mime_type << " not supported by "
<< key_system;
return EmeConfigRule::NOT_SUPPORTED;
}
......@@ -619,9 +623,18 @@ EmeConfigRule KeySystemsImpl::GetContentTypeConfigRule(
// no | any | NOT_SUPPORTED
EmeConfigRule support = EmeConfigRule::SUPPORTED;
for (size_t i = 0; i < codecs.size(); i++) {
SupportedCodecs codec = GetCodecForString(codecs[i]);
if ((codec & key_system_codec_mask & mime_type_codec_mask) == 0) {
DVLOG(2) << " Container/codec pair (" << container_mime_type << " / "
EmeCodec codec = GetCodecForString(codecs[i]);
if (codec == EME_CODEC_NONE) {
DVLOG(2) << "Unknown stripped codec string \"" << codecs[i] << "\"";
return EmeConfigRule::NOT_SUPPORTED;
}
// Currently all EmeCodecs only have one bit set. In case there could be
// codecs with multiple bits set, e.g. to cover multiple profiles, we check
// (codec & mask) == codec instead of (codec & mask) != 0 to make sure all
// bits are set. Same below.
if ((codec & key_system_codec_mask & mime_type_codec_mask) != codec) {
DVLOG(2) << "Container/codec pair (" << container_mime_type << " / "
<< codecs[i] << ") not supported by " << key_system;
return EmeConfigRule::NOT_SUPPORTED;
}
......@@ -634,7 +647,7 @@ EmeConfigRule KeySystemsImpl::GetContentTypeConfigRule(
// to consider codecs that are only supported in hardware-secure mode. We
// could do so, and make use of HW_SECURE_CODECS_REQUIRED, if it turns out
// that hardware-secure-only codecs actually exist and are useful.
if ((codec & key_system_hw_secure_codec_mask) == 0)
if ((codec & key_system_hw_secure_codec_mask) != codec)
support = EmeConfigRule::HW_SECURE_CODECS_NOT_ALLOWED;
}
......
......@@ -904,13 +904,6 @@ SupportsType MimeUtil::IsCodecSupported(const std::string& mime_type_lower_case,
default:
ambiguous_platform_support = true;
}
} else if (codec == MimeUtil::VP9 && video_profile != VP9PROFILE_PROFILE0 &&
is_encrypted) {
// LibVPX is not generally used for encrypted videos, so we do not know
// whether higher profiles are supported.
// TODO(chcunningham/xhwang): Add details to indicate which key system will
// be used and check support by querying the matching KeySystemProperties.
ambiguous_platform_support = true;
}
AudioCodec audio_codec = MimeUtilToAudioCodec(codec);
......
......@@ -167,6 +167,16 @@ bool IsSupportedMediaType(const std::string& container_mime_type,
return (support_result == IsSupported);
}
// Replaces any codec in |codecs| starting with "vp09.00." with "vp09-profile0".
void OverrideVp9Profile0(std::vector<std::string>* codecs) {
for (std::string& codec : *codecs) {
if (base::StartsWith(codec, "vp09.00.", base::CompareCase::SENSITIVE)) {
DVLOG(3) << "Replace codec " << codec << " with vp09-profile0";
codec = "vp09-profile0";
}
}
}
} // namespace
struct KeySystemConfigSelector::SelectionRequest {
......@@ -321,7 +331,9 @@ bool KeySystemConfigSelector::IsSupportedContentType(
const std::string& container_mime_type,
const std::string& codecs,
KeySystemConfigSelector::ConfigState* config_state) {
DVLOG(3) << __func__;
DVLOG(3) << __func__ << ": key_system = " << key_system
<< ", container_mime_type = " << container_mime_type
<< ", codecs = " << codecs;
// From RFC6838: "Both top-level type and subtype names are case-insensitive."
std::string container_lower = base::ToLowerASCII(container_mime_type);
......@@ -346,12 +358,18 @@ bool KeySystemConfigSelector::IsSupportedContentType(
return false;
}
// Check that |container_mime_type| and |codecs| are supported by the CDM.
// This check does not handle extended codecs, so extended codec information
// is stripped (extended codec information was checked above).
// Before checking CDM support, split and strip the |codecs| because
// |key_systems_| does not handle extended codecs. Note that extended codec
// information was checked above.
std::vector<std::string> stripped_codec_vector;
SplitCodecs(codecs, &stripped_codec_vector);
// Since both "vp09.00.*" and "vp09.01.*" will be stripped to "vp09", before
// stripping codecs, replace "vp09.00.*" with "vp09-profile0" to avoid
// ambiguity.
OverrideVp9Profile0(&stripped_codec_vector);
StripCodecs(&stripped_codec_vector);
// Check that |container_mime_type| and |codecs| are supported by the CDM.
EmeConfigRule codecs_rule = key_systems_->GetContentTypeConfigRule(
key_system, media_type, container_lower, stripped_codec_vector);
if (!config_state->IsRuleSupported(codecs_rule)) {
......
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