Title: [236070] trunk
Revision
236070
Author
[email protected]
Date
2018-09-17 10:15:56 -0700 (Mon, 17 Sep 2018)

Log Message

Enable VCP for iOS and reenable it for MacOS
https://bugs.webkit.org/show_bug.cgi?id=189635
<rdar://problem/43621029>

Reviewed by Eric Carlson.

Source/ThirdParty/libwebrtc:

Make sure VCP API is used to set encoding session parameters.

* Source/webrtc/sdk/WebKit/VideoProcessingSoftLink.h:
* Source/webrtc/sdk/objc/Framework/Classes/VideoToolbox/RTCVideoEncoderH264.mm:
(-[RTCVideoEncoderH264 resetCompressionSessionWithPixelFormat:]):
* Source/webrtc/sdk/objc/Framework/Classes/VideoToolbox/helpers.cc:
* Source/webrtc/sdk/objc/Framework/Classes/VideoToolbox/helpers.h:

Source/WebCore:

Covered by exsiting and modified tests.
Instead of using libwebrtc YUV frames for black frames, use CVPixelBuffer to make it efficient.
Add internal API to know whether VCP is enabled so as to make capture-webrtc test pass on all platforms.

* platform/mediastream/RealtimeOutgoingVideoSource.cpp:
(WebCore::RealtimeOutgoingVideoSource::sendBlackFramesIfNeeded):
* platform/mediastream/RealtimeOutgoingVideoSource.h:
* platform/mediastream/gstreamer/RealtimeOutgoingVideoSourceLibWebRTC.h:
* platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.h:
* platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.mm:
(WebCore::createBlackPixelBuffer):
(WebCore::RealtimeIncomingVideoSourceCocoa::pixelBufferFromVideoFrame):
* platform/mediastream/mac/RealtimeOutgoingVideoSourceCocoa.cpp:
(WebCore::RealtimeOutgoingVideoSourceCocoa::createBlackFrame):
* platform/mediastream/mac/RealtimeOutgoingVideoSourceCocoa.h:
* testing/Internals.cpp:
(WebCore::Internals::supportsVCPEncoder):
* testing/Internals.h:
* testing/Internals.idl:

LayoutTests:

* platform/mac/webrtc/captureCanvas-webrtc-software-encoder.html:
For platforms suppporting VCP, arbitrary size should be supported.
* webrtc/routines.js:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (236069 => 236070)


--- trunk/LayoutTests/ChangeLog	2018-09-17 17:15:07 UTC (rev 236069)
+++ trunk/LayoutTests/ChangeLog	2018-09-17 17:15:56 UTC (rev 236070)
@@ -1,3 +1,15 @@
+2018-09-17  Youenn Fablet  <[email protected]>
+
+        Enable VCP for iOS and reenable it for MacOS
+        https://bugs.webkit.org/show_bug.cgi?id=189635
+        <rdar://problem/43621029>
+
+        Reviewed by Eric Carlson.
+
+        * platform/mac/webrtc/captureCanvas-webrtc-software-encoder.html:
+        For platforms suppporting VCP, arbitrary size should be supported.
+        * webrtc/routines.js:
+
 2018-09-17  Alexey Proskuryakov  <[email protected]>
 
         Revert https://trac.webkit.org/r235910, because the new test times out.

Modified: trunk/LayoutTests/platform/mac/webrtc/captureCanvas-webrtc-software-encoder.html (236069 => 236070)


--- trunk/LayoutTests/platform/mac/webrtc/captureCanvas-webrtc-software-encoder.html	2018-09-17 17:15:07 UTC (rev 236069)
+++ trunk/LayoutTests/platform/mac/webrtc/captureCanvas-webrtc-software-encoder.html	2018-09-17 17:15:56 UTC (rev 236070)
@@ -53,6 +53,7 @@
 promise_test((test) => {
     canvas0.color = "green";
     printRectangle(canvas0);
+    const shouldMatchCanvas1AfterReplaceTrack = window.internals ? internals.supportsVCPEncoder() : true;
     return new Promise((resolve, reject) => {
         createConnections((firstConnection) => {
             var stream = canvas0.captureStream();
@@ -77,9 +78,9 @@
     }).then(() => {
         return waitFor(200);
     }).then(() => {
-        return testCanvas("test2", canvas1, false);
+        return testCanvas("test2", canvas1, shouldMatchCanvas1AfterReplaceTrack);
     }).then(() => {
-        return testCanvas("test3", canvas0, true);
+        return testCanvas("test3", canvas0, !shouldMatchCanvas1AfterReplaceTrack);
     }).then(() => {
         return sender.replaceTrack(canvas0Track);
     }).then(() => {

Modified: trunk/LayoutTests/webrtc/routines.js (236069 => 236070)


--- trunk/LayoutTests/webrtc/routines.js	2018-09-17 17:15:07 UTC (rev 236069)
+++ trunk/LayoutTests/webrtc/routines.js	2018-09-17 17:15:56 UTC (rev 236070)
@@ -170,10 +170,10 @@
     canvas.width = video.videoWidth;
     canvas.height = video.videoHeight;
     if (!grabbedHeight) {
-        startX = 0;
-        startY = 0;
-        grabbedWidth = canvas.width;
-        grabbedHeight = canvas.height;
+        startX = 10;
+        startY = 10;
+        grabbedWidth = canvas.width - 20;
+        grabbedHeight = canvas.height - 20;
     }
 
     canvas.getContext('2d').drawImage(video, 0, 0, canvas.width, canvas.height);
@@ -193,6 +193,8 @@
     if (isVideoBlack(canvas, video) === expected)
         return Promise.resolve();
 
+    if (counter === undefined)
+        counter = 0;
     if (counter > 50) {
         if (!errorMessage)
             errorMessage = "checkVideoBlack timed out expecting " + expected;

Modified: trunk/Source/ThirdParty/libwebrtc/ChangeLog (236069 => 236070)


--- trunk/Source/ThirdParty/libwebrtc/ChangeLog	2018-09-17 17:15:07 UTC (rev 236069)
+++ trunk/Source/ThirdParty/libwebrtc/ChangeLog	2018-09-17 17:15:56 UTC (rev 236070)
@@ -1,3 +1,19 @@
+2018-09-17  Youenn Fablet  <[email protected]>
+
+        Enable VCP for iOS and reenable it for MacOS
+        https://bugs.webkit.org/show_bug.cgi?id=189635
+        <rdar://problem/43621029>
+
+        Reviewed by Eric Carlson.
+
+        Make sure VCP API is used to set encoding session parameters.
+
+        * Source/webrtc/sdk/WebKit/VideoProcessingSoftLink.h:
+        * Source/webrtc/sdk/objc/Framework/Classes/VideoToolbox/RTCVideoEncoderH264.mm:
+        (-[RTCVideoEncoderH264 resetCompressionSessionWithPixelFormat:]):
+        * Source/webrtc/sdk/objc/Framework/Classes/VideoToolbox/helpers.cc:
+        * Source/webrtc/sdk/objc/Framework/Classes/VideoToolbox/helpers.h:
+
 2018-09-07  Youenn Fablet  <[email protected]>
 
         Add support for unified plan transceivers

Modified: trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/VideoProcessingSoftLink.h (236069 => 236070)


--- trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/VideoProcessingSoftLink.h	2018-09-17 17:15:07 UTC (rev 236069)
+++ trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/VideoProcessingSoftLink.h	2018-09-17 17:15:56 UTC (rev 236070)
@@ -33,17 +33,21 @@
 // Macro taken from WTF/wtf/Platform.h
 #if defined __has_include && __has_include(<CoreFoundation/CFPriv.h>)
 
-#if (defined(TARGET_IPHONE_SIMULATOR)  && TARGET_IPHONE_SIMULATOR)
-#define ENABLE_VCP_ENCODER 0
-#elif (defined(TARGET_OS_IPHONE)  && TARGET_OS_IPHONE)
-#define ENABLE_VCP_ENCODER 0
-#elif (defined(TARGET_OS_MAC)  && TARGET_OS_MAC)
-#define ENABLE_VCP_ENCODER 0 //(__MAC_OS_X_VERSION_MAX_ALLOWED >= 101304)
+#if (defined(TARGET_OS_IPHONE)  && TARGET_OS_IPHONE)
+#define ENABLE_VCP_ENCODER (__IPHONE_OS_VERSION_MAX_ALLOWED >= 120000)
+#elif (defined(TARGET_OS_MAC) && TARGET_OS_MAC)
+#define ENABLE_VCP_ENCODER (__MAC_OS_X_VERSION_MAX_ALLOWED >= 101304)
 #endif
 
 #endif
 
+#if !defined(ENABLE_VCP_ENCODER)
+#define ENABLE_VCP_ENCODER 0
+#endif
+
+#if !defined(ALWAYS_INLINE)
 #define ALWAYS_INLINE inline
+#endif
 
 #ifdef __cplusplus
 #define WTF_EXTERN_C_BEGIN extern "C" {

Modified: trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/Framework/Classes/VideoToolbox/RTCVideoEncoderH264.mm (236069 => 236070)


--- trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/Framework/Classes/VideoToolbox/RTCVideoEncoderH264.mm	2018-09-17 17:15:07 UTC (rev 236069)
+++ trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/Framework/Classes/VideoToolbox/RTCVideoEncoderH264.mm	2018-09-17 17:15:56 UTC (rev 236070)
@@ -603,7 +603,7 @@
     pixelFormat = nullptr;
   }
   CFDictionaryRef encoderSpecs = nullptr;
-#if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS)
+#if (!defined(WEBRTC_IOS) || ENABLE_VCP_ENCODER)
   auto useHardwareEncoder = webrtc::isH264HardwareEncoderAllowed() ? kCFBooleanTrue : kCFBooleanFalse;
   // Currently hw accl is supported above 360p on mac, below 360p
   // the compression session will be created with hw accl disabled.
@@ -611,6 +611,7 @@
   CFTypeRef sessionValues[] = { useHardwareEncoder, useHardwareEncoder, kCFBooleanTrue };
   encoderSpecs = CFDictionaryCreate(kCFAllocatorDefault, sessionKeys, sessionValues, 3, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
 #endif
+
   OSStatus status =
       CompressionSessionCreate(nullptr,  // use default allocator
                                  _width,

Modified: trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/Framework/Classes/VideoToolbox/helpers.cc (236069 => 236070)


--- trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/Framework/Classes/VideoToolbox/helpers.cc	2018-09-17 17:15:07 UTC (rev 236069)
+++ trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/Framework/Classes/VideoToolbox/helpers.cc	2018-09-17 17:15:56 UTC (rev 236070)
@@ -35,12 +35,12 @@
 }
 
 // Convenience function for setting a VT property.
-void SetVTSessionProperty(VTSessionRef session,
+void SetVTSessionProperty(CompressionSessionRef session,
                           CFStringRef key,
                           int32_t value) {
   CFNumberRef cfNum =
       CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &value);
-  OSStatus status = VTSessionSetProperty(session, key, cfNum);
+  OSStatus status = CompressionSessionSetProperty(session, key, cfNum);
   CFRelease(cfNum);
   if (status != noErr) {
     std::string key_string = CFStringToString(key);
@@ -50,13 +50,13 @@
 }
 
 // Convenience function for setting a VT property.
-void SetVTSessionProperty(VTSessionRef session,
+void SetVTSessionProperty(CompressionSessionRef session,
                           CFStringRef key,
                           uint32_t value) {
   int64_t value_64 = value;
   CFNumberRef cfNum =
       CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt64Type, &value_64);
-  OSStatus status = VTSessionSetProperty(session, key, cfNum);
+  OSStatus status = CompressionSessionSetProperty(session, key, cfNum);
   CFRelease(cfNum);
   if (status != noErr) {
     std::string key_string = CFStringToString(key);
@@ -66,9 +66,9 @@
 }
 
 // Convenience function for setting a VT property.
-void SetVTSessionProperty(VTSessionRef session, CFStringRef key, bool value) {
+void SetVTSessionProperty(CompressionSessionRef session, CFStringRef key, bool value) {
   CFBooleanRef cf_bool = (value) ? kCFBooleanTrue : kCFBooleanFalse;
-  OSStatus status = VTSessionSetProperty(session, key, cf_bool);
+  OSStatus status = CompressionSessionSetProperty(session, key, cf_bool);
   if (status != noErr) {
     std::string key_string = CFStringToString(key);
     RTC_LOG(LS_ERROR) << "VTSessionSetProperty failed to set: " << key_string
@@ -77,10 +77,10 @@
 }
 
 // Convenience function for setting a VT property.
-void SetVTSessionProperty(VTSessionRef session,
+void SetVTSessionProperty(CompressionSessionRef session,
                           CFStringRef key,
                           CFStringRef value) {
-  OSStatus status = VTSessionSetProperty(session, key, value);
+  OSStatus status = CompressionSessionSetProperty(session, key, value);
   if (status != noErr) {
     std::string key_string = CFStringToString(key);
     std::string val_string = CFStringToString(value);

Modified: trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/Framework/Classes/VideoToolbox/helpers.h (236069 => 236070)


--- trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/Framework/Classes/VideoToolbox/helpers.h	2018-09-17 17:15:07 UTC (rev 236069)
+++ trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/Framework/Classes/VideoToolbox/helpers.h	2018-09-17 17:15:56 UTC (rev 236070)
@@ -16,6 +16,8 @@
 #include <VideoToolbox/VideoToolbox.h>
 #include <string>
 
+#include "sdk/WebKit/EncoderUtilities.h"
+
 // Convenience function for creating a dictionary.
 inline CFDictionaryRef CreateCFTypeDictionary(CFTypeRef* keys,
                                               CFTypeRef* values,
@@ -29,18 +31,18 @@
 std::string CFStringToString(const CFStringRef cf_string);
 
 // Convenience function for setting a VT property.
-void SetVTSessionProperty(VTSessionRef session, CFStringRef key, int32_t value);
+void SetVTSessionProperty(CompressionSessionRef session, CFStringRef key, int32_t value);
 
 // Convenience function for setting a VT property.
-void SetVTSessionProperty(VTSessionRef session,
+void SetVTSessionProperty(CompressionSessionRef session,
                           CFStringRef key,
                           uint32_t value);
 
 // Convenience function for setting a VT property.
-void SetVTSessionProperty(VTSessionRef session, CFStringRef key, bool value);
+void SetVTSessionProperty(CompressionSessionRef session, CFStringRef key, bool value);
 
 // Convenience function for setting a VT property.
-void SetVTSessionProperty(VTSessionRef session,
+void SetVTSessionProperty(CompressionSessionRef session,
                           CFStringRef key,
                           CFStringRef value);
 

Modified: trunk/Source/ThirdParty/libwebrtc/libwebrtc.xcodeproj/project.pbxproj (236069 => 236070)


--- trunk/Source/ThirdParty/libwebrtc/libwebrtc.xcodeproj/project.pbxproj	2018-09-17 17:15:07 UTC (rev 236069)
+++ trunk/Source/ThirdParty/libwebrtc/libwebrtc.xcodeproj/project.pbxproj	2018-09-17 17:15:56 UTC (rev 236070)
@@ -945,6 +945,7 @@
 		41A392211EFC5CFA00C4516A /* aes.c in Sources */ = {isa = PBXBuildFile; fileRef = 41A391EB1EFC493000C4516A /* aes.c */; };
 		41AF2D13212CD6AC00D033D5 /* RTCVideoCodecH264.mm in Sources */ = {isa = PBXBuildFile; fileRef = 41ECEAB520630108009D5141 /* RTCVideoCodecH264.mm */; };
 		41AF2D14212CD6AF00D033D5 /* RTCVideoDecoderH264.mm in Sources */ = {isa = PBXBuildFile; fileRef = 413A23F81FE1987C00373E99 /* RTCVideoDecoderH264.mm */; };
+		41BCE753214C81A800A748F1 /* VideoProcessingSoftLink.h in Headers */ = {isa = PBXBuildFile; fileRef = 41ECEAFB20646664009D5141 /* VideoProcessingSoftLink.h */; };
 		41D6B45321273159008F9353 /* call_config.cc in Sources */ = {isa = PBXBuildFile; fileRef = 415F1FD72127313F00064CBF /* call_config.cc */; };
 		41D6B45421273159008F9353 /* call_config.h in Headers */ = {isa = PBXBuildFile; fileRef = 415F1FDA2127313F00064CBF /* call_config.h */; };
 		41D6B45521273159008F9353 /* degraded_call.h in Headers */ = {isa = PBXBuildFile; fileRef = 415F1FD22127313E00064CBF /* degraded_call.h */; };
@@ -11696,6 +11697,7 @@
 				5C4B46E71E42AA97002651C8 /* internal.h in Headers */,
 				5C4B47411E42AAEA002651C8 /* internal.h in Headers */,
 				41A391811EFC447C00C4516A /* internal.h in Headers */,
+				41BCE753214C81A800A748F1 /* VideoProcessingSoftLink.h in Headers */,
 				41A3917C1EFC447C00C4516A /* internal.h in Headers */,
 				41A391851EFC447C00C4516A /* internal.h in Headers */,
 				41EA53AE1EFC2C4D002FF04C /* md32_common.h in Headers */,

Modified: trunk/Source/WebCore/ChangeLog (236069 => 236070)


--- trunk/Source/WebCore/ChangeLog	2018-09-17 17:15:07 UTC (rev 236069)
+++ trunk/Source/WebCore/ChangeLog	2018-09-17 17:15:56 UTC (rev 236070)
@@ -1,3 +1,31 @@
+2018-09-17  Youenn Fablet  <[email protected]>
+
+        Enable VCP for iOS and reenable it for MacOS
+        https://bugs.webkit.org/show_bug.cgi?id=189635
+        <rdar://problem/43621029>
+
+        Reviewed by Eric Carlson.
+
+        Covered by exsiting and modified tests.
+        Instead of using libwebrtc YUV frames for black frames, use CVPixelBuffer to make it efficient.
+        Add internal API to know whether VCP is enabled so as to make capture-webrtc test pass on all platforms.
+
+        * platform/mediastream/RealtimeOutgoingVideoSource.cpp:
+        (WebCore::RealtimeOutgoingVideoSource::sendBlackFramesIfNeeded):
+        * platform/mediastream/RealtimeOutgoingVideoSource.h:
+        * platform/mediastream/gstreamer/RealtimeOutgoingVideoSourceLibWebRTC.h:
+        * platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.h:
+        * platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.mm:
+        (WebCore::createBlackPixelBuffer):
+        (WebCore::RealtimeIncomingVideoSourceCocoa::pixelBufferFromVideoFrame):
+        * platform/mediastream/mac/RealtimeOutgoingVideoSourceCocoa.cpp:
+        (WebCore::RealtimeOutgoingVideoSourceCocoa::createBlackFrame):
+        * platform/mediastream/mac/RealtimeOutgoingVideoSourceCocoa.h:
+        * testing/Internals.cpp:
+        (WebCore::Internals::supportsVCPEncoder):
+        * testing/Internals.h:
+        * testing/Internals.idl:
+
 2018-09-17  Chris Dumez  <[email protected]>
 
         PSON: window.open() with 'noopener' should only process-swap cross-site, not cross-origin

Modified: trunk/Source/WebCore/platform/mediastream/RealtimeOutgoingVideoSource.cpp (236069 => 236070)


--- trunk/Source/WebCore/platform/mediastream/RealtimeOutgoingVideoSource.cpp	2018-09-17 17:15:07 UTC (rev 236069)
+++ trunk/Source/WebCore/platform/mediastream/RealtimeOutgoingVideoSource.cpp	2018-09-17 17:15:56 UTC (rev 236070)
@@ -162,14 +162,12 @@
         auto height = m_height;
         if (m_shouldApplyRotation && (m_currentRotation == webrtc::kVideoRotation_0 || m_currentRotation == webrtc::kVideoRotation_90))
             std::swap(width, height);
-        auto frame = m_bufferPool.CreateBuffer(width, height);
-        ASSERT(frame);
-        if (!frame) {
+        m_blackFrame = createBlackFrame(width, height);
+        ASSERT(m_blackFrame);
+        if (!m_blackFrame) {
             RELEASE_LOG(WebRTC, "RealtimeOutgoingVideoSource::sendBlackFramesIfNeeded unable to send black frames");
             return;
         }
-        webrtc::I420Buffer::SetBlack(frame.get());
-        m_blackFrame = WTFMove(frame);
     }
     sendOneBlackFrame();
     m_blackFrameTimer.startRepeating(1_s);

Modified: trunk/Source/WebCore/platform/mediastream/RealtimeOutgoingVideoSource.h (236069 => 236070)


--- trunk/Source/WebCore/platform/mediastream/RealtimeOutgoingVideoSource.h	2018-09-17 17:15:07 UTC (rev 236069)
+++ trunk/Source/WebCore/platform/mediastream/RealtimeOutgoingVideoSource.h	2018-09-17 17:15:56 UTC (rev 236070)
@@ -79,6 +79,8 @@
     bool m_shouldApplyRotation { false };
     webrtc::VideoRotation m_currentRotation { webrtc::kVideoRotation_0 };
 
+    virtual rtc::scoped_refptr<webrtc::VideoFrameBuffer> createBlackFrame(size_t width, size_t height) = 0;
+
 private:
     void sendBlackFramesIfNeeded();
     void sendOneBlackFrame();

Modified: trunk/Source/WebCore/platform/mediastream/gstreamer/RealtimeOutgoingVideoSourceLibWebRTC.h (236069 => 236070)


--- trunk/Source/WebCore/platform/mediastream/gstreamer/RealtimeOutgoingVideoSourceLibWebRTC.h	2018-09-17 17:15:07 UTC (rev 236069)
+++ trunk/Source/WebCore/platform/mediastream/gstreamer/RealtimeOutgoingVideoSourceLibWebRTC.h	2018-09-17 17:15:56 UTC (rev 236070)
@@ -39,6 +39,8 @@
 private:
     explicit RealtimeOutgoingVideoSourceLibWebRTC(Ref<MediaStreamTrackPrivate>&&);
 
+    rtc::scoped_refptr<webrtc::VideoFrameBuffer> createBlackFrame(size_t, size_t) final { return nullptr; }
+
     // MediaStreamTrackPrivate::Observer API
     void sampleBufferUpdated(MediaStreamTrackPrivate&, MediaSample&) final;
 };

Modified: trunk/Source/WebCore/platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.h (236069 => 236070)


--- trunk/Source/WebCore/platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.h	2018-09-17 17:15:07 UTC (rev 236069)
+++ trunk/Source/WebCore/platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.h	2018-09-17 17:15:56 UTC (rev 236070)
@@ -57,6 +57,8 @@
 #endif
 };
 
+RetainPtr<CVPixelBufferRef> createBlackPixelBuffer(size_t width, size_t height);
+
 } // namespace WebCore
 
 #endif // USE(LIBWEBRTC)

Modified: trunk/Source/WebCore/platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.mm (236069 => 236070)


--- trunk/Source/WebCore/platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.mm	2018-09-17 17:15:07 UTC (rev 236069)
+++ trunk/Source/WebCore/platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.mm	2018-09-17 17:15:56 UTC (rev 236070)
@@ -64,7 +64,7 @@
 {
 }
 
-static inline CVPixelBufferRef createBlackFrame(int width, int height)
+RetainPtr<CVPixelBufferRef> createBlackPixelBuffer(size_t width, size_t height)
 {
     CVPixelBufferRef pixelBuffer = nullptr;
     auto status = CVPixelBufferCreate(kCFAllocatorDefault, width, height, kCVPixelFormatType_420YpCbCr8Planar, nullptr, &pixelBuffer);
@@ -79,7 +79,7 @@
 
     status = CVPixelBufferUnlockBaseAddress(pixelBuffer, 0);
     ASSERT(!status);
-    return pixelBuffer;
+    return adoptCF(pixelBuffer);
 }
 
 CVPixelBufferRef RealtimeIncomingVideoSourceCocoa::pixelBufferFromVideoFrame(const webrtc::VideoFrame& frame)
@@ -88,7 +88,7 @@
         if (!m_blackFrame || m_blackFrameWidth != frame.width() || m_blackFrameHeight != frame.height()) {
             m_blackFrameWidth = frame.width();
             m_blackFrameHeight = frame.height();
-            m_blackFrame = adoptCF(createBlackFrame(m_blackFrameWidth, m_blackFrameHeight));
+            m_blackFrame = createBlackPixelBuffer(m_blackFrameWidth, m_blackFrameHeight);
         }
         return m_blackFrame.get();
     }

Modified: trunk/Source/WebCore/platform/mediastream/mac/RealtimeOutgoingVideoSourceCocoa.cpp (236069 => 236070)


--- trunk/Source/WebCore/platform/mediastream/mac/RealtimeOutgoingVideoSourceCocoa.cpp	2018-09-17 17:15:07 UTC (rev 236069)
+++ trunk/Source/WebCore/platform/mediastream/mac/RealtimeOutgoingVideoSourceCocoa.cpp	2018-09-17 17:15:56 UTC (rev 236070)
@@ -29,6 +29,7 @@
 #if USE(LIBWEBRTC)
 
 #include "Logging.h"
+#include "RealtimeIncomingVideoSourceCocoa.h"
 
 ALLOW_UNUSED_PARAMETERS_BEGIN
 
@@ -92,33 +93,6 @@
 {
 }
 
-static inline int ConvertToI420(webrtc::VideoType src_video_type,
-                  const uint8_t* src_frame,
-                  int crop_x,
-                  int crop_y,
-                  int src_width,
-                  int src_height,
-                  size_t sample_size,
-                  libyuv::RotationMode rotation,
-                  webrtc::I420Buffer* dst_buffer) {
-  int dst_width = dst_buffer->width();
-  int dst_height = dst_buffer->height();
-  // LibYuv expects pre-rotation values for dst.
-  // Stride values should correspond to the destination values.
-  if (rotation == libyuv::kRotate90 || rotation == libyuv::kRotate270) {
-    std::swap(dst_width, dst_height);
-  }
-  return libyuv::ConvertToI420(src_video_type,
-      src_frame, sample_size,
-      dst_buffer->MutableDataY(), dst_buffer->StrideY(),
-      dst_buffer->MutableDataU(), dst_buffer->StrideU(),
-      dst_buffer->MutableDataV(), dst_buffer->StrideV(),
-      crop_x, crop_y,
-      src_width, src_height,
-      dst_width, dst_height,
-      rotation);
-}
-
 void RealtimeOutgoingVideoSourceCocoa::sampleBufferUpdated(MediaStreamTrackPrivate&, MediaSample& sample)
 {
     if (!m_sinks.size())
@@ -161,7 +135,12 @@
     sendFrame(webrtc::pixelBufferToFrame(convertedBuffer.get()));
 }
 
+rtc::scoped_refptr<webrtc::VideoFrameBuffer> RealtimeOutgoingVideoSourceCocoa::createBlackFrame(size_t  width, size_t  height)
+{
+    return webrtc::pixelBufferToFrame(createBlackPixelBuffer(width, height).get());
+}
 
+
 } // namespace WebCore
 
 #endif // USE(LIBWEBRTC)

Modified: trunk/Source/WebCore/platform/mediastream/mac/RealtimeOutgoingVideoSourceCocoa.h (236069 => 236070)


--- trunk/Source/WebCore/platform/mediastream/mac/RealtimeOutgoingVideoSourceCocoa.h	2018-09-17 17:15:07 UTC (rev 236069)
+++ trunk/Source/WebCore/platform/mediastream/mac/RealtimeOutgoingVideoSourceCocoa.h	2018-09-17 17:15:56 UTC (rev 236070)
@@ -43,6 +43,8 @@
 private:
     explicit RealtimeOutgoingVideoSourceCocoa(Ref<MediaStreamTrackPrivate>&&);
 
+    rtc::scoped_refptr<webrtc::VideoFrameBuffer> createBlackFrame(size_t width, size_t height) final;
+
     // MediaStreamTrackPrivate::Observer API
     void sampleBufferUpdated(MediaStreamTrackPrivate&, MediaSample&) final;
 

Modified: trunk/Source/WebCore/testing/Internals.cpp (236069 => 236070)


--- trunk/Source/WebCore/testing/Internals.cpp	2018-09-17 17:15:07 UTC (rev 236069)
+++ trunk/Source/WebCore/testing/Internals.cpp	2018-09-17 17:15:56 UTC (rev 236070)
@@ -271,6 +271,10 @@
 #include "MockAuthenticatorCoordinator.h"
 #endif
 
+#if PLATFORM(MAC) && USE(LIBWEBRTC)
+#include <webrtc/sdk/WebKit/VideoProcessingSoftLink.h>
+#endif
+
 using JSC::CallData;
 using JSC::CallType;
 using JSC::CodeBlock;
@@ -4724,4 +4728,13 @@
 #endif
 }
 
+bool Internals::supportsVCPEncoder()
+{
+#if defined(ENABLE_VCP_ENCODER)
+    return ENABLE_VCP_ENCODER;
+#else
+    return false;
+#endif
+}
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/testing/Internals.h (236069 => 236070)


--- trunk/Source/WebCore/testing/Internals.h	2018-09-17 17:15:07 UTC (rev 236069)
+++ trunk/Source/WebCore/testing/Internals.h	2018-09-17 17:15:56 UTC (rev 236070)
@@ -735,6 +735,8 @@
     void notifyResourceLoadObserver();
 
     unsigned primaryScreenDisplayID();
+
+    bool supportsVCPEncoder();
         
 private:
     explicit Internals(Document&);

Modified: trunk/Source/WebCore/testing/Internals.idl (236069 => 236070)


--- trunk/Source/WebCore/testing/Internals.idl	2018-09-17 17:15:07 UTC (rev 236069)
+++ trunk/Source/WebCore/testing/Internals.idl	2018-09-17 17:15:56 UTC (rev 236070)
@@ -670,4 +670,6 @@
     void notifyResourceLoadObserver();
 
     unsigned long primaryScreenDisplayID();
+
+    boolean supportsVCPEncoder();
 };
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to