summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorddorwin@chromium.org <ddorwin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-10 22:19:43 +0000
committerddorwin@chromium.org <ddorwin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-10 22:19:43 +0000
commit77adc160f76f7d2bd784847e1b0780150c3a27db (patch)
tree3ec690dc852dec21e1d080aab91a8e516f316dda
parent73bd1db1a58f793b19b38bc589202b7dc4efd6a8 (diff)
downloadchromium_src-77adc160f76f7d2bd784847e1b0780150c3a27db.zip
chromium_src-77adc160f76f7d2bd784847e1b0780150c3a27db.tar.gz
chromium_src-77adc160f76f7d2bd784847e1b0780150c3a27db.tar.bz2
Allow support for CENC and the AVC1 and AAC codecs in the Widevine CDM to be enabled independently.
With just CENC enabled, v.canPlayType('video/mp4', 'com.widevine.alpha'); returns "maybe" but v.canPlayType('video/mp4; Codecs="avc1"', 'com.widevine.alpha'); returns "". I also changed the way that MIME type-only (no codec) calls are supported. TEST=content_unittests Review URL: https://chromiumcodereview.appspot.com/12226003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@181657 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--webkit/media/crypto/key_systems.cc65
-rw-r--r--webkit/media/crypto/key_systems_unittest.cc97
2 files changed, 121 insertions, 41 deletions
diff --git a/webkit/media/crypto/key_systems.cc b/webkit/media/crypto/key_systems.cc
index e0b5c96..89605d4 100644
--- a/webkit/media/crypto/key_systems.cc
+++ b/webkit/media/crypto/key_systems.cc
@@ -41,43 +41,64 @@ struct KeySystemPluginTypePair {
// TODO(ddorwin): Automatically support parent systems: http://crbug.com/164303.
static const char kWidevineBaseKeySystem[] = "com.widevine";
+
+#if defined(WIDEVINE_CDM_CENC_SUPPORT_AVAILABLE)
+// The supported codecs depend on what the CDM provides.
+static const char kWidevineVideoMp4Codecs[] =
+#if defined(WIDEVINE_CDM_AVC1_SUPPORT_AVAILABLE) && \
+ defined(WIDEVINE_CDM_AAC_SUPPORT_AVAILABLE)
+ "avc1,mp4a";
+#elif defined(WIDEVINE_CDM_AVC1_SUPPORT_AVAILABLE)
+ "avc1";
+#else
+ ""; // No codec strings are supported.
+#endif
+
+static const char kWidevineAudioMp4Codecs[] =
+#if defined(WIDEVINE_CDM_AAC_SUPPORT_AVAILABLE)
+ "mp4a";
+#else
+ ""; // No codec strings are supported.
+#endif
+#endif // defined(WIDEVINE_CDM_CENC_SUPPORT_AVAILABLE)
+
// Specifies the container and codec combinations supported by individual
// key systems. Each line is a container-codecs combination and the key system
-// that supports it. Multiple codecs can be listed. A trailing commas in
-// the |codecs_list| allows the container to be specified without a codec.
+// that supports it. Multiple codecs can be listed. In all cases, the container
+// without a codec is also supported.
// This list is converted at runtime into individual container-codec-key system
// entries in KeySystems::key_system_map_.
static const MediaFormatAndKeySystem kSupportedFormatKeySystemCombinations[] = {
// Clear Key.
- { "video/webm", "vorbis,vp8,vp8.0,", kClearKeyKeySystem },
- { "audio/webm", "vorbis,", kClearKeyKeySystem },
+ { "video/webm", "vorbis,vp8,vp8.0", kClearKeyKeySystem },
+ { "audio/webm", "vorbis", kClearKeyKeySystem },
#if defined(GOOGLE_CHROME_BUILD) || defined(USE_PROPRIETARY_CODECS)
- { "video/mp4", "avc1,mp4a,", kClearKeyKeySystem },
- { "audio/mp4", "mp4a,", kClearKeyKeySystem },
+ { "video/mp4", "avc1,mp4a", kClearKeyKeySystem },
+ { "audio/mp4", "mp4a", kClearKeyKeySystem },
#endif
// External Clear Key (used for testing).
- { "video/webm", "vorbis,vp8,vp8.0,", kExternalClearKeyKeySystem },
- { "audio/webm", "vorbis,", kExternalClearKeyKeySystem },
+ { "video/webm", "vorbis,vp8,vp8.0", kExternalClearKeyKeySystem },
+ { "audio/webm", "vorbis", kExternalClearKeyKeySystem },
#if defined(GOOGLE_CHROME_BUILD) || defined(USE_PROPRIETARY_CODECS)
- { "video/mp4", "avc1,mp4a,", kExternalClearKeyKeySystem },
- { "audio/mp4", "mp4a,", kExternalClearKeyKeySystem },
+ { "video/mp4", "avc1,mp4a", kExternalClearKeyKeySystem },
+ { "audio/mp4", "mp4a", kExternalClearKeyKeySystem },
#endif
#if defined(WIDEVINE_CDM_AVAILABLE)
// Widevine.
- { "video/webm", "vorbis,vp8,vp8.0,", kWidevineKeySystem },
- { "audio/webm", "vorbis,", kWidevineKeySystem },
- { "video/webm", "vorbis,vp8,vp8.0,", kWidevineBaseKeySystem },
- { "audio/webm", "vorbis,", kWidevineBaseKeySystem },
-#if defined(WIDEVINE_CDM_CENC_SUPPORT_AVAILABLE)
+ { "video/webm", "vorbis,vp8,vp8.0", kWidevineKeySystem },
+ { "audio/webm", "vorbis", kWidevineKeySystem },
+ { "video/webm", "vorbis,vp8,vp8.0", kWidevineBaseKeySystem },
+ { "audio/webm", "vorbis", kWidevineBaseKeySystem },
#if defined(GOOGLE_CHROME_BUILD) || defined(USE_PROPRIETARY_CODECS)
- { "video/mp4", "avc1,mp4a,", kWidevineKeySystem },
- { "audio/mp4", "mp4a,", kWidevineKeySystem },
- { "video/mp4", "avc1,mp4a,", kWidevineBaseKeySystem },
- { "audio/mp4", "mp4a,", kWidevineBaseKeySystem },
-#endif
-#endif
+#if defined(WIDEVINE_CDM_CENC_SUPPORT_AVAILABLE)
+ { "video/mp4", kWidevineVideoMp4Codecs, kWidevineKeySystem },
+ { "video/mp4", kWidevineVideoMp4Codecs, kWidevineBaseKeySystem },
+ { "audio/mp4", kWidevineAudioMp4Codecs, kWidevineKeySystem },
+ { "audio/mp4", kWidevineAudioMp4Codecs, kWidevineBaseKeySystem },
+#endif // defined(WIDEVINE_CDM_CENC_SUPPORT_AVAILABLE)
+#endif // defined(GOOGLE_CHROME_BUILD) || defined(USE_PROPRIETARY_CODECS)
#endif // WIDEVINE_CDM_AVAILABLE
};
@@ -132,6 +153,8 @@ KeySystems::KeySystems() {
CodecMappings codecs;
for (size_t j = 0; j < mime_type_codecs.size(); ++j)
codecs.insert(mime_type_codecs[j]);
+ // Support the MIME type string alone, without codec(s) specified.
+ codecs.insert("");
// Key systems can be repeated, so there may already be an entry.
KeySystemMappings::iterator key_system_iter =
diff --git a/webkit/media/crypto/key_systems_unittest.cc b/webkit/media/crypto/key_systems_unittest.cc
index 024c3b8..6f5dd66 100644
--- a/webkit/media/crypto/key_systems_unittest.cc
+++ b/webkit/media/crypto/key_systems_unittest.cc
@@ -21,21 +21,48 @@ using WebKit::WebString;
#if defined(WIDEVINE_CDM_AVAILABLE)
#define EXPECT_WV EXPECT_TRUE
-#else
-#define EXPECT_WV EXPECT_FALSE
-#endif
-#if defined(WIDEVINE_CDM_AVAILABLE) && \
- defined(WIDEVINE_CDM_CENC_SUPPORT_AVAILABLE)
-#define EXPECT_WVISO EXPECT_TRUE
+#if defined(WIDEVINE_CDM_CENC_SUPPORT_AVAILABLE)
+#define EXPECT_WVCENC EXPECT_TRUE
+
+#if defined(WIDEVINE_CDM_AVC1_SUPPORT_AVAILABLE)
+#define EXPECT_WVAVC1 EXPECT_TRUE
+#if defined(WIDEVINE_CDM_AAC_SUPPORT_AVAILABLE)
+#define EXPECT_WVAVC1AAC EXPECT_TRUE
+#else
+#define EXPECT_WVAVC1AAC EXPECT_FALSE
+#endif // defined(WIDEVINE_CDM_AAC_SUPPORT_AVAILABLE)
+#else // !defined(WIDEVINE_CDM_AVC1_SUPPORT_AVAILABLE)
+#define EXPECT_WVAVC1 EXPECT_FALSE
+#define EXPECT_WVAVC1AAC EXPECT_FALSE
+#endif // defined(WIDEVINE_CDM_AVC1_SUPPORT_AVAILABLE)
+
+#if defined(WIDEVINE_CDM_AAC_SUPPORT_AVAILABLE)
+#define EXPECT_WVAAC EXPECT_TRUE
#else
-#define EXPECT_WVISO EXPECT_FALSE
+#define EXPECT_WVAAC EXPECT_FALSE
#endif
+#else // !defined(WIDEVINE_CDM_CENC_SUPPORT_AVAILABLE)
+#define EXPECT_WVCENC EXPECT_FALSE
+#define EXPECT_WVAVC1 EXPECT_FALSE
+#define EXPECT_WVAVC1AAC EXPECT_FALSE
+#define EXPECT_WVAAC EXPECT_FALSE
+#endif // defined(WIDEVINE_CDM_CENC_SUPPORT_AVAILABLE)
+
+#else // !defined(WIDEVINE_CDM_AVAILABLE)
+#define EXPECT_WV EXPECT_FALSE
+#define EXPECT_WVCENC EXPECT_FALSE
+#define EXPECT_WVAVC1 EXPECT_FALSE
+#define EXPECT_WVAVC1AAC EXPECT_FALSE
+#define EXPECT_WVAAC EXPECT_FALSE
+#endif // defined(WIDEVINE_CDM_AVAILABLE)
+
namespace webkit_media {
static const char* const kClearKey = "webkit-org.w3.clearkey";
static const char* const kExternalClearKey = "org.chromium.externalclearkey";
+static const char* const kWidevine = "com.widevine";
static const char* const kWidevineAlpha = "com.widevine.alpha";
class KeySystemsTest : public testing::Test {
@@ -515,7 +542,7 @@ TEST_F(KeySystemsTest, Widevine_Basic) {
}
TEST_F(KeySystemsTest, Widevine_Parent) {
- const char* const kWidevineParent = "com.widevine";
+ const char* const kWidevineParent = kWidevine;
EXPECT_WV(IsSupportedKeySystem(WebString::fromUTF8(kWidevineParent)));
EXPECT_WV(IsSupportedKeySystemWithMediaMimeType(
@@ -568,9 +595,9 @@ TEST_F(KeySystemsTest, Widevine_IsSupportedKeySystem_InvalidVariants) {
TEST_F(KeySystemsTest, IsSupportedKeySystemWithMediaMimeType_Widevine_NoType) {
// These two should be true. See http://crbug.com/164303.
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
- "", no_codecs(), "com.widevine.alpha"));
+ "", no_codecs(), kWidevineAlpha));
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
- "", no_codecs(), "com.widevine"));
+ "", no_codecs(), kWidevine));
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
"", no_codecs(), "com.widevine.foo"));
@@ -583,8 +610,6 @@ TEST_F(KeySystemsTest, IsSupportedKeySystemWithMediaMimeType_Widevine_WebM) {
EXPECT_WV(IsSupportedKeySystemWithMediaMimeType(
"video/webm", no_codecs(), kWidevineAlpha));
EXPECT_WV(IsSupportedKeySystemWithMediaMimeType(
- "video/webm", no_codecs(), "com.widevine"));
- EXPECT_WV(IsSupportedKeySystemWithMediaMimeType(
"video/webm", vp8_codec(), kWidevineAlpha));
EXPECT_WV(IsSupportedKeySystemWithMediaMimeType(
"video/webm", vp80_codec(), kWidevineAlpha));
@@ -593,6 +618,18 @@ TEST_F(KeySystemsTest, IsSupportedKeySystemWithMediaMimeType_Widevine_WebM) {
EXPECT_WV(IsSupportedKeySystemWithMediaMimeType(
"video/webm", vorbis_codec(), kWidevineAlpha));
+ // Valid video types - parent key system.
+ EXPECT_WV(IsSupportedKeySystemWithMediaMimeType(
+ "video/webm", no_codecs(), kWidevine));
+ EXPECT_WV(IsSupportedKeySystemWithMediaMimeType(
+ "video/webm", vp8_codec(), kWidevine));
+ EXPECT_WV(IsSupportedKeySystemWithMediaMimeType(
+ "video/webm", vp80_codec(), kWidevine));
+ EXPECT_WV(IsSupportedKeySystemWithMediaMimeType(
+ "video/webm", vp8_and_vorbis_codecs(), kWidevine));
+ EXPECT_WV(IsSupportedKeySystemWithMediaMimeType(
+ "video/webm", vorbis_codec(), kWidevine));
+
// Non-Webm codecs.
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
"video/webm", avc1_codec(), kWidevineAlpha));
@@ -607,6 +644,12 @@ TEST_F(KeySystemsTest, IsSupportedKeySystemWithMediaMimeType_Widevine_WebM) {
EXPECT_WV(IsSupportedKeySystemWithMediaMimeType(
"audio/webm", vorbis_codec(), kWidevineAlpha));
+ // Valid audio types - parent key system.
+ EXPECT_WV(IsSupportedKeySystemWithMediaMimeType(
+ "audio/webm", no_codecs(), kWidevine));
+ EXPECT_WV(IsSupportedKeySystemWithMediaMimeType(
+ "audio/webm", vorbis_codec(), kWidevine));
+
// Non-audio codecs.
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
"audio/webm", vp8_codec(), kWidevineAlpha));
@@ -620,17 +663,25 @@ TEST_F(KeySystemsTest, IsSupportedKeySystemWithMediaMimeType_Widevine_WebM) {
TEST_F(KeySystemsTest, IsSupportedKeySystemWithMediaMimeType_Widevine_MP4) {
// Valid video types.
- EXPECT_WVISO(IsSupportedKeySystemWithMediaMimeType(
+ EXPECT_WVCENC(IsSupportedKeySystemWithMediaMimeType(
"video/mp4", no_codecs(), kWidevineAlpha));
- EXPECT_WVISO(IsSupportedKeySystemWithMediaMimeType(
- "video/mp4", no_codecs(), "com.widevine"));
- EXPECT_WVISO(IsSupportedKeySystemWithMediaMimeType(
+ EXPECT_WVAVC1(IsSupportedKeySystemWithMediaMimeType(
"video/mp4", avc1_codec(), kWidevineAlpha));
- EXPECT_WVISO(IsSupportedKeySystemWithMediaMimeType(
+ EXPECT_WVAVC1AAC(IsSupportedKeySystemWithMediaMimeType(
"video/mp4", avc1_and_aac_codecs(), kWidevineAlpha));
- EXPECT_WVISO(IsSupportedKeySystemWithMediaMimeType(
+ EXPECT_WVAVC1AAC(IsSupportedKeySystemWithMediaMimeType(
"video/mp4", aac_codec(), kWidevineAlpha));
+ // Valid video types - parent key system.
+ EXPECT_WVCENC(IsSupportedKeySystemWithMediaMimeType(
+ "video/mp4", no_codecs(), kWidevine));
+ EXPECT_WVAVC1(IsSupportedKeySystemWithMediaMimeType(
+ "video/mp4", avc1_codec(), kWidevine));
+ EXPECT_WVAVC1AAC(IsSupportedKeySystemWithMediaMimeType(
+ "video/mp4", avc1_and_aac_codecs(), kWidevine));
+ EXPECT_WVAVC1AAC(IsSupportedKeySystemWithMediaMimeType(
+ "video/mp4", aac_codec(), kWidevine));
+
// Extended codecs fail because this is handled by SimpleWebMimeRegistryImpl.
// They should really pass canPlayType().
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
@@ -651,11 +702,17 @@ TEST_F(KeySystemsTest, IsSupportedKeySystemWithMediaMimeType_Widevine_MP4) {
"video/mp4", mixed_codecs(), kWidevineAlpha));
// Valid audio types.
- EXPECT_WVISO(IsSupportedKeySystemWithMediaMimeType(
+ EXPECT_WVCENC(IsSupportedKeySystemWithMediaMimeType(
"audio/mp4", no_codecs(), kWidevineAlpha));
- EXPECT_WVISO(IsSupportedKeySystemWithMediaMimeType(
+ EXPECT_WVAAC(IsSupportedKeySystemWithMediaMimeType(
"audio/mp4", aac_codec(), kWidevineAlpha));
+ // Valid audio types - parent key system.
+ EXPECT_WVCENC(IsSupportedKeySystemWithMediaMimeType(
+ "audio/mp4", no_codecs(), kWidevine));
+ EXPECT_WVAAC(IsSupportedKeySystemWithMediaMimeType(
+ "audio/mp4", aac_codec(), kWidevine));
+
// Non-audio codecs.
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
"audio/mp4", avc1_codec(), kWidevineAlpha));