Fix for b/3501089 Require an API in the DRM client to specify the license type (offline/streaming) and b/4084670 Define events in DRM API to support license expiration, revocation, license failure. Implements events and license changes as documented in the Widevine_Java_API_for_Android_DRM_Framework spec
Change-Id: I3d0440e4f64d2279ab3b272a5287db5144e41eb1
This commit is contained in:
@@ -35,15 +35,22 @@ public:
|
||||
|
||||
void TestAsset(IDrmEngine *plugin, String8 &url);
|
||||
|
||||
void TestRemoveAllRights(IDrmEngine *plugin);
|
||||
void TestAcquireRights(IDrmEngine *plugin, String8 &url);
|
||||
void TestRegister(IDrmEngine *plugin);
|
||||
void TestAcquireRights(IDrmEngine *plugin, String8 &url, int playbackMode);
|
||||
void TestCheckRightsNotAcquired(IDrmEngine *plugin, String8 &url);
|
||||
void TestCheckValidRights(IDrmEngine *plugin, String8 &url);
|
||||
void TestGetConstraints(IDrmEngine *plugin, String8 &url);
|
||||
void TestGetConstraints(IDrmEngine *plugin, String8 &url, int playbackMode);
|
||||
void TestRemoveRights(IDrmEngine *plugin, String8 &url);
|
||||
void TestRemoveAllRights(IDrmEngine *plugin);
|
||||
|
||||
// Tests
|
||||
void Run();
|
||||
|
||||
private:
|
||||
static const int PlaybackMode_Default = 0;
|
||||
static const int PlaybackMode_Streaming = 1;
|
||||
static const int PlaybackMode_Offline = 2;
|
||||
static const int PlaybackMode_Any = PlaybackMode_Streaming | PlaybackMode_Offline;
|
||||
};
|
||||
|
||||
void WVMDrmPluginTest::Run()
|
||||
@@ -101,9 +108,25 @@ void WVMDrmPluginTest::Run()
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void WVMDrmPluginTest::TestAcquireRights(IDrmEngine *plugin, String8 &url)
|
||||
void WVMDrmPluginTest::TestRegister(IDrmEngine *plugin)
|
||||
{
|
||||
cout << "WVDrmPluginTest::TestAcquireRights url=" << url << endl;
|
||||
cout << "WVDrmPluginTest::TestRegister" << endl;
|
||||
|
||||
String8 mimeType("video/wvm");
|
||||
DrmInfoRequest registrationInfo(DrmInfoRequest::TYPE_REGISTRATION_INFO, mimeType);
|
||||
registrationInfo.put(String8("WVPortalKey"), String8("YouTube"));
|
||||
|
||||
DrmInfo *info = plugin->acquireDrmInfo(0, ®istrationInfo);
|
||||
if (info == NULL) {
|
||||
fprintf(stderr, "acquireDrmInfo failed!\n");
|
||||
exit(-1);
|
||||
}
|
||||
delete info;
|
||||
}
|
||||
|
||||
void WVMDrmPluginTest::TestAcquireRights(IDrmEngine *plugin, String8 &url, int playbackMode)
|
||||
{
|
||||
cout << "WVDrmPluginTest::TestAcquireRights url=" << url << " mode=" << playbackMode << endl;
|
||||
|
||||
String8 mimeType("video/wvm");
|
||||
DrmInfoRequest rightsAcquisitionInfo(DrmInfoRequest::TYPE_RIGHTS_ACQUISITION_INFO, mimeType);
|
||||
@@ -111,6 +134,12 @@ void WVMDrmPluginTest::TestAcquireRights(IDrmEngine *plugin, String8 &url)
|
||||
rightsAcquisitionInfo.put(String8("WVAssetURIKey"), url);
|
||||
rightsAcquisitionInfo.put(String8("WVDeviceIDKey"), String8("device1234"));
|
||||
rightsAcquisitionInfo.put(String8("WVPortalKey"), String8("YouTube"));
|
||||
if (playbackMode) {
|
||||
char num[4];
|
||||
sprintf(num, "%d", playbackMode);
|
||||
rightsAcquisitionInfo.put(String8("WVLicenseTypeKey"), String8(num));
|
||||
cout << "WVLicenseTypeKey = " << num << endl;
|
||||
}
|
||||
|
||||
DrmInfo *info = plugin->acquireDrmInfo(0, &rightsAcquisitionInfo);
|
||||
if (info == NULL) {
|
||||
@@ -158,7 +187,7 @@ void WVMDrmPluginTest::TestCheckValidRights(IDrmEngine *plugin, String8 &url)
|
||||
}
|
||||
}
|
||||
|
||||
void WVMDrmPluginTest::TestGetConstraints(IDrmEngine *plugin, String8 &url)
|
||||
void WVMDrmPluginTest::TestGetConstraints(IDrmEngine *plugin, String8 &url, int playbackMode)
|
||||
{
|
||||
cout << "WVDrmPluginTest::TestGetConstraints url=" << url << endl;
|
||||
|
||||
@@ -169,23 +198,45 @@ void WVMDrmPluginTest::TestGetConstraints(IDrmEngine *plugin, String8 &url)
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if (constraints->getCount() != 3) {
|
||||
if (constraints->getCount() != 6) {
|
||||
fprintf(stderr, "getConstraints returned unexpected count!\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if (constraints->get(DrmConstraints::LICENSE_START_TIME) == "") {
|
||||
fprintf(stderr, "getConstraints returned unexpected count!\n");
|
||||
fprintf(stderr, "getConstraints missing start time!\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if (constraints->get(DrmConstraints::LICENSE_AVAILABLE_TIME) == "") {
|
||||
fprintf(stderr, "getConstraints returned unexpected count!\n");
|
||||
fprintf(stderr, "getConstraints missing available time!\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if (constraints->get(DrmConstraints::LICENSE_EXPIRY_TIME) == "") {
|
||||
fprintf(stderr, "getConstraints returned unexpected count!\n");
|
||||
fprintf(stderr, "getConstraints missing expiry time!\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if (constraints->get(String8("WVLicenseTypeKey")) == "") {
|
||||
fprintf(stderr, "getConstraints missing license type key!\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if (constraints->get(String8("WVLicensedResolutionKey")) == "") {
|
||||
fprintf(stderr, "getConstraints missing resolution key!\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if (constraints->get(String8("WVLastErrorKey")) == "") {
|
||||
fprintf(stderr, "getConstraints missing last error key!\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
String8 licenseTypeStr = constraints->get(String8("WVLicenseTypeKey"));
|
||||
int licenseType = atol(licenseTypeStr.string());
|
||||
if (licenseType != playbackMode) {
|
||||
fprintf(stderr, "license type mismatch, expected %d, found %d\n", playbackMode, licenseType);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
@@ -218,13 +269,32 @@ void WVMDrmPluginTest::TestAsset(IDrmEngine *plugin, String8 &url)
|
||||
{
|
||||
cout << "WVDrmPluginTest::TestAsset url=" << url << endl;
|
||||
|
||||
TestAcquireRights(plugin, url);
|
||||
TestRegister(plugin);
|
||||
TestRemoveAllRights(plugin);
|
||||
TestCheckRightsNotAcquired(plugin, url);
|
||||
|
||||
TestAcquireRights(plugin, url, PlaybackMode_Default);
|
||||
TestCheckValidRights(plugin, url);
|
||||
TestGetConstraints(plugin, url);
|
||||
TestGetConstraints(plugin, url, PlaybackMode_Any);
|
||||
TestRemoveRights(plugin, url);
|
||||
TestCheckRightsNotAcquired(plugin, url);
|
||||
TestAcquireRights(plugin, url);
|
||||
TestRemoveAllRights(plugin);
|
||||
|
||||
TestAcquireRights(plugin, url, PlaybackMode_Offline);
|
||||
TestCheckValidRights(plugin, url);
|
||||
TestGetConstraints(plugin, url, PlaybackMode_Offline);
|
||||
TestRemoveRights(plugin, url);
|
||||
TestCheckRightsNotAcquired(plugin, url);
|
||||
|
||||
TestAcquireRights(plugin, url, PlaybackMode_Streaming);
|
||||
TestCheckValidRights(plugin, url);
|
||||
TestGetConstraints(plugin, url, PlaybackMode_Streaming);
|
||||
TestRemoveRights(plugin, url);
|
||||
TestCheckRightsNotAcquired(plugin, url);
|
||||
|
||||
TestAcquireRights(plugin, url, PlaybackMode_Any);
|
||||
TestCheckValidRights(plugin, url);
|
||||
TestGetConstraints(plugin, url, PlaybackMode_Any);
|
||||
TestRemoveRights(plugin, url);
|
||||
TestCheckRightsNotAcquired(plugin, url);
|
||||
}
|
||||
|
||||
@@ -232,6 +302,7 @@ int main(int argc, char **argv)
|
||||
{
|
||||
// turn off some noisy printing in WVStreamControl
|
||||
setenv("WV_SILENT", "true", 1);
|
||||
|
||||
WVMDrmPluginTest test;
|
||||
test.Run();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user