am 575dc0ad: Merge "Fix for b/4463415 test-wvplayer unit test always returns status 2001" into honeycomb-mr2
* commit '575dc0ad5640219620bc236bc527d75019dfbe49': Fix for b/4463415 test-wvplayer unit test always returns status 2001
This commit is contained in:
@@ -12,7 +12,9 @@ LOCAL_C_INCLUDES+= \
|
|||||||
vendor/widevine/proprietary/include \
|
vendor/widevine/proprietary/include \
|
||||||
external/stlport/stlport \
|
external/stlport/stlport \
|
||||||
vendor/widevine/proprietary/streamcontrol/include \
|
vendor/widevine/proprietary/streamcontrol/include \
|
||||||
vendor/widevine/proprietary/drmwvmplugin/include
|
vendor/widevine/proprietary/drmwvmplugin/include \
|
||||||
|
frameworks/base/drm/libdrmframework/include \
|
||||||
|
frameworks/base/drm/libdrmframework/plugins/common/include
|
||||||
|
|
||||||
LOCAL_SHARED_LIBRARIES := \
|
LOCAL_SHARED_LIBRARIES := \
|
||||||
libstlport \
|
libstlport \
|
||||||
@@ -22,7 +24,8 @@ LOCAL_SHARED_LIBRARIES := \
|
|||||||
liblog \
|
liblog \
|
||||||
libutils \
|
libutils \
|
||||||
libz \
|
libz \
|
||||||
libcutils
|
libcutils \
|
||||||
|
libdl
|
||||||
|
|
||||||
LOCAL_MODULE:=test-wvplayer
|
LOCAL_MODULE:=test-wvplayer
|
||||||
|
|
||||||
|
|||||||
@@ -19,18 +19,25 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
#include <dlfcn.h>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "WVDRMPluginAPI.h"
|
|
||||||
#include "WVStreamControlAPI.h"
|
#include "WVStreamControlAPI.h"
|
||||||
#include "AndroidHooks.h"
|
#include "AndroidHooks.h"
|
||||||
|
|
||||||
|
#include "WVMDrmPlugin.h"
|
||||||
|
#include "drm/DrmInfoRequest.h"
|
||||||
|
#include "drm/DrmInfoStatus.h"
|
||||||
|
#include "drm/DrmConstraints.h"
|
||||||
|
#include "drm/DrmInfo.h"
|
||||||
|
|
||||||
#define AES_BLOCK_SIZE 16
|
#define AES_BLOCK_SIZE 16
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
using namespace android;
|
||||||
|
|
||||||
#define DEFAULT_BLOCK_SIZE 16*1024
|
#define DEFAULT_BLOCK_SIZE 16*1024
|
||||||
#define DEFAULT_PLAYBACK_BUFFER_SIZE 0*1024*1024
|
#define DEFAULT_PLAYBACK_BUFFER_SIZE 0*1024*1024
|
||||||
@@ -40,6 +47,9 @@ using namespace std;
|
|||||||
|
|
||||||
#define SHOW_BITRATE 1
|
#define SHOW_BITRATE 1
|
||||||
|
|
||||||
|
static void Terminate();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Print command line options
|
* Print command line options
|
||||||
*/
|
*/
|
||||||
@@ -55,7 +65,9 @@ void PrintUsage(char *prog)
|
|||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static WVDRMPluginAPI *sDrmPlugin = NULL;
|
static IDrmEngine *sDrmPlugin = NULL;
|
||||||
|
static void *sSharedLibHandle = NULL;
|
||||||
|
static bool sWVInitialized = false;
|
||||||
|
|
||||||
static struct termios termattr, save_termattr;
|
static struct termios termattr, save_termattr;
|
||||||
static int ttysavefd = -1;
|
static int ttysavefd = -1;
|
||||||
@@ -172,18 +184,99 @@ unsigned char kb_getc(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Terminate()
|
|
||||||
{
|
|
||||||
WV_Terminate();
|
|
||||||
exit(-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void PrintMessage(const char *msg)
|
static void PrintMessage(const char *msg)
|
||||||
{
|
{
|
||||||
printf("%s", msg);
|
printf("%s", msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void OpenDrmPlugin()
|
||||||
|
{
|
||||||
|
const char *path = "/system/lib/drm/libdrmwvmplugin.so";
|
||||||
|
sSharedLibHandle = dlopen(path, RTLD_NOW);
|
||||||
|
if (sSharedLibHandle == NULL) {
|
||||||
|
fprintf(stderr, "Can't open plugin: %s\n", path);
|
||||||
|
Terminate();
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef IDrmEngine *(*create_t)();
|
||||||
|
create_t creator = (create_t)dlsym(sSharedLibHandle, "create");
|
||||||
|
if (!creator) {
|
||||||
|
fprintf(stderr, "Can't find create method\n");
|
||||||
|
Terminate();
|
||||||
|
}
|
||||||
|
|
||||||
|
sDrmPlugin = (*creator)();
|
||||||
|
|
||||||
|
if (sDrmPlugin->initialize(0) != DRM_NO_ERROR) {
|
||||||
|
fprintf(stderr, "onInitialize failed!\n");
|
||||||
|
Terminate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void CloseDrmPlugin()
|
||||||
|
{
|
||||||
|
if (sSharedLibHandle) {
|
||||||
|
|
||||||
|
if (sDrmPlugin) {
|
||||||
|
typedef IDrmEngine *(*destroy_t)(IDrmEngine *plugin);
|
||||||
|
destroy_t destroyer = (destroy_t)dlsym(sSharedLibHandle, "destroy");
|
||||||
|
|
||||||
|
if (destroyer) {
|
||||||
|
(*destroyer(sDrmPlugin));
|
||||||
|
sDrmPlugin = NULL;
|
||||||
|
} else
|
||||||
|
fprintf(stderr, "Can't find destroy method\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
dlclose(sSharedLibHandle);
|
||||||
|
sSharedLibHandle = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void AcquireRights(IDrmEngine *plugin, string url, string drmUrl)
|
||||||
|
{
|
||||||
|
String8 mimeType("video/wvm");
|
||||||
|
DrmInfoRequest rightsAcquisitionInfo(DrmInfoRequest::TYPE_RIGHTS_ACQUISITION_INFO, mimeType);
|
||||||
|
rightsAcquisitionInfo.put(String8("WVDRMServerKey"), String8(drmUrl.c_str()));
|
||||||
|
rightsAcquisitionInfo.put(String8("WVAssetURIKey"), String8(url.c_str()));
|
||||||
|
rightsAcquisitionInfo.put(String8("WVDeviceIDKey"), String8("device1234"));
|
||||||
|
rightsAcquisitionInfo.put(String8("WVPortalKey"), String8("YouTube"));
|
||||||
|
rightsAcquisitionInfo.put(String8("WVLicenseTypeKey"), String8("1"));
|
||||||
|
|
||||||
|
DrmInfo *info = plugin->acquireDrmInfo(0, &rightsAcquisitionInfo);
|
||||||
|
if (info == NULL) {
|
||||||
|
fprintf(stderr, "acquireDrmInfo failed!\n");
|
||||||
|
Terminate();
|
||||||
|
}
|
||||||
|
|
||||||
|
DrmInfoStatus *status = plugin->processDrmInfo(0, info);
|
||||||
|
if (status == NULL || status->statusCode != DrmInfoStatus::STATUS_OK) {
|
||||||
|
fprintf(stderr, "processDrmInfo failed!\n");
|
||||||
|
Terminate();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (plugin->checkRightsStatus(0, String8(url.c_str()), Action::DEFAULT) != RightsStatus::RIGHTS_VALID) {
|
||||||
|
fprintf(stderr, "checkValidRights default action failed!\n");
|
||||||
|
Terminate();
|
||||||
|
}
|
||||||
|
|
||||||
|
delete status;
|
||||||
|
delete info;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Terminate()
|
||||||
|
{
|
||||||
|
if (sWVInitialized)
|
||||||
|
WV_Terminate();
|
||||||
|
CloseDrmPlugin();
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void _cb1(char *a, unsigned long b)
|
||||||
|
{
|
||||||
|
DrmBuffer buf(a, b);
|
||||||
|
sDrmPlugin->initializeDecryptUnit(0, NULL, 0, &buf);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Program entry pointer
|
* Program entry pointer
|
||||||
@@ -202,13 +295,6 @@ int main( int argc, char *argv[] )
|
|||||||
|
|
||||||
_ah006(PrintMessage);
|
_ah006(PrintMessage);
|
||||||
|
|
||||||
// Create DRM plugin object
|
|
||||||
sDrmPlugin = WVDRMPluginAPI::create();
|
|
||||||
if (sDrmPlugin == NULL) {
|
|
||||||
fprintf(stderr, "FATAL: failed to construct WVMDRMPluginAPI instance\n");
|
|
||||||
exit(-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
while ((option = getopt(argc, argv, "o:b:p:s:mD:d:")) != -1) {
|
while ((option = getopt(argc, argv, "o:b:p:s:mD:d:")) != -1) {
|
||||||
switch (option) {
|
switch (option) {
|
||||||
case 'o':
|
case 'o':
|
||||||
@@ -253,7 +339,7 @@ int main( int argc, char *argv[] )
|
|||||||
output = fopen(outputFile.c_str(), "wb");
|
output = fopen(outputFile.c_str(), "wb");
|
||||||
if (!output) {
|
if (!output) {
|
||||||
fprintf(stderr, "unable to open output file %s for writing\n", argv[2]);
|
fprintf(stderr, "unable to open output file %s for writing\n", argv[2]);
|
||||||
exit(-1);
|
Terminate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -265,10 +351,16 @@ int main( int argc, char *argv[] )
|
|||||||
if (status != WV_Status_OK) {
|
if (status != WV_Status_OK) {
|
||||||
fprintf(stderr, "ERROR: WV_Initialize returned status %d\n", (int)status);
|
fprintf(stderr, "ERROR: WV_Initialize returned status %d\n", (int)status);
|
||||||
Terminate();
|
Terminate();
|
||||||
}
|
} else
|
||||||
|
sWVInitialized = true;
|
||||||
|
|
||||||
// enable HTTP logging if you want to debug
|
// enable HTTP logging if you want to debug
|
||||||
//WV_SetLogging(WV_Logging_HTTP);
|
WV_SetLogging(WV_Logging_HTTP);
|
||||||
|
|
||||||
|
OpenDrmPlugin();
|
||||||
|
AcquireRights(sDrmPlugin, url, drmUrl);
|
||||||
|
|
||||||
|
_ah002(_cb1);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
status = WV_StartBandwidthCheck( url.c_str() );
|
status = WV_StartBandwidthCheck( url.c_str() );
|
||||||
@@ -294,31 +386,6 @@ int main( int argc, char *argv[] )
|
|||||||
*/
|
*/
|
||||||
WVSession *session = 0;
|
WVSession *session = 0;
|
||||||
WVCredentials credentials;
|
WVCredentials credentials;
|
||||||
credentials.deviceID="SN12345ABC";
|
|
||||||
credentials.streamID="0123456789";
|
|
||||||
credentials.portal = "YouTube";
|
|
||||||
credentials.clientIP="1.1.1.1";
|
|
||||||
credentials.drmServerURL= drmUrl;
|
|
||||||
credentials.userData="";
|
|
||||||
credentials.drmAckServerURL=DEFAULT_DRM_ACK_URL;
|
|
||||||
|
|
||||||
string dsPath = "";
|
|
||||||
string assetIdStr = "";
|
|
||||||
string systemIdStr = "";
|
|
||||||
string keyIdStr = "";
|
|
||||||
uint_t assetId, systemId, keyId;
|
|
||||||
|
|
||||||
if (!sDrmPlugin->AcquireDrmInfo(url, credentials, dsPath,
|
|
||||||
assetIdStr, systemIdStr, keyIdStr,
|
|
||||||
&assetId, &systemId, &keyId)) {
|
|
||||||
fprintf(stderr, "ERROR: AcquireDrmInfo failed\n");
|
|
||||||
Terminate();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!sDrmPlugin->ProcessDrmInfo(url, WVDRMPluginAPI::PlaybackMode_Any)) {
|
|
||||||
fprintf(stderr, "ERROR: ProcessDrmInfo failed\n");
|
|
||||||
Terminate();
|
|
||||||
}
|
|
||||||
|
|
||||||
status = WV_Setup( session, url.c_str(), "RAW/RAW/RAW;destination=getdata", credentials);
|
status = WV_Setup( session, url.c_str(), "RAW/RAW/RAW;destination=getdata", credentials);
|
||||||
if (status != WV_Status_OK) {
|
if (status != WV_Status_OK) {
|
||||||
@@ -459,8 +526,7 @@ int main( int argc, char *argv[] )
|
|||||||
case WV_Status_OK:
|
case WV_Status_OK:
|
||||||
break;
|
break;
|
||||||
case WV_Status_End_Of_Media:
|
case WV_Status_End_Of_Media:
|
||||||
printf("END OF MEDIA %d\n", trickPlayRate);
|
printf("End of Media\n");
|
||||||
break;
|
|
||||||
if (trickPlayRate < 0) {
|
if (trickPlayRate < 0) {
|
||||||
WV_Play( session, 1.0, &scale_used, "00:00:00-" );
|
WV_Play( session, 1.0, &scale_used, "00:00:00-" );
|
||||||
trickPlayRate = 1;
|
trickPlayRate = 1;
|
||||||
@@ -580,6 +646,8 @@ int main( int argc, char *argv[] )
|
|||||||
WV_Teardown( session );
|
WV_Teardown( session );
|
||||||
WV_Terminate();
|
WV_Terminate();
|
||||||
|
|
||||||
|
CloseDrmPlugin();
|
||||||
|
|
||||||
if (output)
|
if (output)
|
||||||
fclose(output);
|
fclose(output);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user