Commit 715f2a16 authored by Xiaohan Wang's avatar Xiaohan Wang Committed by Commit Bot

media: Add AV1 support in ClearKeyCdm

- Use AomVideoDecoder in ClearKeyCdm to support AV1 decoding.
- Add encrypted AV1 test files in media/test/data.
- Add browser tests to test playback of encrypted AV1 in WebM and MP4
  using Clear Key key system and External Clear Key key system.

Bug: 884898
Test: New test cases added.
Change-Id: I201b47d8261ddc2d68bbcd90c0fd265612133c3e
Reviewed-on: https://chromium-review.googlesource.com/c/1286201
Commit-Queue: Xiaohan Wang <xhwang@chromium.org>
Reviewed-by: default avatarJohn Rummell <jrummell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#600808}
parent 83a9525b
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include "media/cdm/supported_cdm_versions.h" #include "media/cdm/supported_cdm_versions.h"
#include "media/media_buildflags.h" #include "media/media_buildflags.h"
#include "testing/gtest/include/gtest/gtest-spi.h" #include "testing/gtest/include/gtest/gtest-spi.h"
#include "third_party/libaom/av1_buildflags.h"
#include "third_party/widevine/cdm/buildflags.h" #include "third_party/widevine/cdm/buildflags.h"
#include "third_party/widevine/cdm/widevine_cdm_common.h" #include "third_party/widevine/cdm/widevine_cdm_common.h"
...@@ -88,6 +89,10 @@ const char kMp4Vp9VideoOnly[] = ...@@ -88,6 +89,10 @@ const char kMp4Vp9VideoOnly[] =
"video/mp4; codecs=\"vp09.00.10.08.01.02.02.02.00\""; "video/mp4; codecs=\"vp09.00.10.08.01.02.02.02.00\"";
const char kMp4Vp9Profile2VideoOnly[] = const char kMp4Vp9Profile2VideoOnly[] =
"video/mp4; codecs=\"vp09.02.10.10.01.02.02.02.00\""; "video/mp4; codecs=\"vp09.02.10.10.01.02.02.02.00\"";
#if BUILDFLAG(ENABLE_AV1_DECODER)
const char kWebMAv1VideoOnly[] = "video/webm; codecs=\"av01.0.04M.08\"";
const char kMp4Av1VideoOnly[] = "video/mp4; codecs=\"av01.0.04M.08\"";
#endif // BUILDFLAG(ENABLE_AV1_DECODER)
#if BUILDFLAG(ENABLE_LIBRARY_CDMS) #if BUILDFLAG(ENABLE_LIBRARY_CDMS)
const char kWebMVp8VideoOnly[] = "video/webm; codecs=\"vp8\""; const char kWebMVp8VideoOnly[] = "video/webm; codecs=\"vp8\"";
#endif #endif
...@@ -559,18 +564,6 @@ IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoClearAudio_WebM_Opus) { ...@@ -559,18 +564,6 @@ IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoClearAudio_WebM_Opus) {
TestSimplePlayback("bear-320x240-opus-av_enc-v.webm", kWebMOpusAudioVp9Video); TestSimplePlayback("bear-320x240-opus-av_enc-v.webm", kWebMOpusAudioVp9Video);
} }
IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VP9Profile2Video_WebM) {
#if BUILDFLAG(ENABLE_WIDEVINE)
// TODO(crbug.com/707128): Update Widevine CDM to support VP9 profile 1/2/3.
if (IsWidevine(CurrentKeySystem())) {
DVLOG(0) << "Skipping test - Widevine CDM does not support VP9 profile 2";
return;
}
#endif
TestSimplePlayback("bear-320x240-v-vp9_profile2_subsample_cenc-v.webm",
kWebMVp9Profile2VideoOnly);
}
// TODO(xhwang): Test is flaky. https://crbug.com/890124. // TODO(xhwang): Test is flaky. https://crbug.com/890124.
IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, IN_PROC_BROWSER_TEST_P(EncryptedMediaTest,
DISABLED_Playback_Multiple_VideoAudio_WebM) { DISABLED_Playback_Multiple_VideoAudio_WebM) {
...@@ -599,6 +592,19 @@ IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoOnly_MP4_VP9) { ...@@ -599,6 +592,19 @@ IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoOnly_MP4_VP9) {
TestSimplePlayback("bear-320x240-v_frag-vp9-cenc.mp4", kMp4Vp9VideoOnly); TestSimplePlayback("bear-320x240-v_frag-vp9-cenc.mp4", kMp4Vp9VideoOnly);
} }
IN_PROC_BROWSER_TEST_P(EncryptedMediaTest,
Playback_VideoOnly_WebM_VP9Profile2) {
#if BUILDFLAG(ENABLE_WIDEVINE)
// TODO(crbug.com/707128): Update Widevine CDM to support VP9 profile 1/2/3.
if (IsWidevine(CurrentKeySystem())) {
DVLOG(0) << "Skipping test - Widevine CDM does not support VP9 profile 2";
return;
}
#endif
TestSimplePlayback("bear-320x240-v-vp9_profile2_subsample_cenc-v.webm",
kWebMVp9Profile2VideoOnly);
}
IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoOnly_MP4_VP9Profile2) { IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoOnly_MP4_VP9Profile2) {
// MP4 without MSE is not support yet, http://crbug.com/170793. // MP4 without MSE is not support yet, http://crbug.com/170793.
if (CurrentSourceType() != SrcType::MSE) { if (CurrentSourceType() != SrcType::MSE) {
...@@ -616,6 +622,35 @@ IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoOnly_MP4_VP9Profile2) { ...@@ -616,6 +622,35 @@ IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoOnly_MP4_VP9Profile2) {
kMp4Vp9Profile2VideoOnly); kMp4Vp9Profile2VideoOnly);
} }
#if BUILDFLAG(ENABLE_AV1_DECODER)
IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoOnly_WebM_AV1) {
#if BUILDFLAG(ENABLE_WIDEVINE)
// TODO(crbug.com/884845): Update Widevine CDM to support AV1.
if (IsWidevine(CurrentKeySystem())) {
DVLOG(0) << "Skipping test - Widevine CDM does not support AV1";
return;
}
#endif
TestSimplePlayback("bear-av1-cenc.webm", kWebMAv1VideoOnly);
}
IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoOnly_MP4_AV1) {
// MP4 without MSE is not support yet, http://crbug.com/170793.
if (CurrentSourceType() != SrcType::MSE) {
DVLOG(0) << "Skipping test; Can only play MP4 encrypted streams by MSE.";
return;
}
#if BUILDFLAG(ENABLE_WIDEVINE)
// TODO(crbug.com/884845): Update Widevine CDM to support AV1.
if (IsWidevine(CurrentKeySystem())) {
DVLOG(0) << "Skipping test - Widevine CDM does not support AV1";
return;
}
#endif
TestSimplePlayback("bear-av1-cenc.mp4", kMp4Av1VideoOnly);
}
#endif // BUILDFLAG(ENABLE_AV1_DECODER)
IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, InvalidResponseKeyError) { IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, InvalidResponseKeyError) {
RunInvalidResponseTest(); RunInvalidResponseTest();
} }
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "media/base/test_data_util.h" #include "media/base/test_data_util.h"
#include "media/media_buildflags.h" #include "media/media_buildflags.h"
#include "media/mojo/buildflags.h" #include "media/mojo/buildflags.h"
#include "third_party/libaom/av1_buildflags.h"
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
#include "base/android/build_info.h" #include "base/android/build_info.h"
...@@ -68,6 +69,11 @@ const char kMp4Vp9Profile2VideoOnly[] = ...@@ -68,6 +69,11 @@ const char kMp4Vp9Profile2VideoOnly[] =
"video/mp4; codecs=\"vp09.02.10.10.01.02.02.02.00\""; "video/mp4; codecs=\"vp09.02.10.10.01.02.02.02.00\"";
#endif // !defined(OS_ANDROID) #endif // !defined(OS_ANDROID)
#if BUILDFLAG(ENABLE_AV1_DECODER)
const char kWebMAv1VideoOnly[] = "video/webm; codecs=\"av01.0.04M.08\"";
const char kMp4Av1VideoOnly[] = "video/mp4; codecs=\"av01.0.04M.08\"";
#endif // BUILDFLAG(ENABLE_AV1_DECODER)
// EME-specific test results and errors. // EME-specific test results and errors.
const char kEmeKeyError[] = "KEYERROR"; const char kEmeKeyError[] = "KEYERROR";
const char kEmeNotSupportedError[] = "NOTSUPPORTEDERROR"; const char kEmeNotSupportedError[] = "NOTSUPPORTEDERROR";
...@@ -281,14 +287,6 @@ IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoClearAudio_WebM_Opus) { ...@@ -281,14 +287,6 @@ IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoClearAudio_WebM_Opus) {
TestSimplePlayback("bear-320x240-opus-av_enc-v.webm", kWebMOpusAudioVp9Video); TestSimplePlayback("bear-320x240-opus-av_enc-v.webm", kWebMOpusAudioVp9Video);
} }
// 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",
kWebMVp9Profile2VideoOnly);
}
#endif
IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_AudioOnly_MP4_FLAC) { IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_AudioOnly_MP4_FLAC) {
RunMultipleFileTest(std::string(), std::string(), "bear-flac-cenc.mp4", RunMultipleFileTest(std::string(), std::string(), "bear-flac-cenc.mp4",
kMp4FlacAudioOnly, media::kEnded); kMp4FlacAudioOnly, media::kEnded);
...@@ -305,6 +303,12 @@ IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoOnly_MP4_VP9) { ...@@ -305,6 +303,12 @@ IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoOnly_MP4_VP9) {
// TODO(crbug.com/707127): Decide when it's supported on Android. // TODO(crbug.com/707127): Decide when it's supported on Android.
#if !defined(OS_ANDROID) #if !defined(OS_ANDROID)
IN_PROC_BROWSER_TEST_P(EncryptedMediaTest,
Playback_VideoOnly_WebM_VP9Profile2) {
TestSimplePlayback("bear-320x240-v-vp9_profile2_subsample_cenc-v.webm",
kWebMVp9Profile2VideoOnly);
}
IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoOnly_MP4_VP9Profile2) { IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoOnly_MP4_VP9Profile2) {
// MP4 without MSE is not support yet, http://crbug.com/170793. // MP4 without MSE is not support yet, http://crbug.com/170793.
if (CurrentSourceType() != SrcType::MSE) { if (CurrentSourceType() != SrcType::MSE) {
...@@ -314,7 +318,22 @@ IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoOnly_MP4_VP9Profile2) { ...@@ -314,7 +318,22 @@ IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoOnly_MP4_VP9Profile2) {
TestSimplePlayback("bear-320x240-v-vp9_profile2_subsample_cenc-v.mp4", TestSimplePlayback("bear-320x240-v-vp9_profile2_subsample_cenc-v.mp4",
kMp4Vp9Profile2VideoOnly); kMp4Vp9Profile2VideoOnly);
} }
#endif #endif // !defined(OS_ANDROID)
#if BUILDFLAG(ENABLE_AV1_DECODER)
IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoOnly_WebM_AV1) {
TestSimplePlayback("bear-av1-cenc.webm", kWebMAv1VideoOnly);
}
IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoOnly_MP4_AV1) {
// MP4 without MSE is not support yet, http://crbug.com/170793.
if (CurrentSourceType() != SrcType::MSE) {
DVLOG(0) << "Skipping test; Can only play MP4 encrypted streams by MSE.";
return;
}
TestSimplePlayback("bear-av1-cenc.mp4", kMp4Av1VideoOnly);
}
#endif // BUILDFLAG(ENABLE_AV1_DECODER)
// Strictly speaking this is not an "encrypted" media test. Keep it here for // Strictly speaking this is not an "encrypted" media test. Keep it here for
// completeness. // completeness.
......
...@@ -24,16 +24,21 @@ ...@@ -24,16 +24,21 @@
#include "media/cdm/cdm_type_conversion.h" #include "media/cdm/cdm_type_conversion.h"
#include "media/cdm/library_cdm/cdm_host_proxy.h" #include "media/cdm/library_cdm/cdm_host_proxy.h"
#include "media/media_buildflags.h" #include "media/media_buildflags.h"
#include "third_party/libaom/av1_buildflags.h"
#include "third_party/libyuv/include/libyuv/planar_functions.h" #include "third_party/libyuv/include/libyuv/planar_functions.h"
#if BUILDFLAG(ENABLE_FFMPEG)
#include "media/filters/ffmpeg_video_decoder.h"
#endif
#if BUILDFLAG(ENABLE_LIBVPX) #if BUILDFLAG(ENABLE_LIBVPX)
#include "media/filters/vpx_video_decoder.h" #include "media/filters/vpx_video_decoder.h"
#endif #endif
#if BUILDFLAG(ENABLE_AV1_DECODER)
#include "media/filters/aom_video_decoder.h"
#endif
#if BUILDFLAG(ENABLE_FFMPEG)
#include "media/filters/ffmpeg_video_decoder.h"
#endif
namespace media { namespace media {
namespace { namespace {
...@@ -296,6 +301,11 @@ std::unique_ptr<CdmVideoDecoder> CreateVideoDecoder( ...@@ -296,6 +301,11 @@ std::unique_ptr<CdmVideoDecoder> CreateVideoDecoder(
video_decoder.reset(new VpxVideoDecoder()); video_decoder.reset(new VpxVideoDecoder());
#endif #endif
#if BUILDFLAG(ENABLE_AV1_DECODER)
if (config.codec == cdm::kCodecAv1)
video_decoder.reset(new AomVideoDecoder(null_media_log.get()));
#endif
#if BUILDFLAG(ENABLE_FFMPEG) #if BUILDFLAG(ENABLE_FFMPEG)
if (!video_decoder) if (!video_decoder)
video_decoder.reset(new FFmpegVideoDecoder(null_media_log.get())); video_decoder.reset(new FFmpegVideoDecoder(null_media_log.get()));
......
...@@ -125,7 +125,6 @@ aomenc bear_480P.yuv -w 640 -h 480 --fps=30000/1001 --cpu-used=8 \ ...@@ -125,7 +125,6 @@ aomenc bear_480P.yuv -w 640 -h 480 --fps=30000/1001 --cpu-used=8 \
--lag-in-frames=0 --test-decode=fatal --target-bitrate=50 \ --lag-in-frames=0 --test-decode=fatal --target-bitrate=50 \
-o bear-av1-640x480.webm -o bear-av1-640x480.webm
``` ```
### Alpha Channel ### Alpha Channel
#### bear-vp8a.webm #### bear-vp8a.webm
...@@ -404,6 +403,21 @@ bear-320x240-audio-only.webm encrypted using key ID [1] and key [2]. ...@@ -404,6 +403,21 @@ bear-320x240-audio-only.webm encrypted using key ID [1] and key [2].
third_party/WebKit/LayoutTests/media/resources/frame_size_change.webm encrypted third_party/WebKit/LayoutTests/media/resources/frame_size_change.webm encrypted
using key ID [1] and key [2]. using key ID [1] and key [2].
### AV1
#### bear-av1-cenc.mp4
Encrypted version of bear-av1.mp4. Encrypted by [Shaka Packager] built locally
at commit 53aa775ea488c0ffd3a2e1cb78ad000154e414e1 using key ID [1] and key [2].
```
packager in=bear-av1.mp4,stream=video,output=bear-av1-cenc.mp4
--enable_raw_key_encryption --protection_scheme cenc --clear_lead 0
--keys label=:key_id=30313233343536373839303132333435:key=ebdd62f16814d27b68ef122afce4ae3c
--pssh 000000327073736800000000EDEF8BA979D64ACEA3C827DCD51D21ED000000121210303132333435363738393031323334350000003470737368010000001077EFECC0B24D02ACE33C1E52E2FB4B000000013031323334353637383930313233343500000000
```
#### bear-av1-cenc.webm
Same as bear-av1-cenc.mp4, except that the output name is bear-av1-cenc.webm.
### Encryption Scheme Test ### Encryption Scheme Test
* bear-640x360-v_frag-cenc.mp4 * bear-640x360-v_frag-cenc.mp4
......
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