Source release 14.0.0
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#include <gmock/gmock.h>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "file_store.h"
|
||||
#include "initialization_data.h"
|
||||
#include "license_protocol.pb.h"
|
||||
#include "string_conversions.h"
|
||||
@@ -21,6 +22,9 @@ using video_widevine::WidevinePsshData;
|
||||
|
||||
namespace {
|
||||
|
||||
// Import names from ::testing for convenience
|
||||
using ::testing::_;
|
||||
|
||||
// Constants for JSON formatting
|
||||
const std::string kLeftBrace = "{";
|
||||
const std::string kRightBrace = "}";
|
||||
@@ -128,7 +132,7 @@ const std::string kWidevinePsshAfterV1Pssh = a2bs_hex(
|
||||
|
||||
const std::string kWidevineV1Pssh = a2bs_hex(
|
||||
// Widevine PSSH box, v1 format
|
||||
"00000044" // atom size
|
||||
"00000066" // atom size
|
||||
"70737368" // atom type "pssh"
|
||||
"01000000" // v1, flags=0
|
||||
"edef8ba979d64acea3c827dcd51d21ed" // system id (Widevine)
|
||||
@@ -166,7 +170,7 @@ const std::string kZeroSizedPsshBox = a2bs_hex(
|
||||
|
||||
const std::string kSubLicensePsshBox = a2bs_hex(
|
||||
// Widevine PSSH box
|
||||
"0000009f" // atom size (whole buffer)
|
||||
"0000009f" // atom size
|
||||
"70737368" // atom type="pssh"
|
||||
"00000000" // v0, flags=0
|
||||
"edef8ba979d64acea3c827dcd51d21ed" // system id (Widevine)
|
||||
@@ -177,6 +181,93 @@ const std::string kSubLicensePsshBox = a2bs_hex(
|
||||
"5f69645f30120d7375625f6c6963656e73655f305a250a147375625f73657373696f"
|
||||
"6e5f6b65795f69645f31120d7375625f6c6963656e73655f31");
|
||||
|
||||
const std::string kMultipleWidevinePsshBox = a2bs_hex(
|
||||
// first PSSH box, Widevine with single keys
|
||||
"00000042" // atom size
|
||||
"70737368" // atom type "pssh"
|
||||
"00000000" // v0, flags=0
|
||||
"edef8ba979d64acea3c827dcd51d21ed" // system id (Widevine)
|
||||
"00000022" // data size
|
||||
// data:
|
||||
"08011a0d7769646576696e655f74657374220f73747265616d696e675f636c697031"
|
||||
|
||||
// second PSSH box, Widevine with entitled keys
|
||||
"000001fb" // atom size
|
||||
"70737368" // atom type="pssh"
|
||||
"00000000" // v0, flags=0
|
||||
"edef8ba979d64acea3c827dcd51d21ed" // system id (Widevine)
|
||||
"000001db" // data size
|
||||
// data:
|
||||
"220b47726f7570563254657374381448"
|
||||
"e3dc959b065002580272580a10668093"
|
||||
"381a8c5be48a0168ce372726ac1210c8"
|
||||
"326486bb5d5c4a958f00b1111afc811a"
|
||||
"20082cd9d3aed3ebe6239d30fbcf0b22"
|
||||
"1d28cbb0360ea1295c2363973346ec00"
|
||||
"512210914781334e864c8eb7f768cf26"
|
||||
"49073872580a10f872d11d5b1052f2bd"
|
||||
"a94e60a0e383021210450897c987a85c"
|
||||
"2e9579f968554a12991a2097e603ceea"
|
||||
"f35ed8cef1029eae7a0a54701e3d6db6"
|
||||
"80e7da1de3b22a8db347fb2210b41c34"
|
||||
"29b7bb96972bbaf6587bc0ddf172580a"
|
||||
"10bac58b9fce9e5929a42a180e529f19"
|
||||
"4712103f11f22988d25659b145ce4854"
|
||||
"3e6b141a20416e22768e5a57b08d155e"
|
||||
"5210d00658056947ff06d626668bceb3"
|
||||
"5eb01c6b57221081fb2ff3fef79d332f"
|
||||
"f98be46233596972580a101261c8036d"
|
||||
"ae5c8caa968858aa0ca9cc12106d583c"
|
||||
"b37c1456519843a81cf49912221a20c2"
|
||||
"1116bb54a226e8d879a4cd41d8879920"
|
||||
"2ae85b80d83b1b4447e5d7fcad6f6a22"
|
||||
"100b27a4c3f44771d2b0c7c34c66af35"
|
||||
"b572580a10ab1c8c259c6b5967991389"
|
||||
"65bff5ac0c1210b5b4473658565d3786"
|
||||
"efaf4b85d8e6e21a203ce6a9085285c2"
|
||||
"ece0b650dc83dd7aa8ac849611a8e3f8"
|
||||
"3c8f389223c0f3621522101946f0c2a3"
|
||||
"d543101cc842bbec2d0b30");
|
||||
// These are the data payloads of the two PSSH boxes in
|
||||
// kMultipleWidevinePsshBox.
|
||||
const CdmInitData kSingleKeyWidevinePsshBoxData = a2bs_hex(
|
||||
"08011a0d7769646576696e655f74657374220f73747265616d696e675f636c697031");
|
||||
const CdmInitData kEntitledKeysWidevinePsshBoxData = a2bs_hex(
|
||||
"220b47726f7570563254657374381448"
|
||||
"e3dc959b065002580272580a10668093"
|
||||
"381a8c5be48a0168ce372726ac1210c8"
|
||||
"326486bb5d5c4a958f00b1111afc811a"
|
||||
"20082cd9d3aed3ebe6239d30fbcf0b22"
|
||||
"1d28cbb0360ea1295c2363973346ec00"
|
||||
"512210914781334e864c8eb7f768cf26"
|
||||
"49073872580a10f872d11d5b1052f2bd"
|
||||
"a94e60a0e383021210450897c987a85c"
|
||||
"2e9579f968554a12991a2097e603ceea"
|
||||
"f35ed8cef1029eae7a0a54701e3d6db6"
|
||||
"80e7da1de3b22a8db347fb2210b41c34"
|
||||
"29b7bb96972bbaf6587bc0ddf172580a"
|
||||
"10bac58b9fce9e5929a42a180e529f19"
|
||||
"4712103f11f22988d25659b145ce4854"
|
||||
"3e6b141a20416e22768e5a57b08d155e"
|
||||
"5210d00658056947ff06d626668bceb3"
|
||||
"5eb01c6b57221081fb2ff3fef79d332f"
|
||||
"f98be46233596972580a101261c8036d"
|
||||
"ae5c8caa968858aa0ca9cc12106d583c"
|
||||
"b37c1456519843a81cf49912221a20c2"
|
||||
"1116bb54a226e8d879a4cd41d8879920"
|
||||
"2ae85b80d83b1b4447e5d7fcad6f6a22"
|
||||
"100b27a4c3f44771d2b0c7c34c66af35"
|
||||
"b572580a10ab1c8c259c6b5967991389"
|
||||
"65bff5ac0c1210b5b4473658565d3786"
|
||||
"efaf4b85d8e6e21a203ce6a9085285c2"
|
||||
"ece0b650dc83dd7aa8ac849611a8e3f8"
|
||||
"3c8f389223c0f3621522101946f0c2a3"
|
||||
"d543101cc842bbec2d0b30");
|
||||
|
||||
// OEMCrypto Versions known to have and not have entitlement license support.
|
||||
const std::string kOemCryptoWithoutEntitlements = "13";
|
||||
const std::string kOemCryptoWithEntitlements = "14";
|
||||
|
||||
// HLS test attribute key and values
|
||||
const std::string kHlsIvHexValue = "6DF49213A781E338628D0E9C812D328E";
|
||||
const std::string kHlsIvValue = "0x" + kHlsIvHexValue;
|
||||
@@ -418,6 +509,7 @@ class HlsInitDataConstructionTest : public ::testing::Test {};
|
||||
class HlsParseTest : public ::testing::TestWithParam<HlsAttributeVariant> {};
|
||||
|
||||
class HlsTest : public ::testing::Test {};
|
||||
|
||||
} // namespace
|
||||
|
||||
TEST_F(InitializationDataTest, BadType) {
|
||||
@@ -435,13 +527,30 @@ INSTANTIATE_TEST_CASE_P(
|
||||
::testing::Values(kWidevinePssh, kWidevinePsshFirst,
|
||||
kWidevinePsshAfterV0Pssh, kWidevinePsshAfterNonZeroFlags,
|
||||
kWidevinePsshAfterV1Pssh, kWidevineV1Pssh, kOtherBoxFirst,
|
||||
kZeroSizedPsshBox, kSubLicensePsshBox));
|
||||
kZeroSizedPsshBox, kSubLicensePsshBox,
|
||||
kMultipleWidevinePsshBox));
|
||||
|
||||
TEST_F(InitializationDataTest, ExtractSubLicense) {
|
||||
TEST_F(InitializationDataTest, HandlesMultipleWidevinePsshs) {
|
||||
InitializationData single_init_data(ISO_BMFF_VIDEO_MIME_TYPE,
|
||||
kMultipleWidevinePsshBox,
|
||||
kOemCryptoWithoutEntitlements);
|
||||
EXPECT_FALSE(single_init_data.IsEmpty());
|
||||
EXPECT_EQ(kSingleKeyWidevinePsshBoxData, single_init_data.data());
|
||||
|
||||
InitializationData entitled_init_data(ISO_BMFF_VIDEO_MIME_TYPE,
|
||||
kMultipleWidevinePsshBox,
|
||||
kOemCryptoWithEntitlements);
|
||||
EXPECT_FALSE(entitled_init_data.IsEmpty());
|
||||
EXPECT_EQ(kEntitledKeysWidevinePsshBoxData, entitled_init_data.data());
|
||||
}
|
||||
|
||||
// TODO(jfore): The pssh has changed in ways that are not compatible with
|
||||
//sublicenses. Restructure or remove sublicense support including this test.
|
||||
TEST_F(InitializationDataTest, DISABLED_ExtractSubLicense) {
|
||||
InitializationData init_data(ISO_BMFF_VIDEO_MIME_TYPE, kSubLicensePsshBox);
|
||||
ASSERT_FALSE(init_data.IsEmpty());
|
||||
std::vector<video_widevine::SubLicense> keys =
|
||||
init_data.ExtractEmbeddedKeys();
|
||||
init_data.ExtractSublicenseKeys();
|
||||
ASSERT_EQ(keys.size(), 2UL);
|
||||
EXPECT_EQ(keys[0].sub_session_key_id(), "sub_session_key_id_0");
|
||||
EXPECT_EQ(keys[1].sub_session_key_id(), "sub_session_key_id_1");
|
||||
@@ -453,7 +562,7 @@ TEST_F(InitializationDataTest, ExtractEmptySubLicense) {
|
||||
InitializationData init_data(ISO_BMFF_VIDEO_MIME_TYPE, kWidevinePssh);
|
||||
ASSERT_FALSE(init_data.IsEmpty());
|
||||
std::vector<video_widevine::SubLicense> keys =
|
||||
init_data.ExtractEmbeddedKeys();
|
||||
init_data.ExtractSublicenseKeys();
|
||||
ASSERT_TRUE(keys.empty());
|
||||
}
|
||||
|
||||
@@ -644,8 +753,8 @@ TEST_P(HlsConstructionTest, InitData) {
|
||||
for (size_t i = 0; i < param.key_ids_.size(); ++i) {
|
||||
bool key_id_found = false;
|
||||
if (param.key_ids_[i].size() != 32) continue;
|
||||
for (int j = 0; j < cenc_header.key_id_size(); ++j) {
|
||||
if (param.key_ids_[i] == b2a_hex(cenc_header.key_id(j))) {
|
||||
for (int j = 0; j < cenc_header.key_ids_size(); ++j) {
|
||||
if (param.key_ids_[i] == b2a_hex(cenc_header.key_ids(j))) {
|
||||
key_id_found = true;
|
||||
break;
|
||||
}
|
||||
@@ -752,7 +861,7 @@ TEST_P(HlsParseTest, Parse) {
|
||||
} else if (param.key_.compare(kJsonContentId) == 0) {
|
||||
EXPECT_EQ(param.value_, cenc_header.content_id());
|
||||
} else if (param.key_.compare(kJsonKeyIds) == 0) {
|
||||
EXPECT_EQ(param.value_, b2a_hex(cenc_header.key_id(0)));
|
||||
EXPECT_EQ(param.value_, b2a_hex(cenc_header.key_ids(0)));
|
||||
}
|
||||
|
||||
EXPECT_EQ(kHlsIvHexValue, b2a_hex(init_data.hls_iv()));
|
||||
|
||||
Reference in New Issue
Block a user