Initial import of Widevine Common Encryption DRM engine
Builds libwvmdrmengine.so, which is loaded by the new MediaDrm APIs to support playback of Widevine/CENC protected content. Change-Id: I6f57dd37083dfd96c402cb9dd137c7d74edc8f1c
This commit is contained in:
@@ -1,118 +0,0 @@
|
||||
/*
|
||||
* 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_
|
||||
81
libwvdrmengine/cdm/include/wv_content_decryption_module.h
Normal file
81
libwvdrmengine/cdm/include/wv_content_decryption_module.h
Normal file
@@ -0,0 +1,81 @@
|
||||
// Copyright 2013 Google Inc. All Rights Reserved.
|
||||
|
||||
#ifndef CDM_BASE_WV_CONTENT_DECRYPTION_MODULE_H_
|
||||
#define CDM_BASE_WV_CONTENT_DECRYPTION_MODULE_H_
|
||||
|
||||
#include "wv_cdm_types.h"
|
||||
|
||||
#include "utils/UniquePtr.h"
|
||||
|
||||
namespace wvcdm {
|
||||
|
||||
class CdmEngine;
|
||||
class WvCdmEventListener;
|
||||
|
||||
class WvContentDecryptionModule {
|
||||
public:
|
||||
WvContentDecryptionModule();
|
||||
virtual ~WvContentDecryptionModule();
|
||||
|
||||
// Session related methods
|
||||
virtual CdmResponseType OpenSession(const CdmKeySystem& key_system,
|
||||
CdmSessionId* session_id);
|
||||
virtual CdmResponseType CloseSession(CdmSessionId& session_id);
|
||||
|
||||
// Construct a valid license request.
|
||||
virtual CdmResponseType GenerateKeyRequest(const CdmSessionId& session_id,
|
||||
const CdmInitData& init_data,
|
||||
const CdmLicenseType license_type,
|
||||
CdmNameValueMap& app_parameters,
|
||||
CdmKeyMessage* key_request);
|
||||
|
||||
// Accept license response and extract key info.
|
||||
virtual CdmResponseType AddKey(const CdmSessionId& session_id,
|
||||
const CdmKeyResponse& key_data);
|
||||
|
||||
// Cancel session
|
||||
virtual CdmResponseType CancelKeyRequest(const CdmSessionId& session_id);
|
||||
|
||||
// Query license information
|
||||
virtual CdmResponseType QueryKeyStatus(const CdmSessionId& session_id,
|
||||
CdmNameValueMap* key_info);
|
||||
|
||||
// Provisioning related methods
|
||||
virtual CdmResponseType GetProvisioningRequest(
|
||||
CdmProvisioningRequest* request,
|
||||
std::string* default_url);
|
||||
|
||||
virtual CdmResponseType HandleProvisioningResponse(
|
||||
CdmProvisioningResponse& response);
|
||||
|
||||
// Secure stop related methods
|
||||
virtual CdmResponseType GetSecureStops(CdmSecureStops* secure_stops);
|
||||
virtual CdmResponseType ReleaseSecureStops(
|
||||
const CdmSecureStopReleaseMessage& message);
|
||||
|
||||
// Accept encrypted buffer and return decrypted data.
|
||||
virtual CdmResponseType Decrypt(const CdmSessionId& session_id,
|
||||
bool is_encrypted,
|
||||
const KeyId& key_id,
|
||||
const uint8_t* encrypted_buffer,
|
||||
size_t encrypted_size,
|
||||
const std::vector<uint8_t>& iv,
|
||||
size_t block_offset,
|
||||
void* decrypted_buffer);
|
||||
|
||||
// Event listener related methods
|
||||
virtual bool AttachEventListener(CdmSessionId& session_id,
|
||||
WvCdmEventListener* listener);
|
||||
virtual bool DetachEventListener(CdmSessionId& session_id,
|
||||
WvCdmEventListener* listener);
|
||||
private:
|
||||
|
||||
// instance variables
|
||||
UniquePtr<CdmEngine> cdm_engine_;
|
||||
|
||||
CORE_DISALLOW_COPY_AND_ASSIGN(WvContentDecryptionModule);
|
||||
};
|
||||
|
||||
} // namespace wvcdm
|
||||
|
||||
#endif // CDM_BASE_WV_CONTENT_DECRYPTION_MODULE_H_
|
||||
Reference in New Issue
Block a user