Diff
Modified: trunk/Source/ThirdParty/libwebrtc/ChangeLog (229907 => 229908)
--- trunk/Source/ThirdParty/libwebrtc/ChangeLog 2018-03-23 18:06:34 UTC (rev 229907)
+++ trunk/Source/ThirdParty/libwebrtc/ChangeLog 2018-03-23 18:20:47 UTC (rev 229908)
@@ -1,3 +1,49 @@
+2018-03-23 Youenn Fablet <you...@apple.com>
+
+ Use libwebrtc ObjectiveC H264 encoder and decoder
+ https://bugs.webkit.org/show_bug.cgi?id=183912
+
+ Reviewed by Eric Carlson.
+
+ Add utilities inside libwebrtc to be used by WebKit:
+ - Create ObjectiveC encoder/decoder factories
+ - Notify of application status to invalidate encoders/decoders when in background
+ Implement RTCUIApplicationStatusObserver as a simple boolean that is set by WebCore.
+ This allows limiting the changes made to libwebrtc codec implementations.
+
+ Minor modifications done to libwebrtc to fix compilation.
+ Add Block_copy/Block_release to codec callbacks.
+
+ * Configurations/libwebrtc.iOS.exp:
+ * Configurations/libwebrtc.iOSsim.exp:
+ * Configurations/libwebrtc.mac.exp:
+ * Source/webrtc/sdk/WebKit/WebKitUtilities.h: Added.
+ * Source/webrtc/sdk/WebKit/WebKitUtilities.mm: Added.
+ (+[RTCUIApplicationStatusObserver sharedInstance]):
+ (+[RTCUIApplicationStatusObserver prepareForUse]):
+ (-[RTCUIApplicationStatusObserver setActive]):
+ (-[RTCUIApplicationStatusObserver setInactive]):
+ (-[RTCUIApplicationStatusObserver isApplicationActive]):
+ (webrtc::setApplicationStatus):
+ (webrtc::createVideoToolboxEncoderFactory):
+ (webrtc::createVideoToolboxDecoderFactory):
+ (webrtc::setH264HardwareEncoderAllowed):
+ (webrtc::isH264HardwareEncoderAllowed):
+ (webrtc::pixelBufferFromFrame):
+ * Source/webrtc/sdk/objc/Framework/Classes/Video/RTCCVPixelBuffer.mm:
+ (-[RTCCVPixelBuffer dealloc]):
+ * Source/webrtc/sdk/objc/Framework/Classes/VideoToolbox/RTCVideoDecoderH264.mm:
+ (-[RTCVideoDecoderH264 dealloc]):
+ (-[RTCVideoDecoderH264 setCallback:]):
+ (-[RTCVideoDecoderH264 releaseDecoder]):
+ * Source/webrtc/sdk/objc/Framework/Classes/VideoToolbox/RTCVideoEncoderH264.mm:
+ (-[RTCVideoEncoderH264 dealloc]):
+ (-[RTCVideoEncoderH264 setCallback:]):
+ (-[RTCVideoEncoderH264 releaseEncoder]):
+ (-[RTCVideoEncoderH264 resetCompressionSessionWithPixelFormat:]):
+ * WebKit/0001-Adapting-libwebrtc-H264-codec.patch: Added.
+ * libwebrtc.xcodeproj/project.pbxproj:
+
2018-03-22 Commit Queue <commit-qu...@webkit.org>
Unreviewed, rolling out r229876.
Modified: trunk/Source/ThirdParty/libwebrtc/Configurations/libwebrtc.iOS.exp (229907 => 229908)
--- trunk/Source/ThirdParty/libwebrtc/Configurations/libwebrtc.iOS.exp 2018-03-23 18:06:34 UTC (rev 229907)
+++ trunk/Source/ThirdParty/libwebrtc/Configurations/libwebrtc.iOS.exp 2018-03-23 18:20:47 UTC (rev 229908)
@@ -125,3 +125,8 @@
__ZNK6webrtc27SessionDescriptionInterface7GetTypeEv
__ZTVN6webrtc21IceCandidateInterfaceE
__ZTVN6webrtc27SessionDescriptionInterfaceE
+__ZN6webrtc20setApplicationStatusEb
+__ZN6webrtc32createVideoToolboxDecoderFactoryEv
+__ZN6webrtc32createVideoToolboxEncoderFactoryEv
+__ZN6webrtc29setH264HardwareEncoderAllowedEb
+__ZN6webrtc20pixelBufferFromFrameERKNS_10VideoFrameE
Modified: trunk/Source/ThirdParty/libwebrtc/Configurations/libwebrtc.iOSsim.exp (229907 => 229908)
--- trunk/Source/ThirdParty/libwebrtc/Configurations/libwebrtc.iOSsim.exp 2018-03-23 18:06:34 UTC (rev 229907)
+++ trunk/Source/ThirdParty/libwebrtc/Configurations/libwebrtc.iOSsim.exp 2018-03-23 18:20:47 UTC (rev 229908)
@@ -125,3 +125,8 @@
__ZNK6webrtc27SessionDescriptionInterface7GetTypeEv
__ZTVN6webrtc21IceCandidateInterfaceE
__ZTVN6webrtc27SessionDescriptionInterfaceE
+__ZN6webrtc20setApplicationStatusEb
+__ZN6webrtc32createVideoToolboxDecoderFactoryEv
+__ZN6webrtc32createVideoToolboxEncoderFactoryEv
+__ZN6webrtc29setH264HardwareEncoderAllowedEb
+__ZN6webrtc20pixelBufferFromFrameERKNS_10VideoFrameE
Modified: trunk/Source/ThirdParty/libwebrtc/Configurations/libwebrtc.mac.exp (229907 => 229908)
--- trunk/Source/ThirdParty/libwebrtc/Configurations/libwebrtc.mac.exp 2018-03-23 18:06:34 UTC (rev 229907)
+++ trunk/Source/ThirdParty/libwebrtc/Configurations/libwebrtc.mac.exp 2018-03-23 18:20:47 UTC (rev 229908)
@@ -126,3 +126,8 @@
__ZNK6webrtc27SessionDescriptionInterface7GetTypeEv
__ZTVN6webrtc21IceCandidateInterfaceE
__ZTVN6webrtc27SessionDescriptionInterfaceE
+__ZN6webrtc20setApplicationStatusEb
+__ZN6webrtc32createVideoToolboxDecoderFactoryEv
+__ZN6webrtc32createVideoToolboxEncoderFactoryEv
+__ZN6webrtc29setH264HardwareEncoderAllowedEb
+__ZN6webrtc20pixelBufferFromFrameERKNS_10VideoFrameE
Added: trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitUtilities.h (0 => 229908)
--- trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitUtilities.h (rev 0)
+++ trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitUtilities.h 2018-03-23 18:20:47 UTC (rev 229908)
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2018 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 "api/video_codecs/video_encoder_factory.h"
+
+typedef struct __CVBuffer* CVPixelBufferRef;
+
+namespace webrtc {
+
+class VideoDecoderFactory;
+class VideoEncoderFactory;
+class VideoFrame;
+
+std::unique_ptr<webrtc::VideoEncoderFactory> createVideoToolboxEncoderFactory();
+std::unique_ptr<webrtc::VideoDecoderFactory> createVideoToolboxDecoderFactory();
+
+void setApplicationStatus(bool isActive);
+
+void setH264HardwareEncoderAllowed(bool);
+bool isH264HardwareEncoderAllowed();
+
+CVPixelBufferRef pixelBufferFromFrame(const VideoFrame&);
+
+}
Added: trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitUtilities.mm (0 => 229908)
--- trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitUtilities.mm (rev 0)
+++ trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitUtilities.mm 2018-03-23 18:20:47 UTC (rev 229908)
@@ -0,0 +1,123 @@
+/*
+ * Copyright (C) 2018 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 "WebKitUtilities.h"
+#include "Common/RTCUIApplicationStatusObserver.h"
+#include "VideoToolbox/objc_video_decoder_factory.h"
+#include "VideoToolbox/objc_video_encoder_factory.h"
+#import "WebRTC/RTCVideoCodecH264.h"
+#include "api/video/video_frame.h"
+#include <webrtc/sdk/objc/Framework/Classes/Video/objc_frame_buffer.h>
+#include <webrtc/sdk/objc/Framework/Headers/WebRTC/RTCVideoFrameBuffer.h>
+
+#if !defined(WEBRTC_IOS)
+@interface RTCUIApplicationStatusObserver : NSObject
+
++ (instancetype)sharedInstance;
++ (void)prepareForUse;
+
+- (BOOL)isApplicationActive;
+
+@end
+#endif
+
+@implementation RTCUIApplicationStatusObserver {
+ BOOL _isActive;
+}
+
++ (instancetype)sharedInstance {
+ static id sharedInstance;
+ static dispatch_once_t onceToken;
+ dispatch_once(&onceToken, ^{
+ sharedInstance = [[self alloc] init];
+ });
+
+ return sharedInstance;
+}
+
++ (void)prepareForUse {
+ __unused RTCUIApplicationStatusObserver *observer = [self sharedInstance];
+}
+
+- (id)init {
+ _isActive = YES;
+ return self;
+}
+
+- (void)setActive {
+ _isActive = YES;
+}
+
+- (void)setInactive {
+ _isActive = NO;
+}
+
+- (BOOL)isApplicationActive {
+ return _isActive;
+}
+
+@end
+
+namespace webrtc {
+
+void setApplicationStatus(bool isActive)
+{
+ if (isActive)
+ [[RTCUIApplicationStatusObserver sharedInstance] setActive];
+ else
+ [[RTCUIApplicationStatusObserver sharedInstance] setInactive];
+}
+
+std::unique_ptr<webrtc::VideoEncoderFactory> createVideoToolboxEncoderFactory()
+{
+ return std::make_unique<webrtc::ObjCVideoEncoderFactory>([[RTCVideoEncoderFactoryH264 alloc] init]);
+}
+
+std::unique_ptr<webrtc::VideoDecoderFactory> createVideoToolboxDecoderFactory()
+{
+ return std::make_unique<webrtc::ObjCVideoDecoderFactory>([[RTCVideoDecoderFactoryH264 alloc] init]);
+}
+
+static bool h264HardwareEncoderAllowed = true;
+void setH264HardwareEncoderAllowed(bool allowed)
+{
+ h264HardwareEncoderAllowed = allowed;
+}
+
+bool isH264HardwareEncoderAllowed()
+{
+ return h264HardwareEncoderAllowed;
+}
+
+CVPixelBufferRef pixelBufferFromFrame(const VideoFrame& frame)
+{
+ auto buffer = frame.video_frame_buffer();
+ auto frameBuffer = static_cast<webrtc::ObjCFrameBuffer&>(*buffer).wrapped_frame_buffer();
+ if ([frameBuffer isKindOfClass: [RTCCVPixelBuffer class]])
+ return [(RTCCVPixelBuffer *)frameBuffer pixelBuffer];
+ return nullptr;
+}
+
+}
Modified: trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/Framework/Classes/Video/RTCCVPixelBuffer.mm (229907 => 229908)
--- trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/Framework/Classes/Video/RTCCVPixelBuffer.mm 2018-03-23 18:06:34 UTC (rev 229907)
+++ trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/Framework/Classes/Video/RTCCVPixelBuffer.mm 2018-03-23 18:20:47 UTC (rev 229908)
@@ -73,6 +73,7 @@
- (void)dealloc {
CVBufferRelease(_pixelBuffer);
+ [super dealloc];
}
- (int)width {
Modified: trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/Framework/Classes/VideoToolbox/RTCVideoDecoderH264.mm (229907 => 229908)
--- trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/Framework/Classes/VideoToolbox/RTCVideoDecoderH264.mm 2018-03-23 18:06:34 UTC (rev 229907)
+++ trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/Framework/Classes/VideoToolbox/RTCVideoDecoderH264.mm 2018-03-23 18:20:47 UTC (rev 229908)
@@ -90,6 +90,10 @@
- (void)dealloc {
[self destroyDecompressionSession];
[self setVideoFormat:nullptr];
+ if (_callback) {
+ Block_release(_callback);
+ }
+ [super dealloc];
}
- (NSInteger)startDecodeWithSettings:(RTCVideoEncoderSettings *)settings
@@ -178,7 +182,7 @@
}
- (void)setCallback:(RTCVideoDecoderCallback)callback {
- _callback = callback;
+ _callback = Block_copy(callback);
}
- (void)setError:(OSStatus)error {
@@ -190,6 +194,7 @@
// is safe to null out the callback.
[self destroyDecompressionSession];
[self setVideoFormat:nullptr];
+ Block_release(_callback);
_callback = nullptr;
return WEBRTC_VIDEO_CODEC_OK;
}
@@ -260,9 +265,7 @@
- (void)destroyDecompressionSession {
if (_decompressionSession) {
#if defined(WEBRTC_IOS)
- if ([UIDevice isIOS11OrLater]) {
- VTDecompressionSessionWaitForAsynchronousFrames(_decompressionSession);
- }
+ VTDecompressionSessionWaitForAsynchronousFrames(_decompressionSession);
#endif
VTDecompressionSessionInvalidate(_decompressionSession);
CFRelease(_decompressionSession);
Modified: trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/Framework/Classes/VideoToolbox/RTCVideoEncoderH264.mm (229907 => 229908)
--- trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/Framework/Classes/VideoToolbox/RTCVideoEncoderH264.mm 2018-03-23 18:06:34 UTC (rev 229907)
+++ trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/Framework/Classes/VideoToolbox/RTCVideoEncoderH264.mm 2018-03-23 18:20:47 UTC (rev 229908)
@@ -34,6 +34,7 @@
#include "sdk/objc/Framework/Classes/VideoToolbox/nalu_rewriter.h"
#include "system_wrappers/include/clock.h"
#include "third_party/libyuv/include/libyuv/convert_from.h"
+#include "sdk/WebKit/WebKitUtilities.h"
@interface RTCVideoEncoderH264 ()
@@ -318,6 +319,10 @@
- (void)dealloc {
[self destroyCompressionSession];
+ if (_callback) {
+ Block_release(_callback);
+ }
+ [super dealloc];
}
- (NSInteger)startEncodeWithSettings:(RTCVideoEncoderSettings *)settings
@@ -463,7 +468,7 @@
}
- (void)setCallback:(RTCVideoEncoderCallback)callback {
- _callback = callback;
+ _callback = Block_copy(callback);
}
- (int)setBitrate:(uint32_t)bitrateKbit framerate:(uint32_t)framerate {
@@ -480,6 +485,7 @@
// callback anymore. Do not remove callback until the session is invalidated
// since async encoder callbacks can occur until invalidation.
[self destroyCompressionSession];
+ Block_release(_callback);
_callback = nullptr;
return WEBRTC_VIDEO_CODEC_OK;
}
@@ -573,7 +579,7 @@
nullptr, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
CFDictionarySetValue(encoder_specs,
kVTVideoEncoderSpecification_EnableHardwareAcceleratedVideoEncoder,
- kCFBooleanTrue);
+ webrtc::isH264HardwareEncoderAllowed() ? kCFBooleanTrue : kCFBooleanFalse);
#endif
OSStatus status =
VTCompressionSessionCreate(nullptr, // use default allocator
Added: trunk/Source/ThirdParty/libwebrtc/WebKit/0001-Adapting-libwebrtc-H264-codec.patch (0 => 229908)
--- trunk/Source/ThirdParty/libwebrtc/WebKit/0001-Adapting-libwebrtc-H264-codec.patch (rev 0)
+++ trunk/Source/ThirdParty/libwebrtc/WebKit/0001-Adapting-libwebrtc-H264-codec.patch 2018-03-23 18:20:47 UTC (rev 229908)
@@ -0,0 +1,118 @@
+From c5debd83bb3933413d0a3dd2417f5fd9d64a3205 Mon Sep 17 00:00:00 2001
+From: Youenn Fablet <you...@apple.com>
+Date: Thu, 22 Mar 2018 16:38:14 -0700
+Subject: [PATCH] Adapting-libwebrtc-H264-codec
+
+---
+ .../sdk/objc/Framework/Classes/Video/RTCCVPixelBuffer.mm | 1 +
+ .../Framework/Classes/VideoToolbox/RTCVideoDecoderH264.mm | 11 +++++++----
+ .../Framework/Classes/VideoToolbox/RTCVideoEncoderH264.mm | 10 ++++++++--
+ 3 files changed, 16 insertions(+), 6 deletions(-)
+
+diff --git a/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/Framework/Classes/Video/RTCCVPixelBuffer.mm b/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/Framework/Classes/Video/RTCCVPixelBuffer.mm
+index 203896758e8..537a65e17d3 100644
+--- a/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/Framework/Classes/Video/RTCCVPixelBuffer.mm
++++ b/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/Framework/Classes/Video/RTCCVPixelBuffer.mm
+@@ -73,6 +73,7 @@ - (instancetype)initWithPixelBuffer:(CVPixelBufferRef)pixelBuffer
+
+ - (void)dealloc {
+ CVBufferRelease(_pixelBuffer);
++ [super dealloc];
+ }
+
+ - (int)width {
+diff --git a/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/Framework/Classes/VideoToolbox/RTCVideoDecoderH264.mm b/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/Framework/Classes/VideoToolbox/RTCVideoDecoderH264.mm
+index 2f4b6bd72c6..34d08db0e3b 100644
+--- a/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/Framework/Classes/VideoToolbox/RTCVideoDecoderH264.mm
++++ b/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/Framework/Classes/VideoToolbox/RTCVideoDecoderH264.mm
+@@ -90,6 +90,10 @@ - (instancetype)init {
+ - (void)dealloc {
+ [self destroyDecompressionSession];
+ [self setVideoFormat:nullptr];
++ if (_callback) {
++ Block_release(_callback);
++ }
++ [super dealloc];
+ }
+
+ - (NSInteger)startDecodeWithSettings:(RTCVideoEncoderSettings *)settings
+@@ -178,7 +182,7 @@ - (NSInteger)decode:(RTCEncodedImage *)inputImage
+ }
+
+ - (void)setCallback:(RTCVideoDecoderCallback)callback {
+- _callback = callback;
++ _callback = Block_copy(callback);
+ }
+
+ - (void)setError:(OSStatus)error {
+@@ -190,6 +194,7 @@ - (NSInteger)releaseDecoder {
+ // is safe to null out the callback.
+ [self destroyDecompressionSession];
+ [self setVideoFormat:nullptr];
++ Block_release(_callback);
+ _callback = nullptr;
+ return WEBRTC_VIDEO_CODEC_OK;
+ }
+@@ -260,9 +265,7 @@ - (void)configureDecompressionSession {
+ - (void)destroyDecompressionSession {
+ if (_decompressionSession) {
+ #if defined(WEBRTC_IOS)
+- if ([UIDevice isIOS11OrLater]) {
+- VTDecompressionSessionWaitForAsynchronousFrames(_decompressionSession);
+- }
++ VTDecompressionSessionWaitForAsynchronousFrames(_decompressionSession);
+ #endif
+ VTDecompressionSessionInvalidate(_decompressionSession);
+ CFRelease(_decompressionSession);
+diff --git a/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/Framework/Classes/VideoToolbox/RTCVideoEncoderH264.mm b/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/Framework/Classes/VideoToolbox/RTCVideoEncoderH264.mm
+index a818c27d1e6..809948011a6 100644
+--- a/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/Framework/Classes/VideoToolbox/RTCVideoEncoderH264.mm
++++ b/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/Framework/Classes/VideoToolbox/RTCVideoEncoderH264.mm
+@@ -34,6 +34,7 @@
+ #include "sdk/objc/Framework/Classes/VideoToolbox/nalu_rewriter.h"
+ #include "system_wrappers/include/clock.h"
+ #include "third_party/libyuv/include/libyuv/convert_from.h"
++#include "sdk/WebKit/WebKitUtilities.h"
+
+ @interface RTCVideoEncoderH264 ()
+
+@@ -318,6 +319,10 @@ - (instancetype)initWithCodecInfo:(RTCVideoCodecInfo *)codecInfo {
+
+ - (void)dealloc {
+ [self destroyCompressionSession];
++ if (_callback) {
++ Block_release(_callback);
++ }
++ [super dealloc];
+ }
+
+ - (NSInteger)startEncodeWithSettings:(RTCVideoEncoderSettings *)settings
+@@ -463,7 +468,7 @@ - (NSInteger)encode:(RTCVideoFrame *)frame
+ }
+
+ - (void)setCallback:(RTCVideoEncoderCallback)callback {
+- _callback = callback;
++ _callback = Block_copy(callback);
+ }
+
+ - (int)setBitrate:(uint32_t)bitrateKbit framerate:(uint32_t)framerate {
+@@ -480,6 +485,7 @@ - (NSInteger)releaseEncoder {
+ // callback anymore. Do not remove callback until the session is invalidated
+ // since async encoder callbacks can occur until invalidation.
+ [self destroyCompressionSession];
++ Block_release(_callback);
+ _callback = nullptr;
+ return WEBRTC_VIDEO_CODEC_OK;
+ }
+@@ -573,7 +579,7 @@ - (int)resetCompressionSessionWithPixelFormat:(OSType)framePixelFormat {
+ nullptr, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+ CFDictionarySetValue(encoder_specs,
+ kVTVideoEncoderSpecification_EnableHardwareAcceleratedVideoEncoder,
+- kCFBooleanTrue);
++ webrtc::isH264HardwareEncoderAllowed() ? kCFBooleanTrue : kCFBooleanFalse);
+ #endif
+ OSStatus status =
+ VTCompressionSessionCreate(nullptr, // use default allocator
+--
+2.15.1 (Apple Git-101)
+
Modified: trunk/Source/ThirdParty/libwebrtc/libwebrtc.xcodeproj/project.pbxproj (229907 => 229908)
--- trunk/Source/ThirdParty/libwebrtc/libwebrtc.xcodeproj/project.pbxproj 2018-03-23 18:06:34 UTC (rev 229907)
+++ trunk/Source/ThirdParty/libwebrtc/libwebrtc.xcodeproj/project.pbxproj 2018-03-23 18:20:47 UTC (rev 229908)
@@ -305,7 +305,6 @@
413A243C1FE1991A00373E99 /* RTCVideoCodecH264.h in Headers */ = {isa = PBXBuildFile; fileRef = 413A24041FE1990300373E99 /* RTCVideoCodecH264.h */; };
413A243D1FE1991A00373E99 /* RTCVideoCapturer.h in Headers */ = {isa = PBXBuildFile; fileRef = 413A24051FE1990300373E99 /* RTCVideoCapturer.h */; };
413A243E1FE1991A00373E99 /* RTCPeerConnection.h in Headers */ = {isa = PBXBuildFile; fileRef = 413A24061FE1990400373E99 /* RTCPeerConnection.h */; };
- 413A243F1FE1991A00373E99 /* WebRTC.h in Headers */ = {isa = PBXBuildFile; fileRef = 413A24071FE1990400373E99 /* WebRTC.h */; };
413A24401FE1991A00373E99 /* RTCFieldTrials.h in Headers */ = {isa = PBXBuildFile; fileRef = 413A24081FE1990400373E99 /* RTCFieldTrials.h */; };
413A24411FE1991A00373E99 /* RTCVideoFrameBuffer.h in Headers */ = {isa = PBXBuildFile; fileRef = 413A24091FE1990400373E99 /* RTCVideoFrameBuffer.h */; };
413A24421FE1991A00373E99 /* RTCLegacyStatsReport.h in Headers */ = {isa = PBXBuildFile; fileRef = 413A240A1FE1990400373E99 /* RTCLegacyStatsReport.h */; };
@@ -809,6 +808,35 @@
41EA54111EFC2D1B002FF04C /* sqrt.c in Sources */ = {isa = PBXBuildFile; fileRef = 41EA53FB1EFC2D1B002FF04C /* sqrt.c */; };
41EA54191EFC2D53002FF04C /* md4.c in Sources */ = {isa = PBXBuildFile; fileRef = 41EA54131EFC2D4F002FF04C /* md4.c */; };
41EA541A1EFC2D53002FF04C /* md5.c in Sources */ = {isa = PBXBuildFile; fileRef = 41EA54181EFC2D53002FF04C /* md5.c */; };
+ 41ECEAB620630108009D5141 /* RTCVideoCodec+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 41ECEAB320630107009D5141 /* RTCVideoCodec+Private.h */; };
+ 41ECEAB720630108009D5141 /* RTCVideoCodec.mm in Sources */ = {isa = PBXBuildFile; fileRef = 41ECEAB420630107009D5141 /* RTCVideoCodec.mm */; };
+ 41ECEAB820630108009D5141 /* RTCVideoCodecH264.mm in Sources */ = {isa = PBXBuildFile; fileRef = 41ECEAB520630108009D5141 /* RTCVideoCodecH264.mm */; };
+ 41ECEABC206403C2009D5141 /* WebKitUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 41ECEABB206403C1009D5141 /* WebKitUtilities.h */; };
+ 41ECEABE20640498009D5141 /* WebKitUtilities.mm in Sources */ = {isa = PBXBuildFile; fileRef = 41ECEABD20640498009D5141 /* WebKitUtilities.mm */; };
+ 41ECEAC120640F28009D5141 /* NSString+StdString.h in Headers */ = {isa = PBXBuildFile; fileRef = 41ECEABF20640F27009D5141 /* NSString+StdString.h */; };
+ 41ECEAC220640F28009D5141 /* NSString+StdString.mm in Sources */ = {isa = PBXBuildFile; fileRef = 41ECEAC020640F28009D5141 /* NSString+StdString.mm */; };
+ 41ECEAC3206411E2009D5141 /* RTCVideoDecoderH264.mm in Sources */ = {isa = PBXBuildFile; fileRef = 413A23F81FE1987C00373E99 /* RTCVideoDecoderH264.mm */; };
+ 41ECEAC4206411E5009D5141 /* RTCVideoEncoderH264.mm in Sources */ = {isa = PBXBuildFile; fileRef = 413A23F41FE1987B00373E99 /* RTCVideoEncoderH264.mm */; };
+ 41ECEAC620641303009D5141 /* RTCCVPixelBuffer.mm in Sources */ = {isa = PBXBuildFile; fileRef = 41ECEAC520641302009D5141 /* RTCCVPixelBuffer.mm */; };
+ 41ECEAC820641328009D5141 /* RTCEncodedImage.mm in Sources */ = {isa = PBXBuildFile; fileRef = 41ECEAC720641328009D5141 /* RTCEncodedImage.mm */; };
+ 41ECEACB2064134F009D5141 /* RTCVideoFrame.mm in Sources */ = {isa = PBXBuildFile; fileRef = 41ECEAC92064134E009D5141 /* RTCVideoFrame.mm */; };
+ 41ECEACC2064134F009D5141 /* RTCVideoFrame+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 41ECEACA2064134E009D5141 /* RTCVideoFrame+Private.h */; };
+ 41ECEACF20641370009D5141 /* RTCI420Buffer.mm in Sources */ = {isa = PBXBuildFile; fileRef = 41ECEACD2064136F009D5141 /* RTCI420Buffer.mm */; };
+ 41ECEAD020641370009D5141 /* RTCI420Buffer+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 41ECEACE2064136F009D5141 /* RTCI420Buffer+Private.h */; };
+ 41ECEAD320641458009D5141 /* objc_frame_buffer.mm in Sources */ = {isa = PBXBuildFile; fileRef = 41ECEAD120641457009D5141 /* objc_frame_buffer.mm */; };
+ 41ECEAD420641458009D5141 /* objc_frame_buffer.h in Headers */ = {isa = PBXBuildFile; fileRef = 41ECEAD220641458009D5141 /* objc_frame_buffer.h */; };
+ 41ECEAD72064147C009D5141 /* helpers.h in Headers */ = {isa = PBXBuildFile; fileRef = 41ECEAD52064147C009D5141 /* helpers.h */; };
+ 41ECEAD82064147C009D5141 /* helpers.cc in Sources */ = {isa = PBXBuildFile; fileRef = 41ECEAD62064147C009D5141 /* helpers.cc */; };
+ 41ECEADA206414A6009D5141 /* RTCRtpFragmentationHeader.mm in Sources */ = {isa = PBXBuildFile; fileRef = 41ECEAD9206414A6009D5141 /* RTCRtpFragmentationHeader.mm */; };
+ 41ECEADB206415EA009D5141 /* objc_video_decoder_factory.mm in Sources */ = {isa = PBXBuildFile; fileRef = 413A23F91FE1987C00373E99 /* objc_video_decoder_factory.mm */; };
+ 41ECEADC206415EE009D5141 /* objc_video_encoder_factory.mm in Sources */ = {isa = PBXBuildFile; fileRef = 413A23F51FE1987B00373E99 /* objc_video_encoder_factory.mm */; };
+ 41ECEAE1206416FF009D5141 /* RTCWrappedNativeVideoEncoder.h in Headers */ = {isa = PBXBuildFile; fileRef = 41ECEADD206416FD009D5141 /* RTCWrappedNativeVideoEncoder.h */; };
+ 41ECEAE2206416FF009D5141 /* RTCWrappedNativeVideoEncoder.mm in Sources */ = {isa = PBXBuildFile; fileRef = 41ECEADE206416FE009D5141 /* RTCWrappedNativeVideoEncoder.mm */; };
+ 41ECEAE3206416FF009D5141 /* RTCWrappedNativeVideoDecoder.h in Headers */ = {isa = PBXBuildFile; fileRef = 41ECEADF206416FE009D5141 /* RTCWrappedNativeVideoDecoder.h */; };
+ 41ECEAE4206416FF009D5141 /* RTCWrappedNativeVideoDecoder.mm in Sources */ = {isa = PBXBuildFile; fileRef = 41ECEAE0206416FE009D5141 /* RTCWrappedNativeVideoDecoder.mm */; };
+ 41ECEAE7206417E9009D5141 /* webrtcvideoencoderfactory.cc in Sources */ = {isa = PBXBuildFile; fileRef = 41ECEAE5206417E8009D5141 /* webrtcvideoencoderfactory.cc */; };
+ 41ECEAE8206417E9009D5141 /* webrtcvideodecoderfactory.cc in Sources */ = {isa = PBXBuildFile; fileRef = 41ECEAE6206417E9009D5141 /* webrtcvideodecoderfactory.cc */; };
+ 41ECEAEA20641812009D5141 /* RTCVideoEncoderSettings.mm in Sources */ = {isa = PBXBuildFile; fileRef = 41ECEAE920641812009D5141 /* RTCVideoEncoderSettings.mm */; };
41F411AD1EF8D91F00343C26 /* null_aec_dump_factory.cc in Sources */ = {isa = PBXBuildFile; fileRef = 41F411AC1EF8D91E00343C26 /* null_aec_dump_factory.cc */; };
41F411B01EF8DA0100343C26 /* rtcerror.cc in Sources */ = {isa = PBXBuildFile; fileRef = 41F411AE1EF8DA0000343C26 /* rtcerror.cc */; };
41F411B11EF8DA0200343C26 /* rtcerror.h in Headers */ = {isa = PBXBuildFile; fileRef = 41F411AF1EF8DA0000343C26 /* rtcerror.h */; };
@@ -3354,7 +3382,6 @@
413A24041FE1990300373E99 /* RTCVideoCodecH264.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RTCVideoCodecH264.h; path = sdk/objc/Framework/Headers/WebRTC/RTCVideoCodecH264.h; sourceTree = "<group>"; };
413A24051FE1990300373E99 /* RTCVideoCapturer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RTCVideoCapturer.h; path = sdk/objc/Framework/Headers/WebRTC/RTCVideoCapturer.h; sourceTree = "<group>"; };
413A24061FE1990400373E99 /* RTCPeerConnection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RTCPeerConnection.h; path = sdk/objc/Framework/Headers/WebRTC/RTCPeerConnection.h; sourceTree = "<group>"; };
- 413A24071FE1990400373E99 /* WebRTC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebRTC.h; path = sdk/objc/Framework/Headers/WebRTC/WebRTC.h; sourceTree = "<group>"; };
413A24081FE1990400373E99 /* RTCFieldTrials.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RTCFieldTrials.h; path = sdk/objc/Framework/Headers/WebRTC/RTCFieldTrials.h; sourceTree = "<group>"; };
413A24091FE1990400373E99 /* RTCVideoFrameBuffer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RTCVideoFrameBuffer.h; path = sdk/objc/Framework/Headers/WebRTC/RTCVideoFrameBuffer.h; sourceTree = "<group>"; };
413A240A1FE1990400373E99 /* RTCLegacyStatsReport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RTCLegacyStatsReport.h; path = sdk/objc/Framework/Headers/WebRTC/RTCLegacyStatsReport.h; sourceTree = "<group>"; };
@@ -3929,6 +3956,33 @@
41EA54161EFC2D53002FF04C /* md5-586.pl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.perl; path = "md5-586.pl"; sourceTree = "<group>"; };
41EA54171EFC2D53002FF04C /* md5-x86_64.pl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.perl; path = "md5-x86_64.pl"; sourceTree = "<group>"; };
41EA54181EFC2D53002FF04C /* md5.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = md5.c; sourceTree = "<group>"; };
+ 41ECEAB320630107009D5141 /* RTCVideoCodec+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "RTCVideoCodec+Private.h"; path = "PeerConnection/RTCVideoCodec+Private.h"; sourceTree = "<group>"; };
+ 41ECEAB420630107009D5141 /* RTCVideoCodec.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = RTCVideoCodec.mm; path = PeerConnection/RTCVideoCodec.mm; sourceTree = "<group>"; };
+ 41ECEAB520630108009D5141 /* RTCVideoCodecH264.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = RTCVideoCodecH264.mm; path = PeerConnection/RTCVideoCodecH264.mm; sourceTree = "<group>"; };
+ 41ECEAB920630365009D5141 /* RTCUIApplicationStatusObserver.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = RTCUIApplicationStatusObserver.m; path = Common/RTCUIApplicationStatusObserver.m; sourceTree = "<group>"; };
+ 41ECEABB206403C1009D5141 /* WebKitUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebKitUtilities.h; sourceTree = "<group>"; };
+ 41ECEABD20640498009D5141 /* WebKitUtilities.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebKitUtilities.mm; sourceTree = "<group>"; };
+ 41ECEABF20640F27009D5141 /* NSString+StdString.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "NSString+StdString.h"; path = "Common/NSString+StdString.h"; sourceTree = "<group>"; };
+ 41ECEAC020640F28009D5141 /* NSString+StdString.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = "NSString+StdString.mm"; path = "Common/NSString+StdString.mm"; sourceTree = "<group>"; };
+ 41ECEAC520641302009D5141 /* RTCCVPixelBuffer.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = RTCCVPixelBuffer.mm; path = Video/RTCCVPixelBuffer.mm; sourceTree = "<group>"; };
+ 41ECEAC720641328009D5141 /* RTCEncodedImage.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = RTCEncodedImage.mm; path = PeerConnection/RTCEncodedImage.mm; sourceTree = "<group>"; };
+ 41ECEAC92064134E009D5141 /* RTCVideoFrame.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = RTCVideoFrame.mm; path = PeerConnection/RTCVideoFrame.mm; sourceTree = "<group>"; };
+ 41ECEACA2064134E009D5141 /* RTCVideoFrame+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "RTCVideoFrame+Private.h"; path = "PeerConnection/RTCVideoFrame+Private.h"; sourceTree = "<group>"; };
+ 41ECEACD2064136F009D5141 /* RTCI420Buffer.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = RTCI420Buffer.mm; path = Video/RTCI420Buffer.mm; sourceTree = "<group>"; };
+ 41ECEACE2064136F009D5141 /* RTCI420Buffer+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "RTCI420Buffer+Private.h"; path = "Video/RTCI420Buffer+Private.h"; sourceTree = "<group>"; };
+ 41ECEAD120641457009D5141 /* objc_frame_buffer.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = objc_frame_buffer.mm; path = Video/objc_frame_buffer.mm; sourceTree = "<group>"; };
+ 41ECEAD220641458009D5141 /* objc_frame_buffer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = objc_frame_buffer.h; path = Video/objc_frame_buffer.h; sourceTree = "<group>"; };
+ 41ECEAD52064147C009D5141 /* helpers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = helpers.h; sourceTree = "<group>"; };
+ 41ECEAD62064147C009D5141 /* helpers.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = helpers.cc; sourceTree = "<group>"; };
+ 41ECEAD9206414A6009D5141 /* RTCRtpFragmentationHeader.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = RTCRtpFragmentationHeader.mm; path = PeerConnection/RTCRtpFragmentationHeader.mm; sourceTree = "<group>"; };
+ 41ECEADD206416FD009D5141 /* RTCWrappedNativeVideoEncoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RTCWrappedNativeVideoEncoder.h; path = PeerConnection/RTCWrappedNativeVideoEncoder.h; sourceTree = "<group>"; };
+ 41ECEADE206416FE009D5141 /* RTCWrappedNativeVideoEncoder.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = RTCWrappedNativeVideoEncoder.mm; path = PeerConnection/RTCWrappedNativeVideoEncoder.mm; sourceTree = "<group>"; };
+ 41ECEADF206416FE009D5141 /* RTCWrappedNativeVideoDecoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RTCWrappedNativeVideoDecoder.h; path = PeerConnection/RTCWrappedNativeVideoDecoder.h; sourceTree = "<group>"; };
+ 41ECEAE0206416FE009D5141 /* RTCWrappedNativeVideoDecoder.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = RTCWrappedNativeVideoDecoder.mm; path = PeerConnection/RTCWrappedNativeVideoDecoder.mm; sourceTree = "<group>"; };
+ 41ECEAE5206417E8009D5141 /* webrtcvideoencoderfactory.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = webrtcvideoencoderfactory.cc; path = engine/webrtcvideoencoderfactory.cc; sourceTree = "<group>"; };
+ 41ECEAE6206417E9009D5141 /* webrtcvideodecoderfactory.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = webrtcvideodecoderfactory.cc; path = engine/webrtcvideodecoderfactory.cc; sourceTree = "<group>"; };
+ 41ECEAE920641812009D5141 /* RTCVideoEncoderSettings.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = RTCVideoEncoderSettings.mm; path = PeerConnection/RTCVideoEncoderSettings.mm; sourceTree = "<group>"; };
+ 41ECEAF620645CE6009D5141 /* UIDevice+RTCDevice.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = "UIDevice+RTCDevice.mm"; path = "Common/UIDevice+RTCDevice.mm"; sourceTree = "<group>"; };
41F411AC1EF8D91E00343C26 /* null_aec_dump_factory.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = null_aec_dump_factory.cc; path = Source/webrtc/modules/audio_processing/aec_dump/null_aec_dump_factory.cc; sourceTree = SOURCE_ROOT; };
41F411AE1EF8DA0000343C26 /* rtcerror.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = rtcerror.cc; sourceTree = "<group>"; };
41F411AF1EF8DA0000343C26 /* rtcerror.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = rtcerror.h; sourceTree = "<group>"; };
@@ -6419,7 +6473,6 @@
413A24181FE1990800373E99 /* RTCVideoTrack.h */,
413A24021FE1990300373E99 /* RTCVideoViewShading.h */,
413A24331FE1991600373E99 /* UIDevice+RTCDevice.h */,
- 413A24071FE1990400373E99 /* WebRTC.h */,
);
name = WebRTC;
sourceTree = "<group>";
@@ -6548,6 +6601,11 @@
children = (
4145E4A81EF8933C00FCF6E6 /* corevideo_frame_buffer.cc */,
4145E4A91EF8933C00FCF6E6 /* corevideo_frame_buffer.h */,
+ 41ECEAD220641458009D5141 /* objc_frame_buffer.h */,
+ 41ECEAD120641457009D5141 /* objc_frame_buffer.mm */,
+ 41ECEAC520641302009D5141 /* RTCCVPixelBuffer.mm */,
+ 41ECEACE2064136F009D5141 /* RTCI420Buffer+Private.h */,
+ 41ECEACD2064136F009D5141 /* RTCI420Buffer.mm */,
);
name = Video;
sourceTree = "<group>";
@@ -6555,6 +6613,8 @@
4145E4971EF8918600FCF6E6 /* VideoToolbox */ = {
isa = PBXGroup;
children = (
+ 41ECEAD62064147C009D5141 /* helpers.cc */,
+ 41ECEAD52064147C009D5141 /* helpers.h */,
4145E4B21EF8943D00FCF6E6 /* nalu_rewriter.cc */,
4145E4AF1EF8943D00FCF6E6 /* nalu_rewriter.h */,
413A23F61FE1987B00373E99 /* objc_video_decoder_factory.h */,
@@ -6599,7 +6659,11 @@
417DA4551EF9CCD800E869DB /* Common */ = {
isa = PBXGroup;
children = (
+ 41ECEABF20640F27009D5141 /* NSString+StdString.h */,
+ 41ECEAC020640F28009D5141 /* NSString+StdString.mm */,
417DA4561EF9CD0A00E869DB /* RTCUIApplicationStatusObserver.h */,
+ 41ECEAB920630365009D5141 /* RTCUIApplicationStatusObserver.m */,
+ 41ECEAF620645CE6009D5141 /* UIDevice+RTCDevice.mm */,
);
name = Common;
sourceTree = "<group>";
@@ -6785,6 +6849,8 @@
419C84AD1FE304C60040C30F /* VideoToolBoxDecoderFactory.h */,
419C84AE1FE304C60040C30F /* VideoToolBoxEncoderFactory.cpp */,
419C84AC1FE304C60040C30F /* VideoToolBoxEncoderFactory.h */,
+ 41ECEABB206403C1009D5141 /* WebKitUtilities.h */,
+ 41ECEABD20640498009D5141 /* WebKitUtilities.mm */,
);
name = WebKit;
path = sdk/WebKit;
@@ -7214,6 +7280,25 @@
path = asm;
sourceTree = "<group>";
};
+ 41ECEAB2206300E3009D5141 /* PeerConnection */ = {
+ isa = PBXGroup;
+ children = (
+ 41ECEAC720641328009D5141 /* RTCEncodedImage.mm */,
+ 41ECEAD9206414A6009D5141 /* RTCRtpFragmentationHeader.mm */,
+ 41ECEAB320630107009D5141 /* RTCVideoCodec+Private.h */,
+ 41ECEAB420630107009D5141 /* RTCVideoCodec.mm */,
+ 41ECEAB520630108009D5141 /* RTCVideoCodecH264.mm */,
+ 41ECEAE920641812009D5141 /* RTCVideoEncoderSettings.mm */,
+ 41ECEACA2064134E009D5141 /* RTCVideoFrame+Private.h */,
+ 41ECEAC92064134E009D5141 /* RTCVideoFrame.mm */,
+ 41ECEADF206416FE009D5141 /* RTCWrappedNativeVideoDecoder.h */,
+ 41ECEAE0206416FE009D5141 /* RTCWrappedNativeVideoDecoder.mm */,
+ 41ECEADD206416FD009D5141 /* RTCWrappedNativeVideoEncoder.h */,
+ 41ECEADE206416FE009D5141 /* RTCWrappedNativeVideoEncoder.mm */,
+ );
+ name = PeerConnection;
+ sourceTree = "<group>";
+ };
41F411BD1EF8DB8200343C26 /* vp8 */ = {
isa = PBXGroup;
children = (
@@ -7848,7 +7933,9 @@
5C4B486A1E42C1BA002651C8 /* webrtcvideocapturer.h */,
5C4B486B1E42C1BA002651C8 /* webrtcvideocapturerfactory.cc */,
5C4B486C1E42C1BA002651C8 /* webrtcvideocapturerfactory.h */,
+ 41ECEAE6206417E9009D5141 /* webrtcvideodecoderfactory.cc */,
5C4B486D1E42C1BA002651C8 /* webrtcvideodecoderfactory.h */,
+ 41ECEAE5206417E8009D5141 /* webrtcvideoencoderfactory.cc */,
5C4B486F1E42C1BA002651C8 /* webrtcvideoencoderfactory.h */,
4145E4CF1EF8CC1700FCF6E6 /* webrtcvideoengine.cc */,
4145E4D01EF8CC1F00FCF6E6 /* webrtcvideoengine.h */,
@@ -8023,6 +8110,7 @@
isa = PBXGroup;
children = (
417DA4551EF9CCD800E869DB /* Common */,
+ 41ECEAB2206300E3009D5141 /* PeerConnection */,
4145E4931EF890E500FCF6E6 /* Video */,
4145E4971EF8918600FCF6E6 /* VideoToolbox */,
);
@@ -11219,6 +11307,7 @@
5CD285EB1E6A639F0094FDC8 /* h264_sprop_parameter_sets.h in Headers */,
5CDD83DA1E439A6F00621E92 /* h264_sps_pps_tracker.h in Headers */,
413A22D81FE18E0700373E99 /* helpers.h in Headers */,
+ 41ECEAD72064147C009D5141 /* helpers.h in Headers */,
5CDD83DC1E439A6F00621E92 /* histogram.h in Headers */,
419C83581FE246650040C30F /* histogram_percentile_counter.h in Headers */,
5CDD8BAF1E43C2B500621E92 /* hp_input.h in Headers */,
@@ -11364,6 +11453,7 @@
5CDD86A81E43B99400621E92 /* normalized_covariance_estimator.h in Headers */,
5C63F9541E41737B002CA531 /* notifier.h in Headers */,
5CDD86011E43B84E00621E92 /* ns_core.h in Headers */,
+ 41ECEAC120640F28009D5141 /* NSString+StdString.h in Headers */,
5CDD86061E43B84E00621E92 /* nsx_core.h in Headers */,
5CDD86071E43B84E00621E92 /* nsx_defines.h in Headers */,
419C83B41FE2472E0040C30F /* null_audio_poller.h in Headers */,
@@ -11371,6 +11461,7 @@
5C0885321E4A99D200403995 /* null_cipher.h in Headers */,
413A23C01FE18E0800373E99 /* nullsocketserver.h in Headers */,
5CD285331E6A61110094FDC8 /* nullwebrtcvideoengine.h in Headers */,
+ 41ECEAD420641458009D5141 /* objc_frame_buffer.h in Headers */,
413A23FC1FE1987F00373E99 /* objc_video_decoder_factory.h in Headers */,
413A23FD1FE1987F00373E99 /* objc_video_encoder_factory.h in Headers */,
413A23361FE18E0700373E99 /* onetimeevent.h in Headers */,
@@ -11549,6 +11640,7 @@
413A24401FE1991A00373E99 /* RTCFieldTrials.h in Headers */,
413A245A1FE1991A00373E99 /* RTCFileLogger.h in Headers */,
413A24561FE1991A00373E99 /* RTCFileVideoCapturer.h in Headers */,
+ 41ECEAD020641370009D5141 /* RTCI420Buffer+Private.h in Headers */,
413A244E1FE1991A00373E99 /* RTCIceCandidate.h in Headers */,
413A245E1FE1991A00373E99 /* RTCIceServer.h in Headers */,
413A24481FE1991A00373E99 /* RTCIntervalRange.h in Headers */,
@@ -11591,6 +11683,7 @@
413A245F1FE1991A00373E99 /* RTCTracing.h in Headers */,
417DA4581EF9CD0D00E869DB /* RTCUIApplicationStatusObserver.h in Headers */,
413A243D1FE1991A00373E99 /* RTCVideoCapturer.h in Headers */,
+ 41ECEAB620630108009D5141 /* RTCVideoCodec+Private.h in Headers */,
413A24431FE1991A00373E99 /* RTCVideoCodec.h in Headers */,
413A24531FE1991A00373E99 /* RTCVideoCodecFactory.h in Headers */,
413A243C1FE1991A00373E99 /* RTCVideoCodecH264.h in Headers */,
@@ -11598,6 +11691,7 @@
413A24601FE1991A00373E99 /* RTCVideoDecoderVP9.h in Headers */,
413A246E1FE1991A00373E99 /* RTCVideoEncoderVP8.h in Headers */,
413A24461FE1991A00373E99 /* RTCVideoEncoderVP9.h in Headers */,
+ 41ECEACC2064134F009D5141 /* RTCVideoFrame+Private.h in Headers */,
413A244F1FE1991A00373E99 /* RTCVideoFrame.h in Headers */,
413A24411FE1991A00373E99 /* RTCVideoFrameBuffer.h in Headers */,
413A246F1FE1991A00373E99 /* RTCVideoRenderer.h in Headers */,
@@ -11604,6 +11698,8 @@
413A24611FE1991A00373E99 /* RTCVideoSource.h in Headers */,
413A24501FE1991A00373E99 /* RTCVideoTrack.h in Headers */,
413A243A1FE1991A00373E99 /* RTCVideoViewShading.h in Headers */,
+ 41ECEAE3206416FF009D5141 /* RTCWrappedNativeVideoDecoder.h in Headers */,
+ 41ECEAE1206416FF009D5141 /* RTCWrappedNativeVideoEncoder.h in Headers */,
419C82B81FE20DCD0040C30F /* rtp_config.h in Headers */,
419C83C91FE247B40040C30F /* rtp_cvo.h in Headers */,
413092011EF8D0A600757C55 /* rtp_demuxer.h in Headers */,
@@ -11892,7 +11988,7 @@
5CDD8BF61E43C2B500621E92 /* vq4.h in Headers */,
5C4B4C811E431F9C002651C8 /* wav_file.h in Headers */,
5C4B4C841E431F9C002651C8 /* wav_header.h in Headers */,
- 413A243F1FE1991A00373E99 /* WebRTC.h in Headers */,
+ 41ECEABC206403C2009D5141 /* WebKitUtilities.h in Headers */,
5CDD8CAB1E43C6F700621E92 /* webrtc_cng.h in Headers */,
4145E4911EF88EF700FCF6E6 /* webrtc_libyuv.h in Headers */,
41F9BFC72051DCE900ABF0B9 /* webrtc_vad.h in Headers */,
@@ -13059,6 +13155,7 @@
419C84691FE255FA0040C30F /* handshake.cc in Sources */,
419C84891FE2574D0040C30F /* handshake_client.cc in Sources */,
419C848B1FE2574D0040C30F /* handshake_server.cc in Sources */,
+ 41ECEAD82064147C009D5141 /* helpers.cc in Sources */,
413A236E1FE18E0700373E99 /* helpers.cc in Sources */,
5CDD83DB1E439A6F00621E92 /* histogram.cc in Sources */,
419C83511FE246650040C30F /* histogram_percentile_counter.cc in Sources */,
@@ -13188,11 +13285,15 @@
5CDD8A3D1E43BFB300621E92 /* normal.cc in Sources */,
5CDD86A71E43B99400621E92 /* normalized_covariance_estimator.cc in Sources */,
5CDD86001E43B84E00621E92 /* ns_core.c in Sources */,
+ 41ECEAC220640F28009D5141 /* NSString+StdString.mm in Sources */,
5CDD86051E43B84E00621E92 /* nsx_core.c in Sources */,
5CDD86021E43B84E00621E92 /* nsx_core_c.c in Sources */,
41F411AD1EF8D91F00343C26 /* null_aec_dump_factory.cc in Sources */,
419C83B31FE2472E0040C30F /* null_audio_poller.cc in Sources */,
413A23D21FE18E0800373E99 /* nullsocketserver.cc in Sources */,
+ 41ECEAD320641458009D5141 /* objc_frame_buffer.mm in Sources */,
+ 41ECEADB206415EA009D5141 /* objc_video_decoder_factory.mm in Sources */,
+ 41ECEADC206415EE009D5141 /* objc_video_encoder_factory.mm in Sources */,
5CDD86941E43B93900621E92 /* ooura_fft.cc in Sources */,
5CDD86911E43B93900621E92 /* ooura_fft_sse2.cc in Sources */,
419C84271FE24BD10040C30F /* openssladapter.cc in Sources */,
@@ -13345,7 +13446,10 @@
419C841D1FE24AEF0040C30F /* rtc_stream_config.cc in Sources */,
413A230F1FE18E0700373E99 /* rtccertificate.cc in Sources */,
413A22BE1FE18E0700373E99 /* rtccertificategenerator.cc in Sources */,
+ 41ECEAC620641303009D5141 /* RTCCVPixelBuffer.mm in Sources */,
+ 41ECEAC820641328009D5141 /* RTCEncodedImage.mm in Sources */,
41F411B01EF8DA0100343C26 /* rtcerror.cc in Sources */,
+ 41ECEACF20641370009D5141 /* RTCI420Buffer.mm in Sources */,
5CDD8A4F1E43BFB300621E92 /* rtcp.cc in Sources */,
419C82B91FE20DCD0040C30F /* rtcp_demuxer.cc in Sources */,
5CD285FA1E6A64520094FDC8 /* rtcp_nack_stats.cc in Sources */,
@@ -13355,10 +13459,19 @@
419C82FF1FE20F020040C30F /* rtcp_transceiver.cc in Sources */,
419C83021FE20F020040C30F /* rtcp_transceiver_config.cc in Sources */,
419C83001FE20F020040C30F /* rtcp_transceiver_impl.cc in Sources */,
+ 41ECEADA206414A6009D5141 /* RTCRtpFragmentationHeader.mm in Sources */,
5C63FA781E417AED002CA531 /* rtcstats.cc in Sources */,
5C63FA771E417AED002CA531 /* rtcstats_objects.cc in Sources */,
5CD285071E6A60570094FDC8 /* rtcstatscollector.cc in Sources */,
5C63FA791E417AED002CA531 /* rtcstatsreport.cc in Sources */,
+ 41ECEAB720630108009D5141 /* RTCVideoCodec.mm in Sources */,
+ 41ECEAB820630108009D5141 /* RTCVideoCodecH264.mm in Sources */,
+ 41ECEAC3206411E2009D5141 /* RTCVideoDecoderH264.mm in Sources */,
+ 41ECEAC4206411E5009D5141 /* RTCVideoEncoderH264.mm in Sources */,
+ 41ECEAEA20641812009D5141 /* RTCVideoEncoderSettings.mm in Sources */,
+ 41ECEACB2064134F009D5141 /* RTCVideoFrame.mm in Sources */,
+ 41ECEAE4206416FF009D5141 /* RTCWrappedNativeVideoDecoder.mm in Sources */,
+ 41ECEAE2206416FF009D5141 /* RTCWrappedNativeVideoEncoder.mm in Sources */,
419C82B41FE20DCD0040C30F /* rtp_config.cc in Sources */,
413092021EF8D0A600757C55 /* rtp_demuxer.cc in Sources */,
5CDD88B01E43BE3C00621E92 /* rtp_format.cc in Sources */,
@@ -13626,6 +13739,7 @@
5C4B4C801E431F9C002651C8 /* wav_file.cc in Sources */,
5C4B4C831E431F9C002651C8 /* wav_header.cc in Sources */,
413A22E91FE18E0700373E99 /* weak_ptr.cc in Sources */,
+ 41ECEABE20640498009D5141 /* WebKitUtilities.mm in Sources */,
5CDD8CAA1E43C6F700621E92 /* webrtc_cng.cc in Sources */,
5CDD83671E4325D500621E92 /* webrtc_libyuv.cc in Sources */,
5CDD86E41E43BA2800621E92 /* webrtc_vad.c in Sources */,
@@ -13634,6 +13748,8 @@
5CD2851A1E6A60570094FDC8 /* webrtcsessiondescriptionfactory.cc in Sources */,
5C4B48901E42C1BA002651C8 /* webrtcvideocapturer.cc in Sources */,
5C4B48921E42C1BA002651C8 /* webrtcvideocapturerfactory.cc in Sources */,
+ 41ECEAE8206417E9009D5141 /* webrtcvideodecoderfactory.cc in Sources */,
+ 41ECEAE7206417E9009D5141 /* webrtcvideoencoderfactory.cc in Sources */,
4145E4D11EF8CC2000FCF6E6 /* webrtcvideoengine.cc in Sources */,
5C4B489D1E42C1BA002651C8 /* webrtcvoiceengine.cc in Sources */,
5CDD8BF71E43C2B500621E92 /* window32_w32.c in Sources */,
@@ -13978,6 +14094,9 @@
Source/webrtc,
Source/webrtc/sdk/objc/Framework/Classes/,
Source/third_party/libsrtp/config,
+ Source/webrtc/sdk/objc/Framework/Classes/Common,
+ Source/webrtc/sdk/objc/Framework/Classes/Video,
+ Source/webrtc/sdk/objc/Framework/Classes/PeerConnection,
);
OTHER_CFLAGS = "";
};
@@ -14027,6 +14146,9 @@
Source/webrtc,
Source/webrtc/sdk/objc/Framework/Classes/,
Source/third_party/libsrtp/config,
+ Source/webrtc/sdk/objc/Framework/Classes/Common,
+ Source/webrtc/sdk/objc/Framework/Classes/Video,
+ Source/webrtc/sdk/objc/Framework/Classes/PeerConnection,
);
};
name = Debug;
@@ -14060,6 +14182,9 @@
Source/webrtc,
Source/webrtc/sdk/objc/Framework/Classes/,
Source/third_party/libsrtp/config,
+ Source/webrtc/sdk/objc/Framework/Classes/Common,
+ Source/webrtc/sdk/objc/Framework/Classes/Video,
+ Source/webrtc/sdk/objc/Framework/Classes/PeerConnection,
);
OTHER_CFLAGS = "";
};
Modified: trunk/Source/WebCore/ChangeLog (229907 => 229908)
--- trunk/Source/WebCore/ChangeLog 2018-03-23 18:06:34 UTC (rev 229907)
+++ trunk/Source/WebCore/ChangeLog 2018-03-23 18:20:47 UTC (rev 229908)
@@ -1,5 +1,31 @@
2018-03-23 Youenn Fablet <you...@apple.com>
+ Use libwebrtc ObjectiveC H264 encoder and decoder
+ https://bugs.webkit.org/show_bug.cgi?id=183912
+
+ Reviewed by Eric Carlson.
+
+ No observable change of behavior.
+ Made use of libwebrtc WebKit utilities.
+ Updated RealtimeINcomingVideoSourceCocoa as it now receives ObjcVideoFrame.
+
+ * Configurations/WebCore.xcconfig:
+ * SourcesCocoa.txt:
+ * WebCore.xcodeproj/project.pbxproj:
+ * platform/mediastream/libwebrtc/LibWebRTCProviderCocoa.cpp:
+ (WebCore::LibWebRTCProviderCocoa::~LibWebRTCProviderCocoa):
+ (WebCore::LibWebRTCProviderCocoa::setH264HardwareEncoderAllowed):
+ (WebCore::LibWebRTCProviderCocoa::createDecoderFactory):
+ (WebCore::LibWebRTCProviderCocoa::createEncoderFactory):
+ (WebCore::LibWebRTCProviderCocoa::setActive):
+ * platform/mediastream/libwebrtc/LibWebRTCProviderCocoa.h:
+ * platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.mm: Renamed from Source/WebCore/platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.cpp.
+ (WebCore::RealtimeIncomingVideoSourceCocoa::pixelBufferFromVideoFrame):
+ (WebCore::RealtimeIncomingVideoSourceCocoa::OnFrame):
+ * testing/Internals.cpp: Removed commented out include.
+
+2018-03-23 Youenn Fablet <you...@apple.com>
+
DocumentThreadableLoader should send credentials after redirections and preflight if fetch option credentials is include
https://bugs.webkit.org/show_bug.cgi?id=183928
Modified: trunk/Source/WebCore/Configurations/WebCore.xcconfig (229907 => 229908)
--- trunk/Source/WebCore/Configurations/WebCore.xcconfig 2018-03-23 18:06:34 UTC (rev 229907)
+++ trunk/Source/WebCore/Configurations/WebCore.xcconfig 2018-03-23 18:20:47 UTC (rev 229908)
@@ -46,7 +46,7 @@
OTHER_CPLUSPLUSFLAGS = $(inherited) $(ADDITIONAL_CFLAGS);
WEBKITADDITIONS_HEADER_SEARCH_PATHS = $(BUILT_PRODUCTS_DIR)/usr/local/include/WebKitAdditions $(SDKROOT)/usr/local/include/WebKitAdditions;
-LIBWEBRTC_HEADER_SEARCH_PATHS = $(BUILT_PRODUCTS_DIR)/usr/local/include/webrtc $(SDKROOT)/usr/local/include/webrtc;
+LIBWEBRTC_HEADER_SEARCH_PATHS = $(BUILT_PRODUCTS_DIR)/usr/local/include/webrtc $(SDKROOT)/usr/local/include/webrtc $(BUILT_PRODUCTS_DIR)/usr/local/include/webrtc/sdk/objc/Framework/Headers $(SDKROOT)/usr/local/include/webrtc/sdk/objc/Framework/Headers;
HEADER_SEARCH_PATHS = PAL ForwardingHeaders /usr/include/libxslt /usr/include/libxml2 "$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore" "$(BUILT_PRODUCTS_DIR)$(WK_ALTERNATE_WEBKIT_SDK_PATH)/usr/local/include" $(WEBKITADDITIONS_HEADER_SEARCH_PATHS) $(LIBWEBRTC_HEADER_SEARCH_PATHS) $(HEADER_SEARCH_PATHS) $(SRCROOT);
INFOPLIST_FILE = Info.plist;
Modified: trunk/Source/WebCore/SourcesCocoa.txt (229907 => 229908)
--- trunk/Source/WebCore/SourcesCocoa.txt 2018-03-23 18:06:34 UTC (rev 229907)
+++ trunk/Source/WebCore/SourcesCocoa.txt 2018-03-23 18:20:47 UTC (rev 229908)
@@ -542,7 +542,7 @@
platform/mediastream/mac/DisplayCaptureManagerCocoa.cpp
platform/mediastream/mac/DisplayCaptureSourceCocoa.cpp
platform/mediastream/mac/RealtimeIncomingAudioSourceCocoa.cpp
-platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.cpp
+platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.mm
platform/mediastream/mac/RealtimeMediaSourceCenterMac.cpp
platform/mediastream/mac/RealtimeOutgoingAudioSourceCocoa.cpp
platform/mediastream/mac/RealtimeOutgoingVideoSourceCocoa.cpp
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (229907 => 229908)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2018-03-23 18:06:34 UTC (rev 229907)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2018-03-23 18:20:47 UTC (rev 229908)
@@ -4353,6 +4353,7 @@
DE5F86571FA2AF24006DB63A /* UnifiedSource58-mm.mm in Sources */ = {isa = PBXBuildFile; fileRef = DE5F86391FA2AF07006DB63A /* UnifiedSource58-mm.mm */; };
DE5F86581FA2AF24006DB63A /* UnifiedSource59-mm.mm in Sources */ = {isa = PBXBuildFile; fileRef = DE5F86321FA2AEFF006DB63A /* UnifiedSource59-mm.mm */; };
DE5F86591FA2AF24006DB63A /* UnifiedSource60-mm.mm in Sources */ = {isa = PBXBuildFile; fileRef = DE5F863A1FA2AF07006DB63A /* UnifiedSource60-mm.mm */; };
+ DE5F86591FA2AF24006DB63B /* UnifiedSource61-mm.mm in Sources */ = {isa = PBXBuildFile; fileRef = DE5F863A1FA2AF07006DB63B /* UnifiedSource61-mm.mm */; };
DE7710861FA2F0D600460016 /* WebArchiveDumpSupport.mm in Sources */ = {isa = PBXBuildFile; fileRef = A1763F3C1E205234001D58DE /* WebArchiveDumpSupport.mm */; };
DEBCCDD216646E8200A452E1 /* RenderMediaControlElements.h in Headers */ = {isa = PBXBuildFile; fileRef = DE49B308165F2FE10010338D /* RenderMediaControlElements.h */; };
DEBCCDD416646EAF00A452E1 /* MediaControlElementTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = DE49B300165F2FC60010338D /* MediaControlElementTypes.h */; };
@@ -8539,7 +8540,7 @@
5CB37FFD1C62D27800F20188 /* ScrollAnimatorMock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScrollAnimatorMock.h; sourceTree = "<group>"; };
5CBC8DAA1AAA302200E1C803 /* MediaAccessibilitySoftLink.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaAccessibilitySoftLink.cpp; sourceTree = "<group>"; };
5CBC8DAB1AAA302200E1C803 /* MediaAccessibilitySoftLink.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaAccessibilitySoftLink.h; sourceTree = "<group>"; };
- 5CDD83391E4324BB00621E83 /* RealtimeIncomingVideoSourceCocoa.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RealtimeIncomingVideoSourceCocoa.cpp; sourceTree = "<group>"; };
+ 5CDD83391E4324BB00621E83 /* RealtimeIncomingVideoSourceCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RealtimeIncomingVideoSourceCocoa.mm; sourceTree = "<group>"; };
5CDD83391E4324BB00621E92 /* RealtimeIncomingVideoSource.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RealtimeIncomingVideoSource.cpp; sourceTree = "<group>"; };
5CDD833A1E4324BB00621E83 /* RealtimeIncomingVideoSourceCocoa.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RealtimeIncomingVideoSourceCocoa.h; sourceTree = "<group>"; };
5CDD833A1E4324BB00621E92 /* RealtimeIncomingVideoSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RealtimeIncomingVideoSource.h; sourceTree = "<group>"; };
@@ -13738,6 +13739,7 @@
DE5F86381FA2AF06006DB63A /* UnifiedSource57-mm.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "UnifiedSource57-mm.mm"; sourceTree = "<group>"; };
DE5F86391FA2AF07006DB63A /* UnifiedSource58-mm.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "UnifiedSource58-mm.mm"; sourceTree = "<group>"; };
DE5F863A1FA2AF07006DB63A /* UnifiedSource60-mm.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "UnifiedSource60-mm.mm"; sourceTree = "<group>"; };
+ DE5F863A1FA2AF07006DB63B /* UnifiedSource61-mm.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "UnifiedSource61-mm.mm"; sourceTree = "<group>"; };
DE5F863B1FA2AF08006DB63A /* UnifiedSource55-mm.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "UnifiedSource55-mm.mm"; sourceTree = "<group>"; };
DEC2975D1B4DEB2A005F5945 /* JSCustomEventCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCustomEventCustom.cpp; sourceTree = "<group>"; };
DECA7D6A1F9E61CB00E3B661 /* UnifiedSource144.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UnifiedSource144.cpp; sourceTree = "<group>"; };
@@ -15121,8 +15123,8 @@
07EE76EE1BEA619800F89133 /* MockRealtimeVideoSourceMac.mm */,
41103AAA1E39790A00769F14 /* RealtimeIncomingAudioSourceCocoa.cpp */,
41103AA91E39790A00769F14 /* RealtimeIncomingAudioSourceCocoa.h */,
- 5CDD83391E4324BB00621E83 /* RealtimeIncomingVideoSourceCocoa.cpp */,
5CDD833A1E4324BB00621E83 /* RealtimeIncomingVideoSourceCocoa.h */,
+ 5CDD83391E4324BB00621E83 /* RealtimeIncomingVideoSourceCocoa.mm */,
4A0FFAA31AAF5EF60062803B /* RealtimeMediaSourceCenterMac.cpp */,
4A0FFAA41AAF5EF60062803B /* RealtimeMediaSourceCenterMac.h */,
41103AA71E39790A00769F14 /* RealtimeOutgoingAudioSourceCocoa.cpp */,
@@ -17919,6 +17921,7 @@
538EC86B1F993F29004D22A8 /* UnifiedSource59.cpp */,
DE5F863A1FA2AF07006DB63A /* UnifiedSource60-mm.mm */,
538EC8791F993F31004D22A8 /* UnifiedSource60.cpp */,
+ DE5F863A1FA2AF07006DB63B /* UnifiedSource61-mm.mm */,
538EC87E1F993F33004D22A8 /* UnifiedSource61.cpp */,
538EC85A1F993F20004D22A8 /* UnifiedSource62.cpp */,
538EC8611F993F24004D22A8 /* UnifiedSource63.cpp */,
@@ -30884,7 +30887,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
- shellScript = "set -e\n\ncd $SRCROOT\n\nif [ \"${DEPLOYMENT_LOCATION}\" == \"YES\" ]; then\nBUILD_SCRIPTS_DIR=\"${SDKROOT}/usr/local/include/wtf/Scripts\"\nelse\nBUILD_SCRIPTS_DIR=\"${BUILT_PRODUCTS_DIR}/usr/local/include/wtf/Scripts\"\nfi\n\nUnifiedSourceCppFileCount=530\nUnifiedSourceMmFileCount=60\n\necho \"Using unified source list files: Sources.txt, SourcesCocoa.txt\"\n\n/usr/bin/env ruby \"${BUILD_SCRIPTS_DIR}/generate-unified-source-bundles.rb\" \"--derived-sources-path\" \"${BUILT_PRODUCTS_DIR}/DerivedSources/WebCore\" \"--source-tree-path\" \"${SRCROOT}\" \"--feature-flags\" \"${FEATURE_DEFINES}\" \"--max-cpp-bundle-count\" \"${UnifiedSourceCppFileCount}\" \"--max-obj-c-bundle-count\" \"${UnifiedSourceMmFileCount}\" \"Sources.txt\" \"SourcesCocoa.txt\" > /dev/null\n";
+ shellScript = "set -e\n\ncd $SRCROOT\n\nif [ \"${DEPLOYMENT_LOCATION}\" == \"YES\" ]; then\nBUILD_SCRIPTS_DIR=\"${SDKROOT}/usr/local/include/wtf/Scripts\"\nelse\nBUILD_SCRIPTS_DIR=\"${BUILT_PRODUCTS_DIR}/usr/local/include/wtf/Scripts\"\nfi\n\nUnifiedSourceCppFileCount=530\nUnifiedSourceMmFileCount=61\n\necho \"Using unified source list files: Sources.txt, SourcesCocoa.txt\"\n\n/usr/bin/env ruby \"${BUILD_SCRIPTS_DIR}/generate-unified-source-bundles.rb\" \"--derived-sources-path\" \"${BUILT_PRODUCTS_DIR}/DerivedSources/WebCore\" \"--source-tree-path\" \"${SRCROOT}\" \"--feature-flags\" \"${FEATURE_DEFINES}\" \"--max-cpp-bundle-count\" \"${UnifiedSourceCppFileCount}\" \"--max-obj-c-bundle-count\" \"${UnifiedSourceMmFileCount}\" \"Sources.txt\" \"SourcesCocoa.txt\" > /dev/null\n";
};
5D0D540D0E9862F60029E223 /* Check For Weak VTables and Externals */ = {
isa = PBXShellScriptBuildPhase;
@@ -31297,6 +31300,7 @@
538EC8AC1F993F9D004D22A8 /* UnifiedSource59.cpp in Sources */,
DE5F86591FA2AF24006DB63A /* UnifiedSource60-mm.mm in Sources */,
538EC8AD1F993F9D004D22A8 /* UnifiedSource60.cpp in Sources */,
+ DE5F86591FA2AF24006DB63B /* UnifiedSource61-mm.mm in Sources */,
538EC8AE1F993F9D004D22A8 /* UnifiedSource61.cpp in Sources */,
538EC8AF1F993F9D004D22A8 /* UnifiedSource62.cpp in Sources */,
538EC8B01F993F9D004D22A8 /* UnifiedSource63.cpp in Sources */,
Modified: trunk/Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCProviderCocoa.cpp (229907 => 229908)
--- trunk/Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCProviderCocoa.cpp 2018-03-23 18:06:34 UTC (rev 229907)
+++ trunk/Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCProviderCocoa.cpp 2018-03-23 18:20:47 UTC (rev 229908)
@@ -29,6 +29,7 @@
#if USE(LIBWEBRTC)
#include <webrtc/media/engine/webrtcvideodecoderfactory.h>
#include <webrtc/media/engine/webrtcvideoencoderfactory.h>
+#include <webrtc/sdk/WebKit/WebKitUtilities.h>
#include <wtf/darwin/WeakLinking.h>
#endif
@@ -47,49 +48,26 @@
LibWebRTCProviderCocoa::~LibWebRTCProviderCocoa()
{
- if (m_encoderFactory)
- m_encoderFactory->ClearDestructorObserver();
- if (m_decoderFactory)
- m_decoderFactory->ClearDestructorObserver();
}
void LibWebRTCProviderCocoa::setH264HardwareEncoderAllowed(bool allowed)
{
- m_h264HardwareEncoderAllowed = allowed;
-#if PLATFORM(MAC)
- if (m_encoderFactory)
- m_encoderFactory->setH264HardwareEncoderAllowed(allowed);
-#endif
+ webrtc::setH264HardwareEncoderAllowed(allowed);
}
std::unique_ptr<webrtc::VideoDecoderFactory> LibWebRTCProviderCocoa::createDecoderFactory()
{
- ASSERT(!m_decoderFactory);
- auto decoderFactory = std::make_unique<webrtc::VideoToolboxVideoDecoderFactory>(this);
- m_decoderFactory = decoderFactory.get();
-
- return WTFMove(decoderFactory);
+ return webrtc::createVideoToolboxDecoderFactory();
}
std::unique_ptr<webrtc::VideoEncoderFactory> LibWebRTCProviderCocoa::createEncoderFactory()
{
- ASSERT(!m_encoderFactory);
- auto encoderFactory = std::make_unique<webrtc::VideoToolboxVideoEncoderFactory>(this);
- m_encoderFactory = encoderFactory.get();
-
-#if PLATFORM(MAC)
- m_encoderFactory->setH264HardwareEncoderAllowed(m_h264HardwareEncoderAllowed);
-#endif
-
- return WTFMove(encoderFactory);
+ return webrtc::createVideoToolboxEncoderFactory();
}
void LibWebRTCProviderCocoa::setActive(bool value)
{
- if (m_decoderFactory)
- m_decoderFactory->SetActive(value);
- if (m_encoderFactory)
- m_encoderFactory->SetActive(value);
+ webrtc::setApplicationStatus(value);
}
#endif // USE(LIBWEBRTC)
Modified: trunk/Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCProviderCocoa.h (229907 => 229908)
--- trunk/Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCProviderCocoa.h 2018-03-23 18:06:34 UTC (rev 229907)
+++ trunk/Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCProviderCocoa.h 2018-03-23 18:20:47 UTC (rev 229908)
@@ -34,7 +34,7 @@
namespace WebCore {
-class WEBCORE_EXPORT LibWebRTCProviderCocoa : public LibWebRTCProvider, public webrtc::VideoToolboxVideoDecoderFactory::DestructorObserver, public webrtc::VideoToolboxVideoEncoderFactory::DestructorObserver {
+class WEBCORE_EXPORT LibWebRTCProviderCocoa : public LibWebRTCProvider {
public:
LibWebRTCProviderCocoa() = default;
~LibWebRTCProviderCocoa();
@@ -45,22 +45,6 @@
std::unique_ptr<webrtc::VideoEncoderFactory> createEncoderFactory() final;
void setH264HardwareEncoderAllowed(bool allowed) final;
-
- void notifyOfDecoderFactoryDestruction(webrtc::VideoToolboxVideoDecoderFactory& factory) final
- {
- ASSERT_UNUSED(factory, &factory == m_decoderFactory);
- m_decoderFactory = nullptr;
- }
-
- void notifyOfEncoderFactoryDestruction(webrtc::VideoToolboxVideoEncoderFactory& factory) final
- {
- ASSERT_UNUSED(factory, &factory == m_encoderFactory);
- m_encoderFactory = nullptr;
- }
-
- webrtc::VideoToolboxVideoDecoderFactory* m_decoderFactory { nullptr };
- webrtc::VideoToolboxVideoEncoderFactory* m_encoderFactory { nullptr };
- bool m_h264HardwareEncoderAllowed { true };
};
} // namespace WebCore
Deleted: trunk/Source/WebCore/platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.cpp (229907 => 229908)
--- trunk/Source/WebCore/platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.cpp 2018-03-23 18:06:34 UTC (rev 229907)
+++ trunk/Source/WebCore/platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.cpp 2018-03-23 18:20:47 UTC (rev 229908)
@@ -1,173 +0,0 @@
-/*
- * Copyright (C) 2017 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 THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
- * OWNER OR 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 "RealtimeIncomingVideoSourceCocoa.h"
-
-#if USE(LIBWEBRTC)
-
-#include "Logging.h"
-#include "MediaSampleAVFObjC.h"
-#include <webrtc/sdk/objc/Framework/Classes/Video/corevideo_frame_buffer.h>
-#include <wtf/cf/TypeCastsCF.h>
-
-#include <pal/cf/CoreMediaSoftLink.h>
-#include "CoreVideoSoftLink.h"
-
-namespace WebCore {
-using namespace PAL;
-
-Ref<RealtimeIncomingVideoSource> RealtimeIncomingVideoSource::create(rtc::scoped_refptr<webrtc::VideoTrackInterface>&& videoTrack, String&& trackId)
-{
- auto source = RealtimeIncomingVideoSourceCocoa::create(WTFMove(videoTrack), WTFMove(trackId));
- source->start();
- return WTFMove(source);
-}
-
-Ref<RealtimeIncomingVideoSourceCocoa> RealtimeIncomingVideoSourceCocoa::create(rtc::scoped_refptr<webrtc::VideoTrackInterface>&& videoTrack, String&& trackId)
-{
- return adoptRef(*new RealtimeIncomingVideoSourceCocoa(WTFMove(videoTrack), WTFMove(trackId)));
-}
-
-RealtimeIncomingVideoSourceCocoa::RealtimeIncomingVideoSourceCocoa(rtc::scoped_refptr<webrtc::VideoTrackInterface>&& videoTrack, String&& videoTrackId)
- : RealtimeIncomingVideoSource(WTFMove(videoTrack), WTFMove(videoTrackId))
-{
-}
-
-CVPixelBufferRef RealtimeIncomingVideoSourceCocoa::pixelBufferFromVideoFrame(const webrtc::VideoFrame& frame)
-{
- if (muted()) {
- if (!m_blackFrame || m_blackFrameWidth != frame.width() || m_blackFrameHeight != frame.height()) {
- CVPixelBufferRef pixelBuffer = nullptr;
- auto status = CVPixelBufferCreate(kCFAllocatorDefault, frame.width(), frame.height(), kCVPixelFormatType_420YpCbCr8Planar, nullptr, &pixelBuffer);
- ASSERT_UNUSED(status, status == noErr);
-
- m_blackFrame = adoptCF(pixelBuffer);
- m_blackFrameWidth = frame.width();
- m_blackFrameHeight = frame.height();
-
- status = CVPixelBufferLockBaseAddress(pixelBuffer, 0);
- ASSERT(status == noErr);
- void* data = ""
- size_t yLength = frame.width() * frame.height();
- memset(data, 0, yLength);
- memset(static_cast<uint8_t*>(data) + yLength, 128, yLength / 2);
-
- status = CVPixelBufferUnlockBaseAddress(pixelBuffer, 0);
- ASSERT(!status);
- }
- return m_blackFrame.get();
- }
- auto buffer = frame.video_frame_buffer();
- ASSERT(buffer->type() == webrtc::VideoFrameBuffer::Type::kNative);
- return static_cast<webrtc::CoreVideoFrameBuffer&>(*buffer).pixel_buffer();
-}
-
-void RealtimeIncomingVideoSourceCocoa::OnFrame(const webrtc::VideoFrame& frame)
-{
- if (!isProducingData())
- return;
-
-#if !RELEASE_LOG_DISABLED
- if (!(++m_numberOfFrames % 30))
- RELEASE_LOG(MediaStream, "RealtimeIncomingVideoSourceCocoa::OnFrame %zu frame", m_numberOfFrames);
-#endif
-
- auto pixelBuffer = pixelBufferFromVideoFrame(frame);
-
- // FIXME: Convert timing information from VideoFrame to CMSampleTimingInfo.
- // For the moment, we will pretend that frames should be rendered asap.
- CMSampleTimingInfo timingInfo;
- timingInfo.presentationTimeStamp = kCMTimeInvalid;
- timingInfo.decodeTimeStamp = kCMTimeInvalid;
- timingInfo.duration = kCMTimeInvalid;
-
- CMVideoFormatDescriptionRef formatDescription;
- OSStatus ostatus = CMVideoFormatDescriptionCreateForImageBuffer(kCFAllocatorDefault, (CVImageBufferRef)pixelBuffer, &formatDescription);
- if (ostatus != noErr) {
- LOG_ERROR("Failed to initialize CMVideoFormatDescription: %d", static_cast<int>(ostatus));
- return;
- }
-
- CMSampleBufferRef sampleBuffer;
- ostatus = CMSampleBufferCreateReadyWithImageBuffer(kCFAllocatorDefault, (CVImageBufferRef)pixelBuffer, formatDescription, &timingInfo, &sampleBuffer);
- CFRelease(formatDescription);
- if (ostatus != noErr) {
- LOG_ERROR("Failed to create the sample buffer: %d", static_cast<int>(ostatus));
- return;
- }
-
- auto sample = adoptCF(sampleBuffer);
-
- CFArrayRef attachmentsArray = CMSampleBufferGetSampleAttachmentsArray(sampleBuffer, true);
- for (CFIndex i = 0; i < CFArrayGetCount(attachmentsArray); ++i) {
- CFMutableDictionaryRef attachments = checked_cf_cast<CFMutableDictionaryRef>(CFArrayGetValueAtIndex(attachmentsArray, i));
- CFDictionarySetValue(attachments, kCMSampleAttachmentKey_DisplayImmediately, kCFBooleanTrue);
- }
-
- unsigned width = frame.width();
- unsigned height = frame.height();
-
- MediaSample::VideoRotation rotation;
- switch (frame.rotation()) {
- case webrtc::kVideoRotation_0:
- rotation = MediaSample::VideoRotation::None;
- break;
- case webrtc::kVideoRotation_180:
- rotation = MediaSample::VideoRotation::UpsideDown;
- break;
- case webrtc::kVideoRotation_90:
- rotation = MediaSample::VideoRotation::Right;
- std::swap(width, height);
- break;
- case webrtc::kVideoRotation_270:
- rotation = MediaSample::VideoRotation::Left;
- std::swap(width, height);
- break;
- }
-
- RefPtr<RealtimeIncomingVideoSourceCocoa> protectedThis(this);
- callOnMainThread([protectedThis = makeRef(*this), sample = WTFMove(sample), width, height, rotation] {
- protectedThis->processNewSample(sample.get(), width, height, rotation);
- });
-}
-
-void RealtimeIncomingVideoSourceCocoa::processNewSample(CMSampleBufferRef sample, unsigned width, unsigned height, MediaSample::VideoRotation rotation)
-{
- m_buffer = sample;
- if (width != m_currentSettings.width() || height != m_currentSettings.height()) {
- m_currentSettings.setWidth(width);
- m_currentSettings.setHeight(height);
- settingsDidChange();
- }
-
- videoSampleAvailable(MediaSampleAVFObjC::create(sample, rotation));
-}
-
-} // namespace WebCore
-
-#endif // USE(LIBWEBRTC)
Copied: trunk/Source/WebCore/platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.mm (from rev 229907, trunk/Source/WebCore/platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.cpp) (0 => 229908)
--- trunk/Source/WebCore/platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.mm (rev 0)
+++ trunk/Source/WebCore/platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.mm 2018-03-23 18:20:47 UTC (rev 229908)
@@ -0,0 +1,179 @@
+/*
+ * Copyright (C) 2017 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 THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR 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 "RealtimeIncomingVideoSourceCocoa.h"
+
+#if USE(LIBWEBRTC)
+
+#include "Logging.h"
+#include "MediaSampleAVFObjC.h"
+#include <pal/cf/CoreMediaSoftLink.h>
+#include <webrtc/sdk/WebKit/WebKitUtilities.h>
+#include <wtf/cf/TypeCastsCF.h>
+
+#include "CoreVideoSoftLink.h"
+
+namespace WebCore {
+using namespace PAL;
+
+Ref<RealtimeIncomingVideoSource> RealtimeIncomingVideoSource::create(rtc::scoped_refptr<webrtc::VideoTrackInterface>&& videoTrack, String&& trackId)
+{
+ auto source = RealtimeIncomingVideoSourceCocoa::create(WTFMove(videoTrack), WTFMove(trackId));
+ source->start();
+ return WTFMove(source);
+}
+
+Ref<RealtimeIncomingVideoSourceCocoa> RealtimeIncomingVideoSourceCocoa::create(rtc::scoped_refptr<webrtc::VideoTrackInterface>&& videoTrack, String&& trackId)
+{
+ return adoptRef(*new RealtimeIncomingVideoSourceCocoa(WTFMove(videoTrack), WTFMove(trackId)));
+}
+
+RealtimeIncomingVideoSourceCocoa::RealtimeIncomingVideoSourceCocoa(rtc::scoped_refptr<webrtc::VideoTrackInterface>&& videoTrack, String&& videoTrackId)
+ : RealtimeIncomingVideoSource(WTFMove(videoTrack), WTFMove(videoTrackId))
+{
+}
+
+static inline CVPixelBufferRef createBlackFrame(int width, int height)
+{
+ CVPixelBufferRef pixelBuffer = nullptr;
+ auto status = CVPixelBufferCreate(kCFAllocatorDefault, width, height, kCVPixelFormatType_420YpCbCr8Planar, 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);
+ memset(static_cast<uint8_t*>(data) + yLength, 128, yLength / 2);
+
+ status = CVPixelBufferUnlockBaseAddress(pixelBuffer, 0);
+ ASSERT(!status);
+ return pixelBuffer;
+}
+
+CVPixelBufferRef RealtimeIncomingVideoSourceCocoa::pixelBufferFromVideoFrame(const webrtc::VideoFrame& frame)
+{
+ if (muted()) {
+ 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));
+ }
+ return m_blackFrame.get();
+ }
+ ASSERT(frame.video_frame_buffer()->type() == webrtc::VideoFrameBuffer::Type::kNative);
+ return webrtc::pixelBufferFromFrame(frame);
+}
+
+void RealtimeIncomingVideoSourceCocoa::OnFrame(const webrtc::VideoFrame& frame)
+{
+ if (!isProducingData())
+ return;
+
+#if !RELEASE_LOG_DISABLED
+ if (!(++m_numberOfFrames % 30))
+ RELEASE_LOG(MediaStream, "RealtimeIncomingVideoSourceCocoa::OnFrame %zu frame", m_numberOfFrames);
+#endif
+
+ auto pixelBuffer = pixelBufferFromVideoFrame(frame);
+ if (!pixelBuffer) {
+ LOG_ERROR("Failed to get a pixel buffer from a frame");
+ return;
+ }
+
+ // FIXME: Convert timing information from VideoFrame to CMSampleTimingInfo.
+ // For the moment, we will pretend that frames should be rendered asap.
+ CMSampleTimingInfo timingInfo;
+ timingInfo.presentationTimeStamp = kCMTimeInvalid;
+ timingInfo.decodeTimeStamp = kCMTimeInvalid;
+ timingInfo.duration = kCMTimeInvalid;
+
+ CMVideoFormatDescriptionRef formatDescription;
+ OSStatus ostatus = CMVideoFormatDescriptionCreateForImageBuffer(kCFAllocatorDefault, (CVImageBufferRef)pixelBuffer, &formatDescription);
+ if (ostatus != noErr) {
+ LOG_ERROR("Failed to initialize CMVideoFormatDescription: %d", static_cast<int>(ostatus));
+ return;
+ }
+
+ CMSampleBufferRef sampleBuffer;
+ ostatus = CMSampleBufferCreateReadyWithImageBuffer(kCFAllocatorDefault, (CVImageBufferRef)pixelBuffer, formatDescription, &timingInfo, &sampleBuffer);
+ CFRelease(formatDescription);
+ if (ostatus != noErr) {
+ LOG_ERROR("Failed to create the sample buffer: %d", static_cast<int>(ostatus));
+ return;
+ }
+
+ auto sample = adoptCF(sampleBuffer);
+
+ CFArrayRef attachmentsArray = CMSampleBufferGetSampleAttachmentsArray(sampleBuffer, true);
+ for (CFIndex i = 0; i < CFArrayGetCount(attachmentsArray); ++i) {
+ CFMutableDictionaryRef attachments = checked_cf_cast<CFMutableDictionaryRef>(CFArrayGetValueAtIndex(attachmentsArray, i));
+ CFDictionarySetValue(attachments, kCMSampleAttachmentKey_DisplayImmediately, kCFBooleanTrue);
+ }
+
+ unsigned width = frame.width();
+ unsigned height = frame.height();
+
+ MediaSample::VideoRotation rotation;
+ switch (frame.rotation()) {
+ case webrtc::kVideoRotation_0:
+ rotation = MediaSample::VideoRotation::None;
+ break;
+ case webrtc::kVideoRotation_180:
+ rotation = MediaSample::VideoRotation::UpsideDown;
+ break;
+ case webrtc::kVideoRotation_90:
+ rotation = MediaSample::VideoRotation::Right;
+ std::swap(width, height);
+ break;
+ case webrtc::kVideoRotation_270:
+ rotation = MediaSample::VideoRotation::Left;
+ std::swap(width, height);
+ break;
+ }
+
+ callOnMainThread([protectedThis = makeRef(*this), sample = WTFMove(sample), width, height, rotation] {
+ protectedThis->processNewSample(sample.get(), width, height, rotation);
+ });
+}
+
+void RealtimeIncomingVideoSourceCocoa::processNewSample(CMSampleBufferRef sample, unsigned width, unsigned height, MediaSample::VideoRotation rotation)
+{
+ m_buffer = sample;
+ if (width != m_currentSettings.width() || height != m_currentSettings.height()) {
+ m_currentSettings.setWidth(width);
+ m_currentSettings.setHeight(height);
+ settingsDidChange();
+ }
+
+ videoSampleAvailable(MediaSampleAVFObjC::create(sample, rotation));
+}
+
+} // namespace WebCore
+
+#endif // USE(LIBWEBRTC)
Modified: trunk/Source/WebCore/testing/Internals.cpp (229907 => 229908)
--- trunk/Source/WebCore/testing/Internals.cpp 2018-03-23 18:06:34 UTC (rev 229907)
+++ trunk/Source/WebCore/testing/Internals.cpp 2018-03-23 18:20:47 UTC (rev 229908)
@@ -220,10 +220,6 @@
#include "MockMediaPlayerMediaSource.h"
#endif
-#if USE(LIBWEBRTC) && PLATFORM(COCOA)
-//#include "H264VideoToolboxEncoder.h"
-#endif
-
#if PLATFORM(MAC)
#include "DictionaryLookup.h"
#endif