diff --git a/src/browser/tests/webcodecs/audio_data.html b/src/browser/tests/webcodecs/audio_data.html index ee143c9e6..630a7398e 100644 --- a/src/browser/tests/webcodecs/audio_data.html +++ b/src/browser/tests/webcodecs/audio_data.html @@ -87,3 +87,27 @@ } } + + diff --git a/src/browser/tests/webcodecs/video_frame.html b/src/browser/tests/webcodecs/video_frame.html index f21c37e71..0112d66cf 100644 --- a/src/browser/tests/webcodecs/video_frame.html +++ b/src/browser/tests/webcodecs/video_frame.html @@ -143,3 +143,24 @@ testing.expectError('InvalidStateError', () => new VideoFrame(new OffscreenCanvas(32767, 32767), {timestamp: 1})); } + + diff --git a/src/browser/webapi/webcodecs/AudioData.zig b/src/browser/webapi/webcodecs/AudioData.zig index ef7519fa3..b8f11778b 100644 --- a/src/browser/webapi/webcodecs/AudioData.zig +++ b/src/browser/webapi/webcodecs/AudioData.zig @@ -259,7 +259,9 @@ fn allocationSize(self: *const AudioData, options: CopyToOptions) !u32 { return std.math.cast(u32, copy.byteLength()) orelse error.RangeError; } -fn copyTo(self: *const AudioData, destination: js.AllowSharedBufferSource, options: CopyToOptions) !void { +fn copyTo(self: *const AudioData, destination_value: js.Value, options: CopyToOptions, exec: *const Execution) !void { + const destination = try exec.js.local.?.jsValueToZig(js.AllowSharedBufferSource, destination_value); + const copy = try self.computeCopy(options); const byte_length = copy.byteLength(); if (byte_length > destination.bytes.len) { diff --git a/src/browser/webapi/webcodecs/VideoFrame.zig b/src/browser/webapi/webcodecs/VideoFrame.zig index c7d9059c0..e7aa071f9 100644 --- a/src/browser/webapi/webcodecs/VideoFrame.zig +++ b/src/browser/webapi/webcodecs/VideoFrame.zig @@ -745,8 +745,11 @@ fn allocationSize(self: *const VideoFrame, options_: ?CopyToOptions) !u32 { return parsed.layout.allocation_size; } -fn copyTo(self: *const VideoFrame, destination: js.AllowSharedBufferSource, options_: ?CopyToOptions, exec: *const Execution) !js.Promise { +fn copyTo(self: *const VideoFrame, destination_value: js.Value, options_: ?CopyToOptions, exec: *const Execution) !js.Promise { const local = exec.js.local.?; + const destination = local.jsValueToZig(js.AllowSharedBufferSource, destination_value) catch { + return local.rejectPromise(.{ .type_error = "" }); + }; const layouts = self.copyInto(destination.bytes, options_ orelse .{}) catch |err| { return local.rejectPromise(switch (err) { error.TypeError => .{ .type_error = "" },