Source release v2.2.0-0-903 + third_party libs
Change-Id: I03f670eaeb052bc741abb347be06f8ddc58418e7
This commit is contained in:
@@ -3,42 +3,87 @@
|
||||
#ifndef WVCDM_CDM_CDM_HOST_FILE_H_
|
||||
#define WVCDM_CDM_CDM_HOST_FILE_H_
|
||||
|
||||
#include "file_store.h"
|
||||
#include "content_decryption_module.h"
|
||||
#include "file_store.h"
|
||||
#include "host_4_file_io_client.h"
|
||||
#include "scoped_ptr.h"
|
||||
|
||||
namespace wvcdm {
|
||||
|
||||
class IFileFactory;
|
||||
|
||||
class IHostFile {
|
||||
public:
|
||||
virtual ~IHostFile() {}
|
||||
virtual bool Open(const std::string& name) = 0;
|
||||
virtual ssize_t Read(char* buffer, size_t bytes) = 0;
|
||||
virtual ssize_t Write(const char* buffer, size_t bytes) = 0;
|
||||
virtual bool Close() = 0;
|
||||
virtual bool Remove(const std::string& name) = 0;
|
||||
virtual ssize_t FileSize(const std::string& name) = 0;
|
||||
};
|
||||
|
||||
class File1Impl : public IHostFile {
|
||||
public:
|
||||
explicit File1Impl(cdm::Host_1* const host_1) : host_1_(host_1) {}
|
||||
virtual ~File1Impl() {}
|
||||
virtual bool Open(const std::string& name) OVERRIDE;
|
||||
virtual ssize_t Read(char* buffer, size_t bytes) OVERRIDE;
|
||||
virtual ssize_t Write(const char* buffer, size_t bytes) OVERRIDE;
|
||||
virtual bool Close() OVERRIDE;
|
||||
virtual bool Remove(const std::string& name) OVERRIDE;
|
||||
virtual ssize_t FileSize(const std::string& name) OVERRIDE;
|
||||
private:
|
||||
cdm::Host_1* const host_1_;
|
||||
std::string fname_;
|
||||
};
|
||||
|
||||
class File4Impl : public IHostFile {
|
||||
public:
|
||||
explicit File4Impl(cdm::Host_4* const host_4) :
|
||||
host_4_(host_4), host_4_file_io_client_(host_4) {}
|
||||
virtual ~File4Impl() {}
|
||||
virtual bool Open(const std::string& name) OVERRIDE;
|
||||
virtual ssize_t Read(char* buffer, size_t bytes) OVERRIDE;
|
||||
virtual ssize_t Write(const char* buffer, size_t bytes) OVERRIDE;
|
||||
virtual bool Close() OVERRIDE;
|
||||
virtual bool Remove(const std::string& name) OVERRIDE;
|
||||
virtual ssize_t FileSize(const std::string& name) OVERRIDE;
|
||||
private:
|
||||
cdm::Host_4* const host_4_;
|
||||
Host4FileIOClient host_4_file_io_client_;
|
||||
};
|
||||
|
||||
class File::Impl {
|
||||
public:
|
||||
explicit Impl(cdm::Host* const host) : host_(host) {}
|
||||
explicit Impl(cdm::Host_1* const host_1) :
|
||||
file_api_(new File1Impl(host_1)) {}
|
||||
|
||||
static void RegisterFileFactory(IFileFactory* factory) {
|
||||
factory_ = factory;
|
||||
}
|
||||
explicit Impl(cdm::Host_4* const host_4) :
|
||||
file_api_(new File4Impl(host_4)) {}
|
||||
|
||||
~Impl() {}
|
||||
|
||||
static void RegisterFileFactory(IFileFactory* factory) { factory_ = factory; }
|
||||
|
||||
virtual bool Exists(const std::string& name);
|
||||
virtual bool Open(const std::string& name);
|
||||
virtual bool Close();
|
||||
virtual bool Remove(const std::string& name);
|
||||
virtual ssize_t Read(char* buffer, size_t bytes);
|
||||
virtual ssize_t Write(const char* buffer, size_t bytes);
|
||||
virtual bool Close();
|
||||
virtual bool Exists(const std::string& name);
|
||||
virtual bool Remove(const std::string& name);
|
||||
virtual ssize_t FileSize(const std::string& name);
|
||||
|
||||
private:
|
||||
static IFileFactory* factory_;
|
||||
friend class File;
|
||||
|
||||
cdm::Host* const host_;
|
||||
std::string fname_;
|
||||
scoped_ptr<IHostFile> file_api_;
|
||||
};
|
||||
|
||||
class IFileFactory {
|
||||
protected:
|
||||
IFileFactory() {
|
||||
File::Impl::RegisterFileFactory(this);
|
||||
}
|
||||
IFileFactory() { File::Impl::RegisterFileFactory(this); }
|
||||
|
||||
virtual ~IFileFactory() {}
|
||||
|
||||
@@ -46,6 +91,6 @@ class IFileFactory {
|
||||
virtual File::Impl* NewFileImpl() = 0;
|
||||
};
|
||||
|
||||
} // namespace wvcdm
|
||||
} // namespace wvcdm
|
||||
|
||||
#endif // WVCDM_CDM_CDM_HOST_FILE_H_
|
||||
#endif // WVCDM_CDM_CDM_HOST_FILE_H_
|
||||
|
||||
@@ -37,13 +37,11 @@ typedef __int64 int64_t;
|
||||
|
||||
#endif // defined(WIN32)
|
||||
|
||||
// The version number must be rolled when the exported functions are updated!
|
||||
// If the CDM and the adapter use different versions of these functions, the
|
||||
// adapter will fail to load or crash!
|
||||
#define INITIALIZE_CDM_MODULE InitializeCdmModule_1
|
||||
// We maintain this macro for backward compatibility only.
|
||||
#define INITIALIZE_CDM_MODULE InitializeCdmModule
|
||||
|
||||
extern "C" {
|
||||
CDM_EXPORT void INITIALIZE_CDM_MODULE();
|
||||
CDM_EXPORT void InitializeCdmModule();
|
||||
|
||||
CDM_EXPORT void DeinitializeCdmModule();
|
||||
|
||||
@@ -62,38 +60,47 @@ typedef void* (*GetCdmHostFunc)(int host_interface_version, void* user_data);
|
||||
// object.
|
||||
CDM_EXPORT void* CreateCdmInstance(
|
||||
int cdm_interface_version,
|
||||
const char* key_system, int key_system_size,
|
||||
const char* key_system, uint32_t key_system_size,
|
||||
GetCdmHostFunc get_cdm_host_func, void* user_data);
|
||||
|
||||
CDM_EXPORT int GetCdmVersion();
|
||||
CDM_EXPORT const char* GetCdmVersion();
|
||||
}
|
||||
|
||||
namespace cdm {
|
||||
|
||||
class AudioFrames;
|
||||
class DecryptedBlock;
|
||||
class VideoFrame;
|
||||
class Host_1;
|
||||
class Host_4;
|
||||
|
||||
enum Status {
|
||||
kSuccess = 0,
|
||||
kNeedMoreData, // Decoder needs more data to produce a decoded frame/sample.
|
||||
kNoKey, // The required decryption key is not available.
|
||||
kSessionError, // Session management error.
|
||||
kDecryptError, // Decryption failed.
|
||||
kDecodeError, // Error decoding audio or video.
|
||||
kRetry, // Buffer temporarily cannot be accepted. Retry after a short delay.
|
||||
kNeedsDeviceCertificate // Requires Device Certificate for content licensing
|
||||
kNoKey = 2, // The required decryption key is not available.
|
||||
kSessionError = 3, // Session management error.
|
||||
kDecryptError = 4, // Decryption failed.
|
||||
kDecodeError = 5, // Error decoding audio or video.
|
||||
kRetry = 6, // Buffer temporarily cannot be accepted, delay and retry.
|
||||
kNeedsDeviceCertificate = 7 // A certificate is required for licensing.
|
||||
};
|
||||
|
||||
// This must be consistent with MediaKeyError defined in the
|
||||
// Encrypted media Extensions (EME) specification: http://goo.gl/3Df8h
|
||||
// Encrypted media Extensions (EME) specification: http://goo.gl/IBjNCP
|
||||
enum MediaKeyError {
|
||||
kUnknownError = 1,
|
||||
kClientError,
|
||||
kServiceError,
|
||||
kOutputError,
|
||||
kHardwareChangeError,
|
||||
kDomainError
|
||||
kClientError = 2,
|
||||
kOutputError = 4,
|
||||
};
|
||||
|
||||
// The type of session to create. The valid types are defined in the spec:
|
||||
// http://goo.gl/vmc3pd
|
||||
enum SessionType {
|
||||
kTemporary = 0,
|
||||
kPersistent = 1,
|
||||
kProvisioning = 2,
|
||||
};
|
||||
|
||||
// The type of stream. Used in DecryptDecodeAndRender.
|
||||
enum StreamType {
|
||||
kStreamTypeAudio = 0,
|
||||
kStreamTypeVideo = 1
|
||||
};
|
||||
|
||||
// An input buffer can be split into several continuous subsamples.
|
||||
@@ -118,11 +125,11 @@ enum MediaKeyError {
|
||||
// | clear1 | decrypted1| clear2 | decrypted2 | clear3 | decrypted3 |
|
||||
//
|
||||
struct SubsampleEntry {
|
||||
SubsampleEntry(int32_t clear_bytes, int32_t cipher_bytes)
|
||||
SubsampleEntry(uint32_t clear_bytes, uint32_t cipher_bytes)
|
||||
: clear_bytes(clear_bytes), cipher_bytes(cipher_bytes) {}
|
||||
|
||||
int32_t clear_bytes;
|
||||
int32_t cipher_bytes;
|
||||
uint32_t clear_bytes;
|
||||
uint32_t cipher_bytes;
|
||||
};
|
||||
|
||||
// Represents an input buffer to be decrypted (and possibly decoded). It
|
||||
@@ -141,116 +148,173 @@ struct InputBuffer {
|
||||
timestamp(0) {}
|
||||
|
||||
const uint8_t* data; // Pointer to the beginning of the input data.
|
||||
int32_t data_size; // Size (in bytes) of |data|.
|
||||
uint32_t data_size; // Size (in bytes) of |data|.
|
||||
|
||||
int32_t data_offset; // Number of bytes to be discarded before decryption.
|
||||
uint32_t data_offset; // Number of bytes to be discarded before decryption.
|
||||
|
||||
const uint8_t* key_id; // Key ID to identify the decryption key.
|
||||
int32_t key_id_size; // Size (in bytes) of |key_id|.
|
||||
uint32_t key_id_size; // Size (in bytes) of |key_id|.
|
||||
|
||||
const uint8_t* iv; // Initialization vector.
|
||||
int32_t iv_size; // Size (in bytes) of |iv|.
|
||||
uint32_t iv_size; // Size (in bytes) of |iv|.
|
||||
|
||||
const struct SubsampleEntry* subsamples;
|
||||
int32_t num_subsamples; // Number of subsamples in |subsamples|.
|
||||
uint32_t num_subsamples; // Number of subsamples in |subsamples|.
|
||||
|
||||
int64_t timestamp; // Presentation timestamp in microseconds.
|
||||
};
|
||||
|
||||
struct AudioDecoderConfig {
|
||||
enum AudioCodec {
|
||||
kUnknownAudioCodec = 0,
|
||||
kCodecVorbis,
|
||||
kCodecAac
|
||||
// Represents a buffer created by the Host.
|
||||
class Buffer {
|
||||
public:
|
||||
// Destroys the buffer in the same context as it was created.
|
||||
virtual void Destroy() = 0;
|
||||
|
||||
virtual int32_t Capacity() const = 0;
|
||||
virtual uint8_t* Data() = 0;
|
||||
virtual void SetSize(int32_t size) = 0;
|
||||
virtual int32_t Size() const = 0;
|
||||
|
||||
protected:
|
||||
Buffer() {}
|
||||
virtual ~Buffer() {}
|
||||
|
||||
private:
|
||||
Buffer(const Buffer&);
|
||||
void operator=(const Buffer&);
|
||||
};
|
||||
|
||||
// Represents a key-value map.
|
||||
// Both created and destroyed by the Host.
|
||||
// Data is filled in by the CDM.
|
||||
// Need not be implemented if QueryKeyStatus() is not called.
|
||||
class KeyValueMap {
|
||||
public:
|
||||
virtual void Set(const char* key, void* value, size_t value_size) = 0;
|
||||
|
||||
protected:
|
||||
KeyValueMap() {}
|
||||
virtual ~KeyValueMap() {}
|
||||
|
||||
private:
|
||||
KeyValueMap(const KeyValueMap&);
|
||||
void operator=(const KeyValueMap&);
|
||||
};
|
||||
|
||||
// Represents a decrypted block that has not been decoded.
|
||||
class DecryptedBlock {
|
||||
public:
|
||||
virtual void SetDecryptedBuffer(Buffer* buffer) = 0;
|
||||
virtual Buffer* DecryptedBuffer() = 0;
|
||||
|
||||
virtual void SetTimestamp(int64_t timestamp) = 0;
|
||||
virtual int64_t Timestamp() const = 0;
|
||||
|
||||
protected:
|
||||
DecryptedBlock() {}
|
||||
virtual ~DecryptedBlock() {}
|
||||
};
|
||||
|
||||
// The FileIO interface provides a way for the CDM to store data in a file in
|
||||
// persistent storage. This interface aims only at providing basic read/write
|
||||
// capabilities and should not be used as a full fledged file IO API.
|
||||
//
|
||||
// All methods that report their result via calling a method on FileIOClient
|
||||
// (currently, this is Open, Read, and Write) must call into FileIOClient on the
|
||||
// same thread they were called on and must do so before returning. This
|
||||
// restriction may be lifted in the future.
|
||||
//
|
||||
// Each domain (e.g. "example.com") and each CDM has it's own persistent
|
||||
// storage. All instances of a given CDM associated with a given domain share
|
||||
// the same persistent storage.
|
||||
//
|
||||
// Note to implementors of this interface:
|
||||
// Per-origin storage and the ability for users to clear it are important.
|
||||
// See http://www.w3.org/TR/encrypted-media/#privacy-storedinfo.
|
||||
class FileIO {
|
||||
public:
|
||||
// Opens the file with |file_name| for read and write.
|
||||
// FileIOClient::OnOpenComplete() will be called after the opening
|
||||
// operation finishes.
|
||||
// - When the file is opened by a CDM instance, it will be classified as "in
|
||||
// use". In this case other CDM instances in the same domain may receive
|
||||
// kInUse status when trying to open it.
|
||||
// - |file_name| should not include path separators.
|
||||
virtual void Open(const char* file_name, uint32_t file_name_size) = 0;
|
||||
|
||||
// Reads the contents of the file. FileIOClient::OnReadComplete() will be
|
||||
// called with the read status. Read() should not be called if a previous
|
||||
// Read() or Write() call is still pending; otherwise OnReadComplete() will
|
||||
// be called with kInUse.
|
||||
virtual void Read() = 0;
|
||||
|
||||
// Writes |data_size| bytes of |data| into the file.
|
||||
// FileIOClient::OnWriteComplete() will be called with the write status.
|
||||
// All existing contents in the file will be overwritten. Calling Write() with
|
||||
// NULL |data| will clear all contents in the file. Write() should not be
|
||||
// called if a previous Write() or Read() call is still pending; otherwise
|
||||
// OnWriteComplete() will be called with kInUse.
|
||||
virtual void Write(const uint8_t* data, uint32_t data_size) = 0;
|
||||
|
||||
// Closes the file if opened, destroys this FileIO object and releases any
|
||||
// resources allocated. The CDM must call this method when it finished using
|
||||
// this object. A FileIO object must not be used after Close() is called.
|
||||
virtual void Close() = 0;
|
||||
|
||||
protected:
|
||||
FileIO() {}
|
||||
virtual ~FileIO() {}
|
||||
};
|
||||
|
||||
// Responses to FileIO calls.
|
||||
class FileIOClient {
|
||||
public:
|
||||
enum Status {
|
||||
kSuccess = 0,
|
||||
kInUse,
|
||||
kError
|
||||
};
|
||||
|
||||
AudioDecoderConfig()
|
||||
: codec(kUnknownAudioCodec),
|
||||
channel_count(0),
|
||||
bits_per_channel(0),
|
||||
samples_per_second(0),
|
||||
extra_data(NULL),
|
||||
extra_data_size(0) {}
|
||||
// Response to a FileIO::Open() call with the open |status|.
|
||||
virtual void OnOpenComplete(Status status) = 0;
|
||||
|
||||
AudioCodec codec;
|
||||
int32_t channel_count;
|
||||
int32_t bits_per_channel;
|
||||
int32_t samples_per_second;
|
||||
// Response to a FileIO::Read() call to provide |data_size| bytes of |data|
|
||||
// read from the file.
|
||||
// - kSuccess indicates that all contents of the file has been successfully
|
||||
// read. In this case, 0 |data_size| means that the file is empty.
|
||||
// - kInUse indicates that there are other read/write operations pending.
|
||||
// - kError indicates read failure, e.g. the storage isn't open or cannot be
|
||||
// fully read.
|
||||
virtual void OnReadComplete(Status status,
|
||||
const uint8_t* data, uint32_t data_size) = 0;
|
||||
|
||||
// Optional byte data required to initialize audio decoders, such as the
|
||||
// vorbis setup header.
|
||||
uint8_t* extra_data;
|
||||
int32_t extra_data_size;
|
||||
};
|
||||
// Response to a FileIO::Write() call.
|
||||
// - kSuccess indicates that all the data has been written into the file
|
||||
// successfully.
|
||||
// - kInUse indicates that there are other read/write operations pending.
|
||||
// - kError indicates write failure, e.g. the storage isn't open or cannot be
|
||||
// fully written. Upon write failure, the contents of the file should be
|
||||
// regarded as corrupt and should not used.
|
||||
virtual void OnWriteComplete(Status status) = 0;
|
||||
|
||||
// Surface formats based on FOURCC labels, see: http://www.fourcc.org/yuv.php
|
||||
enum VideoFormat {
|
||||
kUnknownVideoFormat = 0, // Unknown format value. Used for error reporting.
|
||||
kYv12, // 12bpp YVU planar 1x1 Y, 2x2 VU samples.
|
||||
kI420 // 12bpp YVU planar 1x1 Y, 2x2 UV samples.
|
||||
};
|
||||
|
||||
struct Size {
|
||||
Size() : width(0), height(0) {}
|
||||
Size(int32_t width, int32_t height) : width(width), height(height) {}
|
||||
|
||||
int32_t width;
|
||||
int32_t height;
|
||||
};
|
||||
|
||||
struct VideoDecoderConfig {
|
||||
enum VideoCodec {
|
||||
kUnknownVideoCodec = 0,
|
||||
kCodecVp8,
|
||||
kCodecH264
|
||||
};
|
||||
|
||||
enum VideoCodecProfile {
|
||||
kUnknownVideoCodecProfile = 0,
|
||||
kVp8ProfileMain,
|
||||
kH264ProfileBaseline,
|
||||
kH264ProfileMain,
|
||||
kH264ProfileExtended,
|
||||
kH264ProfileHigh,
|
||||
kH264ProfileHigh10,
|
||||
kH264ProfileHigh422,
|
||||
kH264ProfileHigh444Predictive
|
||||
};
|
||||
|
||||
VideoDecoderConfig()
|
||||
: codec(kUnknownVideoCodec),
|
||||
profile(kUnknownVideoCodecProfile),
|
||||
format(kUnknownVideoFormat),
|
||||
extra_data(NULL),
|
||||
extra_data_size(0) {}
|
||||
|
||||
VideoCodec codec;
|
||||
VideoCodecProfile profile;
|
||||
VideoFormat format;
|
||||
|
||||
// Width and height of video frame immediately post-decode. Not all pixels
|
||||
// in this region are valid.
|
||||
Size coded_size;
|
||||
|
||||
// Optional byte data required to initialize video decoders, such as H.264
|
||||
// AAVC data.
|
||||
uint8_t* extra_data;
|
||||
int32_t extra_data_size;
|
||||
};
|
||||
|
||||
enum StreamType {
|
||||
kStreamTypeAudio = 0,
|
||||
kStreamTypeVideo = 1
|
||||
protected:
|
||||
FileIOClient() {}
|
||||
virtual ~FileIOClient() {}
|
||||
};
|
||||
|
||||
// ContentDecryptionModule interface that all CDMs need to implement.
|
||||
// The interface is versioned for backward compatibility.
|
||||
// Note: ContentDecryptionModule implementations must use the allocator
|
||||
// provided in CreateCdmInstance() to allocate any Buffer that needs to
|
||||
// be passed back to the caller. Implementations must call Buffer::Destroy()
|
||||
// when a Buffer is created that will never be returned to the caller.
|
||||
// CDM interfaces are versioned for backward compatibility.
|
||||
// Note: ContentDecryptionModule implementations must use the Host
|
||||
// to allocate any Buffer that needs to be passed back to the caller.
|
||||
// Host implementations must call Buffer::Destroy() when a Buffer is created
|
||||
// that will never be returned to the caller.
|
||||
|
||||
// Based on chromium's ContentDecryptionModule_1.
|
||||
class ContentDecryptionModule_1 {
|
||||
public:
|
||||
static const int kVersion = 1002;
|
||||
typedef Host_1 Host;
|
||||
|
||||
// Generates a |key_request| given |type| and |init_data|.
|
||||
//
|
||||
// Returns kSuccess if the key request was successfully generated, in which
|
||||
@@ -296,9 +360,9 @@ class ContentDecryptionModule_1 {
|
||||
virtual Status Decrypt(const InputBuffer& encrypted_buffer,
|
||||
DecryptedBlock* decrypted_buffer) = 0;
|
||||
|
||||
// Decrypts the |encrypted_buffer|, decodes the decrypted buffer into a
|
||||
// video frame, and passes the frame to the rendering FW/HW. No data
|
||||
// is returned.
|
||||
// Decrypts the |encrypted_buffer|, decodes the decrypted buffer, and passes
|
||||
// the video frame or audio samples to the rendering FW/HW. No data is
|
||||
// returned to the caller.
|
||||
//
|
||||
// Returns kSuccess if decryption, decoding, and rendering all succeeded.
|
||||
// Returns kNoKey if the CDM did not have the necessary decryption key
|
||||
@@ -312,9 +376,9 @@ class ContentDecryptionModule_1 {
|
||||
virtual Status DecryptDecodeAndRenderFrame(
|
||||
const InputBuffer& encrypted_buffer) = 0;
|
||||
|
||||
// Decrypts the |encrypted_buffer|, decodes the decrypted buffer into
|
||||
// audio frames, and passes the samples to the rendering FW/HW. No
|
||||
// data is returned.
|
||||
// Decrypts the |encrypted_buffer|, decodes the decrypted buffer into a
|
||||
// video frame, and passes the frame to the rendering FW/HW. No data
|
||||
// is returned.
|
||||
//
|
||||
// Returns kSuccess if decryption, decoding, and rendering all succeeded.
|
||||
// Returns kNoKey if the CDM did not have the necessary decryption key
|
||||
@@ -331,11 +395,11 @@ class ContentDecryptionModule_1 {
|
||||
// Destroys the object in the same context as it was created.
|
||||
virtual void Destroy() = 0;
|
||||
|
||||
// Provisioning related methods
|
||||
// Provisioning-related methods.
|
||||
virtual Status GetProvisioningRequest(
|
||||
std::string* request, std::string* default_url) = 0;
|
||||
|
||||
virtual cdm::Status HandleProvisioningResponse(
|
||||
virtual Status HandleProvisioningResponse(
|
||||
std::string& response) = 0;
|
||||
|
||||
protected:
|
||||
@@ -343,36 +407,139 @@ class ContentDecryptionModule_1 {
|
||||
virtual ~ContentDecryptionModule_1() {}
|
||||
};
|
||||
|
||||
const int kWidevineCdmInterfaceVersion_1 = 1002;
|
||||
|
||||
typedef ContentDecryptionModule_1 ContentDecryptionModule;
|
||||
const int kCdmInterfaceVersion = kWidevineCdmInterfaceVersion_1;
|
||||
|
||||
// Represents a buffer created by Allocator implementations.
|
||||
class Buffer {
|
||||
// Based on chromium's ContentDecryptionModule_4 and ContentDecryptionModule_5.
|
||||
class ContentDecryptionModule_4 {
|
||||
public:
|
||||
// Destroys the buffer in the same context as it was created.
|
||||
static const int kVersion = 1004;
|
||||
typedef Host_4 Host;
|
||||
|
||||
// The non-decryption methods on this class, such as CreateSession(),
|
||||
// get passed a |session_id| for a MediaKeySession object. It must be used in
|
||||
// the reply via Host methods (e.g. Host::OnSessionMessage()).
|
||||
// Note: |session_id| is different from MediaKeySession's sessionId attribute,
|
||||
// which is referred to as |web_session_id| in this file.
|
||||
|
||||
// Creates a new session and generates a key request given |init_data| and
|
||||
// |session_type|. OnSessionCreated() will be called with a web session ID
|
||||
// once the session exists. OnSessionMessage() will subsequently be called
|
||||
// with the key request. A session represents hardware crypto resources,
|
||||
// (if any exist for the platform), which may be in limited supply.
|
||||
// For sessions of type kProvisioning, |mime_type| and |init_data| will be
|
||||
// ignored and may be NULL.
|
||||
virtual void CreateSession(uint32_t session_id,
|
||||
const char* mime_type, uint32_t mime_type_size,
|
||||
const uint8_t* init_data, uint32_t init_data_size,
|
||||
SessionType session_type) = 0;
|
||||
|
||||
// Creates a new session and loads a previous persistent session into it that
|
||||
// has a web session ID of |web_session_id|. OnSessionCreated() will be
|
||||
// called once the session is loaded.
|
||||
virtual void LoadSession(
|
||||
uint32_t session_id,
|
||||
const char* web_session_id, uint32_t web_session_id_length) = 0;
|
||||
|
||||
// Updates the session with |response|.
|
||||
virtual void UpdateSession(
|
||||
uint32_t session_id,
|
||||
const uint8_t* response, uint32_t response_size) = 0;
|
||||
|
||||
// Tests whether |key_id| is known to any current session.
|
||||
virtual bool IsKeyValid(const uint8_t* key_id, int key_id_size) = 0;
|
||||
|
||||
// Releases the resources for the session |session_id|.
|
||||
// After calling this, it is invalid to refer to this session any more.
|
||||
// If any hardware crypto resources were being used by this session, they will
|
||||
// be released.
|
||||
// If this session was a persistent session, this will NOT delete the
|
||||
// persisted data. The persisted data will be preserved so that the session
|
||||
// can be reloaded later with LoadSession(). To delete the persisted session,
|
||||
// use RemoveSession().
|
||||
virtual void ReleaseSession(uint32_t session_id) = 0;
|
||||
|
||||
// Creates a new session and generates a key release request for the
|
||||
// existing persistent session identified by |web_session_id|.
|
||||
// OnSessionCreated() will be called once the session exists.
|
||||
// OnSessionMessage() will subsequently be called with the key release
|
||||
// request.
|
||||
virtual void RemoveSession(
|
||||
uint32_t session_id,
|
||||
const char* web_session_id, uint32_t web_session_id_length) = 0;
|
||||
|
||||
// Signals to the CDM that it should use server certificates to protect the
|
||||
// privacy of the user. The primary use of this is when the application
|
||||
// driving the CDM is untrusted code, such as when a web browser allows a web
|
||||
// page's JavaScript to access the CDM. By using server certificates to
|
||||
// encrypt communication with the license server, device-identifying
|
||||
// information cannot be extracted from the license exchange process by a
|
||||
// malicious caller.
|
||||
// Unless you also call SetServerCertificate() to set a pre-cached server
|
||||
// certificate, the CDM will perform a certificate exchange with the server
|
||||
// prior to any key exchanges.
|
||||
// This method may not be called if any sessions are open. It is typically
|
||||
// called before any sessions have been opened, but may also be called if all
|
||||
// open sessions have been released.
|
||||
// Note that calling SetServerCertificate() implicitly calls this method as
|
||||
// well.
|
||||
virtual Status UsePrivacyMode() = 0;
|
||||
|
||||
// Provides a server certificate to be used to encrypt messages to the
|
||||
// license server. Calling this is like calling UsePrivacyMode(), except that
|
||||
// because the certificate is provided up-front, the CDM does not have to
|
||||
// perform a certificate exchange with the server.
|
||||
// This method may not be called if any sessions are open. It is typically
|
||||
// called before any sessions have been opened, but may also be called if all
|
||||
// open sessions have been released.
|
||||
// Note that calling this method also implicitly calls UsePrivacyMode().
|
||||
virtual Status SetServerCertificate(
|
||||
const uint8_t* server_certificate_data,
|
||||
uint32_t server_certificate_data_size) = 0;
|
||||
|
||||
// Performs scheduled operation with |context| when the timer fires.
|
||||
virtual void TimerExpired(void* context) = 0;
|
||||
|
||||
// Decrypts the |encrypted_buffer|.
|
||||
//
|
||||
// Returns kSuccess if decryption succeeded, in which case the callee
|
||||
// should have filled the |decrypted_buffer| and passed the ownership of
|
||||
// |data| in |decrypted_buffer| to the caller.
|
||||
// Returns kNoKey if the CDM did not have the necessary decryption key
|
||||
// to decrypt.
|
||||
// Returns kDecryptError if any other error happened.
|
||||
// If the return value is not kSuccess, |decrypted_buffer| should be ignored
|
||||
// by the caller.
|
||||
virtual Status Decrypt(const InputBuffer& encrypted_buffer,
|
||||
DecryptedBlock* decrypted_buffer) = 0;
|
||||
|
||||
// Decrypts the |encrypted_buffer|, decodes the decrypted buffer, and passes
|
||||
// the video or audio frames to the rendering FW/HW. No data is returned to
|
||||
// the caller.
|
||||
//
|
||||
// Returns kSuccess if decryption, decoding, and rendering all succeeded.
|
||||
// Returns kNoKey if the CDM did not have the necessary decryption key
|
||||
// to decrypt.
|
||||
// Returns kRetry if |encrypted_buffer| cannot be accepted (e.g, video
|
||||
// pipeline is full). Caller should retry after a short delay.
|
||||
// Returns kDecryptError if any decryption error happened.
|
||||
// Returns kDecodeError if any decoding error happened.
|
||||
virtual Status DecryptDecodeAndRender(const InputBuffer& encrypted_buffer,
|
||||
StreamType stream_type) = 0;
|
||||
|
||||
// Destroys the object in the same context as it was created.
|
||||
virtual void Destroy() = 0;
|
||||
|
||||
virtual int32_t Capacity() const = 0;
|
||||
virtual uint8_t* Data() = 0;
|
||||
virtual void SetSize(int32_t size) = 0;
|
||||
virtual int32_t Size() const = 0;
|
||||
|
||||
protected:
|
||||
Buffer() {}
|
||||
virtual ~Buffer() {}
|
||||
|
||||
private:
|
||||
Buffer(const Buffer&);
|
||||
void operator=(const Buffer&);
|
||||
ContentDecryptionModule_4() {}
|
||||
virtual ~ContentDecryptionModule_4() {}
|
||||
};
|
||||
|
||||
// Host interface that the CDM can call into to access browser side services.
|
||||
// Host interfaces are versioned for backward compatibility. CDM should use
|
||||
// HostFactory object to request a Host interface of a particular version.
|
||||
// Host interfaces are versioned for backward compatibility.
|
||||
|
||||
// Based on chromium's Host_1.
|
||||
class Host_1 {
|
||||
public:
|
||||
static const int kVersion = 1002;
|
||||
|
||||
// Returns a Buffer* containing non-zero members upon success, or NULL on
|
||||
// failure. The caller owns the Buffer* after this call. The buffer is not
|
||||
// guaranteed to be zero initialized. The capacity of the allocated Buffer
|
||||
@@ -418,77 +585,69 @@ class Host_1 {
|
||||
virtual ~Host_1() {}
|
||||
};
|
||||
|
||||
const int kWidevineHostInterfaceVersion_1 = 1002;
|
||||
|
||||
typedef Host_1 Host;
|
||||
const int kHostInterfaceVersion = kWidevineHostInterfaceVersion_1;
|
||||
|
||||
// Represents a decrypted block that has not been decoded.
|
||||
class DecryptedBlock {
|
||||
// Based on chromium's Host_4 and Host_5.
|
||||
class Host_4 {
|
||||
public:
|
||||
virtual void SetDecryptedBuffer(Buffer* buffer) = 0;
|
||||
virtual Buffer* DecryptedBuffer() = 0;
|
||||
static const int kVersion = 1004;
|
||||
|
||||
virtual void SetTimestamp(int64_t timestamp) = 0;
|
||||
virtual int64_t Timestamp() const = 0;
|
||||
// Returns a Buffer* containing non-zero members upon success, or NULL on
|
||||
// failure. The caller owns the Buffer* after this call. The buffer is not
|
||||
// guaranteed to be zero initialized. The capacity of the allocated Buffer
|
||||
// is guaranteed to be not less than |capacity|.
|
||||
virtual Buffer* Allocate(uint32_t capacity) = 0;
|
||||
|
||||
// Requests the host to call ContentDecryptionModule::TimerFired() |delay_ms|
|
||||
// from now with |context|.
|
||||
virtual void SetTimer(int64_t delay_ms, void* context) = 0;
|
||||
|
||||
// Returns the current epoch wall time in seconds.
|
||||
virtual double GetCurrentWallTimeInSeconds() = 0;
|
||||
|
||||
// Called by the CDM when a session is created or loaded and the value for the
|
||||
// MediaKeySession's sessionId attribute is available (|web_session_id|).
|
||||
// This must be called before OnSessionMessage() or OnSessionUpdated() is
|
||||
// called for |session_id|. |web_session_id_length| should not include null
|
||||
// termination.
|
||||
// When called in response to LoadSession(), the |web_session_id| must be the
|
||||
// same as the |web_session_id| passed in LoadSession().
|
||||
virtual void OnSessionCreated(
|
||||
uint32_t session_id,
|
||||
const char* web_session_id, uint32_t web_session_id_length) = 0;
|
||||
|
||||
// Called by the CDM when it has a message for session |session_id|.
|
||||
// Length parameters should not include null termination.
|
||||
virtual void OnSessionMessage(
|
||||
uint32_t session_id,
|
||||
const char* message, uint32_t message_length,
|
||||
const char* destination_url, uint32_t destination_url_length) = 0;
|
||||
|
||||
// Called by the CDM when session |session_id| has been updated.
|
||||
virtual void OnSessionUpdated(uint32_t session_id) = 0;
|
||||
|
||||
// Called by the CDM when session |session_id| is closed.
|
||||
virtual void OnSessionClosed(uint32_t session_id) = 0;
|
||||
|
||||
// Called by the CDM when an error occurs in session |session_id|.
|
||||
virtual void OnSessionError(uint32_t session_id,
|
||||
Status error_code,
|
||||
uint32_t system_code) = 0;
|
||||
|
||||
// Creates a FileIO object from the host to do file IO operation. Returns NULL
|
||||
// if a FileIO object cannot be obtained. Once a valid FileIO object is
|
||||
// returned, |client| must be valid until FileIO::Close() is called. The
|
||||
// CDM can call this method multiple times to operate on different files.
|
||||
virtual FileIO* CreateFileIO(FileIOClient* client) = 0;
|
||||
|
||||
protected:
|
||||
DecryptedBlock() {}
|
||||
virtual ~DecryptedBlock() {}
|
||||
Host_4() {}
|
||||
virtual ~Host_4() {}
|
||||
};
|
||||
|
||||
class VideoFrame {
|
||||
public:
|
||||
enum VideoPlane {
|
||||
kYPlane = 0,
|
||||
kUPlane = 1,
|
||||
kVPlane = 2,
|
||||
kMaxPlanes = 3,
|
||||
};
|
||||
typedef ContentDecryptionModule_1 ContentDecryptionModule;
|
||||
const int kCdmInterfaceVersion = ContentDecryptionModule::kVersion;
|
||||
|
||||
virtual void SetFormat(VideoFormat format) = 0;
|
||||
virtual VideoFormat Format() const = 0;
|
||||
|
||||
virtual void SetSize(cdm::Size size) = 0;
|
||||
virtual cdm::Size Size() const = 0;
|
||||
|
||||
virtual void SetFrameBuffer(Buffer* frame_buffer) = 0;
|
||||
virtual Buffer* FrameBuffer() = 0;
|
||||
|
||||
virtual void SetPlaneOffset(VideoPlane plane, int32_t offset) = 0;
|
||||
virtual int32_t PlaneOffset(VideoPlane plane) = 0;
|
||||
|
||||
virtual void SetStride(VideoPlane plane, int32_t stride) = 0;
|
||||
virtual int32_t Stride(VideoPlane plane) = 0;
|
||||
|
||||
virtual void SetTimestamp(int64_t timestamp) = 0;
|
||||
virtual int64_t Timestamp() const = 0;
|
||||
|
||||
protected:
|
||||
VideoFrame() {}
|
||||
virtual ~VideoFrame() {}
|
||||
};
|
||||
|
||||
// Represents decrypted and decoded audio frames. AudioFrames can contain
|
||||
// multiple audio output buffers, which are serialized into this format:
|
||||
//
|
||||
// |<------------------- serialized audio buffer ------------------->|
|
||||
// | int64_t timestamp | int64_t length | length bytes of audio data |
|
||||
//
|
||||
// For example, with three audio output buffers, the AudioFrames will look
|
||||
// like this:
|
||||
//
|
||||
// |<----------------- AudioFrames ------------------>|
|
||||
// | audio buffer 0 | audio buffer 1 | audio buffer 2 |
|
||||
class AudioFrames {
|
||||
public:
|
||||
virtual void SetFrameBuffer(Buffer* buffer) = 0;
|
||||
virtual Buffer* FrameBuffer() = 0;
|
||||
|
||||
protected:
|
||||
AudioFrames() {}
|
||||
virtual ~AudioFrames() {}
|
||||
};
|
||||
typedef ContentDecryptionModule::Host Host;
|
||||
const int kHostInterfaceVersion = Host::kVersion;
|
||||
|
||||
} // namespace cdm
|
||||
|
||||
|
||||
54
cdm/include/host_4_file_io_client.h
Normal file
54
cdm/include/host_4_file_io_client.h
Normal file
@@ -0,0 +1,54 @@
|
||||
// Copyright 2013 Google Inc. All Rights Reserved.
|
||||
|
||||
#ifndef WVCDM_HOST_4_FILE_IO_CLIENT_H_
|
||||
#define WVCDM_HOST_4_FILE_IO_CLIENT_H_
|
||||
|
||||
#include "content_decryption_module.h"
|
||||
#include "wv_cdm_common.h"
|
||||
#include "wv_cdm_types.h"
|
||||
|
||||
namespace wvcdm {
|
||||
|
||||
class Host4FileIOClient : public cdm::FileIOClient {
|
||||
public:
|
||||
explicit Host4FileIOClient(cdm::Host_4* host)
|
||||
: host_(host),
|
||||
file_io_(NULL),
|
||||
status_(kSuccess),
|
||||
data_size_(0),
|
||||
buffer_(NULL),
|
||||
buffer_size_(0) {}
|
||||
~Host4FileIOClient();
|
||||
|
||||
bool Open(const std::string& name);
|
||||
bool Read(char* buffer, size_t buffer_size);
|
||||
bool ReadFileSize() { return Read(NULL, 0); }
|
||||
bool Write(const char* data, size_t data_size);
|
||||
bool Close();
|
||||
|
||||
// cdm::FileIOClient implementation
|
||||
virtual void OnOpenComplete(Status status) OVERRIDE;
|
||||
virtual void OnReadComplete(Status status, const uint8_t* data,
|
||||
uint32_t data_size) OVERRIDE;
|
||||
virtual void OnWriteComplete(Status status) OVERRIDE;
|
||||
|
||||
// Get the result of the last operation
|
||||
Status status() const { return status_; }
|
||||
uint32_t data_size() const { return data_size_; }
|
||||
|
||||
private:
|
||||
cdm::Host_4* host_;
|
||||
cdm::FileIO* file_io_;
|
||||
|
||||
// These hold the result of the last operation
|
||||
Status status_;
|
||||
uint32_t data_size_;
|
||||
char* buffer_;
|
||||
size_t buffer_size_;
|
||||
|
||||
CORE_DISALLOW_COPY_AND_ASSIGN(Host4FileIOClient);
|
||||
};
|
||||
|
||||
} // namespace wvcdm
|
||||
|
||||
#endif // WVCDM_HOST_4_FILE_IO_CLIENT_H_
|
||||
@@ -1,3 +1,3 @@
|
||||
// Widevine CDM Kit Version
|
||||
#define WV_CDM_VERSION "v2.1.8-0-829"
|
||||
#define WV_CDM_VERSION "v2.2.0-0-903"
|
||||
|
||||
|
||||
73
cdm/include/wv_client_property_set.h
Normal file
73
cdm/include/wv_client_property_set.h
Normal file
@@ -0,0 +1,73 @@
|
||||
// Copyright 2013 Google Inc. All Rights Reserved.
|
||||
|
||||
#ifndef WVCDM_CDM_WV_CLIENT_PROPERTY_SET_H_
|
||||
#define WVCDM_CDM_WV_CLIENT_PROPERTY_SET_H_
|
||||
|
||||
#include "cdm_client_property_set.h"
|
||||
|
||||
#include "wv_cdm_types.h"
|
||||
|
||||
namespace wvcdm {
|
||||
|
||||
class WVClientPropertySet : public CdmClientPropertySet {
|
||||
public:
|
||||
WVClientPropertySet()
|
||||
: use_privacy_mode_(false) {}
|
||||
|
||||
virtual ~WVClientPropertySet() {}
|
||||
|
||||
void set_security_level(const std::string& securityLevel) {
|
||||
security_level_ = securityLevel;
|
||||
}
|
||||
|
||||
virtual const std::string& security_level() const {
|
||||
return security_level_;
|
||||
}
|
||||
|
||||
void set_use_privacy_mode(bool usePrivacyMode) {
|
||||
use_privacy_mode_ = usePrivacyMode;
|
||||
}
|
||||
|
||||
virtual bool use_privacy_mode() const {
|
||||
return use_privacy_mode_;
|
||||
}
|
||||
|
||||
void set_service_certificate(const std::string& serviceCertificate) {
|
||||
service_certificate_ = serviceCertificate;
|
||||
}
|
||||
|
||||
virtual const std::string& service_certificate() const {
|
||||
return service_certificate_;
|
||||
}
|
||||
|
||||
virtual bool is_session_sharing_enabled() const {
|
||||
return true; // This is unused by common cdm but we need a definition
|
||||
// for the pure virtual methods.
|
||||
}
|
||||
|
||||
void set_is_session_sharing_enabled(bool shareKeys) {
|
||||
return; // This is unused by common cdm but we need a definition
|
||||
// for the pure virtual methods.
|
||||
}
|
||||
|
||||
virtual uint32_t session_sharing_id() const {
|
||||
return 1; // This is unused by common cdm but we need a
|
||||
// definition for the pure virtual methods.
|
||||
}
|
||||
|
||||
virtual void set_session_sharing_id(uint32_t id) {
|
||||
return; // This is unused by common cdm but we need a
|
||||
// definition for the pure virtual methods.
|
||||
}
|
||||
|
||||
private:
|
||||
CORE_DISALLOW_COPY_AND_ASSIGN(WVClientPropertySet);
|
||||
|
||||
std::string security_level_;
|
||||
bool use_privacy_mode_;
|
||||
std::string service_certificate_;
|
||||
};
|
||||
|
||||
} // namespace wvcdm
|
||||
|
||||
#endif // WVCDM_CDM_WV_CLIENT_PROPERTY_SET_H_
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2013 Google Inc. All Rights Reserved.
|
||||
|
||||
#ifndef WVCDM_CDM_WV_CONTENT_DECRYPTION_MODULE_H_
|
||||
#define WVCDM_CDM_WV_CONTENT_DECRYPTION_MODULE_H_
|
||||
#ifndef WVCDM_CDM_WV_CONTENT_DECRYPTION_MODULE_1_H_
|
||||
#define WVCDM_CDM_WV_CONTENT_DECRYPTION_MODULE_1_H_
|
||||
|
||||
#include "cdm_client_property_set.h"
|
||||
#include "cdm_engine.h"
|
||||
@@ -14,77 +14,19 @@
|
||||
|
||||
#include "wv_cdm_common.h"
|
||||
#include "wv_cdm_types.h"
|
||||
#include "wv_client_property_set.h"
|
||||
|
||||
namespace wvcdm {
|
||||
|
||||
class WVClientPropertySet : public wvcdm::CdmClientPropertySet {
|
||||
class WvContentDecryptionModule_1 : public cdm::ContentDecryptionModule_1,
|
||||
public IFileFactory,
|
||||
public IClock {
|
||||
public:
|
||||
WVClientPropertySet()
|
||||
: use_privacy_mode_(false) {}
|
||||
explicit WvContentDecryptionModule_1(cdm::Host_1* host);
|
||||
|
||||
virtual ~WVClientPropertySet() {}
|
||||
virtual ~WvContentDecryptionModule_1();
|
||||
|
||||
void set_security_level(const std::string& securityLevel) {
|
||||
security_level_ = securityLevel;
|
||||
}
|
||||
|
||||
virtual const std::string& security_level() const {
|
||||
return security_level_;
|
||||
}
|
||||
|
||||
void set_use_privacy_mode(bool usePrivacyMode) {
|
||||
use_privacy_mode_ = usePrivacyMode;
|
||||
}
|
||||
|
||||
virtual bool use_privacy_mode() const {
|
||||
return use_privacy_mode_;
|
||||
}
|
||||
|
||||
void set_service_certificate(const std::string& serviceCertificate) {
|
||||
service_certificate_ = serviceCertificate;
|
||||
}
|
||||
|
||||
virtual const std::string& service_certificate() const {
|
||||
return service_certificate_;
|
||||
}
|
||||
|
||||
virtual bool is_session_sharing_enabled() const {
|
||||
return true; // This is unused by common cdm but we need a definition
|
||||
// for the pure virtual methods.
|
||||
}
|
||||
|
||||
void set_is_session_sharing_enabled(bool shareKeys) {
|
||||
return; // This is unused by common cdm but we need a definition
|
||||
// for the pure virtual methods.
|
||||
}
|
||||
|
||||
virtual uint32_t session_sharing_id() const {
|
||||
return 1; // This is unused by common cdm but we need a
|
||||
// definition for the pure virtual methods.
|
||||
}
|
||||
|
||||
virtual void set_session_sharing_id(uint32_t id) {
|
||||
return; // This is unused by common cdm but we need a
|
||||
// definition for the pure virtual methods.
|
||||
}
|
||||
|
||||
private:
|
||||
CORE_DISALLOW_COPY_AND_ASSIGN(WVClientPropertySet);
|
||||
|
||||
std::string security_level_;
|
||||
bool use_privacy_mode_;
|
||||
std::string service_certificate_;
|
||||
};
|
||||
|
||||
class WvContentDecryptionModule : public cdm::ContentDecryptionModule,
|
||||
public IFileFactory,
|
||||
public IClock {
|
||||
public:
|
||||
explicit WvContentDecryptionModule(cdm::Host* host);
|
||||
|
||||
virtual ~WvContentDecryptionModule();
|
||||
|
||||
// cdm::ContentDecryptionModule implementation.
|
||||
// cdm::ContentDecryptionModule_1 implementation.
|
||||
virtual cdm::Status GenerateKeyRequest(const char* type, int type_size,
|
||||
const uint8_t* init_data,
|
||||
int init_data_size) OVERRIDE;
|
||||
@@ -125,20 +67,46 @@ class WvContentDecryptionModule : public cdm::ContentDecryptionModule,
|
||||
|
||||
virtual int64_t GetCurrentTimeInSeconds() OVERRIDE;
|
||||
|
||||
/* |parameters| is expected to be initialized with anything not related to
|
||||
* subsample parsing. |iv| is initialized by the caller, but may be modified
|
||||
* during decryption. |decrypted_block| may be NULL for L1 decrypts, since
|
||||
* no data is passed back to the caller. */
|
||||
cdm::Status DoSubsampleDecrypt(CdmDecryptionParameters& parameters,
|
||||
std::vector<uint8_t>& iv,
|
||||
const cdm::InputBuffer& encrypted_buffer,
|
||||
cdm::DecryptedBlock* decrypted_block);
|
||||
cdm::Status DoDecrypt(CdmDecryptionParameters& parameters,
|
||||
std::vector<uint8_t>& iv,
|
||||
const cdm::InputBuffer& encrypted_buffer,
|
||||
cdm::DecryptedBlock* decrypted_block);
|
||||
|
||||
/* |parameters| is expected to be initialized with everything required by
|
||||
* DoSubsampleDecrypt and DoDecrypt, plus |is_encrypted| and
|
||||
* |subsample_flags|. Counters and |iv| will be updated to prepare for
|
||||
* subsequent calls. */
|
||||
cdm::Status DecryptAndUpdateCounters(CdmDecryptionParameters& parameters,
|
||||
std::vector<uint8_t>& iv,
|
||||
const cdm::InputBuffer& encrypted_buffer,
|
||||
const size_t bytes,
|
||||
cdm::DecryptedBlock* decrypted_block,
|
||||
size_t& offset,
|
||||
size_t& encrypted_offset,
|
||||
uint32_t& block_ctr);
|
||||
|
||||
void SetSizesAndAllocate(size_t output_size,
|
||||
CdmDecryptionParameters& parameters,
|
||||
cdm::DecryptedBlock* decrypted_block);
|
||||
|
||||
cdm::Host_1* const host_;
|
||||
HostEventListener host_event_listener_;
|
||||
|
||||
CdmEngine cdm_engine_;
|
||||
cdm::Host* const host_;
|
||||
HostEventListener host_event_listener_;
|
||||
WVClientPropertySet property_set_;
|
||||
bool timer_enabled_;
|
||||
|
||||
CORE_DISALLOW_COPY_AND_ASSIGN(WvContentDecryptionModule);
|
||||
CORE_DISALLOW_COPY_AND_ASSIGN(WvContentDecryptionModule_1);
|
||||
};
|
||||
|
||||
} // namespace wvcdm
|
||||
|
||||
#endif // WVCDM_CDM_WV_CONTENT_DECRYPTION_MODULE_H_
|
||||
#endif // WVCDM_CDM_WV_CONTENT_DECRYPTION_MODULE_1_H_
|
||||
155
cdm/include/wv_content_decryption_module_4.h
Normal file
155
cdm/include/wv_content_decryption_module_4.h
Normal file
@@ -0,0 +1,155 @@
|
||||
// Copyright 2014 Google Inc. All Rights Reserved.
|
||||
|
||||
#ifndef WVCDM_CDM_WV_CONTENT_DECRYPTION_MODULE_4_H_
|
||||
#define WVCDM_CDM_WV_CONTENT_DECRYPTION_MODULE_4_H_
|
||||
|
||||
#include "content_decryption_module.h"
|
||||
|
||||
#include "cdm_client_property_set.h"
|
||||
#include "cdm_engine.h"
|
||||
#include "cdm_host_clock.h"
|
||||
#include "cdm_host_file.h"
|
||||
#include "clock.h"
|
||||
#include "wv_cdm_common.h"
|
||||
#include "wv_cdm_event_listener.h"
|
||||
#include "wv_cdm_types.h"
|
||||
#include "wv_client_property_set.h"
|
||||
|
||||
#if defined(UNIT_TEST)
|
||||
# include "gtest/gtest_prod.h"
|
||||
#endif
|
||||
|
||||
namespace wvcdm {
|
||||
|
||||
class WvContentDecryptionModule_4 : public cdm::ContentDecryptionModule_4,
|
||||
public IFileFactory,
|
||||
public IClock,
|
||||
public WvCdmEventListener {
|
||||
public:
|
||||
explicit WvContentDecryptionModule_4(cdm::Host_4* host);
|
||||
|
||||
virtual ~WvContentDecryptionModule_4();
|
||||
|
||||
virtual void CreateSession(uint32_t session_id,
|
||||
const char* mime_type, uint32_t mime_type_size,
|
||||
const uint8_t* init_data, uint32_t init_data_size,
|
||||
cdm::SessionType session_type) OVERRIDE;
|
||||
|
||||
virtual void LoadSession(uint32_t session_id, const char* web_session_id,
|
||||
uint32_t web_session_id_length) OVERRIDE;
|
||||
|
||||
virtual void UpdateSession(uint32_t session_id, const uint8_t* response,
|
||||
uint32_t response_size) OVERRIDE;
|
||||
|
||||
virtual bool IsKeyValid(const uint8_t* key_id, int key_id_size) OVERRIDE;
|
||||
|
||||
virtual void ReleaseSession(uint32_t session_id) OVERRIDE;
|
||||
|
||||
virtual void RemoveSession(uint32_t session_id, const char* web_session_id,
|
||||
uint32_t web_session_id_length) OVERRIDE;
|
||||
|
||||
virtual cdm::Status UsePrivacyMode() OVERRIDE;
|
||||
|
||||
virtual cdm::Status SetServerCertificate(
|
||||
const uint8_t* server_certificate_data,
|
||||
uint32_t server_certificate_data_size) OVERRIDE;
|
||||
|
||||
virtual void TimerExpired(void* context) OVERRIDE;
|
||||
|
||||
virtual cdm::Status Decrypt(const cdm::InputBuffer& encrypted_buffer,
|
||||
cdm::DecryptedBlock* decrypted_buffer) OVERRIDE;
|
||||
|
||||
virtual cdm::Status DecryptDecodeAndRender(
|
||||
const cdm::InputBuffer& encrypted_buffer,
|
||||
cdm::StreamType stream_type) OVERRIDE;
|
||||
|
||||
virtual void Destroy() OVERRIDE;
|
||||
|
||||
// wvcdm::WvCdmEventListener implementation.
|
||||
virtual void OnEvent(const CdmSessionId& session_id,
|
||||
CdmEventType cdm_event) OVERRIDE;
|
||||
|
||||
private:
|
||||
class InternalSession {
|
||||
public:
|
||||
enum SessionType {
|
||||
kDecrypt = 1,
|
||||
kRelease = 2,
|
||||
kProvision = 3,
|
||||
};
|
||||
|
||||
InternalSession() : webid_(), session_type_(kDecrypt) {}
|
||||
InternalSession(const std::string& webid, SessionType session_type)
|
||||
: webid_(webid), session_type_(session_type) {}
|
||||
|
||||
const std::string& webid() const { return webid_; }
|
||||
bool is_decrypt() const { return session_type_ == kDecrypt; }
|
||||
bool is_release() const { return session_type_ == kRelease; }
|
||||
bool is_provision() const { return session_type_ == kProvision; }
|
||||
|
||||
private:
|
||||
std::string webid_;
|
||||
SessionType session_type_;
|
||||
};
|
||||
|
||||
void EnablePolicyTimer();
|
||||
void DisablePolicyTimer();
|
||||
|
||||
void CreateProvisionSession(uint32_t session_id);
|
||||
void UpdateProvisionSession(uint32_t session_id, const uint8_t* response,
|
||||
uint32_t response_size);
|
||||
|
||||
bool CallOpenSession(uint32_t session_id);
|
||||
|
||||
virtual File::Impl* NewFileImpl() OVERRIDE;
|
||||
|
||||
virtual int64_t GetCurrentTimeInSeconds() OVERRIDE;
|
||||
|
||||
/* |parameters| is expected to be initialized with anything not related to
|
||||
* subsample parsing. |iv| is initialized by the caller, but may be modified
|
||||
* during decryption. |decrypted_block| may be NULL for L1 decrypts, since
|
||||
* no data is passed back to the caller. */
|
||||
cdm::Status DoSubsampleDecrypt(CdmDecryptionParameters& parameters,
|
||||
std::vector<uint8_t>& iv,
|
||||
const cdm::InputBuffer& encrypted_buffer,
|
||||
cdm::DecryptedBlock* decrypted_block);
|
||||
cdm::Status DoDecrypt(CdmDecryptionParameters& parameters,
|
||||
std::vector<uint8_t>& iv,
|
||||
const cdm::InputBuffer& encrypted_buffer,
|
||||
cdm::DecryptedBlock* decrypted_block);
|
||||
|
||||
/* |parameters| is expected to be initialized with everything required by
|
||||
* DoSubsampleDecrypt and DoDecrypt, plus |is_encrypted| and
|
||||
* |subsample_flags|. Counters and |iv| will be updated to prepare for
|
||||
* subsequent calls. */
|
||||
cdm::Status DecryptAndUpdateCounters(CdmDecryptionParameters& parameters,
|
||||
std::vector<uint8_t>& iv,
|
||||
const cdm::InputBuffer& encrypted_buffer,
|
||||
const size_t bytes,
|
||||
cdm::DecryptedBlock* decrypted_block,
|
||||
size_t& offset, size_t& encrypted_offset,
|
||||
uint32_t& block_ctr);
|
||||
|
||||
void SetSizesAndAllocate(size_t output_size,
|
||||
CdmDecryptionParameters& parameters,
|
||||
cdm::DecryptedBlock* decrypted_block);
|
||||
|
||||
#if defined(UNIT_TEST)
|
||||
FRIEND_TEST(CdmApi4Test, UsePrivacyMode);
|
||||
FRIEND_TEST(CdmApi4Test, UsePrivacyModeFailsWithOpenSessions);
|
||||
FRIEND_TEST(CdmApi4Test, SetExplicitServerCertificate);
|
||||
FRIEND_TEST(CdmApi4Test, SetServerCertificateFailsWithOpenSessions);
|
||||
#endif
|
||||
|
||||
cdm::Host_4* const host_;
|
||||
WVClientPropertySet property_set_;
|
||||
CdmEngine cdm_engine_;
|
||||
std::map<uint32_t, InternalSession> session_map_;
|
||||
bool timer_enabled_;
|
||||
|
||||
CORE_DISALLOW_COPY_AND_ASSIGN(WvContentDecryptionModule_4);
|
||||
};
|
||||
|
||||
} // namespace wvcdm
|
||||
|
||||
#endif // WVCDM_CDM_WV_CONTENT_DECRYPTION_MODULE_4_H_
|
||||
Reference in New Issue
Block a user