Merge changes I6d7b5bfb,Ib9041d39

* changes:
  Add License::Policy::play_start_grace_period_seconds
  Update CDM to newest license protocol definitions.
This commit is contained in:
Rahul Frias
2017-01-20 23:02:05 +00:00
committed by Android (Google) Code Review
21 changed files with 623 additions and 345 deletions

View File

@@ -188,10 +188,11 @@ using ::testing::StrNe;
namespace wvcdm {
// Protobuf generated classes
using video_widevine_server::sdk::LicenseIdentification;
using video_widevine_server::sdk::LicenseRequest_ContentIdentification;
using video_widevine_server::sdk::ClientIdentification;
using video_widevine_server::sdk::SignedMessage;
using video_widevine::LicenseIdentification;
using video_widevine::LicenseRequest_ContentIdentification;
using video_widevine::LicenseRequest_ContentIdentification_CencDeprecated;
using video_widevine::ClientIdentification;
using video_widevine::SignedMessage;
class TestWvCdmClientPropertySet : public CdmClientPropertySet {
public:
@@ -460,7 +461,7 @@ class WvCdmExtendedDurationTest : public WvCdmTestBase {
return;
}
void ValidateResponse(video_widevine_server::sdk::LicenseType license_type,
void ValidateResponse(video_widevine::LicenseType license_type,
bool has_provider_session_token) {
// Validate signed response
SignedMessage signed_message;
@@ -470,7 +471,7 @@ class WvCdmExtendedDurationTest : public WvCdmTestBase {
EXPECT_TRUE(!signed_message.msg().empty());
// Verify license
video_widevine_server::sdk::License license;
video_widevine::License license;
EXPECT_TRUE(license.ParseFromString(signed_message.msg()));
// Verify license identification
@@ -491,18 +492,18 @@ class WvCdmExtendedDurationTest : public WvCdmTestBase {
EXPECT_TRUE(!signed_message.msg().empty());
// Verify license request
video_widevine_server::sdk::LicenseRequest license_renewal;
video_widevine::LicenseRequest license_renewal;
EXPECT_TRUE(license_renewal.ParseFromString(signed_message.msg()));
// Verify Content Identification
const LicenseRequest_ContentIdentification& content_id =
license_renewal.content_id();
EXPECT_FALSE(content_id.has_cenc_id());
EXPECT_FALSE(content_id.has_webm_id());
EXPECT_TRUE(content_id.has_license());
EXPECT_FALSE(content_id.has_cenc_id_deprecated());
EXPECT_FALSE(content_id.has_webm_id_deprecated());
EXPECT_TRUE(content_id.has_existing_license());
const LicenseRequest_ContentIdentification::ExistingLicense&
existing_license = content_id.license();
existing_license = content_id.existing_license();
const LicenseIdentification& id = existing_license.license_id();
EXPECT_EQ(license_id_.request_id(), id.request_id());
@@ -518,10 +519,10 @@ class WvCdmExtendedDurationTest : public WvCdmTestBase {
expected_seconds_since_last_played, kClockTolerance);
EXPECT_TRUE(existing_license.session_usage_table_entry().empty());
EXPECT_EQ(::video_widevine_server::sdk::LicenseRequest_RequestType_RENEWAL,
EXPECT_EQ(::video_widevine::LicenseRequest_RequestType_RENEWAL,
license_renewal.type());
EXPECT_LT(0, license_renewal.request_time());
EXPECT_EQ(video_widevine_server::sdk::VERSION_2_1,
EXPECT_EQ(video_widevine::VERSION_2_1,
license_renewal.protocol_version());
EXPECT_TRUE(license_renewal.has_key_control_nonce());
}
@@ -538,18 +539,18 @@ class WvCdmExtendedDurationTest : public WvCdmTestBase {
EXPECT_TRUE(!signed_message.msg().empty());
// Verify license request
video_widevine_server::sdk::LicenseRequest license_renewal;
video_widevine::LicenseRequest license_renewal;
EXPECT_TRUE(license_renewal.ParseFromString(signed_message.msg()));
// Verify Content Identification
const LicenseRequest_ContentIdentification& content_id =
license_renewal.content_id();
EXPECT_FALSE(content_id.has_cenc_id());
EXPECT_FALSE(content_id.has_webm_id());
EXPECT_TRUE(content_id.has_license());
EXPECT_FALSE(content_id.has_cenc_id_deprecated());
EXPECT_FALSE(content_id.has_webm_id_deprecated());
EXPECT_TRUE(content_id.has_existing_license());
const LicenseRequest_ContentIdentification::ExistingLicense&
existing_license = content_id.license();
existing_license = content_id.existing_license();
const LicenseIdentification& id = existing_license.license_id();
EXPECT_EQ(license_id_.request_id(), id.request_id());
@@ -598,10 +599,10 @@ class WvCdmExtendedDurationTest : public WvCdmTestBase {
EXPECT_NEAR(seconds_since_last_decrypt,
expected_seconds_since_last_playback, kClockTolerance);
EXPECT_EQ(::video_widevine_server::sdk::LicenseRequest_RequestType_RELEASE,
EXPECT_EQ(::video_widevine::LicenseRequest_RequestType_RELEASE,
license_renewal.type());
EXPECT_LT(0, license_renewal.request_time());
EXPECT_EQ(video_widevine_server::sdk::VERSION_2_1,
EXPECT_EQ(video_widevine::VERSION_2_1,
license_renewal.protocol_version());
EXPECT_TRUE(license_renewal.has_key_control_nonce());
}
@@ -678,7 +679,7 @@ class WvCdmExtendedDurationTest : public WvCdmTestBase {
CdmKeyResponse key_response_;
CdmSessionId session_id_;
CdmKeySetId key_set_id_;
video_widevine_server::sdk::LicenseIdentification license_id_;
video_widevine::LicenseIdentification license_id_;
};
TEST_F(WvCdmExtendedDurationTest, VerifyLicenseRequestTest) {
@@ -696,18 +697,18 @@ TEST_F(WvCdmExtendedDurationTest, VerifyLicenseRequestTest) {
EXPECT_TRUE(!signed_message.msg().empty());
// Verify license request
video_widevine_server::sdk::LicenseRequest license_request;
video_widevine::LicenseRequest license_request;
EXPECT_TRUE(license_request.ParseFromString(signed_message.msg()));
// Verify Client Identification
const ClientIdentification& client_id = license_request.client_id();
EXPECT_EQ(video_widevine_server::sdk::
ClientIdentification_TokenType_DEVICE_CERTIFICATE,
EXPECT_EQ(video_widevine::
ClientIdentification_TokenType_DRM_DEVICE_CERTIFICATE,
client_id.type());
EXPECT_LT(0, client_id.client_info_size());
for (int i = 0; i < client_id.client_info_size(); ++i) {
const ::video_widevine_server::sdk::ClientIdentification_NameValue&
const ::video_widevine::ClientIdentification_NameValue&
name_value = client_id.client_info(i);
EXPECT_TRUE(!name_value.name().empty());
EXPECT_TRUE(!name_value.value().empty());
@@ -727,22 +728,22 @@ TEST_F(WvCdmExtendedDurationTest, VerifyLicenseRequestTest) {
// Verify Content Identification
const LicenseRequest_ContentIdentification& content_id =
license_request.content_id();
EXPECT_TRUE(content_id.has_cenc_id());
EXPECT_FALSE(content_id.has_webm_id());
EXPECT_FALSE(content_id.has_license());
EXPECT_TRUE(content_id.has_cenc_id_deprecated());
EXPECT_FALSE(content_id.has_webm_id_deprecated());
EXPECT_FALSE(content_id.has_existing_license());
const LicenseRequest_ContentIdentification::CENC& cenc_id =
content_id.cenc_id();
const LicenseRequest_ContentIdentification_CencDeprecated& cenc_id =
content_id.cenc_id_deprecated();
EXPECT_TRUE(std::equal(cenc_id.pssh(0).begin(), cenc_id.pssh(0).end(),
g_key_id.begin() + 32));
EXPECT_EQ(video_widevine_server::sdk::STREAMING, cenc_id.license_type());
EXPECT_EQ(video_widevine::STREAMING, cenc_id.license_type());
EXPECT_TRUE(cenc_id.has_request_id());
// Verify other license request fields
EXPECT_EQ(::video_widevine_server::sdk::LicenseRequest_RequestType_NEW,
EXPECT_EQ(::video_widevine::LicenseRequest_RequestType_NEW,
license_request.type());
EXPECT_LT(0, license_request.request_time());
EXPECT_EQ(video_widevine_server::sdk::VERSION_2_1,
EXPECT_EQ(video_widevine::VERSION_2_1,
license_request.protocol_version());
EXPECT_TRUE(license_request.has_key_control_nonce());
@@ -763,14 +764,14 @@ TEST_F(WvCdmExtendedDurationTest, VerifyLicenseRenewalTest) {
EXPECT_TRUE(!signed_message.msg().empty());
// Verify license
video_widevine_server::sdk::License license;
video_widevine::License license;
EXPECT_TRUE(license.ParseFromString(signed_message.msg()));
// Verify license identification
video_widevine_server::sdk::LicenseIdentification license_id = license.id();
video_widevine::LicenseIdentification license_id = license.id();
EXPECT_LT(0u, license_id.request_id().size());
EXPECT_LT(0u, license_id.session_id().size());
EXPECT_EQ(video_widevine_server::sdk::STREAMING, license_id.type());
EXPECT_EQ(video_widevine::STREAMING, license_id.type());
EXPECT_FALSE(license_id.has_provider_session_token());
// Create renewal request
@@ -787,7 +788,7 @@ TEST_F(WvCdmExtendedDurationTest, VerifyLicenseRenewalTest) {
EXPECT_TRUE(!signed_message.msg().empty());
// Verify license request
video_widevine_server::sdk::LicenseRequest license_renewal;
video_widevine::LicenseRequest license_renewal;
EXPECT_TRUE(license_renewal.ParseFromString(signed_message.msg()));
// Client Identification not filled in in renewal
@@ -795,12 +796,12 @@ TEST_F(WvCdmExtendedDurationTest, VerifyLicenseRenewalTest) {
// Verify Content Identification
const LicenseRequest_ContentIdentification& content_id =
license_renewal.content_id();
EXPECT_FALSE(content_id.has_cenc_id());
EXPECT_FALSE(content_id.has_webm_id());
EXPECT_TRUE(content_id.has_license());
EXPECT_FALSE(content_id.has_cenc_id_deprecated());
EXPECT_FALSE(content_id.has_webm_id_deprecated());
EXPECT_TRUE(content_id.has_existing_license());
const LicenseRequest_ContentIdentification::ExistingLicense&
existing_license = content_id.license();
existing_license = content_id.existing_license();
const LicenseIdentification& id = existing_license.license_id();
EXPECT_EQ(license_id.request_id(), id.request_id());
@@ -814,10 +815,10 @@ TEST_F(WvCdmExtendedDurationTest, VerifyLicenseRenewalTest) {
EXPECT_EQ(0, existing_license.seconds_since_last_played());
EXPECT_TRUE(existing_license.session_usage_table_entry().empty());
EXPECT_EQ(::video_widevine_server::sdk::LicenseRequest_RequestType_RENEWAL,
EXPECT_EQ(::video_widevine::LicenseRequest_RequestType_RENEWAL,
license_renewal.type());
EXPECT_LT(0, license_renewal.request_time());
EXPECT_EQ(video_widevine_server::sdk::VERSION_2_1,
EXPECT_EQ(video_widevine::VERSION_2_1,
license_renewal.protocol_version());
EXPECT_TRUE(license_renewal.has_key_control_nonce());
@@ -959,7 +960,7 @@ TEST_P(WvCdmStreamingNoPstTest, UsageTest) {
GenerateKeyRequest(g_key_id, kLicenseTypeStreaming);
VerifyKeyRequestResponse(g_license_server, g_client_auth, false);
ValidateResponse(video_widevine_server::sdk::STREAMING, false);
ValidateResponse(video_widevine::STREAMING, false);
int64_t initial_license_duration_remaining = 0;
int64_t initial_playback_duration_remaining = 0;
@@ -1033,7 +1034,7 @@ TEST_P(WvCdmStreamingPstTest, UsageTest) {
GenerateKeyRequest(kStreamingClip1PstInitData, kLicenseTypeStreaming);
VerifyKeyRequestResponse(g_license_server, g_client_auth, false);
ValidateResponse(video_widevine_server::sdk::STREAMING, true);
ValidateResponse(video_widevine::STREAMING, true);
int64_t initial_license_duration_remaining = 0;
int64_t initial_playback_duration_remaining = 0;
@@ -1098,7 +1099,7 @@ TEST_P(WvCdmStreamingUsageReportTest, UsageTest) {
GenerateKeyRequest(kStreamingClip1PstInitData, kLicenseTypeStreaming);
VerifyKeyRequestResponse(g_license_server, g_client_auth, false);
ValidateResponse(video_widevine_server::sdk::STREAMING, true);
ValidateResponse(video_widevine::STREAMING, true);
int64_t initial_license_duration_remaining = 0;
int64_t initial_playback_duration_remaining = 0;
@@ -1194,7 +1195,7 @@ TEST_P(WvCdmOfflineUsageReportTest, UsageTest) {
GenerateKeyRequest(kOfflineClip2PstInitData, kLicenseTypeOffline);
VerifyKeyRequestResponse(g_license_server, g_client_auth, false);
ValidateResponse(video_widevine_server::sdk::OFFLINE, true);
ValidateResponse(video_widevine::OFFLINE, true);
CdmKeySetId key_set_id = key_set_id_;
EXPECT_FALSE(key_set_id_.empty());

View File

@@ -51,8 +51,8 @@ const int kHttpInternalServerError = 500;
const char kOrigin[] = "com.example";
// Protobuf generated classes
using video_widevine_server::sdk::LicenseIdentification;
using video_widevine_server::sdk::LicenseRequest_ContentIdentification;
using video_widevine::LicenseIdentification;
using video_widevine::LicenseRequest_ContentIdentification;
// Default license server, can be configured using --server command line option
// Default key id (pssh), can be configured using --keyid command line option
@@ -415,7 +415,7 @@ UsageInfoSubSampleInfo usage_info_sub_sample_info[] = {
{&usage_info_sub_samples_icp[0], 3, wvcdm::kLevel3, "other app id"}};
struct RenewWithClientIdTestConfiguration {
bool renew_with_client_id;
bool always_include_client_id;
bool specify_app_parameters;
bool enable_privacy_mode;
bool specify_service_certificate;
@@ -869,9 +869,9 @@ HlsDecryptionInfo kHlsFourCCBackwardCompatibilityTestVectors[] = {
namespace wvcdm {
// Protobuf generated classes
using video_widevine_server::sdk::ClientIdentification;
using video_widevine_server::sdk::ClientIdentification_NameValue;
using video_widevine_server::sdk::SignedMessage;
using video_widevine::ClientIdentification;
using video_widevine::ClientIdentification_NameValue;
using video_widevine::SignedMessage;
class TestWvCdmClientPropertySet : public CdmClientPropertySet {
public:
@@ -1761,18 +1761,18 @@ TEST_F(WvCdmRequestLicenseTest, ReleaseOfflineKeySessionUsageDisabledTest) {
EXPECT_TRUE(!signed_message.msg().empty());
// Verify license request
video_widevine_server::sdk::LicenseRequest license_renewal;
video_widevine::LicenseRequest license_renewal;
EXPECT_TRUE(license_renewal.ParseFromString(signed_message.msg()));
// Verify Content Identification
const LicenseRequest_ContentIdentification& content_id =
license_renewal.content_id();
EXPECT_FALSE(content_id.has_cenc_id());
EXPECT_FALSE(content_id.has_webm_id());
EXPECT_TRUE(content_id.has_license());
EXPECT_FALSE(content_id.has_cenc_id_deprecated());
EXPECT_FALSE(content_id.has_webm_id_deprecated());
EXPECT_TRUE(content_id.has_existing_license());
const LicenseRequest_ContentIdentification::ExistingLicense&
existing_license = content_id.license();
existing_license = content_id.existing_license();
EXPECT_TRUE(existing_license.license_id().provider_session_token().empty());
EXPECT_TRUE(existing_license.session_usage_table_entry().empty());
}
@@ -2055,7 +2055,7 @@ class WvCdmStreamingLicenseRenewalTest
TEST_P(WvCdmStreamingLicenseRenewalTest, WithClientId) {
RenewWithClientIdTestConfiguration* config = GetParam();
std::string key_id;
if (config->renew_with_client_id) {
if (config->always_include_client_id) {
key_id = a2bs_hex(
"000000427073736800000000" // blob size and pssh
"EDEF8BA979D64ACEA3C827DCD51D21ED00000022" // Widevine system id
@@ -2105,13 +2105,13 @@ TEST_P(WvCdmStreamingLicenseRenewalTest, WithClientId) {
EXPECT_TRUE(!signed_message.msg().empty()) << config->test_description;
// Verify license request
video_widevine_server::sdk::License license;
video_widevine::License license;
EXPECT_TRUE(license.ParseFromString(signed_message.msg()))
<< config->test_description;
// Verify renew_with_client_id
EXPECT_EQ(config->renew_with_client_id,
license.policy().has_renew_with_client_id());
// Verify always_include_client_id
EXPECT_EQ(config->always_include_client_id,
license.policy().has_always_include_client_id());
std::string license_server;
CdmKeyMessage key_msg;
@@ -2127,12 +2127,12 @@ TEST_P(WvCdmStreamingLicenseRenewalTest, WithClientId) {
EXPECT_TRUE(!signed_message.msg().empty()) << config->test_description;
// Verify license request
video_widevine_server::sdk::LicenseRequest license_renewal;
video_widevine::LicenseRequest license_renewal;
EXPECT_TRUE(license_renewal.ParseFromString(signed_message.msg()))
<< config->test_description;
// Verify ClientId
EXPECT_EQ(config->renew_with_client_id && !config->enable_privacy_mode,
EXPECT_EQ(config->always_include_client_id && !config->enable_privacy_mode,
license_renewal.has_client_id())
<< config->test_description;
@@ -2153,7 +2153,7 @@ TEST_P(WvCdmStreamingLicenseRenewalTest, WithClientId) {
}
if (config->enable_privacy_mode) {
EXPECT_EQ(config->renew_with_client_id,
EXPECT_EQ(config->always_include_client_id,
license_renewal.has_encrypted_client_id())
<< config->test_description;
EXPECT_NE(
@@ -2183,7 +2183,7 @@ TEST_P(WvCdmOfflineLicenseReleaseTest, WithClientId) {
std::string client_auth;
GetOfflineConfiguration(&key_id, &client_auth);
if (config->renew_with_client_id) {
if (config->always_include_client_id) {
key_id = a2bs_hex(
"00000040" // blob size
"70737368" // "pssh"
@@ -2233,13 +2233,13 @@ TEST_P(WvCdmOfflineLicenseReleaseTest, WithClientId) {
EXPECT_TRUE(!signed_message.msg().empty()) << config->test_description;
// Verify license request
video_widevine_server::sdk::License license;
video_widevine::License license;
EXPECT_TRUE(license.ParseFromString(signed_message.msg()))
<< config->test_description;
// Verify renew_with_client_id
EXPECT_EQ(config->renew_with_client_id,
license.policy().has_renew_with_client_id());
// Verify always_include_client_id
EXPECT_EQ(config->always_include_client_id,
license.policy().has_always_include_client_id());
CdmKeySetId key_set_id = key_set_id_;
EXPECT_TRUE(key_set_id_.size() > 0);
@@ -2268,12 +2268,12 @@ TEST_P(WvCdmOfflineLicenseReleaseTest, WithClientId) {
EXPECT_TRUE(!signed_message.msg().empty()) << config->test_description;
// Verify license request
video_widevine_server::sdk::LicenseRequest license_release;
video_widevine::LicenseRequest license_release;
EXPECT_TRUE(license_release.ParseFromString(signed_message.msg()))
<< config->test_description;
// Verify ClientId
EXPECT_EQ(config->renew_with_client_id && !config->enable_privacy_mode,
EXPECT_EQ(config->always_include_client_id && !config->enable_privacy_mode,
license_release.has_client_id())
<< config->test_description;
@@ -2294,7 +2294,7 @@ TEST_P(WvCdmOfflineLicenseReleaseTest, WithClientId) {
}
if (config->enable_privacy_mode) {
EXPECT_EQ(config->renew_with_client_id,
EXPECT_EQ(config->always_include_client_id,
license_release.has_encrypted_client_id())
<< config->test_description;
EXPECT_NE(
@@ -2330,7 +2330,7 @@ TEST_P(WvCdmUsageTest, WithClientId) {
RenewWithClientIdTestConfiguration* config = GetParam();
std::string key_id;
if (config->renew_with_client_id) {
if (config->always_include_client_id) {
key_id = a2bs_hex( // streaming_clip20
"000000427073736800000000" // blob size and pssh
"EDEF8BA979D64ACEA3C827DCD51D21ED00000023" // Widevine system id
@@ -2367,13 +2367,13 @@ TEST_P(WvCdmUsageTest, WithClientId) {
EXPECT_TRUE(!signed_message.msg().empty()) << config->test_description;
// Verify license request
video_widevine_server::sdk::License license;
video_widevine::License license;
EXPECT_TRUE(license.ParseFromString(signed_message.msg()))
<< config->test_description;
// Verify renew_with_client_id
EXPECT_EQ(config->renew_with_client_id,
license.policy().has_renew_with_client_id());
// Verify always_include_client_id
EXPECT_EQ(config->always_include_client_id,
license.policy().has_always_include_client_id());
EXPECT_FALSE(license.id().provider_session_token().empty());
@@ -2406,17 +2406,17 @@ TEST_P(WvCdmUsageTest, WithClientId) {
EXPECT_TRUE(!signed_message.msg().empty()) << config->test_description;
// Verify license request
video_widevine_server::sdk::LicenseRequest license_renewal;
video_widevine::LicenseRequest license_renewal;
EXPECT_TRUE(license_renewal.ParseFromString(signed_message.msg()))
<< config->test_description;
// Verify ClientId
EXPECT_EQ(config->renew_with_client_id && !config->enable_privacy_mode,
EXPECT_EQ(config->always_include_client_id && !config->enable_privacy_mode,
license_renewal.has_client_id())
<< config->test_description;
if (config->enable_privacy_mode) {
EXPECT_EQ(config->renew_with_client_id,
EXPECT_EQ(config->always_include_client_id,
license_renewal.has_encrypted_client_id())
<< config->test_description;
EXPECT_NE(