Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!DOCTYPE html> | |
| 2 <html> | |
| 3 <head> | |
| 4 <title>Clear Key Playback with Multiple Sessions</title> | |
| 5 <script src="encrypted-media-utils.js"></script> | |
| 6 <script src="../w3c-media-utils.js"></script> | |
| 7 <script src="../../resources/testharness.js"></script> | |
| 8 <script src="../../resources/testharnessreport.js"></script> | |
| 9 </head> | |
| 10 <body> | |
| 11 <video id="testVideo"></video> | |
| 12 <div id="log"></div> | |
| 13 <p>Test playback of encrypted media using Clear Key key system with mult iple sessions.</p> | |
| 14 <script> | |
| 15 setup({ timeout: 60000 }); // Timeout for all tests to run. | |
| 16 | |
| 17 async_test(function(test) | |
| 18 { | |
| 19 var video = document.getElementById("testVideo"); | |
| 20 var mediaKeys = new MediaKeys("org.w3.clearkey"); | |
| 21 var audioMediaKeySession = null; | |
| 22 var videoMediaKeySession = null; | |
| 23 var audioKeyProvided = false; | |
| 24 var videoKeyProvided = false; | |
| 25 | |
| 26 // The 2 streams use different key ids and different keys. | |
| 27 var audioKeyId = "1234567890123456"; | |
| 28 var audioKey = new Uint8Array([0x30, 0x30, 0x62, 0xF1, 0x68, 0x1 4, 0xD2, 0x7B, | |
| 29 0x68, 0xEF, 0x12, 0x2A, 0xFC, 0xE 4, 0xAE, 0x0A]); | |
| 30 var videoKeyId = "0123456789012345"; | |
| 31 var videoKey = new Uint8Array([0x7A, 0x7A, 0x62, 0xF1, 0x68, 0x1 4, 0xD2, 0x7B, | |
| 32 0x68, 0xEF, 0x12, 0x2A, 0xFC, 0xE 4, 0xAE, 0x0A]); | |
| 33 | |
| 34 function onNeedKey(event) | |
| 35 { | |
| 36 var keyId = String.fromCharCode.apply(null, event.initData); | |
| 37 var newSession = mediaKeys.createSession(event.contentType, event.initData); | |
| 38 if (keyId == videoKeyId) { | |
| 39 assert_equals(videoMediaKeySession, null); | |
| 40 videoMediaKeySession = newSession; | |
| 41 } else { | |
| 42 assert_equals(keyId, audioKeyId); | |
| 43 assert_equals(audioMediaKeySession, null); | |
| 44 audioMediaKeySession = newSession; | |
| 45 } | |
| 46 waitForEventAndRunStep("message", newSession, onMessage, tes t); | |
| 47 } | |
| 48 | |
| 49 function onMessage(event) | |
| 50 { | |
| 51 var keyId = event.message; | |
| 52 if (event.target == videoMediaKeySession) { | |
| 53 assert_equals(String.fromCharCode.apply(null, keyId), vi deoKeyId); | |
| 54 var jwkSet = stringToUint8Array(createJWKSet(createJWK(k eyId, videoKey))); | |
| 55 videoMediaKeySession.update(jwkSet); | |
| 56 videoKeyProvided = true; | |
| 57 } else { | |
| 58 assert_equals(event.target, audioMediaKeySession); | |
| 59 assert_equals(String.fromCharCode.apply(null, keyId), au dioKeyId); | |
| 60 var jwkSet = stringToUint8Array(createJWKSet(createJWK(k eyId, audioKey))); | |
| 61 audioMediaKeySession.update(jwkSet); | |
| 62 audioKeyProvided = true; | |
| 63 } | |
| 64 } | |
| 65 | |
| 66 function onPlaying(event) | |
| 67 { | |
| 68 // Video should not start playing until both keys have been | |
| 69 // provided. | |
| 70 assert_true(videoKeyProvided); | |
| 71 assert_true(audioKeyProvided); | |
| 72 | |
| 73 // Not using waitForEventAndRunStep() to avoid too many | |
|
ddorwin
2014/03/21 20:25:59
This is fine, but note that there's no line length
| |
| 74 // EVENT(onTimeUpdate) logs. | |
| 75 video.addEventListener("timeupdate", onTimeUpdate, true); | |
| 76 } | |
| 77 | |
| 78 function onTimeUpdate(event) | |
| 79 { | |
| 80 if (event.target.currentTime < 0.2) | |
| 81 return; | |
| 82 | |
| 83 test.done(); | |
| 84 } | |
| 85 | |
| 86 waitForEventAndRunStep("needkey", video, onNeedKey, test); | |
| 87 waitForEventAndRunStep("playing", video, onPlaying, test); | |
| 88 | |
| 89 video.src = "../content/test-encrypted-different-av-keys.webm"; | |
| 90 video.setMediaKeys(mediaKeys); | |
| 91 video.play(); | |
| 92 }, "Playback using Clear Key key system with multiple sessions.", | |
| 93 { timeout: 60000 }); | |
| 94 </script> | |
| 95 </body> | |
| 96 </html> | |
| OLD | NEW |