mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-11 16:32:59 +00:00
Bug 1351124 - Test for PSSH boxes in MOOF boxes. r=jya
Includes "bear" samples from the Chromium project which include several runs of PSSH boxes in their MOOF boxes. MozReview-Commit-ID: 4KIJ2FCOyWT --HG-- rename : dom/media/test/short-cenc.mp4 => dom/media/test/short-cenc-pssh-in-moof.mp4 extra : rebase_source : 29cd7ea0e3b76935d76e376ee0f88f4c93aca85d
This commit is contained in:
parent
87ce56017f
commit
965450cd7c
BIN
dom/media/test/bear-640x360-a_frag-cenc-key_rotation.mp4
Normal file
BIN
dom/media/test/bear-640x360-a_frag-cenc-key_rotation.mp4
Normal file
Binary file not shown.
BIN
dom/media/test/bear-640x360-v_frag-cenc-key_rotation.mp4
Normal file
BIN
dom/media/test/bear-640x360-v_frag-cenc-key_rotation.mp4
Normal file
Binary file not shown.
@ -49,6 +49,8 @@ support-files =
|
||||
badtags.ogg^headers^
|
||||
basic.vtt
|
||||
bad-signature.vtt
|
||||
bear-640x360-v_frag-cenc-key_rotation.mp4
|
||||
bear-640x360-a_frag-cenc-key_rotation.mp4
|
||||
beta-phrasebook.ogg
|
||||
beta-phrasebook.ogg^headers^
|
||||
big.wav
|
||||
@ -738,6 +740,8 @@ skip-if = toolkit == 'android' # bug 1336166
|
||||
[test_delay_load.html]
|
||||
skip-if = android_version == '17' # android(bug 1232305)
|
||||
[test_duration_after_error.html]
|
||||
[test_eme_pssh_in_moof.html]
|
||||
skip-if = toolkit == 'android' # bug 1149374
|
||||
[test_eme_session_callable_value.html]
|
||||
[test_eme_canvas_blocked.html]
|
||||
skip-if = toolkit == 'android' # bug 1149374
|
||||
|
BIN
dom/media/test/short-cenc-pssh-in-moof.mp4
Normal file
BIN
dom/media/test/short-cenc-pssh-in-moof.mp4
Normal file
Binary file not shown.
142
dom/media/test/test_eme_pssh_in_moof.html
Normal file
142
dom/media/test/test_eme_pssh_in_moof.html
Normal file
@ -0,0 +1,142 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<title>Test Encrypted Media Extensions</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
<script type="text/javascript" src="manifest.js"></script>
|
||||
<script type="text/javascript" src="eme.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<video controls id="video"></video>
|
||||
<div id="log"></div>
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function e(id) {
|
||||
return document.getElementById(id);
|
||||
}
|
||||
|
||||
function log(msg) {
|
||||
var log_pane = e('log');
|
||||
log_pane.appendChild(document.createTextNode(msg));
|
||||
log_pane.appendChild(document.createElement("br"));
|
||||
}
|
||||
|
||||
function DownloadMedia(url, type, mediaSource) {
|
||||
return new Promise((resolve, reject) => {
|
||||
var sourceBuffer = mediaSource.addSourceBuffer(type);
|
||||
fetch(url)
|
||||
.then((response) => { return response.arrayBuffer(); })
|
||||
.then((arrayBuffer) => {
|
||||
once(sourceBuffer, "updateend", resolve);
|
||||
sourceBuffer.appendBuffer(arrayBuffer);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function LoadMSE(video, tracks) {
|
||||
var ms = new MediaSource();
|
||||
video.src = URL.createObjectURL(ms);
|
||||
once(ms, "sourceopen", () => {
|
||||
Promise.all(tracks.map(track => DownloadMedia(track.url, track.type, ms)))
|
||||
.then(() => {
|
||||
ms.endOfStream();
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
function CreateMediaKeys(video, configurations) {
|
||||
return navigator.requestMediaKeySystemAccess("org.w3.clearkey", configurations)
|
||||
.then((keySystemAccess) => {
|
||||
return keySystemAccess.createMediaKeys();
|
||||
}, bail("Failed to request key system access."))
|
||||
|
||||
.then((mediaKeys) => {
|
||||
video.mediaKeys = mediaKeys;
|
||||
return video.setMediaKeys(mediaKeys);
|
||||
}, bail("Failed to set media keys."));
|
||||
}
|
||||
|
||||
var encryptedEventCount = 0;
|
||||
|
||||
var initDatas = new Map();
|
||||
|
||||
var keys = {
|
||||
"30313233343536373839303132333435" : "ebdd62f16814d27b68ef122afce4ae3c"
|
||||
};
|
||||
|
||||
function handleEncrypted(event) {
|
||||
// We get one 'encrypted' event for every run of contiguous PSSH boxes
|
||||
// in each stream. Note that some of the PSSH boxes contained in the
|
||||
// "bear" streams aren't in the Common Open PSSH box format, so our
|
||||
// ClearKey CDM will reject those license requests. Some of the init
|
||||
// data is also repeated.
|
||||
encryptedEventCount++;
|
||||
|
||||
var hexStr = StringToHex(new TextDecoder().decode(event.initData));
|
||||
if (initDatas.has(hexStr)) {
|
||||
// Already have a session for this.
|
||||
return;
|
||||
}
|
||||
initDatas.set(hexStr, session);
|
||||
|
||||
var initData = new Uint8Array(event.initData);
|
||||
log("encrypted event => len=" + initData.length + " " + hexStr);
|
||||
var session = event.target.mediaKeys.createSession();
|
||||
session.addEventListener("message", function(event) {
|
||||
event.target.update(GenerateClearKeyLicense(event.message, keys));
|
||||
});
|
||||
|
||||
session.generateRequest(event.initDataType, event.initData);
|
||||
}
|
||||
|
||||
const videoContentType = "video/mp4; codecs=\"avc1.64000d\"";
|
||||
const audioContentType = "audio/mp4; codecs=\"mp4a.40.2\"";
|
||||
|
||||
var tracks = [
|
||||
{
|
||||
type: videoContentType,
|
||||
url: "bear-640x360-v_frag-cenc-key_rotation.mp4",
|
||||
initDatas: 6,
|
||||
},
|
||||
{
|
||||
type: audioContentType,
|
||||
url: "bear-640x360-a_frag-cenc-key_rotation.mp4",
|
||||
initDatas: 7,
|
||||
}
|
||||
];
|
||||
|
||||
var configurations = [{
|
||||
initDataTypes: ["cenc"],
|
||||
audioCapabilities: [{
|
||||
contentType: audioContentType
|
||||
}],
|
||||
videoCapabilities: [{
|
||||
contentType: videoContentType
|
||||
}]
|
||||
}];
|
||||
|
||||
var video = document.getElementById("video");
|
||||
|
||||
video.addEventListener("encrypted", handleEncrypted, false);
|
||||
|
||||
video.addEventListener("ended", ()=>{
|
||||
var expectedEncryptedEvents = tracks.reduce((sum, track) => sum += track.initDatas, 0);
|
||||
is(encryptedEventCount, expectedEncryptedEvents, "Should get one 'encrypted' event per run of contiguous PSSH boxes in media.");
|
||||
SimpleTest.finish();
|
||||
});
|
||||
|
||||
video.autoplay = true;
|
||||
|
||||
CreateMediaKeys(video, configurations)
|
||||
.then(()=>{
|
||||
LoadMSE(video, tracks);
|
||||
});
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user