Shaka Player Embedded
Public Member Functions | List of all members
shaka::eme::Implementation Class Referenceabstract

#include <implementation.h>

Inheritance diagram for shaka::eme::Implementation:
shaka::eme::ClearKeyImplementation

Public Member Functions

 Implementation ()
 
virtual ~ Implementation ()
 
 Implementation (const Implementation &)=delete
 
Implementationoperator= (const Implementation &)=delete
 
 Implementation (Implementation &&)=delete
 
Implementationoperator= (Implementation &&)=delete
 
virtual bool GetExpiration (const std::string &session_id, int64_t *expiration) const =0
 
virtual bool GetKeyStatuses (const std::string &session_id, std::vector< KeyStatusInfo > *statuses) const =0
 
virtual void SetServerCertificate (EmePromise promise, Data cert)=0
 
virtual void CreateSessionAndGenerateRequest (EmePromise promise, std::function< void(const std::string &)> set_session_id, MediaKeySessionType session_type, MediaKeyInitDataType init_data_type, Data data)=0
 
virtual void Load (const std::string &session_id, EmePromise promise)=0
 
virtual void Update (const std::string &session_id, EmePromise promise, Data data)=0
 
virtual void Close (const std::string &session_id, EmePromise promise)=0
 
virtual void Remove (const std::string &session_id, EmePromise promise)=0
 
virtual DecryptStatus Decrypt (const FrameEncryptionInfo *info, const uint8_t *data, size_t data_size, uint8_t *dest) const =0
 

Detailed Description

An interface for an EME implementation instance. This represents an adapter to a CDM instance. This is a one-to-one mapping to a MediaKeys object in EME. This should create and manage a single CDM instance. This object must remain alive until the Destroy() method is called.

This can spawn background threads as needed to monitor the system. These thread(s) must be deleted inside Destroy().

It is ok to manipulate the filesystem, but it should be done inside the ImplementationHelper::DataPathPrefix directory.

Many of the actions here are asynchronous. Some are completed by the end of the call here, but are run asynchronously with respect to JavaScript. In either case, those methods are given a promise. Once the operation is complete (error or success), one of the methods on it MUST be called. It is ok to synchronously call those methods.

Most methods here are only called on the JS main thread; the exception is Decrypt, which can be called from any thread, including concurrently with other Decrypt calls. It is highly suggested to avoid exclusive locks in Decrypt so we can get parallel decrypt operations.

Definition at line 86 of file implementation.h.

Constructor & Destructor Documentation

§ Implementation() [1/3]

shaka::eme::Implementation::Implementation ( )

§ ~ Implementation()

virtual shaka::eme::Implementation::~ Implementation ( )
virtual

§ Implementation() [2/3]

shaka::eme::Implementation::Implementation ( const Implementation )
delete

§ Implementation() [3/3]

shaka::eme::Implementation::Implementation ( Implementation &&  )
delete

Member Function Documentation

§ Close()

virtual void shaka::eme::Implementation::Close ( const std::string &  session_id,
EmePromise  promise 
)
pure virtual

Closes the given session. This does NOT delete persistent sessions, it only closes the current running session and any runtime data.

Parameters
session_idThe session ID to close.
promiseThe Promise object.

Implemented in shaka::eme::ClearKeyImplementation.

§ CreateSessionAndGenerateRequest()

virtual void shaka::eme::Implementation::CreateSessionAndGenerateRequest ( EmePromise  promise,
std::function< void(const std::string &)>  set_session_id,
MediaKeySessionType  session_type,
MediaKeyInitDataType  init_data_type,
Data  data 
)
pure virtual

This method creates a new session and generates a license request. This is only called for new session, not for loading persistent sessions.

This should call set_session_id before sending any messages so the session ID is set. The function must only be called once.

This method should create a message to send the license request. This will only be called with init data types where ImplementationFactory::SupportsInitDataType() returns true.

The Promise should be resolved when the request has been generated, NOT when the response comes back. This should call ImplementationHelper::OnMessage() before resolving the Promise.

There are situations where this may not generate the license request immediately, for example if the device isn't provisioned. This will still generate a message, but it may not be a license request.

Parameters
promiseThe Promise object.
set_session_idA function that accepts the session ID of the new session.
session_typeThe type of session to create.
init_data_typeThe type of init data given
dataThe data contents of the request.

Implemented in shaka::eme::ClearKeyImplementation.

§ Decrypt()

virtual DecryptStatus shaka::eme::Implementation::Decrypt ( const FrameEncryptionInfo info,
const uint8_t *  data,
size_t  data_size,
uint8_t *  dest 
) const
pure virtual

Decrypts the given data. This is given a whole frame and is expected to decrypt the encrypted portions and copy over clear portions. This method doesn't need to handle containers or codecs, all it needs to do is decrypt and copy the data. If the data needs to be processed before decryption (e.g. for MPEG2-TS), it is done by the caller.

If pattern is (0, 0), then this is not using pattern encryption (e.g. for "cenc" or "cbc1").

Parameters
infoContains information about how the frame is encrypted.
dataThe data to decrypt.
data_sizeThe size of |data|.
destThe destination buffer to hold the decrypted data. Is at least |data_size| bytes large.
Returns
The resulting status code.

Implemented in shaka::eme::ClearKeyImplementation.

§ GetExpiration()

virtual bool shaka::eme::Implementation::GetExpiration ( const std::string &  session_id,
int64_t *  expiration 
) const
pure virtual

Gets the expiration of the session. This should give the time in milliseconds since the epoch, or -1 if the session never expires.

Parameters
session_idThe ID of the session to get the expiration for.
expiration[OUT] Where to put the expiration time.
Returns
True on success, false on error.

Implemented in shaka::eme::ClearKeyImplementation.

§ GetKeyStatuses()

virtual bool shaka::eme::Implementation::GetKeyStatuses ( const std::string &  session_id,
std::vector< KeyStatusInfo > *  statuses 
) const
pure virtual

Gets the status of each key in the given session. These values can be cached to avoid extra overhead. This means that the key status may have changed but not be reflected yet (e.g. they may have expired).

Parameters
session_idThe ID of the session to query.
statuses[OUT] Where to put the resulting statuses.
Returns
True on success, false on error.

Implemented in shaka::eme::ClearKeyImplementation.

§ Load()

virtual void shaka::eme::Implementation::Load ( const std::string &  session_id,
EmePromise  promise 
)
pure virtual

Loads the given session from persistent storage.

This should use ResolveWith() and pass true if the session was found, false if the session didn't exist. This should still reject for errors.

Parameters
session_idThe session ID to load.
promiseThe Promise object.

Implemented in shaka::eme::ClearKeyImplementation.

§ operator=() [1/2]

Implementation& shaka::eme::Implementation::operator= ( Implementation &&  )
delete

§ operator=() [2/2]

Implementation& shaka::eme::Implementation::operator= ( const Implementation )
delete

§ Remove()

virtual void shaka::eme::Implementation::Remove ( const std::string &  session_id,
EmePromise  promise 
)
pure virtual

Removes any persistent data associated with the given session.

This should generate a 'license-release' message. The session should not actually be deleted until the response is given to Update(). However, the Promise should be resolved once the message is generated.

Parameters
session_idThe session ID to delete.
promiseThe Promise object.

Implemented in shaka::eme::ClearKeyImplementation.

§ SetServerCertificate()

virtual void shaka::eme::Implementation::SetServerCertificate ( EmePromise  promise,
Data  cert 
)
pure virtual

Sets the server certificate for the CDM.

This should use EmePromise::ResolveWith() and pass true for supported and false for not supported. This should only reject for errors in the certificate.

Parameters
promiseThe Promise object.
certThe data contents of the certificate.

Implemented in shaka::eme::ClearKeyImplementation.

§ Update()

virtual void shaka::eme::Implementation::Update ( const std::string &  session_id,
EmePromise  promise,
Data  data 
)
pure virtual

Updates the given session with a response from the server.

Parameters
session_idThe session ID to use.
promiseThe Promise object.
dataThe data contents of the response.

Implemented in shaka::eme::ClearKeyImplementation.


The documentation for this class was generated from the following file: