Navigation Menu

Skip to content

Commit

Permalink
[webcodecs] Deprecate VideoFrame.destroy().
Browse files Browse the repository at this point in the history
This CL adds VideoFrame.close() as an alias for VideoFrame.destroy(),
adds a deprecation message for VideoFrame.destroy(), and changes all
callsites to use close().

Bug: 1166930
Change-Id: I39b9c68262553a6814f6bb0b6b81c02012c2d026
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2631405
Commit-Queue: Dan Sanders <sandersd@chromium.org>
Reviewed-by: Jeremy Roman <jbroman@chromium.org>
Reviewed-by: Eugene Zemtsov <eugene@chromium.org>
Reviewed-by: Guido Urdaneta <guidou@chromium.org>
Cr-Commit-Position: refs/heads/master@{#844250}
  • Loading branch information
Dan Sanders authored and chromium-wpt-export-bot committed Jan 15, 2021
1 parent f5d2090 commit 1895256
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 27 deletions.
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

0 comments on commit 1895256

Please sign in to comment.