am ba5fa0ef: Fixes for b/4149416:expired license refresh, b/4126624:heartbeats, b/4171055: inconsistent license modes Also includes b/3500025: A/V resync issues
* commit 'ba5fa0ef570f6ca3524f8158a23371528930f0fc': Fixes for b/4149416:expired license refresh, b/4126624:heartbeats, b/4171055: inconsistent license modes Also includes b/3500025: A/V resync issues
This commit is contained in:
@@ -47,16 +47,18 @@ class WVDRMPluginAPI {
|
||||
std::string &dsPath, const std::string &assetIdStr,
|
||||
const std::string &systemIdStr,
|
||||
const std::string &keyIdStr,
|
||||
uint32_t *assetId, uint32_t *systemId,
|
||||
uint32_t *assetId, uint32_t *systemId,
|
||||
uint32_t *keyId) = 0;
|
||||
|
||||
virtual bool ProcessDrmInfo(std::string &assetPath, int playbackMode) = 0;
|
||||
virtual int CheckRightsStatus(std::string &path) = 0;
|
||||
|
||||
virtual bool GetConstraints(std::string &path, uint32_t *timeSincePlayback,
|
||||
uint32_t *timeRemaining,
|
||||
uint32_t *licenseDuration, std::string &lastError,
|
||||
bool &allowOffline, bool &allowStreaming,
|
||||
bool &denyHD) = 0;
|
||||
|
||||
virtual bool SetPlaybackStatus(int playbackStatus, off64_t position) = 0;
|
||||
virtual bool RemoveRights(std::string &path) = 0;
|
||||
virtual bool RemoveAllRights() = 0;
|
||||
@@ -67,10 +69,20 @@ class WVDRMPluginAPI {
|
||||
EventType_AcquireDrmInfoFailed,
|
||||
EventType_ProcessDrmInfoFailed,
|
||||
EventType_RightsInstalled,
|
||||
EventType_RightsRemoved
|
||||
EventType_RightsRemoved,
|
||||
|
||||
EventType_HeartbeatServer,
|
||||
EventType_HeartbeatPeriod
|
||||
};
|
||||
|
||||
typedef void (*EventHandler)(EventType type, const std::string &path);
|
||||
enum EventDestination {
|
||||
EventDestination_JavaAPI,
|
||||
EventDestination_MediaPlayer
|
||||
};
|
||||
|
||||
// Returns true if event sent, false if no handler
|
||||
typedef bool (*EventHandler)(EventType type, EventDestination destination,
|
||||
const std::string &path);
|
||||
virtual void SetEventHandler(EventHandler handler) = 0;
|
||||
|
||||
protected:
|
||||
|
||||
@@ -100,10 +100,32 @@ protected:
|
||||
ssize_t onPread(int uniqueId, DecryptHandle* decryptHandle,
|
||||
void* buffer, ssize_t numBytes, off64_t offset);
|
||||
|
||||
class Listener {
|
||||
public:
|
||||
Listener() : mListener(NULL), mUniqueId(-1) {}
|
||||
|
||||
Listener(IDrmEngine::OnInfoListener *listener, int uniqueId)
|
||||
: mListener(listener), mUniqueId(uniqueId) {};
|
||||
|
||||
IDrmEngine::OnInfoListener *GetListener() const {return mListener;}
|
||||
int GetUniqueId() const {return mUniqueId;}
|
||||
|
||||
private:
|
||||
IDrmEngine::OnInfoListener *mListener;
|
||||
int mUniqueId;
|
||||
};
|
||||
|
||||
enum MessageType {
|
||||
MessageType_HeartbeatServer = 4000,
|
||||
MessageType_HeartbeatPeriod = 4001
|
||||
};
|
||||
|
||||
private:
|
||||
static void SendEvent(WVDRMPluginAPI::EventType code, const std::string &path);
|
||||
static IDrmEngine::OnInfoListener *sOnInfoListener;
|
||||
static int sUniqueId;
|
||||
static bool SendEvent(WVDRMPluginAPI::EventType code, WVDRMPluginAPI::EventDestination dest,
|
||||
const std::string &path);
|
||||
|
||||
static Vector<Listener> *sNativeListeners;
|
||||
static Vector<Listener> *sJavaAPIListeners;
|
||||
|
||||
WVDRMPluginAPI *mDrmPluginImpl;
|
||||
};
|
||||
|
||||
Binary file not shown.
@@ -47,17 +47,21 @@ extern "C" void destroy(IDrmEngine* pPlugIn) {
|
||||
}
|
||||
|
||||
// Needed for event callout from implementation object
|
||||
IDrmEngine::OnInfoListener *WVMDrmPlugin::sOnInfoListener = NULL;
|
||||
int WVMDrmPlugin::sUniqueId;
|
||||
Vector<WVMDrmPlugin::Listener> *WVMDrmPlugin::sNativeListeners = NULL;
|
||||
Vector<WVMDrmPlugin::Listener> *WVMDrmPlugin::sJavaAPIListeners = NULL;
|
||||
|
||||
WVMDrmPlugin::WVMDrmPlugin()
|
||||
: DrmEngineBase(),
|
||||
mDrmPluginImpl(WVDRMPluginAPI::create())
|
||||
{
|
||||
sNativeListeners = new Vector<WVMDrmPlugin::Listener>();
|
||||
sJavaAPIListeners = new Vector<WVMDrmPlugin::Listener>();
|
||||
mDrmPluginImpl->SetEventHandler(&SendEvent);
|
||||
}
|
||||
|
||||
WVMDrmPlugin::~WVMDrmPlugin() {
|
||||
delete sNativeListeners;
|
||||
delete sJavaAPIListeners;
|
||||
WVDRMPluginAPI::destroy(mDrmPluginImpl);
|
||||
}
|
||||
|
||||
@@ -86,6 +90,21 @@ status_t WVMDrmPlugin::onInitialize(int uniqueId) {
|
||||
*/
|
||||
status_t WVMDrmPlugin::onTerminate(int uniqueId) {
|
||||
//LOGD("WVMDrmPlugin::onTerminate : %d", uniqueId);
|
||||
|
||||
for (size_t i = 0; i < sNativeListeners->size(); i++) {
|
||||
if ((*sNativeListeners)[i].GetUniqueId() == uniqueId) {
|
||||
sNativeListeners->removeAt(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < sJavaAPIListeners->size(); i++) {
|
||||
if ((*sJavaAPIListeners)[i].GetUniqueId() == uniqueId) {
|
||||
sJavaAPIListeners->removeAt(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return DRM_NO_ERROR;
|
||||
}
|
||||
|
||||
@@ -99,39 +118,91 @@ status_t WVMDrmPlugin::onTerminate(int uniqueId) {
|
||||
* Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
|
||||
*/
|
||||
status_t WVMDrmPlugin::onSetOnInfoListener(
|
||||
int uniqueId, const IDrmEngine::OnInfoListener* infoListener) {
|
||||
//LOGD("WVMDrmPlugin::onSetOnInfoListener : %d", uniqueId);
|
||||
sOnInfoListener = const_cast<IDrmEngine::OnInfoListener *>(infoListener);
|
||||
sUniqueId = uniqueId;
|
||||
int uniqueId, const IDrmEngine::OnInfoListener* infoListener) {
|
||||
//LOGD("WVMDrmPlugin::onSetOnInfoListener : add %d", uniqueId);
|
||||
|
||||
Listener newListener = Listener(const_cast<IDrmEngine::OnInfoListener *>(infoListener), uniqueId);
|
||||
bool found = false;
|
||||
|
||||
const int maxNativeUniqueId = 100;
|
||||
if (uniqueId <= maxNativeUniqueId) {
|
||||
// Replace old listener for this id if it exists
|
||||
for (size_t i = 0; i < sNativeListeners->size(); i++) {
|
||||
if ((*sNativeListeners)[i].GetUniqueId() == uniqueId) {
|
||||
sNativeListeners->replaceAt(newListener, i);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
sNativeListeners->push(newListener);
|
||||
} else {
|
||||
// Replace old listener for this id if it exists
|
||||
for (size_t i = 0; i < sJavaAPIListeners->size(); i++) {
|
||||
if ((*sJavaAPIListeners)[i].GetUniqueId() == uniqueId) {
|
||||
sJavaAPIListeners->replaceAt(newListener, i);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
sJavaAPIListeners->push(newListener);
|
||||
}
|
||||
|
||||
return DRM_NO_ERROR;
|
||||
}
|
||||
|
||||
void WVMDrmPlugin::SendEvent(WVDRMPluginAPI::EventType type, const std::string &path)
|
||||
bool WVMDrmPlugin::SendEvent(WVDRMPluginAPI::EventType type,
|
||||
WVDRMPluginAPI::EventDestination destination,
|
||||
const std::string &msg)
|
||||
{
|
||||
int code = -1;
|
||||
bool result = false;
|
||||
|
||||
switch(type) {
|
||||
EventType_AcquireFailed:
|
||||
case WVDRMPluginAPI::EventType_AcquireDrmInfoFailed:
|
||||
code = DrmInfoEvent::TYPE_ACQUIRE_DRM_INFO_FAILED;
|
||||
break;
|
||||
EventType_ProcessDrmInfoFailed:
|
||||
case WVDRMPluginAPI::EventType_ProcessDrmInfoFailed:
|
||||
code = DrmInfoEvent::TYPE_PROCESS_DRM_INFO_FAILED;
|
||||
break;
|
||||
EventType_RightsInstalled:
|
||||
case WVDRMPluginAPI::EventType_RightsInstalled:
|
||||
code = DrmInfoEvent::TYPE_RIGHTS_INSTALLED;
|
||||
break;
|
||||
EventType_RightsRemoved:
|
||||
case WVDRMPluginAPI::EventType_RightsRemoved:
|
||||
code = DrmInfoEvent::TYPE_RIGHTS_REMOVED;
|
||||
break;
|
||||
case WVDRMPluginAPI::EventType_HeartbeatServer:
|
||||
code = MessageType_HeartbeatServer;
|
||||
break;
|
||||
case WVDRMPluginAPI::EventType_HeartbeatPeriod:
|
||||
code = MessageType_HeartbeatPeriod;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (sOnInfoListener) {
|
||||
String8 msg = String8(path.c_str());
|
||||
DrmInfoEvent event(sUniqueId, code, msg);
|
||||
sOnInfoListener->onInfo(event);
|
||||
String8 message = String8(msg.c_str());
|
||||
|
||||
if (destination == WVDRMPluginAPI::EventDestination_JavaAPI) {
|
||||
for (size_t i = 0; i < sJavaAPIListeners->size(); i++) {
|
||||
DrmInfoEvent event((*sJavaAPIListeners)[i].GetUniqueId(), code, message);
|
||||
//LOGD("WVMDrmPlugin::SendEvent [Java]: uniqueId=%d type=%d, code=%d, msg=%s",
|
||||
// (*sJavaAPIListeners)[i].GetUniqueId(), type, code, msg.c_str());
|
||||
(*sJavaAPIListeners)[i].GetListener()->onInfo(event);
|
||||
}
|
||||
result = true;
|
||||
} else if (destination == WVDRMPluginAPI::EventDestination_MediaPlayer) {
|
||||
for (size_t i = 0; i < sNativeListeners->size(); i++) {
|
||||
DrmInfoEvent event((*sNativeListeners)[i].GetUniqueId(), code, message);
|
||||
//LOGD("WVMDrmPlugin::SendEvent [Native]: uniqueId=%d type=%d, code=%d, msg=%s",
|
||||
// (*sNativeListeners)[i].GetUniqueId(), type, code, msg.c_str());
|
||||
(*sNativeListeners)[i].GetListener()->onInfo(event);
|
||||
}
|
||||
result = true;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -341,7 +412,7 @@ DrmConstraints* WVMDrmPlugin::onGetConstraints(int uniqueId, const String8* path
|
||||
drmConstraints->put(&key, lastError.c_str());
|
||||
|
||||
if (isValid) {
|
||||
char charValue[16]; // max uint32 = 0xffffffff + terminating char
|
||||
char charValue[16]; // max uint32 + terminating char
|
||||
|
||||
memset(charValue, 0, 16);
|
||||
sprintf(charValue, "%lu", (unsigned long)timeSincePlayback);
|
||||
@@ -649,6 +720,7 @@ status_t WVMDrmPlugin::onOpenDecryptSession(
|
||||
decryptHandle->decryptApiType = DecryptApiType::WV_BASED;
|
||||
decryptHandle->status = DRM_NO_ERROR;
|
||||
decryptHandle->decryptInfo = NULL;
|
||||
|
||||
mDrmPluginImpl->OpenSession();
|
||||
result = DRM_NO_ERROR;
|
||||
} else {
|
||||
@@ -675,8 +747,6 @@ status_t WVMDrmPlugin::onOpenDecryptSession(
|
||||
if (!uri)
|
||||
return result;
|
||||
|
||||
size_t len = strlen(uri);
|
||||
|
||||
if (mDrmPluginImpl->IsSupportedMediaType(uri)) {
|
||||
//LOGD("WVMDrmPlugin::onOpenDecryptSession(uri) : %d - match", uniqueId);
|
||||
decryptHandle->mimeType = String8("video/wvm");
|
||||
@@ -712,6 +782,7 @@ status_t WVMDrmPlugin::onCloseDecryptSession(int uniqueId, DecryptHandle* decryp
|
||||
delete decryptHandle; decryptHandle = NULL;
|
||||
}
|
||||
mDrmPluginImpl->CloseSession();
|
||||
|
||||
return DRM_NO_ERROR;
|
||||
}
|
||||
|
||||
|
||||
@@ -199,7 +199,7 @@ void WVMDrmPluginTest::TestGetConstraints(IDrmEngine *plugin, String8 &url, int
|
||||
}
|
||||
|
||||
if (constraints->getCount() != 6) {
|
||||
fprintf(stderr, "getConstraints returned unexpected count!\n");
|
||||
fprintf(stderr, "getConstraints returned unexpected count: %d!\n", constraints->getCount());
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user