Diff
Modified: trunk/Source/WebCore/ChangeLog (236346 => 236347)
--- trunk/Source/WebCore/ChangeLog 2018-09-21 19:39:41 UTC (rev 236346)
+++ trunk/Source/WebCore/ChangeLog 2018-09-21 19:55:57 UTC (rev 236347)
@@ -1,5 +1,23 @@
2018-09-21 Youenn Fablet <[email protected]>
+ Use biplanar CVPixelBuffer for black frames sent to libwebrtc
+ https://bugs.webkit.org/show_bug.cgi?id=189837
+
+ Reviewed by Eric Carlson.
+
+ Covered by webrtc/video-mute.html.
+
+ Add support to call CVPixelBufferGetBytesPerRowOfPlane.
+ Make createBlackPixelBuffer use a biplanar CVPixelBuffer as this is better supported in libwebrtc.
+ It is also what is being used in iOS for capture.
+
+ * platform/cocoa/CoreVideoSoftLink.cpp:
+ * platform/cocoa/CoreVideoSoftLink.h:
+ * platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.mm:
+ (WebCore::createBlackPixelBuffer):
+
+2018-09-21 Youenn Fablet <[email protected]>
+
Add RTCCodecStats support
https://bugs.webkit.org/show_bug.cgi?id=189792
<rdar://problem/32370668>
Modified: trunk/Source/WebCore/platform/cocoa/CoreVideoSoftLink.cpp (236346 => 236347)
--- trunk/Source/WebCore/platform/cocoa/CoreVideoSoftLink.cpp 2018-09-21 19:39:41 UTC (rev 236346)
+++ trunk/Source/WebCore/platform/cocoa/CoreVideoSoftLink.cpp 2018-09-21 19:55:57 UTC (rev 236347)
@@ -40,6 +40,7 @@
SOFT_LINK_FUNCTION_FOR_SOURCE(WebCore, CoreVideo, CVPixelBufferGetHeight, size_t, (CVPixelBufferRef pixelBuffer), (pixelBuffer))
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, CVPixelBufferGetDataSize, size_t, (CVPixelBufferRef pixelBuffer), (pixelBuffer))
SOFT_LINK_FUNCTION_FOR_SOURCE(WebCore, CoreVideo, CVPixelBufferGetPixelFormatType, OSType, (CVPixelBufferRef pixelBuffer), (pixelBuffer))
SOFT_LINK_FUNCTION_FOR_SOURCE(WebCore, CoreVideo, CVPixelBufferGetBaseAddressOfPlane, void *, (CVPixelBufferRef pixelBuffer, size_t planeIndex), (pixelBuffer, planeIndex));
Modified: trunk/Source/WebCore/platform/cocoa/CoreVideoSoftLink.h (236346 => 236347)
--- trunk/Source/WebCore/platform/cocoa/CoreVideoSoftLink.h 2018-09-21 19:39:41 UTC (rev 236346)
+++ trunk/Source/WebCore/platform/cocoa/CoreVideoSoftLink.h 2018-09-21 19:55:57 UTC (rev 236347)
@@ -46,6 +46,8 @@
#define CVPixelBufferGetBaseAddress softLink_CoreVideo_CVPixelBufferGetBaseAddress
SOFT_LINK_FUNCTION_FOR_HEADER(WebCore, CoreVideo, CVPixelBufferGetBytesPerRow, size_t, (CVPixelBufferRef pixelBuffer), (pixelBuffer))
#define CVPixelBufferGetBytesPerRow softLink_CoreVideo_CVPixelBufferGetBytesPerRow
+SOFT_LINK_FUNCTION_FOR_HEADER(WebCore, CoreVideo, CVPixelBufferGetBytesPerRowOfPlane, size_t, (CVPixelBufferRef pixelBuffer, size_t planeIndex), (pixelBuffer, planeIndex))
+#define CVPixelBufferGetBytesPerRowOfPlane softLink_CoreVideo_CVPixelBufferGetBytesPerRowOfPlane
SOFT_LINK_FUNCTION_FOR_HEADER(WebCore, CoreVideo, CVPixelBufferGetDataSize, size_t, (CVPixelBufferRef pixelBuffer), (pixelBuffer))
#define CVPixelBufferGetDataSize softLink_CoreVideo_CVPixelBufferGetDataSize
SOFT_LINK_FUNCTION_FOR_HEADER(WebCore, CoreVideo, CVPixelBufferGetPixelFormatType, OSType, (CVPixelBufferRef pixelBuffer), (pixelBuffer))
Modified: trunk/Source/WebCore/platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.mm (236346 => 236347)
--- trunk/Source/WebCore/platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.mm 2018-09-21 19:39:41 UTC (rev 236346)
+++ trunk/Source/WebCore/platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.mm 2018-09-21 19:55:57 UTC (rev 236347)
@@ -66,20 +66,25 @@
RetainPtr<CVPixelBufferRef> createBlackPixelBuffer(size_t width, size_t height)
{
- // FIXME: change to biplanar format type.
+ OSType format = preferedPixelBufferFormat();
+ ASSERT(format == kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange || format == kCVPixelFormatType_420YpCbCr8BiPlanarFullRange);
+
CVPixelBufferRef pixelBuffer = nullptr;
- auto status = CVPixelBufferCreate(kCFAllocatorDefault, width, height, kCVPixelFormatType_420YpCbCr8Planar, nullptr, &pixelBuffer);
+ auto status = CVPixelBufferCreate(kCFAllocatorDefault, width, height, format, nullptr, &pixelBuffer);
ASSERT_UNUSED(status, status == noErr);
status = CVPixelBufferLockBaseAddress(pixelBuffer, 0);
ASSERT(status == noErr);
- void* data = ""
- size_t yLength = width * height;
- memset(data, 0, yLength);
+ auto* yPlane = static_cast<uint8_t*>(CVPixelBufferGetBaseAddressOfPlane(pixelBuffer, 0));
+ size_t yStride = CVPixelBufferGetBytesPerRowOfPlane(pixelBuffer, 0);
+ for (unsigned i = 0; i < height; ++i)
+ memset(&yPlane[i * yStride], 0, width);
- auto totalSize = CVPixelBufferGetDataSize(pixelBuffer);
- memset(static_cast<uint8_t*>(data) + yLength, 128, totalSize - yLength);
+ auto* uvPlane = static_cast<uint8_t*>(CVPixelBufferGetBaseAddressOfPlane(pixelBuffer, 1));
+ size_t uvStride = CVPixelBufferGetBytesPerRowOfPlane(pixelBuffer, 1);
+ for (unsigned i = 0; i < height / 2; ++i)
+ memset(&uvPlane[i * uvStride], 128, width);
status = CVPixelBufferUnlockBaseAddress(pixelBuffer, 0);
ASSERT(!status);