OEMCrypto Profiler - Merge of Widevine Updates
This change is a merge of the following changes: 1. Remove MultipleSessions (go/wvgerrit/16763) 2. Increase Memory Budget (go/wvgerrit/16764) 3. Fixing Possible Integer Overflow (go/wvgerrit/16765) 4. Creating Call Table (go/wvgerrit/16766) 5. Creating Call History (go/wvgerrit/16767) 6. Connecting Profiled Scope (go/wvgerrit/16768) 7. Adding Call Table Version Number (go/wvgerrit/16780) 8. Add Version Number to Call History (go/wvgerrit/16781) bug: 27157796 Change-Id: Ia3f088a1714f3f5b426fee6141daa4ea8d832cf4
This commit is contained in:
@@ -39,7 +39,9 @@ LOCAL_SRC_FILES := \
|
|||||||
$(PROFILER_SRC_DIR)/entry_writer.cpp \
|
$(PROFILER_SRC_DIR)/entry_writer.cpp \
|
||||||
$(PROFILER_SRC_DIR)/profiled_scope.cpp \
|
$(PROFILER_SRC_DIR)/profiled_scope.cpp \
|
||||||
$(PROFILER_SRC_DIR)/stats.cpp \
|
$(PROFILER_SRC_DIR)/stats.cpp \
|
||||||
$(PROFILER_SRC_DIR)/profiler_session.cpp
|
$(PROFILER_SRC_DIR)/profiler.cpp \
|
||||||
|
$(PROFILER_SRC_DIR)/call_table.cpp \
|
||||||
|
$(PROFILER_SRC_DIR)/call_history.cpp
|
||||||
|
|
||||||
LOCAL_MODULE := libcdm
|
LOCAL_MODULE := libcdm
|
||||||
LOCAL_MODULE_TAGS := optional
|
LOCAL_MODULE_TAGS := optional
|
||||||
|
|||||||
@@ -23,7 +23,6 @@
|
|||||||
#include "lock.h"
|
#include "lock.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "profiled_scope.h"
|
#include "profiled_scope.h"
|
||||||
#include "profiler_session.h"
|
|
||||||
#include "properties.h"
|
#include "properties.h"
|
||||||
|
|
||||||
using namespace wvoec3;
|
using namespace wvoec3;
|
||||||
@@ -514,10 +513,6 @@ class Adapter {
|
|||||||
session_map_[*session] = new_session;
|
session_map_[*session] = new_session;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result == OEMCrypto_SUCCESS) {
|
|
||||||
wvcdm::oemprofiler::ProfilerSession::Open(static_cast<int64_t>(*session));
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -534,10 +529,6 @@ class Adapter {
|
|||||||
pair->second.fcn->CloseSession(pair->second.session);
|
pair->second.fcn->CloseSession(pair->second.session);
|
||||||
session_map_.erase(pair);
|
session_map_.erase(pair);
|
||||||
|
|
||||||
if (result == OEMCrypto_SUCCESS) {
|
|
||||||
wvcdm::oemprofiler::ProfilerSession::Close(static_cast<int64_t>(session));
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -739,16 +730,6 @@ OEMCryptoResult OEMCrypto_GetMaxNumberOfSessions(SecurityLevel level,
|
|||||||
} // namespace wvcdm
|
} // namespace wvcdm
|
||||||
|
|
||||||
extern "C" OEMCryptoResult OEMCrypto_Initialize(void) {
|
extern "C" OEMCryptoResult OEMCrypto_Initialize(void) {
|
||||||
|
|
||||||
if (wvcdm::oemprofiler::ProfilerSession::Find(
|
|
||||||
wvcdm::oemprofiler::ProfiledScope::kGlobalSID) != NULL) {
|
|
||||||
wvcdm::oemprofiler::ProfilerSession::Close(
|
|
||||||
wvcdm::oemprofiler::ProfiledScope::kGlobalSID);
|
|
||||||
}
|
|
||||||
|
|
||||||
wvcdm::oemprofiler::ProfilerSession::Open(
|
|
||||||
wvcdm::oemprofiler::ProfiledScope::kGlobalSID);
|
|
||||||
|
|
||||||
if (kAdapter) {
|
if (kAdapter) {
|
||||||
kAdapter->Terminate();
|
kAdapter->Terminate();
|
||||||
delete kAdapter;
|
delete kAdapter;
|
||||||
@@ -758,13 +739,6 @@ extern "C" OEMCryptoResult OEMCrypto_Initialize(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
extern "C" OEMCryptoResult OEMCrypto_Terminate(void) {
|
extern "C" OEMCryptoResult OEMCrypto_Terminate(void) {
|
||||||
|
|
||||||
if (wvcdm::oemprofiler::ProfilerSession::Find(
|
|
||||||
wvcdm::oemprofiler::ProfiledScope::kGlobalSID) != NULL) {
|
|
||||||
wvcdm::oemprofiler::ProfilerSession::Close(
|
|
||||||
wvcdm::oemprofiler::ProfiledScope::kGlobalSID);
|
|
||||||
}
|
|
||||||
|
|
||||||
OEMCryptoResult result = OEMCrypto_SUCCESS;
|
OEMCryptoResult result = OEMCrypto_SUCCESS;
|
||||||
if (kAdapter) {
|
if (kAdapter) {
|
||||||
result = kAdapter->Terminate();
|
result = kAdapter->Terminate();
|
||||||
@@ -788,7 +762,7 @@ extern "C" OEMCryptoResult OEMCrypto_GenerateDerivedKeys(
|
|||||||
uint32_t mac_key_context_length, const uint8_t* enc_key_context,
|
uint32_t mac_key_context_length, const uint8_t* enc_key_context,
|
||||||
uint32_t enc_key_context_length) {
|
uint32_t enc_key_context_length) {
|
||||||
|
|
||||||
wvcdm::oemprofiler::ProfiledScope ps(session,
|
wvcdm::oemprofiler::ProfiledScope ps(
|
||||||
wvcdm::oemprofiler::OEM_FUNCTION_GENERATE_DERIVED_KEYS);
|
wvcdm::oemprofiler::OEM_FUNCTION_GENERATE_DERIVED_KEYS);
|
||||||
|
|
||||||
if (!kAdapter) return OEMCrypto_ERROR_UNKNOWN_FAILURE;
|
if (!kAdapter) return OEMCrypto_ERROR_UNKNOWN_FAILURE;
|
||||||
@@ -802,7 +776,7 @@ extern "C" OEMCryptoResult OEMCrypto_GenerateDerivedKeys(
|
|||||||
extern "C" OEMCryptoResult OEMCrypto_GenerateNonce(OEMCrypto_SESSION session,
|
extern "C" OEMCryptoResult OEMCrypto_GenerateNonce(OEMCrypto_SESSION session,
|
||||||
uint32_t* nonce) {
|
uint32_t* nonce) {
|
||||||
|
|
||||||
wvcdm::oemprofiler::ProfiledScope ps(session,
|
wvcdm::oemprofiler::ProfiledScope ps(
|
||||||
wvcdm::oemprofiler::OEM_FUNCTION_GENERATE_NONCE);
|
wvcdm::oemprofiler::OEM_FUNCTION_GENERATE_NONCE);
|
||||||
|
|
||||||
if (!kAdapter) return OEMCrypto_ERROR_UNKNOWN_FAILURE;
|
if (!kAdapter) return OEMCrypto_ERROR_UNKNOWN_FAILURE;
|
||||||
@@ -815,7 +789,7 @@ extern "C" OEMCryptoResult OEMCrypto_GenerateSignature(
|
|||||||
OEMCrypto_SESSION session, const uint8_t* message, size_t message_length,
|
OEMCrypto_SESSION session, const uint8_t* message, size_t message_length,
|
||||||
uint8_t* signature, size_t* signature_length) {
|
uint8_t* signature, size_t* signature_length) {
|
||||||
|
|
||||||
wvcdm::oemprofiler::ProfiledScope ps(session,
|
wvcdm::oemprofiler::ProfiledScope ps(
|
||||||
wvcdm::oemprofiler::OEM_FUNCTION_GENERATE_SIGNATURE);
|
wvcdm::oemprofiler::OEM_FUNCTION_GENERATE_SIGNATURE);
|
||||||
|
|
||||||
if (!kAdapter) return OEMCrypto_ERROR_UNKNOWN_FAILURE;
|
if (!kAdapter) return OEMCrypto_ERROR_UNKNOWN_FAILURE;
|
||||||
@@ -832,7 +806,7 @@ extern "C" OEMCryptoResult OEMCrypto_LoadKeys(
|
|||||||
const OEMCrypto_KeyObject* key_array, const uint8_t* pst,
|
const OEMCrypto_KeyObject* key_array, const uint8_t* pst,
|
||||||
size_t pst_length) {
|
size_t pst_length) {
|
||||||
|
|
||||||
wvcdm::oemprofiler::ProfiledScope ps(session,
|
wvcdm::oemprofiler::ProfiledScope ps(
|
||||||
wvcdm::oemprofiler::OEM_FUNCTION_LOAD_KEYS);
|
wvcdm::oemprofiler::OEM_FUNCTION_LOAD_KEYS);
|
||||||
|
|
||||||
if (!kAdapter) return OEMCrypto_ERROR_UNKNOWN_FAILURE;
|
if (!kAdapter) return OEMCrypto_ERROR_UNKNOWN_FAILURE;
|
||||||
@@ -876,7 +850,7 @@ extern "C" OEMCryptoResult OEMCrypto_RefreshKeys(
|
|||||||
const uint8_t* signature, size_t signature_length, size_t num_keys,
|
const uint8_t* signature, size_t signature_length, size_t num_keys,
|
||||||
const OEMCrypto_KeyRefreshObject* key_array) {
|
const OEMCrypto_KeyRefreshObject* key_array) {
|
||||||
|
|
||||||
wvcdm::oemprofiler::ProfiledScope ps(session,
|
wvcdm::oemprofiler::ProfiledScope ps(
|
||||||
wvcdm::oemprofiler::OEM_FUNCTION_REFRESH_KEYS);
|
wvcdm::oemprofiler::OEM_FUNCTION_REFRESH_KEYS);
|
||||||
|
|
||||||
if (!kAdapter) return OEMCrypto_ERROR_UNKNOWN_FAILURE;
|
if (!kAdapter) return OEMCrypto_ERROR_UNKNOWN_FAILURE;
|
||||||
@@ -890,7 +864,7 @@ extern "C" OEMCryptoResult OEMCrypto_QueryKeyControl(
|
|||||||
OEMCrypto_SESSION session, const uint8_t* key_id, size_t key_id_length,
|
OEMCrypto_SESSION session, const uint8_t* key_id, size_t key_id_length,
|
||||||
uint8_t* key_control_block, size_t* key_control_block_length) {
|
uint8_t* key_control_block, size_t* key_control_block_length) {
|
||||||
|
|
||||||
wvcdm::oemprofiler::ProfiledScope ps(session,
|
wvcdm::oemprofiler::ProfiledScope ps(
|
||||||
wvcdm::oemprofiler::OEM_FUNCTION_QUERY_KEY_CONTROL);
|
wvcdm::oemprofiler::OEM_FUNCTION_QUERY_KEY_CONTROL);
|
||||||
|
|
||||||
if (!kAdapter) return OEMCrypto_ERROR_UNKNOWN_FAILURE;
|
if (!kAdapter) return OEMCrypto_ERROR_UNKNOWN_FAILURE;
|
||||||
@@ -905,7 +879,7 @@ extern "C" OEMCryptoResult OEMCrypto_SelectKey(const OEMCrypto_SESSION session,
|
|||||||
const uint8_t* key_id,
|
const uint8_t* key_id,
|
||||||
size_t key_id_length) {
|
size_t key_id_length) {
|
||||||
|
|
||||||
wvcdm::oemprofiler::ProfiledScope ps(session,
|
wvcdm::oemprofiler::ProfiledScope ps(
|
||||||
wvcdm::oemprofiler::OEM_FUNCTION_SELECT_KEY);
|
wvcdm::oemprofiler::OEM_FUNCTION_SELECT_KEY);
|
||||||
|
|
||||||
if (!kAdapter) return OEMCrypto_ERROR_UNKNOWN_FAILURE;
|
if (!kAdapter) return OEMCrypto_ERROR_UNKNOWN_FAILURE;
|
||||||
@@ -921,7 +895,7 @@ extern "C" OEMCryptoResult OEMCrypto_DecryptCENC(
|
|||||||
const OEMCrypto_CENCEncryptPatternDesc* pattern,
|
const OEMCrypto_CENCEncryptPatternDesc* pattern,
|
||||||
uint8_t subsample_flags) {
|
uint8_t subsample_flags) {
|
||||||
|
|
||||||
wvcdm::oemprofiler::ProfiledScope ps(session,
|
wvcdm::oemprofiler::ProfiledScope ps(
|
||||||
wvcdm::oemprofiler::OEM_FUNCTION_DECRYPT_CENC);
|
wvcdm::oemprofiler::OEM_FUNCTION_DECRYPT_CENC);
|
||||||
|
|
||||||
ps.meta_data_.WriteVLV(static_cast<uint64_t>(data_length));
|
ps.meta_data_.WriteVLV(static_cast<uint64_t>(data_length));
|
||||||
@@ -1014,7 +988,7 @@ extern "C" OEMCryptoResult OEMCrypto_RewrapDeviceRSAKey(
|
|||||||
const uint8_t* enc_rsa_key_iv, uint8_t* wrapped_rsa_key,
|
const uint8_t* enc_rsa_key_iv, uint8_t* wrapped_rsa_key,
|
||||||
size_t* wrapped_rsa_key_length) {
|
size_t* wrapped_rsa_key_length) {
|
||||||
|
|
||||||
wvcdm::oemprofiler::ProfiledScope ps(session,
|
wvcdm::oemprofiler::ProfiledScope ps(
|
||||||
wvcdm::oemprofiler::OEM_FUNCTION_REWRAP_DEVICE_RSA_KEY);
|
wvcdm::oemprofiler::OEM_FUNCTION_REWRAP_DEVICE_RSA_KEY);
|
||||||
|
|
||||||
if (!kAdapter) return OEMCrypto_ERROR_UNKNOWN_FAILURE;
|
if (!kAdapter) return OEMCrypto_ERROR_UNKNOWN_FAILURE;
|
||||||
@@ -1030,7 +1004,7 @@ extern "C" OEMCryptoResult OEMCrypto_LoadDeviceRSAKey(
|
|||||||
OEMCrypto_SESSION session, const uint8_t* wrapped_rsa_key,
|
OEMCrypto_SESSION session, const uint8_t* wrapped_rsa_key,
|
||||||
size_t wrapped_rsa_key_length) {
|
size_t wrapped_rsa_key_length) {
|
||||||
|
|
||||||
wvcdm::oemprofiler::ProfiledScope ps(session,
|
wvcdm::oemprofiler::ProfiledScope ps(
|
||||||
wvcdm::oemprofiler::OEM_FUNCTION_LOAD_DEVICE_RSA_KEY);
|
wvcdm::oemprofiler::OEM_FUNCTION_LOAD_DEVICE_RSA_KEY);
|
||||||
|
|
||||||
if (!kAdapter) return OEMCrypto_ERROR_UNKNOWN_FAILURE;
|
if (!kAdapter) return OEMCrypto_ERROR_UNKNOWN_FAILURE;
|
||||||
@@ -1057,7 +1031,7 @@ extern "C" OEMCryptoResult OEMCrypto_GenerateRSASignature(
|
|||||||
uint8_t* signature, size_t* signature_length,
|
uint8_t* signature, size_t* signature_length,
|
||||||
RSA_Padding_Scheme padding_scheme) {
|
RSA_Padding_Scheme padding_scheme) {
|
||||||
|
|
||||||
wvcdm::oemprofiler::ProfiledScope ps(session,
|
wvcdm::oemprofiler::ProfiledScope ps(
|
||||||
wvcdm::oemprofiler::OEM_FUNCTION_GENERATE_RSA_SIGNATURE);
|
wvcdm::oemprofiler::OEM_FUNCTION_GENERATE_RSA_SIGNATURE);
|
||||||
|
|
||||||
if (!kAdapter) return OEMCrypto_ERROR_UNKNOWN_FAILURE;
|
if (!kAdapter) return OEMCrypto_ERROR_UNKNOWN_FAILURE;
|
||||||
@@ -1079,7 +1053,7 @@ extern "C" OEMCryptoResult OEMCrypto_DeriveKeysFromSessionKey(
|
|||||||
size_t mac_key_context_length, const uint8_t* enc_key_context,
|
size_t mac_key_context_length, const uint8_t* enc_key_context,
|
||||||
size_t enc_key_context_length) {
|
size_t enc_key_context_length) {
|
||||||
|
|
||||||
wvcdm::oemprofiler::ProfiledScope ps(session,
|
wvcdm::oemprofiler::ProfiledScope ps(
|
||||||
wvcdm::oemprofiler::OEM_FUNCTION_DERIVE_KEYS_FROM_SESSION_KEY);
|
wvcdm::oemprofiler::OEM_FUNCTION_DERIVE_KEYS_FROM_SESSION_KEY);
|
||||||
|
|
||||||
if (!kAdapter) return OEMCrypto_ERROR_UNKNOWN_FAILURE;
|
if (!kAdapter) return OEMCrypto_ERROR_UNKNOWN_FAILURE;
|
||||||
@@ -1127,7 +1101,7 @@ extern "C" OEMCryptoResult OEMCrypto_Generic_Encrypt(
|
|||||||
OEMCrypto_SESSION session, const uint8_t* in_buffer, size_t buffer_length,
|
OEMCrypto_SESSION session, const uint8_t* in_buffer, size_t buffer_length,
|
||||||
const uint8_t* iv, OEMCrypto_Algorithm algorithm, uint8_t* out_buffer) {
|
const uint8_t* iv, OEMCrypto_Algorithm algorithm, uint8_t* out_buffer) {
|
||||||
|
|
||||||
wvcdm::oemprofiler::ProfiledScope ps(session,
|
wvcdm::oemprofiler::ProfiledScope ps(
|
||||||
wvcdm::oemprofiler::OEM_FUNCTION_GENERIC_ENCRYPT);
|
wvcdm::oemprofiler::OEM_FUNCTION_GENERIC_ENCRYPT);
|
||||||
|
|
||||||
if (!kAdapter) return OEMCrypto_ERROR_UNKNOWN_FAILURE;
|
if (!kAdapter) return OEMCrypto_ERROR_UNKNOWN_FAILURE;
|
||||||
@@ -1141,7 +1115,7 @@ extern "C" OEMCryptoResult OEMCrypto_Generic_Decrypt(
|
|||||||
OEMCrypto_SESSION session, const uint8_t* in_buffer, size_t buffer_length,
|
OEMCrypto_SESSION session, const uint8_t* in_buffer, size_t buffer_length,
|
||||||
const uint8_t* iv, OEMCrypto_Algorithm algorithm, uint8_t* out_buffer) {
|
const uint8_t* iv, OEMCrypto_Algorithm algorithm, uint8_t* out_buffer) {
|
||||||
|
|
||||||
wvcdm::oemprofiler::ProfiledScope ps(session,
|
wvcdm::oemprofiler::ProfiledScope ps(
|
||||||
wvcdm::oemprofiler::OEM_FUNCTION_GENERIC_DECRYPT);
|
wvcdm::oemprofiler::OEM_FUNCTION_GENERIC_DECRYPT);
|
||||||
|
|
||||||
if (!kAdapter) return OEMCrypto_ERROR_UNKNOWN_FAILURE;
|
if (!kAdapter) return OEMCrypto_ERROR_UNKNOWN_FAILURE;
|
||||||
@@ -1158,7 +1132,7 @@ extern "C" OEMCryptoResult OEMCrypto_Generic_Sign(OEMCrypto_SESSION session,
|
|||||||
uint8_t* signature,
|
uint8_t* signature,
|
||||||
size_t* signature_length) {
|
size_t* signature_length) {
|
||||||
|
|
||||||
wvcdm::oemprofiler::ProfiledScope ps(session,
|
wvcdm::oemprofiler::ProfiledScope ps(
|
||||||
wvcdm::oemprofiler::OEM_FUNCTION_GENERIC_SIGN);
|
wvcdm::oemprofiler::OEM_FUNCTION_GENERIC_SIGN);
|
||||||
|
|
||||||
if (!kAdapter) return OEMCrypto_ERROR_UNKNOWN_FAILURE;
|
if (!kAdapter) return OEMCrypto_ERROR_UNKNOWN_FAILURE;
|
||||||
@@ -1224,7 +1198,7 @@ extern "C" OEMCryptoResult OEMCrypto_ReportUsage(OEMCrypto_SESSION session,
|
|||||||
OEMCrypto_PST_Report* buffer,
|
OEMCrypto_PST_Report* buffer,
|
||||||
size_t* buffer_length) {
|
size_t* buffer_length) {
|
||||||
|
|
||||||
wvcdm::oemprofiler::ProfiledScope ps(session,
|
wvcdm::oemprofiler::ProfiledScope ps(
|
||||||
wvcdm::oemprofiler::OEM_FUNCTION_REPORT_USAGE);
|
wvcdm::oemprofiler::OEM_FUNCTION_REPORT_USAGE);
|
||||||
|
|
||||||
if (!kAdapter) return OEMCrypto_ERROR_UNKNOWN_FAILURE;
|
if (!kAdapter) return OEMCrypto_ERROR_UNKNOWN_FAILURE;
|
||||||
@@ -1243,7 +1217,7 @@ extern "C" OEMCryptoResult OEMCrypto_DeleteUsageEntry(
|
|||||||
const uint8_t* message, size_t message_length, const uint8_t* signature,
|
const uint8_t* message, size_t message_length, const uint8_t* signature,
|
||||||
size_t signature_length) {
|
size_t signature_length) {
|
||||||
|
|
||||||
wvcdm::oemprofiler::ProfiledScope ps(session,
|
wvcdm::oemprofiler::ProfiledScope ps(
|
||||||
wvcdm::oemprofiler::OEM_FUNCTION_DELETE_USAGE_ENTRY);
|
wvcdm::oemprofiler::OEM_FUNCTION_DELETE_USAGE_ENTRY);
|
||||||
|
|
||||||
if (!kAdapter) return OEMCrypto_ERROR_UNKNOWN_FAILURE;
|
if (!kAdapter) return OEMCrypto_ERROR_UNKNOWN_FAILURE;
|
||||||
|
|||||||
49
libwvdrmengine/cdm/profiler/include/call_history.h
Normal file
49
libwvdrmengine/cdm/profiler/include/call_history.h
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
// Copyright 2016 Google Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#ifndef WVCDM_CALL_HISTORY_H_
|
||||||
|
#define WVCDM_CALL_HISTORY_H_
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include "circular_buffer.h"
|
||||||
|
#include "oem_functions.h"
|
||||||
|
|
||||||
|
namespace wvcdm {
|
||||||
|
namespace oemprofiler {
|
||||||
|
|
||||||
|
class CallHistory {
|
||||||
|
|
||||||
|
public:
|
||||||
|
CallHistory();
|
||||||
|
|
||||||
|
void Write(
|
||||||
|
OEM_FUNCTION fid,
|
||||||
|
uint64_t start_time,
|
||||||
|
uint64_t end_time,
|
||||||
|
const uint8_t* meta_data,
|
||||||
|
size_t meta_data_length);
|
||||||
|
|
||||||
|
void Read(std::vector<uint8_t>& output) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
CircularBuffer buffer_;
|
||||||
|
|
||||||
|
uint64_t time_at_head_;
|
||||||
|
uint64_t time_at_tail_;
|
||||||
|
|
||||||
|
bool RequestSpace(uint8_t num_bytes);
|
||||||
|
|
||||||
|
bool ReadNextEntryRealEndTime(uint64_t* output);
|
||||||
|
|
||||||
|
bool DropLastEntry();
|
||||||
|
|
||||||
|
// Read a variable length value. This is the read that matches
|
||||||
|
// EntryWriter's WriteVLV.
|
||||||
|
int ReadVLV(size_t offset, uint64_t* output) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace oemprofiler
|
||||||
|
} // namespace wvcdm
|
||||||
|
|
||||||
|
#endif
|
||||||
49
libwvdrmengine/cdm/profiler/include/call_table.h
Normal file
49
libwvdrmengine/cdm/profiler/include/call_table.h
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
#ifndef WVCDM_PROFILER_CALL_TABLE_H_
|
||||||
|
#define WVCDM_PROFILER_CALL_TABLE_H_
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
namespace wvcdm {
|
||||||
|
namespace oemprofiler {
|
||||||
|
|
||||||
|
class CallTable {
|
||||||
|
public:
|
||||||
|
class Row {
|
||||||
|
public:
|
||||||
|
Row();
|
||||||
|
void Add(uint64_t sample);
|
||||||
|
|
||||||
|
uint64_t GetSampleSize() const;
|
||||||
|
|
||||||
|
uint64_t GetMin() const;
|
||||||
|
uint64_t GetMax() const;
|
||||||
|
|
||||||
|
double GetMean() const;
|
||||||
|
double GetVariance() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
uint64_t min_;
|
||||||
|
uint64_t max_;
|
||||||
|
uint64_t sample_size_;
|
||||||
|
double mean_;
|
||||||
|
double variance_m_;
|
||||||
|
double variance_s_;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
const Row* LookUp(uint64_t row_id) const;
|
||||||
|
|
||||||
|
void Write(uint64_t row_id, uint64_t sample);
|
||||||
|
|
||||||
|
void Read(std::vector<uint8_t>& output) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::map<uint64_t, Row> map_;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace oemprofiler
|
||||||
|
} // namespace wvcdm
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -14,26 +14,16 @@ namespace oemprofiler {
|
|||||||
class ProfiledScope {
|
class ProfiledScope {
|
||||||
public:
|
public:
|
||||||
explicit ProfiledScope(OEM_FUNCTION fid);
|
explicit ProfiledScope(OEM_FUNCTION fid);
|
||||||
explicit ProfiledScope(uint32_t sid, OEM_FUNCTION fid);
|
|
||||||
~ProfiledScope();
|
~ProfiledScope();
|
||||||
|
|
||||||
EntryWriter meta_data_;
|
EntryWriter meta_data_;
|
||||||
|
|
||||||
// All profiling data must be assigned to a session but some oem
|
|
||||||
// crypto calls are not associated with crypto sessions. To gather
|
|
||||||
// those functions' data, the global session id is used. Crypto.Session
|
|
||||||
// Ids are unsigned 32 bit integers. To use those as a profiling session
|
|
||||||
// id but also allow for a global id that won't conflict with them,
|
|
||||||
// we use a -1 as the a proifiling session id is a signed 64 bit integer.
|
|
||||||
static const int64_t kGlobalSID = -1;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int64_t sid_;
|
|
||||||
OEM_FUNCTION fid_;
|
OEM_FUNCTION fid_;
|
||||||
|
|
||||||
uint64_t start_time_;
|
uint64_t start_time_;
|
||||||
|
|
||||||
void Submit(int64_t sid, uint64_t end_time) const;
|
void Submit(uint64_t end_time) const;
|
||||||
uint64_t GetNowUS() const;
|
uint64_t GetNowUS() const;
|
||||||
|
|
||||||
// disallow copy and assign
|
// disallow copy and assign
|
||||||
|
|||||||
25
libwvdrmengine/cdm/profiler/include/profiler.h
Normal file
25
libwvdrmengine/cdm/profiler/include/profiler.h
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
// Copyright 2016 Google Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#ifndef WVCDM_PROFILER_H_
|
||||||
|
#define WVCDM_PROFILER_H_
|
||||||
|
|
||||||
|
#include "call_table.h"
|
||||||
|
#include "call_history.h"
|
||||||
|
|
||||||
|
namespace wvcdm {
|
||||||
|
namespace oemprofiler {
|
||||||
|
|
||||||
|
class Profiler {
|
||||||
|
public:
|
||||||
|
static CallTable& GetTable();
|
||||||
|
static CallHistory& GetHistory();
|
||||||
|
|
||||||
|
private:
|
||||||
|
static CallTable global_table_;
|
||||||
|
static CallHistory global_history_;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace oemprofiler
|
||||||
|
} // namespace wvcdm
|
||||||
|
|
||||||
|
#endif
|
||||||
170
libwvdrmengine/cdm/profiler/src/call_history.cpp
Normal file
170
libwvdrmengine/cdm/profiler/src/call_history.cpp
Normal file
@@ -0,0 +1,170 @@
|
|||||||
|
// Copyright 2016 Google Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#include "call_history.h"
|
||||||
|
|
||||||
|
#include <log.h>
|
||||||
|
|
||||||
|
#include "entry_writer.h"
|
||||||
|
|
||||||
|
namespace wvcdm {
|
||||||
|
namespace oemprofiler {
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
const size_t kProfilingMemoryBudget = 64 * 1024; // 64 KB
|
||||||
|
const uint8_t kOutputVersionNumber = 0x00;
|
||||||
|
}
|
||||||
|
|
||||||
|
CallHistory::CallHistory() :
|
||||||
|
buffer_(kProfilingMemoryBudget),
|
||||||
|
time_at_head_(0),
|
||||||
|
time_at_tail_(0) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CallHistory::Write(
|
||||||
|
OEM_FUNCTION fid,
|
||||||
|
uint64_t start_time,
|
||||||
|
uint64_t end_time,
|
||||||
|
const uint8_t* meta_data,
|
||||||
|
size_t meta_data_length) {
|
||||||
|
|
||||||
|
// time_at_tail <= start_time <= end_time or else the subtraction
|
||||||
|
// will be invalid
|
||||||
|
if (start_time > end_time || start_time < time_at_tail_) {
|
||||||
|
LOGE("Skipping submission. Submission has time travelled."
|
||||||
|
"Start=%llu End=%llu Tail=%llu. Should be Tail<=Start<=End.",
|
||||||
|
start_time, end_time, time_at_tail_);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
EntryWriter header;
|
||||||
|
header.WriteU8(fid);
|
||||||
|
header.WriteVLV(start_time - time_at_tail_);
|
||||||
|
header.WriteVLV(end_time - start_time);
|
||||||
|
|
||||||
|
const size_t total_packet_size = header.GetSize() + meta_data_length;
|
||||||
|
|
||||||
|
// The max size for a VLV is 8 bytes and the max size for a entry
|
||||||
|
// writer is 32 bytes. Normally the meta data will be packed using
|
||||||
|
// an entry writer so the max packet size will be 64 bytes. Since the
|
||||||
|
// packet size is encoded with a single byte, the packet must first
|
||||||
|
// be checked to ensure it is not too large for the cast.
|
||||||
|
if (total_packet_size <= 255 && RequestSpace(total_packet_size + 1)) {
|
||||||
|
buffer_.AddU8(static_cast<uint8_t>(total_packet_size));
|
||||||
|
buffer_.AddU8s(header.GetData(), header.GetSize());
|
||||||
|
buffer_.AddU8s(meta_data, meta_data_length);
|
||||||
|
|
||||||
|
time_at_tail_ = end_time;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CallHistory::Read(std::vector<uint8_t>& output) const {
|
||||||
|
output.push_back(kOutputVersionNumber);
|
||||||
|
|
||||||
|
// write the starting time
|
||||||
|
EntryWriter startingTimeWriter;
|
||||||
|
if (-1 == startingTimeWriter.WriteVLV(time_at_head_)) {
|
||||||
|
output.clear();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (size_t i = 0; i < startingTimeWriter.GetSize(); i++) {
|
||||||
|
output.push_back(startingTimeWriter.GetData()[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// write the whole circular buffer into the output buffer
|
||||||
|
const size_t num_bytes = buffer_.GetUsedSpace();
|
||||||
|
for (size_t i = 0; i < num_bytes; i++) {
|
||||||
|
uint8_t b;
|
||||||
|
if (buffer_.PeekU8(i, &b)) {
|
||||||
|
output.push_back(b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CallHistory::RequestSpace(uint8_t num_bytes) {
|
||||||
|
// check if it is possible to make enough room
|
||||||
|
const size_t buffer_size = buffer_.GetFreeSpace() +
|
||||||
|
buffer_.GetUsedSpace();
|
||||||
|
|
||||||
|
if (num_bytes > buffer_size) {
|
||||||
|
LOGE("Requesting more space than possible (requested = %u, max = %zu)",
|
||||||
|
num_bytes, buffer_size);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// drop entries until we have enough space
|
||||||
|
while (num_bytes > buffer_.GetFreeSpace() && DropLastEntry());
|
||||||
|
|
||||||
|
return num_bytes <= buffer_.GetFreeSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CallHistory::ReadNextEntryRealEndTime(uint64_t* output) {
|
||||||
|
if (output == NULL) {
|
||||||
|
LOGE("Cannout output to null pointer");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t initial_time_start_index = 2;
|
||||||
|
|
||||||
|
uint64_t initial_time;
|
||||||
|
const int initial_time_length =
|
||||||
|
ReadVLV(initial_time_start_index, &initial_time);
|
||||||
|
if (initial_time_length == -1) {
|
||||||
|
LOGE("Failed to read the start time for head entry");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t delta_time;
|
||||||
|
const int delta_time_length = ReadVLV(
|
||||||
|
initial_time_start_index + initial_time_length, &delta_time);
|
||||||
|
|
||||||
|
if (delta_time_length == -1) {
|
||||||
|
LOGE("Failed to read the delta time for head entry");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
*output = time_at_head_ + initial_time + delta_time;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CallHistory::DropLastEntry() {
|
||||||
|
uint8_t entry_size;
|
||||||
|
uint64_t end_time;
|
||||||
|
|
||||||
|
if (buffer_.PeekU8(0, &entry_size) && ReadNextEntryRealEndTime(&end_time)) {
|
||||||
|
// + 1 because the entry size byte needs to be removed too
|
||||||
|
if (buffer_.Remove(entry_size + 1)) {
|
||||||
|
time_at_head_ = end_time;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CallHistory::ReadVLV(size_t offset, uint64_t* output) const {
|
||||||
|
uint8_t first_byte;
|
||||||
|
if (buffer_.PeekU8(offset, &first_byte)) {
|
||||||
|
const size_t num_bytes = (first_byte >> 5) + 1;
|
||||||
|
|
||||||
|
uint64_t value = first_byte & 0x1F;
|
||||||
|
for (size_t i = 1; i < num_bytes; i++) {
|
||||||
|
uint8_t next_byte;
|
||||||
|
if (buffer_.PeekU8(offset + i, &next_byte)) {
|
||||||
|
value = value << 8 | next_byte;
|
||||||
|
} else {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
*output = value;
|
||||||
|
return num_bytes;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace wvcdm
|
||||||
|
} // namespace oemprofiler
|
||||||
|
|
||||||
103
libwvdrmengine/cdm/profiler/src/call_table.cpp
Normal file
103
libwvdrmengine/cdm/profiler/src/call_table.cpp
Normal file
@@ -0,0 +1,103 @@
|
|||||||
|
#include "call_table.h"
|
||||||
|
|
||||||
|
#include <limits>
|
||||||
|
|
||||||
|
#include "entry_writer.h"
|
||||||
|
|
||||||
|
namespace wvcdm {
|
||||||
|
namespace oemprofiler {
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
const uint8_t kOutputVersionNumber = 0x00;
|
||||||
|
}
|
||||||
|
|
||||||
|
CallTable::Row::Row() :
|
||||||
|
min_(std::numeric_limits<uint64_t>::max()),
|
||||||
|
max_(0),
|
||||||
|
sample_size_(0),
|
||||||
|
mean_(0),
|
||||||
|
variance_m_(0),
|
||||||
|
variance_s_(0) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CallTable::Row::Add(uint64_t value) {
|
||||||
|
min_ = std::min(min_, value);
|
||||||
|
max_ = std::max(max_, value);
|
||||||
|
|
||||||
|
mean_ = ((mean_ * sample_size_) + value) / (sample_size_ + 1.0);
|
||||||
|
sample_size_ += 1;
|
||||||
|
|
||||||
|
// Welford's method for standard deviation and variance
|
||||||
|
const double old_m = variance_m_;
|
||||||
|
const double old_s = variance_s_;
|
||||||
|
variance_m_ = old_m + (value - old_m) / sample_size_;
|
||||||
|
variance_s_ = old_s + (value - variance_m_) * (value -old_m);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t CallTable::Row::GetSampleSize() const {
|
||||||
|
return sample_size_;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t CallTable::Row::GetMin() const {
|
||||||
|
return min_;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t CallTable::Row::GetMax() const {
|
||||||
|
return max_;
|
||||||
|
}
|
||||||
|
|
||||||
|
double CallTable::Row::GetMean() const {
|
||||||
|
return mean_;
|
||||||
|
}
|
||||||
|
|
||||||
|
double CallTable::Row::GetVariance() const {
|
||||||
|
return sample_size_ > 1 ? variance_s_ / (sample_size_ - 1) : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
const CallTable::Row* CallTable::LookUp(uint64_t row_id) const {
|
||||||
|
return map_.count(row_id) == 0 ? NULL : &map_.find(row_id)->second;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CallTable::Write(uint64_t row_id, uint64_t sample) {
|
||||||
|
if (map_.count(row_id) == 0) {
|
||||||
|
map_.insert(std::pair<uint64_t, Row>(row_id, Row()));
|
||||||
|
}
|
||||||
|
|
||||||
|
map_[row_id].Add(sample);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CallTable::Read(std::vector<uint8_t>& output) const {
|
||||||
|
output.push_back(kOutputVersionNumber);
|
||||||
|
|
||||||
|
for (std::map<uint64_t, Row>::const_iterator it = map_.begin();
|
||||||
|
it != map_.end(); ++it) {
|
||||||
|
|
||||||
|
const uint64_t values_to_write[] = {
|
||||||
|
it->first,
|
||||||
|
it->second.GetSampleSize(),
|
||||||
|
it->second.GetMin(),
|
||||||
|
it->second.GetMax(),
|
||||||
|
static_cast<uint64_t>(it->second.GetMean()),
|
||||||
|
// get the decimal places to the one-hundredths
|
||||||
|
static_cast<uint64_t>(it->second.GetMean() * 100) % 100,
|
||||||
|
static_cast<uint64_t>(it->second.GetVariance()),
|
||||||
|
// get the decimal places to the one-hundredths
|
||||||
|
static_cast<uint64_t>(it->second.GetVariance() * 100) % 100
|
||||||
|
};
|
||||||
|
|
||||||
|
const size_t kValuesToWriteSize = 8;
|
||||||
|
|
||||||
|
for (size_t i = 0; i < kValuesToWriteSize; i++) {
|
||||||
|
EntryWriter writer;
|
||||||
|
writer.WriteVLV(values_to_write[i]);
|
||||||
|
|
||||||
|
for (size_t w_i = 0; w_i < writer.GetSize(); w_i++) {
|
||||||
|
output.push_back(writer.GetData()[w_i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace oemprofiler
|
||||||
|
} // namespace wvcdm
|
||||||
@@ -4,53 +4,31 @@
|
|||||||
|
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
|
||||||
#include "profiler_session.h"
|
#include "profiler.h"
|
||||||
|
|
||||||
namespace wvcdm {
|
namespace wvcdm {
|
||||||
namespace oemprofiler {
|
namespace oemprofiler {
|
||||||
|
|
||||||
ProfiledScope::ProfiledScope(OEM_FUNCTION fid) :
|
ProfiledScope::ProfiledScope(OEM_FUNCTION fid) :
|
||||||
meta_data_(),
|
meta_data_(),
|
||||||
sid_(kGlobalSID),
|
|
||||||
fid_(fid),
|
|
||||||
start_time_(GetNowUS()) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Only allow a user provided sid to be a positive integer
|
|
||||||
// to prevent a user provided sid from conflicting with the
|
|
||||||
// global sid
|
|
||||||
ProfiledScope::ProfiledScope(uint32_t sid, OEM_FUNCTION fid) :
|
|
||||||
meta_data_(),
|
|
||||||
sid_(static_cast<int64_t>(sid)),
|
|
||||||
fid_(fid),
|
fid_(fid),
|
||||||
start_time_(GetNowUS()) {
|
start_time_(GetNowUS()) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ProfiledScope::~ProfiledScope() {
|
ProfiledScope::~ProfiledScope() {
|
||||||
const uint64_t end_time = GetNowUS();
|
Submit(GetNowUS());
|
||||||
|
|
||||||
if (sid_ != kGlobalSID) {
|
|
||||||
Submit(sid_, end_time);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Always save a copy to the global session so that all other sessions
|
|
||||||
// are subsets of the global session
|
|
||||||
Submit(kGlobalSID, end_time);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProfiledScope::Submit(int64_t sid, uint64_t end_time) const {
|
void ProfiledScope::Submit(uint64_t end_time) const {
|
||||||
ProfilerSession* const session = ProfilerSession::Find(sid);
|
Profiler::GetTable().Write(fid_, end_time - start_time_);
|
||||||
|
|
||||||
if (session != NULL) {
|
Profiler::GetHistory().Write(
|
||||||
session->Submit(
|
|
||||||
fid_,
|
fid_,
|
||||||
start_time_,
|
start_time_,
|
||||||
end_time,
|
end_time,
|
||||||
meta_data_.GetData(),
|
meta_data_.GetData(),
|
||||||
meta_data_.GetSize());
|
meta_data_.GetSize());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t ProfiledScope::GetNowUS() const {
|
uint64_t ProfiledScope::GetNowUS() const {
|
||||||
|
|||||||
21
libwvdrmengine/cdm/profiler/src/profiler.cpp
Normal file
21
libwvdrmengine/cdm/profiler/src/profiler.cpp
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
// Copyright 2016 Google Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#include "profiler.h"
|
||||||
|
|
||||||
|
namespace wvcdm {
|
||||||
|
namespace oemprofiler {
|
||||||
|
|
||||||
|
CallTable Profiler::global_table_;
|
||||||
|
CallHistory Profiler::global_history_;
|
||||||
|
|
||||||
|
CallTable& Profiler::GetTable() {
|
||||||
|
return global_table_;
|
||||||
|
}
|
||||||
|
|
||||||
|
CallHistory& Profiler::GetHistory() {
|
||||||
|
return global_history_;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace wvcdm
|
||||||
|
} // namespace oemprofiler
|
||||||
|
|
||||||
@@ -13,7 +13,6 @@
|
|||||||
#include "media/stagefright/foundation/ABase.h"
|
#include "media/stagefright/foundation/ABase.h"
|
||||||
#include "media/stagefright/foundation/AString.h"
|
#include "media/stagefright/foundation/AString.h"
|
||||||
#include "OEMCryptoCENC.h"
|
#include "OEMCryptoCENC.h"
|
||||||
#include "profiler_session.h"
|
|
||||||
#include "utils/Errors.h"
|
#include "utils/Errors.h"
|
||||||
#include "utils/KeyedVector.h"
|
#include "utils/KeyedVector.h"
|
||||||
#include "utils/List.h"
|
#include "utils/List.h"
|
||||||
@@ -275,11 +274,6 @@ class WVDrmPlugin : public android::DrmPlugin,
|
|||||||
status_t mapAndNotifyOfOEMCryptoResult(const Vector<uint8_t>& sessionId,
|
status_t mapAndNotifyOfOEMCryptoResult(const Vector<uint8_t>& sessionId,
|
||||||
OEMCryptoResult res);
|
OEMCryptoResult res);
|
||||||
|
|
||||||
bool tryGettingSessionFromPropertyName(
|
|
||||||
const String8& name,
|
|
||||||
const String8& tag,
|
|
||||||
wvcdm::oemprofiler::ProfilerSession** out) const;
|
|
||||||
|
|
||||||
bool tryGettingOEMProfilingHistory(
|
bool tryGettingOEMProfilingHistory(
|
||||||
const String8& name,
|
const String8& name,
|
||||||
Vector<uint8_t>& value) const;
|
Vector<uint8_t>& value) const;
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
#include "mapErrors-inl.h"
|
#include "mapErrors-inl.h"
|
||||||
#include "media/stagefright/MediaErrors.h"
|
#include "media/stagefright/MediaErrors.h"
|
||||||
#include "profiled_scope.h"
|
#include "profiler.h"
|
||||||
#include "utils/Errors.h"
|
#include "utils/Errors.h"
|
||||||
#include "wv_cdm_constants.h"
|
#include "wv_cdm_constants.h"
|
||||||
|
|
||||||
@@ -30,8 +30,8 @@ namespace {
|
|||||||
|
|
||||||
|
|
||||||
// profiler proterties constants
|
// profiler proterties constants
|
||||||
static const android::String8 kProfilerHistoryTag("oemProfilerHistory-");
|
static const android::String8 kProfilerHistoryTag("oemProfilerHistory");
|
||||||
static const android::String8 kProfilerStatsTag("oemProfilerStats-");
|
static const android::String8 kProfilerStatsTag("oemProfilerStats");
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace wvdrm {
|
namespace wvdrm {
|
||||||
@@ -498,84 +498,33 @@ status_t WVDrmPlugin::getPropertyString(const String8& name,
|
|||||||
return android::OK;
|
return android::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WVDrmPlugin::tryGettingSessionFromPropertyName(
|
|
||||||
const String8& name,
|
|
||||||
const String8& tag,
|
|
||||||
oemprofiler::ProfilerSession** out) const {
|
|
||||||
|
|
||||||
if (name.find(tag) != 0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
oemprofiler::ProfilerSession* session = NULL;
|
|
||||||
|
|
||||||
// if the name starts with the tag and is the same length
|
|
||||||
// as the tag, then it must just be the tag
|
|
||||||
if (name.length() == tag.length()) {
|
|
||||||
// if it is just the tag, then return the global session
|
|
||||||
session = oemprofiler::ProfilerSession::Find(
|
|
||||||
oemprofiler::ProfiledScope::kGlobalSID);
|
|
||||||
} else {
|
|
||||||
// make a string that is only the part that comes after the tag.
|
|
||||||
// If it is a valid property, this should be a cdm session id
|
|
||||||
const CdmSessionId cdm_session_id(name.string() + tag.length());
|
|
||||||
|
|
||||||
if (mCryptoSessions.count(cdm_session_id) != 1) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const OEMCrypto_SESSION sid =
|
|
||||||
mCryptoSessions.at(cdm_session_id).oecSessionId();
|
|
||||||
|
|
||||||
session = oemprofiler::ProfilerSession::Find(static_cast<int64_t>(sid));
|
|
||||||
}
|
|
||||||
|
|
||||||
// if the session is not open, then treat the property as not existing
|
|
||||||
if (session == nullptr) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (out != nullptr) {
|
|
||||||
*out = session;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool WVDrmPlugin::tryGettingOEMProfilingHistory(const String8& name,
|
bool WVDrmPlugin::tryGettingOEMProfilingHistory(const String8& name,
|
||||||
Vector<uint8_t>& value) const {
|
Vector<uint8_t>& value) const {
|
||||||
|
|
||||||
oemprofiler::ProfilerSession* session = nullptr;
|
if (name == kProfilerHistoryTag) {
|
||||||
|
|
||||||
if (!tryGettingSessionFromPropertyName(
|
|
||||||
name, kProfilerHistoryTag, &session)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// read the data out of the session
|
|
||||||
std::vector<uint8_t> tempValue;
|
std::vector<uint8_t> tempValue;
|
||||||
session->ReadHistory(tempValue);
|
oemprofiler::Profiler::GetHistory().Read(tempValue);
|
||||||
value.appendArray(tempValue.data(), tempValue.size());
|
value.appendArray(tempValue.data(), tempValue.size());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WVDrmPlugin::tryGettingOEMProfilingStats(
|
bool WVDrmPlugin::tryGettingOEMProfilingStats(
|
||||||
const String8& name,
|
const String8& name,
|
||||||
Vector<uint8_t>& value) const {
|
Vector<uint8_t>& value) const {
|
||||||
|
|
||||||
oemprofiler::ProfilerSession* session = nullptr;
|
if (name == kProfilerStatsTag) {
|
||||||
|
std::vector<uint8_t> tempValue;
|
||||||
|
oemprofiler::Profiler::GetTable().Read(tempValue);
|
||||||
|
value.appendArray(tempValue.data(), tempValue.size());
|
||||||
|
|
||||||
if (!tryGettingSessionFromPropertyName(
|
return true;
|
||||||
name, kProfilerStatsTag, &session)) {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<uint8_t> tempValue;
|
return false;
|
||||||
session->ReadAllStats(tempValue);
|
|
||||||
value.appendArray(tempValue.data(), tempValue.size());
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t WVDrmPlugin::getPropertyByteArray(const String8& name,
|
status_t WVDrmPlugin::getPropertyByteArray(const String8& name,
|
||||||
|
|||||||
Reference in New Issue
Block a user