Improve android MediaDrm property latency
[ Merge of http://go/wvgerrit/89848 ] Apps query a number of properties at initialization. The mediaDrm API getProperty allows the query of a single property at a time. This causes a series of requests. If no crypto sessions are concurrently open, a series of expensive OEMCrypto Initialization and Termination calls will occur. In this change OEMCrypto termination is delayed. If an OEMCrypto Terminate is followed in close succession by an Initialize, neither will occur avoiding the overhead. A timer enables a countdown process. If no session activity occurs, the timer will eventually terminate OEMCrypto and exit. Bug: 136282358 Test: Android unit/integration tests Change-Id: I442b7919b4e7835c52583516c8bc64d0c150241d
This commit is contained in:
@@ -44,11 +44,11 @@ class CryptoSessionFactory;
|
||||
class CryptoSession {
|
||||
public:
|
||||
using HdcpCapability = OEMCrypto_HDCP_Capability;
|
||||
typedef enum {
|
||||
enum UsageDurationStatus {
|
||||
kUsageDurationsInvalid = 0,
|
||||
kUsageDurationPlaybackNotBegun = 1,
|
||||
kUsageDurationsValid = 2,
|
||||
} UsageDurationStatus;
|
||||
};
|
||||
|
||||
struct SupportedCertificateTypes {
|
||||
bool rsa_2048_bit;
|
||||
@@ -64,6 +64,17 @@ class CryptoSession {
|
||||
|
||||
virtual ~CryptoSession();
|
||||
|
||||
// This method will try to terminate OEMCrypto if |session_size_| is 0.
|
||||
// A platform configured property |delay_oem_crypto_termination| will
|
||||
// determine if termination occurs immediately or after a delay.
|
||||
// If termination is delayed, a countdown mechanism is employed.
|
||||
// Call |TryTerminate| periodically until it no longer returns true.
|
||||
// To immediately terminate call |DisableDelayedTermination| before calling
|
||||
// |TryTerminate|.
|
||||
static bool TryTerminate();
|
||||
|
||||
static void DisableDelayedTermination();
|
||||
|
||||
virtual CdmResponseType GetProvisioningToken(std::string* client_token);
|
||||
virtual CdmClientTokenType GetPreProvisionTokenType() {
|
||||
return pre_provision_token_type_;
|
||||
@@ -282,7 +293,6 @@ class CryptoSession {
|
||||
}
|
||||
|
||||
void Init();
|
||||
void Terminate();
|
||||
CdmResponseType GetTokenFromKeybox(std::string* token);
|
||||
CdmResponseType GetTokenFromOemCert(std::string* token);
|
||||
static bool ExtractSystemIdFromOemCert(const std::string& oem_cert,
|
||||
@@ -385,6 +395,7 @@ class CryptoSession {
|
||||
|
||||
static bool initialized_;
|
||||
static int session_count_;
|
||||
static int termination_counter_;
|
||||
|
||||
metrics::CryptoMetrics* metrics_;
|
||||
metrics::TimerMetric life_span_;
|
||||
|
||||
Reference in New Issue
Block a user