Use Jsmn to parse json data

[ Merge of http://go/wvgerrit/16628 ]

Jsmn will replace a local method that parsed json init data.
Added a fix to include all key Ids in the WidevineCencHeader rather than
just the first. Also modified the content_id to reflect that it is a
base64 encoded value.

b/20630275

Change-Id: I7080c8cea21be4dea09a4905a96b4cc03e584c1d
This commit is contained in:
Rahul Frias
2016-01-29 13:08:31 -08:00
parent 7be45a9011
commit e0da404b14
8 changed files with 117 additions and 73 deletions

View File

@@ -180,7 +180,7 @@ const std::string kHlsTestInvalidHexValue = kHlsIvHexValue + "g7";
char kHlsTestKeyFormatVersionsSeparator = '/';
const std::string kHlsTestUriDataFormat = "data:text/plain;base64,";
const std::string kHlsTestProvider = "youtube";
const std::string kHlsTestContentId = "Tears_2015";
const std::string kHlsTestContentId = "MjAxNV9UZWFycw==";
const std::string kHlsTestKeyId1 = "371E135E1A985D75D198A7F41020DC23";
const std::string kHlsTestKeyId2 = "E670D9B60AE61583E01BC9253FA19261";
const std::string kHlsTestKeyId3 = "78094E72165DF39721B8A354D6A71390";
@@ -594,7 +594,17 @@ TEST_P(HlsConstructionTest, InitData) {
EXPECT_TRUE(cenc_header.ParseFromString(value));
EXPECT_EQ(video_widevine_server::sdk::WidevineCencHeader_Algorithm_AESCTR,
cenc_header.algorithm());
EXPECT_EQ(param.key_ids_[0], b2a_hex(cenc_header.key_id(0)));
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))) {
key_id_found = true;
break;
}
}
EXPECT_TRUE(key_id_found);
}
EXPECT_EQ(param.provider_, cenc_header.provider());
EXPECT_EQ(param.content_id_, cenc_header.content_id());
} else {
@@ -617,7 +627,7 @@ INSTANTIATE_TEST_CASE_P(
.AddKeyId(kHlsTestKeyId2)
.AddKeyId(kHlsTestKeyId3),
HlsInitDataVariant(kHlsTestProvider, kHlsTestContentId,
kHlsTestInvalidKeyId, false)
kHlsTestInvalidKeyId, true)
.AddKeyId(kHlsTestKeyId1)));
TEST_F(HlsInitDataConstructionTest, InvalidUriDataFormat) {