Diff
Modified: trunk/LayoutTests/platform/glib/TestExpectations (295025 => 295026)
--- trunk/LayoutTests/platform/glib/TestExpectations 2022-05-30 13:54:04 UTC (rev 295025)
+++ trunk/LayoutTests/platform/glib/TestExpectations 2022-05-30 14:05:27 UTC (rev 295026)
@@ -923,6 +923,9 @@
webkit.org/b/235885 webrtc/audio-video-element-playing.html [ Timeout ]
webkit.org/b/235885 webrtc/candidate-stats.html [ Failure ]
webkit.org/b/235885 webrtc/canvas-to-peer-connection.html [ Failure ]
+webkit.org/b/235885 webrtc/canvas-to-peer-connection-2d.html [ Failure ]
+webkit.org/b/235885 webrtc/canvas-to-peer-connection-vp8-2d.html [ Failure ]
+webkit.org/b/235885 webrtc/canvas-to-peer-connection-vp8.html [ Failure ]
webkit.org/b/235885 webrtc/captureCanvas-webrtc.html [ Timeout ]
webkit.org/b/235885 webrtc/closing-peerconnection.html [ Timeout ]
webkit.org/b/235885 webrtc/direction-change.html [ Failure ]
Modified: trunk/LayoutTests/platform/ios-simulator/TestExpectations (295025 => 295026)
--- trunk/LayoutTests/platform/ios-simulator/TestExpectations 2022-05-30 13:54:04 UTC (rev 295025)
+++ trunk/LayoutTests/platform/ios-simulator/TestExpectations 2022-05-30 14:05:27 UTC (rev 295026)
@@ -33,6 +33,9 @@
imported/w3c/web-platform-tests/webrtc/RTCPeerConnection-setLocalDescription-offer.html [ Failure ]
webkit.org/b/235765 webrtc/canvas-to-peer-connection.html [ Failure ]
+webkit.org/b/235765 webrtc/canvas-to-peer-connection-2d.html [ Failure ]
+webkit.org/b/235765 webrtc/canvas-to-peer-connection-vp8.html [ Failure ]
+webkit.org/b/235765 webrtc/canvas-to-peer-connection-vp8-2d.html [ Failure ]
# Simulator doesn't support WebAssembly.
imported/w3c/web-platform-tests/wasm/wasm_stream_instantiate_test.html [ Skip ]
Modified: trunk/LayoutTests/platform/mac-wk2/TestExpectations (295025 => 295026)
--- trunk/LayoutTests/platform/mac-wk2/TestExpectations 2022-05-30 13:54:04 UTC (rev 295025)
+++ trunk/LayoutTests/platform/mac-wk2/TestExpectations 2022-05-30 14:05:27 UTC (rev 295026)
@@ -1733,8 +1733,6 @@
webkit.org/b/240735 [ Release ] webgl/2.0.0/conformance2/textures/image_bitmap_from_image_bitmap/tex-2d-r11f_g11f_b10f-rgb-float.html [ Pass Failure ]
webkit.org/b/240735 [ Release ] webgl/2.0.0/conformance2/textures/image_bitmap_from_image_bitmap/tex-2d-r16f-red-half_float.html [ Pass Failure ]
-webkit.org/b/240814 webrtc/canvas-to-peer-connection.html [ Pass Failure ]
-
webkit.org/b/240821 [ Monterey Release ] webgl/max-active-contexts-webglcontextlost-prevent-default.html [ Slow ]
webkit.org/b/240830 [ Monterey ] webgl/2.0.0/conformance/attribs/gl-vertexattribpointer-offsets.html [ Pass Timeout ]
Added: trunk/LayoutTests/webrtc/canvas-to-peer-connection-2d-expected.txt (0 => 295026)
--- trunk/LayoutTests/webrtc/canvas-to-peer-connection-2d-expected.txt (rev 0)
+++ trunk/LayoutTests/webrtc/canvas-to-peer-connection-2d-expected.txt 2022-05-30 14:05:27 UTC (rev 295026)
@@ -0,0 +1,3 @@
+
+PASS draw: with2DContext
+
Added: trunk/LayoutTests/webrtc/canvas-to-peer-connection-2d.html (0 => 295026)
--- trunk/LayoutTests/webrtc/canvas-to-peer-connection-2d.html (rev 0)
+++ trunk/LayoutTests/webrtc/canvas-to-peer-connection-2d.html 2022-05-30 14:05:27 UTC (rev 295026)
@@ -0,0 +1,24 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src=""
+<script src=""
+<script src=""
+<script src=""
+<style type="text/css">
+video { width: 40px; }
+canvas { width: 40px; }
+</style>
+</head>
+<body>
+<div id="debuge"></div>
+<script>
+function testDescription(subcase) {
+ return Object.keys(subcase).map((k) => `${k}: ${typeof subcase[k] === "function" ? subcase[k].name : subcase[k]}`).join(",");
+}
+
+const testcase = {draw: with2DContext};
+promise_test(async t => { await testCanvasToPeerConnection(t, testcase); }, testDescription(testcase));
+</script>
+</body>
+</html>
Added: trunk/LayoutTests/webrtc/canvas-to-peer-connection-vp8-2d-expected.txt (0 => 295026)
--- trunk/LayoutTests/webrtc/canvas-to-peer-connection-vp8-2d-expected.txt (rev 0)
+++ trunk/LayoutTests/webrtc/canvas-to-peer-connection-vp8-2d-expected.txt 2022-05-30 14:05:27 UTC (rev 295026)
@@ -0,0 +1,3 @@
+
+PASS draw: with2DContext
+
Added: trunk/LayoutTests/webrtc/canvas-to-peer-connection-vp8-2d.html (0 => 295026)
--- trunk/LayoutTests/webrtc/canvas-to-peer-connection-vp8-2d.html (rev 0)
+++ trunk/LayoutTests/webrtc/canvas-to-peer-connection-vp8-2d.html 2022-05-30 14:05:27 UTC (rev 295026)
@@ -0,0 +1,27 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src=""
+<script src=""
+<script src=""
+<script src=""
+<style type="text/css">
+video { width: 400px; }
+canvas { width: 400px; }
+</style>
+</head>
+<body>
+<div id="debuge"></div>
+<script>
+function testDescription(subcase) {
+ return Object.keys(subcase).map((k) => `${k}: ${typeof subcase[k] === "function" ? subcase[k].name : subcase[k]}`).join(",");
+}
+
+const testcase = {draw: with2DContext};
+useVP8 = true;
+// FIXME: We should reduce to 25 when having a good RGB -> YUC conversion story for VPx.
+pixelColorTestError = 50;
+promise_test(async t => { await testCanvasToPeerConnection(t, testcase); }, testDescription(testcase));
+</script>
+</body>
+</html>
Added: trunk/LayoutTests/webrtc/canvas-to-peer-connection-vp8-expected.txt (0 => 295026)
--- trunk/LayoutTests/webrtc/canvas-to-peer-connection-vp8-expected.txt (rev 0)
+++ trunk/LayoutTests/webrtc/canvas-to-peer-connection-vp8-expected.txt 2022-05-30 14:05:27 UTC (rev 295026)
@@ -0,0 +1,3 @@
+
+PASS draw: withWebGL
+
Added: trunk/LayoutTests/webrtc/canvas-to-peer-connection-vp8.html (0 => 295026)
--- trunk/LayoutTests/webrtc/canvas-to-peer-connection-vp8.html (rev 0)
+++ trunk/LayoutTests/webrtc/canvas-to-peer-connection-vp8.html 2022-05-30 14:05:27 UTC (rev 295026)
@@ -0,0 +1,27 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src=""
+<script src=""
+<script src=""
+<script src=""
+<style type="text/css">
+video { width: 40px; }
+canvas { width: 40px; }
+</style>
+</head>
+<body>
+<div id="debuge"></div>
+<script>
+function testDescription(subcase) {
+ return Object.keys(subcase).map((k) => `${k}: ${typeof subcase[k] === "function" ? subcase[k].name : subcase[k]}`).join(",");
+}
+
+const testcase = {draw: withWebGL};
+useVP8 = true;
+// FIXME: We should reduce to 25 when having a good RGB -> YUC conversion story for VPx.
+pixelColorTestError = 50;
+promise_test(async t => { await testCanvasToPeerConnection(t, testcase); }, testDescription(testcase));
+</script>
+</body>
+</html>
Modified: trunk/LayoutTests/webrtc/canvas-to-peer-connection.html (295025 => 295026)
--- trunk/LayoutTests/webrtc/canvas-to-peer-connection.html 2022-05-30 13:54:04 UTC (rev 295025)
+++ trunk/LayoutTests/webrtc/canvas-to-peer-connection.html 2022-05-30 14:05:27 UTC (rev 295026)
@@ -3,7 +3,8 @@
<head>
<script src=""
<script src=""
-<script src =""
+<script src=""
+<script src=""
<style type="text/css">
video { width: 40px; }
canvas { width: 40px; }
@@ -12,125 +13,12 @@
<body>
<div id="debuge"></div>
<script>
-"use strict";
-
-function with2DContext(subcase, canvas, patternNumber)
-{
- drawCanvasTestPattern2D(canvas, patternNumber);
-}
-
-function withWebGL(subcase, canvas, patternNumber)
-{
- drawCanvasTestPatternWebGL(canvas, patternNumber);
-}
-
-async function createLocalPeerConnectionStream(stream)
-{
- return new Promise((resolve, reject) => {
- createConnections((firstConnection) => {
- firstConnection.addTrack(stream.getVideoTracks()[0], stream);
- }, (secondConnection) => {
- secondConnection._ontrack_ = (trackEvent) => {
- resolve(trackEvent.streams[0]);
- };
- });
- });
-}
-
-function waitForVideoFrame(video)
-{
- return new Promise((resolve) => {
- video.requestVideoFrameCallback((now, metadata) => {
- resolve(now, metadata);
- });
- });
-}
-
-const width = 500;
-const height = 500;
-
-async function waitForVideoFrameSize(video, width, height, counter)
-{
- if (!counter)
- counter = 0;
- else if (counter > 100)
- return Promise.reject("waitForVideoFrameSize timed out");
-
- const result = await new Promise((resolve, reject) => {
- video.requestVideoFrameCallback((now, metadata) => {
- resolve(metadata.width === width && metadata.height === height);
- });
- setTimeout(() => reject("video.requestVideoFrameCallback timed out"), 5000);
- });
- if (result)
- return;
-
- return waitForVideoFrameSize(video, width, height, ++counter);
-}
-
-async function drawAndValidate(subcase, canvas, video, counter, stepName)
-{
- // First change canvas width and wait for width change to clear previous frames.
- canvas.width = canvas.width + 500;
- canvas.height = canvas.height + 500;
-
- let counter1 = counter;
- let id = setInterval(() => { subcase.draw(subcase, canvas, counter1++)}, 100);
- await waitForVideoFrameSize(video, canvas.width, canvas.height);
- clearInterval(id);
-
- // Get back canvas size to normal and wait for width change to get test frames.
- canvas.width = canvas.width - 500;
- canvas.height = canvas.height - 500;
- id = setInterval(() => { subcase.draw(subcase, canvas, counter)}, 100);
- subcase.draw(subcase, canvas, counter);
- await waitForVideoFrameSize(video, canvas.width, canvas.height);
- clearInterval(id);
-
- assertImageSourceContainsCanvasTestPattern(video, counter, stepName);
-}
-
-async function testCanvasToPeerConnection(t, subcase)
-{
- const canvas = document.createElement("canvas");
- canvas.width = width;
- canvas.height = height;
- debuge.appendChild(canvas);
- t.add_cleanup(async () => debuge.removeChild(canvas));
- const localStream = canvas.captureStream();
- const remoteStream = await createLocalPeerConnectionStream(localStream);
- t.add_cleanup(async () => closeConnections());
-
- const video = document.createElement("video");
- video.autoplay = true;
- video.controls = false;
- debuge.appendChild(video);
- t.add_cleanup(async () => debuge.removeChild(video));
- video.srcObject = remoteStream;
-
- for (let i = 0; i < 5; ++i)
- await drawAndValidate(subcase, canvas, video, 1, `base case: ${i}`);
-
- for (let i = 0; i < 5; ++i)
- await drawAndValidate(subcase, canvas, video, i, `iteration: ${i}`);
-}
-
-const subcases = [];
-// FIXME: This should be filled when 2D context supports HTMLCanvasElement.captureStream().
-// subcases.push({draw: with2DContext});
-subcases.push({draw: withWebGL});
-
function testDescription(subcase) {
return Object.keys(subcase).map((k) => `${k}: ${typeof subcase[k] === "function" ? subcase[k].name : subcase[k]}`).join(",");
}
-function createCanvasToPeerConnectionTests(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 testCanvasToPeerConnection(t, subcase); }, testDescription(subcase));
-}
-createCanvasToPeerConnectionTests(0, 1);
+const testcase = {draw: withWebGL};
+promise_test(async t => { await testCanvasToPeerConnection(t, testcase); }, testDescription(testcase));
</script>
</body>
</html>
Copied: trunk/LayoutTests/webrtc/canvas-to-peer-connection.js (from rev 295025, trunk/LayoutTests/webrtc/canvas-to-peer-connection.html) (0 => 295026)
--- trunk/LayoutTests/webrtc/canvas-to-peer-connection.js (rev 0)
+++ trunk/LayoutTests/webrtc/canvas-to-peer-connection.js 2022-05-30 14:05:27 UTC (rev 295026)
@@ -0,0 +1,103 @@
+function with2DContext(subcase, canvas, patternNumber)
+{
+ drawCanvasTestPattern2D(canvas, patternNumber);
+}
+
+function withWebGL(subcase, canvas, patternNumber)
+{
+ drawCanvasTestPatternWebGL(canvas, patternNumber);
+}
+
+var useVP8 = false;
+async function createLocalPeerConnectionStream(stream)
+{
+ return new Promise((resolve, reject) => {
+ createConnections((firstConnection) => {
+ firstConnection.addTrack(stream.getVideoTracks()[0], stream);
+ if (useVP8)
+ firstConnection.getTransceivers()[0].setCodecPreferences([{mimeType: "video/VP8", clockRate: 90000}]);
+ }, (secondConnection) => {
+ secondConnection._ontrack_ = (trackEvent) => {
+ resolve(trackEvent.streams[0]);
+ };
+ });
+ });
+}
+
+function waitForVideoFrame(video)
+{
+ return new Promise((resolve) => {
+ video.requestVideoFrameCallback((now, metadata) => {
+ resolve(now, metadata);
+ });
+ });
+}
+
+const width = 500;
+const height = 500;
+
+async function waitForVideoFrameSize(video, width, height, counter)
+{
+ if (!counter)
+ counter = 0;
+ else if (counter > 100)
+ return Promise.reject("waitForVideoFrameSize timed out");
+
+ const result = await new Promise((resolve, reject) => {
+ video.requestVideoFrameCallback((now, metadata) => {
+ resolve(metadata.width === width && metadata.height === height);
+ });
+ setTimeout(() => reject("video.requestVideoFrameCallback timed out"), 5000);
+ });
+ if (result)
+ return;
+
+ return waitForVideoFrameSize(video, width, height, ++counter);
+}
+
+let pixelColorTestError = 25;
+async function drawAndValidate(subcase, canvas, video, counter, stepName)
+{
+ // First change canvas width and wait for width change to clear previous frames.
+ canvas.width = canvas.width + 500;
+ canvas.height = canvas.height + 500;
+
+ let counter1 = counter;
+ let id = setInterval(() => { subcase.draw(subcase, canvas, counter1++)}, 100);
+ await waitForVideoFrameSize(video, canvas.width, canvas.height);
+ clearInterval(id);
+
+ // Get back canvas size to normal and wait for width change to get test frames.
+ canvas.width = canvas.width - 500;
+ canvas.height = canvas.height - 500;
+ id = setInterval(() => { subcase.draw(subcase, canvas, counter)}, 100);
+ subcase.draw(subcase, canvas, counter);
+ await waitForVideoFrameSize(video, canvas.width, canvas.height);
+ clearInterval(id);
+
+ assertImageSourceContainsCanvasTestPattern(video, counter, stepName, pixelColorTestError);
+}
+
+async function testCanvasToPeerConnection(t, subcase)
+{
+ const canvas = document.createElement("canvas");
+ canvas.width = width;
+ canvas.height = height;
+ debuge.appendChild(canvas);
+ const localStream = canvas.captureStream();
+ const remoteStream = await createLocalPeerConnectionStream(localStream);
+
+ const video = document.createElement("video");
+ video.autoplay = true;
+ video.controls = true;
+ debuge.appendChild(video);
+ t.add_cleanup(async () => debuge.removeChild(video));
+ video.srcObject = remoteStream;
+
+ for (let i = 0; i < 5; ++i)
+ await drawAndValidate(subcase, canvas, video, 1, `base case: ${i}`);
+
+ for (let i = 0; i < 5; ++i)
+ await drawAndValidate(subcase, canvas, video, i, `iteration: ${i}`);
+}
+
Modified: trunk/LayoutTests/webrtc/routines.js (295025 => 295026)
--- trunk/LayoutTests/webrtc/routines.js 2022-05-30 13:54:04 UTC (rev 295025)
+++ trunk/LayoutTests/webrtc/routines.js 2022-05-30 14:05:27 UTC (rev 295026)
@@ -393,14 +393,38 @@
}
}
-function assertImageSourceContainsCanvasTestPattern(imageSource, patternNumber, desc)
+function drawCanvasTestPattern2D(canvas, patternNumber)
{
patternNumber = patternNumber || 0;
+ const context = canvas.getContext("2d");
+ const boxSize = [ canvas.width, canvas.height ];
+ const boxes = [
+ [0.0, 0.0, 0.5, 0.5],
+ [0.5, 0.0, 1.0, 0.5],
+ [0.5, 0.5, 1.0, 1.0],
+ [0.0, 0.5, 0.5, 1.0],
+ ];
+ const boxColors = Object.values(testColors);
+ for (let n = 0; n < 4; ++n) {
+ const i = (n + patternNumber) % boxes.length;
+ const color = boxColors[i];
+ const box = boxes[n];
+
+ context.fillStyle = `rgb(${color[0]}, ${color[1]}, ${color[2]})`;
+ context.fillRect(box[0] * boxSize[0], box[1] * boxSize[1], box[2] * boxSize[0], box[3] * boxSize[1]);
+ }
+}
+
+
+function assertImageSourceContainsCanvasTestPattern(imageSource, patternNumber, desc, err)
+{
+ patternNumber = patternNumber || 0;
desc = desc || "";
const verifyWidth = 300;
// FIXME: canvas-to-peer-connection on Catalina-WK2 would fail with 0 -> 8 and 255 -> 240 for some reason.
// https://bugs.webkit.org/show_bug.cgi?id=235708
- const err = 25;
+ if (!err)
+ err = 25;
let imageSourceSize;
let imageSourceHeight;
if (imageSource instanceof HTMLVideoElement)
Modified: trunk/Source/WebCore/platform/cocoa/CoreVideoSoftLink.cpp (295025 => 295026)
--- trunk/Source/WebCore/platform/cocoa/CoreVideoSoftLink.cpp 2022-05-30 13:54:04 UTC (rev 295025)
+++ trunk/Source/WebCore/platform/cocoa/CoreVideoSoftLink.cpp 2022-05-30 14:05:27 UTC (rev 295026)
@@ -45,7 +45,7 @@
SOFT_LINK_FUNCTION_FOR_SOURCE(WebCore, CoreVideo, CVPixelBufferGetBaseAddress, void*, (CVPixelBufferRef pixelBuffer), (pixelBuffer))
SOFT_LINK_FUNCTION_FOR_SOURCE(WebCore, CoreVideo, CVPixelBufferGetBytesPerRow, size_t, (CVPixelBufferRef pixelBuffer), (pixelBuffer))
SOFT_LINK_FUNCTION_FOR_SOURCE(WebCore, CoreVideo, CVPixelBufferGetBytesPerRowOfPlane, size_t, (CVPixelBufferRef pixelBuffer, size_t planeIndex), (pixelBuffer, planeIndex))
-SOFT_LINK_FUNCTION_FOR_SOURCE(WebCore, CoreVideo, CVPixelBufferGetPixelFormatType, OSType, (CVPixelBufferRef pixelBuffer), (pixelBuffer))
+SOFT_LINK_FUNCTION_FOR_SOURCE_WITH_EXPORT(WebCore, CoreVideo, CVPixelBufferGetPixelFormatType, OSType, (CVPixelBufferRef pixelBuffer), (pixelBuffer), WEBCORE_EXPORT)
SOFT_LINK_FUNCTION_FOR_SOURCE(WebCore, CoreVideo, CVPixelBufferGetPlaneCount, size_t, (CVPixelBufferRef pixelBuffer), (pixelBuffer))
SOFT_LINK_FUNCTION_FOR_SOURCE(WebCore, CoreVideo, CVPixelBufferGetBaseAddressOfPlane, void *, (CVPixelBufferRef pixelBuffer, size_t planeIndex), (pixelBuffer, planeIndex));
SOFT_LINK_FUNCTION_FOR_SOURCE(WebCore, CoreVideo, CVPixelBufferLockBaseAddress, CVReturn, (CVPixelBufferRef pixelBuffer, CVOptionFlags lockFlags), (pixelBuffer, lockFlags))
Modified: trunk/Source/WebCore/platform/mediastream/mac/RealtimeOutgoingVideoSourceCocoa.cpp (295025 => 295026)
--- trunk/Source/WebCore/platform/mediastream/mac/RealtimeOutgoingVideoSourceCocoa.cpp 2022-05-30 13:54:04 UTC (rev 295025)
+++ trunk/Source/WebCore/platform/mediastream/mac/RealtimeOutgoingVideoSourceCocoa.cpp 2022-05-30 14:05:27 UTC (rev 295026)
@@ -102,30 +102,11 @@
}
}
+#if ASSERT_ENABLED
auto pixelFormat = videoFrame.pixelFormat();
- if (pixelFormat == kCVPixelFormatType_32BGRA) {
- auto size = videoFrame.presentationSize();
- auto pixelBufferPool = this->pixelBufferPool(size.width(), size.height());
- if (!pixelBufferPool)
- return;
- CVPixelBufferRef newPixelBuffer = nullptr;
- auto status = CVPixelBufferPoolCreatePixelBuffer(kCFAllocatorDefault, pixelBufferPool, &newPixelBuffer);
- if (status != kCVReturnSuccess) {
- RELEASE_LOG_ERROR(WebRTC, "RealtimeOutgoingVideoSourceCocoa failed creating a pixel buffer with error %d", status);
- return;
- }
-
- auto convertedBuffer = adoptCF(newPixelBuffer);
- ASSERT(!m_currentRotation);
- if (webrtc::convertBGRAToYUV(videoFrame.pixelBuffer(), convertedBuffer.get()))
- sendFrame(webrtc::pixelBufferToFrame(convertedBuffer.get()));
- else
- RELEASE_LOG_ERROR(WebRTC, "Unable to convert BGRA video frame to YUV");
- return;
- }
-
- // FIXME: For other pixel formats, we should use a pixel conformer.
- ASSERT(pixelFormat == kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange || pixelFormat == kCVPixelFormatType_420YpCbCr8BiPlanarFullRange);
+ // FIXME: We should use a pixel conformer for other pixel formats and kCVPixelFormatType_32BGRA.
+ ASSERT(pixelFormat == kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange || pixelFormat == kCVPixelFormatType_420YpCbCr8BiPlanarFullRange || pixelFormat == kCVPixelFormatType_32BGRA);
+#endif
RetainPtr<CVPixelBufferRef> convertedBuffer = videoFrame.pixelBuffer();
if (shouldApplyRotation)
convertedBuffer = rotatePixelBuffer(convertedBuffer.get(), m_currentRotation);
Modified: trunk/Source/WebCore/platform/mediastream/mac/RealtimeOutgoingVideoSourceCocoa.h (295025 => 295026)
--- trunk/Source/WebCore/platform/mediastream/mac/RealtimeOutgoingVideoSourceCocoa.h 2022-05-30 13:54:04 UTC (rev 295025)
+++ trunk/Source/WebCore/platform/mediastream/mac/RealtimeOutgoingVideoSourceCocoa.h 2022-05-30 14:05:27 UTC (rev 295026)
@@ -58,10 +58,6 @@
size_t m_rotatedHeight { 0 };
OSType m_rotatedFormat;
- RetainPtr<CVPixelBufferPoolRef> m_pixelBufferPool;
- size_t m_pixelBufferPoolWidth { 0 };
- size_t m_pixelBufferPoolHeight { 0 };
-
#if !RELEASE_LOG_DISABLED
size_t m_numberOfFrames { 0 };
#endif
Modified: trunk/Source/WebCore/platform/mediastream/mac/RealtimeOutgoingVideoSourceCocoa.mm (295025 => 295026)
--- trunk/Source/WebCore/platform/mediastream/mac/RealtimeOutgoingVideoSourceCocoa.mm 2022-05-30 13:54:04 UTC (rev 295025)
+++ trunk/Source/WebCore/platform/mediastream/mac/RealtimeOutgoingVideoSourceCocoa.mm 2022-05-30 14:05:27 UTC (rev 295026)
@@ -75,22 +75,6 @@
return m_rotationSession->rotate(pixelBuffer);
}
-CVPixelBufferPoolRef RealtimeOutgoingVideoSourceCocoa::pixelBufferPool(size_t width, size_t height)
-{
- if (!m_pixelBufferPool || m_pixelBufferPoolWidth != width || m_pixelBufferPoolHeight != height) {
- auto result = createInMemoryCVPixelBufferPool(width, height, kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange);
- if (!result) {
- RELEASE_LOG_ERROR(WebRTC, "RealtimeOutgoingVideoSourceCocoa failed creating buffer pool with error %d", result.error());
- return nullptr;
- }
-
- m_pixelBufferPool = WTFMove(*result);
- m_pixelBufferPoolWidth = width;
- m_pixelBufferPoolHeight = height;
- }
- return m_pixelBufferPool.get();
-}
-
} // namespace WebCore
#endif // USE(LIBWEBRTC)
Modified: trunk/Source/WebKit/GPUProcess/webrtc/LibWebRTCCodecsProxy.h (295025 => 295026)
--- trunk/Source/WebKit/GPUProcess/webrtc/LibWebRTCCodecsProxy.h 2022-05-30 13:54:04 UTC (rev 295025)
+++ trunk/Source/WebKit/GPUProcess/webrtc/LibWebRTCCodecsProxy.h 2022-05-30 14:05:27 UTC (rev 295026)
@@ -49,6 +49,10 @@
using LocalEncoder = void*;
}
+namespace WebCore {
+class PixelBufferConformerCV;
+}
+
namespace WebKit {
class GPUConnectionToWebProcess;
@@ -102,6 +106,8 @@
HashMap<RTCDecoderIdentifier, webrtc::LocalDecoder> m_decoders WTF_GUARDED_BY_CAPABILITY(workQueue());
HashMap<RTCEncoderIdentifier, Encoder> m_encoders WTF_GUARDED_BY_CAPABILITY(workQueue());
std::atomic<bool> m_hasEncodersOrDecoders { false };
+
+ std::unique_ptr<WebCore::PixelBufferConformerCV> m_pixelBufferConformer;
};
}
Modified: trunk/Source/WebKit/GPUProcess/webrtc/LibWebRTCCodecsProxy.mm (295025 => 295026)
--- trunk/Source/WebKit/GPUProcess/webrtc/LibWebRTCCodecsProxy.mm 2022-05-30 13:54:04 UTC (rev 295025)
+++ trunk/Source/WebKit/GPUProcess/webrtc/LibWebRTCCodecsProxy.mm 2022-05-30 14:05:27 UTC (rev 295026)
@@ -39,6 +39,7 @@
#import "WebCoreArgumentCoders.h"
#import <WebCore/CVUtilities.h>
#import <WebCore/LibWebRTCProvider.h>
+#import <WebCore/PixelBufferConformerCV.h>
#import <WebCore/VideoFrameCV.h>
#import <webrtc/sdk/WebKit/WebKitDecoder.h>
#import <webrtc/sdk/WebKit/WebKitEncoder.h>
@@ -46,8 +47,10 @@
#import <wtf/MediaTime.h>
#import <pal/cf/CoreMediaSoftLink.h>
+#import <WebCore/CoreVideoSoftLink.h>
namespace WebKit {
+using namespace WebCore;
Ref<LibWebRTCCodecsProxy> LibWebRTCCodecsProxy::create(GPUConnectionToWebProcess& webProcessConnection)
{
@@ -242,6 +245,15 @@
if (!pixelBuffer)
return;
+ if (CVPixelBufferGetPixelFormatType(pixelBuffer.get()) == kCVPixelFormatType_32BGRA) {
+ if (!m_pixelBufferConformer) {
+ m_pixelBufferConformer = makeUnique<WebCore::PixelBufferConformerCV>((__bridge CFDictionaryRef)@{ (__bridge NSString *)kCVPixelBufferPixelFormatTypeKey: @(kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange) });
+ }
+ pixelBuffer = m_pixelBufferConformer->convert(pixelBuffer.get());
+ if (!pixelBuffer)
+ return;
+ }
+
#if !PLATFORM(MACCATALYST)
webrtc::encodeLocalEncoderFrame(encoder->webrtcEncoder, pixelBuffer.get(), sharedVideoFrame.time.toTimeScale(1000000).timeValue(), timeStamp, toWebRTCVideoRotation(sharedVideoFrame.rotation), shouldEncodeAsKeyFrame);
#endif