Diff
Modified: trunk/Source/WebCore/ChangeLog (283035 => 283036)
--- trunk/Source/WebCore/ChangeLog 2021-09-24 11:13:33 UTC (rev 283035)
+++ trunk/Source/WebCore/ChangeLog 2021-09-24 12:41:04 UTC (rev 283036)
@@ -1,3 +1,70 @@
+2021-09-24 Kimmo Kinnunen <[email protected]>
+
+ Add utility to create CVPixelBuffers from IOSurfaces
+ https://bugs.webkit.org/show_bug.cgi?id=230338
+
+ Reviewed by Youenn Fablet.
+
+ Move the functionality of creating CVPixelBuffers
+ from IOSurfaces from ImageTransferSessionVT to
+ standalone functions in new header CVUtilities.
+ The functionality did not use any state of
+ ImageTransferSessionVT.
+
+ This functionality is useful in other scenarios too.
+
+ Remove instantiations of ImageTransferSessionVT from
+ the old call sites, as it was never used for anything
+ else than creation of the pixel buffer.
+
+ Move the related CVPixelBufferPool instantiation
+ from RealtimeVideoUtilities.h to CVUtilities.h
+
+ Remove the usage of kCVPixelFormatOpenGLESCompatibility
+ from the CVPixelBuffer creation code. It was incorrect property
+ all along, property of pixel formats not of pixel buffers. The
+ intended property was kCVPixelBufferOpenGLESCompatibilityKey
+ but it is not needed anymore.
+ Retains the usage of kCVPixelBufferOpenGLCompatibilityKey, though
+ it is incorrect and unneeded for the current operation too.
+ Since theoretically this could affect something on Mac, this
+ will be removed in a separate fix.
+
+ No new tests, a refactor.
+
+ * PlatformMac.cmake:
+ * SourcesCocoa.txt:
+ * WebCore.xcodeproj/project.pbxproj:
+ * platform/graphics/cv/CVUtilities.h: Added.
+ * platform/graphics/cv/CVUtilities.mm: Added.
+ (WebCore::createIOSurfaceCVPixelBufferPool):
+ (WebCore::createCVPixelBufferFromPool):
+ (WebCore::pixelBufferCreationOptions):
+ (WebCore::createCVPixelBuffer):
+ The added functions return Expected<object, status> since
+ some of the callers want to log the failure status code.
+ * platform/graphics/cv/ImageTransferSessionVT.h:
+ * platform/graphics/cv/ImageTransferSessionVT.mm:
+ (WebCore::ImageTransferSessionVT::setSize):
+ (WebCore::ImageTransferSessionVT::convertPixelBuffer):
+ (WebCore::ImageTransferSessionVT::convertCMSampleBuffer):
+ (WebCore::ImageTransferSessionVT::createCMSampleBuffer):
+ (WebCore::cvPixelFormatOpenGLKey): Deleted.
+ Incorrect, replaced with Mac-only use of OpenGLCompatibilityKey in
+ CVUtilities.mm.
+ (WebCore::roundUpToMacroblockMultiple): Deleted.
+ Use the similar function in WTF.
+ (WebCore::ImageTransferSessionVT::ioSurfacePixelBufferCreationOptions): Deleted.
+ * platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.mm:
+ (WebCore::RealtimeIncomingVideoSourceCocoa::pixelBufferPool):
+ * platform/mediastream/mac/RealtimeVideoUtilities.h:
+ Preserved, since preferedPixelBufferFormat means
+ "the pixel buffer format that is preferred by media stream implementations"
+ which does not fit to category of "CoreVideo Utilities".
+ * platform/mediastream/mac/RealtimeVideoUtilities.mm: Removed.
+ * platform/network/mac/WebCoreURLResponse.mm:
+ Fix unified build failure due to a missing include.
+
2021-09-24 Youenn Fablet <[email protected]>
<video> element rendered incorrectly when provided with a portrait orientation stream in Safari 15
Modified: trunk/Source/WebCore/PlatformMac.cmake (283035 => 283036)
--- trunk/Source/WebCore/PlatformMac.cmake 2021-09-24 11:13:33 UTC (rev 283035)
+++ trunk/Source/WebCore/PlatformMac.cmake 2021-09-24 12:41:04 UTC (rev 283036)
@@ -337,6 +337,7 @@
platform/graphics/coretext/FontPlatformDataCoreText.cpp
platform/graphics/coretext/GlyphPageCoreText.cpp
+ platform/graphics/cv/CVUtilities.mm
platform/graphics/cv/GraphicsContextGLCVANGLE.cpp
platform/graphics/cv/ImageRotationSessionVT.mm
platform/graphics/cv/PixelBufferConformerCV.cpp
Modified: trunk/Source/WebCore/SourcesCocoa.txt (283035 => 283036)
--- trunk/Source/WebCore/SourcesCocoa.txt 2021-09-24 11:13:33 UTC (rev 283035)
+++ trunk/Source/WebCore/SourcesCocoa.txt 2021-09-24 12:41:04 UTC (rev 283036)
@@ -391,6 +391,7 @@
platform/graphics/coretext/FontCoreText.cpp
platform/graphics/coretext/FontPlatformDataCoreText.cpp
platform/graphics/coretext/GlyphPageCoreText.cpp
+platform/graphics/cv/CVUtilities.mm
platform/graphics/cv/ImageTransferSessionVT.mm
platform/graphics/cv/PixelBufferConformerCV.cpp
platform/graphics/cv/GraphicsContextGLCVANGLE.cpp
@@ -542,7 +543,6 @@
platform/mediastream/mac/RealtimeMediaSourceCenterMac.mm
platform/mediastream/mac/RealtimeOutgoingAudioSourceCocoa.cpp
platform/mediastream/mac/RealtimeOutgoingVideoSourceCocoa.cpp
-platform/mediastream/mac/RealtimeVideoUtilities.mm
platform/mediastream/mac/WebAudioSourceProviderCocoa.mm
platform/mock/MediaPlaybackTargetMock.cpp
platform/mock/MediaPlaybackTargetPickerMock.cpp
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (283035 => 283036)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2021-09-24 11:13:33 UTC (rev 283035)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2021-09-24 12:41:04 UTC (rev 283036)
@@ -2351,6 +2351,7 @@
7B45AB5525FBA9DE00FD27F4 /* GraphicsContextGLANGLEEGLUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B45AB5425FBA9DD00FD27F4 /* GraphicsContextGLANGLEEGLUtilities.h */; settings = {ATTRIBUTES = (Private, ); }; };
7B6DC81925712E9200380C70 /* GraphicsContextGLIOSurfaceSwapChain.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B6DC81725712E9200380C70 /* GraphicsContextGLIOSurfaceSwapChain.h */; settings = {ATTRIBUTES = (Private, ); }; };
7B7311FB25C092B7003B2796 /* ScopedHighPerformanceGPURequest.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B7311FA25C092B7003B2796 /* ScopedHighPerformanceGPURequest.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 7B8ED5F026F0C13D008AC023 /* CVUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B8ED5ED26F0C123008AC023 /* CVUtilities.h */; settings = {ATTRIBUTES = (Private, ); }; };
7B90417025501142006EEB8C /* RemoteGraphicsContextGLProxyBase.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B90416E25501109006EEB8C /* RemoteGraphicsContextGLProxyBase.h */; settings = {ATTRIBUTES = (Private, ); }; };
7BB34A1725345CB200029D08 /* GraphicsContextGLANGLEUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 7BB34A1625345CB200029D08 /* GraphicsContextGLANGLEUtilities.h */; settings = {ATTRIBUTES = (Private, ); }; };
7BB34A48253776CA00029D08 /* GraphicsContextGLImageExtractor.h in Headers */ = {isa = PBXBuildFile; fileRef = 7BB34A45253776C600029D08 /* GraphicsContextGLImageExtractor.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -7959,7 +7960,6 @@
415747441E38699E00E914D8 /* LibWebRTCProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LibWebRTCProvider.h; path = libwebrtc/LibWebRTCProvider.h; sourceTree = "<group>"; };
4157EBF81E3AB06800AC9FE9 /* MockLibWebRTCPeerConnection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MockLibWebRTCPeerConnection.h; sourceTree = "<group>"; };
4157EBF91E3AB06800AC9FE9 /* MockLibWebRTCPeerConnection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MockLibWebRTCPeerConnection.cpp; sourceTree = "<group>"; };
- 4158649F23BF7B9300A0A61E /* RealtimeVideoUtilities.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RealtimeVideoUtilities.mm; sourceTree = "<group>"; };
4158DCB624FFCD1B00B9DA41 /* RTCIceComponent.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = RTCIceComponent.idl; sourceTree = "<group>"; };
4158DCB824FFCDC300B9DA41 /* RTCIceProtocol.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = RTCIceProtocol.idl; sourceTree = "<group>"; };
4158DCB924FFCDC300B9DA41 /* RTCIceTcpCandidateType.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = RTCIceTcpCandidateType.idl; sourceTree = "<group>"; };
@@ -10615,6 +10615,8 @@
7B6DC81725712E9200380C70 /* GraphicsContextGLIOSurfaceSwapChain.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GraphicsContextGLIOSurfaceSwapChain.h; sourceTree = "<group>"; };
7B7311FA25C092B7003B2796 /* ScopedHighPerformanceGPURequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScopedHighPerformanceGPURequest.h; sourceTree = "<group>"; };
7B774C6225FB93550091395F /* GraphicsContextGLANGLEEGLUtilities.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = GraphicsContextGLANGLEEGLUtilities.cpp; sourceTree = "<group>"; };
+ 7B8ED5ED26F0C123008AC023 /* CVUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CVUtilities.h; sourceTree = "<group>"; };
+ 7B8ED5EF26F0C123008AC023 /* CVUtilities.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CVUtilities.mm; sourceTree = "<group>"; };
7B90416E25501109006EEB8C /* RemoteGraphicsContextGLProxyBase.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RemoteGraphicsContextGLProxyBase.h; sourceTree = "<group>"; };
7BB34A1625345CB200029D08 /* GraphicsContextGLANGLEUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GraphicsContextGLANGLEUtilities.h; sourceTree = "<group>"; };
7BB34A45253776C600029D08 /* GraphicsContextGLImageExtractor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GraphicsContextGLImageExtractor.h; sourceTree = "<group>"; };
@@ -17650,7 +17652,6 @@
5CDD833C1E4324BB00621B83 /* RealtimeOutgoingVideoSourceCocoa.h */,
419242472127B7CC00634FCF /* RealtimeOutgoingVideoSourceCocoa.mm */,
41D1938F2152C561006F14CA /* RealtimeVideoUtilities.h */,
- 4158649F23BF7B9300A0A61E /* RealtimeVideoUtilities.mm */,
07D6373E1BB0B11300256CE9 /* WebAudioSourceProviderCocoa.h */,
07D6373F1BB0B11300256CE9 /* WebAudioSourceProviderCocoa.mm */,
);
@@ -28386,6 +28387,8 @@
CD9D827C1C7BB2ED006FF066 /* cv */ = {
isa = PBXGroup;
children = (
+ 7B8ED5ED26F0C123008AC023 /* CVUtilities.h */,
+ 7B8ED5EF26F0C123008AC023 /* CVUtilities.mm */,
7B10339D2549720100C8C1AC /* GraphicsContextGLCV.h */,
7B10339A2549720000C8C1AC /* GraphicsContextGLCVANGLE.cpp */,
7B10339C2549720100C8C1AC /* GraphicsContextGLCVANGLE.h */,
@@ -32068,6 +32071,7 @@
62CD325A1157E57C0063B0A7 /* CustomEvent.h in Headers */,
5C5D2385227A0652000B9BDA /* CustomHeaderFields.h in Headers */,
4B1E13E721790D660042CF98 /* CustomPaintCanvas.h in Headers */,
+ 7B8ED5F026F0C13D008AC023 /* CVUtilities.h in Headers */,
A8CB413E0E8633FD0032C4F0 /* DashArray.h in Headers */,
97BC6A211505F081001B74AC /* Database.h in Headers */,
97BC6A241505F081001B74AC /* DatabaseAuthorizer.h in Headers */,
Added: trunk/Source/WebCore/platform/graphics/cv/CVUtilities.h (0 => 283036)
--- trunk/Source/WebCore/platform/graphics/cv/CVUtilities.h (rev 0)
+++ trunk/Source/WebCore/platform/graphics/cv/CVUtilities.h 2021-09-24 12:41:04 UTC (rev 283036)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2021 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. AND ITS CONTRIBUTORS ``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 ITS 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
+
+#include <CoreVideo/CoreVideo.h>
+#include <utility>
+#include <wtf/Expected.h>
+#include <wtf/RetainPtr.h>
+
+using CVPixelBufferPoolRef = struct __CVPixelBufferPool*;
+using CVPixelBufferRef = struct __CVBuffer*;
+
+namespace WebCore {
+
+// Creates CVPixelBufferPool that creates CVPixelBuffers backed by IOSurfaces.
+// These buffers can be for example sent through IPC.
+WEBCORE_EXPORT Expected<RetainPtr<CVPixelBufferPoolRef>, CVReturn> createIOSurfaceCVPixelBufferPool(size_t width, size_t height, OSType pixelFormat, unsigned minimumBufferCount = 0u);
+
+WEBCORE_EXPORT Expected<RetainPtr<CVPixelBufferRef>, CVReturn> createCVPixelBufferFromPool(CVPixelBufferPoolRef);
+
+WEBCORE_EXPORT Expected<RetainPtr<CVPixelBufferRef>, CVReturn> createCVPixelBuffer(IOSurfaceRef);
+
+}
Added: trunk/Source/WebCore/platform/graphics/cv/CVUtilities.mm (0 => 283036)
--- trunk/Source/WebCore/platform/graphics/cv/CVUtilities.mm (rev 0)
+++ trunk/Source/WebCore/platform/graphics/cv/CVUtilities.mm 2021-09-24 12:41:04 UTC (rev 283036)
@@ -0,0 +1,110 @@
+/*
+ * Copyright (C) 2021 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. AND ITS CONTRIBUTORS ``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 ITS 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.
+ */
+
+#import "config.h"
+#import "CVUtilities.h"
+
+#import <wtf/StdLibExtras.h>
+#import "CoreVideoSoftLink.h"
+
+namespace WebCore {
+
+Expected<RetainPtr<CVPixelBufferPoolRef>, CVReturn> createIOSurfaceCVPixelBufferPool(size_t width, size_t height, OSType format, unsigned minimumBufferCount)
+{
+ auto pixelAttributes = @{
+ (__bridge NSString *)kCVPixelBufferWidthKey : @(width),
+ (__bridge NSString *)kCVPixelBufferHeightKey : @(height),
+ (__bridge NSString *)kCVPixelBufferPixelFormatTypeKey : @(format),
+ (__bridge NSString *)kCVPixelBufferCGImageCompatibilityKey : @NO,
+#if PLATFORM(MAC)
+ (__bridge NSString *)kCVPixelBufferOpenGLCompatibilityKey : @YES,
+#endif
+ (__bridge NSString *)kCVPixelBufferIOSurfacePropertiesKey : @{ }
+ };
+ NSDictionary *poolOptions = nullptr;
+ if (minimumBufferCount) {
+ poolOptions = @{
+ (__bridge NSString *)kCVPixelBufferPoolMinimumBufferCountKey : @(minimumBufferCount)
+ };
+ }
+ CVPixelBufferPoolRef pool = nullptr;
+ auto status = CVPixelBufferPoolCreate(kCFAllocatorDefault, (__bridge CFDictionaryRef)poolOptions, (__bridge CFDictionaryRef)pixelAttributes, &pool);
+ if (status != kCVReturnSuccess || !pool)
+ return makeUnexpected(status);
+ return adoptCF(pool);
+}
+
+Expected<RetainPtr<CVPixelBufferRef>, CVReturn> createCVPixelBufferFromPool(CVPixelBufferPoolRef pixelBufferPool)
+{
+ CVPixelBufferRef pixelBuffer = nullptr;
+ auto status = CVPixelBufferPoolCreatePixelBuffer(kCFAllocatorDefault, pixelBufferPool, &pixelBuffer);
+ if (status != kCVReturnSuccess || !pixelBuffer)
+ return makeUnexpected(status);
+ return adoptCF(pixelBuffer);
+}
+
+static CFDictionaryRef pixelBufferCreationOptions(IOSurfaceRef surface)
+{
+#if PLATFORM(MAC)
+ auto format = IOSurfaceGetPixelFormat(surface);
+ if (format == kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange || format == kCVPixelFormatType_420YpCbCr8BiPlanarFullRange) {
+ // YUV formats might contain extra pixels due to block size. Define the picture position
+ // in the buffer as the default top-left position. The caller might use the pixel buffer
+ // with APIs that expect the properties.
+ constexpr size_t macroblockSize = 16;
+ auto width = IOSurfaceGetWidth(surface);
+ auto height = IOSurfaceGetHeight(surface);
+ auto extendedRight = roundUpToMultipleOf(macroblockSize, width) - width;
+ auto extendedBottom = roundUpToMultipleOf(macroblockSize, height) - height;
+ if ((IOSurfaceGetBytesPerRowOfPlane(surface, 0) >= width + extendedRight)
+ && (IOSurfaceGetBytesPerRowOfPlane(surface, 1) >= width + extendedRight)
+ && (IOSurfaceGetAllocSize(surface) >= (height + extendedBottom) * IOSurfaceGetBytesPerRowOfPlane(surface, 0) * 3 / 2)) {
+ return (__bridge CFDictionaryRef) @{
+ (__bridge NSString *)kCVPixelBufferOpenGLCompatibilityKey : @YES,
+ (__bridge NSString *)kCVPixelBufferExtendedPixelsRightKey : @(extendedRight),
+ (__bridge NSString *)kCVPixelBufferExtendedPixelsBottomKey : @(extendedBottom)
+ };
+ }
+ }
+#else
+ UNUSED_PARAM(surface);
+#endif
+ return (__bridge CFDictionaryRef) @{
+#if PLATFORM(MAC)
+ (__bridge NSString *)kCVPixelBufferOpenGLCompatibilityKey : @YES
+#endif
+ };
+}
+
+Expected<RetainPtr<CVPixelBufferRef>, CVReturn> createCVPixelBuffer(IOSurfaceRef surface)
+{
+ CVPixelBufferRef pixelBuffer = nullptr;
+ auto status = CVPixelBufferCreateWithIOSurface(kCFAllocatorDefault, surface, pixelBufferCreationOptions(surface), &pixelBuffer);
+ if (status != kCVReturnSuccess || !pixelBuffer)
+ return makeUnexpected(status);
+ return adoptCF(pixelBuffer);
+}
+
+}
Modified: trunk/Source/WebCore/platform/graphics/cv/ImageTransferSessionVT.h (283035 => 283036)
--- trunk/Source/WebCore/platform/graphics/cv/ImageTransferSessionVT.h 2021-09-24 11:13:33 UTC (rev 283035)
+++ trunk/Source/WebCore/platform/graphics/cv/ImageTransferSessionVT.h 2021-09-24 12:41:04 UTC (rev 283036)
@@ -58,11 +58,6 @@
#endif
#endif
-#if !PLATFORM(MACCATALYST)
- WEBCORE_EXPORT RetainPtr<CVPixelBufferRef> createPixelBuffer(IOSurfaceRef);
- WEBCORE_EXPORT RetainPtr<CVPixelBufferRef> createPixelBuffer(IOSurfaceRef, const IntSize&);
-#endif
-
uint32_t pixelFormat() const { return m_pixelFormat; }
private:
@@ -69,7 +64,6 @@
WEBCORE_EXPORT explicit ImageTransferSessionVT(uint32_t pixelFormat);
#if !PLATFORM(MACCATALYST)
- CFDictionaryRef ioSurfacePixelBufferCreationOptions(IOSurfaceRef);
RetainPtr<CMSampleBufferRef> createCMSampleBuffer(IOSurfaceRef, const MediaTime&, const IntSize&);
#endif
Modified: trunk/Source/WebCore/platform/graphics/cv/ImageTransferSessionVT.mm (283035 => 283036)
--- trunk/Source/WebCore/platform/graphics/cv/ImageTransferSessionVT.mm 2021-09-24 11:13:33 UTC (rev 283035)
+++ trunk/Source/WebCore/platform/graphics/cv/ImageTransferSessionVT.mm 2021-09-24 12:41:04 UTC (rev 283036)
@@ -26,6 +26,7 @@
#import "config.h"
#import "ImageTransferSessionVT.h"
+#import "CVUtilities.h"
#import "GraphicsContextCG.h"
#import "Logging.h"
#import "MediaSampleAVFObjC.h"
@@ -43,15 +44,6 @@
namespace WebCore {
-static inline CFStringRef cvPixelFormatOpenGLKey()
-{
-#if PLATFORM(IOS_FAMILY) && !PLATFORM(MACCATALYST)
- return kCVPixelFormatOpenGLESCompatibility;
-#else
- return kCVPixelBufferOpenGLCompatibilityKey;
-#endif
-}
-
ImageTransferSessionVT::ImageTransferSessionVT(uint32_t pixelFormat)
{
VTPixelTransferSessionRef transferSession;
@@ -84,29 +76,11 @@
{
if (m_size == size && m_outputBufferPool)
return true;
-
- NSDictionary* pixelBufferOptions = @{
- (__bridge NSString *)kCVPixelBufferWidthKey : @(size.width()),
- (__bridge NSString *)kCVPixelBufferHeightKey : @(size.height()),
- (__bridge NSString *)kCVPixelBufferPixelFormatTypeKey : @(m_pixelFormat),
- (__bridge NSString *)cvPixelFormatOpenGLKey() : @YES,
- (__bridge NSString *)kCVPixelBufferIOSurfacePropertiesKey : @{ /*empty dictionary*/ },
- };
-
- NSDictionary* pixelBufferPoolOptions = @{
- (__bridge NSString *)kCVPixelBufferPoolMinimumBufferCountKey: @(6)
- };
-
- CVPixelBufferPoolRef bufferPool;
- auto status = CVPixelBufferPoolCreate(kCFAllocatorDefault, (__bridge CFDictionaryRef)pixelBufferPoolOptions, (__bridge CFDictionaryRef)pixelBufferOptions, &bufferPool);
- ASSERT(!status);
- if (status != kCVReturnSuccess)
+ auto bufferPool = createIOSurfaceCVPixelBufferPool(size.width(), size.height(), m_pixelFormat, 6).value_or(nullptr);
+ if (!bufferPool)
return false;
-
- m_outputBufferPool = adoptCF(bufferPool);
+ m_outputBufferPool = WTFMove(bufferPool);
m_size = size;
- m_ioSurfaceBufferAttributes = nullptr;
-
return true;
}
@@ -118,28 +92,22 @@
if (!sourceBuffer || !setSize(size))
return nullptr;
- CVPixelBufferRef outputBuffer = nullptr;
- auto status = CVPixelBufferPoolCreatePixelBuffer(kCFAllocatorDefault, m_outputBufferPool.get(), &outputBuffer);
- if (status) {
- RELEASE_LOG(Media, "ImageTransferSessionVT::convertPixelBuffer, CVPixelBufferPoolCreatePixelBuffer failed with error %d", static_cast<int>(status));
+ auto result = createCVPixelBufferFromPool(m_outputBufferPool.get());
+ if (!result) {
+ RELEASE_LOG(Media, "ImageTransferSessionVT::convertPixelBuffer, createCVPixelBufferFromPool failed with error %d", static_cast<int>(result.error()));
return nullptr;
}
- auto result = adoptCF(outputBuffer);
+ auto outputBuffer = WTFMove(*result);
- auto err = VTPixelTransferSessionTransferImage(m_transferSession.get(), sourceBuffer, outputBuffer);
+ auto err = VTPixelTransferSessionTransferImage(m_transferSession.get(), sourceBuffer, outputBuffer.get());
if (err) {
RELEASE_LOG(Media, "ImageTransferSessionVT::convertPixelBuffer, VTPixelTransferSessionTransferImage failed with error %d", static_cast<int>(err));
return nullptr;
}
- return result;
+ return outputBuffer;
}
-RetainPtr<CVPixelBufferRef> ImageTransferSessionVT::createPixelBuffer(CMSampleBufferRef sourceBuffer, const IntSize& size)
-{
- return convertPixelBuffer(PAL::CMSampleBufferGetImageBuffer(sourceBuffer), size);
-}
-
RetainPtr<CMSampleBufferRef> ImageTransferSessionVT::convertCMSampleBuffer(CMSampleBufferRef sourceBuffer, const IntSize& size)
{
if (!sourceBuffer)
@@ -154,7 +122,7 @@
if (!setSize(size))
return nullptr;
- auto convertedPixelBuffer = createPixelBuffer(sourceBuffer, size);
+ auto convertedPixelBuffer = convertPixelBuffer(pixelBuffer, size);
if (!convertedPixelBuffer)
return nullptr;
@@ -266,82 +234,11 @@
#if !PLATFORM(MACCATALYST)
-#if PLATFORM(MAC)
-static int32_t roundUpToMacroblockMultiple(int32_t size)
+RetainPtr<CMSampleBufferRef> ImageTransferSessionVT::createCMSampleBuffer(IOSurfaceRef surface, const MediaTime &sampleTime, const IntSize &size)
{
- return (size + 15) & ~15;
-}
-#endif
-
-CFDictionaryRef ImageTransferSessionVT::ioSurfacePixelBufferCreationOptions(IOSurfaceRef surface)
-{
- if (m_ioSurfaceBufferAttributes)
- return m_ioSurfaceBufferAttributes.get();
-
- m_ioSurfaceBufferAttributes = (__bridge CFDictionaryRef) @{
- (__bridge NSString *)cvPixelFormatOpenGLKey() : @YES,
- };
-
-#if PLATFORM(MAC)
- auto format = IOSurfaceGetPixelFormat(surface);
- auto width = IOSurfaceGetWidth(surface);
- auto height = IOSurfaceGetHeight(surface);
- auto extendedRight = roundUpToMacroblockMultiple(width) - width;
- auto extendedBottom = roundUpToMacroblockMultiple(height) - height;
-
- if ((format == kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange || format == kCVPixelFormatType_420YpCbCr8BiPlanarFullRange)
- && (IOSurfaceGetBytesPerRowOfPlane(surface, 0) >= width + extendedRight)
- && (IOSurfaceGetBytesPerRowOfPlane(surface, 1) >= width + extendedRight)
- && (IOSurfaceGetAllocSize(surface) >= (height + extendedBottom) * IOSurfaceGetBytesPerRowOfPlane(surface, 0) * 3 / 2)) {
- m_ioSurfaceBufferAttributes = (__bridge CFDictionaryRef) @{
- (__bridge NSString *)kCVPixelBufferOpenGLCompatibilityKey : @YES,
- (__bridge NSString *)kCVPixelBufferExtendedPixelsRightKey : @(extendedRight),
- (__bridge NSString *)kCVPixelBufferExtendedPixelsBottomKey : @(extendedBottom)
- };
- }
-#else
- UNUSED_PARAM(surface);
-#endif
-
- return m_ioSurfaceBufferAttributes.get();
-}
-
-RetainPtr<CVPixelBufferRef> ImageTransferSessionVT::createPixelBuffer(IOSurfaceRef surface)
-{
- if (!surface)
- return nullptr;
-
- CVPixelBufferRef pixelBuffer;
- auto status = CVPixelBufferCreateWithIOSurface(kCFAllocatorDefault, surface, ioSurfacePixelBufferCreationOptions(surface), &pixelBuffer);
- if (status) {
- RELEASE_LOG(Media, "CVPixelBufferCreateWithIOSurface failed with error code: %d", static_cast<int>(status));
- return nullptr;
- }
- return adoptCF(pixelBuffer);
-}
-
-RetainPtr<CVPixelBufferRef> ImageTransferSessionVT::createPixelBuffer(IOSurfaceRef surface, const IntSize& size)
-{
if (!surface || !setSize(size))
return nullptr;
-
- CVPixelBufferRef pixelBuffer;
- auto status = CVPixelBufferCreateWithIOSurface(kCFAllocatorDefault, surface, ioSurfacePixelBufferCreationOptions(surface), &pixelBuffer);
- if (status) {
- RELEASE_LOG(Media, "CVPixelBufferCreateWithIOSurface failed with error code: %d", static_cast<int>(status));
- return nullptr;
- }
-
- auto retainedBuffer = adoptCF(pixelBuffer);
- if (m_size == IntSize(CVPixelBufferGetWidth(pixelBuffer), CVPixelBufferGetHeight(pixelBuffer)) && m_pixelFormat == CVPixelBufferGetPixelFormatType(pixelBuffer))
- return retainedBuffer;
-
- return convertPixelBuffer(pixelBuffer, size);
-}
-
-RetainPtr<CMSampleBufferRef> ImageTransferSessionVT::createCMSampleBuffer(IOSurfaceRef surface, const MediaTime& sampleTime, const IntSize& size)
-{
- auto pixelBuffer = createPixelBuffer(surface, size);
+ auto pixelBuffer = createCVPixelBuffer(surface).value_or(nullptr);
if (!pixelBuffer)
return nullptr;
Modified: trunk/Source/WebCore/platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.mm (283035 => 283036)
--- trunk/Source/WebCore/platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.mm 2021-09-24 11:13:33 UTC (rev 283035)
+++ trunk/Source/WebCore/platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.mm 2021-09-24 12:41:04 UTC (rev 283036)
@@ -30,6 +30,7 @@
#if USE(LIBWEBRTC)
+#import "CVUtilities.h"
#import "Logging.h"
#import "MediaSampleAVFObjC.h"
#import "RealtimeVideoUtilities.h"
@@ -39,6 +40,7 @@
#import <webrtc/sdk/WebKit/WebKitUtilities.h>
ALLOW_UNUSED_PARAMETERS_END
+#import "CoreVideoSoftLink.h"
#import <pal/cf/CoreMediaSoftLink.h>
namespace WebCore {
@@ -98,10 +100,12 @@
case webrtc::BufferType::I010:
poolBufferType = kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange;
}
- m_pixelBufferPool = createPixelBufferPool(width, height, poolBufferType);
- m_pixelBufferPoolWidth = width;
- m_pixelBufferPoolHeight = height;
- m_pixelBufferPoolBufferType = bufferType;
+ if (auto pool = createIOSurfaceCVPixelBufferPool(width, height, poolBufferType)) {
+ m_pixelBufferPool = WTFMove(*pool);
+ m_pixelBufferPoolWidth = width;
+ m_pixelBufferPoolHeight = height;
+ m_pixelBufferPoolBufferType = bufferType;
+ }
}
return m_pixelBufferPool.get();
}
Modified: trunk/Source/WebCore/platform/mediastream/mac/RealtimeVideoUtilities.h (283035 => 283036)
--- trunk/Source/WebCore/platform/mediastream/mac/RealtimeVideoUtilities.h 2021-09-24 11:13:33 UTC (rev 283035)
+++ trunk/Source/WebCore/platform/mediastream/mac/RealtimeVideoUtilities.h 2021-09-24 12:41:04 UTC (rev 283036)
@@ -27,9 +27,6 @@
#include <CoreVideo/CoreVideo.h>
-using CVPixelBufferPoolRef = struct __CVPixelBufferPool*;
-using CVPixelBufferRef = struct __CVBuffer*;
-
namespace WebCore {
static inline OSType preferedPixelBufferFormat()
@@ -41,7 +38,4 @@
#endif
}
-WEBCORE_EXPORT RetainPtr<CVPixelBufferPoolRef> createPixelBufferPool(size_t width, size_t height, OSType);
-WEBCORE_EXPORT RetainPtr<CVPixelBufferRef> createPixelBufferFromPool(CVPixelBufferPoolRef);
-
}
Deleted: trunk/Source/WebCore/platform/mediastream/mac/RealtimeVideoUtilities.mm (283035 => 283036)
--- trunk/Source/WebCore/platform/mediastream/mac/RealtimeVideoUtilities.mm 2021-09-24 11:13:33 UTC (rev 283035)
+++ trunk/Source/WebCore/platform/mediastream/mac/RealtimeVideoUtilities.mm 2021-09-24 12:41:04 UTC (rev 283036)
@@ -1,67 +0,0 @@
-/*
- * Copyright (C) 2020 Apple Inc.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted, provided that the following conditions
- * are required to be 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. AND ITS CONTRIBUTORS "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. AND ITS 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.
- */
-
-#import "config.h"
-#import "RealtimeVideoUtilities.h"
-
-#import "CoreVideoSoftLink.h"
-
-namespace WebCore {
-
-RetainPtr<CVPixelBufferPoolRef> createPixelBufferPool(size_t width, size_t height, OSType videoCaptureFormat)
-{
- auto pixelAttributes = @{
- (__bridge NSString *)kCVPixelBufferWidthKey: @(width),
- (__bridge NSString *)kCVPixelBufferHeightKey: @(height),
- (__bridge NSString *)kCVPixelBufferPixelFormatTypeKey: @(videoCaptureFormat),
- (__bridge NSString *)kCVPixelBufferCGImageCompatibilityKey: @NO,
-#if PLATFORM(IOS_FAMILY)
- (__bridge NSString *)kCVPixelFormatOpenGLESCompatibility : @YES,
-#else
- (__bridge NSString *)kCVPixelBufferOpenGLCompatibilityKey : @YES,
-#endif
- (__bridge NSString *)kCVPixelBufferIOSurfacePropertiesKey : @{ }
- };
-
- CVPixelBufferPoolRef pool = nullptr;
- auto status = CVPixelBufferPoolCreate(kCFAllocatorDefault, nullptr, (__bridge CFDictionaryRef)pixelAttributes, &pool);
-
- if (status != kCVReturnSuccess)
- return nullptr;
-
- return adoptCF(pool);
-}
-
-RetainPtr<CVPixelBufferRef> createPixelBufferFromPool(CVPixelBufferPoolRef pixelBufferPool)
-{
- CVPixelBufferRef pixelBuffer = nullptr;
- auto status = CVPixelBufferPoolCreatePixelBuffer(kCFAllocatorDefault, pixelBufferPool, &pixelBuffer);
-
- if (status != kCVReturnSuccess)
- return nullptr;
- return adoptCF(pixelBuffer);
-}
-
-}
Modified: trunk/Source/WebCore/platform/network/mac/WebCoreURLResponse.mm (283035 => 283036)
--- trunk/Source/WebCore/platform/network/mac/WebCoreURLResponse.mm 2021-09-24 11:13:33 UTC (rev 283035)
+++ trunk/Source/WebCore/platform/network/mac/WebCoreURLResponse.mm 2021-09-24 12:41:04 UTC (rev 283036)
@@ -35,6 +35,7 @@
#import <pal/spi/cf/CFNetworkSPI.h>
#import <wtf/Assertions.h>
#import <wtf/RetainPtr.h>
+#import <wtf/SortedArrayMap.h>
namespace WebCore {
Modified: trunk/Source/WebKit/ChangeLog (283035 => 283036)
--- trunk/Source/WebKit/ChangeLog 2021-09-24 11:13:33 UTC (rev 283035)
+++ trunk/Source/WebKit/ChangeLog 2021-09-24 12:41:04 UTC (rev 283036)
@@ -1,3 +1,27 @@
+2021-09-24 Kimmo Kinnunen <[email protected]>
+
+ Add utility to create CVPixelBuffers from IOSurfaces
+ https://bugs.webkit.org/show_bug.cgi?id=230338
+
+ Reviewed by Youenn Fablet.
+
+ The helper function moved from ImageTransferSessionVT
+ to free standalone function. Stop instantiating the
+ object and just call the function.
+
+ In both of the cases, the pixel buffer is created out of
+ the IOSurface and the pool is not used. In both of the cases
+ the size and the pixel format of the image transfer session
+ is the same as the input IOSurface.
+
+ * GPUProcess/webrtc/LibWebRTCCodecsProxy.h:
+ * GPUProcess/webrtc/LibWebRTCCodecsProxy.mm:
+ * WebProcess/GPU/webrtc/LibWebRTCCodecs.cpp:
+ (WebKit::LibWebRTCCodecs::completedDecoding):
+ (WebKit::LibWebRTCCodecs::encodeFrame):
+ (WebKit::LibWebRTCCodecs::pixelBufferPool):
+ * WebProcess/GPU/webrtc/LibWebRTCCodecs.h:
+
2021-09-24 Youenn Fablet <[email protected]>
<video> element rendered incorrectly when provided with a portrait orientation stream in Safari 15
Modified: trunk/Source/WebKit/GPUProcess/webrtc/LibWebRTCCodecsProxy.h (283035 => 283036)
--- trunk/Source/WebKit/GPUProcess/webrtc/LibWebRTCCodecsProxy.h 2021-09-24 11:13:33 UTC (rev 283035)
+++ trunk/Source/WebKit/GPUProcess/webrtc/LibWebRTCCodecsProxy.h 2021-09-24 12:41:04 UTC (rev 283036)
@@ -31,7 +31,6 @@
#include "DataReference.h"
#include "RTCDecoderIdentifier.h"
#include "RTCEncoderIdentifier.h"
-#include <WebCore/ImageTransferSessionVT.h>
#include <wtf/Lock.h>
namespace IPC {
@@ -93,7 +92,6 @@
HashMap<RTCEncoderIdentifier, webrtc::LocalEncoder> m_encoders WTF_GUARDED_BY_LOCK(m_lock); // Only modified on the libWebRTCCodecsQueue but may get accessed from the main thread.
Ref<WorkQueue> m_queue;
- std::unique_ptr<WebCore::ImageTransferSessionVT> m_imageTransferSession;
};
}
Modified: trunk/Source/WebKit/GPUProcess/webrtc/LibWebRTCCodecsProxy.mm (283035 => 283036)
--- trunk/Source/WebKit/GPUProcess/webrtc/LibWebRTCCodecsProxy.mm 2021-09-24 11:13:33 UTC (rev 283035)
+++ trunk/Source/WebKit/GPUProcess/webrtc/LibWebRTCCodecsProxy.mm 2021-09-24 12:41:04 UTC (rev 283036)
@@ -33,6 +33,7 @@
#import "LibWebRTCCodecsMessages.h"
#import "LibWebRTCCodecsProxyMessages.h"
#import "WebCoreArgumentCoders.h"
+#import <WebCore/CVUtilities.h>
#import <WebCore/LibWebRTCProvider.h>
#import <WebCore/RemoteVideoSample.h>
#import <webrtc/sdk/WebKit/WebKitDecoder.h>
@@ -207,12 +208,13 @@
if (!encoder)
return;
- if (!m_imageTransferSession || m_imageTransferSession->pixelFormat() != sample.videoFormat())
- m_imageTransferSession = WebCore::ImageTransferSessionVT::create(sample.videoFormat());
-
#if !PLATFORM(MACCATALYST)
- auto pixelBuffer = m_imageTransferSession->createPixelBuffer(sample.surface());
- webrtc::encodeLocalEncoderFrame(encoder, pixelBuffer.get(), sample.time().toTimeScale(1000000).timeValue(), timeStamp, toWebRTCVideoRotation(sample.rotation()), shouldEncodeAsKeyFrame);
+ if (!sample.surface())
+ return;
+ auto pixelBuffer = WebCore::createCVPixelBuffer(sample.surface());
+ if (!pixelBuffer)
+ return;
+ webrtc::encodeLocalEncoderFrame(encoder, pixelBuffer->get(), sample.time().toTimeScale(1000000).timeValue(), timeStamp, toWebRTCVideoRotation(sample.rotation()), shouldEncodeAsKeyFrame);
#endif
}
Modified: trunk/Source/WebKit/WebProcess/GPU/webrtc/LibWebRTCCodecs.cpp (283035 => 283036)
--- trunk/Source/WebKit/WebProcess/GPU/webrtc/LibWebRTCCodecs.cpp 2021-09-24 11:13:33 UTC (rev 283035)
+++ trunk/Source/WebKit/WebProcess/GPU/webrtc/LibWebRTCCodecs.cpp 2021-09-24 12:41:04 UTC (rev 283036)
@@ -33,9 +33,9 @@
#include "LibWebRTCCodecsProxyMessages.h"
#include "WebCoreArgumentCoders.h"
#include "WebProcess.h"
+#include <WebCore/CVUtilities.h>
#include <WebCore/LibWebRTCMacros.h>
#include <WebCore/PlatformMediaSessionManager.h>
-#include <WebCore/RealtimeVideoUtilities.h>
#include <WebCore/RemoteVideoSample.h>
#include <WebCore/RuntimeEnabledFeatures.h>
#include <WebCore/VP9UtilitiesCocoa.h>
@@ -332,15 +332,9 @@
if (!decoder->decodedImageCallback)
return;
- if (!m_imageTransferSession || m_imageTransferSession->pixelFormat() != remoteSample.videoFormat())
- m_imageTransferSession = WebCore::ImageTransferSessionVT::create(remoteSample.videoFormat());
-
- if (!m_imageTransferSession) {
- ASSERT_NOT_REACHED();
+ if (!remoteSample.surface())
return;
- }
-
- auto pixelBuffer = m_imageTransferSession->createPixelBuffer(remoteSample.surface(), remoteSample.size());
+ auto pixelBuffer = createCVPixelBuffer(remoteSample.surface()).value_or(nullptr);
if (!pixelBuffer) {
ASSERT_NOT_REACHED();
return;
@@ -444,7 +438,7 @@
if (!pixelBufferPool)
return nullptr;
- return WebCore::createPixelBufferFromPool(pixelBufferPool).leakRef();
+ return WebCore::createCVPixelBufferFromPool(pixelBufferPool).value_or(nullptr).leakRef();
}));
if (!pixelBuffer)
@@ -503,9 +497,14 @@
CVPixelBufferPoolRef LibWebRTCCodecs::pixelBufferPool(size_t width, size_t height, OSType type)
{
if (!m_pixelBufferPool || m_pixelBufferPoolWidth != width || m_pixelBufferPoolHeight != height) {
- m_pixelBufferPool = createPixelBufferPool(width, height, type);
- m_pixelBufferPoolWidth = width;
- m_pixelBufferPoolHeight = height;
+ m_pixelBufferPool = nullptr;
+ m_pixelBufferPoolWidth = 0;
+ m_pixelBufferPoolHeight = 0;
+ if (auto pool = WebCore::createIOSurfaceCVPixelBufferPool(width, height, type)) {
+ m_pixelBufferPool = WTFMove(*pool);
+ m_pixelBufferPoolWidth = width;
+ m_pixelBufferPoolHeight = height;
+ }
}
return m_pixelBufferPool.get();
}
Modified: trunk/Source/WebKit/WebProcess/GPU/webrtc/LibWebRTCCodecs.h (283035 => 283036)
--- trunk/Source/WebKit/WebProcess/GPU/webrtc/LibWebRTCCodecs.h 2021-09-24 11:13:33 UTC (rev 283035)
+++ trunk/Source/WebKit/WebProcess/GPU/webrtc/LibWebRTCCodecs.h 2021-09-24 12:41:04 UTC (rev 283036)
@@ -33,7 +33,6 @@
#include "MessageReceiver.h"
#include "RTCDecoderIdentifier.h"
#include "RTCEncoderIdentifier.h"
-#include <WebCore/ImageTransferSessionVT.h>
#include <WebCore/PixelBufferConformerCV.h>
#include <map>
#include <webrtc/api/video/video_codec_type.h>
@@ -149,7 +148,6 @@
Vector<Function<void()>> m_tasksToDispatchAfterEstablishingConnection;
Ref<WorkQueue> m_queue;
- std::unique_ptr<WebCore::ImageTransferSessionVT> m_imageTransferSession;
std::unique_ptr<WebCore::PixelBufferConformerCV> m_pixelBufferConformer;
RetainPtr<CVPixelBufferPoolRef> m_pixelBufferPool;
size_t m_pixelBufferPoolWidth { 0 };