Support New isContentTypeSupported API

Adds support and tests for the new isContentTypeSupported API to the
Widevine DrmEngine.

Bug: 10244066

Merge of https://widevine-internal-review.googlesource.com/#/c/7321/
from the Widevine CDM repo.

Change-Id: I4f606de7897a49da745ff76faceeb358f8ac9073
This commit is contained in:
Jeff Tinker
2013-08-22 09:33:58 -07:00
parent 2fa6b63292
commit f51c0d27e1
3 changed files with 52 additions and 5 deletions

View File

@@ -19,6 +19,8 @@ class WVDrmFactory : public android::DrmFactory {
virtual bool isCryptoSchemeSupported(const uint8_t uuid[16]);
virtual bool isContentTypeSupported(const android::String8 &mimeType);
virtual android::status_t createDrmPlugin(const uint8_t uuid[16],
android::DrmPlugin** plugin);

View File

@@ -23,6 +23,11 @@ bool WVDrmFactory::isCryptoSchemeSupported(const uint8_t uuid[16]) {
return isWidevineUUID(uuid);
}
bool WVDrmFactory::isContentTypeSupported(const String8 &mimeType) {
// For now, only ISO-BMFF is supported, which has MIME-type video/mp4
return mimeType == "video/mp4";
}
status_t WVDrmFactory::createDrmPlugin(const uint8_t uuid[16],
DrmPlugin** plugin) {
if (!isCryptoSchemeSupported(uuid)) {

View File

@@ -7,6 +7,7 @@
#include "WVDrmFactory.h"
using namespace wvdrm;
using namespace android;
const uint8_t kWidevineUUID[16] = {
0xED,0xEF,0x8B,0xA9,0x79,0xD6,0x4A,0xCE,
@@ -24,18 +25,57 @@ const uint8_t kUnknownUUID[16] = {
};
TEST(WVDrmFactoryTest, SupportsSupportedCryptoSchemes) {
UniquePtr<WVDrmFactory> factory(new WVDrmFactory());
WVDrmFactory factory;
EXPECT_TRUE(factory->isCryptoSchemeSupported(kWidevineUUID)) <<
EXPECT_TRUE(factory.isCryptoSchemeSupported(kWidevineUUID)) <<
"WVPluginFactory does not support Widevine's UUID";
EXPECT_TRUE(factory->isCryptoSchemeSupported(kOldNetflixWidevineUUID)) <<
EXPECT_TRUE(factory.isCryptoSchemeSupported(kOldNetflixWidevineUUID)) <<
"WVPluginFactory does not support the old Netflix Widevine UUID";
}
TEST(WVDrmFactoryTest, DoesNotSupportUnsupportedCryptoSchemes) {
UniquePtr<WVDrmFactory> factory(new WVDrmFactory());
WVDrmFactory factory;
EXPECT_FALSE(factory->isCryptoSchemeSupported(kUnknownUUID)) <<
EXPECT_FALSE(factory.isCryptoSchemeSupported(kUnknownUUID)) <<
"WVPluginFactory incorrectly claims to support an unknown UUID";
}
TEST(WVDrmFactoryTest, SupportsSupportedContainerFormats) {
WVDrmFactory factory;
EXPECT_TRUE(factory.isContentTypeSupported(String8("video/mp4"))) <<
"WVPluginFactory does not support ISO-BMFF";
}
TEST(WVDrmFactoryTest, DoesNotSupportUnsupportedContainerFormats) {
WVDrmFactory factory;
EXPECT_FALSE(factory.isContentTypeSupported(String8("video/webm"))) <<
"WVPluginFactory incorrectly claims to support Web-M";
// Taken from Encoding.com's list of the most common internet video MIME-types
EXPECT_FALSE(factory.isContentTypeSupported(String8("video/x-matroska"))) <<
"WVPluginFactory incorrectly claims to support Matroska";
EXPECT_FALSE(factory.isContentTypeSupported(String8("video/x-flv"))) <<
"WVPluginFactory incorrectly claims to support Flash Video";
EXPECT_FALSE(factory.isContentTypeSupported(String8("application/x-mpegURL"))) <<
"WVPluginFactory incorrectly claims to support m3u8 Indexes";
EXPECT_FALSE(factory.isContentTypeSupported(String8("video/MP2T"))) <<
"WVPluginFactory incorrectly claims to support MPEG-2 TS";
EXPECT_FALSE(factory.isContentTypeSupported(String8("video/3gpp"))) <<
"WVPluginFactory incorrectly claims to support 3GP Mobile";
EXPECT_FALSE(factory.isContentTypeSupported(String8("video/quicktime"))) <<
"WVPluginFactory incorrectly claims to support Quicktime";
EXPECT_FALSE(factory.isContentTypeSupported(String8("video/x-msvideo"))) <<
"WVPluginFactory incorrectly claims to support AVI";
EXPECT_FALSE(factory.isContentTypeSupported(String8("video/x-ms-wmv"))) <<
"WVPluginFactory incorrectly claims to support WMV";
}