Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[webcodecs] Deprecate VideoFrame.destroy(). #27194

Merged
merged 1 commit into from Jan 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion webcodecs/video-decoder.any.js
Expand Up @@ -199,7 +199,7 @@ promise_test(async t => {
assert_equals(frame.cropWidth, 320, "cropWidth");
assert_equals(frame.cropHeight, 240, "cropHeight");
assert_equals(frame.timestamp, 0, "timestamp");
frame.destroy();
frame.close();
});
},
error(e) {
Expand Down
9 changes: 4 additions & 5 deletions webcodecs/video-encoder.any.js
Expand Up @@ -222,14 +222,14 @@ promise_test(async t => {

encoder.encode(frame);

// |frame| is not longer valid since it has been destroyed.
// |frame| is not longer valid since it has been closed.
assert_not_equals(frame.timestamp, timestamp);
assert_throws_dom("InvalidStateError", () => frame.clone());

encoder.close();

return endAfterEventLoopTurn();
}, 'Test encoder consumes (destroys) frames.');
}, 'Test encoder consumes (closes) frames.');

promise_test(async t => {
let encoder = new VideoEncoder(getDefaultCodecInit(t));
Expand All @@ -251,12 +251,11 @@ promise_test(async t => {
let encoder = new VideoEncoder(getDefaultCodecInit(t));

let frame = await createVideoFrame(640, 480, 0);
frame.destroy();
frame.close();

encoder.configure(defaultConfig);

frame.destroy();
assert_throws_dom("OperationError", () => {
encoder.encode(frame)
});
}, 'Verify encoding destroyed frames throws.');
}, 'Verify encoding closed frames throws.');
28 changes: 14 additions & 14 deletions webcodecs/video-frame-serialization.any.js
Expand Up @@ -25,8 +25,8 @@ test(t => {
assert_equals(frame.cropWidth, clone.cropWidth);
assert_equals(frame.cropHeight, clone.cropHeight);

frame.destroy();
clone.destroy();
frame.close();
clone.close();
}, 'Test we can clone a VideoFrame.');

test(t => {
Expand All @@ -35,23 +35,23 @@ test(t => {
let copy = frame;
let clone = frame.clone();

frame.destroy();
frame.close();

assert_not_equals(copy.timestamp, defaultInit.timestamp);
assert_equals(clone.timestamp, defaultInit.timestamp);

clone.destroy();
}, 'Verify destroying a frame doesn\'t affect its clones.');
clone.close();
}, 'Verify closing a frame doesn\'t affect its clones.');

test(t => {
let frame = createDefaultVideoFrame();

frame.destroy();
frame.close();

assert_throws_dom("InvalidStateError", () => {
let clone = frame.clone();
});
}, 'Verify cloning a destroyed frame throws.');
}, 'Verify cloning a closed frame throws.');

async_test(t => {
let localFrame = createDefaultVideoFrame();
Expand All @@ -62,7 +62,7 @@ async_test(t => {

externalPort.onmessage = t.step_func((e) => {
let externalFrame = e.data;
externalFrame.destroy();
externalFrame.close();
externalPort.postMessage("Done");
})

Expand All @@ -72,7 +72,7 @@ async_test(t => {

localPort.postMessage(localFrame);

}, 'Verify destroying frames propagates accross contexts.');
}, 'Verify closing frames propagates accross contexts.');

async_test(t => {
let localFrame = createDefaultVideoFrame();
Expand All @@ -83,18 +83,18 @@ async_test(t => {

externalPort.onmessage = t.step_func((e) => {
let externalFrame = e.data;
externalFrame.destroy();
externalFrame.close();
externalPort.postMessage("Done");
})

localPort.onmessage = t.step_func_done((e) => {
assert_equals(localFrame.timestamp, defaultInit.timestamp);
localFrame.destroy();
localFrame.close();
})

localPort.postMessage(localFrame.clone());

}, 'Verify destroying cloned frames doesn\'t propagate accross contexts.');
}, 'Verify closing cloned frames doesn\'t propagate accross contexts.');

async_test(t => {
let localFrame = createDefaultVideoFrame();
Expand All @@ -104,11 +104,11 @@ async_test(t => {

localPort.onmessage = t.unreached_func();

localFrame.destroy();
localFrame.close();

assert_throws_dom("DataCloneError", () => {
localPort.postMessage(localFrame);
});

t.done();
}, 'Verify posting destroyed frames throws.');
}, 'Verify posting closed frames throws.');
12 changes: 6 additions & 6 deletions webcodecs/video-frame.any.js
Expand Up @@ -12,7 +12,7 @@ test(t => {
assert_equals(frame.cropWidth, 32, "displayWidth");
assert_equals(frame.cropHeight, 16, "displayHeight");

frame.destroy();
frame.close();
}, 'Test we can construct a VideoFrame.');

test(t => {
Expand All @@ -24,7 +24,7 @@ test(t => {
assert_equals(frame.cropWidth, 1, "displayWidth");
assert_equals(frame.cropHeight, 1, "displayHeight");

frame.destroy();
frame.close();
}, 'Test we can construct an odd-sized VideoFrame.');

test(t => {
Expand Down Expand Up @@ -63,7 +63,7 @@ test(t => {
// guarantees about the color space.
assert_equals(view[0], 94, "Y value at (0, 0)");

frame.destroy();
frame.close();
}, 'Test we can read planar data from a VideoFrame.');

test(t => {
Expand All @@ -78,15 +78,15 @@ test(t => {

assert_equals(frame.planes.length, 3, "number of planes");

// Attempt to read Y plane data, but destroy the frame first.
// Attempt to read Y plane data, but close the frame first.
let yPlane = frame.planes[0];
let yLength = yPlane.length;
frame.destroy();
frame.close();

let buffer = new ArrayBuffer(yLength);
let view = new Uint8Array(buffer);
assert_throws_dom("InvalidStateError", () => yPlane.readInto(view));
}, 'Test we cannot read planar data from a destroyed VideoFrame.');
}, 'Test we cannot read planar data from a closed VideoFrame.');

test(t => {
let image = makeImageBitmap(32, 16);
Expand Down
2 changes: 1 addition & 1 deletion webcodecs/video-track-reader.html
Expand Up @@ -38,7 +38,7 @@
assert_equals(frame.codedWidth, testVideo.width);
assert_equals(frame.codedHeight, testVideo.height);
assert_not_equals(frame.timestamp, null);
frame.destroy();
frame.close();

if (++numberFrames == 5) {
vtr.stop();
Expand Down