Source release 15.0.0
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
#define WVCDM_CORE_CDM_ENGINE_H_
|
||||
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@@ -16,10 +17,8 @@
|
||||
#include "disallow_copy_and_assign.h"
|
||||
#include "file_store.h"
|
||||
#include "initialization_data.h"
|
||||
#include "lock.h"
|
||||
#include "metrics_collections.h"
|
||||
#include "oemcrypto_adapter.h"
|
||||
#include "scoped_ptr.h"
|
||||
#include "service_certificate.h"
|
||||
#include "wv_cdm_constants.h"
|
||||
#include "wv_cdm_types.h"
|
||||
@@ -27,6 +26,7 @@
|
||||
namespace wvcdm {
|
||||
|
||||
class CdmClientPropertySet;
|
||||
class CdmEngineFactory;
|
||||
class CdmSession;
|
||||
class CryptoEngine;
|
||||
class UsagePropertySet;
|
||||
@@ -38,7 +38,6 @@ typedef std::map<CdmKeySetId,
|
||||
|
||||
class CdmEngine {
|
||||
public:
|
||||
CdmEngine(FileSystem* file_system, const std::string& spoid = EMPTY_SPOID);
|
||||
virtual ~CdmEngine();
|
||||
|
||||
// Session related methods
|
||||
@@ -98,6 +97,9 @@ class CdmEngine {
|
||||
// process the response. Should be empty if a release response.
|
||||
// |key_data| is the license, renewal, release response or service
|
||||
// certificate response.
|
||||
// |license_type| must not be null. If the result is KEY_ADDED, this out
|
||||
// parameter indicates the type of license containd in
|
||||
// key_data. For any other return code, no value is provided.
|
||||
// |key_set_id| should be non-null and specified if license release.
|
||||
// If offline license or streaming license associated with
|
||||
// a secure stop, |key_set_id| should be non-null and will
|
||||
@@ -108,6 +110,7 @@ class CdmEngine {
|
||||
// (not associated with a secure stop).
|
||||
virtual CdmResponseType AddKey(const CdmSessionId& session_id,
|
||||
const CdmKeyResponse& key_data,
|
||||
CdmLicenseType* license_type,
|
||||
CdmKeySetId* key_set_id);
|
||||
|
||||
virtual CdmResponseType RestoreKey(const CdmSessionId& session_id,
|
||||
@@ -148,6 +151,9 @@ class CdmEngine {
|
||||
virtual CdmResponseType QueryKeyStatus(const CdmSessionId& session_id,
|
||||
CdmQueryMap* query_response);
|
||||
|
||||
// Query security level support
|
||||
static bool IsSecurityLevelSupported(CdmSecurityLevel level);
|
||||
|
||||
// Query the types of usage permitted for the specified key.
|
||||
virtual CdmResponseType QueryKeyAllowedUsage(const CdmSessionId& session_id,
|
||||
const std::string& key_id,
|
||||
@@ -206,16 +212,32 @@ class CdmEngine {
|
||||
CdmSecurityLevel security_level,
|
||||
const std::string& key_set_id);
|
||||
|
||||
// Get offline license status: active, release or unknown
|
||||
virtual CdmResponseType GetOfflineLicenseState(
|
||||
const std::string& key_set_id,
|
||||
CdmSecurityLevel security_level,
|
||||
CdmOfflineLicenseState* license_state);
|
||||
|
||||
// Remove offline license with the given key_set_id
|
||||
virtual CdmResponseType RemoveOfflineLicense(
|
||||
const std::string& key_set_id,
|
||||
CdmSecurityLevel security_level);
|
||||
|
||||
// Usage related methods for streaming licenses
|
||||
// Retrieve a random usage info from the list of all usage infos for this app
|
||||
// id.
|
||||
// id. If |error_detail| is not null, an additional error code may be provided
|
||||
// in the event of an error.
|
||||
virtual CdmResponseType GetUsageInfo(const std::string& app_id,
|
||||
int* error_detail,
|
||||
CdmUsageInfo* usage_info);
|
||||
|
||||
// Retrieve the usage info for the specified pst.
|
||||
// Returns UNKNOWN_ERROR if no usage info was found.
|
||||
// id. If |error_detail| is not null, an additional error code may be provided
|
||||
// in the event of an error.
|
||||
virtual CdmResponseType GetUsageInfo(const std::string& app_id,
|
||||
const CdmSecureStopId& ssid,
|
||||
int* error_detail,
|
||||
CdmUsageInfo* usage_info);
|
||||
|
||||
// Remove all usage records for the current origin.
|
||||
@@ -271,6 +293,16 @@ class CdmEngine {
|
||||
|
||||
virtual size_t SessionSize() const { return session_map_.Size(); }
|
||||
|
||||
static CdmResponseType ParseDecryptHashString(const std::string& hash_string,
|
||||
CdmSessionId* id,
|
||||
uint32_t* frame_number,
|
||||
std::string* hash);
|
||||
virtual CdmResponseType SetDecryptHash(const CdmSessionId& session_id,
|
||||
uint32_t frame_number,
|
||||
const std::string& hash);
|
||||
virtual CdmResponseType GetDecryptHashError(const CdmSessionId& session_id,
|
||||
std::string* hash_error_string);
|
||||
|
||||
// Is the key known to any session?
|
||||
virtual bool IsKeyLoaded(const KeyId& key_id);
|
||||
virtual bool FindSessionForKey(const KeyId& key_id, CdmSessionId* sessionId);
|
||||
@@ -289,10 +321,38 @@ class CdmEngine {
|
||||
// dead lock.
|
||||
virtual void OnTimerEvent();
|
||||
|
||||
virtual metrics::EngineMetrics* GetMetrics() { return &metrics_; }
|
||||
// Fills the |engine_metrics| parameter with the current snapshot of metrics
|
||||
// data. Returns true if the metrics data is populated, false otherwise.
|
||||
// |engine_metrics| is owned by the caller and must not be null.
|
||||
// The CdmEngine implementation is a placeholder. Just return false.
|
||||
virtual bool GetMetricsSnapshot(
|
||||
__attribute__((unused)) drm_metrics::WvCdmMetrics *metrics) {
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual CdmResponseType ValidateServiceCertificate(const std::string& cert);
|
||||
|
||||
// Setter and getter for the |app_package_name| identifier for this instance
|
||||
// of the CdmEngine. This is used to identify the package name.
|
||||
virtual void SetAppPackageName(const std::string& app_package_name) {
|
||||
app_package_name_ = app_package_name;
|
||||
}
|
||||
virtual const std::string& GetAppPackageName() {
|
||||
return app_package_name_;
|
||||
}
|
||||
|
||||
protected:
|
||||
friend class CdmEngineFactory;
|
||||
friend class ParallelCdmTest;
|
||||
friend class WvCdmEnginePreProvTest;
|
||||
friend class WvCdmTestBase;
|
||||
friend class WvGenericOperationsTest;
|
||||
friend class TestLicenseHolder;
|
||||
|
||||
CdmEngine(FileSystem* file_system,
|
||||
std::shared_ptr<metrics::EngineMetrics> metrics,
|
||||
const std::string& spoid = EMPTY_SPOID);
|
||||
|
||||
private:
|
||||
// private methods
|
||||
CdmResponseType OpenSession(
|
||||
@@ -304,6 +364,7 @@ class CdmEngine {
|
||||
bool ValidateKeySystem(const CdmKeySystem& key_system);
|
||||
CdmResponseType GetUsageInfo(const std::string& app_id,
|
||||
SecurityLevel requested_security_level,
|
||||
int* error_detail,
|
||||
CdmUsageInfo* usage_info);
|
||||
|
||||
void OnKeyReleaseEvent(const CdmKeySetId& key_set_id);
|
||||
@@ -321,11 +382,12 @@ class CdmEngine {
|
||||
* ensure that all data has been properly recorded in the group before
|
||||
* it is published.
|
||||
*/
|
||||
metrics::EngineMetrics metrics_;
|
||||
std::shared_ptr<metrics::EngineMetrics> metrics_;
|
||||
std::string app_package_name_;
|
||||
|
||||
CdmSessionMap session_map_;
|
||||
CdmReleaseKeySetMap release_key_sets_;
|
||||
scoped_ptr<CertificateProvisioning> cert_provisioning_;
|
||||
std::unique_ptr<CertificateProvisioning> cert_provisioning_;
|
||||
SecurityLevel cert_provisioning_requested_security_level_;
|
||||
FileSystem* file_system_;
|
||||
Clock clock_;
|
||||
@@ -334,14 +396,14 @@ class CdmEngine {
|
||||
static bool seeded_;
|
||||
|
||||
// usage related variables
|
||||
scoped_ptr<CdmSession> usage_session_;
|
||||
scoped_ptr<UsagePropertySet> usage_property_set_;
|
||||
std::unique_ptr<CdmSession> usage_session_;
|
||||
std::unique_ptr<UsagePropertySet> usage_property_set_;
|
||||
int64_t last_usage_information_update_time_;
|
||||
|
||||
// Protect release_key_sets_ from non-thread-safe operations.
|
||||
Lock release_key_sets_lock_;
|
||||
std::mutex release_key_sets_lock_;
|
||||
|
||||
// TODO(rfrias): Replace with two sets of locks, one to protect
|
||||
// TODO(b/124471172): Replace with two sets of locks, one to protect
|
||||
// the CdmSessionMap and a per-session lock to control access to
|
||||
// session usage/destruction.
|
||||
// Locks the session map |session_map_| and session usage/destruction
|
||||
@@ -350,7 +412,9 @@ class CdmEngine {
|
||||
// The layer above the CDM implementation is expected to handle thread
|
||||
// synchronization to make sure other functions that access sessions do not
|
||||
// occur simultaneously with OpenSession or CloseSession.
|
||||
Lock session_map_lock_;
|
||||
// This mutex must be recursive because it is sometimes held while callbacks
|
||||
// occur that may subsequently call back into CdmEngine.
|
||||
std::recursive_mutex session_map_lock_;
|
||||
|
||||
CORE_DISALLOW_COPY_AND_ASSIGN(CdmEngine);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user