1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
|
<!DOCTYPE HTML>
<html>
<head>
<title>Test video hardware decoding</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script type="application/javascript">
/**
* This test is used to check hardware video decoding on different platforms.
*/
const FFVPX_HW = "media.ffvpx-hw.enabled";
const PLATFORMS = {
// TODO : add Linux and Android, media-gpu doesn't run on them yet
WINNT: {
process: "GPU",
tests: [
{
files: ["gizmo.mp4"],
decoder: "wmf H264 codec hardware video decoder",
},
{
files: ["gizmo.webm"],
decoder: "ffvpx video decoder",
},
{
files: ["gizmo.webm"],
disableFFVPXHW : true,
decoder: "wmf VP9 codec hardware video decoder",
},
{
files: [
"gizmo_av1_8bit_420.webm",
"gizmo_av1_10bit_420.webm",
"av1-yuv420p.mp4",
],
decoder: "ffvpx video decoder",
},
{
files: [
"gizmo_av1_8bit_420.webm",
"gizmo_av1_10bit_420.webm"
],
disableFFVPXHW : true,
decoder: "wmf AV1 codec hardware video decoder",
},
],
},
Darwin: {
process: "RDD",
tests: [
{
files: ["gizmo.mp4"], // H264
decoder: "apple hardware VT decoder",
},
{
files: ["gizmo_hevc_8bit_420.mp4"], // HEVC
decoder: "apple hardware VT decoder",
},
// TODO : enable VP9 for MacOS. The current machine on CI doesn't support
// VP9 HW. See bug 1861741.
// {
// file: "gizmo.webm",
// decoder: "apple hardware VT decoder",
// },
],
},
};
add_task(async function testHardwareVideoDecoding() {
const platformName = SpecialPowers.Services.appinfo.OS;
const platformTest = PLATFORMS[platformName];
for (const test of platformTest.tests) {
for (const file of test.files) {
info(
`Testing ${file} on ${platformName} : expect ${test.decoder} in ${platformTest.process}`
);
// Disable ffvpx hw if needed
if (test.disableFFVPXHW !== undefined) {
await SpecialPowers.pushPrefEnv({
set: [[FFVPX_HW, false]],
});
}
await createAndPlayVideo(file);
await assertRunningProcessAndDecoderName({
expectedProcess: platformTest.process,
expectedDecoder: test.decoder,
});
// Reset ffvpx hw pref in order not to interfere next test case
if (test.disableFFVPXHW !== undefined) {
await SpecialPowers.pushPrefEnv({
set: [[FFVPX_HW, true]],
});
}
}
}
});
// Following are helper functions
async function createAndPlayVideo(fileUrl) {
let video = document.querySelector("video");
if (!video) {
video = document.createElement("video");
document.body.appendChild(video);
}
video.src = fileUrl;
video.loop = true;
ok(
await video.play().then(
() => true,
() => false
),
"video started playing"
);
}
async function assertRunningProcessAndDecoderName(
{ expectedProcess, expectedDecoder } = {}
) {
const video = document.querySelector("video");
ok(!video.paused, "checking a playing video that should be hw decoding");
const debugInfo = await SpecialPowers.wrap(video).mozRequestDebugInfo();
const videoDecoderName = debugInfo.decoder.reader.videoDecoderName;
const isExpectedDecoder =
videoDecoderName.indexOf(`${expectedDecoder}`) == 0;
ok(
isExpectedDecoder,
`Playback running by decoder '${videoDecoderName}', expected '${expectedDecoder}'`
);
const isExpectedProcess =
videoDecoderName.indexOf(`(${expectedProcess} remote)`) > 0;
ok(
isExpectedProcess,
`Playback running in process '${videoDecoderName}', expected '${expectedProcess}'`
);
}
</script>
</head>
<body>
</body>
</html>
|