Commit d680c4cb authored by ddorwin@chromium.org's avatar ddorwin@chromium.org

Allow suppressed EME canPlayType() responses to be overridden with a flag.

Adds --override-encrypted-media-canplaytype and the corresponding flag.

BUG=252967
TBR=jochen@chromium.org

Review URL: https://chromiumcodereview.appspot.com/17459003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@208096 0039d316-1c4b-4281-b951-d872f2087c98
parent 3d7205ae
...@@ -754,6 +754,13 @@ const Experiment kExperiments[] = { ...@@ -754,6 +754,13 @@ const Experiment kExperiments[] = {
kOsDesktop, kOsDesktop,
SINGLE_VALUE_TYPE(switches::kDisableLegacyEncryptedMedia) SINGLE_VALUE_TYPE(switches::kDisableLegacyEncryptedMedia)
}, },
{
"override-encrypted-media-canplaytype",
IDS_FLAGS_ENCRYPTED_MEDIA_CANPLAYTYPE_OVERRIDE_NAME,
IDS_FLAGS_ENCRYPTED_MEDIA_CANPLAYTYPE_OVERRIDE_DESCRIPTION,
kOsMac | kOsWin,
SINGLE_VALUE_TYPE(switches::kOverrideEncryptedMediaCanPlayType)
},
{ {
"enable-opus-playback", "enable-opus-playback",
IDS_FLAGS_ENABLE_OPUS_PLAYBACK_NAME, IDS_FLAGS_ENABLE_OPUS_PLAYBACK_NAME,
......
...@@ -894,6 +894,7 @@ void RenderProcessHostImpl::PropagateBrowserCommandLineToRenderer( ...@@ -894,6 +894,7 @@ void RenderProcessHostImpl::PropagateBrowserCommandLineToRenderer(
switches::kEnableDelegatedRenderer, switches::kEnableDelegatedRenderer,
switches::kEnableEncryptedMedia, switches::kEnableEncryptedMedia,
switches::kDisableLegacyEncryptedMedia, switches::kDisableLegacyEncryptedMedia,
switches::kOverrideEncryptedMediaCanPlayType,
switches::kEnableExperimentalWebKitFeatures, switches::kEnableExperimentalWebKitFeatures,
switches::kEnableFixedLayout, switches::kEnableFixedLayout,
switches::kEnableDeferredImageDecoding, switches::kEnableDeferredImageDecoding,
......
...@@ -21,6 +21,10 @@ const char kEnableVp8AlphaPlayback[] = "enable-vp8-alpha-playback"; ...@@ -21,6 +21,10 @@ const char kEnableVp8AlphaPlayback[] = "enable-vp8-alpha-playback";
// Set number of threads to use for video decoding. // Set number of threads to use for video decoding.
const char kVideoThreads[] = "video-threads"; const char kVideoThreads[] = "video-threads";
// Override suppressed responses to canPlayType().
const char kOverrideEncryptedMediaCanPlayType[] =
"override-encrypted-media-canplaytype";
#if defined(GOOGLE_TV) #if defined(GOOGLE_TV)
// Use external video surface for video with more than or equal pixels to // Use external video surface for video with more than or equal pixels to
// specified value. For example, value of 0 will enable external video surface // specified value. For example, value of 0 will enable external video surface
......
...@@ -22,6 +22,8 @@ MEDIA_EXPORT extern const char kEnableVp8AlphaPlayback[]; ...@@ -22,6 +22,8 @@ MEDIA_EXPORT extern const char kEnableVp8AlphaPlayback[];
MEDIA_EXPORT extern const char kVideoThreads[]; MEDIA_EXPORT extern const char kVideoThreads[];
MEDIA_EXPORT extern const char kOverrideEncryptedMediaCanPlayType[];
#if defined(GOOGLE_TV) #if defined(GOOGLE_TV)
MEDIA_EXPORT extern const char kUseExternalVideoSurfaceThresholdInPixels[]; MEDIA_EXPORT extern const char kUseExternalVideoSurfaceThresholdInPixels[];
#endif #endif
......
...@@ -112,6 +112,11 @@ bool KeySystems::IsSupportedKeySystemWithMediaMimeType( ...@@ -112,6 +112,11 @@ bool KeySystems::IsSupportedKeySystemWithMediaMimeType(
const std::string& mime_type, const std::string& mime_type,
const std::vector<std::string>& codecs, const std::vector<std::string>& codecs,
const std::string& key_system) { const std::string& key_system) {
// This method is only used by the canPlaytType() path (not the EME methods),
// so we check for suppressed key_systems here.
if(IsCanPlayTypeSuppressed(key_system))
return false;
if (codecs.empty()) if (codecs.empty())
return IsSupportedKeySystemWithContainerAndCodec( return IsSupportedKeySystemWithContainerAndCodec(
mime_type, std::string(), key_system); mime_type, std::string(), key_system);
......
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
#include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR.
// The following must be after widevine_cdm_version.h.
#if defined(WIDEVINE_CDM_AVAILABLE) && \ #if defined(WIDEVINE_CDM_AVAILABLE) && \
defined(OS_LINUX) && !defined(OS_CHROMEOS) defined(OS_LINUX) && !defined(OS_CHROMEOS)
#include <gnu/libc-version.h> #include <gnu/libc-version.h>
...@@ -13,6 +15,11 @@ ...@@ -13,6 +15,11 @@
#include "base/version.h" #include "base/version.h"
#endif #endif
#if defined(DISABLE_WIDEVINE_CDM_CANPLAYTYPE)
#include "base/command_line.h"
#include "media/base/media_switches.h"
#endif
namespace webkit_media { namespace webkit_media {
static const char kClearKeyKeySystem[] = "webkit-org.w3.clearkey"; static const char kClearKeyKeySystem[] = "webkit-org.w3.clearkey";
...@@ -23,7 +30,6 @@ static const char kExternalClearKeyKeySystem[] = ...@@ -23,7 +30,6 @@ static const char kExternalClearKeyKeySystem[] =
#if defined(WIDEVINE_CDM_AVAILABLE) #if defined(WIDEVINE_CDM_AVAILABLE)
// TODO(ddorwin): Automatically support parent systems: http://crbug.com/164303. // TODO(ddorwin): Automatically support parent systems: http://crbug.com/164303.
static const char kWidevineBaseKeySystem[] = "com.widevine"; static const char kWidevineBaseKeySystem[] = "com.widevine";
#endif // defined(WIDEVINE_CDM_AVAILABLE)
#if defined(WIDEVINE_CDM_CENC_SUPPORT_AVAILABLE) #if defined(WIDEVINE_CDM_CENC_SUPPORT_AVAILABLE)
// The supported codecs depend on what the CDM provides. // The supported codecs depend on what the CDM provides.
...@@ -45,6 +51,12 @@ static const char kWidevineAudioMp4Codecs[] = ...@@ -45,6 +51,12 @@ static const char kWidevineAudioMp4Codecs[] =
#endif #endif
#endif // defined(WIDEVINE_CDM_CENC_SUPPORT_AVAILABLE) #endif // defined(WIDEVINE_CDM_CENC_SUPPORT_AVAILABLE)
static inline bool IsWidevine(const std::string& key_system) {
return key_system == kWidevineKeySystem ||
key_system == kWidevineBaseKeySystem;
}
#endif // defined(WIDEVINE_CDM_AVAILABLE)
const MediaFormatAndKeySystem kSupportedFormatKeySystemCombinations[] = { const MediaFormatAndKeySystem kSupportedFormatKeySystemCombinations[] = {
// Clear Key. // Clear Key.
{ "video/webm", "vorbis,vp8,vp8.0", kClearKeyKeySystem }, { "video/webm", "vorbis,vp8,vp8.0", kClearKeyKeySystem },
...@@ -64,10 +76,6 @@ const MediaFormatAndKeySystem kSupportedFormatKeySystemCombinations[] = { ...@@ -64,10 +76,6 @@ const MediaFormatAndKeySystem kSupportedFormatKeySystemCombinations[] = {
#if defined(WIDEVINE_CDM_AVAILABLE) #if defined(WIDEVINE_CDM_AVAILABLE)
// Widevine. // Widevine.
// See http://crbug.com/237627.
#if defined(DISABLE_WIDEVINE_CDM_CANPLAYTYPE)
{ "", "", kWidevineKeySystem },
#else
{ "video/webm", "vorbis,vp8,vp8.0", kWidevineKeySystem }, { "video/webm", "vorbis,vp8,vp8.0", kWidevineKeySystem },
{ "audio/webm", "vorbis", kWidevineKeySystem }, { "audio/webm", "vorbis", kWidevineKeySystem },
{ "video/webm", "vorbis,vp8,vp8.0", kWidevineBaseKeySystem }, { "video/webm", "vorbis,vp8,vp8.0", kWidevineBaseKeySystem },
...@@ -80,7 +88,6 @@ const MediaFormatAndKeySystem kSupportedFormatKeySystemCombinations[] = { ...@@ -80,7 +88,6 @@ const MediaFormatAndKeySystem kSupportedFormatKeySystemCombinations[] = {
{ "audio/mp4", kWidevineAudioMp4Codecs, kWidevineBaseKeySystem }, { "audio/mp4", kWidevineAudioMp4Codecs, kWidevineBaseKeySystem },
#endif // defined(WIDEVINE_CDM_CENC_SUPPORT_AVAILABLE) #endif // defined(WIDEVINE_CDM_CENC_SUPPORT_AVAILABLE)
#endif // defined(GOOGLE_CHROME_BUILD) || defined(USE_PROPRIETARY_CODECS) #endif // defined(GOOGLE_CHROME_BUILD) || defined(USE_PROPRIETARY_CODECS)
#endif // defined(DISABLE_WIDEVINE_CDM_CANPLAYTYPE)
#endif // WIDEVINE_CDM_AVAILABLE #endif // WIDEVINE_CDM_AVAILABLE
}; };
...@@ -117,8 +124,7 @@ const int kNumKeySystemToUUIDMapping = ...@@ -117,8 +124,7 @@ const int kNumKeySystemToUUIDMapping =
bool IsSystemCompatible(const std::string& key_system) { bool IsSystemCompatible(const std::string& key_system) {
#if defined(WIDEVINE_CDM_AVAILABLE) && \ #if defined(WIDEVINE_CDM_AVAILABLE) && \
defined(OS_LINUX) && !defined(OS_CHROMEOS) defined(OS_LINUX) && !defined(OS_CHROMEOS)
if (key_system == kWidevineKeySystem || if (IsWidevine(key_system)) {
key_system == kWidevineBaseKeySystem) {
Version glibc_version(gnu_get_libc_version()); Version glibc_version(gnu_get_libc_version());
DCHECK(glibc_version.IsValid()); DCHECK(glibc_version.IsValid());
return !glibc_version.IsOlderThan(WIDEVINE_CDM_MIN_GLIBC_VERSION); return !glibc_version.IsOlderThan(WIDEVINE_CDM_MIN_GLIBC_VERSION);
...@@ -127,6 +133,17 @@ bool IsSystemCompatible(const std::string& key_system) { ...@@ -127,6 +133,17 @@ bool IsSystemCompatible(const std::string& key_system) {
return true; return true;
} }
bool IsCanPlayTypeSuppressed(const std::string& key_system) {
#if defined(DISABLE_WIDEVINE_CDM_CANPLAYTYPE)
// See http://crbug.com/237627.
if (IsWidevine(key_system) &&
!CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEncryptedMediaCanPlayTypeOverride))
return true;
#endif
return false;
}
std::string KeySystemNameForUMAGeneric(const std::string& key_system) { std::string KeySystemNameForUMAGeneric(const std::string& key_system) {
if (key_system == kClearKeyKeySystem) if (key_system == kClearKeyKeySystem)
return "ClearKey"; return "ClearKey";
......
...@@ -55,6 +55,9 @@ extern const int kNumKeySystemToUUIDMapping; ...@@ -55,6 +55,9 @@ extern const int kNumKeySystemToUUIDMapping;
// Returns whether |key_system| is compatible with the user's system. // Returns whether |key_system| is compatible with the user's system.
bool IsSystemCompatible(const std::string& key_system); bool IsSystemCompatible(const std::string& key_system);
// Returns true if canPlayType should return an empty string for |key_system|.
bool IsCanPlayTypeSuppressed(const std::string& key_system);
// Returns the name that UMA will use for the given |key_system|. // Returns the name that UMA will use for the given |key_system|.
// This function can be called frequently. Hence this function should be // This function can be called frequently. Hence this function should be
// implemented not to impact performance. // implemented not to impact performance.
......
...@@ -540,7 +540,13 @@ TEST_F(KeySystemsTest, ...@@ -540,7 +540,13 @@ TEST_F(KeySystemsTest,
// //
TEST_F(KeySystemsTest, Widevine_Basic) { TEST_F(KeySystemsTest, Widevine_Basic) {
#if defined(WIDEVINE_CDM_AVAILABLE) && \
defined(DISABLE_WIDEVINE_CDM_CANPLAYTYPE)
EXPECT_TRUE(IsSupportedKeySystem(WebString::fromUTF8(kWidevineAlpha)));
#else
EXPECT_WV(IsSupportedKeySystem(WebString::fromUTF8(kWidevineAlpha))); EXPECT_WV(IsSupportedKeySystem(WebString::fromUTF8(kWidevineAlpha)));
#endif
EXPECT_WV(IsSupportedKeySystemWithMediaMimeType( EXPECT_WV(IsSupportedKeySystemWithMediaMimeType(
"video/webm", no_codecs(), kWidevineAlpha)); "video/webm", no_codecs(), kWidevineAlpha));
...@@ -571,7 +577,12 @@ TEST_F(KeySystemsTest, Widevine_Basic) { ...@@ -571,7 +577,12 @@ TEST_F(KeySystemsTest, Widevine_Basic) {
TEST_F(KeySystemsTest, Widevine_Parent) { TEST_F(KeySystemsTest, Widevine_Parent) {
const char* const kWidevineParent = kWidevine; const char* const kWidevineParent = kWidevine;
#if defined(WIDEVINE_CDM_AVAILABLE) && \
defined(DISABLE_WIDEVINE_CDM_CANPLAYTYPE)
EXPECT_TRUE(IsSupportedKeySystem(WebString::fromUTF8(kWidevineParent)));
#else
EXPECT_WV(IsSupportedKeySystem(WebString::fromUTF8(kWidevineParent))); EXPECT_WV(IsSupportedKeySystem(WebString::fromUTF8(kWidevineParent)));
#endif
EXPECT_WV(IsSupportedKeySystemWithMediaMimeType( EXPECT_WV(IsSupportedKeySystemWithMediaMimeType(
"video/webm", no_codecs(), kWidevineParent)); "video/webm", no_codecs(), kWidevineParent));
......
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