Source code

Revision control

Copy as Markdown

Other Tools

Test Info: Warnings

<!DOCTYPE HTML>
<html>
<head>
<title>Test HEVC video playback</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="manifest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script type="application/javascript">
/**
* This test is used to check whether non-MSE HEVC video can be played on the
* platform. HEVC can only be played if we have platform decoder supports
* hardware decoding. Currently we can only do that on Windows.
*/
add_task(async function testHEVCPlayback() {
let video = document.createElement('video');
info(`try to play HEVC video`);
video.src = "hevc_white_frame.mp4";
video.controls = true;
document.body.appendChild(video);
ok(await video.play().then(_=>true, _=>false), "video started playing");
ok(await new Promise(r => video.onended = r).then(_=>true, _=>false),
"video played to end");
removeNodeAndSource(video);
});
// This test video contains an inband SPS that is different from the SPS in the
// extradata, so we would recreate a new decoder.
add_task(async function testHEVCInbandConfigChange() {
let video = document.createElement('video');
info(`try to play HEVC video`);
video.src = "hevc_white_red_frames.mp4";
video.playbackRate = 2.0; // speed up the test.
video.controls = true;
document.body.appendChild(video);
ok(await video.play().then(_=>true, _=>false), "video started playing");
// This video contains two resolutions, so we should expect to receive a
// resize event during the playback.
await Promise.all([
new Promise(r => video.onended = r),
new Promise(r => video.onresize = r)
]);
ok(true, "video played to end and got a resize");
removeNodeAndSource(video);
});
add_task(async function test8BitAnd10BitHEVC() {
const files = ['gizmo_hevc_8bit_420.mp4', 'gizmo_hevc_10bit_420.mp4'];
for (let file of files) {
let video = document.createElement('video');
info(`try to play ${file}`);
video.src = file;
video.controls = true;
document.body.appendChild(video);
ok(await video.play().then(_=>true, _=>false), "video started playing");
ok(await new Promise(r => video.onended = r).then(_=>true, _=>false),
"video played to end");
removeNodeAndSource(video);
}
});
add_task(async function testHEVCAspectRatio() {
// The video resolution is 1440x1080, but its Display Aspect Ratio (DAR) is
// influenced by different Sample Aspect Ratios (SARs), which adjust how the
// image is stretched when displayed.
const tests = [
{ file: 'aspect_ratio_4_3_hevc.mp4',
expectedWidth: 1920,
expectedHeight: 1080,
}, {
file: 'aspect_ratio_5_2_hevc.mp4',
expectedWidth: 3600,
expectedHeight: 1080,
}];
for (let test of tests) {
let video = document.createElement('video');
info(`try to play ${test.file}`);
video.src = test.file;
video.controls = true;
document.body.appendChild(video);
ok(await video.play().then(_=>true, _=>false), "video started playing");
is(video.videoWidth, test.expectedWidth, `expect width ${test.expectedWidth}, actual width ${video.videoWidth}`);
is(video.videoHeight, test.expectedHeight, `expect height ${test.expectedHeight}, actual height ${video.videoHeight}`);
ok(await new Promise(r => video.onended = r).then(_=>true, _=>false),
"video played to end");
removeNodeAndSource(video);
}
});
</script>
</head>
<body>
</body>
</html>