From 114f025eb6d83a6b33591a823e4a0b3d223773c3 Mon Sep 17 00:00:00 2001 From: "xhwang@chromium.org" Date: Tue, 11 Mar 2014 11:08:20 +0000 Subject: [PATCH] Reland r256032 "Clean up usage of MediaCodecBridge/MediaDrmBridge::IsAvailable()". Fixed VLOG include errors in the original CL. Description of the original CL: - All static methods in MediaCodecBridge and MediaDrmBridge check IsAvailable() internally so that callers don't need to check IsAvailable() before calling these static methods. - Remove MediaSourcePlayer::IsTypeSupported() because it's obsolete now. - Add MediaDrmBridge unittests. BUG=303864 TBR=ddorwin@chromium.org,qinmin@chromium.org Review URL: https://codereview.chromium.org/193353002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@256192 0039d316-1c4b-4281-b951-d872f2087c98 --- .../encrypted_media_message_filter_android.cc | 3 - .../media/android_video_decode_accelerator.cc | 3 - ...droid_video_decode_accelerator_unittest.cc | 2 - .../media/android_video_encode_accelerator.cc | 3 +- .../media/media_stream_dependency_factory.cc | 4 +- .../org/chromium/media/MediaDrmBridge.java | 2 +- media/base/android/media_codec_bridge.cc | 24 +++++- media/base/android/media_codec_bridge.h | 6 +- media/base/android/media_drm_bridge.cc | 9 ++ media/base/android/media_drm_bridge.h | 5 +- .../base/android/media_drm_bridge_unittest.cc | 84 ++++++++++++++++++ media/base/android/media_source_player.cc | 29 ------- media/base/android/media_source_player.h | 5 -- .../android/media_source_player_unittest.cc | 86 +------------------ media/media.gyp | 1 + 15 files changed, 126 insertions(+), 140 deletions(-) create mode 100644 media/base/android/media_drm_bridge_unittest.cc diff --git a/chrome/browser/media/encrypted_media_message_filter_android.cc b/chrome/browser/media/encrypted_media_message_filter_android.cc index b4a55a9fa4ae62..bca0225d1da64f 100644 --- a/chrome/browser/media/encrypted_media_message_filter_android.cc +++ b/chrome/browser/media/encrypted_media_message_filter_android.cc @@ -84,9 +84,6 @@ void EncryptedMediaMessageFilterAndroid::OnGetSupportedKeySystems( return; } - if (!MediaDrmBridge::IsAvailable() || !MediaCodecBridge::IsAvailable()) - return; - // TODO(qinmin): Convert codecs to container types and check whether they // are supported with the key system. if (!MediaDrmBridge::IsKeySystemSupportedWithType(request.key_system, "")) diff --git a/content/common/gpu/media/android_video_decode_accelerator.cc b/content/common/gpu/media/android_video_decode_accelerator.cc index 9999130c6eb7ed..be969f0873689b 100644 --- a/content/common/gpu/media/android_video_decode_accelerator.cc +++ b/content/common/gpu/media/android_video_decode_accelerator.cc @@ -86,9 +86,6 @@ bool AndroidVideoDecodeAccelerator::Initialize(media::VideoCodecProfile profile, client_ = client; - if (!media::MediaCodecBridge::IsAvailable()) - return false; - if (profile == media::VP8PROFILE_MAIN) { codec_ = media::kCodecVP8; } else { diff --git a/content/common/gpu/media/android_video_decode_accelerator_unittest.cc b/content/common/gpu/media/android_video_decode_accelerator_unittest.cc index 1ee5f8f695dbc5..1bb59897ec5910 100644 --- a/content/common/gpu/media/android_video_decode_accelerator_unittest.cc +++ b/content/common/gpu/media/android_video_decode_accelerator_unittest.cc @@ -82,8 +82,6 @@ class AndroidVideoDecodeAcceleratorTest : public testing::Test { }; TEST_F(AndroidVideoDecodeAcceleratorTest, ConfigureUnsupportedCodec) { - if (!media::MediaCodecBridge::IsAvailable()) - return; EXPECT_FALSE(Configure(media::kUnknownVideoCodec)); } diff --git a/content/common/gpu/media/android_video_encode_accelerator.cc b/content/common/gpu/media/android_video_encode_accelerator.cc index 9e0aefcad3b1f8..fe2679f90d4a62 100644 --- a/content/common/gpu/media/android_video_encode_accelerator.cc +++ b/content/common/gpu/media/android_video_encode_accelerator.cc @@ -127,8 +127,7 @@ void AndroidVideoEncodeAccelerator::Initialize( client_ptr_factory_.reset(new base::WeakPtrFactory(client)); - RETURN_ON_FAILURE(media::MediaCodecBridge::IsAvailable() && - media::MediaCodecBridge::SupportsSetParameters() && + RETURN_ON_FAILURE(media::MediaCodecBridge::SupportsSetParameters() && format == VideoFrame::I420 && output_profile == media::VP8PROFILE_MAIN, "Unexpected combo: " << format << ", " << output_profile, diff --git a/content/renderer/media/media_stream_dependency_factory.cc b/content/renderer/media/media_stream_dependency_factory.cc index f1477519c7c533..80392c3888eaa6 100644 --- a/content/renderer/media/media_stream_dependency_factory.cc +++ b/content/renderer/media/media_stream_dependency_factory.cc @@ -452,10 +452,8 @@ void MediaStreamDependencyFactory::CreatePeerConnectionFactory() { } #if defined(OS_ANDROID) - if (!media::MediaCodecBridge::IsAvailable() || - !media::MediaCodecBridge::SupportsSetParameters()) { + if (!media::MediaCodecBridge::SupportsSetParameters()) encoder_factory.reset(); - } #endif EnsureWebRtcAudioDeviceImpl(); diff --git a/media/base/android/java/src/org/chromium/media/MediaDrmBridge.java b/media/base/android/java/src/org/chromium/media/MediaDrmBridge.java index 06a02b3a7c15cb..2099ddec76a03e 100644 --- a/media/base/android/java/src/org/chromium/media/MediaDrmBridge.java +++ b/media/base/android/java/src/org/chromium/media/MediaDrmBridge.java @@ -254,7 +254,7 @@ private void closeSession(ByteBuffer session) { * Check whether the crypto scheme is supported for the given container. * If |containerMimeType| is an empty string, we just return whether * the crypto scheme is supported. - * TODO(qinmin): Implement the checking for container. + * TODO(xhwang): Implement container check. See: http://crbug.com/350481 * * @return true if the container and the crypto scheme is supported, or * false otherwise. diff --git a/media/base/android/media_codec_bridge.cc b/media/base/android/media_codec_bridge.cc index 1b35bdeb8d7709..0178844156c504 100644 --- a/media/base/android/media_codec_bridge.cc +++ b/media/base/android/media_codec_bridge.cc @@ -116,10 +116,10 @@ bool MediaCodecBridge::SupportsSetParameters() { // static std::vector MediaCodecBridge::GetCodecsInfo() { std::vector codecs_info; - JNIEnv* env = AttachCurrentThread(); if (!IsAvailable()) return codecs_info; + JNIEnv* env = AttachCurrentThread(); std::string mime_type; ScopedJavaLocalRef j_codec_info_array = Java_MediaCodecBridge_getCodecsInfo(env); @@ -144,6 +144,9 @@ std::vector MediaCodecBridge::GetCodecsInfo() { // static bool MediaCodecBridge::CanDecode(const std::string& codec, bool is_secure) { + if (!IsAvailable()) + return false; + JNIEnv* env = AttachCurrentThread(); std::string mime = CodecTypeToAndroidMimeType(codec); if (mime.empty()) @@ -161,6 +164,9 @@ bool MediaCodecBridge::CanDecode(const std::string& codec, bool is_secure) { // static bool MediaCodecBridge::IsKnownUnaccelerated(const std::string& mime_type, MediaCodecDirection direction) { + if (!IsAvailable()) + return true; + std::string codec_type = AndroidMimeTypeToCodecType(mime_type); std::vector codecs_info = MediaCodecBridge::GetCodecsInfo(); @@ -605,7 +611,11 @@ void AudioCodecBridge::SetVolume(double volume) { Java_MediaCodecBridge_setVolume(env, media_codec(), volume); } +// static AudioCodecBridge* AudioCodecBridge::Create(const AudioCodec& codec) { + if (!MediaCodecBridge::IsAvailable()) + return NULL; + const std::string mime = AudioCodecToAndroidMimeType(codec); return mime.empty() ? NULL : new AudioCodecBridge(mime); } @@ -623,12 +633,15 @@ bool VideoCodecBridge::IsKnownUnaccelerated(const VideoCodec& codec, VideoCodecToAndroidMimeType(codec), direction); } +// static VideoCodecBridge* VideoCodecBridge::CreateDecoder(const VideoCodec& codec, bool is_secure, const gfx::Size& size, jobject surface, jobject media_crypto) { - JNIEnv* env = AttachCurrentThread(); + if (!MediaCodecBridge::IsAvailable()) + return NULL; + const std::string mime = VideoCodecToAndroidMimeType(codec); if (mime.empty()) return NULL; @@ -638,6 +651,7 @@ VideoCodecBridge* VideoCodecBridge::CreateDecoder(const VideoCodec& codec, if (!bridge->media_codec()) return NULL; + JNIEnv* env = AttachCurrentThread(); ScopedJavaLocalRef j_mime = ConvertUTF8ToJavaString(env, mime); ScopedJavaLocalRef j_format( Java_MediaCodecBridge_createVideoDecoderFormat( @@ -655,13 +669,16 @@ VideoCodecBridge* VideoCodecBridge::CreateDecoder(const VideoCodec& codec, return bridge->StartInternal() ? bridge.release() : NULL; } +// static VideoCodecBridge* VideoCodecBridge::CreateEncoder(const VideoCodec& codec, const gfx::Size& size, int bit_rate, int frame_rate, int i_frame_interval, int color_format) { - JNIEnv* env = AttachCurrentThread(); + if (!MediaCodecBridge::IsAvailable()) + return NULL; + const std::string mime = VideoCodecToAndroidMimeType(codec); if (mime.empty()) return NULL; @@ -671,6 +688,7 @@ VideoCodecBridge* VideoCodecBridge::CreateEncoder(const VideoCodec& codec, if (!bridge->media_codec()) return NULL; + JNIEnv* env = AttachCurrentThread(); ScopedJavaLocalRef j_mime = ConvertUTF8ToJavaString(env, mime); ScopedJavaLocalRef j_format( Java_MediaCodecBridge_createVideoEncoderFormat(env, diff --git a/media/base/android/media_codec_bridge.h b/media/base/android/media_codec_bridge.h index e71f67f918e8df..f90edcf6ff6136 100644 --- a/media/base/android/media_codec_bridge.h +++ b/media/base/android/media_codec_bridge.h @@ -51,6 +51,8 @@ enum MediaCodecDirection { class MEDIA_EXPORT MediaCodecBridge { public: // Returns true if MediaCodec is available on the device. + // All other static methods check IsAvailable() internally. There's no need + // to check IsAvailable() explicitly before calling them. static bool IsAvailable(); // Returns true if MediaCodec.setParameters() is available on the device. @@ -61,8 +63,8 @@ class MEDIA_EXPORT MediaCodecBridge { static bool CanDecode(const std::string& codec, bool is_secure); // Represents supported codecs on android. - // TODO(qinmin): Curretly the codecs string only contains one codec, do we - // need more specific codecs separated by comma. (e.g. "vp8" -> "vp8, vp8.0") + // TODO(qinmin): Currently the codecs string only contains one codec. Do we + // need to support codecs separated by comma. (e.g. "vp8" -> "vp8, vp8.0")? struct CodecsInfo { std::string codecs; // E.g. "vp8" or "avc1". std::string name; // E.g. "OMX.google.vp8.decoder". diff --git a/media/base/android/media_drm_bridge.cc b/media/base/android/media_drm_bridge.cc index 7e47c5d0f5f517..d1119bc657d2d9 100644 --- a/media/base/android/media_drm_bridge.cc +++ b/media/base/android/media_drm_bridge.cc @@ -187,11 +187,16 @@ bool MediaDrmBridge::IsAvailable() { // static bool MediaDrmBridge::IsSecureDecoderRequired(SecurityLevel security_level) { + DCHECK(IsAvailable()); return SECURITY_LEVEL_1 == security_level; } +// static bool MediaDrmBridge::IsSecurityLevelSupported(const std::string& key_system, SecurityLevel security_level) { + if (!IsAvailable()) + return false; + // Pass 0 as |cdm_id| and NULL as |manager| as they are not used in // creation time of MediaDrmBridge. scoped_ptr media_drm_bridge = @@ -202,9 +207,13 @@ bool MediaDrmBridge::IsSecurityLevelSupported(const std::string& key_system, return media_drm_bridge->SetSecurityLevel(security_level); } +// static bool MediaDrmBridge::IsKeySystemSupportedWithType( const std::string& key_system, const std::string& container_mime_type) { + if (!IsAvailable()) + return false; + std::vector scheme_uuid = GetUUID(key_system); if (scheme_uuid.empty()) return false; diff --git a/media/base/android/media_drm_bridge.h b/media/base/android/media_drm_bridge.h index c36447f1896354..4e83eb48ca4b3f 100644 --- a/media/base/android/media_drm_bridge.h +++ b/media/base/android/media_drm_bridge.h @@ -6,8 +6,6 @@ #define MEDIA_BASE_ANDROID_MEDIA_DRM_BRIDGE_H_ #include -#include -#include #include #include @@ -39,9 +37,10 @@ class MEDIA_EXPORT MediaDrmBridge : public MediaKeys { virtual ~MediaDrmBridge(); // Checks whether MediaDRM is available. + // All other static methods check IsAvailable() internally. There's no need + // to check IsAvailable() explicitly before calling them. static bool IsAvailable(); - // TODO(xhwang): Add tests for MediaDrmBridge. See http://crbug.com/303864 static bool IsSecurityLevelSupported(const std::string& key_system, SecurityLevel security_level); diff --git a/media/base/android/media_drm_bridge_unittest.cc b/media/base/android/media_drm_bridge_unittest.cc new file mode 100644 index 00000000000000..fdf5350ed31eed --- /dev/null +++ b/media/base/android/media_drm_bridge_unittest.cc @@ -0,0 +1,84 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "base/basictypes.h" +#include "base/logging.h" +#include "media/base/android/media_drm_bridge.h" +#include "testing/gtest/include/gtest/gtest.h" + +#include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. + +namespace media { + +#define EXPECT_TRUE_IF_AVAILABLE(a) \ + do { \ + if (!MediaDrmBridge::IsAvailable()) { \ + VLOG(0) << "MediaDrm not supported on device."; \ + EXPECT_FALSE(a); \ + } else { \ + EXPECT_TRUE(a); \ + } \ + } while (0) + +const char kAudioMp4[] = "audio/mp4"; +const char kVideoMp4[] = "video/mp4"; +const char kAudioWebM[] = "audio/webm"; +const char kVideoWebM[] = "video/webm"; +const char kInvalidKeySystem[] = "invalid.keysystem"; +const MediaDrmBridge::SecurityLevel kLNone = + MediaDrmBridge::SECURITY_LEVEL_NONE; +const MediaDrmBridge::SecurityLevel kL1 = MediaDrmBridge::SECURITY_LEVEL_1; +const MediaDrmBridge::SecurityLevel kL3 = MediaDrmBridge::SECURITY_LEVEL_3; + +static bool IsKeySystemSupportedWithType( + const std::string& key_system, + const std::string& container_mime_type) { + return MediaDrmBridge::IsKeySystemSupportedWithType(key_system, + container_mime_type); +} + +static bool IsSecurityLevelSupported( + const std::string& key_system, + MediaDrmBridge::SecurityLevel security_level) { + return MediaDrmBridge::IsSecurityLevelSupported(key_system, security_level); +} + +TEST(MediaDrmBridgeTest, IsSecurityLevelSupported_Widevine) { + EXPECT_FALSE(IsSecurityLevelSupported(kWidevineKeySystem, kLNone)); + // We test "L3" fully. But for "L1" we don't check the result as it depends on + // whether the test device supports "L1". + EXPECT_TRUE_IF_AVAILABLE(IsSecurityLevelSupported(kWidevineKeySystem, kL3)); + IsSecurityLevelSupported(kWidevineKeySystem, kL1); +} + +// Invalid keysytem is NOT supported regardless whether MediaDrm is available. +TEST(MediaDrmBridgeTest, IsSecurityLevelSupported_InvalidKeySystem) { + EXPECT_FALSE(IsSecurityLevelSupported(kInvalidKeySystem, kLNone)); + EXPECT_FALSE(IsSecurityLevelSupported(kInvalidKeySystem, kL1)); + EXPECT_FALSE(IsSecurityLevelSupported(kInvalidKeySystem, kL3)); +} + +TEST(MediaDrmBridgeTest, IsTypeSupported_Widevine) { + EXPECT_TRUE_IF_AVAILABLE( + IsKeySystemSupportedWithType(kWidevineKeySystem, kAudioMp4)); + EXPECT_TRUE_IF_AVAILABLE( + IsKeySystemSupportedWithType(kWidevineKeySystem, kVideoMp4)); + + // TODO(xhwang): MediaDrmBridge.IsKeySystemSupportedWithType() doesn't check + // the container type. Fix IsKeySystemSupportedWithType() and update this test + // as necessary. See: http://crbug.com/350481 + EXPECT_TRUE_IF_AVAILABLE( + IsKeySystemSupportedWithType(kWidevineKeySystem, kAudioWebM)); + EXPECT_TRUE_IF_AVAILABLE( + IsKeySystemSupportedWithType(kWidevineKeySystem, kVideoWebM)); +} + +// Invalid keysytem is NOT supported regardless whether MediaDrm is available. +TEST(MediaDrmBridgeTest, IsTypeSupported_InvalidKeySystem) { + EXPECT_FALSE(IsKeySystemSupportedWithType(kInvalidKeySystem, "")); + EXPECT_FALSE(IsKeySystemSupportedWithType(kInvalidKeySystem, kVideoMp4)); + EXPECT_FALSE(IsKeySystemSupportedWithType(kInvalidKeySystem, kVideoWebM)); +} + +} // namespace media diff --git a/media/base/android/media_source_player.cc b/media/base/android/media_source_player.cc index 3182c9f344b0e8..584d50b2385167 100644 --- a/media/base/android/media_source_player.cc +++ b/media/base/android/media_source_player.cc @@ -31,35 +31,6 @@ const int kBytesPerAudioOutputSample = 2; namespace media { -// static -bool MediaSourcePlayer::IsTypeSupported( - const std::string& key_system, - MediaDrmBridge::SecurityLevel security_level, - const std::string& container, - const std::vector& codecs) { - if (!MediaDrmBridge::IsKeySystemSupportedWithType(key_system, container)) { - DVLOG(1) << "Key system and container '" << container << "' not supported."; - return false; - } - - if (!MediaDrmBridge::IsSecurityLevelSupported(key_system, security_level)) { - DVLOG(1) << "Key system and security level '" << security_level - << "' not supported."; - return false; - } - - bool is_secure = MediaDrmBridge::IsSecureDecoderRequired(security_level); - for (size_t i = 0; i < codecs.size(); ++i) { - if (!MediaCodecBridge::CanDecode(codecs[i], is_secure)) { - DVLOG(1) << "Codec '" << codecs[i] << "' " - << (is_secure ? "in secure mode " : "") << "not supported."; - return false; - } - } - - return true; -} - MediaSourcePlayer::MediaSourcePlayer( int player_id, MediaPlayerManager* manager, diff --git a/media/base/android/media_source_player.h b/media/base/android/media_source_player.h index 615918587065f8..b3af1be238e866 100644 --- a/media/base/android/media_source_player.h +++ b/media/base/android/media_source_player.h @@ -46,11 +46,6 @@ class MEDIA_EXPORT MediaSourcePlayer : public MediaPlayerAndroid, scoped_ptr demuxer); virtual ~MediaSourcePlayer(); - static bool IsTypeSupported(const std::string& key_system, - MediaDrmBridge::SecurityLevel security_level, - const std::string& container, - const std::vector& codecs); - // MediaPlayerAndroid implementation. virtual void SetVideoSurface(gfx::ScopedJavaSurface surface) OVERRIDE; virtual void Start() OVERRIDE; diff --git a/media/base/android/media_source_player_unittest.cc b/media/base/android/media_source_player_unittest.cc index 5ee701343c5fe8..1b0bae71d56efb 100644 --- a/media/base/android/media_source_player_unittest.cc +++ b/media/base/android/media_source_player_unittest.cc @@ -5,6 +5,7 @@ #include #include "base/basictypes.h" +#include "base/logging.h" #include "base/memory/scoped_ptr.h" #include "base/strings/stringprintf.h" #include "media/base/android/media_codec_bridge.h" @@ -17,8 +18,6 @@ #include "testing/gmock/include/gmock/gmock.h" #include "ui/gl/android/surface_texture.h" -#include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. - namespace media { // Helper macro to skip the test if MediaCodecBridge isn't available. @@ -32,17 +31,10 @@ namespace media { const int kDefaultDurationInMs = 10000; -const char kAudioMp4[] = "audio/mp4"; -const char kVideoMp4[] = "video/mp4"; -const char kAudioWebM[] = "audio/webm"; -const char kVideoWebM[] = "video/webm"; -const MediaDrmBridge::SecurityLevel kL1 = MediaDrmBridge::SECURITY_LEVEL_1; -const MediaDrmBridge::SecurityLevel kL3 = MediaDrmBridge::SECURITY_LEVEL_3; - // TODO(wolenetz/qinmin): Simplify tests with more effective mock usage, and // fix flaky pointer-based MDJ inequality testing. See http://crbug.com/327839. -// Mock of MediaPlayerManager for testing purpose +// Mock of MediaPlayerManager for testing purpose. class MockMediaPlayerManager : public MediaPlayerManager { public: explicit MockMediaPlayerManager(base::MessageLoop* message_loop) @@ -734,14 +726,6 @@ class MediaSourcePlayerTest : public testing::Test { return player_.start_time_ticks_; } - bool IsTypeSupported(const std::string& key_system, - MediaDrmBridge::SecurityLevel security_level, - const std::string& container, - const std::vector& codecs) { - return MediaSourcePlayer::IsTypeSupported( - key_system, security_level, container, codecs); - } - base::MessageLoop message_loop_; MockMediaPlayerManager manager_; MockDemuxerAndroid* demuxer_; // Owned by |player_|. @@ -2078,70 +2062,4 @@ TEST_F(MediaSourcePlayerTest, SurfaceChangeClearedEvenIfMediaCryptoAbsent) { EXPECT_FALSE(GetMediaDecoderJob(false)); } -// TODO(xhwang): Enable this test when the test devices are updated. -TEST_F(MediaSourcePlayerTest, DISABLED_IsTypeSupported_Widevine) { - if (!MediaCodecBridge::IsAvailable() || !MediaDrmBridge::IsAvailable()) { - VLOG(0) << "Could not run test - not supported on device."; - return; - } - - // We test "L3" fully. But for "L1" we don't check the result as it depend on - // whether the test device supports "L1" decoding. - - std::vector codec_avc(1, "avc1"); - std::vector codec_aac(1, "mp4a"); - std::vector codec_avc_aac(1, "avc1"); - codec_avc_aac.push_back("mp4a"); - - EXPECT_TRUE(IsTypeSupported(kWidevineKeySystem, kL3, kVideoMp4, codec_avc)); - IsTypeSupported(kWidevineKeySystem, kL1, kVideoMp4, codec_avc); - - // TODO(xhwang): L1/L3 doesn't apply to audio, so the result is messy. - // Clean this up after we have a solution to specifying decoding mode. - EXPECT_TRUE(IsTypeSupported(kWidevineKeySystem, kL3, kAudioMp4, codec_aac)); - IsTypeSupported(kWidevineKeySystem, kL1, kAudioMp4, codec_aac); - - EXPECT_TRUE( - IsTypeSupported(kWidevineKeySystem, kL3, kVideoMp4, codec_avc_aac)); - IsTypeSupported(kWidevineKeySystem, kL1, kVideoMp4, codec_avc_aac); - - std::vector codec_vp8(1, "vp8"); - std::vector codec_vorbis(1, "vorbis"); - std::vector codec_vp8_vorbis(1, "vp8"); - codec_vp8_vorbis.push_back("vorbis"); - - // TODO(xhwang): WebM is actually not supported but currently - // MediaDrmBridge.IsKeySystemSupportedWithType() doesn't check the container - // type. - // Fix IsKeySystemSupportedWithType() and update this test as necessary. - EXPECT_TRUE(IsTypeSupported(kWidevineKeySystem, kL3, kVideoWebM, codec_vp8)); - IsTypeSupported(kWidevineKeySystem, kL1, kVideoWebM, codec_vp8); - - // TODO(xhwang): L1/L3 doesn't apply to audio, so the result is messy. - // Clean this up after we have a solution to specifying decoding mode. - EXPECT_TRUE( - IsTypeSupported(kWidevineKeySystem, kL3, kAudioWebM, codec_vorbis)); - IsTypeSupported(kWidevineKeySystem, kL1, kAudioWebM, codec_vorbis); - - EXPECT_TRUE( - IsTypeSupported(kWidevineKeySystem, kL3, kVideoWebM, codec_vp8_vorbis)); - IsTypeSupported(kWidevineKeySystem, kL1, kVideoWebM, codec_vp8_vorbis); -} - -TEST_F(MediaSourcePlayerTest, IsTypeSupported_InvalidKeySystem) { - if (!MediaCodecBridge::IsAvailable() || !MediaDrmBridge::IsAvailable()) { - VLOG(0) << "Could not run test - not supported on device."; - return; - } - - const char kInvalidKeySystem[] = "invalid.keysystem"; - - std::vector codec_avc(1, "avc1"); - EXPECT_FALSE(IsTypeSupported(kInvalidKeySystem, kL3, kVideoMp4, codec_avc)); - EXPECT_FALSE(IsTypeSupported(kInvalidKeySystem, kL1, kVideoMp4, codec_avc)); -} - -// TODO(xhwang): Are these IsTypeSupported tests device specific? -// TODO(xhwang): Add more IsTypeSupported tests. - } // namespace media diff --git a/media/media.gyp b/media/media.gyp index 4782741d1c2b78..989b16e3b37ebc 100644 --- a/media/media.gyp +++ b/media/media.gyp @@ -949,6 +949,7 @@ 'audio/win/audio_output_win_unittest.cc', 'audio/win/core_audio_util_win_unittest.cc', 'base/android/media_codec_bridge_unittest.cc', + 'base/android/media_drm_bridge_unittest.cc', 'base/android/media_source_player_unittest.cc', 'base/audio_buffer_unittest.cc', 'base/audio_buffer_queue_unittest.cc',