Merge "Revert "Core CDM: Removed secure stop support.""

This commit is contained in:
Alex Dale
2022-12-05 22:05:07 +00:00
committed by Android (Google) Code Review
6 changed files with 660 additions and 139 deletions

View File

@@ -127,10 +127,10 @@ class CdmEngine {
// stored offline data associated with the session.
virtual CdmResponseType RemoveKeys(const CdmSessionId& session_id);
// This method removes all offline data associated with the session. It
// should be used with care, as it deletes the info immediately and
// without using a release message, so the server is not able to
// receive usage info or track releases for offline licenses.
// This method removes all offline data associated with the session, such as
// offline keys and usage info. It should be used with care, as it deletes the
// info immediately and without using a release message, so the server is not
// able to receive usage info or track releases for offline licenses.
virtual CdmResponseType RemoveLicense(const CdmSessionId& session_id);
// Construct valid renewal request for the current session keys.
@@ -235,32 +235,38 @@ class CdmEngine {
virtual CdmResponseType RemoveOfflineLicense(const std::string& key_set_id,
CdmSecurityLevel security_level);
// Usage related methods for streaming licenses with persistent usage
// information (deprecated).
// Usage related methods for streaming licenses
// Retrieve a random usage info from the list of all usage infos for this app
// 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 usage info whose PST is specified by |ssid| (deprecated).
// Retrieve usage info whose PST is specified by |ssid|
// 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);
// Retrieve usage info for a given security level and whose PST is
// specified by |ssid| (deprecated).
// Retrieve usage info for a given security level and whose
// PST is specified by |ssid|.
// 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,
RequestedSecurityLevel security_level,
int* error_detail,
CdmUsageInfo* usage_info);
// Remove all usage records for the current origin (deprecated).
// Remove all usage records for the current origin.
virtual CdmResponseType RemoveAllUsageInfo(const std::string& app_id,
CdmSecurityLevel security_level);
// Remove all usage records for the current origin. Span all
// security levels (deprecated).
// security levels.
virtual CdmResponseType RemoveAllUsageInfo(const std::string& app_id);
virtual CdmResponseType RemoveUsageInfo(
@@ -400,6 +406,9 @@ class CdmEngine {
CdmSessionId* session_id);
bool ValidateKeySystem(const CdmKeySystem& key_system);
CdmResponseType GetUsageInfo(const std::string& app_id,
RequestedSecurityLevel requested_security_level,
int* error_detail, CdmUsageInfo* usage_info);
void OnKeyReleaseEvent(const CdmKeySetId& key_set_id);
@@ -434,11 +443,13 @@ class CdmEngine {
std::string spoid_;
uint32_t user_id_;
// Tracks the time of the last update to usage info across all
// actively managed CDM sessions with loaded usage entries. Used
// to periodically update a usage entry associated with an active
// license.
int64_t last_usage_info_update_time_ = 0;
// Usage related variables
// Used to isolate a single active usage information license. Loading,
// creating or releasing a different usage licenses through the engine
// API will release the handle to previously active secure stop license.
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.
std::mutex release_key_sets_lock_;

View File

@@ -75,6 +75,12 @@ class CdmSession {
virtual CdmResponseType RestoreOfflineSession(const CdmKeySetId& key_set_id,
CdmLicenseType license_type,
int* error_detail);
// Restores an usage session from the provided |usage_data|.
// The |error_detail| will be filled with an internal error code. The
// |error_detail| may be a CdmResponseType or other error code type. It is
// only suitable for additional logging or debugging.
virtual CdmResponseType RestoreUsageSession(
const DeviceFiles::CdmUsageData& usage_data, int* error_detail);
virtual const CdmSessionId& session_id() { return session_id_; }
virtual const CdmKeySetId& key_set_id() { return key_set_id_; }
@@ -144,7 +150,7 @@ class CdmSession {
virtual bool is_initial_usage_update() { return is_initial_usage_update_; }
virtual bool is_usage_update_needed() { return is_usage_update_needed_; }
virtual void ResetUsageFlags() {
virtual void reset_usage_flags() {
is_initial_usage_update_ = false;
is_usage_update_needed_ = false;
}
@@ -153,19 +159,12 @@ class CdmSession {
virtual bool is_offline() { return is_offline_; }
virtual bool is_temporary() { return is_temporary_; }
virtual bool license_received() { return license_received_; }
virtual bool HasUsageEntry() {
// The PST is only set if a usage entry has been loaded.
return provider_session_token_.size() > 0;
}
virtual const std::string& provider_session_token() {
return provider_session_token_;
}
void SetProviderSessionTokenForTest(const std::string& pst) {
provider_session_token_ = pst;
virtual bool has_provider_session_token() {
return (license_parser_ &&
license_parser_->provider_session_token().size() > 0);
}
virtual bool SupportsUsageEntries() const {
virtual bool supports_usage_info() const {
return usage_table_header_ != nullptr;
}
@@ -244,6 +243,8 @@ class CdmSession {
bool StoreLicense(CdmOfflineLicenseState state, int* error_detail);
bool UpdateUsageInfo();
CdmResponseType GenerateKeyRequestInternal(
const InitializationData& init_data, CdmLicenseType license_type,
const CdmAppParameterMap& app_parameters, CdmKeyRequest* key_request);
@@ -304,15 +305,14 @@ class CdmSession {
bool last_decrypt_failed_ = false;
// Usage related flags and data
bool is_initial_usage_update_ = true;
bool is_usage_update_needed_ = false;
bool is_initial_usage_update_;
bool is_usage_update_needed_;
// Only assign |usage_table_header_| if capable of supporting usage
// information.
UsageTableHeader* usage_table_header_ = nullptr;
uint32_t usage_entry_number_ = 0;
uint32_t usage_entry_number_;
CdmUsageEntry usage_entry_;
// This PST should only be set if the session has a usage entry.
std::string provider_session_token_;
std::string usage_provider_session_token_;
// information useful for offline and usage scenarios
CdmKeyMessage key_request_;