Diff
Modified: trunk/Source/WebCore/ChangeLog (236338 => 236339)
--- trunk/Source/WebCore/ChangeLog 2018-09-21 18:33:29 UTC (rev 236338)
+++ trunk/Source/WebCore/ChangeLog 2018-09-21 18:37:31 UTC (rev 236339)
@@ -1,3 +1,28 @@
+2018-09-21 Youenn Fablet <[email protected]>
+
+ Centralize which CVPixelBuffer format is being used
+ https://bugs.webkit.org/show_bug.cgi?id=189772
+
+ Reviewed by Eric Carlson.
+
+ Get the format type from a single point.
+ This changes the video capture and mock realtime video sources on Mac to use a biplanar format.
+ No observable change of behavior.
+
+ * WebCore.xcodeproj/project.pbxproj:
+ * platform/mediastream/mac/AVVideoCaptureSource.mm:
+ (WebCore::AVVideoCaptureSource::setSizeAndFrameRateWithPreset):
+ (WebCore::AVVideoCaptureSource::setupCaptureSession):
+ (WebCore::AVVideoCaptureSource::captureOutputDidOutputSampleBufferFromConnection):
+ * platform/mediastream/mac/MockRealtimeVideoSourceMac.mm:
+ (WebCore::MockRealtimeVideoSourceMac::updateSampleBuffer):
+ (WebCore::MockRealtimeVideoSourceMac::setSizeAndFrameRateWithPreset):
+ * platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.mm:
+ (WebCore::createBlackPixelBuffer):
+ * platform/mediastream/mac/RealtimeOutgoingVideoSourceCocoa.cpp:
+ (WebCore::RealtimeOutgoingVideoSourceCocoa::sampleBufferUpdated):
+ * platform/mediastream/mac/RealtimeVideoUtilities.h: Added.
+
2018-09-21 Antoine Quint <[email protected]>
REGRESSION (r235962-r235963): Layout Test animations/suspend-resume-animation-events.html is a flaky failure
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (236338 => 236339)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2018-09-21 18:33:29 UTC (rev 236338)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2018-09-21 18:37:31 UTC (rev 236339)
@@ -7379,6 +7379,7 @@
41D129CA1F3D0EE300D15E47 /* CacheStorageRecord.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CacheStorageRecord.h; sourceTree = "<group>"; };
41D129CC1F3D0EE300D15E47 /* CacheStorageConnection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CacheStorageConnection.h; sourceTree = "<group>"; };
41D129D41F3D0F6600D15E47 /* CacheStorageProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CacheStorageProvider.h; sourceTree = "<group>"; };
+ 41D1938F2152C561006F14CA /* RealtimeVideoUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RealtimeVideoUtilities.h; sourceTree = "<group>"; };
41D1A046213EDDEB0063FB6B /* RTCRtpSenderBackend.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RTCRtpSenderBackend.h; sourceTree = "<group>"; };
41D1A048213EDDEB0063FB6B /* RTCRtpReceiverBackend.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RTCRtpReceiverBackend.h; sourceTree = "<group>"; };
41D1A049213EDDFD0063FB6B /* LibWebRTCUtils.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = LibWebRTCUtils.cpp; path = libwebrtc/LibWebRTCUtils.cpp; sourceTree = "<group>"; };
@@ -15372,6 +15373,7 @@
5CDD833B1E4324BB00621B83 /* RealtimeOutgoingVideoSourceCocoa.cpp */,
5CDD833C1E4324BB00621B83 /* RealtimeOutgoingVideoSourceCocoa.h */,
419242472127B7CC00634FCF /* RealtimeOutgoingVideoSourceCocoa.mm */,
+ 41D1938F2152C561006F14CA /* RealtimeVideoUtilities.h */,
070A9F5E1FFECC70003DF649 /* ScreenDisplayCaptureSourceMac.h */,
070A9F601FFECC71003DF649 /* ScreenDisplayCaptureSourceMac.mm */,
07D6373E1BB0B11300256CE9 /* WebAudioSourceProviderAVFObjC.h */,
Modified: trunk/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.mm (236338 => 236339)
--- trunk/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.mm 2018-09-21 18:33:29 UTC (rev 236338)
+++ trunk/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.mm 2018-09-21 18:37:31 UTC (rev 236339)
@@ -37,6 +37,7 @@
#import "PlatformLayer.h"
#import "RealtimeMediaSourceCenterMac.h"
#import "RealtimeMediaSourceSettings.h"
+#import "RealtimeVideoUtilities.h"
#import <AVFoundation/AVCaptureDevice.h>
#import <AVFoundation/AVCaptureInput.h>
#import <AVFoundation/AVCaptureOutput.h>
@@ -113,12 +114,6 @@
namespace WebCore {
-#if PLATFORM(MAC)
-const OSType videoCaptureFormat = kCVPixelFormatType_420YpCbCr8Planar;
-#else
-const OSType videoCaptureFormat = kCVPixelFormatType_420YpCbCr8BiPlanarFullRange;
-#endif
-
static dispatch_queue_t globaVideoCaptureSerialQueue()
{
static dispatch_queue_t globalQueue;
@@ -340,7 +335,7 @@
[device() setActiveFormat:avPreset->format.get()];
#if PLATFORM(MAC)
auto settingsDictionary = @{
- (__bridge NSString *)kCVPixelBufferPixelFormatTypeKey: @(videoCaptureFormat),
+ (__bridge NSString *)kCVPixelBufferPixelFormatTypeKey: @(preferedPixelBufferFormat()),
(__bridge NSString *)kCVPixelBufferWidthKey: @(avPreset->size.width()),
(__bridge NSString *)kCVPixelBufferHeightKey: @(avPreset->size.height())
};
@@ -449,7 +444,7 @@
[session() addInput:videoIn.get()];
m_videoOutput = adoptNS([allocAVCaptureVideoDataOutputInstance() init]);
- auto settingsDictionary = adoptNS([[NSMutableDictionary alloc] initWithObjectsAndKeys: [NSNumber numberWithInt:videoCaptureFormat], kCVPixelBufferPixelFormatTypeKey, nil]);
+ auto settingsDictionary = adoptNS([[NSMutableDictionary alloc] initWithObjectsAndKeys: [NSNumber numberWithInt:preferedPixelBufferFormat()], kCVPixelBufferPixelFormatTypeKey, nil]);
[m_videoOutput setVideoSettings:settingsDictionary.get()];
[m_videoOutput setAlwaysDiscardsLateVideoFrames:YES];
@@ -554,7 +549,7 @@
m_pixelBufferResizer = nullptr;
if (!m_pixelBufferResizer)
- m_pixelBufferResizer = std::make_unique<PixelBufferResizer>(m_requestedSize, videoCaptureFormat);
+ m_pixelBufferResizer = std::make_unique<PixelBufferResizer>(m_requestedSize, preferedPixelBufferFormat());
} else
m_pixelBufferResizer = nullptr;
Modified: trunk/Source/WebCore/platform/mediastream/mac/MockRealtimeVideoSourceMac.mm (236338 => 236339)
--- trunk/Source/WebCore/platform/mediastream/mac/MockRealtimeVideoSourceMac.mm 2018-09-21 18:33:29 UTC (rev 236338)
+++ trunk/Source/WebCore/platform/mediastream/mac/MockRealtimeVideoSourceMac.mm 2018-09-21 18:37:31 UTC (rev 236339)
@@ -40,6 +40,7 @@
#import "PixelBufferResizer.h"
#import "PlatformLayer.h"
#import "RealtimeMediaSourceSettings.h"
+#import "RealtimeVideoUtilities.h"
#import <QuartzCore/CALayer.h>
#import <QuartzCore/CATransaction.h>
#import <objc/runtime.h>
@@ -50,11 +51,6 @@
namespace WebCore {
using namespace PAL;
-#if PLATFORM(MAC)
-const OSType videoCaptureFormat = kCVPixelFormatType_420YpCbCr8Planar;
-#else
-const OSType videoCaptureFormat = kCVPixelFormatType_420YpCbCr8BiPlanarFullRange;
-#endif
static const int videoSampleRate = 90000;
CaptureSourceOrError MockRealtimeVideoSource::create(const String& deviceID, const String& name, const MediaConstraints* constraints)
@@ -154,7 +150,7 @@
else {
if (!m_pixelBufferConformer) {
m_pixelBufferConformer = std::make_unique<PixelBufferConformerCV>((__bridge CFDictionaryRef)@{
- (__bridge NSString *)kCVPixelBufferPixelFormatTypeKey: @(videoCaptureFormat)
+ (__bridge NSString *)kCVPixelBufferPixelFormatTypeKey: @(preferedPixelBufferFormat())
});
}
@@ -210,7 +206,7 @@
m_pixelBufferResizer = nullptr;
if (!m_pixelBufferResizer)
- m_pixelBufferResizer = std::make_unique<PixelBufferResizer>(requestedSize, videoCaptureFormat);
+ m_pixelBufferResizer = std::make_unique<PixelBufferResizer>(requestedSize, preferedPixelBufferFormat());
} else
m_pixelBufferResizer = nullptr;
}
Modified: trunk/Source/WebCore/platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.mm (236338 => 236339)
--- trunk/Source/WebCore/platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.mm 2018-09-21 18:33:29 UTC (rev 236338)
+++ trunk/Source/WebCore/platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.mm 2018-09-21 18:37:31 UTC (rev 236339)
@@ -66,6 +66,7 @@
RetainPtr<CVPixelBufferRef> createBlackPixelBuffer(size_t width, size_t height)
{
+ // FIXME: change to biplanar format type.
CVPixelBufferRef pixelBuffer = nullptr;
auto status = CVPixelBufferCreate(kCFAllocatorDefault, width, height, kCVPixelFormatType_420YpCbCr8Planar, nullptr, &pixelBuffer);
ASSERT_UNUSED(status, status == noErr);
Modified: trunk/Source/WebCore/platform/mediastream/mac/RealtimeOutgoingVideoSourceCocoa.cpp (236338 => 236339)
--- trunk/Source/WebCore/platform/mediastream/mac/RealtimeOutgoingVideoSourceCocoa.cpp 2018-09-21 18:33:29 UTC (rev 236338)
+++ trunk/Source/WebCore/platform/mediastream/mac/RealtimeOutgoingVideoSourceCocoa.cpp 2018-09-21 18:37:31 UTC (rev 236339)
@@ -30,6 +30,7 @@
#include "Logging.h"
#include "RealtimeIncomingVideoSourceCocoa.h"
+#include "RealtimeVideoUtilities.h"
ALLOW_UNUSED_PARAMETERS_BEGIN
@@ -126,7 +127,7 @@
auto pixelFormatType = CVPixelBufferGetPixelFormatType(pixelBuffer);
RetainPtr<CVPixelBufferRef> convertedBuffer = pixelBuffer;
- if (pixelFormatType != kCVPixelFormatType_420YpCbCr8Planar && pixelFormatType != kCVPixelFormatType_420YpCbCr8BiPlanarFullRange)
+ if (pixelFormatType != preferedPixelBufferFormat())
convertedBuffer = convertToYUV(pixelBuffer);
if (m_shouldApplyRotation && m_currentRotation != webrtc::kVideoRotation_0)
Added: trunk/Source/WebCore/platform/mediastream/mac/RealtimeVideoUtilities.h (0 => 236339)
--- trunk/Source/WebCore/platform/mediastream/mac/RealtimeVideoUtilities.h (rev 0)
+++ trunk/Source/WebCore/platform/mediastream/mac/RealtimeVideoUtilities.h 2018-09-21 18:37:31 UTC (rev 236339)
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2018 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.
+ */
+
+#include <CoreVideo/CoreVideo.h>
+
+namespace WebCore {
+
+static inline OSType preferedPixelBufferFormat()
+{
+#if PLATFORM(MAC)
+ return kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange;
+#else
+ return kCVPixelFormatType_420YpCbCr8BiPlanarFullRange;
+#endif
+}
+
+}