Merge "Add ContentDecryptionModule API"
This commit is contained in:
118
libwvdrmengine/cdm/include/ContentDecryptionModule.h
Normal file
118
libwvdrmengine/cdm/include/ContentDecryptionModule.h
Normal file
@@ -0,0 +1,118 @@
|
||||
/*
|
||||
* Copyright 2012 Google Inc. All Rights Reserved.
|
||||
*/
|
||||
|
||||
#ifndef WV_CONTENT_DECRYPTION_MODULE_H_
|
||||
#define WV_CONTENT_DECRYPTION_MODULE_H_
|
||||
|
||||
#include <media/stagefright/foundation/ABase.h>
|
||||
#include <utils/String8.h>
|
||||
#include <utils/KeyedVector.h>
|
||||
#include "sys/types.h"
|
||||
|
||||
#include <media/hardware/CryptoAPI.h>
|
||||
|
||||
namespace wvcdm {
|
||||
|
||||
class CdmDecryptor;
|
||||
|
||||
/**
|
||||
* This class allows the invoker of the ContentDecryptionModule to receive
|
||||
* license requests and error information. The invoker should provide a
|
||||
* concrete implementation for this class.
|
||||
*/
|
||||
class CdmClient
|
||||
{
|
||||
public:
|
||||
typedef enum {
|
||||
kErrorInvalidInitData = 0,
|
||||
kErrorInvalidKeyResponse = 1,
|
||||
kErrorInvalidSessionId = 2,
|
||||
kErrorCdmDecryptorInitializationFailed = 3,
|
||||
kErrorKeyAddFailed = 4
|
||||
} Error;
|
||||
|
||||
CdmClient();
|
||||
virtual ~CdmClient();
|
||||
|
||||
virtual void keyMessage(const android::String8& sessionId,
|
||||
const android::Vector<uint8_t>& message,
|
||||
const android::String8& defaultUrl) = 0;
|
||||
|
||||
virtual void keyAdded(const android::String8& sessionId) = 0;
|
||||
virtual void keyError(const android::String8& sessionId, Error error) = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* The ContentDecryptionModule provides a mechanism to create a license
|
||||
* request, handle the license response and handle decryption of content.
|
||||
*/
|
||||
class ContentDecryptionModule
|
||||
{
|
||||
|
||||
public:
|
||||
explicit ContentDecryptionModule(CdmClient* client);
|
||||
virtual ~ContentDecryptionModule();
|
||||
|
||||
/**
|
||||
* This generates a license request message and session ID for given
|
||||
* initialization data.
|
||||
*
|
||||
* @param[in] initData contains Content Protection system specific data
|
||||
* (initialization or PSSH data).
|
||||
* @return false on error.
|
||||
* @note CdmClient::keyMessage and CdmClient::keyError may be called
|
||||
* on successful license generation or error, respectively.
|
||||
*/
|
||||
bool generateKeyRequest(const android::Vector<uint8_t>& initData);
|
||||
|
||||
/**
|
||||
* This takes in a license response and sets up the crypto content
|
||||
* in preparation for decryption for a given session.
|
||||
*
|
||||
* @param[in] sessionId identifies the license request message created by
|
||||
* generateKeyRequest though the CdmClient::KeyMessage method.
|
||||
* @param[in] keyResponse is the license response from the license server.
|
||||
* @note CdmClient::keyError may be called on error.
|
||||
*/
|
||||
void addKey(const android::String8& sessionId,
|
||||
const android::Vector<uint8_t>& keyResponse);
|
||||
|
||||
/**
|
||||
* TODO:rfrias,edwinwong: These interfaces are pending finalization
|
||||
* of OEMCrypto APIs
|
||||
*/
|
||||
void decryptVideo(const uint8_t* keyId, const uint8_t* iv,
|
||||
size_t ivLength, const void* input,
|
||||
const android::CryptoPlugin::SubSample* subSamples,
|
||||
size_t numSubSamples, void* outputHandle, size_t* outputOffset,
|
||||
size_t* outputLength);
|
||||
|
||||
/**
|
||||
* TODO:rfrias,edwinwong: These interfaces are pending finalization
|
||||
* of OEMCrypto APIs
|
||||
*/
|
||||
void decryptAudio(const uint8_t* keyId, const uint8_t* iv,
|
||||
size_t ivLength, const void* input,
|
||||
const android::CryptoPlugin::SubSample* subSamples,
|
||||
size_t numSubSamples, void* output, size_t* outputLength);
|
||||
|
||||
/**
|
||||
* This releases resources and crypto contexts associated with a
|
||||
* given session.
|
||||
*
|
||||
* @param[in] sessionId identifies a license and associated crypto
|
||||
* contexts
|
||||
*/
|
||||
virtual void closeSession(const android::String8& sessionId);
|
||||
|
||||
private:
|
||||
CdmClient* const mClient;
|
||||
android::KeyedVector<android::String8, CdmDecryptor*> mSessionIdToDecryptorMap;
|
||||
|
||||
DISALLOW_EVIL_CONSTRUCTORS(ContentDecryptionModule);
|
||||
};
|
||||
|
||||
} // namespace wvcdm
|
||||
|
||||
#endif // WV_CONTENT_DECRYPTION_MODULE_H_
|
||||
@@ -1,2 +0,0 @@
|
||||
Rahul and Edwin fill this out
|
||||
Rahul and Edwin write tests
|
||||
Reference in New Issue
Block a user