RDK Documentation (Open Sourced RDK Components)
drmHelperTest.cpp
1 #include <vector>
2 #include <iostream>
3 #include <sstream>
4 #include <iomanip>
5 #include <algorithm>
6 #include <iterator>
7 
8 #include "AampConfig.h"
9 
10 #include "AampDrmHelper.h"
11 
12 #include "drmTestUtils.h"
13 #include "aampMocks.h"
14 
15 #include "CppUTest/TestHarness.h"
16 
17 TEST_GROUP(AampDrmHelperTests)
18 {
19  struct CreateHelperTestData
20  {
21  DrmMethod method;
22  MediaFormat mediaFormat;
23  std::string uri;
24  std::string keyFormat;
25  std::string systemUUID;
26  std::vector<uint8_t> expectedKeyPayload;
27  };
28 
29  DrmInfo createDrmInfo(DrmMethod method,
30  MediaFormat mediaFormat,
31  const std::string& uri = "",
32  const std::string& keyFormat = "",
33  const std::string& systemUUID = "",
34  const std::string& initData = "")
35  {
36  DrmInfo drmInfo;
37 
38  drmInfo.method = method;
39  drmInfo.mediaFormat = mediaFormat;
40  drmInfo.keyURI = uri;
41  drmInfo.keyFormat = keyFormat;
42  drmInfo.systemUUID = systemUUID;
43  drmInfo.initData = initData;
44 
45  return drmInfo;
46  }
47 
48  void setup()
49  {
50  MockAampReset();
51  }
52 
53  void teardown()
54  {
55  MockAampReset();
56  }
57 };
58 
59 TEST(AampDrmHelperTests, TestDrmIds)
60 {
61  std::vector<std::string> expectedIds({
62  "A68129D3-575B-4F1A-9CBA-3223846CF7C3", // VGDRM
63  "1077efec-c0b2-4d02-ace3-3c1e52e2fb4b", // ClearKey
64  "edef8ba9-79d6-4ace-a3c8-27dcd51d21ed", // Widevine
65  "9a04f079-9840-4286-ab92-e65be0885f95" // PlayReady
66  });
67  std::sort(expectedIds.begin(), expectedIds.end());
68 
69  std::vector<std::string> actualIds;
71  std::sort(actualIds.begin(), actualIds.end());
72 
73  CHECK_EQUAL(expectedIds, actualIds);
74 }
75 
76 TEST(AampDrmHelperTests, TestCreateVgdrmHelper)
77 {
78  const std::vector<CreateHelperTestData> testData = {
79  // Invalid URI but valid KEYFORMAT
82  "91701500000810367b131dd025ab0a7bd8d20c1314151600",
83  "A68129D3-575B-4F1A-9CBA-3223846CF7C3",
84  "",
85  {}},
86 
87  // Invalid URI but valid KEYFORMAT
90  "91701500000810367b131dd025ab0a7bd8d20c1314151600",
91  "A68129D3-575B-4F1A-9CBA-3223846CF7C3",
92  "",
93  {}},
94 
95  // Valid 48 char URI and KEYFORMAT
98  "81701500000810367b131dd025ab0a7bd8d20c1314151600",
99  "A68129D3-575B-4F1A-9CBA-3223846CF7C3",
100  "",
101  {0x36, 0x7b, 0x13, 0x1d, 0xd0, 0x25, 0xab, 0x0a, 0x7b, 0xd8, 0xd2, 0x0c, 0x13, 0x14, 0x15, 0x16}},
102 
103  // Valid 48 char URI and KEYFORMAT. No METHOD (not required to pick up the VGDRM helper)
104  {eMETHOD_NONE,
106  "81701500000810367b131dd025ab0a7bd8d20c1314151600",
107  "A68129D3-575B-4F1A-9CBA-3223846CF7C3",
108  "",
109  {0x36, 0x7b, 0x13, 0x1d, 0xd0, 0x25, 0xab, 0x0a, 0x7b, 0xd8, 0xd2, 0x0c, 0x13, 0x14, 0x15, 0x16}},
110 
111  // Valid 48 char URI, no KEYFORMAT
114  "81701500000810367b131dd025ab0a7bd8d20c1314151600",
115  "",
116  "",
117  {0x36, 0x7b, 0x13, 0x1d, 0xd0, 0x25, 0xab, 0x0a, 0x7b, 0xd8, 0xd2, 0x0c, 0x13, 0x14, 0x15, 0x16}},
118 
119  // Valid 40 char URI, no KEYFORMAT
122  "8170110000080c367b131dd025ab0a7bd8d20c00",
123  "",
124  "",
125  {0x36, 0x7b, 0x13, 0x1d, 0xd0, 0x25, 0xab, 0x0a, 0x7b, 0xd8, 0xd2, 0x0c}},
126 
127  // Valid 48 char URI, uppercase
130  "81701500000810367B131DD025AB0A7BD8D20C1314151600",
131  "",
132  "",
133  {0x36, 0x7b, 0x13, 0x1d, 0xd0, 0x25, 0xab, 0x0a, 0x7b, 0xd8, 0xd2, 0x0c, 0x13, 0x14, 0x15, 0x16}},
134 
135  // Valid 40 char URI, uppercase
138  "8170110000080C367B131DD025AB0A7BD8D20C00",
139  "",
140  "",
141  {0x36, 0x7b, 0x13, 0x1d, 0xd0, 0x25, 0xab, 0x0a, 0x7b, 0xd8, 0xd2, 0x0c}},
142 
143  // 48 char URI specifies maximum key length possible without going off the end of the string
146  "81701500000811367b131dd025ab0a7bd8d20c1314151600",
147  "A68129D3-575B-4F1A-9CBA-3223846CF7C3",
148  "",
149  {0x36, 0x7b, 0x13, 0x1d, 0xd0, 0x25, 0xab, 0x0a, 0x7b, 0xd8, 0xd2, 0x0c, 0x13, 0x14, 0x15, 0x16, 0x0}},
150 
151  // 48 char URI specifies key length which will just take us off the end of the string.
152  // Creation should pass but empty key returned
155  "81701500000812367b131dd025ab0a7bd8d20c1314151600",
156  "A68129D3-575B-4F1A-9CBA-3223846CF7C3",
157  "",
158  {}},
159 
160  // 40 char URI specifies maximum key length possible without going off the end of the string
163  "8170110000080d367b131dd025ab0a7bd8d20c00",
164  "A68129D3-575B-4F1A-9CBA-3223846CF7C3",
165  "",
166  {0x36, 0x7b, 0x13, 0x1d, 0xd0, 0x25, 0xab, 0x0a, 0x7b, 0xd8, 0xd2, 0x0c, 0x0}},
167 
168  // 40 char URI specifies key length which will just take us off the end of the string.
169  // Creation should pass but empty key returned
172  "8170110000080e367b131dd025ab0a7bd8d20c00",
173  "A68129D3-575B-4F1A-9CBA-3223846CF7C3",
174  "",
175  {}},
176 
177  // Textual identifier
180  "",
181  "net.vgdrm",
182  "",
183  {}}
184  };
185  DrmInfo drmInfo;
186 
187  for (auto& test_data: testData)
188  {
189  std::vector<uint8_t> keyID;
190 
191  drmInfo = createDrmInfo(test_data.method, test_data.mediaFormat, test_data.uri, test_data.keyFormat, test_data.systemUUID);
192 
193  CHECK_TRUE(AampDrmHelperEngine::getInstance().hasDRM(drmInfo));
194 
195  std::shared_ptr<AampDrmHelper> vgdrmHelper = AampDrmHelperEngine::getInstance().createHelper(drmInfo);
196  CHECK_TEXT(vgdrmHelper != NULL, "VGDRM helper creation failed");
197  CHECK_EQUAL("net.vgdrm", vgdrmHelper->ocdmSystemId());
198  CHECK_EQUAL(true, vgdrmHelper->isClearDecrypt());
199  CHECK_EQUAL(true, vgdrmHelper->isHdcp22Required());
200  CHECK_EQUAL(4, vgdrmHelper->getDrmCodecType());
201  CHECK_EQUAL(true, vgdrmHelper->isExternalLicense());
202  CHECK_EQUAL(10000U, vgdrmHelper->licenseGenerateTimeout());
203  CHECK_EQUAL(10000U, vgdrmHelper->keyProcessTimeout());
204 
205  vgdrmHelper->getKey(keyID);
206 
207  if (test_data.expectedKeyPayload.size() != 0) {
208  std::shared_ptr<std::vector<uint8_t>> keyData;
209  CHECK_EQUAL(test_data.expectedKeyPayload , keyID);
210  }
211  }
212 }
213 
214 TEST(AampDrmHelperTests, TestCreateVgdrmHelperNegative)
215 {
216  // Note: using METHOD_NONE on each of the below to avoid picking up
217  // the default helper for AES_128 (ClearKey). The positive test proves
218  // that we can create a VGDRM helper with METHOD_NONE, providing the
219  // other criteria are matched
220  const std::vector<CreateHelperTestData> testData = {
221  // Start of URI is valid, but payload has a non hex value at start
222  {eMETHOD_NONE,
224  "8170110000080CZ67B331DD025AB0A7BD8D20C00",
225  "",
226  "",
227  {}},
228 
229  // Start of URI is valid, but payload has a non hex value in middle
230  {eMETHOD_NONE,
232  "8170110000080C367B331DD025AZ0A7BD8D20C00",
233  "",
234  "",
235  {}},
236 
237  // Invalid URI and KEYFORMAT
238  {eMETHOD_NONE,
240  "BAD0110000080c367b131dd025ab0a7bd8d20c00",
241  "BAD129D3-575B-4F1A-9CBA-3223846CF7C3",
242  "",
243  {}}, /* Since the URI data is bad we won't get a payload */
244 
245  // Invalid URI and KEYFORMAT (lower-case)
246  {eMETHOD_NONE,
248  "BAD0110000080c367b131dd025ab0a7bd8d20c00",
249  "a68129d3-575b-4f1a-9cba-3223846cf7c3",
250  "",
251  {}}, /* Since the URI data is bad we won't get a payload */
252 
253  // Invalid URI, no KEYFORMAT
254  {eMETHOD_NONE,
256  "BAD0110000080c367b131dd025ab0a7bd8d20c00",
257  "",
258  "",
259  {}},
260 
261  // Start of URI is valid, but it's 1 character short
262  {eMETHOD_NONE,
264  "8170110000080c367b131dd025ab0a7bd8d20c0",
265  "",
266  "",
267  {}},
268 
269  // Start of URI is valid, but it's 1 character too long
270  {eMETHOD_NONE,
272  "8170110000080c367b131dd025ab0a7bd8d20c000",
273  "",
274  "",
275  {}}
276  };
277  DrmInfo drmInfo;
278 
279  for (auto& test_data: testData)
280  {
281  drmInfo = createDrmInfo(test_data.method, test_data.mediaFormat, test_data.uri, test_data.keyFormat, test_data.systemUUID);
282 
283  CHECK_FALSE(AampDrmHelperEngine::getInstance().hasDRM(drmInfo));
284 
285  std::shared_ptr<AampDrmHelper> vgdrmHelper = AampDrmHelperEngine::getInstance().createHelper(drmInfo);
286  CHECK(vgdrmHelper == NULL);
287  }
288 }
289 
290 TEST(AampDrmHelperTests, TestVgdrmHelperInitDataCreation)
291 {
292  std::vector<DrmInfo> drmInfoList;
293 
294  drmInfoList.push_back(createDrmInfo(eMETHOD_AES_128,
296  "8170110000080c367b131dd025ab0a7bd8d20c00",
297  "A68129D3-575B-4F1A-9CBA-3223846CF7C3",
298  "",
299  "somebase64initdata"));
300 
301  // Extra base 64 characters at start and end. Shouldn't cause any issue
302  drmInfoList.push_back(createDrmInfo(eMETHOD_AES_128,
304  "8170110000080c367b131dd025ab0a7bd8d20c00",
305  "A68129D3-575B-4F1A-9CBA-3223846CF7C3",
306  "",
307  "+/=somebase64initdata+/="));
308 
309  for (const DrmInfo& drmInfo : drmInfoList)
310  {
311  std::shared_ptr<AampDrmHelper> vgdrmHelper = AampDrmHelperEngine::getInstance().createHelper(drmInfo);
312  CHECK_TEXT(vgdrmHelper != NULL, "VGDRM helper creation failed");
313 
314  std::vector<uint8_t> initData;
315  vgdrmHelper->createInitData(initData);
316 
317  TestUtilJsonWrapper jsonWrapper(initData);
318  cJSON *initDataObj = jsonWrapper.getJsonObj();
319  CHECK_TEXT(initDataObj != NULL, "Invalid JSON init data");
320 
321  CHECK_JSON_STR_VALUE(initDataObj, "initData", drmInfo.initData.c_str());
322  CHECK_JSON_STR_VALUE(initDataObj, "uri", drmInfo.keyURI.c_str());
323 
324  // Currently pssh won't be present
325  POINTERS_EQUAL(NULL, cJSON_GetObjectItem(initDataObj, "pssh"));
326  }
327 }
328 
329 TEST(AampDrmHelperTests, TestVgdrmHelperGenerateLicenseRequest)
330 {
331  DrmInfo drmInfo = createDrmInfo(eMETHOD_AES_128, eMEDIAFORMAT_HLS, "81701500000810367b131dd025ab0a7bd8d20c1314151600");
332  drmInfo.manifestURL = "http://example.com/hls/playlist.m3u8";
333  CHECK_TRUE(AampDrmHelperEngine::getInstance().hasDRM(drmInfo));
334  std::shared_ptr<AampDrmHelper> clearKeyHelper = AampDrmHelperEngine::getInstance().createHelper(drmInfo);
335 
336  AampChallengeInfo challengeInfo;
337  AampLicenseRequest licenseRequest;
338  clearKeyHelper->generateLicenseRequest(challengeInfo, licenseRequest);
339 
340  CHECK_EQUAL(AampLicenseRequest::DRM_RETRIEVE, licenseRequest.method);
341  CHECK_EQUAL("", licenseRequest.url);
342  CHECK_EQUAL("", licenseRequest.payload);
343 }
344 
345 TEST(AampDrmHelperTests, TestCreateClearKeyHelper)
346 {
347  const std::vector<CreateHelperTestData> testData = {
348  // Valid KEYFORMAT, HLS
351  "file.key",
352  "urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b",
353  "1077efec-c0b2-4d02-ace3-3c1e52e2fb4b",
354  {'1'}},
355 
356  // Valid KEYFORMAT, DASH
359  "file.key",
360  "urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b",
361  "1077efec-c0b2-4d02-ace3-3c1e52e2fb4b",
362  {}}, // For DASH, the key should come from the PSSH, so we won't check that here
363 
364  // Textual identifier rather than UUID
367  "file.key",
368  "org.w3.clearkey",
369  "1077efec-c0b2-4d02-ace3-3c1e52e2fb4b",
370  {'1'}},
371 
372  };
373  DrmInfo drmInfo;
374 
375  for (auto& test_data: testData)
376  {
377  drmInfo = createDrmInfo(eMETHOD_AES_128, test_data.mediaFormat, test_data.uri, test_data.keyFormat, test_data.systemUUID);
378 
379  CHECK_TRUE(AampDrmHelperEngine::getInstance().hasDRM(drmInfo));
380 
381  std::shared_ptr<AampDrmHelper> clearKeyHelper = AampDrmHelperEngine::getInstance().createHelper(drmInfo);
382  CHECK_TEXT(clearKeyHelper != NULL, "ClearKey helper creation failed");
383  CHECK_EQUAL("org.w3.clearkey", clearKeyHelper->ocdmSystemId());
384  CHECK_EQUAL(true, clearKeyHelper->isClearDecrypt());
385  CHECK_EQUAL(false, clearKeyHelper->isHdcp22Required());
386  CHECK_EQUAL(0, clearKeyHelper->getDrmCodecType());
387  CHECK_EQUAL(false, clearKeyHelper->isExternalLicense());
388  CHECK_EQUAL(5000U, clearKeyHelper->licenseGenerateTimeout());
389  CHECK_EQUAL(5000U, clearKeyHelper->keyProcessTimeout());
390 
391  if (test_data.expectedKeyPayload.size() != 0)
392  {
393  std::vector<uint8_t> keyID;
394  clearKeyHelper->getKey(keyID);
395  CHECK_EQUAL(test_data.expectedKeyPayload , keyID);
396  }
397  }
398 }
399 
400 TEST(AampDrmHelperTests, TestClearKeyHelperHlsInitDataCreation)
401 {
402  DrmInfo drmInfo = createDrmInfo(eMETHOD_AES_128, eMEDIAFORMAT_HLS_MP4, "file.key", "urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b");
403  CHECK_TRUE(AampDrmHelperEngine::getInstance().hasDRM(drmInfo));
404  std::shared_ptr<AampDrmHelper> clearKeyHelper = AampDrmHelperEngine::getInstance().createHelper(drmInfo);
405 
406  std::vector<uint8_t> initData;
407  clearKeyHelper->createInitData(initData);
408 
409  TestUtilJsonWrapper jsonWrapper(initData);
410  cJSON *initDataObj = jsonWrapper.getJsonObj();
411  CHECK_TEXT(initDataObj != NULL, "Invalid JSON init data");
412 
413  // kids
414  cJSON *kidsArray = cJSON_GetObjectItem(initDataObj, "kids");
415  CHECK_TEXT(kidsArray != NULL, "Missing kids in JSON init data");
416  CHECK_EQUAL(1, cJSON_GetArraySize(kidsArray));
417  cJSON *kids0 = cJSON_GetArrayItem(kidsArray, 0);
418  STRCMP_EQUAL("1", cJSON_GetStringValue(kids0));
419 }
420 
421 TEST(AampDrmHelperTests, TestClearKeyHelperParsePssh)
422 {
423  DrmInfo drmInfo = createDrmInfo(eMETHOD_AES_128, eMEDIAFORMAT_DASH, "file.key", "urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b");
424  CHECK_TRUE(AampDrmHelperEngine::getInstance().hasDRM(drmInfo));
425  std::shared_ptr<AampDrmHelper> clearKeyHelper = AampDrmHelperEngine::getInstance().createHelper(drmInfo);
426 
427  // For DASH the init data should have come from the PSSH, so when asked to create
428  // the init data, the helper should just return that
429  std::vector<uint8_t> psshData = {
430  0x00, 0x00, 0x00, 0x34, 0x70, 0x73, 0x73, 0x68, 0x01, 0x00, 0x00, 0x00, 0x10, 0x77, 0xef, 0xec,
431  0xc0, 0xb2, 0x4d, 0x02, 0xac, 0xe3, 0x3c, 0x1e, 0x52, 0xe2, 0xfb, 0x4b, 0x00, 0x00, 0x00, 0x01,
432  0xfe, 0xed, 0xf0, 0x0d, 0xee, 0xde, 0xad, 0xbe, 0xef, 0xf0, 0xba, 0xad, 0xf0, 0x0d, 0xd0, 0x0d,
433  0x00, 0x00, 0x00, 0x00};
434 
435  CHECK_TRUE(clearKeyHelper->parsePssh(psshData.data(), psshData.size()));
436 
437  std::vector<uint8_t> initData;
438  clearKeyHelper->createInitData(initData);
439  CHECK_EQUAL_TEXT(psshData, initData, "Init data does not match PSSH data");
440 
441  // KeyId should have been extracted from the PSSH
442  std::vector<uint8_t> keyID;
443  const std::vector<uint8_t> expectedKeyID = {0xfe, 0xed, 0xf0, 0x0d, 0xee, 0xde, 0xad, 0xbe, 0xef, 0xf0, 0xba, 0xad, 0xf0, 0x0d, 0xd0, 0x0d};
444  clearKeyHelper->getKey(keyID);
445  CHECK_EQUAL(expectedKeyID, keyID);
446 }
447 
448 TEST(AampDrmHelperTests, TestClearKeyHelperGenerateLicenseRequest)
449 {
450  DrmInfo drmInfo = createDrmInfo(eMETHOD_AES_128, eMEDIAFORMAT_HLS_MP4, "file.key", "urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b");
451  drmInfo.manifestURL = "http://stream.example/hls/playlist.m3u8";
452  CHECK_TRUE(AampDrmHelperEngine::getInstance().hasDRM(drmInfo));
453  std::shared_ptr<AampDrmHelper> clearKeyHelper = AampDrmHelperEngine::getInstance().createHelper(drmInfo);
454 
455  AampChallengeInfo challengeInfo;
456  challengeInfo.url = "http://challengeinfourl.example";
457  AampLicenseRequest licenseRequest;
458 
459  // No ClearKey license URL in the license request, expect the URL to be
460  // constructed from the information in the DrmInfo
461  clearKeyHelper->generateLicenseRequest(challengeInfo, licenseRequest);
462  CHECK_EQUAL(AampLicenseRequest::POST, licenseRequest.method);
463  CHECK_EQUAL("http://stream.example/hls/file.key", licenseRequest.url);
464  CHECK_EQUAL("", licenseRequest.payload);
465 
466  // Setting a ClearKey license URL in the license request, expect
467  // that to take precedence
468  const std::string fixedCkLicenseUrl = "http://cklicenseserver.example";
469  licenseRequest.url = fixedCkLicenseUrl;
470  clearKeyHelper->generateLicenseRequest(challengeInfo, licenseRequest);
471  CHECK_EQUAL(fixedCkLicenseUrl, licenseRequest.url);
472 
473  // Clearing ClearKey license URL in the license request and creating a
474  // helper with no key URI in the DrmInfo. Should use the URI from the challenge
475  licenseRequest.url.clear();
476  DrmInfo drmInfoNoKeyUri = createDrmInfo(eMETHOD_AES_128, eMEDIAFORMAT_HLS_MP4, "", "urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b");
477  std::shared_ptr<AampDrmHelper> clearKeyHelperNoKeyUri = AampDrmHelperEngine::getInstance().createHelper(drmInfoNoKeyUri);
478  clearKeyHelperNoKeyUri->generateLicenseRequest(challengeInfo, licenseRequest);
479  CHECK_EQUAL(challengeInfo.url, licenseRequest.url);
480 }
481 
482 TEST(AampDrmHelperTests, TestClearKeyHelperTransformHlsLicenseResponse)
483 {
484  struct TransformLicenseResponseTestData
485  {
486  std::vector<uint8_t> keyResponse;
487  std::string expectedEncodedKey;
488  };
489 
490  DrmInfo drmInfo = createDrmInfo(eMETHOD_AES_128, eMEDIAFORMAT_HLS_MP4, "file.key", "urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b");
491  CHECK_TRUE(AampDrmHelperEngine::getInstance().hasDRM(drmInfo));
492  std::shared_ptr<AampDrmHelper> clearKeyHelper = AampDrmHelperEngine::getInstance().createHelper(drmInfo);
493 
494  const std::vector<TransformLicenseResponseTestData> testData {
495  // Empty response - should lead to empty string
496  {{}, {""}},
497  // Most basic case - 1 maps to AQ
498  {{0x1}, {"AQ"}},
499  // Should lead to a string containing every possible base64url character
500  {{0x00, 0x10, 0x83, 0x10, 0x51, 0x87, 0x20, 0x92, 0x8b, 0x30, 0xd3, 0x8f, 0x41, 0x14,
501  0x93, 0x51, 0x55, 0x97, 0x61, 0x96, 0x9b, 0x71, 0xd7, 0x9f, 0x82, 0x18, 0xa3, 0x92,
502  0x59, 0xa7, 0xa2, 0x9a, 0xab, 0xb2, 0xdb, 0xaf, 0xc3, 0x1c, 0xb3, 0xd3, 0x5d, 0xb7,
503  0xe3, 0x9e, 0xbb, 0xf3, 0xdf, 0xbf}, {"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"}}
504  };
505 
506  for (auto& testCase : testData)
507  {
508  std::shared_ptr<DrmData> drmData = std::make_shared<DrmData>((unsigned char *)&testCase.keyResponse[0], testCase.keyResponse.size());
509  clearKeyHelper->transformLicenseResponse(drmData);
510 
511  TestUtilJsonWrapper jsonWrapper((const char*)drmData->getData().c_str(), drmData->getDataLength());
512  cJSON *responseObj = jsonWrapper.getJsonObj();
513  CHECK_TEXT(responseObj != NULL, "Invalid license response data");
514 
515  // keys array
516  cJSON *keysArray = cJSON_GetObjectItem(responseObj, "keys");
517  CHECK_TEXT(keysArray != NULL, "Missing keys in JSON response data");
518  CHECK_EQUAL(1, cJSON_GetArraySize(keysArray));
519  cJSON *keys0Obj = cJSON_GetArrayItem(keysArray, 0);
520  CHECK_JSON_STR_VALUE(keys0Obj, "alg", "cbc");
521  CHECK_JSON_STR_VALUE(keys0Obj, "k", testCase.expectedEncodedKey.c_str());
522  CHECK_JSON_STR_VALUE(keys0Obj, "kid", "MQ"); // Expecting the character '1' (0x31) base64url encoded
523  }
524 }
525 
526 TEST(AampDrmHelperTests, TestTransformDashLicenseResponse)
527 {
528  // Unlike HLS (where we do expect a ClearKey license to be transformed),
529  // for DASH we expect the response to be given back untouched
530  std::vector<DrmInfo> drmInfoList;
531 
532  // ClearKey
533  drmInfoList.push_back(createDrmInfo(eMETHOD_AES_128, eMEDIAFORMAT_DASH, "file.key", "urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b"));
534 
535  // PlayReady
536  drmInfoList.push_back(createDrmInfo(eMETHOD_NONE, eMEDIAFORMAT_DASH, "", "", "9a04f079-9840-4286-ab92-e65be0885f95"));
537 
538  for (auto& drmInfo : drmInfoList)
539  {
540  CHECK_TRUE(AampDrmHelperEngine::getInstance().hasDRM(drmInfo));
541  std::shared_ptr<AampDrmHelper> clearKeyHelper = AampDrmHelperEngine::getInstance().createHelper(drmInfo);
542  unsigned char licenseResponse[] = {'D', 'A', 'S', 'H', 'L', 'I', 'C'};
543  std::shared_ptr<DrmData> drmData = std::make_shared<DrmData>(licenseResponse, sizeof(licenseResponse));
544 
545  clearKeyHelper->transformLicenseResponse(drmData);
546  CHECK_EQUAL_TEXT(sizeof(licenseResponse), drmData->getDataLength(), "Unexpected change in license response size");
547  MEMCMP_EQUAL_TEXT(licenseResponse, drmData->getData().c_str(), sizeof(licenseResponse), "Unexpected transformation of license response");
548  }
549 }
550 
551 TEST(AampDrmHelperTests, TestCreatePlayReadyHelper)
552 {
553  const std::vector<CreateHelperTestData> testData = {
554  // Valid UUID
556  eMEDIAFORMAT_DASH, // Note: PlayReady helper currently supports DASH only
557  "file.key",
558  "",
559  "9a04f079-9840-4286-ab92-e65be0885f95",
560  {}}, // For DASH, the key should come from the PSSH, so we won't check that here
561 
562  // Valid UUID, no method (method not required)
563  {eMETHOD_NONE,
564  eMEDIAFORMAT_DASH, // Note: PlayReady helper currently supports DASH only
565  "file.key",
566  "",
567  "9a04f079-9840-4286-ab92-e65be0885f95",
568  {}}, // For DASH, the key should come from the PSSH, so we won't check that here
569 
570  // Textual identifier rather than UUID
572  eMEDIAFORMAT_DASH, // Note: PlayReady helper currently supports DASH only
573  "file.key",
574  "com.microsoft.playready",
575  "",
576  {}} // For DASH, the key should come from the PSSH, so we won't check that here
577  };
578  DrmInfo drmInfo;
579 
580  for (auto& test_data: testData)
581  {
582  drmInfo = createDrmInfo(test_data.method, test_data.mediaFormat, test_data.uri, test_data.keyFormat, test_data.systemUUID);
583 
584  CHECK_TRUE(AampDrmHelperEngine::getInstance().hasDRM(drmInfo));
585 
586  std::shared_ptr<AampDrmHelper> playReadyHelper = AampDrmHelperEngine::getInstance().createHelper(drmInfo);
587  CHECK_TEXT(playReadyHelper != NULL, "PlayReady helper creation failed");
588  CHECK_EQUAL("com.microsoft.playready", playReadyHelper->ocdmSystemId());
589  CHECK_EQUAL(false, playReadyHelper->isClearDecrypt());
590  CHECK_EQUAL(eDRM_PlayReady, playReadyHelper->getDrmCodecType());
591  CHECK_EQUAL(false, playReadyHelper->isExternalLicense());
592  CHECK_EQUAL(5000U, playReadyHelper->licenseGenerateTimeout());
593  CHECK_EQUAL(5000U, playReadyHelper->keyProcessTimeout());
594 
595  // TODO: HDCP checks
596  }
597 }
598 
599 TEST(AampDrmHelperTests, TestCreatePlayReadyHelperNegative)
600 {
601  const std::vector<CreateHelperTestData> testData = {
602  // Valid UUID but HLS media format, which isn't supported for the PlayReady helper
603  {eMETHOD_NONE,
605  "file.key",
606  "",
607  "9a04f079-9840-4286-ab92-e65be0885f95",
608  {}}
609  };
610  DrmInfo drmInfo;
611 
612  for (auto& test_data: testData)
613  {
614  drmInfo = createDrmInfo(test_data.method, test_data.mediaFormat, test_data.uri, test_data.keyFormat, test_data.systemUUID);
615 
616  CHECK_FALSE(AampDrmHelperEngine::getInstance().hasDRM(drmInfo));
617 
618  std::shared_ptr<AampDrmHelper> playReadyHelper = AampDrmHelperEngine::getInstance().createHelper(drmInfo);
619  CHECK(playReadyHelper == NULL);
620  }
621 }
622 
623 TEST(AampDrmHelperTests, TestWidevineHelperParsePsshDrmMetaData)
624 {
625  // For DASH the init data should have come from the PSSH, so when asked to create
626  // the init data, the helper should just return that.
627  std::vector<uint8_t> psshData = {
628  0x00, 0x00, 0x00, 0x34, 0x70, 0x73, 0x73, 0x68, 0x00, 0x00, 0x00, 0x00, 0x10, 0x77, 0xef, 0xec,
629  0xc0, 0xb2, 0x4d, 0x02, 0xac, 0xe3, 0x3c, 0x1e, 0x52, 0xe2, 0xfb, 0x4b, 0x00, 0x00, 0x00, 0x12,
630  0x12, 0x10, 0xfe, 0xed, 0xf0, 0x0d, 0xee, 0xde, 0xad, 0xbe, 0xef, 0xf0, 0xba, 0xad, 0xf0, 0x0d,
631  0xd0, 0x0d, 0x00, 0x00, 0x00, 0x00};
632 
633  DrmInfo drmInfo;
634 
635  drmInfo = createDrmInfo(eMETHOD_AES_128, eMEDIAFORMAT_DASH, "file.key", "", "edef8ba9-79d6-4ace-a3c8-27dcd51d21ed");
636 
637  CHECK_TRUE(AampDrmHelperEngine::getInstance().hasDRM(drmInfo));
638  std::shared_ptr<AampDrmHelper> widevineHelper = AampDrmHelperEngine::getInstance().createHelper(drmInfo);
639  CHECK_TEXT(widevineHelper != NULL, "Widevine helper creation failed");
640 
641  CHECK_TRUE(widevineHelper->parsePssh(psshData.data(), psshData.size()));
642 
643  std::vector<uint8_t> initData;
644  widevineHelper->createInitData(initData);
645  CHECK_EQUAL_TEXT(psshData, initData, "Init data does not match PSSH data");
646 
647  // KeyId should have been extracted from the PSSH
648  std::vector<uint8_t> keyID;
649  const std::vector<uint8_t> expectedKeyID = {0xfe, 0xed, 0xf0, 0x0d, 0xee, 0xde, 0xad, 0xbe, 0xef, 0xf0, 0xba, 0xad, 0xf0, 0x0d, 0xd0, 0x0d};
650  widevineHelper->getKey(keyID);
651  CHECK_EQUAL(expectedKeyID, keyID);
652 
653  std::string contentMetadata;
654  contentMetadata = widevineHelper->getDrmMetaData();
655  CHECK_EQUAL("", contentMetadata);
656 
657  std::string metaData("content meta data");
658  widevineHelper->setDrmMetaData(metaData);
659  contentMetadata = widevineHelper->getDrmMetaData();
660  CHECK_EQUAL(metaData, contentMetadata);
661 }
662 
663 
664 TEST(AampDrmHelperTests, TestCreateWidevineHelper)
665 {
666  const std::vector<CreateHelperTestData> testData = {
667  {eMETHOD_NONE,
669  "file.key",
670  "",
671  "edef8ba9-79d6-4ace-a3c8-27dcd51d21ed",
672  {}},
673 
676  "file.key",
677  "",
678  "edef8ba9-79d6-4ace-a3c8-27dcd51d21ed",
679  {}},
680 
681  // Textual identifier rather than UUID
684  "file.key",
685  "com.widevine.alpha",
686  "",
687  {}}
688  };
689  DrmInfo drmInfo;
690 
691  for (auto& test_data: testData)
692  {
693  drmInfo = createDrmInfo(test_data.method, test_data.mediaFormat, test_data.uri, test_data.keyFormat, test_data.systemUUID);
694 
695  CHECK_TRUE(AampDrmHelperEngine::getInstance().hasDRM(drmInfo));
696 
697  std::shared_ptr<AampDrmHelper> widevineHelper = AampDrmHelperEngine::getInstance().createHelper(drmInfo);
698  CHECK_TEXT(widevineHelper != NULL, "Widevine helper creation failed");
699  CHECK_EQUAL("com.widevine.alpha", widevineHelper->ocdmSystemId());
700  CHECK_EQUAL(false, widevineHelper->isClearDecrypt());
701  CHECK_EQUAL(false, widevineHelper->isHdcp22Required());
702  CHECK_EQUAL(eDRM_WideVine, widevineHelper->getDrmCodecType());
703  CHECK_EQUAL(false, widevineHelper->isExternalLicense());
704  CHECK_EQUAL(5000U, widevineHelper->licenseGenerateTimeout());
705  CHECK_EQUAL(5000U, widevineHelper->keyProcessTimeout());
706  }
707 
708 }
709 
710 
711 TEST(AampDrmHelperTests, TestCreateWidevineHelperNegative)
712 {
713  const std::vector<CreateHelperTestData> testData = {
714  // Valid UUID but HLS media format, which isn't supported for the Widevine helper
715  {eMETHOD_NONE,
717  "file.key",
718  "",
719  "edef8ba9-79d6-4ace-a3c8-27dcd51d21ed",
720  {}}
721  };
722  DrmInfo drmInfo;
723 
724  for (auto& test_data: testData)
725  {
726  drmInfo = createDrmInfo(test_data.method, test_data.mediaFormat, test_data.uri, test_data.keyFormat, test_data.systemUUID);
727 
728  CHECK_FALSE(AampDrmHelperEngine::getInstance().hasDRM(drmInfo));
729 
730  std::shared_ptr<AampDrmHelper> widevineHelper = AampDrmHelperEngine::getInstance().createHelper(drmInfo);
731  CHECK(widevineHelper == NULL);
732  }
733 }
734 
735 TEST(AampDrmHelperTests, TestPlayReadyHelperParsePssh)
736 {
737  DrmInfo drmInfo = createDrmInfo(eMETHOD_NONE, eMEDIAFORMAT_DASH, "", "", "9a04f079-9840-4286-ab92-e65be0885f95");
738  CHECK_TRUE(AampDrmHelperEngine::getInstance().hasDRM(drmInfo));
739  std::shared_ptr<AampDrmHelper> playReadyHelper = AampDrmHelperEngine::getInstance().createHelper(drmInfo);
740 
741  const std::string expectedMetadata = "testpolicydata";
742 
743  std::ostringstream psshSs;
744  psshSs << "<WRMHEADER xmlns=\"http://schemas.microsoft.com/DRM/2007/03/PlayReadyHeader\" version=\"4.0.0.0\">"
745  << "<DATA>"
746  << "<KID>16bytebase64enckeydata==</KID>"
747  << "<ckm:policy xmlns:ckm=\"urn:ccp:ckm\">" << expectedMetadata << "</ckm:policy>"
748  << "</DATA>"
749  << "</WRMHEADER>";
750  const std::string psshStr = psshSs.str();
751 
752  CHECK_TRUE(playReadyHelper->parsePssh((const unsigned char*)psshStr.data(), psshStr.size()));
753 
754  // Check keyId and metadata, both of which should be based on the PSSH
755  std::vector<uint8_t> keyId;
756  playReadyHelper->getKey(keyId);
757 
758  const std::string expectedKeyId = "b5f2a6d7-dae6-eeb1-b87a-77247b275ab5";
759  const std::string actualKeyId = std::string(keyId.begin(), keyId.begin() + keyId.size());
760 
761  CHECK_EQUAL(expectedKeyId, actualKeyId);
762  CHECK_EQUAL(expectedMetadata, playReadyHelper->getDrmMetaData());
763  // Ensure the helper doesn't set the meta data
764  playReadyHelper->setDrmMetaData("content meta data that should be ignored");
765  CHECK_EQUAL(expectedMetadata, playReadyHelper->getDrmMetaData());
766 
767  // Dodgy PSSH data should lead to false return value
768  const std::string badPssh = "somerandomdatawhichisntevenxml";
769  CHECK_FALSE(playReadyHelper->parsePssh((const unsigned char*)badPssh.data(), badPssh.size()));
770 }
771 
772 TEST(AampDrmHelperTests, TestPlayReadyHelperParsePsshNoPolicy)
773 {
774  // As before but with no ckm:policy in the PSSH data.
775  // Should be OK but lead to empty metadata
776  DrmInfo drmInfo = createDrmInfo(eMETHOD_NONE, eMEDIAFORMAT_DASH, "", "", "9a04f079-9840-4286-ab92-e65be0885f95");
777  CHECK_TRUE(AampDrmHelperEngine::getInstance().hasDRM(drmInfo));
778  std::shared_ptr<AampDrmHelper> playReadyHelper = AampDrmHelperEngine::getInstance().createHelper(drmInfo);
779 
780  const std::string psshStr =
781  "<WRMHEADER xmlns=\"http://schemas.microsoft.com/DRM/2007/03/PlayReadyHeader\" version=\"4.0.0.0\">"
782  "<DATA>"
783  "<KID>16bytebase64enckeydata==</KID>"
784  "</DATA>"
785  "</WRMHEADER>";
786 
787  CHECK_TRUE(playReadyHelper->parsePssh((const unsigned char*)psshStr.data(), psshStr.size()));
788 
789  // Check keyId and metadata, both of which should be based on the PSSH
790  std::vector<uint8_t> keyId;
791  playReadyHelper->getKey(keyId);
792 
793  const std::string expectedKeyId = "b5f2a6d7-dae6-eeb1-b87a-77247b275ab5";
794  const std::string actualKeyId = std::string(keyId.begin(), keyId.begin() + keyId.size());
795 
796  CHECK_EQUAL(expectedKeyId, actualKeyId);
797  // Not expecting any metadata
798  CHECK_EQUAL("", playReadyHelper->getDrmMetaData());
799 }
800 
801 TEST(AampDrmHelperTests, TestPlayReadyHelperGenerateLicenseRequest)
802 {
803  DrmInfo drmInfo = createDrmInfo(eMETHOD_NONE, eMEDIAFORMAT_DASH, "", "", "9a04f079-9840-4286-ab92-e65be0885f95");
804  CHECK_TRUE(AampDrmHelperEngine::getInstance().hasDRM(drmInfo));
805  std::shared_ptr<AampDrmHelper> playReadyHelper = AampDrmHelperEngine::getInstance().createHelper(drmInfo);
806 
807  AampChallengeInfo challengeInfo;
808  challengeInfo.url = "http://challengeinfourl.example";
809  std::string challengeData = "OCDM_CHALLENGE_DATA";
810 
811  challengeInfo.data = std::make_shared<DrmData>((unsigned char*)challengeData.data(), challengeData.length());
812  challengeInfo.accessToken = "ACCESS_TOKEN";
813 
814  // No PSSH parsed. Expecting data from the provided challenge to be given back in the request info
815  AampLicenseRequest licenseRequest1;
816  playReadyHelper->generateLicenseRequest(challengeInfo, licenseRequest1);
817  CHECK_EQUAL(challengeInfo.url, licenseRequest1.url);
818  MEMCMP_EQUAL(challengeInfo.data->getData().c_str(), licenseRequest1.payload.data(), challengeInfo.data->getDataLength());
819 
820  // Parse a PSSH with a ckm:policy. This should cause generateLicenseRequest to return a JSON payload
821  AampLicenseRequest licenseRequest2;
822  const std::string psshStr =
823  "<WRMHEADER xmlns=\"http://schemas.microsoft.com/DRM/2007/03/PlayReadyHeader\" version=\"4.0.0.0\">"
824  "<DATA>"
825  "<KID>16bytebase64enckeydata==</KID>"
826  "<ckm:policy xmlns:ckm=\"urn:ccp:ckm\">policy</ckm:policy>"
827  "</DATA>"
828  "</WRMHEADER>";
829  CHECK_TRUE(playReadyHelper->parsePssh((const unsigned char*)psshStr.data(), psshStr.size()));
830 
831  playReadyHelper->generateLicenseRequest(challengeInfo, licenseRequest2);
832  CHECK_EQUAL(challengeInfo.url, licenseRequest2.url);
833 
834  TestUtilJsonWrapper jsonWrapper(licenseRequest2.payload);
835  cJSON *postFieldObj = jsonWrapper.getJsonObj();
836  CHECK_TEXT(postFieldObj != NULL, "Invalid JSON challenge data");
837  CHECK_JSON_STR_VALUE(postFieldObj, "keySystem", "playReady");
838  CHECK_JSON_STR_VALUE(postFieldObj, "mediaUsage", "stream");
839  // For the licenseRequest we expect the base64 encoding of the string
840  // we placed in the challenge data: 'OCDM_CHALLENGE_DATA'
841  CHECK_JSON_STR_VALUE(postFieldObj, "licenseRequest", "T0NETV9DSEFMTEVOR0VfREFUQQ==");
842  CHECK_JSON_STR_VALUE(postFieldObj, "contentMetadata", "cG9saWN5");
843  CHECK_JSON_STR_VALUE(postFieldObj, "accessToken", challengeInfo.accessToken.c_str());
844 
845  // Finally, checking the license uri override works
846  AampLicenseRequest licenseRequest3;
847  const std::string fixedPrLicenseUrl = "http://prlicenseserver.example";
848  licenseRequest3.url = fixedPrLicenseUrl;
849 
850  playReadyHelper->generateLicenseRequest(challengeInfo, licenseRequest3);
851  CHECK_EQUAL(fixedPrLicenseUrl, licenseRequest3.url);
852 }
853 
854 TEST(AampDrmHelperTests, TestCompareHelpers)
855 {
856  std::shared_ptr<AampDrmHelper> vgdrmHelper = AampDrmHelperEngine::getInstance().createHelper(createDrmInfo(
859  "91701500000810367b131dd025ab0a7bd8d20c1314151600",
860  "A68129D3-575B-4F1A-9CBA-3223846CF7C3"));
861  CHECK_TRUE(vgdrmHelper != nullptr);
862 
863  std::shared_ptr<AampDrmHelper> playreadyHelper = AampDrmHelperEngine::getInstance().createHelper(createDrmInfo(
866  "file.key",
867  "",
868  "9a04f079-9840-4286-ab92-e65be0885f95"));
869  CHECK_TRUE(playreadyHelper != nullptr);
870 
871  std::shared_ptr<AampDrmHelper> widevineHelper = AampDrmHelperEngine::getInstance().createHelper(createDrmInfo(
874  "file.key",
875  "",
876  "edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"));
877  CHECK_TRUE(widevineHelper != nullptr);
878 
879  std::shared_ptr<AampDrmHelper> clearKeyHelperHls = AampDrmHelperEngine::getInstance().createHelper(createDrmInfo(
882  "file.key",
883  "",
884  "1077efec-c0b2-4d02-ace3-3c1e52e2fb4b"));
885  CHECK_TRUE(clearKeyHelperHls != nullptr);
886 
887  std::shared_ptr<AampDrmHelper> clearKeyHelperDash = AampDrmHelperEngine::getInstance().createHelper(createDrmInfo(
890  "file.key",
891  "",
892  "1077efec-c0b2-4d02-ace3-3c1e52e2fb4b"));
893  CHECK_TRUE(clearKeyHelperDash != nullptr);
894 
895  // All helpers should equal themselves
896  CHECK_TRUE(vgdrmHelper->compare(vgdrmHelper));
897  CHECK_TRUE(widevineHelper->compare(widevineHelper));
898  CHECK_TRUE(playreadyHelper->compare(playreadyHelper));
899  CHECK_TRUE(clearKeyHelperHls->compare(clearKeyHelperHls));
900 
901  // Different helper types, should not equal
902  CHECK_FALSE(vgdrmHelper->compare(playreadyHelper) || vgdrmHelper->compare(widevineHelper) || vgdrmHelper->compare(clearKeyHelperHls));
903  CHECK_FALSE(playreadyHelper->compare(vgdrmHelper) || playreadyHelper->compare(widevineHelper) || playreadyHelper->compare(clearKeyHelperHls));
904  CHECK_FALSE(widevineHelper->compare(vgdrmHelper) || widevineHelper->compare(playreadyHelper) || widevineHelper->compare(clearKeyHelperHls));
905 
906  // Same helper type but one is HLS and the other is DASH, so should not equal
907  CHECK_FALSE(clearKeyHelperHls->compare(clearKeyHelperDash));
908 
909  // Comparison against null helper, should not equal, should not cause a problem
910  std::shared_ptr<AampDrmHelper> nullHelper;
911  CHECK_FALSE(clearKeyHelperHls->compare(nullHelper));
912 
913  std::shared_ptr<AampDrmHelper> vgdrmHelper2 = AampDrmHelperEngine::getInstance().createHelper(createDrmInfo(
916  "91701500000810387b131dd025ab0a7bd8d20c1314151600", // Different key
917  "A68129D3-575B-4F1A-9CBA-3223846CF7C3"));
918  CHECK_TRUE(vgdrmHelper != nullptr);
919 
920  // Different key, should not equal
921  CHECK_FALSE(vgdrmHelper->compare(vgdrmHelper2));
922 
923  std::shared_ptr<AampDrmHelper> playreadyHelper2 = AampDrmHelperEngine::getInstance().createHelper(createDrmInfo(
926  "file.key",
927  "",
928  "9a04f079-9840-4286-ab92-e65be0885f95"));
929  CHECK_TRUE(playreadyHelper2 != nullptr);
930 
931  const std::string pssh1 =
932  "<WRMHEADER xmlns=\"http://schemas.microsoft.com/DRM/2007/03/PlayReadyHeader\" version=\"4.0.0.0\">"
933  "<DATA>"
934  "<KID>16bytebase64enckeydata==</KID>"
935  "</DATA>"
936  "</WRMHEADER>";
937  playreadyHelper->parsePssh((const unsigned char*)pssh1.data(), pssh1.size());
938  playreadyHelper2->parsePssh((const unsigned char*)pssh1.data(), pssh1.size());
939 
940  // Same key in the PSSH data, should equal
941  CHECK_TRUE(playreadyHelper->compare(playreadyHelper2));
942 
943  const std::string pssh2 =
944  "<WRMHEADER xmlns=\"http://schemas.microsoft.com/DRM/2007/03/PlayReadyHeader\" version=\"4.0.0.0\">"
945  "<DATA>"
946  "<KID>differentbase64keydata==</KID>"
947  "</DATA>"
948  "</WRMHEADER>";
949  playreadyHelper2->parsePssh((const unsigned char*)pssh2.data(), pssh2.size());
950 
951  // Different key in the PSSH data, should not equal
952  CHECK_FALSE(playreadyHelper->compare(playreadyHelper2));
953 
954  // Create another PR helper, same details as PR helper 1
955  std::shared_ptr<AampDrmHelper> playreadyHelper3 = AampDrmHelperEngine::getInstance().createHelper(createDrmInfo(
958  "file.key",
959  "",
960  "9a04f079-9840-4286-ab92-e65be0885f95"));
961  CHECK_TRUE(playreadyHelper3 != nullptr);
962 
963  // But no PSSH parsed for the 3rd PR helper, so shouldn't be equal
964  CHECK_FALSE(playreadyHelper->compare(playreadyHelper3));
965 
966  // Parse the same PSSH as used for 1, now should be equal
967  playreadyHelper3->parsePssh((const unsigned char*)pssh1.data(), pssh1.size());
968  CHECK_TRUE(playreadyHelper->compare(playreadyHelper3));
969 
970  // Finally keep the same key but add in metadata. Now PR helpers 1 & 3 shouldn't be equal
971  const std::string pssh3 =
972  "<WRMHEADER xmlns=\"http://schemas.microsoft.com/DRM/2007/03/PlayReadyHeader\" version=\"4.0.0.0\">"
973  "<DATA>"
974  "<KID>16bytebase64enckeydata==</KID>"
975  "<ckm:policy xmlns:ckm=\"urn:ccp:ckm\">policy</ckm:policy>"
976  "</DATA>"
977  "</WRMHEADER>";
978  playreadyHelper3->parsePssh((const unsigned char*)pssh3.data(), pssh3.size());
979  CHECK_FALSE(playreadyHelper->compare(playreadyHelper3));
980 }
eDRM_WideVine
@ eDRM_WideVine
Definition: AampDrmSystems.h:36
DrmInfo::keyURI
std::string keyURI
Definition: AampDrmInfo.h:87
AampDrmHelper.h
Implented DRM helper functionalities.
eDRM_PlayReady
@ eDRM_PlayReady
Definition: AampDrmSystems.h:37
DrmMethod
DrmMethod
DRM method.
Definition: AampDrmInfo.h:36
AampDrmHelperEngine::getInstance
static AampDrmHelperEngine & getInstance()
Get an instance of the DRM Helper Engine.
Definition: AampDrmHelperFactory.cpp:37
DrmInfo::manifestURL
std::string manifestURL
Definition: AampDrmInfo.h:86
AampChallengeInfo::data
std::shared_ptr< DrmData > data
Definition: AampDrmHelper.h:46
AampChallengeInfo::accessToken
std::string accessToken
Definition: AampDrmHelper.h:49
eMEDIAFORMAT_DASH
@ eMEDIAFORMAT_DASH
Definition: AampDrmMediaFormat.h:35
AampLicenseRequest::DRM_RETRIEVE
@ DRM_RETRIEVE
Definition: AampDrmHelper.h:63
AampLicenseRequest
Holds the data to get the License.
Definition: AampDrmHelper.h:57
DrmInfo::systemUUID
std::string systemUUID
Definition: AampDrmInfo.h:89
DrmInfo::initData
std::string initData
Definition: AampDrmInfo.h:90
DrmInfo
DRM information required to decrypt.
Definition: AampDrmInfo.h:47
AampChallengeInfo::url
std::string url
Definition: AampDrmHelper.h:48
DrmInfo::keyFormat
std::string keyFormat
Definition: AampDrmInfo.h:88
TestUtilJsonWrapper
Definition: drmTestUtils.h:12
AampConfig.h
Configurations for AAMP.
eMETHOD_AES_128
@ eMETHOD_AES_128
Definition: AampDrmInfo.h:39
eMEDIAFORMAT_HLS
@ eMEDIAFORMAT_HLS
Definition: AampDrmMediaFormat.h:34
AampLicenseRequest::POST
@ POST
Definition: AampDrmHelper.h:65
AampDrmHelperEngine::getSystemIds
void getSystemIds(std::vector< std::string > &ids) const
Get the supported OCDM system IDs.
Definition: AampDrmHelperFactory.cpp:57
eMEDIAFORMAT_HLS_MP4
@ eMEDIAFORMAT_HLS_MP4
Definition: AampDrmMediaFormat.h:37
DrmInfo::method
DrmMethod method
Definition: AampDrmInfo.h:79
AampChallengeInfo
Aamp challenge info to get the License.
Definition: AampDrmHelper.h:44
DrmInfo::mediaFormat
MediaFormat mediaFormat
Definition: AampDrmInfo.h:80
MediaFormat
MediaFormat
Media format types.
Definition: AampDrmMediaFormat.h:32
AampDrmHelperEngine::createHelper
std::shared_ptr< AampDrmHelper > createHelper(const struct DrmInfo &drmInfo, AampLogManager *logObj=NULL) const
Build a helper class to support the identified DRM.
Definition: AampDrmHelperFactory.cpp:69