Merge Tweaks Originating in Merge Review Comments
This merges several small changes that were made in response to comments that arose when LMP changes were merged into the Widevine repository's master branch. Change-Id: Ifec968af54dbc3288f24654ec0c6ca9b5962e1aa
This commit is contained in:
@@ -142,7 +142,7 @@ class CdmEngine {
|
||||
|
||||
// We assume that the WvCdmEventListener is asynchronous -- i.e. an event
|
||||
// should be dispatched to another thread which actually does the work. In
|
||||
// particular, if a syncrhonous listener calls OpenSession or CloseSession,
|
||||
// particular, if a synchronous listener calls OpenSession or CloseSession,
|
||||
// the thread will dead lock.
|
||||
// Returns false if listener already attached.
|
||||
virtual bool AttachEventListener(const CdmSessionId& session_id,
|
||||
|
||||
@@ -134,7 +134,7 @@ class CdmSession {
|
||||
|
||||
// decryption and usage flags
|
||||
bool is_initial_decryption_;
|
||||
bool has_decrypted_recently_;
|
||||
bool has_decrypted_since_last_report_; // ... last report to policy engine.
|
||||
bool is_initial_usage_update_;
|
||||
bool is_usage_update_needed_;
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ class WvCdmEngineTest;
|
||||
|
||||
class InitializationData {
|
||||
public:
|
||||
InitializationData(const std::string& type,
|
||||
InitializationData(const std::string& type = std::string(),
|
||||
const CdmInitData& data = CdmInitData());
|
||||
|
||||
bool is_supported() const { return is_cenc_ || is_webm_; }
|
||||
|
||||
@@ -74,11 +74,12 @@ class MaxResEngine {
|
||||
|
||||
bool can_decrypt_;
|
||||
|
||||
scoped_ptr<CryptoSession::OemCryptoHdcpVersion> default_hdcp_level_;
|
||||
CryptoSession::OemCryptoHdcpVersion default_hdcp_level_;
|
||||
ConstraintList constraints_;
|
||||
};
|
||||
|
||||
typedef std::map<wvcdm::KeyId, KeyStatus*>::const_iterator KeyIterator;
|
||||
typedef std::map<wvcdm::KeyId,
|
||||
wvcdm::MaxResEngine::KeyStatus*>::const_iterator KeyIterator;
|
||||
|
||||
void Init(CryptoSession* crypto_session, Clock* clock);
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ std::string HexEncode(const uint8_t* bytes, unsigned size);
|
||||
std::string IntToString(int value);
|
||||
std::string UintToString(unsigned int value);
|
||||
int64_t htonll64(int64_t x);
|
||||
int64_t ntohll64(int64_t x);
|
||||
inline int64_t ntohll64(int64_t x) { return htonll64(x); }
|
||||
|
||||
} // namespace wvcdm
|
||||
|
||||
|
||||
@@ -40,9 +40,7 @@ class UsagePropertySet : public CdmClientPropertySet {
|
||||
virtual const std::string& service_certificate() const { return empty_; }
|
||||
virtual bool is_session_sharing_enabled() const { return false; }
|
||||
virtual uint32_t session_sharing_id() const { return 0; }
|
||||
virtual void set_session_sharing_id(uint32_t id) {
|
||||
id; // noop to suppress warning
|
||||
}
|
||||
virtual void set_session_sharing_id(uint32_t /* id */) {}
|
||||
virtual const std::string& app_id() const { return app_id_; }
|
||||
void set_app_id(const std::string& appId) { app_id_ = appId; }
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ void CdmSession::Create(CdmLicense* license_parser,
|
||||
is_initial_usage_update_ = true;
|
||||
is_usage_update_needed_ = false;
|
||||
is_initial_decryption_ = true;
|
||||
has_decrypted_recently_ = false;
|
||||
has_decrypted_since_last_report_ = false;
|
||||
if (cdm_client_property_set) {
|
||||
Properties::AddSessionPropertySet(session_id_, cdm_client_property_set);
|
||||
}
|
||||
@@ -340,6 +340,8 @@ CdmResponseType CdmSession::Decrypt(const CdmDecryptionParameters& params) {
|
||||
if (crypto_session_.get() == NULL || !crypto_session_->IsOpen())
|
||||
return UNKNOWN_ERROR;
|
||||
|
||||
// Playback may not begin until either the start time passes or the license
|
||||
// is updated, so we treat this Decrypt call as invalid and return KEY_ERROR.
|
||||
if (params.is_encrypted && !policy_engine_->CanDecrypt(*params.key_id)) {
|
||||
return policy_engine_->IsLicenseForFuture() ? KEY_ERROR : NEED_KEY;
|
||||
}
|
||||
@@ -352,7 +354,7 @@ CdmResponseType CdmSession::Decrypt(const CdmDecryptionParameters& params) {
|
||||
policy_engine_->BeginDecryption();
|
||||
is_initial_decryption_ = false;
|
||||
}
|
||||
has_decrypted_recently_ = true;
|
||||
has_decrypted_since_last_report_ = true;
|
||||
if (!is_usage_update_needed_) {
|
||||
is_usage_update_needed_ =
|
||||
!license_parser_->provider_session_token().empty();
|
||||
@@ -368,9 +370,6 @@ CdmResponseType CdmSession::Decrypt(const CdmDecryptionParameters& params) {
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: { //Ignore
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return status;
|
||||
@@ -557,9 +556,9 @@ void CdmSession::OnTimerEvent(bool update_usage) {
|
||||
bool event_occurred = false;
|
||||
CdmEventType event;
|
||||
|
||||
if (update_usage && has_decrypted_recently_) {
|
||||
if (update_usage && has_decrypted_since_last_report_) {
|
||||
policy_engine_->DecryptionEvent();
|
||||
has_decrypted_recently_ = false;
|
||||
has_decrypted_since_last_report_ = false;
|
||||
if (is_offline_ && !is_release_) {
|
||||
StoreLicense(DeviceFiles::kLicenseStateActive);
|
||||
}
|
||||
|
||||
@@ -14,12 +14,11 @@ const uint32_t kNoResolution = 0;
|
||||
|
||||
namespace wvcdm {
|
||||
|
||||
MaxResEngine::MaxResEngine(CryptoSession* crypto_session) : status_lock_() {
|
||||
MaxResEngine::MaxResEngine(CryptoSession* crypto_session) {
|
||||
Init(crypto_session, new Clock());
|
||||
}
|
||||
|
||||
MaxResEngine::MaxResEngine(CryptoSession* crypto_session, Clock* clock)
|
||||
: status_lock_() {
|
||||
MaxResEngine::MaxResEngine(CryptoSession* crypto_session, Clock* clock) {
|
||||
Init(crypto_session, clock);
|
||||
}
|
||||
|
||||
@@ -51,8 +50,8 @@ void MaxResEngine::SetLicense(
|
||||
const video_widevine_server::sdk::License& license) {
|
||||
AutoLock lock(status_lock_);
|
||||
DeleteAllKeys();
|
||||
for (int32_t key_iter = 0; key_iter < license.key_size(); ++key_iter) {
|
||||
const KeyContainer& key = license.key(key_iter);
|
||||
for (int32_t key_index = 0; key_index < license.key_size(); ++key_index) {
|
||||
const KeyContainer& key = license.key(key_index);
|
||||
if (key.type() == KeyContainer::CONTENT && key.has_id() &&
|
||||
key.video_resolution_constraints_size() > 0) {
|
||||
const ConstraintList& constraints = key.video_resolution_constraints();
|
||||
@@ -96,15 +95,14 @@ void MaxResEngine::DeleteAllKeys() {
|
||||
}
|
||||
|
||||
MaxResEngine::KeyStatus::KeyStatus(const ConstraintList& constraints)
|
||||
: default_hdcp_level_(NULL) {
|
||||
: default_hdcp_level_(CryptoSession::kOemCryptoHdcpNotSupported) {
|
||||
Init(constraints);
|
||||
}
|
||||
|
||||
MaxResEngine::KeyStatus::KeyStatus(
|
||||
const ConstraintList& constraints,
|
||||
const OutputProtection::HDCP& default_hdcp_level) {
|
||||
default_hdcp_level_.reset(new CryptoSession::OemCryptoHdcpVersion(
|
||||
ProtobufHdcpToOemCryptoHdcp(default_hdcp_level)));
|
||||
const OutputProtection::HDCP& default_hdcp_level)
|
||||
: default_hdcp_level_(ProtobufHdcpToOemCryptoHdcp(default_hdcp_level)) {
|
||||
Init(constraints);
|
||||
}
|
||||
|
||||
@@ -127,14 +125,9 @@ void MaxResEngine::KeyStatus::Update(
|
||||
if (current_constraint->has_required_protection()) {
|
||||
desired_hdcp_level = ProtobufHdcpToOemCryptoHdcp(
|
||||
current_constraint->required_protection().hdcp());
|
||||
} else if (default_hdcp_level_.get() != NULL) {
|
||||
desired_hdcp_level = *default_hdcp_level_;
|
||||
} else {
|
||||
// No constraint value and no default means there's nothing to enforce.
|
||||
can_decrypt_ = true;
|
||||
return;
|
||||
desired_hdcp_level = default_hdcp_level_;
|
||||
}
|
||||
|
||||
can_decrypt_ = (current_hdcp_level >= desired_hdcp_level);
|
||||
}
|
||||
|
||||
|
||||
@@ -185,21 +185,4 @@ int64_t htonll64(int64_t x) { // Convert to big endian (network-byte-order)
|
||||
}
|
||||
}
|
||||
|
||||
int64_t ntohll64(int64_t x) { // Convert from big endian (network-byte-order)
|
||||
union {
|
||||
uint32_t array[2];
|
||||
int64_t number;
|
||||
} mixed;
|
||||
mixed.number = 1;
|
||||
if (mixed.array[0] == 1) { // Little Endian.
|
||||
mixed.number = x;
|
||||
uint32_t temp = mixed.array[0];
|
||||
mixed.array[0] = ntohl(mixed.array[1]);
|
||||
mixed.array[1] = ntohl(temp);
|
||||
return mixed.number;
|
||||
} else { // Big Endian.
|
||||
return x;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace wvcdm
|
||||
|
||||
@@ -1098,8 +1098,7 @@ TEST_P(WvCdmStreamingUsageReportTest, UsageTest) {
|
||||
uint32_t num_usage_info = 0;
|
||||
CdmUsageInfo usage_info;
|
||||
CdmUsageInfoReleaseMessage release_msg;
|
||||
std::string app_id;
|
||||
CdmResponseType status = decryptor_.GetUsageInfo(app_id, &usage_info);
|
||||
CdmResponseType status = decryptor_.GetUsageInfo("", &usage_info);
|
||||
EXPECT_EQ(usage_info.empty() ? NO_ERROR : KEY_MESSAGE, status);
|
||||
while (usage_info.size() > 0) {
|
||||
for (size_t i = 0; i < usage_info.size(); ++i) {
|
||||
@@ -1111,7 +1110,7 @@ TEST_P(WvCdmStreamingUsageReportTest, UsageTest) {
|
||||
GetUsageInfoResponse(g_license_server, g_client_auth, usage_info[i]);
|
||||
EXPECT_EQ(NO_ERROR, decryptor_.ReleaseUsageInfo(release_msg));
|
||||
}
|
||||
status = decryptor_.GetUsageInfo(app_id, &usage_info);
|
||||
status = decryptor_.GetUsageInfo("", &usage_info);
|
||||
switch (status) {
|
||||
case KEY_MESSAGE:
|
||||
EXPECT_FALSE(usage_info.empty());
|
||||
|
||||
@@ -1559,9 +1559,16 @@ TEST_F(WvCdmRequestLicenseTest, SecurityLevelPathBackwardCompatibility) {
|
||||
TestWvCdmClientPropertySet property_set;
|
||||
property_set.set_security_level(QUERY_VALUE_SECURITY_LEVEL_L3);
|
||||
|
||||
EXPECT_EQ(wvcdm::NEED_PROVISIONING,
|
||||
EXPECT_EQ(NO_ERROR,
|
||||
decryptor_.OpenSession(g_key_system, &property_set, &session_id_));
|
||||
|
||||
wvcdm::CdmAppParameterMap app_parameters;
|
||||
std::string server_url;
|
||||
EXPECT_EQ(wvcdm::NEED_PROVISIONING,
|
||||
decryptor_.GenerateKeyRequest(session_id_, key_set_id, "video/mp4",
|
||||
key_id, kLicenseTypeStreaming,
|
||||
app_parameters, NULL, &key_msg_,
|
||||
&server_url));
|
||||
EXPECT_EQ(NO_ERROR, decryptor_.GetProvisioningRequest(
|
||||
cert_type, cert_authority, &key_msg_,
|
||||
&provisioning_server_url));
|
||||
|
||||
Reference in New Issue
Block a user