New CdmResponseType fields: oec_result & crypto_session_method

[ Merge of go/wvgerrit/163437 ]

Bug: 253271674
Test: cdm unit tests
Change-Id: I064e28af593e4a55c13d03115bb5181a879a1ed4
This commit is contained in:
Robert Shih
2022-12-11 10:16:37 -08:00
parent adf20ed758
commit 2384efde1e
5 changed files with 124 additions and 94 deletions

View File

@@ -12,6 +12,8 @@
#include <string>
#include <vector>
#include "OEMCryptoCENC.h"
namespace wvcdm {
using CdmKeySystem = std::string;
@@ -448,27 +450,44 @@ enum CdmResponseEnum : int32_t {
};
struct CdmResponseType {
CdmResponseType() : status_(NO_ERROR){};
explicit CdmResponseType(CdmResponseEnum status) : status_(status){};
explicit CdmResponseType(CdmResponseEnum status = NO_ERROR,
OEMCryptoResult oec_result = OEMCrypto_SUCCESS,
const char* crypto_session_method = nullptr)
: status_(status),
oec_result_(oec_result),
crypto_session_method_(crypto_session_method){};
explicit operator CdmResponseEnum() const { return status_; };
explicit operator std::string() {
std::string str = "status = ";
str.append(std::to_string(static_cast<int>(status_)));
if (oec_result_) {
str.append("; oec_result = ");
str.append(std::to_string(static_cast<int>(oec_result_)));
}
if (crypto_session_method_) {
str.append("; crypto_session_method = ");
str.append(crypto_session_method_);
}
return str;
}
CdmResponseEnum Enum() const { return status_; };
constexpr explicit operator int() const { return status_; };
OEMCryptoResult getOEMCryptoResult() const { return oec_result_; }
const char* getCryptoSessionMethod() const { return crypto_session_method_; }
bool operator==(CdmResponseEnum other) const { return status_ == other; }
bool operator!=(CdmResponseEnum other) const { return status_ != other; }
bool operator==(const CdmResponseType& other) const {
return status_ == other.Enum();
return status_ == other.status_ && oec_result_ == other.oec_result_ &&
crypto_session_method_ == other.crypto_session_method_;
}
bool operator!=(const CdmResponseType& other) const {
return status_ != other.Enum();
return !operator==(other);
}
private:
CdmResponseEnum status_;
OEMCryptoResult oec_result_;
const char* crypto_session_method_;
// CORE_DISALLOW_COPY_AND_ASSIGN(CdmResponseType);
};