-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RemoteVideoEncoderCallbacks and RemoteVideoDecoderCallbacks HashMaps …
…could be corrupted by JS https://bugs.webkit.org/show_bug.cgi?id=258123 rdar://110777506 Reviewed by Eric Carlson. JS can provide signed timestamps, which are used as keys in RemoteVideoDecoderCallbacks and RemoteVideoEncoderCallbacks maps. Move to StdUnorderedMap to support all keys. * LayoutTests/http/wpt/webcodecs/videoFrame-negative-timestamp-expected.txt: Added. * LayoutTests/http/wpt/webcodecs/videoFrame-negative-timestamp.html: Added. * Source/WebKit/WebProcess/GPU/media/RemoteVideoCodecFactory.cpp: (WebKit::RemoteVideoDecoderCallbacks::addDuration): (WebKit::RemoteVideoEncoderCallbacks::addDuration): (WebKit::RemoteVideoDecoderCallbacks::notifyDecodingResult): (WebKit::RemoteVideoEncoderCallbacks::notifyEncodedChunk): Canonical link: https://commits.webkit.org/259548.831@safari-7615-branch
- Loading branch information
Showing
3 changed files
with
110 additions
and
6 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
LayoutTests/http/wpt/webcodecs/videoFrame-negative-timestamp-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
PASS VP8 decoded frames | ||
PASS VP9 decoded frames | ||
PASS H.264 decoded frames | ||
|
90 changes: 90 additions & 0 deletions
90
LayoutTests/http/wpt/webcodecs/videoFrame-negative-timestamp.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<header> | ||
<script src='/resources/testharness.js'></script> | ||
<script src='/resources/testharnessreport.js'></script> | ||
</header> | ||
<body> | ||
<script> | ||
|
||
function makeOffscreenCanvas(width, height, timestamp) { | ||
let canvas = new OffscreenCanvas(width, height); | ||
let ctx = canvas.getContext('2d'); | ||
ctx.fillStyle = 'rgba(50, 100, 150, 255)'; | ||
ctx.fillRect(0, 0, width, height); | ||
return new VideoFrame(canvas, { timestamp, duration : 10 }); | ||
} | ||
|
||
async function doEncodeDecode(encoderConfig, timestamp) | ||
{ | ||
let resolve, reject; | ||
const promise = new Promise((res, rej) => { | ||
resolve = res; | ||
reject = rej; | ||
}); | ||
|
||
const decoder = new VideoDecoder({ | ||
output(frame) { | ||
resolve(frame); | ||
}, | ||
error(e) { | ||
reject(e.message); | ||
} | ||
}); | ||
|
||
const encoderInit = { | ||
output(chunk, metadata) { | ||
let config = metadata.decoderConfig; | ||
if (config) { | ||
decoder.configure(config); | ||
} | ||
decoder.decode(chunk); | ||
}, | ||
error(e) { | ||
reject(e.message); | ||
} | ||
}; | ||
|
||
const encoder = new VideoEncoder(encoderInit); | ||
encoder.configure(encoderConfig); | ||
|
||
const w = encoderConfig.width; | ||
const h = encoderConfig.height; | ||
const frame = makeOffscreenCanvas(w, h, timestamp); | ||
encoder.encode(frame, { keyFrame: true }); | ||
frame.close(); | ||
|
||
await encoder.flush(); | ||
await decoder.flush(); | ||
encoder.close(); | ||
decoder.close(); | ||
|
||
return promise; | ||
} | ||
|
||
function doTest(codec, title) | ||
{ | ||
const config = { codec }; | ||
config.width = 320; | ||
config.height = 200; | ||
config.bitrate = 1000000; | ||
config.framerate = 30; | ||
|
||
promise_test(async t => { | ||
const frame1 = await doEncodeDecode(config, -2); | ||
t.add_cleanup(() => frame1.close()); | ||
|
||
const frame2 = await doEncodeDecode(config, -1); | ||
t.add_cleanup(() => frame2.close()); | ||
|
||
const frame3 = await doEncodeDecode(config, 0); | ||
t.add_cleanup(() => frame3.close()); | ||
}, title); | ||
} | ||
|
||
doTest('vp8', "VP8 decoded frames"); | ||
doTest('vp09.00.10.08', "VP9 decoded frames"); | ||
doTest('avc1.42001E', "H.264 decoded frames"); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters