Merge of usage reporting and license changes from WV CDM repo

* CdmSession unittest and license request time changes
  b/15914199
  Merge of https://widevine-internal-review.googlesource.com/#/c/10597/

* Specify OEMCrypto API version in client capabilities
  b/15388863
  Merge of https://widevine-internal-review.googlesource.com/#/c/10616/

* Report start and last play time in license request
  b/15995227
  Merge of https://widevine-internal-review.googlesource.com/#/c/10617/

* Respect can_play flag
  b/15330338
  Merge of https://widevine-internal-review.googlesource.com/#/c/10619/

* Restore offline session information
  b/16009274
  Merge of https://widevine-internal-review.googlesource.com/#/c/10641/

Change-Id: I17fdc309efbc1d44385a86a368df11b1349b29c2
This commit is contained in:
Rahul Frias
2014-07-02 13:03:09 -07:00
parent 9b4da994ec
commit 7a933ee48e
18 changed files with 1308 additions and 692 deletions

View File

@@ -55,8 +55,13 @@ bool Hash(const std::string& data, std::string* hash) {
namespace wvcdm {
DeviceFiles::DeviceFiles()
: file_(NULL), security_level_(kSecurityLevelUninitialized),
initialized_(false), test_file_(false) {
}
DeviceFiles::~DeviceFiles() {
if (!file_ && !test_file_) delete file_;
if (test_file_) file_.release();
}
bool DeviceFiles::Init(CdmSecurityLevel security_level) {
@@ -69,7 +74,7 @@ bool DeviceFiles::Init(CdmSecurityLevel security_level) {
LOGW("DeviceFiles::Init: Unsupported security level %d", security_level);
return false;
}
file_ = new File();
if (!test_file_) file_.reset(new File());
security_level_ = security_level;
initialized_ = true;
return true;
@@ -148,7 +153,9 @@ bool DeviceFiles::StoreLicense(const std::string& key_set_id,
const CdmKeyResponse& license_message,
const CdmKeyMessage& license_renewal_request,
const CdmKeyResponse& license_renewal,
const std::string& release_server_url) {
const std::string& release_server_url,
int64_t playback_start_time,
int64_t last_playback_time) {
if (!initialized_) {
LOGW("DeviceFiles::StoreLicense: not initialized");
return false;
@@ -179,6 +186,8 @@ bool DeviceFiles::StoreLicense(const std::string& key_set_id,
license->set_renewal_request(license_renewal_request);
license->set_renewal(license_renewal);
license->set_release_server_url(release_server_url);
license->set_playback_start_time(playback_start_time);
license->set_last_playback_time(last_playback_time);
std::string serialized_file;
file.SerializeToString(&serialized_file);
@@ -193,7 +202,9 @@ bool DeviceFiles::RetrieveLicense(const std::string& key_set_id,
CdmKeyResponse* license_message,
CdmKeyMessage* license_renewal_request,
CdmKeyResponse* license_renewal,
std::string* release_server_url) {
std::string* release_server_url,
int64_t* playback_start_time,
int64_t* last_playback_time) {
if (!initialized_) {
LOGW("DeviceFiles::RetrieveLicense: not initialized");
return false;
@@ -245,6 +256,8 @@ bool DeviceFiles::RetrieveLicense(const std::string& key_set_id,
*license_renewal_request = license.renewal_request();
*license_renewal = license.renewal();
*release_server_url = license.release_server_url();
*playback_start_time = license.playback_start_time();
*last_playback_time = license.last_playback_time();
return true;
}
@@ -454,7 +467,7 @@ bool DeviceFiles::RetrieveUsageInfo(std::vector<
bool DeviceFiles::StoreFile(const char* name,
const std::string& serialized_file) {
if (!file_) {
if (!file_.get()) {
LOGW("DeviceFiles::StoreFile: Invalid file handle");
return false;
}
@@ -514,7 +527,7 @@ bool DeviceFiles::StoreFile(const char* name,
}
bool DeviceFiles::RetrieveFile(const char* name, std::string* serialized_file) {
if (!file_) {
if (!file_.get()) {
LOGW("DeviceFiles::RetrieveFile: Invalid file handle");
return false;
}
@@ -663,8 +676,7 @@ std::string DeviceFiles::GetUsageInfoFileName() {
}
void DeviceFiles::SetTestFile(File* file) {
if (file_) delete file_;
file_ = file;
file_.reset(file);
test_file_ = true;
}