Diff
Modified: trunk/Source/ThirdParty/libwebrtc/ChangeLog (291050 => 291051)
--- trunk/Source/ThirdParty/libwebrtc/ChangeLog 2022-03-09 15:58:14 UTC (rev 291050)
+++ trunk/Source/ThirdParty/libwebrtc/ChangeLog 2022-03-09 17:47:33 UTC (rev 291051)
@@ -1,3 +1,20 @@
+2022-03-09 Youenn Fablet <[email protected]>
+
+ Allow to pass webrtc video frame buffers through RealtimeMediaSource based pipelines
+ https://bugs.webkit.org/show_bug.cgi?id=236131
+ <rdar://problem/88805580>
+
+ Reviewed by Eric Carlson.
+
+ Update routines to take VideoFrameBuffer instead of VideoFrame.
+ Fix bugs in handling of YUV conversion libwebrtc routines.
+
+ * Configurations/libwebrtc.iOS.exp:
+ * Configurations/libwebrtc.iOSsim.exp:
+ * Configurations/libwebrtc.mac.exp:
+ * Source/webrtc/sdk/WebKit/WebKitUtilities.h:
+ * Source/webrtc/sdk/WebKit/WebKitUtilities.mm:
+
2022-03-07 Alex Christensen <[email protected]>
Unreviewed, reverting r290966.
Modified: trunk/Source/ThirdParty/libwebrtc/Configurations/libwebrtc.iOS.exp (291050 => 291051)
--- trunk/Source/ThirdParty/libwebrtc/Configurations/libwebrtc.iOS.exp 2022-03-09 15:58:14 UTC (rev 291050)
+++ trunk/Source/ThirdParty/libwebrtc/Configurations/libwebrtc.iOS.exp 2022-03-09 17:47:33 UTC (rev 291051)
@@ -334,4 +334,5 @@
__ZNK3rtc14RTCCertificate17GetSSLCertificateEv
__ZTVN6webrtc30WrappingAsyncDnsResolverResultE
__ZN6webrtc20pixelBufferFromFrameERKNS_10VideoFrameE
-__ZN6webrtc14copyVideoFrameERKNS_10VideoFrameEPh
+__ZN6webrtc20copyVideoFrameBufferERNS_16VideoFrameBufferEPh
+__ZN6webrtc32createPixelBufferFromFrameBufferERNS_16VideoFrameBufferERKNSt3__18functionIFP10__CVBuffermmNS_10BufferTypeEEEE
Modified: trunk/Source/ThirdParty/libwebrtc/Configurations/libwebrtc.iOSsim.exp (291050 => 291051)
--- trunk/Source/ThirdParty/libwebrtc/Configurations/libwebrtc.iOSsim.exp 2022-03-09 15:58:14 UTC (rev 291050)
+++ trunk/Source/ThirdParty/libwebrtc/Configurations/libwebrtc.iOSsim.exp 2022-03-09 17:47:33 UTC (rev 291051)
@@ -334,4 +334,5 @@
__ZNK3rtc14RTCCertificate17GetSSLCertificateEv
__ZTVN6webrtc30WrappingAsyncDnsResolverResultE
__ZN6webrtc20pixelBufferFromFrameERKNS_10VideoFrameE
-__ZN6webrtc14copyVideoFrameERKNS_10VideoFrameEPh
+__ZN6webrtc20copyVideoFrameBufferERNS_16VideoFrameBufferEPh
+__ZN6webrtc32createPixelBufferFromFrameBufferERNS_16VideoFrameBufferERKNSt3__18functionIFP10__CVBuffermmNS_10BufferTypeEEEE
Modified: trunk/Source/ThirdParty/libwebrtc/Configurations/libwebrtc.mac.exp (291050 => 291051)
--- trunk/Source/ThirdParty/libwebrtc/Configurations/libwebrtc.mac.exp 2022-03-09 15:58:14 UTC (rev 291050)
+++ trunk/Source/ThirdParty/libwebrtc/Configurations/libwebrtc.mac.exp 2022-03-09 17:47:33 UTC (rev 291051)
@@ -334,4 +334,5 @@
__ZNK3rtc14RTCCertificate17GetSSLCertificateEv
__ZTVN6webrtc30WrappingAsyncDnsResolverResultE
__ZN6webrtc20pixelBufferFromFrameERKNS_10VideoFrameE
-__ZN6webrtc14copyVideoFrameERKNS_10VideoFrameEPh
+__ZN6webrtc20copyVideoFrameBufferERNS_16VideoFrameBufferEPh
+__ZN6webrtc32createPixelBufferFromFrameBufferERNS_16VideoFrameBufferERKNSt3__18functionIFP10__CVBuffermmNS_10BufferTypeEEEE
Modified: trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitUtilities.h (291050 => 291051)
--- trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitUtilities.h 2022-03-09 15:58:14 UTC (rev 291050)
+++ trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitUtilities.h 2022-03-09 17:47:33 UTC (rev 291051)
@@ -48,9 +48,10 @@
enum class BufferType { I420, I010 };
CVPixelBufferRef createPixelBufferFromFrame(const VideoFrame&, const std::function<CVPixelBufferRef(size_t, size_t, BufferType)>& createPixelBuffer) CF_RETURNS_RETAINED;
+CVPixelBufferRef createPixelBufferFromFrameBuffer(VideoFrameBuffer&, const std::function<CVPixelBufferRef(size_t, size_t, BufferType)>& createPixelBuffer) CF_RETURNS_RETAINED;
CVPixelBufferRef pixelBufferFromFrame(const VideoFrame&) CF_RETURNS_RETAINED;
rtc::scoped_refptr<webrtc::VideoFrameBuffer> pixelBufferToFrame(CVPixelBufferRef);
-bool copyVideoFrame(const VideoFrame&, uint8_t*);
+bool copyVideoFrameBuffer(VideoFrameBuffer&, uint8_t*);
typedef CVPixelBufferRef (*GetBufferCallback)(void*);
typedef void (*ReleaseBufferCallback)(void*);
Modified: trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitUtilities.mm (291050 => 291051)
--- trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitUtilities.mm 2022-03-09 15:58:14 UTC (rev 291050)
+++ trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitUtilities.mm 2022-03-09 17:47:33 UTC (rev 291051)
@@ -160,15 +160,19 @@
CVPixelBufferRef createPixelBufferFromFrame(const VideoFrame& frame, const std::function<CVPixelBufferRef(size_t, size_t, BufferType)>& createPixelBuffer)
{
- auto buffer = frame.video_frame_buffer();
- if (buffer->type() != VideoFrameBuffer::Type::kNative) {
- auto type = buffer->type();
+ return createPixelBufferFromFrameBuffer(*frame.video_frame_buffer(), createPixelBuffer);
+}
+
+CVPixelBufferRef createPixelBufferFromFrameBuffer(VideoFrameBuffer& buffer, const std::function<CVPixelBufferRef(size_t, size_t, BufferType)>& createPixelBuffer)
+{
+ if (buffer.type() != VideoFrameBuffer::Type::kNative) {
+ auto type = buffer.type();
if (type != VideoFrameBuffer::Type::kI420 && type != VideoFrameBuffer::Type::kI010) {
RTC_LOG(WARNING) << "Video frame buffer type is not expected.";
return nullptr;
}
- auto pixelBuffer = createPixelBuffer(buffer->width(), buffer->height(), type == VideoFrameBuffer::Type::kI420 ? BufferType::I420 : BufferType::I010);
+ auto pixelBuffer = createPixelBuffer(buffer.width(), buffer.height(), type == VideoFrameBuffer::Type::kI420 ? BufferType::I420 : BufferType::I010);
if (!pixelBuffer) {
RTC_LOG(WARNING) << "Pixel buffer creation failed.";
return nullptr;
@@ -175,13 +179,13 @@
}
if (type == VideoFrameBuffer::Type::kI420)
- CopyVideoFrameToPixelBuffer(buffer->GetI420(), pixelBuffer);
+ CopyVideoFrameToPixelBuffer(buffer.GetI420(), pixelBuffer);
else
- CopyVideoFrameToPixelBuffer(buffer->GetI010(), pixelBuffer);
+ CopyVideoFrameToPixelBuffer(buffer.GetI010(), pixelBuffer);
return pixelBuffer;
}
- auto *frameBuffer = static_cast<ObjCFrameBuffer*>(buffer.get())->wrapped_frame_buffer();
+ auto *frameBuffer = static_cast<ObjCFrameBuffer*>(&buffer)->wrapped_frame_buffer();
if (![frameBuffer isKindOfClass:[RTCCVPixelBuffer class]])
return nullptr;
@@ -203,18 +207,17 @@
return CVPixelBufferRetain(rtcPixelBuffer.pixelBuffer);
}
-bool copyVideoFrame(const VideoFrame& frame, uint8_t* data)
+bool copyVideoFrameBuffer(VideoFrameBuffer& buffer, uint8_t* data)
{
- auto buffer = frame.video_frame_buffer();
- if (buffer->type() == VideoFrameBuffer::Type::kNative)
+ if (buffer.type() == VideoFrameBuffer::Type::kNative)
return false;
- auto type = buffer->type();
+ auto type = buffer.type();
if (type == VideoFrameBuffer::Type::kI420) {
- auto* i420Frame = buffer->GetI420();
+ auto* i420Frame = buffer.GetI420();
auto* dataY = data;
auto strideY = i420Frame->width();
- auto strideUV = i420Frame->width() / 2;
+ auto strideUV = i420Frame->width();
auto* dataUV = data + (i420Frame->width() * i420Frame->height());
return !libyuv::I420ToNV12(i420Frame->DataY(), i420Frame->StrideY(),
i420Frame->DataU(), i420Frame->StrideU(),
@@ -223,10 +226,10 @@
i420Frame->width(), i420Frame->height());
}
if (type == VideoFrameBuffer::Type::kI010) {
- auto* i010Frame = buffer->GetI010();
+ auto* i010Frame = buffer.GetI010();
auto* dataY = reinterpret_cast<uint16_t*>(data);
auto strideY = i010Frame->width();
- auto strideUV = i010Frame->width() / 2;
+ auto strideUV = i010Frame->width();
auto* dataUV = dataY + (i010Frame->width() * i010Frame->height());
return !libyuv::I010ToP010(i010Frame->DataY(), i010Frame->StrideY(),
i010Frame->DataU(), i010Frame->StrideU(),
Modified: trunk/Source/WebCore/ChangeLog (291050 => 291051)
--- trunk/Source/WebCore/ChangeLog 2022-03-09 15:58:14 UTC (rev 291050)
+++ trunk/Source/WebCore/ChangeLog 2022-03-09 17:47:33 UTC (rev 291051)
@@ -1,5 +1,34 @@
2022-03-09 Youenn Fablet <[email protected]>
+ Allow to pass webrtc video frame buffers through RealtimeMediaSource based pipelines
+ https://bugs.webkit.org/show_bug.cgi?id=236131
+ <rdar://problem/88805580>
+
+ Reviewed by Eric Carlson.
+
+ Introduce VideoFrameLibWebRTC as a wrapper to libwebrtc video frame buffer.
+ In case we send VideoFrameLibWebRTC through RealtimeOutgoingVideoSourceCocoa, directly send the video frame buffer.
+ When receiving libwebrtc video frame buffers in RealtimeIncomingVideoSourceCocoa, make use of VideoFrameLibWebRTC to delay conversion of the video frame buffer in a CVPixelBufferRef.
+ In most cases, the conversion is unneeded as the video frame buffer will be used for rendering and will be copied to shared memory through SharedVideoFrameWriter.
+ Fix bugs in handling of YUV conversion libwebrtc routines.
+ Minor refactoring to have a default asVideoFrameCV method implementatin in VideoFrame.
+
+ Covered by existing tests.
+
+ * Sources.txt:
+ * WebCore.xcodeproj/project.pbxproj:
+ * platform/VideoFrame.cpp:
+ * platform/VideoFrame.h:
+ * platform/cocoa/SharedVideoFrameInfo.h:
+ * platform/cocoa/SharedVideoFrameInfo.mm:
+ * platform/mediastream/libwebrtc/VideoFrameLibWebRTC.cpp: Added.
+ * platform/mediastream/libwebrtc/VideoFrameLibWebRTC.h: Added.
+ * platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.h:
+ * platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.mm:
+ * platform/mediastream/mac/RealtimeOutgoingVideoSourceCocoa.cpp:
+
+2022-03-09 Youenn Fablet <[email protected]>
+
WebRTC decoded frames are not correctly rotated in case GPU Process DOM rendering flag is set to true
https://bugs.webkit.org/show_bug.cgi?id=237468
<rdar://problem/89807876>
Modified: trunk/Source/WebCore/Sources.txt (291050 => 291051)
--- trunk/Source/WebCore/Sources.txt 2022-03-09 15:58:14 UTC (rev 291050)
+++ trunk/Source/WebCore/Sources.txt 2022-03-09 17:47:33 UTC (rev 291051)
@@ -2198,6 +2198,7 @@
platform/mediastream/RealtimeVideoSource.cpp
platform/mediastream/libwebrtc/LibWebRTCDTMFSenderBackend.cpp
platform/mediastream/libwebrtc/LibWebRTCProvider.cpp
+platform/mediastream/libwebrtc/VideoFrameLibWebRTC.cpp
platform/mock/DeviceOrientationClientMock.cpp
platform/mock/GeolocationClientMock.cpp
platform/mock/MediaEngineConfigurationFactoryMock.cpp
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (291050 => 291051)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2022-03-09 15:58:14 UTC (rev 291050)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2022-03-09 17:47:33 UTC (rev 291051)
@@ -1227,6 +1227,7 @@
41E6D71B26EA1A4600B765D6 /* RTCError.h in Headers */ = {isa = PBXBuildFile; fileRef = 41B7C04B26E6917100D36C07 /* RTCError.h */; settings = {ATTRIBUTES = (Private, ); }; };
41E9DCE7231974BF00F35949 /* BlobLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 41E9DCE4231973FE00F35949 /* BlobLoader.h */; settings = {ATTRIBUTES = (Private, ); }; };
41E9DCE92319CA7600F35949 /* NetworkSendQueue.h in Headers */ = {isa = PBXBuildFile; fileRef = 41E9DCE82319CA7500F35949 /* NetworkSendQueue.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 41EB797E27C3E45E001C3E3E /* VideoFrameLibWebRTC.h in Headers */ = {isa = PBXBuildFile; fileRef = 41EB797C27C3E45D001C3E3E /* VideoFrameLibWebRTC.h */; settings = {ATTRIBUTES = (Private, ); }; };
41F062140F5F192600A07EAC /* InspectorDatabaseResource.h in Headers */ = {isa = PBXBuildFile; fileRef = 41F062120F5F192600A07EAC /* InspectorDatabaseResource.h */; };
41F1D21F0EF35C2A00DA8753 /* ScriptCachedFrameData.h in Headers */ = {isa = PBXBuildFile; fileRef = 41F1D21D0EF35C2A00DA8753 /* ScriptCachedFrameData.h */; settings = {ATTRIBUTES = (Private, ); }; };
41FABD2D1F4DFE4A006A6C97 /* DOMCacheEngine.h in Headers */ = {isa = PBXBuildFile; fileRef = 41FABD2B1F4DFE42006A6C97 /* DOMCacheEngine.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -8999,6 +9000,8 @@
41E9DCE62319742300F35949 /* EndingType.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = EndingType.idl; sourceTree = "<group>"; };
41E9DCE82319CA7500F35949 /* NetworkSendQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetworkSendQueue.h; sourceTree = "<group>"; };
41E9DCEA2319CAE800F35949 /* NetworkSendQueue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetworkSendQueue.cpp; sourceTree = "<group>"; };
+ 41EB797B27C3E45D001C3E3E /* VideoFrameLibWebRTC.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = VideoFrameLibWebRTC.cpp; path = libwebrtc/VideoFrameLibWebRTC.cpp; sourceTree = "<group>"; };
+ 41EB797C27C3E45D001C3E3E /* VideoFrameLibWebRTC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VideoFrameLibWebRTC.h; path = libwebrtc/VideoFrameLibWebRTC.h; sourceTree = "<group>"; };
41F062120F5F192600A07EAC /* InspectorDatabaseResource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorDatabaseResource.h; sourceTree = "<group>"; };
41F062130F5F192600A07EAC /* InspectorDatabaseResource.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InspectorDatabaseResource.cpp; sourceTree = "<group>"; };
41F0963424F90DEA0009FB93 /* TextDecoderStreamDecoder.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = TextDecoderStreamDecoder.idl; sourceTree = "<group>"; };
@@ -21101,6 +21104,8 @@
41B28B381F860BD100FB52AC /* LibWebRTCProviderCocoa.cpp */,
41B28B361F860BD000FB52AC /* LibWebRTCProviderCocoa.h */,
410E445F234373AD000173D4 /* LibWebRTCSocketIdentifier.h */,
+ 41EB797B27C3E45D001C3E3E /* VideoFrameLibWebRTC.cpp */,
+ 41EB797C27C3E45D001C3E3E /* VideoFrameLibWebRTC.h */,
);
name = libwebrtc;
sourceTree = "<group>";
@@ -37949,6 +37954,7 @@
CD3EEF3B25799FA1006563BB /* VideoConfiguration.h in Headers */,
7B5A3DAF27ABF8C5006C6F97 /* VideoFrame.h in Headers */,
7BE37F8727BBB708007A6CD3 /* VideoFrameCV.h in Headers */,
+ 41EB797E27C3E45E001C3E3E /* VideoFrameLibWebRTC.h in Headers */,
41DEEFB62719BA1A00CB8D74 /* VideoFrameMetadata.h in Headers */,
41DEEFB02719B29000CB8D74 /* VideoFrameRequestCallback.h in Headers */,
52B0D4C01C57FD660077CE53 /* VideoFullscreenChangeObserver.h in Headers */,
Modified: trunk/Source/WebCore/platform/VideoFrame.cpp (291050 => 291051)
--- trunk/Source/WebCore/platform/VideoFrame.cpp 2022-03-09 15:58:14 UTC (rev 291050)
+++ trunk/Source/WebCore/platform/VideoFrame.cpp 2022-03-09 17:47:33 UTC (rev 291051)
@@ -26,6 +26,10 @@
#include "config.h"
#include "VideoFrame.h"
+#if PLATFORM(COCOA)
+#include "VideoFrameCV.h"
+#endif
+
#if ENABLE(VIDEO)
namespace WebCore {
@@ -119,6 +123,17 @@
const_cast<VideoRotation&>(m_rotation) = rotation;
}
+#if PLATFORM(COCOA)
+RefPtr<VideoFrameCV> VideoFrame::asVideoFrameCV()
+{
+ auto buffer = pixelBuffer();
+ if (!buffer)
+ return nullptr;
+
+ return VideoFrameCV::create(presentationTime(), videoMirrored(), videoRotation(), buffer);
}
+#endif
+}
+
#endif
Modified: trunk/Source/WebCore/platform/VideoFrame.h (291050 => 291051)
--- trunk/Source/WebCore/platform/VideoFrame.h 2022-03-09 15:58:14 UTC (rev 291050)
+++ trunk/Source/WebCore/platform/VideoFrame.h 2022-03-09 17:47:33 UTC (rev 291051)
@@ -52,9 +52,10 @@
WEBCORE_EXPORT PlatformSample::Type platformSampleType() const final;
virtual bool isRemoteProxy() const { return false; }
+ virtual bool isLibWebRTC() const { return false; }
#if USE(AVFOUNDATION)
virtual bool isCV() const { return false; }
- virtual RefPtr<WebCore::VideoFrameCV> asVideoFrameCV() = 0;
+ WEBCORE_EXPORT virtual RefPtr<VideoFrameCV> asVideoFrameCV();
#endif
void initializeCharacteristics(MediaTime presentationTime, bool isMirrored, VideoRotation);
Modified: trunk/Source/WebCore/platform/cocoa/SharedVideoFrameInfo.h (291050 => 291051)
--- trunk/Source/WebCore/platform/cocoa/SharedVideoFrameInfo.h 2022-03-09 15:58:14 UTC (rev 291050)
+++ trunk/Source/WebCore/platform/cocoa/SharedVideoFrameInfo.h 2022-03-09 17:47:33 UTC (rev 291051)
@@ -34,7 +34,7 @@
typedef struct __CVPixelBufferPool* CVPixelBufferPoolRef;
namespace webrtc {
-class VideoFrame;
+class VideoFrameBuffer;
}
namespace WebCore {
@@ -51,8 +51,8 @@
WEBCORE_EXPORT bool writePixelBuffer(CVPixelBufferRef, uint8_t* data);
#if USE(LIBWEBRTC)
- WEBCORE_EXPORT static SharedVideoFrameInfo fromVideoFrame(const webrtc::VideoFrame&);
- WEBCORE_EXPORT bool writeVideoFrame(const webrtc::VideoFrame&, uint8_t* data);
+ WEBCORE_EXPORT static SharedVideoFrameInfo fromVideoFrameBuffer(const webrtc::VideoFrameBuffer&);
+ WEBCORE_EXPORT bool writeVideoFrameBuffer(webrtc::VideoFrameBuffer&, uint8_t* data);
#endif
WEBCORE_EXPORT size_t storageSize() const;
Modified: trunk/Source/WebCore/platform/cocoa/SharedVideoFrameInfo.mm (291050 => 291051)
--- trunk/Source/WebCore/platform/cocoa/SharedVideoFrameInfo.mm 2022-03-09 15:58:14 UTC (rev 291050)
+++ trunk/Source/WebCore/platform/cocoa/SharedVideoFrameInfo.mm 2022-03-09 17:47:33 UTC (rev 291051)
@@ -72,6 +72,7 @@
void SharedVideoFrameInfo::encode(uint8_t* destination)
{
WTF::Persistence::Encoder encoder;
+
encoder << (uint32_t)m_bufferType;
encoder << m_width;
encoder << m_height;
@@ -209,31 +210,31 @@
}
#if USE(LIBWEBRTC)
-SharedVideoFrameInfo SharedVideoFrameInfo::fromVideoFrame(const webrtc::VideoFrame& frame)
+SharedVideoFrameInfo SharedVideoFrameInfo::fromVideoFrameBuffer(const webrtc::VideoFrameBuffer& frame)
{
- auto buffer = frame.video_frame_buffer();
- if (buffer->type() == webrtc::VideoFrameBuffer::Type::kNative)
+ if (frame.type() == webrtc::VideoFrameBuffer::Type::kNative)
return SharedVideoFrameInfo { };
- auto type = buffer->type();
-
+ auto type = frame.type();
if (type == webrtc::VideoFrameBuffer::Type::kI420)
return SharedVideoFrameInfo { kCVPixelFormatType_420YpCbCr8BiPlanarFullRange,
static_cast<uint32_t>(frame.width()), static_cast<uint32_t>(frame.height()), static_cast<uint32_t>(frame.width()),
- static_cast<uint32_t>(frame.width()), static_cast<uint32_t>(frame.height()), static_cast<uint32_t>(frame.width()) / 2 };
+ static_cast<uint32_t>(frame.width()) / 2, static_cast<uint32_t>(frame.height()) / 2, static_cast<uint32_t>(frame.width()) };
if (type == webrtc::VideoFrameBuffer::Type::kI010)
return SharedVideoFrameInfo { kCVPixelFormatType_420YpCbCr10BiPlanarFullRange,
static_cast<uint32_t>(frame.width()), static_cast<uint32_t>(frame.height()), static_cast<uint32_t>(frame.width() * 2),
- static_cast<uint32_t>(frame.width()), static_cast<uint32_t>(frame.height()), static_cast<uint32_t>(frame.width()) };
+ static_cast<uint32_t>(frame.width()) / 2, static_cast<uint32_t>(frame.height()) / 2, static_cast<uint32_t>(frame.width()) * 2 };
return SharedVideoFrameInfo { };
}
-bool SharedVideoFrameInfo::writeVideoFrame(const webrtc::VideoFrame& frame, uint8_t* data)
+bool SharedVideoFrameInfo::writeVideoFrameBuffer(webrtc::VideoFrameBuffer& frameBuffer, uint8_t* data)
{
ASSERT(m_bufferType == kCVPixelFormatType_420YpCbCr8BiPlanarFullRange || m_bufferType == kCVPixelFormatType_420YpCbCr10BiPlanarFullRange);
- return webrtc::copyVideoFrame(frame, data);
+ encode(data);
+ data += sizeof(SharedVideoFrameInfo);
+ return webrtc::copyVideoFrameBuffer(frameBuffer, data);
}
#endif
Added: trunk/Source/WebCore/platform/mediastream/libwebrtc/VideoFrameLibWebRTC.cpp (0 => 291051)
--- trunk/Source/WebCore/platform/mediastream/libwebrtc/VideoFrameLibWebRTC.cpp (rev 0)
+++ trunk/Source/WebCore/platform/mediastream/libwebrtc/VideoFrameLibWebRTC.cpp 2022-03-09 17:47:33 UTC (rev 291051)
@@ -0,0 +1,68 @@
+/*
+ * 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. 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.
+ */
+
+#include "config.h"
+#include "VideoFrameLibWebRTC.h"
+
+#if PLATFORM(COCOA) && USE(LIBWEBRTC)
+
+#include <pal/cf/CoreMediaSoftLink.h>
+#include "CoreVideoSoftLink.h"
+
+namespace WebCore {
+
+Ref<VideoFrameLibWebRTC> VideoFrameLibWebRTC::create(MediaTime presentationTime, bool isMirrored, VideoRotation rotation, rtc::scoped_refptr<webrtc::VideoFrameBuffer>&& buffer, ConversionCallback&& conversionCallback)
+{
+ return adoptRef(*new VideoFrameLibWebRTC(presentationTime, isMirrored, rotation, WTFMove(buffer), WTFMove(conversionCallback)));
+}
+
+VideoFrameLibWebRTC::VideoFrameLibWebRTC(MediaTime presentationTime, bool isMirrored, VideoRotation rotation, rtc::scoped_refptr<webrtc::VideoFrameBuffer>&& buffer, ConversionCallback&& conversionCallback)
+ : VideoFrame(presentationTime, isMirrored, rotation)
+ , m_buffer(WTFMove(buffer))
+ , m_size(m_buffer->width(), m_buffer->height())
+ , m_conversionCallback(WTFMove(conversionCallback))
+{
+ switch (m_buffer->type()) {
+ case webrtc::VideoFrameBuffer::Type::kI420:
+ m_videoPixelFormat = kCVPixelFormatType_420YpCbCr8BiPlanarFullRange;
+ break;
+ case webrtc::VideoFrameBuffer::Type::kI010:
+ m_videoPixelFormat = kCVPixelFormatType_420YpCbCr10BiPlanarFullRange;
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ }
+}
+
+CVPixelBufferRef VideoFrameLibWebRTC::pixelBuffer() const
+{
+ Locker locker { m_pixelBufferLock };
+ if (!m_pixelBuffer && m_conversionCallback)
+ m_pixelBuffer = std::exchange(m_conversionCallback, { })(*m_buffer);
+ return m_pixelBuffer.get();
+}
+
+}
+#endif // PLATFORM(COCOA) && USE(LIBWEBRTC)
Added: trunk/Source/WebCore/platform/mediastream/libwebrtc/VideoFrameLibWebRTC.h (0 => 291051)
--- trunk/Source/WebCore/platform/mediastream/libwebrtc/VideoFrameLibWebRTC.h (rev 0)
+++ trunk/Source/WebCore/platform/mediastream/libwebrtc/VideoFrameLibWebRTC.h 2022-03-09 17:47:33 UTC (rev 291051)
@@ -0,0 +1,73 @@
+/*
+ * 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. 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
+
+#if PLATFORM(COCOA) && USE(LIBWEBRTC)
+
+#include "VideoFrame.h"
+
+ALLOW_UNUSED_PARAMETERS_BEGIN
+#include <webrtc/api/video/video_frame.h>
+#include <webrtc/sdk/WebKit/WebKitUtilities.h>
+ALLOW_UNUSED_PARAMETERS_END
+
+using CVPixelBufferRef = struct __CVBuffer*;
+
+
+namespace WebCore {
+
+class VideoFrameLibWebRTC final : public VideoFrame {
+public:
+ using ConversionCallback = Function<RetainPtr<CVPixelBufferRef>(webrtc::VideoFrameBuffer&)>;
+ static Ref<VideoFrameLibWebRTC> create(MediaTime, bool isMirrored, VideoRotation, rtc::scoped_refptr<webrtc::VideoFrameBuffer>&&, ConversionCallback&&);
+
+ rtc::scoped_refptr<webrtc::VideoFrameBuffer> buffer() { return m_buffer; }
+
+private:
+ VideoFrameLibWebRTC(MediaTime, bool isMirrored, VideoRotation, rtc::scoped_refptr<webrtc::VideoFrameBuffer>&&, ConversionCallback&&);
+
+ // VideoFrame
+ FloatSize presentationSize() const final { return m_size; }
+ uint32_t videoPixelFormat() const final { return m_videoPixelFormat; }
+ CVPixelBufferRef pixelBuffer() const final;
+
+ const rtc::scoped_refptr<webrtc::VideoFrameBuffer> m_buffer;
+ FloatSize m_size;
+ uint32_t m_videoPixelFormat { 0 };
+
+ mutable ConversionCallback m_conversionCallback;
+ mutable RetainPtr<CVPixelBufferRef> m_pixelBuffer WTF_GUARDED_BY_LOCK(m_pixelBufferLock);
+ mutable Lock m_pixelBufferLock;
+};
+
+}
+
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::VideoFrameLibWebRTC)
+ static bool isType(const WebCore::VideoFrame& videoFrame) { return videoFrame.isLibWebRTC(); }
+ static bool isType(const WebCore::MediaSample& mediaSample) { return is<WebCore::VideoFrame>(mediaSample) && is<WebCore::VideoFrameLibWebRTC>(downcast<WebCore::VideoFrame>(mediaSample)); }
+SPECIALIZE_TYPE_TRAITS_END()
+
+#endif // PLATFORM(COCOA) && USE(LIBWEBRTC)
Modified: trunk/Source/WebCore/platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.h (291050 => 291051)
--- trunk/Source/WebCore/platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.h 2022-03-09 15:58:14 UTC (rev 291050)
+++ trunk/Source/WebCore/platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.h 2022-03-09 17:47:33 UTC (rev 291051)
@@ -62,7 +62,8 @@
#if !RELEASE_LOG_DISABLED
size_t m_numberOfFrames { 0 };
#endif
- RetainPtr<CVPixelBufferPoolRef> m_pixelBufferPool;
+ Lock m_pixelBufferPoolLock;
+ RetainPtr<CVPixelBufferPoolRef> m_pixelBufferPool WTF_GUARDED_BY_LOCK(m_pixelBufferPoolLock);
size_t m_pixelBufferPoolWidth { 0 };
size_t m_pixelBufferPoolHeight { 0 };
webrtc::BufferType m_pixelBufferPoolBufferType;
Modified: trunk/Source/WebCore/platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.mm (291050 => 291051)
--- trunk/Source/WebCore/platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.mm 2022-03-09 15:58:14 UTC (rev 291050)
+++ trunk/Source/WebCore/platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.mm 2022-03-09 17:47:33 UTC (rev 291051)
@@ -33,7 +33,7 @@
#import "CVUtilities.h"
#import "Logging.h"
#import "MediaSampleAVFObjC.h"
-#import "VideoFrame.h"
+#import "VideoFrameLibWebRTC.h"
#import <wtf/cf/TypeCastsCF.h>
ALLOW_UNUSED_PARAMETERS_BEGIN
@@ -62,7 +62,7 @@
{
}
-CVPixelBufferPoolRef RealtimeIncomingVideoSourceCocoa::pixelBufferPool(size_t width, size_t height, webrtc::BufferType bufferType)
+CVPixelBufferPoolRef RealtimeIncomingVideoSourceCocoa::pixelBufferPool(size_t width, size_t height, webrtc::BufferType bufferType) WTF_IGNORES_THREAD_SAFETY_ANALYSIS
{
if (!m_pixelBufferPool || m_pixelBufferPoolWidth != width || m_pixelBufferPoolHeight != height || m_pixelBufferPoolBufferType != bufferType) {
OSType poolBufferType;
@@ -135,23 +135,26 @@
return videoFrame;
}
- // In case of in memory samples, we have non interleaved YUV data while CVPixelBuffers prefer interleaved YUV data.
- // Maybe we should introduce a MediaSample that would represent non interleaved YUV data as an optimization.
- auto pixelBuffer = adoptCF(webrtc::createPixelBufferFromFrame(frame, [this](size_t width, size_t height, webrtc::BufferType bufferType) -> CVPixelBufferRef {
- auto pixelBufferPool = this->pixelBufferPool(width, height, bufferType);
- if (!pixelBufferPool)
- return nullptr;
+ // If we already have a CVPixelBufferRef, use it directly.
+ if (auto pixelBuffer = webrtc::pixelBufferFromFrame(frame))
+ return createMediaSampleFromCVPixelBuffer(pixelBuffer, rotation, frame.timestamp_us());
- CVPixelBufferRef pixelBuffer = nullptr;
- auto status = CVPixelBufferPoolCreatePixelBuffer(kCFAllocatorDefault, m_pixelBufferPool.get(), &pixelBuffer);
-
- if (status != kCVReturnSuccess) {
- ERROR_LOG_IF(loggerPtr(), LOGIDENTIFIER, "Failed creating a pixel buffer with error ", status);
- return nullptr;
- }
- return pixelBuffer;
- }));
- return createMediaSampleFromCVPixelBuffer(pixelBuffer.get(), rotation, frame.timestamp_us());
+ // In case of in memory libwebrtc samples, we have non interleaved YUV data, let's lazily create CVPixelBuffers if needed.
+ return VideoFrameLibWebRTC::create(MediaTime(frame.timestamp_us(), 1000000), false, rotation, frame.video_frame_buffer(), [protectedThis = Ref { *this }, this](auto& buffer) {
+ return adoptCF(webrtc::createPixelBufferFromFrameBuffer(buffer, [this](size_t width, size_t height, webrtc::BufferType bufferType) -> CVPixelBufferRef {
+ Locker lock(m_pixelBufferPoolLock);
+ auto pixelBufferPool = this->pixelBufferPool(width, height, bufferType);
+ if (!pixelBufferPool)
+ return nullptr;
+ CVPixelBufferRef pixelBuffer = nullptr;
+ auto status = CVPixelBufferPoolCreatePixelBuffer(kCFAllocatorDefault, m_pixelBufferPool.get(), &pixelBuffer);
+ if (status != kCVReturnSuccess) {
+ ERROR_LOG_IF(loggerPtr(), LOGIDENTIFIER, "Failed creating a pixel buffer with error ", status);
+ return nullptr;
+ }
+ return pixelBuffer;
+ }));
+ });
}
void RealtimeIncomingVideoSourceCocoa::OnFrame(const webrtc::VideoFrame& webrtcVideoFrame)
Modified: trunk/Source/WebCore/platform/mediastream/mac/RealtimeOutgoingVideoSourceCocoa.cpp (291050 => 291051)
--- trunk/Source/WebCore/platform/mediastream/mac/RealtimeOutgoingVideoSourceCocoa.cpp 2022-03-09 15:58:14 UTC (rev 291050)
+++ trunk/Source/WebCore/platform/mediastream/mac/RealtimeOutgoingVideoSourceCocoa.cpp 2022-03-09 17:47:33 UTC (rev 291051)
@@ -33,7 +33,7 @@
#include "Logging.h"
#include "RealtimeIncomingVideoSourceCocoa.h"
#include "RealtimeVideoUtilities.h"
-#include "VideoFrame.h"
+#include "VideoFrameLibWebRTC.h"
ALLOW_UNUSED_PARAMETERS_BEGIN
@@ -86,14 +86,20 @@
}
bool shouldApplyRotation = m_shouldApplyRotation && m_currentRotation != webrtc::kVideoRotation_0;
- if (!shouldApplyRotation && is<VideoFrame>(sample) && downcast<VideoFrame>(sample).isRemoteProxy()) {
- Ref videoFrame { downcast<VideoFrame>(sample) };
- auto size = sample.presentationSize();
- sendFrame(webrtc::toWebRTCVideoFrameBuffer(&videoFrame.leakRef(),
- [](auto* pointer) { return static_cast<VideoFrame*>(pointer)->pixelBuffer(); },
- [](auto* pointer) { static_cast<VideoFrame*>(pointer)->deref(); },
- static_cast<int>(size.width()), static_cast<int>(size.height())));
- return;
+ if (!shouldApplyRotation && is<VideoFrame>(sample)) {
+ if (downcast<VideoFrame>(sample).isRemoteProxy()) {
+ Ref videoFrame { downcast<VideoFrame>(sample) };
+ auto size = sample.presentationSize();
+ sendFrame(webrtc::toWebRTCVideoFrameBuffer(&videoFrame.leakRef(),
+ [](auto* pointer) { return static_cast<VideoFrame*>(pointer)->pixelBuffer(); },
+ [](auto* pointer) { static_cast<VideoFrame*>(pointer)->deref(); },
+ static_cast<int>(size.width()), static_cast<int>(size.height())));
+ return;
+ }
+ if (downcast<VideoFrame>(sample).isLibWebRTC()) {
+ sendFrame(downcast<VideoFrameLibWebRTC>(sample).buffer());
+ return;
+ }
}
auto pixelBuffer = sample.pixelBuffer();
Modified: trunk/Source/WebKit/ChangeLog (291050 => 291051)
--- trunk/Source/WebKit/ChangeLog 2022-03-09 15:58:14 UTC (rev 291050)
+++ trunk/Source/WebKit/ChangeLog 2022-03-09 17:47:33 UTC (rev 291051)
@@ -1,3 +1,21 @@
+2022-03-09 Youenn Fablet <[email protected]>
+
+ Allow to pass webrtc video frame buffers through RealtimeMediaSource based pipelines
+ https://bugs.webkit.org/show_bug.cgi?id=236131
+ <rdar://problem/88805580>
+
+ Reviewed by Eric Carlson.
+
+ Add optimization support for VideoFrameLibWebRTC writing into shared memory.
+ This removes the need to convert the webrtc video frame into a CVPixelBuffer, just to send it to GPUProcess for rendering.
+
+ * GPUProcess/webrtc/LibWebRTCCodecsProxy.h:
+ * WebKit.xcodeproj/project.pbxproj:
+ * WebProcess/GPU/media/RemoteVideoFrameProxy.cpp:
+ * WebProcess/GPU/media/RemoteVideoFrameProxy.h:
+ * WebProcess/GPU/webrtc/SharedVideoFrame.cpp:
+ * WebProcess/GPU/webrtc/SharedVideoFrame.h:
+
2022-03-09 Fujii Hironori <[email protected]>
[WinCairo] Improve WCTiledBacking and TextureMapperSparseBackingStore
Modified: trunk/Source/WebKit/GPUProcess/webrtc/LibWebRTCCodecsProxy.h (291050 => 291051)
--- trunk/Source/WebKit/GPUProcess/webrtc/LibWebRTCCodecsProxy.h 2022-03-09 15:58:14 UTC (rev 291050)
+++ trunk/Source/WebKit/GPUProcess/webrtc/LibWebRTCCodecsProxy.h 2022-03-09 17:47:33 UTC (rev 291051)
@@ -57,6 +57,7 @@
class GPUConnectionToWebProcess;
class RemoteVideoFrameObjectHeap;
+struct SharedVideoFrame;
class SharedVideoFrameReader;
class LibWebRTCCodecsProxy final : public IPC::Connection::ThreadMessageReceiverRefCounted {
Modified: trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj (291050 => 291051)
--- trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj 2022-03-09 15:58:14 UTC (rev 291050)
+++ trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj 2022-03-09 17:47:33 UTC (rev 291051)
@@ -846,6 +846,8 @@
413075B01DE85F580039EC69 /* WebRTCMonitor.h in Headers */ = {isa = PBXBuildFile; fileRef = 413075A31DE85EE70039EC69 /* WebRTCMonitor.h */; };
413075B21DE85F580039EC69 /* LibWebRTCSocketFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = 413075A61DE85EE70039EC69 /* LibWebRTCSocketFactory.h */; };
413075B41DE85F580039EC69 /* LibWebRTCProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 413075A81DE85EE70039EC69 /* LibWebRTCProvider.h */; };
+ 413C541A27C67C39002FCDA8 /* LibWebRTCCodecsProxy.mm in Sources */ = {isa = PBXBuildFile; fileRef = 41E0A7C823B6397900561060 /* LibWebRTCCodecsProxy.mm */; };
+ 413C542527CCB7CE002FCDA8 /* SharedVideoFrame.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41DC04F927A816BB008CF968 /* SharedVideoFrame.cpp */; };
4176901422FDD41B00B1576D /* NetworkRTCProvider.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4176901322FDD41B00B1576D /* NetworkRTCProvider.mm */; };
417915AF2256BB7500D6F97E /* WebSocketChannel.h in Headers */ = {isa = PBXBuildFile; fileRef = 417915AD2256BB7400D6F97E /* WebSocketChannel.h */; };
417915B12256C0D600D6F97E /* WebSocketChannelManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 417915B02256C0D600D6F97E /* WebSocketChannelManager.h */; };
@@ -16251,6 +16253,8 @@
buildActionMask = 2147483647;
files = (
5CE912102293C277005BEC78 /* AuxiliaryProcessMain.cpp in Sources */,
+ 413C541A27C67C39002FCDA8 /* LibWebRTCCodecsProxy.mm in Sources */,
+ 413C542527CCB7CE002FCDA8 /* SharedVideoFrame.cpp in Sources */,
5C9A9111228F69CC005C5B17 /* XPCServiceMain.mm in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Modified: trunk/Source/WebKit/WebProcess/GPU/media/RemoteVideoFrameProxy.cpp (291050 => 291051)
--- trunk/Source/WebKit/WebProcess/GPU/media/RemoteVideoFrameProxy.cpp 2022-03-09 15:58:14 UTC (rev 291050)
+++ trunk/Source/WebKit/WebProcess/GPU/media/RemoteVideoFrameProxy.cpp 2022-03-09 17:47:33 UTC (rev 291051)
@@ -127,15 +127,6 @@
m_pixelBuffer = WebCore::createBlackPixelBuffer(static_cast<size_t>(m_size.width()), static_cast<size_t>(m_size.height()));
return m_pixelBuffer.get();
}
-
-RefPtr<WebCore::VideoFrameCV> RemoteVideoFrameProxy::asVideoFrameCV()
-{
- auto buffer = pixelBuffer();
- if (!buffer)
- return nullptr;
- return VideoFrameCV::create(m_presentationTime, m_isMirrored, m_rotation, RetainPtr { buffer });
-}
-
#endif
TextStream& operator<<(TextStream& ts, const RemoteVideoFrameProxy::Properties& properties)
Modified: trunk/Source/WebKit/WebProcess/GPU/media/RemoteVideoFrameProxy.h (291050 => 291051)
--- trunk/Source/WebKit/WebProcess/GPU/media/RemoteVideoFrameProxy.h 2022-03-09 15:58:14 UTC (rev 291050)
+++ trunk/Source/WebKit/WebProcess/GPU/media/RemoteVideoFrameProxy.h 2022-03-09 17:47:33 UTC (rev 291051)
@@ -88,7 +88,6 @@
bool isRemoteProxy() const final { return true; }
#if PLATFORM(COCOA)
CVPixelBufferRef pixelBuffer() const final;
- RefPtr<WebCore::VideoFrameCV> asVideoFrameCV() final;
#endif
private:
Modified: trunk/Source/WebKit/WebProcess/GPU/webrtc/SharedVideoFrame.cpp (291050 => 291051)
--- trunk/Source/WebKit/WebProcess/GPU/webrtc/SharedVideoFrame.cpp 2022-03-09 15:58:14 UTC (rev 291050)
+++ trunk/Source/WebKit/WebProcess/GPU/webrtc/SharedVideoFrame.cpp 2022-03-09 17:47:33 UTC (rev 291051)
@@ -35,6 +35,7 @@
#include <WebCore/IOSurface.h>
#include <WebCore/MediaSampleAVFObjC.h>
#include <WebCore/SharedVideoFrameInfo.h>
+#include <WebCore/VideoFrameLibWebRTC.h>
#include <wtf/Scope.h>
#if USE(LIBWEBRTC)
@@ -105,6 +106,11 @@
if (is<RemoteVideoFrameProxy>(frame))
return downcast<RemoteVideoFrameProxy>(frame).newReadReference();
+#if USE(LIBWEBRTC)
+ if (is<VideoFrameLibWebRTC>(frame))
+ return writeBuffer(*downcast<VideoFrameLibWebRTC>(frame).buffer(), newSemaphoreCallback, newMemoryCallback);
+#endif
+
return writeBuffer(frame.pixelBuffer(), newSemaphoreCallback, newMemoryCallback);
}
@@ -136,11 +142,16 @@
if (auto pixelBuffer = adoptCF(webrtc::pixelBufferFromFrame(frame)))
return writeBuffer(pixelBuffer.get(), newSemaphoreCallback, newMemoryCallback);
- auto info = SharedVideoFrameInfo::fromVideoFrame(frame);
+ return writeBuffer(*frame.video_frame_buffer(), newSemaphoreCallback, newMemoryCallback);
+}
+
+std::optional<SharedVideoFrame::Buffer> SharedVideoFrameWriter::writeBuffer(webrtc::VideoFrameBuffer& frameBuffer, const Function<void(IPC::Semaphore&)>& newSemaphoreCallback, const Function<void(const SharedMemory::IPCHandle&)>& newMemoryCallback)
+{
+ auto info = SharedVideoFrameInfo::fromVideoFrameBuffer(frameBuffer);
if (!prepareWriting(info, newSemaphoreCallback, newMemoryCallback))
return { };
- if (!info.writeVideoFrame(frame, static_cast<uint8_t*>(m_storage->data())))
+ if (!info.writeVideoFrameBuffer(frameBuffer, static_cast<uint8_t*>(m_storage->data())))
return { };
return nullptr;
}
Modified: trunk/Source/WebKit/WebProcess/GPU/webrtc/SharedVideoFrame.h (291050 => 291051)
--- trunk/Source/WebKit/WebProcess/GPU/webrtc/SharedVideoFrame.h 2022-03-09 15:58:14 UTC (rev 291050)
+++ trunk/Source/WebKit/WebProcess/GPU/webrtc/SharedVideoFrame.h 2022-03-09 17:47:33 UTC (rev 291051)
@@ -45,6 +45,7 @@
namespace webrtc {
class VideoFrame;
+class VideoFrameBuffer;
}
namespace WebKit {
@@ -78,7 +79,11 @@
bool wait(const Function<void(IPC::Semaphore&)>&);
bool allocateStorage(size_t, const Function<void(const SharedMemory::IPCHandle&)>&);
bool prepareWriting(const WebCore::SharedVideoFrameInfo&, const Function<void(IPC::Semaphore&)>&, const Function<void(const SharedMemory::IPCHandle&)>&);
+
std::optional<SharedVideoFrame::Buffer> writeBuffer(WebCore::MediaSample&, const Function<void(IPC::Semaphore&)>&, const Function<void(const SharedMemory::IPCHandle&)>&);
+#if USE(LIBWEBRTC)
+ std::optional<SharedVideoFrame::Buffer> writeBuffer(webrtc::VideoFrameBuffer&, const Function<void(IPC::Semaphore&)>&, const Function<void(const SharedMemory::IPCHandle&)>&);
+#endif
UniqueRef<IPC::Semaphore> m_semaphore;
RefPtr<SharedMemory> m_storage;