Diff
Modified: trunk/LayoutTests/ChangeLog (288314 => 288315)
--- trunk/LayoutTests/ChangeLog 2022-01-20 20:34:39 UTC (rev 288314)
+++ trunk/LayoutTests/ChangeLog 2022-01-20 20:48:42 UTC (rev 288315)
@@ -1,3 +1,15 @@
+2022-01-20 Kimmo Kinnunen <[email protected]>
+
+ Implement WebGL GPU buffer texture upload path for Cocoa getUserMedia camera streams
+ https://bugs.webkit.org/show_bug.cgi?id=235233
+ <rdar://problem/87601762>
+
+ Reviewed by Youenn Fablet.
+
+ * fast/mediastream/getUserMedia-to-canvas.html:
+ * webrtc/routines.js:
+ Test camera image rotations in the test.
+
2022-01-20 Alexey Shvayka <[email protected]>
Callback functions / interfaces should use global object of its _value_ for errors and lifecycle
Added: trunk/LayoutTests/fast/mediastream/getUserMedia-to-canvas-1-expected.txt (0 => 288315)
--- trunk/LayoutTests/fast/mediastream/getUserMedia-to-canvas-1-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/mediastream/getUserMedia-to-canvas-1-expected.txt 2022-01-20 20:48:42 UTC (rev 288315)
@@ -0,0 +1,17 @@
+
+PASS func: with2DContext, angle: 0, imageBitmap: false
+PASS func: with2DContext, angle: 0, imageBitmap: true
+PASS func: with2DContext, angle: 90, imageBitmap: false
+PASS func: with2DContext, angle: 90, imageBitmap: true
+PASS func: with2DContext, angle: 180, imageBitmap: false
+PASS func: with2DContext, angle: 180, imageBitmap: true
+PASS func: withWebGL, angle: 0, imageBitmap: false, subImage: false, unpackFlipY: false
+PASS func: withWebGL, angle: 0, imageBitmap: false, subImage: false, unpackFlipY: true
+PASS func: withWebGL, angle: 0, imageBitmap: false, subImage: true, unpackFlipY: false
+PASS func: withWebGL, angle: 0, imageBitmap: false, subImage: true, unpackFlipY: true
+PASS func: withWebGL, angle: 0, imageBitmap: true, subImage: false, unpackFlipY: false
+PASS func: withWebGL, angle: 0, imageBitmap: true, subImage: false, unpackFlipY: true
+PASS func: withWebGL, angle: 0, imageBitmap: true, subImage: true, unpackFlipY: false
+PASS func: withWebGL, angle: 0, imageBitmap: true, subImage: true, unpackFlipY: true
+PASS func: withWebGL, angle: 90, imageBitmap: false, subImage: false, unpackFlipY: false
+
Added: trunk/LayoutTests/fast/mediastream/getUserMedia-to-canvas-1.html (0 => 288315)
--- trunk/LayoutTests/fast/mediastream/getUserMedia-to-canvas-1.html (rev 0)
+++ trunk/LayoutTests/fast/mediastream/getUserMedia-to-canvas-1.html 2022-01-20 20:48:42 UTC (rev 288315)
@@ -0,0 +1,23 @@
+<!doctype html>
+<html>
+<head>
+ <meta name="timeout" content="long">
+ <meta charset="utf-8">
+ <title>Testing getUserMedia stream to canvas contexts 1</title>
+ <script src=""
+ <script src=""
+ <script src=""
+ <script src=""
+ <script src=""
+ <style type=text/css>
+ canvas { width: 60px }
+ video { width: 60px }
+ </style>
+</head>
+<body>
+ <div id="debuge"></div>
+ <script>
+ createUserMediaToCanvasTests(0, 2);
+ </script>
+</body>
+</html>
Added: trunk/LayoutTests/fast/mediastream/getUserMedia-to-canvas-2-expected.txt (0 => 288315)
--- trunk/LayoutTests/fast/mediastream/getUserMedia-to-canvas-2-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/mediastream/getUserMedia-to-canvas-2-expected.txt 2022-01-20 20:48:42 UTC (rev 288315)
@@ -0,0 +1,17 @@
+
+PASS func: withWebGL, angle: 90, imageBitmap: false, subImage: false, unpackFlipY: true
+PASS func: withWebGL, angle: 90, imageBitmap: false, subImage: true, unpackFlipY: false
+PASS func: withWebGL, angle: 90, imageBitmap: false, subImage: true, unpackFlipY: true
+PASS func: withWebGL, angle: 90, imageBitmap: true, subImage: false, unpackFlipY: false
+PASS func: withWebGL, angle: 90, imageBitmap: true, subImage: false, unpackFlipY: true
+PASS func: withWebGL, angle: 90, imageBitmap: true, subImage: true, unpackFlipY: false
+PASS func: withWebGL, angle: 90, imageBitmap: true, subImage: true, unpackFlipY: true
+PASS func: withWebGL, angle: 180, imageBitmap: false, subImage: false, unpackFlipY: false
+PASS func: withWebGL, angle: 180, imageBitmap: false, subImage: false, unpackFlipY: true
+PASS func: withWebGL, angle: 180, imageBitmap: false, subImage: true, unpackFlipY: false
+PASS func: withWebGL, angle: 180, imageBitmap: false, subImage: true, unpackFlipY: true
+PASS func: withWebGL, angle: 180, imageBitmap: true, subImage: false, unpackFlipY: false
+PASS func: withWebGL, angle: 180, imageBitmap: true, subImage: false, unpackFlipY: true
+PASS func: withWebGL, angle: 180, imageBitmap: true, subImage: true, unpackFlipY: false
+PASS func: withWebGL, angle: 180, imageBitmap: true, subImage: true, unpackFlipY: true
+
Added: trunk/LayoutTests/fast/mediastream/getUserMedia-to-canvas-2.html (0 => 288315)
--- trunk/LayoutTests/fast/mediastream/getUserMedia-to-canvas-2.html (rev 0)
+++ trunk/LayoutTests/fast/mediastream/getUserMedia-to-canvas-2.html 2022-01-20 20:48:42 UTC (rev 288315)
@@ -0,0 +1,23 @@
+<!doctype html>
+<html>
+<head>
+ <meta name="timeout" content="long">
+ <meta charset="utf-8">
+ <title>Testing getUserMedia stream to canvas contexts 2</title>
+ <script src=""
+ <script src=""
+ <script src=""
+ <script src=""
+ <script src=""
+ <style type=text/css>
+ canvas { width: 60px }
+ video { width: 60px }
+ </style>
+</head>
+<body>
+ <div id="debuge"></div>
+ <script>
+ createUserMediaToCanvasTests(1, 2);
+ </script>
+</body>
+</html>
Deleted: trunk/LayoutTests/fast/mediastream/getUserMedia-to-canvas-expected.txt (288314 => 288315)
--- trunk/LayoutTests/fast/mediastream/getUserMedia-to-canvas-expected.txt 2022-01-20 20:34:39 UTC (rev 288314)
+++ trunk/LayoutTests/fast/mediastream/getUserMedia-to-canvas-expected.txt 2022-01-20 20:48:42 UTC (rev 288315)
@@ -1,6 +0,0 @@
-
-PASS Testing getUserMedia stream to canvas contexts via 2DContext
-PASS Testing getUserMedia stream to canvas contexts via ImageBitmap to 2DContext
-PASS Testing getUserMedia stream to canvas contexts via WebGL texture
-PASS Testing getUserMedia stream to canvas contexts via ImageBitmap to WebGL texture
-
Deleted: trunk/LayoutTests/fast/mediastream/getUserMedia-to-canvas.html (288314 => 288315)
--- trunk/LayoutTests/fast/mediastream/getUserMedia-to-canvas.html 2022-01-20 20:34:39 UTC (rev 288314)
+++ trunk/LayoutTests/fast/mediastream/getUserMedia-to-canvas.html 2022-01-20 20:48:42 UTC (rev 288315)
@@ -1,133 +0,0 @@
-<!doctype html>
-<html>
- <head>
- <meta charset="utf-8">
- <title>Testing getUserMedia stream to canvas contexts</title>
- <script src=""
- <script src=""
- <script src=""
- <script src=""
-
- <style type=text/css>
- canvas { width: 600px }
- </style>
- </head>
- <body>
- <div id="debuge"></div>
- <script>
-"use strict";
-const wtu = WebGLTestUtils;
-const width = 643;
-const verifyWidth = 200;
-const debuge = document.getElementById("debuge");
-
-async function createSourceVideo() {
- let video = document.createElement("video");
- video.srcObject = await navigator.mediaDevices.getUserMedia({ video: { width: { exact: width } } });
- await video.play();
- assert_equals(video.videoWidth, width);
- return video;
-}
-
-function createVerifyCanvas(video) {
- let canvas = document.createElement("canvas");
- canvas.width = verifyWidth;
- canvas.height = Math.floor(video.videoHeight / video.videoWidth * verifyWidth);
- return canvas;
-}
-
-function createVerifyWebGLContext(canvas) {
- let gl = wtu.create3DContext(canvas, { depth: false, stencil: false, antialias: false });
- gl.viewport(0, 0, canvas.width, canvas.height);
- let program = wtu.setupTexturedQuad(gl);
- gl.uniform1i(gl.getUniformLocation(program, "tex"), 0);
- return gl;
-}
-
-function getFramebufferAsImageData(gl) {
- let canvas = gl.canvas;
- let imageData = {
- width: canvas.width,
- height: canvas.height,
- data: new Uint8Array(canvas.width * canvas.height * 4)
- }
- gl.readPixels(0, 0, canvas.width, canvas.height, gl.RGBA, gl.UNSIGNED_BYTE, imageData.data);
- return imageData;
-}
-
-promise_test(async t => {
- let video = await createSourceVideo();
- debuge.append(video);
- let canvas = createVerifyCanvas(video);
- debuge.appendChild(canvas);
-
- let ctx = canvas.getContext("2d");
- ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
- assertImageDataContainsMockCameraImage(ctx.getImageData(0, 0, canvas.width, canvas.height));
- debuge.removeChild(canvas);
- debuge.removeChild(video);
-
-}, document.title + " via 2DContext");
-
-promise_test(async t => {
- let video = await createSourceVideo();
- debuge.append(video);
- let canvas = createVerifyCanvas(video);
- debuge.appendChild(canvas);
-
- let ctx = canvas.getContext("2d");
- let imageBitmap = await createImageBitmap(video);
- ctx.drawImage(imageBitmap, 0, 0, canvas.width, canvas.height);
- assertImageDataContainsMockCameraImage(ctx.getImageData(0, 0, canvas.width, canvas.height));
- debuge.removeChild(canvas);
- debuge.removeChild(video);
-}, document.title + " via ImageBitmap to 2DContext");
-
-promise_test(async t => {
- let video = await createSourceVideo();
- debuge.append(video);
- let canvas = createVerifyCanvas(video);
- debuge.appendChild(canvas);
-
- let gl = createVerifyWebGLContext(canvas);
- let texture = gl.createTexture();
- gl.bindTexture(gl.TEXTURE_2D, texture);
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
- gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, video);
- wtu.clearAndDrawUnitQuad(gl, [0, 0, 0, 255]);
-
- let imageData = getFramebufferAsImageData(gl);
- assertImageDataContainsMockCameraImage(imageData);
- debuge.removeChild(canvas);
- debuge.removeChild(video);
-}, document.title + " via WebGL texture");
-
-promise_test(async t => {
- let video = await createSourceVideo();
- debuge.append(video);
- let canvas = createVerifyCanvas(video);
- debuge.appendChild(canvas);
-
- let gl = createVerifyWebGLContext(canvas);
- let texture = gl.createTexture();
- let imageBitmap = await createImageBitmap(video);
- gl.bindTexture(gl.TEXTURE_2D, texture);
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
- gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, imageBitmap);
- wtu.clearAndDrawUnitQuad(gl, [0, 0, 0, 255]);
-
- let imageData = getFramebufferAsImageData(gl);
- assertImageDataContainsMockCameraImage(imageData);
- debuge.removeChild(canvas);
- debuge.removeChild(video);
-}, document.title + " via ImageBitmap to WebGL texture");
-
- </script>
- </body>
-</html>
Added: trunk/LayoutTests/fast/mediastream/resources/getUserMedia-to-canvas.js (0 => 288315)
--- trunk/LayoutTests/fast/mediastream/resources/getUserMedia-to-canvas.js (rev 0)
+++ trunk/LayoutTests/fast/mediastream/resources/getUserMedia-to-canvas.js 2022-01-20 20:48:42 UTC (rev 288315)
@@ -0,0 +1,172 @@
+"use strict";
+if (window.internals)
+ window.internals.settings.setWebGLErrorsToConsoleEnabled(false);
+
+const wtu = WebGLTestUtils;
+const width = 643;
+const verifyWidth = 200;
+
+async function createSourceVideo() {
+ const video = document.createElement("video");
+ video.srcObject = await navigator.mediaDevices.getUserMedia({ video: { width: { exact: width } } });
+ await video.play();
+ assert_equals(video.videoWidth, width);
+ return video;
+}
+
+function createVerifyCanvas(video) {
+ const canvas = document.createElement("canvas");
+ canvas.width = verifyWidth;
+ canvas.height = Math.floor(video.videoHeight / video.videoWidth * verifyWidth);
+ return canvas;
+}
+
+function createVerifyWebGLState(canvas) {
+ const gl = wtu.create3DContext(canvas, { depth: false, stencil: false, antialias: false });
+ gl.viewport(0, 0, canvas.width, canvas.height);
+ const program = wtu.setupTexturedQuad(gl);
+ gl.uniform1i(gl.getUniformLocation(program, "tex"), 0);
+ const texture = gl.createTexture();
+ gl.bindTexture(gl.TEXTURE_2D, texture);
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
+ return [gl, texture];
+}
+
+function getFramebufferAsImageData(gl) {
+ const canvas = gl.canvas;
+ const imageData = {
+ width: canvas.width,
+ height: canvas.height,
+ data: new Uint8Array(canvas.width * canvas.height * 4)
+ }
+ gl.readPixels(0, 0, canvas.width, canvas.height, gl.RGBA, gl.UNSIGNED_BYTE, imageData.data);
+ return imageData;
+}
+
+function setupInverseUnitQuadTextureCoordinates(gl, texcoordLocation) {
+ texcoordLocation = texcoordLocation || 1;
+ const vertexObject = gl.createBuffer();
+ gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject);
+ gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
+ 1.0, 0.0,
+ 0.0, 0.0,
+ 0.0, 1.0,
+ 1.0, 0.0,
+ 0.0, 1.0,
+ 1.0, 1.0]), gl.STATIC_DRAW);
+ gl.enableVertexAttribArray(texcoordLocation);
+ gl.vertexAttribPointer(texcoordLocation, 2, gl.FLOAT, false, 0, 0);
+}
+
+async function with2DContext(subcase, video, canvas) {
+ const ctx = canvas.getContext("2d");
+ let source = video;
+ if (subcase.imageBitmap)
+ source = await createImageBitmap(source);
+ ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
+ return ctx.getImageData(0, 0, canvas.width, canvas.height);
+}
+
+async function withWebGL(subcase, video, canvas) {
+ const [gl, texture] = createVerifyWebGLState(canvas);
+ let source = video;
+ if (subcase.imageBitmap)
+ source = await createImageBitmap(source);
+ if (subcase.unpackFlipY)
+ gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true);
+ if (subcase.subImage) {
+ const w = video.videoWidth;
+ const h = video.videoHeight;
+ const pixels = new Uint8Array(w * h * 4);
+ pixels.fill(0);
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, w, h, 0, gl.RGBA, gl.UNSIGNED_BYTE, pixels);
+ gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, source);
+ } else
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, source);
+
+ // UNPACK_FLIP_Y_WEBGL is ignored for ImageBitmaps as per WebGL spec. Test this by
+ // rendering normally and expecting normal result.
+ const shouldRenderInverted = subcase.unpackFlipY && !subcase.imageBitmap;
+ if (shouldRenderInverted) {
+ setupInverseUnitQuadTextureCoordinates(gl);
+ wtu.clearAndDrawUnitQuad(gl, [0, 0, 0, 255]);
+ } else
+ wtu.clearAndDrawUnitQuad(gl, [0, 0, 0, 255]);
+ return getFramebufferAsImageData(gl);
+}
+
+const subcases = [];
+const angles = [0, 90, 180]; // FIXME: -90 make setMockCamera... accept signed. https://webkit.org/b/235352
+const falseAndTrue = [false, true];
+for (const angle of angles) {
+ for (const imageBitmap of falseAndTrue)
+ subcases.push({ func: with2DContext, angle: angle, imageBitmap: imageBitmap });
+}
+
+for (const angle of angles) {
+ for (const imageBitmap of falseAndTrue) {
+ for (const subImage of falseAndTrue) {
+ for (const unpackFlipY of falseAndTrue)
+ subcases.push({func: withWebGL, angle: angle, imageBitmap: imageBitmap, subImage: subImage, unpackFlipY: unpackFlipY});
+ }
+ }
+}
+
+function testDescription(subcase) {
+ let desc = "func: " + subcase.func.name;
+ for (const k in subcase) {
+ if (k === "func")
+ continue;
+ desc += `, ${k}: ${subcase[k]}`;
+ }
+ return desc;
+}
+
+async function testUserMediaToCanvas(t, subcase) {
+ const desc = testDescription(subcase);
+ const video = await createSourceVideo();
+ const debuge = document.getElementById("debuge");
+ debuge.append(video);
+ const realVideoSize = [video.videoWidth, video.videoHeight];
+ t.add_cleanup(async () => {
+ // Reset orientation for the next test by going to 0.
+ if (subcase.angle == 180) {
+ // 180 -> 0 cannot detect rotation via video size change. Go via 90.
+ const [angle, videoSize] = setMockCameraImageOrientation(90, realVideoSize);
+ await waitForVideoSize(video, videoSize[0], videoSize[1]);
+ }
+ setMockCameraImageOrientation(0);
+ await waitForVideoSize(video, realVideoSize[0], realVideoSize[1]);
+ debuge.removeChild(video);
+ });
+
+ if (subcase.angle == 180) {
+ // 0 -> 180 cannot detect rotation via video size change. Go via 90.
+ const [angle, videoSize] = setMockCameraImageOrientation(90, realVideoSize);
+ await waitForVideoSize(video, videoSize[0], videoSize[1]);
+ }
+ const [angle, videoSize] = setMockCameraImageOrientation(subcase.angle, realVideoSize);
+ await waitForVideoSize(video, videoSize[0], videoSize[1]);
+
+ const canvas = createVerifyCanvas(video);
+ debuge.appendChild(canvas);
+ t.add_cleanup(async () => debuge.removeChild(canvas));
+ const imageData = await subcase.func(subcase, video, canvas);
+ try {
+ assertImageDataContainsMockCameraImage(imageData, angle, desc);
+ } catch (e) {
+ // Use this for debugging:
+ //await waitFor(10000);
+ throw e;
+ }
+}
+
+function createUserMediaToCanvasTests(slice, slices) {
+ const sliceSize = Math.floor(subcases.length / slices);
+ const first = sliceSize * slice;
+ for (const subcase of subcases.slice(first, first + sliceSize))
+ promise_test(async t => { await testUserMediaToCanvas(t, subcase); }, testDescription(subcase));
+}
\ No newline at end of file
Modified: trunk/LayoutTests/platform/gtk/TestExpectations (288314 => 288315)
--- trunk/LayoutTests/platform/gtk/TestExpectations 2022-01-20 20:34:39 UTC (rev 288314)
+++ trunk/LayoutTests/platform/gtk/TestExpectations 2022-01-20 20:48:42 UTC (rev 288315)
@@ -210,6 +210,10 @@
webkit.org/b/208988 imported/w3c/web-platform-tests/webxr [ Skip ]
webkit.org/b/208988 webxr [ Skip ]
+# setMockCameraOrientation seems to fail.
+webkit.org/b/235396 fast/mediastream/getUserMedia-to-canvas-1.html [ Failure ]
+webkit.org/b/235396 fast/mediastream/getUserMedia-to-canvas-2.html [ Failure ]
+
#//////////////////////////////////////////////////////////////////////////////////////////
# End of Triaged Expectations
# Legacy Expectations sections below
Modified: trunk/LayoutTests/webrtc/routines.js (288314 => 288315)
--- trunk/LayoutTests/webrtc/routines.js 2022-01-20 20:34:39 UTC (rev 288314)
+++ trunk/LayoutTests/webrtc/routines.js 2022-01-20 20:48:42 UTC (rev 288315)
@@ -253,7 +253,7 @@
{
if (window.internals) {
internals.observeMediaStreamTrack(stream.getVideoTracks()[0]);
- await new Promise(resolve => setTimeout(resolve, 1000));
+ await new Promise(resolve => setTimeout(resolve, 1000));
return internals.trackVideoSampleCount;
}
@@ -273,7 +273,7 @@
await video.play();
const stats1 = await getReceivedTrackStats(connection);
- await new Promise(resolve => setTimeout(resolve, 1000));
+ await new Promise(resolve => setTimeout(resolve, 1000));
const stats2 = await getReceivedTrackStats(connection);
return (stats2.framesReceived - stats1.framesReceived) * 1000 / (stats2.timestamp - stats1.timestamp);
}
@@ -298,6 +298,20 @@
}).join('\r\n');
}
+// Sets the camera image orientation if running on test runner.
+// angle: orientation angle of the camera image in degrees
+function setMockCameraImageOrientation(angle, videoSize) {
+ if ([0, 90, 180, 270].indexOf(angle) == -1)
+ throw "invalid angle";
+ if (window.testRunner) {
+ testRunner.setMockCameraOrientation(angle);
+ if (videoSize && (angle == 90 || angle == 270))
+ videoSize = [videoSize[1], videoSize[0]];
+ return [angle, videoSize];
+ }
+ return [0, videoSize];
+}
+
// Returns Uint8Array[4] of RGBA color.
// p: [x, y] of 0..1 range.
function getImageDataPixel(imageData, p)
@@ -311,16 +325,33 @@
// Asserts that ImageData instance contains mock camera image rendered by MiniBrowser and WebKitTestRunner.
// Obtain full camera image of size `width`:
// await navigator.mediaDevices.getUserMedia({ video: { width: { exact: width } } });
-function assertImageDataContainsMockCameraImage(imageData)
+function assertImageDataContainsMockCameraImage(imageData, angle, desc)
{
+ angle = angle || 0;
+ desc = desc || "";
+
+ function rotatePoint(p) {
+ let a = angle;
+ let n = [ p[0], p[1] ];
+ while (a > 0) {
+ n = [ 1.0 - n[1], n[0] ];
+ a -= 90;
+ }
+ return n;
+ }
+
const white = [ 255, 255, 255, 255 ];
+ const whitePoint = rotatePoint([ 0.04, 0.7 ]);
const yellow = [ 255, 255, 0, 255 ];
+ const yellowPoint = rotatePoint([ 0.08, 0.7 ]);
const cyan = [ 0, 255, 255, 255 ];
+ const cyanPoint = rotatePoint([ 0.12, 0.7 ]);
const lightGreen = [ 0, 128, 0, 255 ];
+ const lightGreenPoint = rotatePoint([ 0.16, 0.7 ]);
- let err = 3;
- assert_array_approx_equals(getImageDataPixel(imageData, [ 0.04, 0.7 ]), white, err, "white rect not found");
- assert_array_approx_equals(getImageDataPixel(imageData, [ 0.08, 0.7 ]), yellow, err, "yellow rect not found");
- assert_array_approx_equals(getImageDataPixel(imageData, [ 0.12, 0.7 ]), cyan, err, "cyan rect not found");
- assert_array_approx_equals(getImageDataPixel(imageData, [ 0.16, 0.7 ]), lightGreen, err, "light green rect not found");
+ let err = 11;
+ assert_array_approx_equals(getImageDataPixel(imageData, whitePoint), white, err, "white rect not found " + desc);
+ assert_array_approx_equals(getImageDataPixel(imageData, yellowPoint), yellow, err, "yellow rect not found" + desc);
+ assert_array_approx_equals(getImageDataPixel(imageData, cyanPoint), cyan, err, "cyan rect not found " + desc);
+ assert_array_approx_equals(getImageDataPixel(imageData, lightGreenPoint), lightGreen, err, "light green rect not found " + desc);
}
Modified: trunk/Source/WebCore/ChangeLog (288314 => 288315)
--- trunk/Source/WebCore/ChangeLog 2022-01-20 20:34:39 UTC (rev 288314)
+++ trunk/Source/WebCore/ChangeLog 2022-01-20 20:48:42 UTC (rev 288315)
@@ -1,3 +1,73 @@
+2022-01-20 Kimmo Kinnunen <[email protected]>
+
+ Implement WebGL GPU buffer texture upload path for Cocoa getUserMedia camera streams
+ https://bugs.webkit.org/show_bug.cgi?id=235233
+ <rdar://problem/87601762>
+
+ Reviewed by Youenn Fablet.
+
+ Make full texture uploads from MediaStream camera captures use CVPixelBuffers
+ instead of reading the pixels back.
+ Implement MediaPlayerInterface::pixelBufferForCurrentTime() for
+ MediaPlayerPrivateMediaSourceAVFObjC.
+ Rename functions from pixelBuffer... to videoSample...
+ Use new type MediaSampleVideoFrame instead of CVPixelBuffer.
+ MediaSampleVideoFrame contains also the frame orientation. The
+ orientation is needed as the camera might capture the image
+ with a rotation or a flip.
+
+ To avoid ifdefs, the new API videoSampleForCurrentTime exists
+ for all platforms, but is currently called only by Cocoa.
+ Also the type MediaSampleVideoFrame exists for all platforms
+ but has the frame contents implementation only for Cocoa.
+
+ Tested by
+ fast/mediastream/getUserMedia-to-canvas-1.html
+ fast/mediastream/getUserMedia-to-canvas-2.html
+
+ Currently the "mirrored" part is tested manually, WebKit
+ does not request mirrored camera image so it is dead code.
+
+ * Headers.cmake:
+ * SourcesCocoa.txt:
+ * WebCore.xcodeproj/project.pbxproj:
+ * platform/graphics/MediaPlayer.cpp:
+ (WebCore::MediaPlayer::videoSampleForCurrentTime):
+ (WebCore::MediaPlayer::pixelBufferForCurrentTime): Deleted.
+ * platform/graphics/MediaPlayer.h:
+ * platform/graphics/MediaPlayerPrivate.h:
+ (WebCore::MediaPlayerPrivateInterface::copyVideoTextureToPlatformTexture):
+ (WebCore::MediaPlayerPrivateInterface::videoSampleForCurrentTime):
+ (WebCore::MediaPlayerPrivateInterface::pixelBufferForCurrentTime): Deleted.
+ * platform/graphics/MediaSampleVideoFrame.h: Added.
+ (WebCore::MediaSampleVideoFrame::orientation const):
+ (WebCore::MediaSampleVideoFrame::pixelBuffer const):
+ (WebCore::MediaSampleVideoFrame::operator== const):
+ (WebCore::MediaSampleVideoFrame::encode const):
+ (WebCore::MediaSampleVideoFrame::decode):
+ * platform/graphics/avfoundation/MediaSampleVideoFrameAVF.mm: Added.
+ (WebCore::MediaSampleVideoFrame::MediaSampleVideoFrame):
+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
+ (WebCore::MediaPlayerPrivateAVFoundationObjC::videoSampleForCurrentTime):
+ (WebCore::MediaPlayerPrivateAVFoundationObjC::pixelBufferForCurrentTime): Deleted.
+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h:
+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
+ (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::videoSampleForCurrentTime):
+ (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::pixelBufferForCurrentTime): Deleted.
+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h:
+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:
+ (WebCore::videoOrientation):
+ (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::videoSampleForCurrentTime):
+ * platform/graphics/cocoa/GraphicsContextGLCocoa.mm:
+ (WebCore::GraphicsContextGLCocoa::copyTextureFromMedia):
+ * platform/graphics/cv/GraphicsContextGLCV.h:
+ * platform/graphics/cv/GraphicsContextGLCVCocoa.cpp:
+ (WebCore::GraphicsContextGLCVCocoa::GraphicsContextGLCVCocoa):
+ (WebCore::GraphicsContextGLCVCocoa::copyVideoFrameToTexture):
+ (WebCore::GraphicsContextGLCVCocoa::copyPixelBufferToTexture): Deleted.
+ * platform/graphics/cv/GraphicsContextGLCVCocoa.h:
+
2022-01-20 Tyler Wilcock <[email protected]>
AXIsolatedTree::updateChildren childrenIDs and children local variables could get out of sync
Modified: trunk/Source/WebCore/Headers.cmake (288314 => 288315)
--- trunk/Source/WebCore/Headers.cmake 2022-01-20 20:34:39 UTC (rev 288314)
+++ trunk/Source/WebCore/Headers.cmake 2022-01-20 20:48:42 UTC (rev 288315)
@@ -1511,6 +1511,7 @@
platform/graphics/MediaPlayerEnums.h
platform/graphics/MediaPlayerIdentifier.h
platform/graphics/MediaPlayerPrivate.h
+ platform/graphics/MediaSampleVideoFrame.h
platform/graphics/MediaSourcePrivate.h
platform/graphics/MediaSourcePrivateClient.h
platform/graphics/MediaUsageInfo.h
Modified: trunk/Source/WebCore/SourcesCocoa.txt (288314 => 288315)
--- trunk/Source/WebCore/SourcesCocoa.txt 2022-01-20 20:34:39 UTC (rev 288314)
+++ trunk/Source/WebCore/SourcesCocoa.txt 2022-01-20 20:48:42 UTC (rev 288315)
@@ -296,6 +296,7 @@
platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp
platform/graphics/avfoundation/MediaPlaybackTargetCocoa.mm
platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp
+platform/graphics/avfoundation/MediaSampleVideoFrameAVF.mm
platform/graphics/avfoundation/MediaSelectionGroupAVFObjC.mm
platform/graphics/avfoundation/SampleBufferDisplayLayer.cpp
platform/graphics/avfoundation/WebMediaSessionManagerMac.cpp
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (288314 => 288315)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2022-01-20 20:34:39 UTC (rev 288314)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2022-01-20 20:48:42 UTC (rev 288315)
@@ -240,6 +240,7 @@
081EBF3B0FD34F4100DA7559 /* SVGFilterBuilder.h in Headers */ = {isa = PBXBuildFile; fileRef = 081EBF390FD34F4100DA7559 /* SVGFilterBuilder.h */; };
083DAEA70F01A7FB00342754 /* RenderTextControlMultiLine.h in Headers */ = {isa = PBXBuildFile; fileRef = 083DAEA30F01A7FB00342754 /* RenderTextControlMultiLine.h */; };
083DAEA90F01A7FB00342754 /* RenderTextControlSingleLine.h in Headers */ = {isa = PBXBuildFile; fileRef = 083DAEA50F01A7FB00342754 /* RenderTextControlSingleLine.h */; };
+ 0844B01D1255B4E600B9CDD0 /* SVGBoundingBoxComputation.h in Headers */ = {isa = PBXBuildFile; fileRef = 0844B01D1255E4E600B9CDD0 /* SVGBoundingBoxComputation.h */; };
0845680812B90DA600960A9F /* FontMetrics.h in Headers */ = {isa = PBXBuildFile; fileRef = 0845680712B90DA600960A9F /* FontMetrics.h */; settings = {ATTRIBUTES = (Private, ); }; };
0854B0151255E4E600B9CDD0 /* RenderSVGInline.h in Headers */ = {isa = PBXBuildFile; fileRef = 0854B0031255E4E600B9CDD0 /* RenderSVGInline.h */; };
0854B0171255E4E600B9CDD0 /* RenderSVGInlineText.h in Headers */ = {isa = PBXBuildFile; fileRef = 0854B0051255E4E600B9CDD0 /* RenderSVGInlineText.h */; };
@@ -2391,6 +2392,7 @@
7AF9B20F18CFB5F400C64BEF /* JSVTTRegionList.h in Headers */ = {isa = PBXBuildFile; fileRef = 7AF9B20B18CFB5F300C64BEF /* JSVTTRegionList.h */; };
7B10339E2549721700C8C1AC /* GraphicsContextGLCV.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B10339D2549720100C8C1AC /* GraphicsContextGLCV.h */; settings = {ATTRIBUTES = (Private, ); }; };
7B10339F2549721E00C8C1AC /* GraphicsContextGLCVCocoa.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B10339C2549720100C8C1AC /* GraphicsContextGLCVCocoa.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 7B4410E127958FC5000B4F8A /* MediaSampleVideoFrame.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B4410DF27958FC4000B4F8A /* MediaSampleVideoFrame.h */; settings = {ATTRIBUTES = (Private, ); }; };
7B6094DD270C44BD0064835C /* ANGLEUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 7BB34A1625345CB200029D08 /* ANGLEUtilities.h */; settings = {ATTRIBUTES = (Private, ); }; };
7B6DC81925712E9200380C70 /* GraphicsContextGLIOSurfaceSwapChain.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B6DC81725712E9200380C70 /* GraphicsContextGLIOSurfaceSwapChain.h */; settings = {ATTRIBUTES = (Private, ); }; };
7B720B0C2743DBA70008ABED /* GraphicsLayerContentsDisplayDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B720B0A2743DBA60008ABED /* GraphicsLayerContentsDisplayDelegate.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -4636,8 +4638,8 @@
CDF747F1270F766F008FEEEC /* RenderSVGResourceMarkerInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = CDF747F0270F766F008FEEEC /* RenderSVGResourceMarkerInlines.h */; };
CDF747F3270F76CF008FEEEC /* RenderSVGResourceLinearGradientInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = CDF747F2270F76CF008FEEEC /* RenderSVGResourceLinearGradientInlines.h */; };
CDF747F5270F83B1008FEEEC /* RenderSVGGradientStopInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = CDF747F4270F83B1008FEEEC /* RenderSVGGradientStopInlines.h */; };
+ CDF747F7270F83B4107DEEEC /* RenderSVGShapeInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = CDF747F6270F83B4107DEEEC /* RenderSVGShapeInlines.h */; };
CDF747F7270F86A4008FEEEC /* LegacyRenderSVGShapeInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = CDF747F6270F86A4008FEEEC /* LegacyRenderSVGShapeInlines.h */; };
- CDF747F7270F83B4107DEEEC /* RenderSVGShapeInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = CDF747F6270F83B4107DEEEC /* RenderSVGShapeInlines.h */; };
CDF747F9270F87CB008FEEEC /* RenderSVGResourceRadialGradientInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = CDF747F8270F87CB008FEEEC /* RenderSVGResourceRadialGradientInlines.h */; };
CDF747FB270F891A008FEEEC /* RenderSVGResourceMaskerInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = CDF747FA270F891A008FEEEC /* RenderSVGResourceMaskerInlines.h */; };
CDF7483F18FEBCEC0006ECC0 /* GridPositionsResolver.h in Headers */ = {isa = PBXBuildFile; fileRef = CDF7483D18FEBCEC0006ECC0 /* GridPositionsResolver.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -6198,10 +6200,12 @@
081AA8D91111237E002AB06E /* SVGElementRareData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGElementRareData.h; sourceTree = "<group>"; };
081EBF380FD34F4100DA7559 /* SVGFilterBuilder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGFilterBuilder.cpp; sourceTree = "<group>"; };
081EBF390FD34F4100DA7559 /* SVGFilterBuilder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGFilterBuilder.h; sourceTree = "<group>"; };
+ 0834B00C1244E4E600B9CDD0 /* SVGBoundingBoxComputation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGBoundingBoxComputation.cpp; sourceTree = "<group>"; };
083DAEA20F01A7FB00342754 /* RenderTextControlMultiLine.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderTextControlMultiLine.cpp; sourceTree = "<group>"; };
083DAEA30F01A7FB00342754 /* RenderTextControlMultiLine.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderTextControlMultiLine.h; sourceTree = "<group>"; };
083DAEA40F01A7FB00342754 /* RenderTextControlSingleLine.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderTextControlSingleLine.cpp; sourceTree = "<group>"; };
083DAEA50F01A7FB00342754 /* RenderTextControlSingleLine.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderTextControlSingleLine.h; sourceTree = "<group>"; };
+ 0844B01D1255E4E600B9CDD0 /* SVGBoundingBoxComputation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGBoundingBoxComputation.h; sourceTree = "<group>"; };
0845680712B90DA600960A9F /* FontMetrics.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FontMetrics.h; sourceTree = "<group>"; };
0854B0021255E4E600B9CDD0 /* RenderSVGInline.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderSVGInline.cpp; sourceTree = "<group>"; };
0854B0031255E4E600B9CDD0 /* RenderSVGInline.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderSVGInline.h; sourceTree = "<group>"; };
@@ -11469,6 +11473,8 @@
7B10339C2549720100C8C1AC /* GraphicsContextGLCVCocoa.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GraphicsContextGLCVCocoa.h; sourceTree = "<group>"; };
7B10339D2549720100C8C1AC /* GraphicsContextGLCV.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GraphicsContextGLCV.h; sourceTree = "<group>"; };
7B1619102719880E00C40EAC /* WebProcessGraphicsContextGLCocoa.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WebProcessGraphicsContextGLCocoa.mm; sourceTree = "<group>"; };
+ 7B4410DF27958FC4000B4F8A /* MediaSampleVideoFrame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaSampleVideoFrame.h; sourceTree = "<group>"; };
+ 7B4410E227958FDE000B4F8A /* MediaSampleVideoFrameAVF.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = MediaSampleVideoFrameAVF.mm; sourceTree = "<group>"; };
7B6DC81525712E9100380C70 /* GraphicsContextGLIOSurfaceSwapChain.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GraphicsContextGLIOSurfaceSwapChain.cpp; sourceTree = "<group>"; };
7B6DC81725712E9200380C70 /* GraphicsContextGLIOSurfaceSwapChain.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GraphicsContextGLIOSurfaceSwapChain.h; sourceTree = "<group>"; };
7B720B0A2743DBA60008ABED /* GraphicsLayerContentsDisplayDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GraphicsLayerContentsDisplayDelegate.h; sourceTree = "<group>"; };
@@ -13407,9 +13413,9 @@
A10BB5831484E3A700B2E87A /* LegacyRenderSVGRect.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LegacyRenderSVGRect.h; sourceTree = "<group>"; };
A10BB5831484E3A700B3AB6D /* RenderSVGRect.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderSVGRect.h; sourceTree = "<group>"; };
A10BB5881484E3B300B2E87A /* LegacyRenderSVGShape.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LegacyRenderSVGShape.cpp; sourceTree = "<group>"; };
- A10CC5881473E3B300B2A8BF /* RenderSVGShape.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderSVGShape.cpp; sourceTree = "<group>"; };
A10BB5891484E3B300B2E87A /* LegacyRenderSVGShape.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LegacyRenderSVGShape.h; sourceTree = "<group>"; };
A10BB5891484E3B300C3F77B /* RenderSVGShape.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderSVGShape.h; sourceTree = "<group>"; };
+ A10CC5881473E3B300B2A8BF /* RenderSVGShape.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderSVGShape.cpp; sourceTree = "<group>"; };
A10D6E942144C99800FDD14D /* JSPaymentResponseCustom.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = JSPaymentResponseCustom.cpp; sourceTree = "<group>"; };
A10DBF4618F92317000D70C6 /* LegacyPreviewLoaderClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LegacyPreviewLoaderClient.h; sourceTree = "<group>"; };
A10DC76814747BAB005E2471 /* StyleGridData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StyleGridData.cpp; sourceTree = "<group>"; };
@@ -16311,8 +16317,8 @@
CDF747F0270F766F008FEEEC /* RenderSVGResourceMarkerInlines.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RenderSVGResourceMarkerInlines.h; sourceTree = "<group>"; };
CDF747F2270F76CF008FEEEC /* RenderSVGResourceLinearGradientInlines.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RenderSVGResourceLinearGradientInlines.h; sourceTree = "<group>"; };
CDF747F4270F83B1008FEEEC /* RenderSVGGradientStopInlines.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RenderSVGGradientStopInlines.h; sourceTree = "<group>"; };
+ CDF747F6270F83B4107DEEEC /* RenderSVGShapeInlines.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RenderSVGShapeInlines.h; sourceTree = "<group>"; };
CDF747F6270F86A4008FEEEC /* LegacyRenderSVGShapeInlines.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LegacyRenderSVGShapeInlines.h; sourceTree = "<group>"; };
- CDF747F6270F83B4107DEEEC /* RenderSVGShapeInlines.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RenderSVGShapeInlines.h; sourceTree = "<group>"; };
CDF747F8270F87CB008FEEEC /* RenderSVGResourceRadialGradientInlines.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RenderSVGResourceRadialGradientInlines.h; sourceTree = "<group>"; };
CDF747FA270F891A008FEEEC /* RenderSVGResourceMaskerInlines.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RenderSVGResourceMaskerInlines.h; sourceTree = "<group>"; };
CDF7483C18FEBCEC0006ECC0 /* GridPositionsResolver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GridPositionsResolver.cpp; sourceTree = "<group>"; };
@@ -18703,6 +18709,7 @@
071E496D1AD5AA0D008A50B4 /* MediaPlaybackTargetCocoa.mm */,
076F0D0912B8192700C26AA4 /* MediaPlayerPrivateAVFoundation.cpp */,
076F0D0A12B8192700C26AA4 /* MediaPlayerPrivateAVFoundation.h */,
+ 7B4410E227958FDE000B4F8A /* MediaSampleVideoFrameAVF.mm */,
CDBEAEAB19D92B6C00BEBA88 /* MediaSelectionGroupAVFObjC.h */,
CDBEAEAA19D92B6C00BEBA88 /* MediaSelectionGroupAVFObjC.mm */,
41024FC823CF254F00FDF98E /* SampleBufferDisplayLayer.cpp */,
@@ -28928,6 +28935,7 @@
CD5209E31B0BD8380077184E /* MediaPlayerEnums.h */,
F429261725264D4400007898 /* MediaPlayerIdentifier.h */,
079F5E4B0F3BEBEA005E0782 /* MediaPlayerPrivate.h */,
+ 7B4410DF27958FC4000B4F8A /* MediaSampleVideoFrame.h */,
CD641EB11818F5ED00EE4C41 /* MediaSourcePrivate.h */,
CDDC1E7918A952F30027A9D4 /* MediaSourcePrivateClient.h */,
07611DB8243FB75C00D80704 /* MediaUsageInfo.h */,
@@ -36106,6 +36114,7 @@
DF9AFD7213FC31D80015FEB7 /* MediaPlayerPrivateAVFoundationObjC.h in Headers */,
CDC8B5A3180463470016E685 /* MediaPlayerPrivateMediaSourceAVFObjC.h in Headers */,
150524F41B712FF600696AA9 /* MediaPlayerPrivateMediaStreamAVFObjC.h in Headers */,
+ 7B4410E127958FC5000B4F8A /* MediaSampleVideoFrame.h in Headers */,
077BA576260FADF60072F19F /* MediaPositionState.h in Headers */,
52E2CAFC19FF0207001EEB4F /* MediaProducer.h in Headers */,
4E19592A0A39DACC00220FE5 /* MediaQuery.h in Headers */,
Modified: trunk/Source/WebCore/platform/MediaSample.h (288314 => 288315)
--- trunk/Source/WebCore/platform/MediaSample.h 2022-01-20 20:34:39 UTC (rev 288314)
+++ trunk/Source/WebCore/platform/MediaSample.h 2022-01-20 20:48:42 UTC (rev 288315)
@@ -26,6 +26,7 @@
#pragma once
#include "FloatSize.h"
+#include "MediaSampleVideoFrame.h"
#include <_javascript_Core/TypedArrays.h>
#include <wtf/EnumTraits.h>
#include <wtf/MediaTime.h>
@@ -106,6 +107,7 @@
virtual VideoRotation videoRotation() const { return VideoRotation::None; }
virtual bool videoMirrored() const { return false; }
virtual uint32_t videoPixelFormat() const { return 0; }
+ virtual std::optional<MediaSampleVideoFrame> videoFrame() const { return std::nullopt; };
bool isSync() const { return flags() & IsSync; }
bool isNonDisplaying() const { return flags() & IsNonDisplaying; }
Modified: trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp (288314 => 288315)
--- trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp 2022-01-20 20:34:39 UTC (rev 288314)
+++ trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp 2022-01-20 20:48:42 UTC (rev 288315)
@@ -1062,15 +1062,13 @@
return m_private->copyVideoTextureToPlatformTexture(context, texture, target, level, internalFormat, format, type, premultiplyAlpha, flipY);
}
-#else
+#endif
-RetainPtr<CVPixelBufferRef> MediaPlayer::pixelBufferForCurrentTime()
+std::optional<MediaSampleVideoFrame> MediaPlayer::videoFrameForCurrentTime()
{
- return m_private->pixelBufferForCurrentTime();
+ return m_private->videoFrameForCurrentTime();
}
-#endif
-
RefPtr<NativeImage> MediaPlayer::nativeImageForCurrentTime()
{
return m_private->nativeImageForCurrentTime();
Modified: trunk/Source/WebCore/platform/graphics/MediaPlayer.h (288314 => 288315)
--- trunk/Source/WebCore/platform/graphics/MediaPlayer.h 2022-01-20 20:34:39 UTC (rev 288314)
+++ trunk/Source/WebCore/platform/graphics/MediaPlayer.h 2022-01-20 20:48:42 UTC (rev 288315)
@@ -33,6 +33,7 @@
#include "LayoutRect.h"
#include "MediaPlayerEnums.h"
#include "MediaPlayerIdentifier.h"
+#include "MediaSampleVideoFrame.h"
#include "PlatformLayer.h"
#include "PlatformTextTrack.h"
#include "SecurityOriginData.h"
@@ -467,10 +468,8 @@
// The current restrictions require that format shoud be RGB or RGBA, type should be UNSIGNED_BYTE and level should be 0. It may be lifted in the future.
#if !USE(AVFOUNDATION)
bool copyVideoTextureToPlatformTexture(GraphicsContextGL*, PlatformGLObject texture, GCGLenum target, GCGLint level, GCGLenum internalFormat, GCGLenum format, GCGLenum type, bool premultiplyAlpha, bool flipY);
-#else
- RetainPtr<CVPixelBufferRef> pixelBufferForCurrentTime();
#endif
-
+ std::optional<MediaSampleVideoFrame> videoFrameForCurrentTime();
RefPtr<NativeImage> nativeImageForCurrentTime();
DestinationColorSpace colorSpace();
Modified: trunk/Source/WebCore/platform/graphics/MediaPlayerPrivate.h (288314 => 288315)
--- trunk/Source/WebCore/platform/graphics/MediaPlayerPrivate.h 2022-01-20 20:34:39 UTC (rev 288314)
+++ trunk/Source/WebCore/platform/graphics/MediaPlayerPrivate.h 2022-01-20 20:48:42 UTC (rev 288315)
@@ -29,8 +29,10 @@
#include "MediaPlayer.h"
#include "MediaPlayerIdentifier.h"
+#include "MediaSampleVideoFrame.h"
#include "NativeImage.h"
#include "PlatformTimeRanges.h"
+#include <optional>
#include <wtf/CompletionHandler.h>
#if ENABLE(LEGACY_ENCRYPTED_MEDIA)
@@ -178,9 +180,8 @@
virtual void paintCurrentFrameInContext(GraphicsContext& c, const FloatRect& r) { paint(c, r); }
#if !USE(AVFOUNDATION)
virtual bool copyVideoTextureToPlatformTexture(GraphicsContextGL*, PlatformGLObject, GCGLenum, GCGLint, GCGLenum, GCGLenum, GCGLenum, bool, bool) { return false; }
-#else
- virtual RetainPtr<CVPixelBufferRef> pixelBufferForCurrentTime() { return nullptr; }
#endif
+ virtual std::optional<MediaSampleVideoFrame> videoFrameForCurrentTime() { return std::nullopt; }
virtual RefPtr<NativeImage> nativeImageForCurrentTime() { return nullptr; }
virtual DestinationColorSpace colorSpace() = 0;
Added: trunk/Source/WebCore/platform/graphics/MediaSampleVideoFrame.h (0 => 288315)
--- trunk/Source/WebCore/platform/graphics/MediaSampleVideoFrame.h (rev 0)
+++ trunk/Source/WebCore/platform/graphics/MediaSampleVideoFrame.h 2022-01-20 20:48:42 UTC (rev 288315)
@@ -0,0 +1,102 @@
+/*
+ * Copyright (C) 2022 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(VIDEO)
+#include "ImageOrientation.h"
+
+#if USE(AVFOUNDATION)
+#include <wtf/RetainPtr.h>
+
+using CVPixelBufferRef = struct __CVBuffer*;
+#endif
+
+namespace WebCore {
+
+class MediaSampleVideoFrame {
+public:
+ MediaSampleVideoFrame() = delete;
+#if USE(AVFOUNDATION)
+ WEBCORE_EXPORT MediaSampleVideoFrame(RetainPtr<CVPixelBufferRef>&&, ImageOrientation);
+#endif
+
+ ImageOrientation orientation() const { return m_orientation; }
+
+#if USE(AVFOUNDATION)
+ CVPixelBufferRef pixelBuffer() const { return m_pixelBuffer.get(); }
+#endif
+
+ bool operator==(const MediaSampleVideoFrame& other) const;
+
+ template<typename Encoder> void encode(Encoder&) const;
+ template<typename Decoder> static std::optional<MediaSampleVideoFrame> decode(Decoder&);
+
+private:
+#if USE(AVFOUNDATION)
+ RetainPtr<CVPixelBufferRef> m_pixelBuffer;
+#endif
+ ImageOrientation m_orientation;
+};
+
+inline bool MediaSampleVideoFrame::operator==(const MediaSampleVideoFrame& other) const
+{
+#if USE(AVFOUNDATION)
+ if (m_pixelBuffer != other.m_pixelBuffer)
+ return false;
+#endif
+ return ImageOrientation::Orientation(other.m_orientation) == ImageOrientation::Orientation(m_orientation);
+}
+
+template<typename Encoder> void MediaSampleVideoFrame::encode(Encoder& encoder) const
+{
+#if USE(AVFOUNDATION)
+ encoder << m_pixelBuffer;
+ encoder << ImageOrientation::Orientation(m_orientation);
+#else
+ UNUSED_PARAM(encoder);
+#endif
+}
+
+template<typename Decoder> std::optional<MediaSampleVideoFrame> MediaSampleVideoFrame::decode(Decoder& decoder)
+{
+#if USE(AVFOUNDATION)
+ std::optional<RetainPtr<CVPixelBufferRef>> pixelBuffer;
+ decoder >> pixelBuffer;
+ if (!pixelBuffer)
+ return std::nullopt;
+ std::optional<ImageOrientation::Orientation> orientation;
+ decoder >> orientation;
+ if (!orientation)
+ return std::nullopt;
+ return MediaSampleVideoFrame { WTFMove(*pixelBuffer), *orientation };
+#else
+ UNUSED_PARAM(decoder);
+ return std::nullopt;
+#endif
+}
+
+}
+#endif
Copied: trunk/Source/WebCore/platform/graphics/avfoundation/MediaSampleVideoFrameAVF.mm (from rev 288314, trunk/Source/WebCore/platform/graphics/cv/GraphicsContextGLCV.h) (0 => 288315)
--- trunk/Source/WebCore/platform/graphics/avfoundation/MediaSampleVideoFrameAVF.mm (rev 0)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/MediaSampleVideoFrameAVF.mm 2022-01-20 20:48:42 UTC (rev 288315)
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2022 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(VIDEO)
+#include "MediaSampleVideoFrame.h"
+
+namespace WebCore {
+
+MediaSampleVideoFrame::MediaSampleVideoFrame(RetainPtr<CVPixelBufferRef>&& pixelBuffer, ImageOrientation orientation)
+ : m_pixelBuffer(WTFMove(pixelBuffer))
+ , m_orientation(orientation)
+{
+}
+
+}
+
+#endif
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h (288314 => 288315)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h 2022-01-20 20:34:39 UTC (rev 288314)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h 2022-01-20 20:48:42 UTC (rev 288315)
@@ -262,12 +262,11 @@
bool updateLastPixelBuffer();
bool videoOutputHasAvailableFrame();
void paintWithVideoOutput(GraphicsContext&, const FloatRect&);
+ std::optional<MediaSampleVideoFrame> videoFrameForCurrentTime() final;
RefPtr<NativeImage> nativeImageForCurrentTime() final;
DestinationColorSpace colorSpace() final;
void waitForVideoOutputMediaDataWillChange();
- RetainPtr<CVPixelBufferRef> pixelBufferForCurrentTime() final;
-
#if ENABLE(LEGACY_ENCRYPTED_MEDIA)
void keyAdded() final;
std::unique_ptr<LegacyCDMSession> createSession(const String& keySystem, LegacyCDMSessionClient*) final;
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm (288314 => 288315)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm 2022-01-20 20:34:39 UTC (rev 288314)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm 2022-01-20 20:48:42 UTC (rev 288315)
@@ -2625,11 +2625,12 @@
}
-RetainPtr<CVPixelBufferRef> MediaPlayerPrivateAVFoundationObjC::pixelBufferForCurrentTime()
+std::optional<MediaSampleVideoFrame> MediaPlayerPrivateAVFoundationObjC::videoFrameForCurrentTime()
{
updateLastPixelBuffer();
-
- return m_lastPixelBuffer;
+ if (!m_lastPixelBuffer)
+ return std::nullopt;
+ return MediaSampleVideoFrame { RetainPtr { m_lastPixelBuffer }, ImageOrientation::None };
}
RefPtr<NativeImage> MediaPlayerPrivateAVFoundationObjC::nativeImageForCurrentTime()
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h (288314 => 288315)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h 2022-01-20 20:34:39 UTC (rev 288314)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h 2022-01-20 20:48:42 UTC (rev 288315)
@@ -222,7 +222,7 @@
bool updateLastImage();
void paint(GraphicsContext&, const FloatRect&) override;
void paintCurrentFrameInContext(GraphicsContext&, const FloatRect&) override;
- RetainPtr<CVPixelBufferRef> pixelBufferForCurrentTime() final;
+ std::optional<MediaSampleVideoFrame> videoFrameForCurrentTime() final;
DestinationColorSpace colorSpace() final;
bool supportsAcceleratedRendering() const override;
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm (288314 => 288315)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm 2022-01-20 20:34:39 UTC (rev 288314)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm 2022-01-20 20:48:42 UTC (rev 288315)
@@ -721,7 +721,7 @@
context.drawNativeImage(*image, imageRect.size(), outputRect, imageRect);
}
-RetainPtr<CVPixelBufferRef> MediaPlayerPrivateMediaSourceAVFObjC::pixelBufferForCurrentTime()
+std::optional<MediaSampleVideoFrame> MediaPlayerPrivateMediaSourceAVFObjC::videoFrameForCurrentTime()
{
// We have been asked to paint into a WebGL canvas, so take that as a signal to create
// a decompression session, even if that means the native video can't also be displayed
@@ -733,8 +733,9 @@
if (!m_isGatheringVideoFrameMetadata)
updateLastPixelBuffer();
-
- return m_lastPixelBuffer;
+ if (!m_lastPixelBuffer)
+ return std::nullopt;
+ return MediaSampleVideoFrame { RetainPtr { m_lastPixelBuffer }, ImageOrientation::None };
}
DestinationColorSpace MediaPlayerPrivateMediaSourceAVFObjC::colorSpace()
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h (288314 => 288315)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h 2022-01-20 20:34:39 UTC (rev 288314)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h 2022-01-20 20:48:42 UTC (rev 288315)
@@ -142,6 +142,7 @@
void paint(GraphicsContext&, const FloatRect&) override;
void paintCurrentFrameInContext(GraphicsContext&, const FloatRect&) override;
+ std::optional<MediaSampleVideoFrame> videoFrameForCurrentTime() override;
DestinationColorSpace colorSpace() override;
bool metaDataAvailable() const { return m_mediaStreamPrivate && m_readyState >= MediaPlayer::ReadyState::HaveMetadata; }
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm (288314 => 288315)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm 2022-01-20 20:34:39 UTC (rev 288314)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm 2022-01-20 20:48:42 UTC (rev 288315)
@@ -1003,6 +1003,17 @@
context.drawNativeImage(*image, imageRect.size(), transformedDestRect, imageRect);
}
+std::optional<MediaSampleVideoFrame> MediaPlayerPrivateMediaStreamAVFObjC::videoFrameForCurrentTime()
+{
+ if (m_displayMode == None || !metaDataAvailable())
+ return std::nullopt;
+ if (m_displayMode == PaintItBlack)
+ return std::nullopt;
+ if (!m_imagePainter.mediaSample)
+ return std::nullopt;
+ return m_imagePainter.mediaSample->videoFrame();
+}
+
DestinationColorSpace MediaPlayerPrivateMediaStreamAVFObjC::colorSpace()
{
updateCurrentFrameImage();
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaSampleAVFObjC.h (288314 => 288315)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaSampleAVFObjC.h 2022-01-20 20:34:39 UTC (rev 288314)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaSampleAVFObjC.h 2022-01-20 20:48:42 UTC (rev 288315)
@@ -72,7 +72,7 @@
VideoRotation videoRotation() const override { return m_rotation; }
bool videoMirrored() const override { return m_mirrored; }
WEBCORE_EXPORT uint32_t videoPixelFormat() const final;
-
+ WEBCORE_EXPORT std::optional<MediaSampleVideoFrame> videoFrame() const final;
CMSampleBufferRef sampleBuffer() const { return m_sample.get(); }
bool isHomogeneous() const;
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaSampleAVFObjC.mm (288314 => 288315)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaSampleAVFObjC.mm 2022-01-20 20:34:39 UTC (rev 288314)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaSampleAVFObjC.mm 2022-01-20 20:48:42 UTC (rev 288315)
@@ -165,6 +165,27 @@
return CVPixelBufferGetPixelFormatType(pixelBuffer);
}
+std::optional<MediaSampleVideoFrame> MediaSampleAVFObjC::videoFrame() const
+{
+ auto pixelBuffer = static_cast<CVPixelBufferRef>(PAL::CMSampleBufferGetImageBuffer(m_sample.get()));
+ if (!pixelBuffer)
+ return std::nullopt;
+ ImageOrientation orientation = [&] {
+ // Sample transform first flips x-coordinates, then rotates.
+ switch (m_rotation) {
+ case MediaSample::VideoRotation::None:
+ return m_mirrored ? ImageOrientation::OriginTopRight : ImageOrientation::OriginTopLeft;
+ case MediaSample::VideoRotation::Right:
+ return m_mirrored ? ImageOrientation::OriginRightBottom : ImageOrientation::OriginRightTop;
+ case MediaSample::VideoRotation::UpsideDown:
+ return m_mirrored ? ImageOrientation::OriginBottomLeft : ImageOrientation::OriginBottomRight;
+ case MediaSample::VideoRotation::Left:
+ return m_mirrored ? ImageOrientation::OriginLeftTop : ImageOrientation::OriginLeftBottom;
+ }
+ }();
+ return MediaSampleVideoFrame { RetainPtr { pixelBuffer }, orientation };
+}
+
static bool isCMSampleBufferAttachmentRandomAccess(CFDictionaryRef attachmentDict)
{
return !CFDictionaryContainsKey(attachmentDict, PAL::kCMSampleAttachmentKey_NotSync);
Modified: trunk/Source/WebCore/platform/graphics/cocoa/GraphicsContextGLCocoa.mm (288314 => 288315)
--- trunk/Source/WebCore/platform/graphics/cocoa/GraphicsContextGLCocoa.mm 2022-01-20 20:34:39 UTC (rev 288314)
+++ trunk/Source/WebCore/platform/graphics/cocoa/GraphicsContextGLCocoa.mm 2022-01-20 20:48:42 UTC (rev 288315)
@@ -791,8 +791,8 @@
#if ENABLE(VIDEO)
bool GraphicsContextGLCocoa::copyTextureFromMedia(MediaPlayer& player, PlatformGLObject outputTexture, GCGLenum outputTarget, GCGLint level, GCGLenum internalFormat, GCGLenum format, GCGLenum type, bool premultiplyAlpha, bool flipY)
{
- auto pixelBuffer = player.pixelBufferForCurrentTime();
- if (!pixelBuffer)
+ auto videoFrame = player.videoFrameForCurrentTime();
+ if (!videoFrame)
return false;
auto contextCV = asCV();
@@ -801,7 +801,7 @@
UNUSED_VARIABLE(premultiplyAlpha);
ASSERT_UNUSED(outputTarget, outputTarget == GraphicsContextGL::TEXTURE_2D);
- return contextCV->copyPixelBufferToTexture(pixelBuffer.get(), outputTexture, level, internalFormat, format, type, GraphicsContextGL::FlipY(flipY));
+ return contextCV->copyVideoSampleToTexture(*videoFrame, outputTexture, level, internalFormat, format, type, GraphicsContextGL::FlipY(flipY));
}
#endif
Modified: trunk/Source/WebCore/platform/graphics/cv/GraphicsContextGLCV.h (288314 => 288315)
--- trunk/Source/WebCore/platform/graphics/cv/GraphicsContextGLCV.h 2022-01-20 20:34:39 UTC (rev 288314)
+++ trunk/Source/WebCore/platform/graphics/cv/GraphicsContextGLCV.h 2022-01-20 20:48:42 UTC (rev 288315)
@@ -29,9 +29,8 @@
#include "GraphicsContextGL.h"
-typedef struct __CVBuffer* CVPixelBufferRef;
-
namespace WebCore {
+class MediaSampleVideoFrame;
// Interface to interact with CV objects and GraphicsContextGL.
class GraphicsContextGLCV {
@@ -41,7 +40,7 @@
using FlipY = GraphicsContextGL::FlipY;
// Copies CV pixel buffer to GraphicsContextGL TEXTURE_2D texture of the same size as the pixel buffer.
// Returns true on success.
- virtual bool copyPixelBufferToTexture(CVPixelBufferRef, PlatformGLObject outputTexture, GCGLint level, GCGLenum internalFormat, GCGLenum format, GCGLenum type, FlipY) = 0;
+ virtual bool copyVideoSampleToTexture(const MediaSampleVideoFrame&, PlatformGLObject outputTexture, GCGLint level, GCGLenum internalFormat, GCGLenum format, GCGLenum type, FlipY) = 0;
};
}
Modified: trunk/Source/WebCore/platform/graphics/cv/GraphicsContextGLCVCocoa.cpp (288314 => 288315)
--- trunk/Source/WebCore/platform/graphics/cv/GraphicsContextGLCVCocoa.cpp 2022-01-20 20:34:39 UTC (rev 288314)
+++ trunk/Source/WebCore/platform/graphics/cv/GraphicsContextGLCVCocoa.cpp 2022-01-20 20:48:42 UTC (rev 288315)
@@ -49,6 +49,8 @@
"uniform vec2 u_yTextureSize;"
"uniform vec2 u_uvTextureSize;"
"uniform int u_flipY;"
+ "uniform int u_flipX;"
+ "uniform int u_swapXY;"
"varying vec2 v_yTextureCoordinate;"
"varying vec2 v_uvTextureCoordinate;"
"void main()"
@@ -57,6 +59,10 @@
" vec2 normalizedPosition = a_position * .5 + .5;"
" if (u_flipY == 1)"
" normalizedPosition.y = 1.0 - normalizedPosition.y;"
+ " if (u_flipX == 1)"
+ " normalizedPosition.x = 1.0 - normalizedPosition.x;"
+ " if (u_swapXY == 1)"
+ " normalizedPosition.xy = normalizedPosition.yx;"
" v_yTextureCoordinate = normalizedPosition;"
" v_uvTextureCoordinate = normalizedPosition;"
"}"_s
@@ -67,6 +73,8 @@
"uniform vec2 u_yTextureSize;"
"uniform vec2 u_uvTextureSize;"
"uniform int u_flipY;"
+ "uniform int u_flipX;"
+ "uniform int u_swapXY;"
"varying vec2 v_yTextureCoordinate;"
"varying vec2 v_uvTextureCoordinate;"
"void main()"
@@ -75,6 +83,10 @@
" vec2 normalizedPosition = a_position * .5 + .5;"
" if (u_flipY == 1)"
" normalizedPosition.y = 1.0 - normalizedPosition.y;"
+ " if (u_flipX == 1)"
+ " normalizedPosition.x = 1.0 - normalizedPosition.x;"
+ " if (u_swapXY == 1)"
+ " normalizedPosition.xy = normalizedPosition.yx;"
" v_yTextureCoordinate = normalizedPosition * u_yTextureSize;"
" v_uvTextureCoordinate = normalizedPosition * u_uvTextureSize;"
"}"_s
@@ -548,6 +560,8 @@
m_uvTextureUniformLocation = GL_GetUniformLocation(yuvProgram, "u_uvTexture");
m_colorMatrixUniformLocation = GL_GetUniformLocation(yuvProgram, "u_colorMatrix");
m_yuvFlipYUniformLocation = GL_GetUniformLocation(yuvProgram, "u_flipY");
+ m_yuvFlipXUniformLocation = GL_GetUniformLocation(yuvProgram, "u_flipX");
+ m_yuvSwapXYUniformLocation = GL_GetUniformLocation(yuvProgram, "u_swapXY");
m_yTextureSizeUniformLocation = GL_GetUniformLocation(yuvProgram, "u_yTextureSize");
m_uvTextureSizeUniformLocation = GL_GetUniformLocation(yuvProgram, "u_uvTextureSize");
m_yuvPositionAttributeLocation = GL_GetAttribLocation(yuvProgram, "a_position");
@@ -559,8 +573,9 @@
GL_BindFramebuffer(GL_FRAMEBUFFER, m_framebuffer);
}
-bool GraphicsContextGLCVCocoa::copyPixelBufferToTexture(CVPixelBufferRef image, PlatformGLObject outputTexture, GLint level, GLenum internalFormat, GLenum format, GLenum type, FlipY flipY)
+bool GraphicsContextGLCVCocoa::copyVideoSampleToTexture(const MediaSampleVideoFrame& videoFrame, PlatformGLObject outputTexture, GLint level, GLenum internalFormat, GLenum format, GLenum type, FlipY unpackFlipY)
{
+ auto image = videoFrame.pixelBuffer();
// FIXME: This currently only supports '420v' and '420f' pixel formats. Investigate supporting more pixel formats.
OSType pixelFormat = CVPixelBufferGetPixelFormatType(image);
if (pixelFormat != kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange // NOLINT
@@ -577,9 +592,10 @@
if (!surface)
return false;
+ auto orientation = videoFrame.orientation();
auto newSurfaceSeed = IOSurfaceGetSeed(surface);
- if (flipY == m_lastFlipY
- && surface == m_lastSurface
+ if (ImageOrientation::Orientation(orientation) == ImageOrientation::Orientation(m_lastSurfaceOrientation)
+ && unpackFlipY == m_lastUnpackFlipY
&& newSurfaceSeed == m_lastSurfaceSeed
&& lastTextureSeed(outputTexture) == m_owner.textureSeed(outputTexture)) {
// If the texture hasn't been modified since the last time we copied to it, and the
@@ -589,9 +605,61 @@
if (!m_context || !GraphicsContextGLCocoa::makeCurrent(m_display, m_context))
return false;
- size_t width = CVPixelBufferGetWidth(image);
- size_t height = CVPixelBufferGetHeight(image);
+ // Compute transform that undoes the `orientation`, e.g. moves the origin to top left.
+ // Even number of operations (flipX, flipY, swapXY) means a rotation.
+ // Odd number of operations means a rotation and a flip.
+ // `flipX` switches between Left and Right. `flipY` switches between Top and Bottom.
+ // `swapXY`switches LeftTop to TopLeft.
+ // Goal is to get to OriginTopLeft.
+ bool flipY = false; // Flip y coordinate, i.e. mirrored along the x-axis.
+ bool flipX = false; // Flip x coordinate, i.e. mirrored along the y-axis.
+ bool swapXY = false;
+ switch (videoFrame.orientation()) {
+ case ImageOrientation::FromImage:
+ case ImageOrientation::OriginTopLeft:
+ break;
+ case ImageOrientation::OriginTopRight:
+ flipX = true;
+ break;
+ case ImageOrientation::OriginBottomRight:
+ // Rotated 180 degrees.
+ flipY = true;
+ flipX = true;
+ break;
+ case ImageOrientation::OriginBottomLeft:
+ // Mirrored along the x-axis.
+ flipY = true;
+ break;
+ case ImageOrientation::OriginLeftTop:
+ // Mirrored along x-axis and rotated 270 degrees clock-wise.
+ swapXY = true;
+ break;
+ case ImageOrientation::OriginRightTop:
+ // Rotated 90 degrees clock-wise.
+ flipX = true;
+ swapXY = true;
+ break;
+ case ImageOrientation::OriginRightBottom:
+ // Mirror along x-axis and rotated 90 degrees clockwise.
+ flipY = true;
+ flipX = true;
+ swapXY = true;
+ break;
+ case ImageOrientation::OriginLeftBottom:
+ // Rotated 270 degrees clock-wise.
+ flipY = true;
+ swapXY = true;
+ break;
+ }
+ if (unpackFlipY == FlipY::Yes)
+ flipY = !flipY;
+ size_t sourceWidth = CVPixelBufferGetWidth(image);
+ size_t sourceHeight = CVPixelBufferGetHeight(image);
+
+ size_t width = swapXY ? sourceHeight : sourceWidth;
+ size_t height = swapXY ? sourceWidth : sourceHeight;
+
GL_Viewport(0, 0, width, height);
// The outputTexture might contain uninitialized content on early-outs. Clear it in cases
@@ -664,7 +732,9 @@
// Configure the drawing parameters.
GL_Uniform1i(m_yTextureUniformLocation, 0);
GL_Uniform1i(m_uvTextureUniformLocation, 1);
- GL_Uniform1i(m_yuvFlipYUniformLocation, flipY == FlipY::Yes ? 1 : 0);
+ GL_Uniform1i(m_yuvFlipYUniformLocation, flipY ? 1 : 0);
+ GL_Uniform1i(m_yuvFlipXUniformLocation, flipX ? 1 : 0);
+ GL_Uniform1i(m_yuvSwapXYUniformLocation, swapXY ? 1 : 0);
GL_Uniform2f(m_yTextureSizeUniformLocation, yPlaneWidth, yPlaneHeight);
GL_Uniform2f(m_uvTextureSizeUniformLocation, uvPlaneWidth, uvPlaneHeight);
@@ -676,10 +746,11 @@
// Do the actual drawing.
GL_DrawArrays(GL_TRIANGLES, 0, 6);
+ m_lastUnpackFlipY = unpackFlipY;
m_lastSurface = surface;
m_lastSurfaceSeed = newSurfaceSeed;
+ m_lastSurfaceOrientation = orientation;
m_lastTextureSeed.set(outputTexture, m_owner.textureSeed(outputTexture));
- m_lastFlipY = flipY;
autoClearTextureOnError.release();
return true;
}
Modified: trunk/Source/WebCore/platform/graphics/cv/GraphicsContextGLCVCocoa.h (288314 => 288315)
--- trunk/Source/WebCore/platform/graphics/cv/GraphicsContextGLCVCocoa.h 2022-01-20 20:34:39 UTC (rev 288314)
+++ trunk/Source/WebCore/platform/graphics/cv/GraphicsContextGLCVCocoa.h 2022-01-20 20:48:42 UTC (rev 288315)
@@ -28,7 +28,7 @@
#if ENABLE(WEBGL) && ENABLE(VIDEO) && USE(AVFOUNDATION)
#include "GraphicsContextGLCV.h"
-
+#include "ImageOrientation.h"
#include <memory>
#include <wtf/UnsafePointer.h>
@@ -44,7 +44,7 @@
~GraphicsContextGLCVCocoa() final;
- bool copyPixelBufferToTexture(CVPixelBufferRef, PlatformGLObject outputTexture, GCGLint level, GCGLenum internalFormat, GCGLenum format, GCGLenum type, FlipY) final;
+ bool copyVideoSampleToTexture(const MediaSampleVideoFrame&, PlatformGLObject outputTexture, GCGLint level, GCGLenum internalFormat, GCGLenum format, GCGLenum type, FlipY) final;
private:
GraphicsContextGLCVCocoa(GraphicsContextGLCocoa&);
@@ -64,12 +64,15 @@
GCGLint m_yTextureUniformLocation { -1 };
GCGLint m_uvTextureUniformLocation { -1 };
GCGLint m_yuvFlipYUniformLocation { -1 };
+ GCGLint m_yuvFlipXUniformLocation { -1 };
+ GCGLint m_yuvSwapXYUniformLocation { -1 };
GCGLint m_colorMatrixUniformLocation { -1 };
GCGLint m_yuvPositionAttributeLocation { -1 };
GCGLint m_yTextureSizeUniformLocation { -1 };
GCGLint m_uvTextureSizeUniformLocation { -1 };
- FlipY m_lastFlipY { FlipY::No };
+ FlipY m_lastUnpackFlipY { FlipY::No };
+ ImageOrientation m_lastSurfaceOrientation;
UnsafePointer<IOSurfaceRef> m_lastSurface;
uint32_t m_lastSurfaceSeed { 0 };
Modified: trunk/Source/WebCore/platform/mock/MockRealtimeVideoSource.cpp (288314 => 288315)
--- trunk/Source/WebCore/platform/mock/MockRealtimeVideoSource.cpp 2022-01-20 20:34:39 UTC (rev 288314)
+++ trunk/Source/WebCore/platform/mock/MockRealtimeVideoSource.cpp 2022-01-20 20:48:42 UTC (rev 288315)
@@ -509,6 +509,7 @@
m_deviceOrientation = MediaSample::VideoRotation::UpsideDown;
break;
default:
+ ASSERT_NOT_REACHED();
return;
}
Modified: trunk/Source/WebKit/ChangeLog (288314 => 288315)
--- trunk/Source/WebKit/ChangeLog 2022-01-20 20:34:39 UTC (rev 288314)
+++ trunk/Source/WebKit/ChangeLog 2022-01-20 20:48:42 UTC (rev 288315)
@@ -1,3 +1,31 @@
+2022-01-20 Kimmo Kinnunen <[email protected]>
+
+ Implement WebGL GPU buffer texture upload path for Cocoa getUserMedia camera streams
+ https://bugs.webkit.org/show_bug.cgi?id=235233
+ <rdar://problem/87601762>
+
+ Reviewed by Youenn Fablet.
+
+ Rename functions from pixelBuffer... to videoFrame.
+ Send new type MediaPlayerVideoFrame instead of CVPixelBuffer.
+ MediaPlayerVideoFrame contains also the frame orientation.
+
+ * GPUProcess/graphics/RemoteGraphicsContextGL.cpp:
+ (WebKit::RemoteGraphicsContextGL::copyTextureFromMedia):
+ * GPUProcess/media/RemoteMediaPlayerProxy.cpp:
+ (WebKit::RemoteMediaPlayerProxy::invalidate):
+ (WebKit::RemoteMediaPlayerProxy::videoFrameForCurrentTimeIfChanged):
+ * GPUProcess/media/RemoteMediaPlayerProxy.h:
+ * GPUProcess/media/RemoteMediaPlayerProxy.messages.in:
+ * GPUProcess/media/cocoa/RemoteMediaPlayerProxyCocoa.mm:
+ (WebKit::RemoteMediaPlayerProxy::pixelBufferForCurrentTimeIfChanged): Deleted.
+ * WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp:
+ (WebKit::MediaPlayerPrivateRemote::videoFrameForCurrentTime):
+ (WebKit::MediaPlayerPrivateRemote::pixelBufferForCurrentTime): Deleted.
+ * WebProcess/GPU/media/MediaPlayerPrivateRemote.h:
+ * WebProcess/GPU/media/cocoa/MediaPlayerPrivateRemoteCocoa.mm:
+ (WebKit::MediaPlayerPrivateRemote::pixelBufferForCurrentTime): Deleted.
+
2022-01-20 Ross Kirsling <[email protected]>
Unreviewed PlayStation / clang-cl build fix following r288298.
Modified: trunk/Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.cpp (288314 => 288315)
--- trunk/Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.cpp 2022-01-20 20:34:39 UTC (rev 288314)
+++ trunk/Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.cpp 2022-01-20 20:48:42 UTC (rev 288315)
@@ -260,18 +260,18 @@
UNUSED_VARIABLE(premultiplyAlpha);
ASSERT_UNUSED(target, target == GraphicsContextGL::TEXTURE_2D);
- RetainPtr<CVPixelBufferRef> pixelBuffer;
- auto getPixelBuffer = [&] {
+ std::optional<MediaSampleVideoFrame> videoFrame;
+ auto getVideoFrame = [&] {
if (!m_gpuConnectionToWebProcess)
return;
if (auto mediaPlayer = m_gpuConnectionToWebProcess->remoteMediaPlayerManagerProxy().mediaPlayer(mediaPlayerIdentifier))
- pixelBuffer = mediaPlayer->pixelBufferForCurrentTime();
+ videoFrame = mediaPlayer->videoFrameForCurrentTime();
};
- callOnMainRunLoopAndWait(WTFMove(getPixelBuffer));
+ callOnMainRunLoopAndWait(WTFMove(getVideoFrame));
- if (!pixelBuffer) {
+ if (!videoFrame) {
completionHandler(false);
return;
}
@@ -282,7 +282,7 @@
return;
}
- completionHandler(contextCV->copyPixelBufferToTexture(pixelBuffer.get(), texture, level, internalFormat, format, type, GraphicsContextGL::FlipY(flipY)));
+ completionHandler(contextCV->copyVideoSampleToTexture(*videoFrame, texture, level, internalFormat, format, type, GraphicsContextGL::FlipY(flipY)));
#else
UNUSED_VARIABLE(mediaPlayerIdentifier);
UNUSED_VARIABLE(texture);
Modified: trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.cpp (288314 => 288315)
--- trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.cpp 2022-01-20 20:34:39 UTC (rev 288314)
+++ trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.cpp 2022-01-20 20:48:42 UTC (rev 288315)
@@ -107,7 +107,7 @@
}
m_renderingResourcesRequest = { };
#if USE(AVFOUNDATION)
- m_pixelBufferForCurrentTime = nullptr;
+ m_videoFrameForCurrentTime = std::nullopt;
#endif
}
@@ -868,6 +868,21 @@
m_webProcessConnection->send(Messages::MediaPlayerPrivateRemote::CurrentTimeChanged(mediaTime, MonotonicTime::now(), !mediaPlayerPausedOrStalled()), m_id);
}
+void RemoteMediaPlayerProxy::videoFrameForCurrentTimeIfChanged(CompletionHandler<void(std::optional<WebCore::MediaSampleVideoFrame>&&, bool)>&& completionHandler)
+{
+ std::optional<WebCore::MediaSampleVideoFrame> result;
+ bool changed = false;
+ std::optional<WebCore::MediaSampleVideoFrame> videoFrame;
+ if (m_player)
+ videoFrame = m_player->videoFrameForCurrentTime();
+ if (!(m_videoFrameForCurrentTime == videoFrame)) {
+ m_videoFrameForCurrentTime = videoFrame;
+ changed = true;
+ result = WTFMove(videoFrame);
+ }
+ completionHandler(WTFMove(result), changed);
+}
+
void RemoteMediaPlayerProxy::updateCachedState(bool forceCurrentTimeUpdate)
{
if (!m_observingTimeChanges || forceCurrentTimeUpdate)
Modified: trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.h (288314 => 288315)
--- trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.h 2022-01-20 20:34:39 UTC (rev 288314)
+++ trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.h 2022-01-20 20:48:42 UTC (rev 288315)
@@ -320,9 +320,7 @@
void nativeImageForCurrentTime(CompletionHandler<void(std::optional<WTF::MachSendRight>&&, WebCore::DestinationColorSpace)>&&);
void colorSpace(CompletionHandler<void(WebCore::DestinationColorSpace)>&&);
#endif
-#if USE(AVFOUNDATION)
- void pixelBufferForCurrentTimeIfChanged(CompletionHandler<void(std::optional<RetainPtr<CVPixelBufferRef>>&&)>&&);
-#endif
+ void videoFrameForCurrentTimeIfChanged(CompletionHandler<void(std::optional<WebCore::MediaSampleVideoFrame>&&, bool)>&&);
#if !RELEASE_LOG_DISABLED
const Logger& mediaPlayerLogger() final { return m_logger; }
@@ -378,9 +376,7 @@
ScopedRenderingResourcesRequest m_renderingResourcesRequest;
bool m_observingTimeChanges { false };
-#if USE(AVFOUNDATION)
- RetainPtr<CVPixelBufferRef> m_pixelBufferForCurrentTime;
-#endif
+ std::optional<WebCore::MediaSampleVideoFrame> m_videoFrameForCurrentTime;
#if !RELEASE_LOG_DISABLED
const Logger& m_logger;
#endif
Modified: trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.messages.in (288314 => 288315)
--- trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.messages.in 2022-01-20 20:34:39 UTC (rev 288314)
+++ trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.messages.in 2022-01-20 20:48:42 UTC (rev 288315)
@@ -126,9 +126,7 @@
NativeImageForCurrentTime() -> (std::optional<MachSendRight> sendRight, WebCore::DestinationColorSpace colorSpace) Synchronous
ColorSpace() -> (WebCore::DestinationColorSpace colorSpace) Synchronous
#endif
-#if USE(AVFOUNDATION)
- PixelBufferForCurrentTimeIfChanged() -> (std::optional<RetainPtr<CVPixelBufferRef>> pixelBuffer) Synchronous
-#endif
+ VideoFrameForCurrentTimeIfChanged() -> (std::optional<WebCore::MediaSampleVideoFrame> videoFrame, bool changed) Synchronous
PlayAtHostTime(MonotonicTime time)
PauseAtHostTime(MonotonicTime time)
Modified: trunk/Source/WebKit/GPUProcess/media/cocoa/RemoteMediaPlayerProxyCocoa.mm (288314 => 288315)
--- trunk/Source/WebKit/GPUProcess/media/cocoa/RemoteMediaPlayerProxyCocoa.mm 2022-01-20 20:34:39 UTC (rev 288314)
+++ trunk/Source/WebKit/GPUProcess/media/cocoa/RemoteMediaPlayerProxyCocoa.mm 2022-01-20 20:48:42 UTC (rev 288315)
@@ -127,21 +127,6 @@
completionHandler(m_player->colorSpace());
}
-#if USE(AVFOUNDATION)
-void RemoteMediaPlayerProxy::pixelBufferForCurrentTimeIfChanged(CompletionHandler<void(std::optional<RetainPtr<CVPixelBufferRef>>&&)>&& completionHandler)
-{
- std::optional<RetainPtr<CVPixelBufferRef>> result;
- RetainPtr<CVPixelBufferRef> pixelBuffer;
- if (m_player)
- pixelBuffer = m_player->pixelBufferForCurrentTime();
- if (m_pixelBufferForCurrentTime != pixelBuffer) {
- result = pixelBuffer;
- m_pixelBufferForCurrentTime = WTFMove(pixelBuffer);
- }
- completionHandler(WTFMove(result));
-}
-#endif
-
} // namespace WebKit
#endif // ENABLE(GPU_PROCESS) && PLATFORM(COCOA)
Modified: trunk/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp (288314 => 288315)
--- trunk/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp 2022-01-20 20:34:39 UTC (rev 288314)
+++ trunk/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp 2022-01-20 20:48:42 UTC (rev 288315)
@@ -1000,13 +1000,18 @@
notImplemented();
return false;
}
-#elif !PLATFORM(COCOA)
-RetainPtr<CVPixelBufferRef> MediaPlayerPrivateRemote::pixelBufferForCurrentTime()
+#endif
+
+std::optional<WebCore::MediaSampleVideoFrame> MediaPlayerPrivateRemote::videoFrameForCurrentTime()
{
- notImplemented();
- return false;
+ std::optional<WebCore::MediaSampleVideoFrame> result;
+ bool changed = false;
+ if (!connection().sendSync(Messages::RemoteMediaPlayerProxy::VideoFrameForCurrentTimeIfChanged(), Messages::RemoteMediaPlayerProxy::VideoFrameForCurrentTimeIfChanged::Reply(result, changed), m_id))
+ return std::nullopt;
+ if (changed)
+ m_videoFrameForCurrentTime = WTFMove(result);
+ return m_videoFrameForCurrentTime;
}
-#endif
#if !PLATFORM(COCOA)
RefPtr<NativeImage> MediaPlayerPrivateRemote::nativeImageForCurrentTime()
Modified: trunk/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.h (288314 => 288315)
--- trunk/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.h 2022-01-20 20:34:39 UTC (rev 288314)
+++ trunk/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.h 2022-01-20 20:48:42 UTC (rev 288315)
@@ -292,9 +292,8 @@
void paintCurrentFrameInContext(WebCore::GraphicsContext&, const WebCore::FloatRect&) final;
#if !USE(AVFOUNDATION)
bool copyVideoTextureToPlatformTexture(WebCore::GraphicsContextGL*, PlatformGLObject, GCGLenum, GCGLint, GCGLenum, GCGLenum, GCGLenum, bool, bool) final;
-#else
- RetainPtr<CVPixelBufferRef> pixelBufferForCurrentTime() final;
#endif
+ std::optional<WebCore::MediaSampleVideoFrame> videoFrameForCurrentTime() final;
RefPtr<WebCore::NativeImage> nativeImageForCurrentTime() final;
WebCore::DestinationColorSpace colorSpace() final;
@@ -461,9 +460,7 @@
bool m_waitingForKey { false };
bool m_timeIsProgressing { false };
bool m_renderingCanBeAccelerated { false };
-#if USE(AVFOUNDATION)
- RetainPtr<CVPixelBufferRef> m_pixelBufferForCurrentTime;
-#endif
+ std::optional<WebCore::MediaSampleVideoFrame> m_videoFrameForCurrentTime;
#if PLATFORM(COCOA)
RetainPtr<CVPixelBufferRef> m_pixelBufferGatheredWithVideoFrameMetadata;
std::unique_ptr<WebCore::PixelBufferConformerCV> m_pixelBufferConformer;
Modified: trunk/Source/WebKit/WebProcess/GPU/media/cocoa/MediaPlayerPrivateRemoteCocoa.mm (288314 => 288315)
--- trunk/Source/WebKit/WebProcess/GPU/media/cocoa/MediaPlayerPrivateRemoteCocoa.mm 2022-01-20 20:34:39 UTC (rev 288314)
+++ trunk/Source/WebKit/WebProcess/GPU/media/cocoa/MediaPlayerPrivateRemoteCocoa.mm 2022-01-20 20:48:42 UTC (rev 288315)
@@ -94,18 +94,6 @@
return colorSpace;
}
-#if USE(AVFOUNDATION)
-RetainPtr<CVPixelBufferRef> MediaPlayerPrivateRemote::pixelBufferForCurrentTime()
-{
- std::optional<RetainPtr<CVPixelBufferRef>> result;
- if (!connection().sendSync(Messages::RemoteMediaPlayerProxy::PixelBufferForCurrentTimeIfChanged(), Messages::RemoteMediaPlayerProxy::PixelBufferForCurrentTimeIfChanged::Reply(result), m_id))
- return nullptr;
- if (result)
- m_pixelBufferForCurrentTime = WTFMove(*result);
- return m_pixelBufferForCurrentTime;
-}
-#endif
-
} // namespace WebKit
#endif // ENABLE(GPU_PROCESS) && PLATFORM(COCOA)