Support Dual PSSHs
Merge from Widevine repo of http://go/wvgerrit/48842 In order to work around a limitation of some versions of OEMCrypto, the packager is going to start generating files with multiple Widevine PSSH boxes. For backwards-compatibility, the first PSSH will be a SINGLE-type PSSH while the ENTITLED_KEYS-type PSSH (if any) will come later. In order to use entitlement licenses, then, the CDM needs to change how it selects PSSHs from the init data blob. Previously, the CDM always took the first Widevine PSSH it found. Now, it must find all the Widevine PSSHs and select the appropriate PSSH for the OEMCrypto implementation. ENTITLTED_KEYS will be used on OEC v14 and later, if available, while SINGLE will be preferred on earlier OEMCrypto versions. As a side-effect of this, the CDM is now stricter about what PSSH payloads it will accept. Previously, it would blindly accept the payload of any PSSH where the wrapper was not malformed. Now, it sometimes has to actually parse the payload, and therefore PSSHs that have corrupted payloads will be rejected. This affected a few unit tests which used PSSHs that were malformed. These tests have been updated to use PSSHs that do not fail to parse. Bug: 78142219 Test: CE CDM Unit Tests Test: Android Unit Tests Test: Android Google Play & Netflix Test: tested as part of http://go/ag/4674759 Change-Id: Ia70d627a914299bfbae84b4cb46f100dc5c7a501
This commit is contained in:
@@ -6,6 +6,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"
|
||||
@@ -23,6 +24,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 = "}";
|
||||
@@ -130,7 +134,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)
|
||||
@@ -168,7 +172,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)
|
||||
@@ -179,6 +183,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;
|
||||
@@ -420,6 +511,7 @@ class HlsInitDataConstructionTest : public ::testing::Test {};
|
||||
class HlsParseTest : public ::testing::TestWithParam<HlsAttributeVariant> {};
|
||||
|
||||
class HlsTest : public ::testing::Test {};
|
||||
|
||||
} // namespace
|
||||
|
||||
TEST_F(InitializationDataTest, BadType) {
|
||||
@@ -437,7 +529,22 @@ INSTANTIATE_TEST_CASE_P(
|
||||
::testing::Values(kWidevinePssh, kWidevinePsshFirst,
|
||||
kWidevinePsshAfterV0Pssh, kWidevinePsshAfterNonZeroFlags,
|
||||
kWidevinePsshAfterV1Pssh, kWidevineV1Pssh, kOtherBoxFirst,
|
||||
kZeroSizedPsshBox, kSubLicensePsshBox));
|
||||
kZeroSizedPsshBox, kSubLicensePsshBox,
|
||||
kMultipleWidevinePsshBox));
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
TEST_F(InitializationDataTest, ExtractSubLicense) {
|
||||
InitializationData init_data(ISO_BMFF_VIDEO_MIME_TYPE, kSubLicensePsshBox);
|
||||
|
||||
Reference in New Issue
Block a user