test_sw_video_decoding.html (4639B)
1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <title>Test video software decoding</title> 5 <script src="/tests/SimpleTest/SimpleTest.js"></script> 6 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 7 <script type="application/javascript"> 8 9 /** 10 * This test verifies that software video decoding is correctly executed on the 11 * appropriate process and utilizes the correct decoder across various platforms. 12 */ 13 // TODO : as on Android we still don't have RDD process, add Android test cases 14 // later in bug 1974849. 15 const gTestCases = [ 16 { 17 codec : "H264", 18 files: ["gizmo.mp4"], 19 platforms : { 20 WINNT : { 21 decoder : "wmf H264 codec software video decoder", 22 process : "RDD", 23 }, 24 Darwin : { 25 decoder: "apple software VT decoder", 26 process : "RDD", 27 }, 28 Linux : { 29 decoder: "ffmpeg video decoder", 30 process : "RDD", 31 }, 32 } 33 }, 34 { 35 codec : "VP8", 36 files: ["bipbop_short_vp8.webm"], 37 platforms : { 38 WINNT : { 39 decoder : "ffvpx video decoder", 40 process : "RDD", 41 }, 42 Darwin : { 43 decoder: "ffvpx video decoder", 44 process : "RDD", 45 }, 46 Linux : { 47 decoder: "ffvpx video decoder", 48 process : "RDD", 49 }, 50 } 51 }, 52 { 53 codec : "VP9", 54 files: ["gizmo.webm"], 55 platforms : { 56 WINNT : { 57 decoder : "ffvpx video decoder", 58 process : "RDD", 59 }, 60 Darwin : { 61 decoder: "ffvpx video decoder", 62 process : "RDD", 63 }, 64 Linux : { 65 decoder: "ffvpx video decoder", 66 process : "RDD", 67 }, 68 } 69 }, 70 { 71 codec : "AV1", 72 files: [ 73 "av1.mp4", 74 "gizmo_av1_8bit_420.webm", 75 "gizmo_av1_10bit_420.webm", 76 ], 77 platforms : { 78 WINNT : { 79 decoder : "ffvpx video decoder", 80 process : "RDD", 81 }, 82 Darwin : { 83 decoder: "ffvpx video decoder", 84 process : "RDD", 85 }, 86 Linux : { 87 decoder: "ffvpx video decoder", 88 process : "RDD", 89 }, 90 } 91 }, 92 { 93 // HEVC SW decoder is added since MacOS 10.13, and since ffmpeg 2.0.2. 94 codec : "HEVC", 95 files: [ 96 "gizmo_hevc_8bit_420.mp4", 97 "gizmo_hevc_10bit_420.mp4", 98 ], 99 platforms : { 100 // Our MacOS 10.15 workers on the try server somehow do not support 101 // HEVC SW, but MacOS 15 does. We may consider enabling this when 102 // all workers have HEVC SW support in the future. 103 // Darwin : { 104 // decoder: "apple software VT decoder", 105 // process : "RDD", 106 // }, 107 Linux : { 108 decoder: "ffmpeg video decoder", 109 process : "RDD", 110 }, 111 } 112 }, 113 ]; 114 115 add_task(async function testSoftwareVideoDecoding() { 116 const platformName = SpecialPowers.Services.appinfo.OS; 117 for (let {codec, files, platforms} of gTestCases) { 118 let platformData = platforms[platformName]; 119 if (platformData === undefined) { 120 ok(true, `skip ${codec} test on ${platformName}`); 121 continue; 122 } 123 info(`run ${codec} SW test on ${platformName}`); 124 for (let file of files) { 125 await createAndPlayVideo(file); 126 await assertRunningProcessAndDecoderName({ 127 expectedProcess: platformData.process, 128 expectedDecoder: platformData.decoder, 129 }); 130 } 131 } 132 }); 133 134 // Following are helper functions 135 async function createAndPlayVideo(fileUrl) { 136 let video = document.querySelector("video"); 137 if (!video) { 138 video = document.createElement("video"); 139 document.body.appendChild(video); 140 } 141 video.src = fileUrl; 142 video.loop = true; 143 ok( 144 await video.play().then( 145 () => true, 146 () => false 147 ), 148 "video started playing" 149 ); 150 } 151 152 async function assertRunningProcessAndDecoderName( 153 { expectedProcess, expectedDecoder } = {} 154 ) { 155 const video = document.querySelector("video"); 156 ok(!video.paused, "checking a playing video that should be sw decoding"); 157 158 const debugInfo = await SpecialPowers.wrap(video).mozRequestDebugInfo(); 159 const videoDecoderName = debugInfo.decoder.reader.videoDecoderName; 160 161 is(debugInfo.decoder.reader.videoHardwareAccelerated, false, 162 `decoder should not be hardware accelerated`); 163 164 const isExpectedDecoder = 165 videoDecoderName.indexOf(`${expectedDecoder}`) == 0; 166 ok( 167 isExpectedDecoder, 168 `Playback running by decoder '${videoDecoderName}', expected '${expectedDecoder}'` 169 ); 170 171 const isExpectedProcess = 172 videoDecoderName.indexOf(`(${expectedProcess} remote)`) > 0; 173 ok( 174 isExpectedProcess, 175 `Playback running in process '${videoDecoderName}', expected '${expectedProcess}'` 176 ); 177 } 178 179 </script> 180 </head> 181 <body> 182 </body> 183 </html>