Title: [259568] trunk/Source
Revision
259568
Author
[email protected]
Date
2020-04-06 02:57:27 -0700 (Mon, 06 Apr 2020)

Log Message

Add HEVC support in GPU Process for WebRTC
https://bugs.webkit.org/show_bug.cgi?id=209857

Reviewed by Eric Carlson.

Source/ThirdParty/libwebrtc:

* Configurations/libwebrtc.iOS.exp:
* Configurations/libwebrtc.iOSsim.exp:
* Configurations/libwebrtc.mac.exp:
* Source/webrtc/sdk/WebKit/WebKitDecoder.h: Copied from Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitUtilities.h.
* Source/webrtc/sdk/WebKit/WebKitDecoder.mm: Added.
(-[WK_RTCLocalVideoH264H265Decoder initH264DecoderWithCallback:]):
(-[WK_RTCLocalVideoH264H265Decoder initH265DecoderWithCallback:]):
(-[WK_RTCLocalVideoH264H265Decoder decodeData:size:timeStamp:]):
(-[WK_RTCLocalVideoH264H265Decoder releaseDecoder]):
(webrtc::videoDecoderCallbacks):
(webrtc::setVideoDecoderCallbacks):
(webrtc::RemoteVideoDecoder::RemoteVideoDecoder):
(webrtc::RemoteVideoDecoder::decodeComplete):
(webrtc::RemoteVideoDecoder::InitDecode):
(webrtc::RemoteVideoDecoder::Decode):
(webrtc::RemoteVideoDecoder::RegisterDecodeCompleteCallback):
(webrtc::RemoteVideoDecoder::Release):
(webrtc::RemoteVideoDecoderFactory::RemoteVideoDecoderFactory):
(webrtc::RemoteVideoDecoderFactory::GetSupportedFormats const):
(webrtc::RemoteVideoDecoderFactory::CreateVideoDecoder):
(webrtc::createWebKitDecoderFactory):
(webrtc::createLocalH264Decoder):
(webrtc::createLocalH265Decoder):
(webrtc::releaseLocalDecoder):
(webrtc::decodeFrame):
* Source/webrtc/sdk/WebKit/WebKitEncoder.mm:
(-[WK_RTCLocalVideoH264H265Encoder initWithCodecInfo:]):
(-[WK_RTCLocalVideoH264H265Encoder setCallback:]):
(-[WK_RTCLocalVideoH264H265Encoder releaseEncoder]):
(-[WK_RTCLocalVideoH264H265Encoder startEncodeWithSettings:numberOfCores:]):
(-[WK_RTCLocalVideoH264H265Encoder encode:codecSpecificInfo:frameTypes:]):
(-[WK_RTCLocalVideoH264H265Encoder setBitrate:framerate:]):
(webrtc::createLocalEncoder):
(webrtc::releaseLocalEncoder):
(webrtc::initializeLocalEncoder):
(webrtc::encodeLocalEncoderFrame):
(webrtc::setLocalEncoderRates):
* Source/webrtc/sdk/WebKit/WebKitUtilities.h:
(): Deleted.
* Source/webrtc/sdk/WebKit/WebKitUtilities.mm:
(webrtc::videoDecoderCallbacks): Deleted.
(webrtc::setVideoDecoderCallbacks): Deleted.
(webrtc::RemoteVideoDecoder::RemoteVideoDecoder): Deleted.
(webrtc::RemoteVideoDecoder::decodeComplete): Deleted.
(webrtc::RemoteVideoDecoder::InitDecode): Deleted.
(webrtc::RemoteVideoDecoder::Decode): Deleted.
(webrtc::RemoteVideoDecoder::RegisterDecodeCompleteCallback): Deleted.
(webrtc::RemoteVideoDecoder::Release): Deleted.
(webrtc::RemoteVideoDecoderFactory::RemoteVideoDecoderFactory): Deleted.
(webrtc::RemoteVideoDecoderFactory::GetSupportedFormats const): Deleted.
(webrtc::RemoteVideoDecoderFactory::CreateVideoDecoder): Deleted.
(webrtc::createWebKitDecoderFactory): Deleted.
(webrtc::createLocalDecoder): Deleted.
(webrtc::releaseLocalDecoder): Deleted.
(webrtc::decodeFrame): Deleted.
* Source/webrtc/sdk/objc/components/video_codec/RTCVideoDecoderH265.h:
* Source/webrtc/sdk/objc/components/video_codec/RTCVideoDecoderH265.mm:
(-[RTCVideoDecoderH265 decode:missingFrames:codecSpecificInfo:renderTimeMs:]):
(-[RTCVideoDecoderH265 decodeData:size:timeStamp:]):
* libwebrtc.xcodeproj/project.pbxproj:

Source/WebKit:

* GPUProcess/webrtc/LibWebRTCCodecsProxy.h:
* GPUProcess/webrtc/LibWebRTCCodecsProxy.messages.in:
* GPUProcess/webrtc/LibWebRTCCodecsProxy.mm:
(WebKit::LibWebRTCCodecsProxy::createH264Decoder):
(WebKit::LibWebRTCCodecsProxy::createH265Decoder):
(WebKit::LibWebRTCCodecsProxy::createEncoder):
(WebKit::LibWebRTCCodecsProxy::createDecoder): Deleted.
* WebProcess/GPU/webrtc/LibWebRTCCodecs.cpp:
(WebKit::createVideoDecoder):
(WebKit::createVideoEncoder):
(WebKit::LibWebRTCCodecs::createDecoder):
(WebKit::formatNameFromCodecType):
(WebKit::LibWebRTCCodecs::createEncoder):
* WebProcess/GPU/webrtc/LibWebRTCCodecs.h:

Modified Paths

Added Paths

Diff

Modified: trunk/Source/ThirdParty/libwebrtc/ChangeLog (259567 => 259568)


--- trunk/Source/ThirdParty/libwebrtc/ChangeLog	2020-04-06 08:03:17 UTC (rev 259567)
+++ trunk/Source/ThirdParty/libwebrtc/ChangeLog	2020-04-06 09:57:27 UTC (rev 259568)
@@ -1,3 +1,71 @@
+2020-04-06  youenn fablet  <[email protected]>
+
+        Add HEVC support in GPU Process for WebRTC
+        https://bugs.webkit.org/show_bug.cgi?id=209857
+
+        Reviewed by Eric Carlson.
+
+        * Configurations/libwebrtc.iOS.exp:
+        * Configurations/libwebrtc.iOSsim.exp:
+        * Configurations/libwebrtc.mac.exp:
+        * Source/webrtc/sdk/WebKit/WebKitDecoder.h: Copied from Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitUtilities.h.
+        * Source/webrtc/sdk/WebKit/WebKitDecoder.mm: Added.
+        (-[WK_RTCLocalVideoH264H265Decoder initH264DecoderWithCallback:]):
+        (-[WK_RTCLocalVideoH264H265Decoder initH265DecoderWithCallback:]):
+        (-[WK_RTCLocalVideoH264H265Decoder decodeData:size:timeStamp:]):
+        (-[WK_RTCLocalVideoH264H265Decoder releaseDecoder]):
+        (webrtc::videoDecoderCallbacks):
+        (webrtc::setVideoDecoderCallbacks):
+        (webrtc::RemoteVideoDecoder::RemoteVideoDecoder):
+        (webrtc::RemoteVideoDecoder::decodeComplete):
+        (webrtc::RemoteVideoDecoder::InitDecode):
+        (webrtc::RemoteVideoDecoder::Decode):
+        (webrtc::RemoteVideoDecoder::RegisterDecodeCompleteCallback):
+        (webrtc::RemoteVideoDecoder::Release):
+        (webrtc::RemoteVideoDecoderFactory::RemoteVideoDecoderFactory):
+        (webrtc::RemoteVideoDecoderFactory::GetSupportedFormats const):
+        (webrtc::RemoteVideoDecoderFactory::CreateVideoDecoder):
+        (webrtc::createWebKitDecoderFactory):
+        (webrtc::createLocalH264Decoder):
+        (webrtc::createLocalH265Decoder):
+        (webrtc::releaseLocalDecoder):
+        (webrtc::decodeFrame):
+        * Source/webrtc/sdk/WebKit/WebKitEncoder.mm:
+        (-[WK_RTCLocalVideoH264H265Encoder initWithCodecInfo:]):
+        (-[WK_RTCLocalVideoH264H265Encoder setCallback:]):
+        (-[WK_RTCLocalVideoH264H265Encoder releaseEncoder]):
+        (-[WK_RTCLocalVideoH264H265Encoder startEncodeWithSettings:numberOfCores:]):
+        (-[WK_RTCLocalVideoH264H265Encoder encode:codecSpecificInfo:frameTypes:]):
+        (-[WK_RTCLocalVideoH264H265Encoder setBitrate:framerate:]):
+        (webrtc::createLocalEncoder):
+        (webrtc::releaseLocalEncoder):
+        (webrtc::initializeLocalEncoder):
+        (webrtc::encodeLocalEncoderFrame):
+        (webrtc::setLocalEncoderRates):
+        * Source/webrtc/sdk/WebKit/WebKitUtilities.h:
+        (): Deleted.
+        * Source/webrtc/sdk/WebKit/WebKitUtilities.mm:
+        (webrtc::videoDecoderCallbacks): Deleted.
+        (webrtc::setVideoDecoderCallbacks): Deleted.
+        (webrtc::RemoteVideoDecoder::RemoteVideoDecoder): Deleted.
+        (webrtc::RemoteVideoDecoder::decodeComplete): Deleted.
+        (webrtc::RemoteVideoDecoder::InitDecode): Deleted.
+        (webrtc::RemoteVideoDecoder::Decode): Deleted.
+        (webrtc::RemoteVideoDecoder::RegisterDecodeCompleteCallback): Deleted.
+        (webrtc::RemoteVideoDecoder::Release): Deleted.
+        (webrtc::RemoteVideoDecoderFactory::RemoteVideoDecoderFactory): Deleted.
+        (webrtc::RemoteVideoDecoderFactory::GetSupportedFormats const): Deleted.
+        (webrtc::RemoteVideoDecoderFactory::CreateVideoDecoder): Deleted.
+        (webrtc::createWebKitDecoderFactory): Deleted.
+        (webrtc::createLocalDecoder): Deleted.
+        (webrtc::releaseLocalDecoder): Deleted.
+        (webrtc::decodeFrame): Deleted.
+        * Source/webrtc/sdk/objc/components/video_codec/RTCVideoDecoderH265.h:
+        * Source/webrtc/sdk/objc/components/video_codec/RTCVideoDecoderH265.mm:
+        (-[RTCVideoDecoderH265 decode:missingFrames:codecSpecificInfo:renderTimeMs:]):
+        (-[RTCVideoDecoderH265 decodeData:size:timeStamp:]):
+        * libwebrtc.xcodeproj/project.pbxproj:
+
 2020-04-03  David Kilzer  <[email protected]>
 
         [Xcode] Replace ASAN_OTHER_CFLAGS and ASAN_OTHER_CPLUSPLUSFLAGS with $(inherited)

Modified: trunk/Source/ThirdParty/libwebrtc/Configurations/libwebrtc.iOS.exp (259567 => 259568)


--- trunk/Source/ThirdParty/libwebrtc/Configurations/libwebrtc.iOS.exp	2020-04-06 08:03:17 UTC (rev 259567)
+++ trunk/Source/ThirdParty/libwebrtc/Configurations/libwebrtc.iOS.exp	2020-04-06 09:57:27 UTC (rev 259568)
@@ -233,7 +233,8 @@
 __ZNK6webrtc20DataChannelInterface17maxRetransmitsOptEv
 __ZNK6webrtc20RtpReceiverInterface14dtls_transportEv
 __ZNK6webrtc23RtpTransceiverInterface17codec_preferencesEv
-__ZN6webrtc18createLocalDecoderEU13block_pointerFvP10__CVBufferjjE
+__ZN6webrtc22createLocalH264DecoderEU13block_pointerFvP10__CVBufferjjE
+__ZN6webrtc22createLocalH265DecoderEU13block_pointerFvP10__CVBufferjjE
 __ZN6webrtc19releaseLocalDecoderEPv
 __ZN6webrtc11decodeFrameEPvjPKhm
 __ZN6webrtc18RemoteVideoDecoder14decodeCompleteEPvjP10__CVBufferj

Modified: trunk/Source/ThirdParty/libwebrtc/Configurations/libwebrtc.iOSsim.exp (259567 => 259568)


--- trunk/Source/ThirdParty/libwebrtc/Configurations/libwebrtc.iOSsim.exp	2020-04-06 08:03:17 UTC (rev 259567)
+++ trunk/Source/ThirdParty/libwebrtc/Configurations/libwebrtc.iOSsim.exp	2020-04-06 09:57:27 UTC (rev 259568)
@@ -233,7 +233,8 @@
 __ZNK6webrtc20DataChannelInterface17maxRetransmitsOptEv
 __ZNK6webrtc20RtpReceiverInterface14dtls_transportEv
 __ZNK6webrtc23RtpTransceiverInterface17codec_preferencesEv
-__ZN6webrtc18createLocalDecoderEU13block_pointerFvP10__CVBufferjjE
+__ZN6webrtc22createLocalH264DecoderEU13block_pointerFvP10__CVBufferjjE
+__ZN6webrtc22createLocalH265DecoderEU13block_pointerFvP10__CVBufferjjE
 __ZN6webrtc19releaseLocalDecoderEPv
 __ZN6webrtc11decodeFrameEPvjPKhm
 __ZN6webrtc18RemoteVideoDecoder14decodeCompleteEPvjP10__CVBufferj

Modified: trunk/Source/ThirdParty/libwebrtc/Configurations/libwebrtc.mac.exp (259567 => 259568)


--- trunk/Source/ThirdParty/libwebrtc/Configurations/libwebrtc.mac.exp	2020-04-06 08:03:17 UTC (rev 259567)
+++ trunk/Source/ThirdParty/libwebrtc/Configurations/libwebrtc.mac.exp	2020-04-06 09:57:27 UTC (rev 259568)
@@ -233,7 +233,8 @@
 __ZNK6webrtc20DataChannelInterface17maxRetransmitsOptEv
 __ZNK6webrtc20RtpReceiverInterface14dtls_transportEv
 __ZNK6webrtc23RtpTransceiverInterface17codec_preferencesEv
-__ZN6webrtc18createLocalDecoderEU13block_pointerFvP10__CVBufferjjE
+__ZN6webrtc22createLocalH264DecoderEU13block_pointerFvP10__CVBufferjjE
+__ZN6webrtc22createLocalH265DecoderEU13block_pointerFvP10__CVBufferjjE
 __ZN6webrtc19releaseLocalDecoderEPv
 __ZN6webrtc11decodeFrameEPvjPKhm
 __ZN6webrtc18RemoteVideoDecoder14decodeCompleteEPvjP10__CVBufferj

Copied: trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitDecoder.h (from rev 259567, trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitUtilities.h) (0 => 259568)


--- trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitDecoder.h	                        (rev 0)
+++ trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitDecoder.h	2020-04-06 09:57:27 UTC (rev 259568)
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 2020 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_decoder.h"
+#include "api/video_codecs/video_decoder_factory.h"
+
+typedef struct __CVBuffer* CVPixelBufferRef;
+
+namespace webrtc {
+
+struct SdpVideoFormat;
+
+using WebKitVideoDecoder = void*;
+using VideoDecoderCreateCallback = WebKitVideoDecoder(*)(const SdpVideoFormat& format);
+using VideoDecoderReleaseCallback = int32_t(*)(WebKitVideoDecoder);
+using VideoDecoderDecodeCallback = int32_t(*)(WebKitVideoDecoder, uint32_t timeStamp, const uint8_t*, size_t length);
+using VideoDecoderRegisterDecodeCompleteCallback = int32_t(*)(WebKitVideoDecoder, void* decodedImageCallback);
+
+void setVideoDecoderCallbacks(VideoDecoderCreateCallback, VideoDecoderReleaseCallback, VideoDecoderDecodeCallback, VideoDecoderRegisterDecodeCompleteCallback);
+
+class RemoteVideoDecoderFactory final : public VideoDecoderFactory {
+public:
+    explicit RemoteVideoDecoderFactory(std::unique_ptr<VideoDecoderFactory>&&);
+    ~RemoteVideoDecoderFactory() = default;
+
+private:
+    std::vector<SdpVideoFormat> GetSupportedFormats() const final;
+    std::unique_ptr<VideoDecoder> CreateVideoDecoder(const SdpVideoFormat& format) final;
+
+    std::unique_ptr<VideoDecoderFactory> m_internalFactory;
+};
+
+class RemoteVideoDecoder final : public webrtc::VideoDecoder {
+public:
+    explicit RemoteVideoDecoder(WebKitVideoDecoder);
+    ~RemoteVideoDecoder() = default;
+
+    static void decodeComplete(void* callback, uint32_t timeStamp, CVPixelBufferRef, uint32_t timeStampRTP);
+
+private:
+    int32_t InitDecode(const VideoCodec*, int32_t number_of_cores) final;
+    int32_t Decode(const EncodedImage&, bool missing_frames, int64_t render_time_ms) final;
+    int32_t RegisterDecodeCompleteCallback(DecodedImageCallback*) final;
+    int32_t Release() final;
+    const char* ImplementationName() const final { return "RemoteVideoToolBox"; }
+
+    WebKitVideoDecoder m_internalDecoder;
+};
+
+using LocalDecoder = void*;
+using LocalDecoderCallback = void (^)(CVPixelBufferRef, uint32_t timeStamp, uint32_t timeStampNs);
+void* createLocalH264Decoder(LocalDecoderCallback);
+void* createLocalH265Decoder(LocalDecoderCallback);
+void releaseLocalDecoder(LocalDecoder);
+int32_t decodeFrame(LocalDecoder, uint32_t timeStamp, const uint8_t*, size_t);
+
+}

Added: trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitDecoder.mm (0 => 259568)


--- trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitDecoder.mm	                        (rev 0)
+++ trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitDecoder.mm	2020-04-06 09:57:27 UTC (rev 259568)
@@ -0,0 +1,202 @@
+/*
+ * Copyright (C) 2020 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 "WebKitDecoder.h"
+
+#import "Framework/Headers/WebRTC/RTCVideoCodecFactory.h"
+#import "Framework/Headers/WebRTC/RTCVideoFrameBuffer.h"
+#import "Framework/Native/api/video_decoder_factory.h"
+#import "WebKitUtilities.h"
+#import "sdk/objc/components/video_codec/RTCVideoDecoderH264.h"
+#import "sdk/objc/components/video_codec/RTCVideoDecoderH265.h"
+
+@interface WK_RTCLocalVideoH264H265Decoder : NSObject
+- (instancetype)initH264DecoderWithCallback:(webrtc::LocalDecoderCallback)callback;
+- (instancetype)initH265DecoderWithCallback:(webrtc::LocalDecoderCallback)callback;
+- (NSInteger)decodeData:(const uint8_t *)data size:(size_t)size timeStamp:(uint32_t)timeStamp;
+- (NSInteger)releaseDecoder;
+@end
+
+@implementation WK_RTCLocalVideoH264H265Decoder {
+    RTCVideoDecoderH264 *m_h264Decoder;
+    RTCVideoDecoderH265 *m_h265Decoder;
+}
+
+- (instancetype)initH264DecoderWithCallback:(webrtc::LocalDecoderCallback)callback {
+    if (self = [super init]) {
+        m_h264Decoder = [[RTCVideoDecoderH264 alloc] init];
+        [m_h264Decoder setCallback:^(RTCVideoFrame *frame) {
+            auto *buffer = (RTCCVPixelBuffer *)frame.buffer;
+            callback(buffer.pixelBuffer, frame.timeStampNs, frame.timeStamp);
+        }];
+    }
+    return self;
+}
+
+- (instancetype)initH265DecoderWithCallback:(webrtc::LocalDecoderCallback)callback {
+    if (self = [super init]) {
+        m_h265Decoder = [[RTCVideoDecoderH265 alloc] init];
+        [m_h265Decoder setCallback:^(RTCVideoFrame *frame) {
+            auto *buffer = (RTCCVPixelBuffer *)frame.buffer;
+            callback(buffer.pixelBuffer, frame.timeStampNs, frame.timeStamp);
+        }];
+    }
+    return self;
+}
+
+- (NSInteger)decodeData:(const uint8_t *)data size:(size_t)size timeStamp:(uint32_t)timeStamp {
+    if (m_h264Decoder)
+        return [m_h264Decoder decodeData:data size:size timeStamp:timeStamp];
+    if (m_h265Decoder)
+        return [m_h265Decoder decodeData:data size:size timeStamp:timeStamp];
+    return 0;
+}
+
+- (NSInteger)releaseDecoder {
+    if (m_h264Decoder)
+        return [m_h264Decoder releaseDecoder];
+    return [m_h265Decoder releaseDecoder];
+}
+@end
+
+namespace webrtc {
+
+struct VideoDecoderCallbacks {
+    VideoDecoderCreateCallback createCallback;
+    VideoDecoderReleaseCallback releaseCallback;
+    VideoDecoderDecodeCallback decodeCallback;
+    VideoDecoderRegisterDecodeCompleteCallback registerDecodeCompleteCallback;
+};
+
+static VideoDecoderCallbacks& videoDecoderCallbacks() {
+    static VideoDecoderCallbacks callbacks;
+    return callbacks;
+}
+
+void setVideoDecoderCallbacks(VideoDecoderCreateCallback createCallback, VideoDecoderReleaseCallback releaseCallback, VideoDecoderDecodeCallback decodeCallback, VideoDecoderRegisterDecodeCompleteCallback registerDecodeCompleteCallback)
+{
+    auto& callbacks = videoDecoderCallbacks();
+    callbacks.createCallback = createCallback;
+    callbacks.releaseCallback = releaseCallback;
+    callbacks.decodeCallback = decodeCallback;
+    callbacks.registerDecodeCompleteCallback = registerDecodeCompleteCallback;
+}
+
+RemoteVideoDecoder::RemoteVideoDecoder(WebKitVideoDecoder internalDecoder)
+    : m_internalDecoder(internalDecoder)
+{
+}
+
+void RemoteVideoDecoder::decodeComplete(void* callback, uint32_t timeStamp, CVPixelBufferRef pixelBuffer, uint32_t timeStampRTP)
+{
+    auto videoFrame = VideoFrame::Builder().set_video_frame_buffer(pixelBufferToFrame(pixelBuffer))
+        .set_timestamp_rtp(timeStampRTP)
+        .set_timestamp_ms(0)
+        .set_rotation((VideoRotation)RTCVideoRotation_0)
+        .build();
+    videoFrame.set_timestamp(timeStamp);
+
+    static_cast<DecodedImageCallback*>(callback)->Decoded(videoFrame);
+}
+
+int32_t RemoteVideoDecoder::InitDecode(const VideoCodec* codec_settings, int32_t number_of_cores)
+{
+    return WEBRTC_VIDEO_CODEC_OK;
+}
+
+int32_t RemoteVideoDecoder::Decode(const EncodedImage& input_image, bool missing_frames, int64_t render_time_ms)
+{
+    return videoDecoderCallbacks().decodeCallback(m_internalDecoder, input_image.Timestamp(), input_image.data(), input_image.size());
+}
+
+int32_t RemoteVideoDecoder::RegisterDecodeCompleteCallback(DecodedImageCallback* callback)
+{
+    return videoDecoderCallbacks().registerDecodeCompleteCallback(m_internalDecoder, callback);
+}
+
+int32_t RemoteVideoDecoder::Release()
+{
+    return videoDecoderCallbacks().releaseCallback(m_internalDecoder);
+}
+
+RemoteVideoDecoderFactory::RemoteVideoDecoderFactory(std::unique_ptr<VideoDecoderFactory>&& internalFactory)
+    : m_internalFactory(std::move(internalFactory))
+{
+}
+
+std::vector<SdpVideoFormat> RemoteVideoDecoderFactory::GetSupportedFormats() const
+{
+    std::vector<SdpVideoFormat> supported_formats;
+    supported_formats.push_back(SdpVideoFormat { "H264" });
+    supported_formats.push_back(SdpVideoFormat { "H265" });
+    supported_formats.push_back(SdpVideoFormat { "VP8" });
+    return supported_formats;
+}
+
+std::unique_ptr<VideoDecoder> RemoteVideoDecoderFactory::CreateVideoDecoder(const SdpVideoFormat& format)
+{
+    if (!videoDecoderCallbacks().createCallback)
+        return m_internalFactory->CreateVideoDecoder(format);
+
+    auto identifier = videoDecoderCallbacks().createCallback(format);
+    if (!identifier)
+        return m_internalFactory->CreateVideoDecoder(format);
+
+    return std::make_unique<RemoteVideoDecoder>(identifier);
+}
+
+std::unique_ptr<webrtc::VideoDecoderFactory> createWebKitDecoderFactory(WebKitCodecSupport codecSupport)
+{
+    auto internalFactory = ObjCToNativeVideoDecoderFactory([[RTCDefaultVideoDecoderFactory alloc] initWithH265: codecSupport == WebKitCodecSupport::H264VP8AndH265]);
+    if (videoDecoderCallbacks().createCallback)
+        return std::make_unique<RemoteVideoDecoderFactory>(std::move(internalFactory));
+    return internalFactory;
+}
+
+void* createLocalH264Decoder(LocalDecoderCallback callback)
+{
+    auto decoder = [[WK_RTCLocalVideoH264H265Decoder alloc] initH264DecoderWithCallback: callback];
+    return (__bridge_retained void*)decoder;
+}
+
+void* createLocalH265Decoder(LocalDecoderCallback callback)
+{
+    auto decoder = [[WK_RTCLocalVideoH264H265Decoder alloc] initH265DecoderWithCallback: callback];
+    return (__bridge_retained void*)decoder;
+}
+
+void releaseLocalDecoder(LocalDecoder localDecoder)
+{
+    auto* decoder = (__bridge_transfer WK_RTCLocalVideoH264H265Decoder *)(localDecoder);
+    [decoder releaseDecoder];
+}
+
+int32_t decodeFrame(LocalDecoder localDecoder, uint32_t timeStamp, const uint8_t* data, size_t size)
+{
+    auto* decoder = (__bridge WK_RTCLocalVideoH264H265Decoder *)(localDecoder);
+    return [decoder decodeData: data size: size timeStamp: timeStamp];
+}
+
+}

Modified: trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitEncoder.mm (259567 => 259568)


--- trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitEncoder.mm	2020-04-06 08:03:17 UTC (rev 259567)
+++ trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitEncoder.mm	2020-04-06 09:57:27 UTC (rev 259568)
@@ -34,8 +34,64 @@
 #include "sdk/objc/api/peerconnection/RTCVideoCodecInfo+Private.h"
 #include "sdk/objc/api/peerconnection/RTCVideoEncoderSettings+Private.h"
 #include "sdk/objc/components/video_codec/RTCVideoEncoderH264.h"
+#include "sdk/objc/components/video_codec/RTCVideoEncoderH265.h"
 #include "sdk/objc/native/src/objc_frame_buffer.h"
 
+
+@interface WK_RTCLocalVideoH264H265Encoder : NSObject
+- (instancetype)initWithCodecInfo:(RTCVideoCodecInfo*)codecInfo;
+- (void)setCallback:(RTCVideoEncoderCallback)callback;
+- (NSInteger)releaseEncoder;
+- (NSInteger)startEncodeWithSettings:(RTCVideoEncoderSettings *)settings numberOfCores:(int)numberOfCores;
+- (NSInteger)encode:(RTCVideoFrame *)frame codecSpecificInfo:(nullable id<RTCCodecSpecificInfo>)info frameTypes:(NSArray<NSNumber *> *)frameTypes;
+- (int)setBitrate:(uint32_t)bitrateKbit framerate:(uint32_t)framerate;
+@end
+
+@implementation WK_RTCLocalVideoH264H265Encoder {
+    RTCVideoEncoderH264 *m_h264Encoder;
+    RTCVideoEncoderH265 *m_h265Encoder;
+}
+
+- (instancetype)initWithCodecInfo:(RTCVideoCodecInfo*)codecInfo {
+    if (self = [super init]) {
+        if ([codecInfo.name isEqualToString:@"H265"])
+            m_h265Encoder = [[RTCVideoEncoderH265 alloc] init];
+        else
+            m_h264Encoder = [[RTCVideoEncoderH264 alloc] init];
+    }
+    return self;
+}
+
+- (void)setCallback:(RTCVideoEncoderCallback)callback {
+    if (m_h264Encoder)
+        return [m_h264Encoder setCallback:callback];
+    return [m_h265Encoder setCallback:callback];
+}
+
+- (NSInteger)releaseEncoder {
+    if (m_h264Encoder)
+        return [m_h264Encoder releaseEncoder];
+    return [m_h265Encoder releaseEncoder];
+}
+
+- (NSInteger)startEncodeWithSettings:(RTCVideoEncoderSettings *)settings numberOfCores:(int)numberOfCores {
+    if (m_h264Encoder)
+        return [m_h264Encoder startEncodeWithSettings:settings numberOfCores:numberOfCores];
+    return [m_h265Encoder startEncodeWithSettings:settings numberOfCores:numberOfCores];
+}
+
+- (NSInteger)encode:(RTCVideoFrame *)frame codecSpecificInfo:(nullable id<RTCCodecSpecificInfo>)info frameTypes:(NSArray<NSNumber *> *)frameTypes {
+    if (m_h264Encoder)
+        return [m_h264Encoder encode:frame codecSpecificInfo:info frameTypes:frameTypes];
+    return [m_h265Encoder encode:frame codecSpecificInfo:info frameTypes:frameTypes];
+}
+
+- (int)setBitrate:(uint32_t)bitrateKbit framerate:(uint32_t)framerate {
+    if (m_h264Encoder)
+        return [m_h264Encoder setBitrate:bitrateKbit framerate:framerate];
+    return [m_h265Encoder setBitrate:bitrateKbit framerate:framerate];
+}
+@end
 namespace webrtc {
 
 std::unique_ptr<VideoEncoder> VideoEncoderFactoryWithSimulcast::CreateVideoEncoder(const SdpVideoFormat& format)
@@ -150,8 +206,8 @@
 void* createLocalEncoder(const webrtc::SdpVideoFormat& format, LocalEncoderCallback callback)
 {
     auto *codecInfo = [[RTCVideoCodecInfo alloc] initWithNativeSdpVideoFormat: format];
-    auto *encoder = [[RTCVideoEncoderH264 alloc] initWithCodecInfo:codecInfo];
-    
+    auto *encoder = [[WK_RTCLocalVideoH264H265Encoder alloc] initWithCodecInfo:codecInfo];
+
     [encoder setCallback:^BOOL(RTCEncodedImage *_Nonnull frame, id<RTCCodecSpecificInfo> _Nonnull codecSpecificInfo,  RTCRtpFragmentationHeader *_Nonnull header) {
         EncodedImage encodedImage = [frame nativeEncodedImage];
 
@@ -178,7 +234,7 @@
 
 void releaseLocalEncoder(LocalEncoder localEncoder)
 {
-    auto *encoder = (__bridge_transfer RTCVideoEncoderH264 *)(localEncoder);
+    auto *encoder = (__bridge_transfer WK_RTCLocalVideoH264H265Encoder *)(localEncoder);
     [encoder releaseEncoder];
 }
 
@@ -192,7 +248,7 @@
     codecSettings.minBitrate = minBitrate;
     codecSettings.maxFramerate = maxFramerate;
 
-    auto *encoder = (__bridge RTCVideoEncoderH264 *)(localEncoder);
+    auto *encoder = (__bridge WK_RTCLocalVideoH264H265Encoder *)(localEncoder);
     [encoder startEncodeWithSettings:[[RTCVideoEncoderSettings alloc] initWithNativeVideoCodec:&codecSettings] numberOfCores:1];
 }
 
@@ -203,13 +259,13 @@
         [rtcFrameTypes addObject:@(RTCFrameType(RTCFrameTypeVideoFrameKey))];
 
     auto *videoFrame = [[RTCVideoFrame alloc] initWithBuffer:ToObjCVideoFrameBuffer(pixelBufferToFrame(pixelBuffer)) rotation:RTCVideoRotation(rotation) timeStampNs:timeStamp];
-    auto *encoder = (__bridge RTCVideoEncoderH264 *)(localEncoder);
+    auto *encoder = (__bridge WK_RTCLocalVideoH264H265Encoder *)(localEncoder);
     [encoder encode:videoFrame codecSpecificInfo:nil frameTypes:rtcFrameTypes];
 }
 
 void setLocalEncoderRates(LocalEncoder localEncoder, uint32_t bitRate, uint32_t frameRate)
 {
-    auto *encoder = (__bridge RTCVideoEncoderH264 *)(localEncoder);
+    auto *encoder = (__bridge WK_RTCLocalVideoH264H265Encoder *)(localEncoder);
     [encoder setBitrate:bitRate framerate:frameRate];
 }
 

Modified: trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitUtilities.h (259567 => 259568)


--- trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitUtilities.h	2020-04-06 08:03:17 UTC (rev 259567)
+++ trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitUtilities.h	2020-04-06 09:57:27 UTC (rev 259568)
@@ -52,47 +52,4 @@
 CVPixelBufferRef pixelBufferFromFrame(const VideoFrame&, const std::function<CVPixelBufferRef(size_t, size_t)>&);
 rtc::scoped_refptr<webrtc::VideoFrameBuffer> pixelBufferToFrame(CVPixelBufferRef);
 
-using WebKitVideoDecoder = void*;
-using VideoDecoderCreateCallback = WebKitVideoDecoder(*)(const SdpVideoFormat& format);
-using VideoDecoderReleaseCallback = int32_t(*)(WebKitVideoDecoder);
-using VideoDecoderDecodeCallback = int32_t(*)(WebKitVideoDecoder, uint32_t timeStamp, const uint8_t*, size_t length);
-using VideoDecoderRegisterDecodeCompleteCallback = int32_t(*)(WebKitVideoDecoder, void* decodedImageCallback);
-
-void setVideoDecoderCallbacks(VideoDecoderCreateCallback, VideoDecoderReleaseCallback, VideoDecoderDecodeCallback, VideoDecoderRegisterDecodeCompleteCallback);
-
-class RemoteVideoDecoderFactory final : public VideoDecoderFactory {
-public:
-    explicit RemoteVideoDecoderFactory(std::unique_ptr<VideoDecoderFactory>&&);
-    ~RemoteVideoDecoderFactory() = default;
-
-private:
-    std::vector<SdpVideoFormat> GetSupportedFormats() const final;
-    std::unique_ptr<VideoDecoder> CreateVideoDecoder(const SdpVideoFormat& format) final;
-
-    std::unique_ptr<VideoDecoderFactory> m_internalFactory;
-};
-
-class RemoteVideoDecoder final : public webrtc::VideoDecoder {
-public:
-    explicit RemoteVideoDecoder(WebKitVideoDecoder);
-    ~RemoteVideoDecoder() = default;
-
-    static void decodeComplete(void* callback, uint32_t timeStamp, CVPixelBufferRef, uint32_t timeStampRTP);
-
-private:
-    int32_t InitDecode(const VideoCodec*, int32_t number_of_cores) final;
-    int32_t Decode(const EncodedImage&, bool missing_frames, int64_t render_time_ms) final;
-    int32_t RegisterDecodeCompleteCallback(DecodedImageCallback*) final;
-    int32_t Release() final;
-    const char* ImplementationName() const final { return "RemoteVideoToolBox"; }
-
-    WebKitVideoDecoder m_internalDecoder;
-};
-
-using LocalDecoder = void*;
-using LocalDecoderCallback = void (^)(CVPixelBufferRef, uint32_t timeStamp, uint32_t timeStampNs);
-void* createLocalDecoder(LocalDecoderCallback);
-void releaseLocalDecoder(LocalDecoder);
-int32_t decodeFrame(LocalDecoder, uint32_t timeStamp, const uint8_t*, size_t);
-
 }

Modified: trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitUtilities.mm (259567 => 259568)


--- trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitUtilities.mm	2020-04-06 08:03:17 UTC (rev 259567)
+++ trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitUtilities.mm	2020-04-06 09:57:27 UTC (rev 259568)
@@ -186,117 +186,4 @@
     return rtcPixelBuffer.pixelBuffer;
 }
 
-struct VideoDecoderCallbacks {
-    VideoDecoderCreateCallback createCallback;
-    VideoDecoderReleaseCallback releaseCallback;
-    VideoDecoderDecodeCallback decodeCallback;
-    VideoDecoderRegisterDecodeCompleteCallback registerDecodeCompleteCallback;
-};
-
-static VideoDecoderCallbacks& videoDecoderCallbacks() {
-    static VideoDecoderCallbacks callbacks;
-    return callbacks;
 }
-
-void setVideoDecoderCallbacks(VideoDecoderCreateCallback createCallback, VideoDecoderReleaseCallback releaseCallback, VideoDecoderDecodeCallback decodeCallback, VideoDecoderRegisterDecodeCompleteCallback registerDecodeCompleteCallback)
-{
-    auto& callbacks = videoDecoderCallbacks();
-    callbacks.createCallback = createCallback;
-    callbacks.releaseCallback = releaseCallback;
-    callbacks.decodeCallback = decodeCallback;
-    callbacks.registerDecodeCompleteCallback = registerDecodeCompleteCallback;
-}
-
-RemoteVideoDecoder::RemoteVideoDecoder(WebKitVideoDecoder internalDecoder)
-    : m_internalDecoder(internalDecoder)
-{
-}
-
-void RemoteVideoDecoder::decodeComplete(void* callback, uint32_t timeStamp, CVPixelBufferRef pixelBuffer, uint32_t timeStampRTP)
-{
-    auto videoFrame = VideoFrame::Builder().set_video_frame_buffer(pixelBufferToFrame(pixelBuffer))
-        .set_timestamp_rtp(timeStampRTP)
-        .set_timestamp_ms(0)
-        .set_rotation((VideoRotation)RTCVideoRotation_0)
-        .build();
-    videoFrame.set_timestamp(timeStamp);
-
-    static_cast<DecodedImageCallback*>(callback)->Decoded(videoFrame);
-}
-
-int32_t RemoteVideoDecoder::InitDecode(const VideoCodec* codec_settings, int32_t number_of_cores)
-{
-    return WEBRTC_VIDEO_CODEC_OK;
-}
-
-int32_t RemoteVideoDecoder::Decode(const EncodedImage& input_image, bool missing_frames, int64_t render_time_ms)
-{
-    return videoDecoderCallbacks().decodeCallback(m_internalDecoder, input_image.Timestamp(), input_image.data(), input_image.size());
-}
-
-int32_t RemoteVideoDecoder::RegisterDecodeCompleteCallback(DecodedImageCallback* callback)
-{
-    return videoDecoderCallbacks().registerDecodeCompleteCallback(m_internalDecoder, callback);
-}
-
-int32_t RemoteVideoDecoder::Release()
-{
-    return videoDecoderCallbacks().releaseCallback(m_internalDecoder);
-}
-
-RemoteVideoDecoderFactory::RemoteVideoDecoderFactory(std::unique_ptr<VideoDecoderFactory>&& internalFactory)
-    : m_internalFactory(std::move(internalFactory))
-{
-}
-
-std::vector<SdpVideoFormat> RemoteVideoDecoderFactory::GetSupportedFormats() const
-{
-    std::vector<SdpVideoFormat> supported_formats;
-    supported_formats.push_back(SdpVideoFormat { "H264" });
-    supported_formats.push_back(SdpVideoFormat { "VP8" });
-    return supported_formats;
-}
-
-std::unique_ptr<VideoDecoder> RemoteVideoDecoderFactory::CreateVideoDecoder(const SdpVideoFormat& format)
-{
-    if (!videoDecoderCallbacks().createCallback)
-        return m_internalFactory->CreateVideoDecoder(format);
-
-    auto identifier = videoDecoderCallbacks().createCallback(format);
-    if (!identifier)
-        return m_internalFactory->CreateVideoDecoder(format);
-
-    return std::make_unique<RemoteVideoDecoder>(identifier);
-}
-
-std::unique_ptr<webrtc::VideoDecoderFactory> createWebKitDecoderFactory(WebKitCodecSupport codecSupport)
-{
-    auto internalFactory = ObjCToNativeVideoDecoderFactory([[RTCDefaultVideoDecoderFactory alloc] initWithH265: codecSupport == WebKitCodecSupport::H264VP8AndH265]);
-    if (videoDecoderCallbacks().createCallback)
-        return std::make_unique<RemoteVideoDecoderFactory>(std::move(internalFactory));
-    return internalFactory;
-}
-
-void* createLocalDecoder(LocalDecoderCallback callback)
-{
-    auto decoder = [[RTCVideoDecoderH264 alloc] init];
-    [decoder setCallback:^(RTCVideoFrame *frame) {
-        auto *buffer = (RTCCVPixelBuffer *)frame.buffer;
-        callback(buffer.pixelBuffer, frame.timeStampNs, frame.timeStamp);
-    }];
-    return (__bridge_retained void*)decoder;
-}
-
-void releaseLocalDecoder(LocalDecoder localDecoder)
-{
-    RTCVideoDecoderH264* decoder = (__bridge_transfer RTCVideoDecoderH264 *)(localDecoder);
-    [decoder releaseDecoder];
-}
-
-int32_t decodeFrame(LocalDecoder localDecoder, uint32_t timeStamp, const uint8_t* data, size_t size)
-{
-    RTCVideoDecoderH264* decoder = (__bridge RTCVideoDecoderH264 *)(localDecoder);
-    return [decoder decodeData: data size: size timeStamp: timeStamp];
-}
-
-}

Modified: trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/components/video_codec/RTCVideoDecoderH265.h (259567 => 259568)


--- trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/components/video_codec/RTCVideoDecoderH265.h	2020-04-06 08:03:17 UTC (rev 259567)
+++ trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/components/video_codec/RTCVideoDecoderH265.h	2020-04-06 09:57:27 UTC (rev 259568)
@@ -16,4 +16,7 @@
 RTC_OBJC_EXPORT
 __attribute__((objc_runtime_name("WK_RTCVideoDecoderH265")))
 @interface RTCVideoDecoderH265 : NSObject <RTCVideoDecoder>
+- (NSInteger)decodeData:(const uint8_t *)data
+    size:(size_t)size
+    timeStamp:(uint32_t)timeStamp;
 @end

Modified: trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/components/video_codec/RTCVideoDecoderH265.mm (259567 => 259568)


--- trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/components/video_codec/RTCVideoDecoderH265.mm	2020-04-06 08:03:17 UTC (rev 259567)
+++ trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/components/video_codec/RTCVideoDecoderH265.mm	2020-04-06 09:57:27 UTC (rev 259568)
@@ -89,7 +89,10 @@
       codecSpecificInfo:(__nullable id<RTCCodecSpecificInfo>)info
            renderTimeMs:(int64_t)renderTimeMs {
   RTC_DCHECK(inputImage.buffer);
+  return [self decodeData: (uint8_t *)inputImage.buffer.bytes size: inputImage.buffer.length timeStamp: inputImage.timeStamp];
+}
 
+- (NSInteger)decodeData:(const uint8_t *)data size:(size_t)size timeStamp:(uint32_t)timeStamp {
   if (_error != noErr) {
     RTC_LOG(LS_WARNING) << "Last frame decode failed.";
     _error = noErr;
@@ -98,7 +101,7 @@
 
   rtc::ScopedCFTypeRef<CMVideoFormatDescriptionRef> inputFormat =
       rtc::ScopedCF(webrtc::CreateH265VideoFormatDescription(
-          (uint8_t*)inputImage.buffer.bytes, inputImage.buffer.length));
+          (uint8_t*)data, size));
   if (inputFormat) {
     CMVideoDimensions dimensions =
         CMVideoFormatDescriptionGetDimensions(inputFormat.get());
@@ -123,9 +126,10 @@
     RTC_LOG(LS_WARNING) << "Missing video format. Frame with sps/pps required.";
     return WEBRTC_VIDEO_CODEC_ERROR;
   }
+
   CMSampleBufferRef sampleBuffer = nullptr;
   if (!webrtc::H265AnnexBBufferToCMSampleBuffer(
-          (uint8_t*)inputImage.buffer.bytes, inputImage.buffer.length,
+          (uint8_t*)data, size,
           _videoFormat, &sampleBuffer)) {
     return WEBRTC_VIDEO_CODEC_ERROR;
   }
@@ -134,7 +138,7 @@
       kVTDecodeFrame_EnableAsynchronousDecompression;
   std::unique_ptr<RTCH265FrameDecodeParams> frameDecodeParams;
   frameDecodeParams.reset(
-      new RTCH265FrameDecodeParams(_callback, inputImage.timeStamp));
+      new RTCH265FrameDecodeParams(_callback, timeStamp));
   OSStatus status = VTDecompressionSessionDecodeFrame(
       _decompressionSession, sampleBuffer, decodeFlags,
       frameDecodeParams.release(), nullptr);
@@ -144,7 +148,7 @@
   if (status == kVTInvalidSessionErr &&
       [self resetDecompressionSession] == WEBRTC_VIDEO_CODEC_OK) {
     frameDecodeParams.reset(
-        new RTCH265FrameDecodeParams(_callback, inputImage.timeStamp));
+        new RTCH265FrameDecodeParams(_callback, timeStamp));
     status = VTDecompressionSessionDecodeFrame(
         _decompressionSession, sampleBuffer, decodeFlags,
         frameDecodeParams.release(), nullptr);

Modified: trunk/Source/ThirdParty/libwebrtc/libwebrtc.xcodeproj/project.pbxproj (259567 => 259568)


--- trunk/Source/ThirdParty/libwebrtc/libwebrtc.xcodeproj/project.pbxproj	2020-04-06 08:03:17 UTC (rev 259567)
+++ trunk/Source/ThirdParty/libwebrtc/libwebrtc.xcodeproj/project.pbxproj	2020-04-06 09:57:27 UTC (rev 259568)
@@ -1981,6 +1981,7 @@
 		41E84BD224373C1400D34E41 /* RTCVideoDecoderH265.mm in Sources */ = {isa = PBXBuildFile; fileRef = 41009207242E3A4500C5EDA2 /* RTCVideoDecoderH265.mm */; };
 		41E84BD324373C1A00D34E41 /* RTCVideoEncoderH265.mm in Sources */ = {isa = PBXBuildFile; fileRef = 41009206242E3A4500C5EDA2 /* RTCVideoEncoderH265.mm */; };
 		41E84BD424373C2900D34E41 /* RTCCodecSpecificInfoH265.mm in Sources */ = {isa = PBXBuildFile; fileRef = 41009208242E3A4600C5EDA2 /* RTCCodecSpecificInfoH265.mm */; };
+		41E84BD524373F7200D34E41 /* WebKitDecoder.mm in Sources */ = {isa = PBXBuildFile; fileRef = 41E84BCA2434C4A300D34E41 /* WebKitDecoder.mm */; };
 		41EA53A51EFC2C14002FF04C /* hmac.c in Sources */ = {isa = PBXBuildFile; fileRef = 41EA53A41EFC2BFD002FF04C /* hmac.c */; };
 		41EA53AB1EFC2C4D002FF04C /* digest.c in Sources */ = {isa = PBXBuildFile; fileRef = 41EA53A71EFC2C4D002FF04C /* digest.c */; };
 		41EA53AC1EFC2C4D002FF04C /* digests.c in Sources */ = {isa = PBXBuildFile; fileRef = 41EA53A81EFC2C4D002FF04C /* digests.c */; };
@@ -6135,6 +6136,8 @@
 		41E59E9323ACB6520095A94B /* system_state.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = system_state.h; sourceTree = "<group>"; };
 		41E59E9423ACC1230095A94B /* vp8_rtcd_no_acceleration.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = vp8_rtcd_no_acceleration.h; sourceTree = "<group>"; };
 		41E59E9523ACC1230095A94B /* vpx_dsp_rtcd_no_acceleration.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = vpx_dsp_rtcd_no_acceleration.h; sourceTree = "<group>"; };
+		41E84BC92434C4A200D34E41 /* WebKitDecoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebKitDecoder.h; sourceTree = "<group>"; };
+		41E84BCA2434C4A300D34E41 /* WebKitDecoder.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebKitDecoder.mm; sourceTree = "<group>"; };
 		41EA53A41EFC2BFD002FF04C /* hmac.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = hmac.c; sourceTree = "<group>"; };
 		41EA53A71EFC2C4D002FF04C /* digest.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = digest.c; sourceTree = "<group>"; };
 		41EA53A81EFC2C4D002FF04C /* digests.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = digests.c; sourceTree = "<group>"; };
@@ -9171,12 +9174,12 @@
 				416225F5216981F400A91C9B /* helpers.h */,
 				417953AC2169823D0028266B /* nalu_rewriter.cc */,
 				411521D521698220000ABAF7 /* nalu_rewriter.h */,
+				417953B2216982410028266B /* RTCCodecSpecificInfoH264+Private.h */,
 				416225F1216981F300A91C9B /* RTCCodecSpecificInfoH264.h */,
 				416225ED216981F200A91C9B /* RTCCodecSpecificInfoH264.mm */,
-				417953B2216982410028266B /* RTCCodecSpecificInfoH264+Private.h */,
+				41009203242E3A4400C5EDA2 /* RTCCodecSpecificInfoH265+Private.h */,
 				41009202242E3A4400C5EDA2 /* RTCCodecSpecificInfoH265.h */,
 				41009208242E3A4600C5EDA2 /* RTCCodecSpecificInfoH265.mm */,
-				41009203242E3A4400C5EDA2 /* RTCCodecSpecificInfoH265+Private.h */,
 				417953B3216982420028266B /* RTCDefaultVideoDecoderFactory.h */,
 				417953AD2169823E0028266B /* RTCDefaultVideoDecoderFactory.m */,
 				416225F7216981F400A91C9B /* RTCDefaultVideoEncoderFactory.h */,
@@ -9884,6 +9887,8 @@
 				41ECEAF920646663009D5141 /* EncoderUtilities.h */,
 				41ECEAFA20646663009D5141 /* VideoProcessingSoftLink.cpp */,
 				41ECEAFB20646664009D5141 /* VideoProcessingSoftLink.h */,
+				41E84BC92434C4A200D34E41 /* WebKitDecoder.h */,
+				41E84BCA2434C4A300D34E41 /* WebKitDecoder.mm */,
 				4158649623BE05E800A0A61E /* WebKitEncoder.h */,
 				4158649723BE05E900A0A61E /* WebKitEncoder.mm */,
 				41ECEABB206403C1009D5141 /* WebKitUtilities.h */,
@@ -14692,7 +14697,6 @@
 				5CD285A71E6A63430094FDC8 /* aec_state.h in Headers */,
 				5CDD85E81E43B81000621E92 /* aecm_core.h in Headers */,
 				5CDD85E91E43B81000621E92 /* aecm_defines.h in Headers */,
-				410091E7242E2AA300C5EDA2 /* rtp_format_h265.h in Headers */,
 				5C0885271E4A99D200403995 /* aes.h in Headers */,
 				5C0885241E4A99D200403995 /* aes_gcm_ossl.h in Headers */,
 				5C0885261E4A99D200403995 /* aes_icm.h in Headers */,
@@ -15032,7 +15036,6 @@
 				413A213E1FE0F0EF00373E99 /* ekt.h in Headers */,
 				5CDD8B971E43C2B500621E92 /* encode.h in Headers */,
 				5CDD87B61E43BC0500621E92 /* encode_lpc_swb.h in Headers */,
-				41009209242E3A4600C5EDA2 /* RTCVideoDecoderH265.h in Headers */,
 				5CDD8A961E43C00F00621E92 /* encode_neteq_input.h in Headers */,
 				418938D8242A69CC007FDC41 /* encode_usage_resource.h in Headers */,
 				5CDD83CD1E439A6F00621E92 /* encoded_frame.h in Headers */,
@@ -15065,7 +15068,6 @@
 				4102F6AF212732E7006AE8D7 /* expand_uma_logger.h in Headers */,
 				41BE71A6215C463700A7B196 /* expr.h in Headers */,
 				5CDD894B1E43BF3A00621E92 /* extended_jitter_report.h in Headers */,
-				410091FE242E362200C5EDA2 /* h265_vps_parser.h in Headers */,
 				5CDD894E1E43BF3A00621E92 /* extended_reports.h in Headers */,
 				4131BF46234B88200028A615 /* external_hmac.h in Headers */,
 				4131C077234B898D0028A615 /* fake_clock.h in Headers */,
@@ -15171,6 +15173,10 @@
 				4131BF96234B88A60028A615 /* h264_profile_level_id.h in Headers */,
 				5CD285EB1E6A639F0094FDC8 /* h264_sprop_parameter_sets.h in Headers */,
 				5CDD83DA1E439A6F00621E92 /* h264_sps_pps_tracker.h in Headers */,
+				410091FD242E362200C5EDA2 /* h265_common.h in Headers */,
+				410091F9242E362200C5EDA2 /* h265_sps_parser.h in Headers */,
+				410091FE242E362200C5EDA2 /* h265_vps_parser.h in Headers */,
+				410091ED242E317400C5EDA2 /* h265_vps_sps_pps_tracker.h in Headers */,
 				41FCBB7221B1FF7400A5DF27 /* hdr_metadata.h in Headers */,
 				4131C087234B898D0028A615 /* helpers.h in Headers */,
 				417953BD2169824B0028266B /* helpers.h in Headers */,
@@ -15504,7 +15510,6 @@
 				5CDD8FDE1E43CD6600621E92 /* remote_bitrate_estimator_single_stream.h in Headers */,
 				4131C4B7234C83DD0028A615 /* remote_estimate.h in Headers */,
 				5CDD8FE21E43CD6600621E92 /* remote_estimator_proxy.h in Headers */,
-				410091F9242E362200C5EDA2 /* h265_sps_parser.h in Headers */,
 				419C83C51FE247B40040C30F /* remote_ntp_time_estimator.h in Headers */,
 				4145E4DA1EF8CC9B00FCF6E6 /* render_buffer.h in Headers */,
 				5CD285D61E6A63430094FDC8 /* render_delay_buffer.h in Headers */,
@@ -15609,6 +15614,7 @@
 				413A245A1FE1991A00373E99 /* RTCFileLogger.h in Headers */,
 				413A24561FE1991A00373E99 /* RTCFileVideoCapturer.h in Headers */,
 				417953C32169824B0028266B /* RTCH264ProfileLevelId.h in Headers */,
+				4100920E242E3A4600C5EDA2 /* RTCH265ProfileLevelId.h in Headers */,
 				417953F9216984BE0028266B /* RTCI420Buffer.h in Headers */,
 				413A244E1FE1991A00373E99 /* RTCIceCandidate.h in Headers */,
 				413A245E1FE1991A00373E99 /* RTCIceServer.h in Headers */,
@@ -15637,7 +15643,6 @@
 				5CDD889E1E43BE3C00621E92 /* rtcp_sender.h in Headers */,
 				4131C4EF234C86110028A615 /* rtcp_statistics.h in Headers */,
 				419C83031FE20F020040C30F /* rtcp_transceiver.h in Headers */,
-				410091FD242E362200C5EDA2 /* h265_common.h in Headers */,
 				419C83011FE20F020040C30F /* rtcp_transceiver_config.h in Headers */,
 				419C83051FE20F020040C30F /* rtcp_transceiver_impl.h in Headers */,
 				413A243E1FE1991A00373E99 /* RTCPeerConnection.h in Headers */,
@@ -15667,6 +15672,7 @@
 				4144B3E02169A070004363AC /* RTCVideoDecoderFactory.h in Headers */,
 				417953C52169824B0028266B /* RTCVideoDecoderFactoryH264.h in Headers */,
 				417953C62169824B0028266B /* RTCVideoDecoderH264.h in Headers */,
+				41009209242E3A4600C5EDA2 /* RTCVideoDecoderH265.h in Headers */,
 				413A24651FE1991A00373E99 /* RTCVideoDecoderVP8.h in Headers */,
 				413F4D7022B0BAEF006A7A6B /* RTCVideoDecoderVP8.h in Headers */,
 				413A24601FE1991A00373E99 /* RTCVideoDecoderVP9.h in Headers */,
@@ -15683,7 +15689,6 @@
 				413A244F1FE1991A00373E99 /* RTCVideoFrame.h in Headers */,
 				413E678F216987DB00EF37ED /* RTCVideoFrame.h in Headers */,
 				413E6791216987DB00EF37ED /* RTCVideoFrameBuffer.h in Headers */,
-				410091ED242E317400C5EDA2 /* h265_vps_sps_pps_tracker.h in Headers */,
 				413A24411FE1991A00373E99 /* RTCVideoFrameBuffer.h in Headers */,
 				413A246F1FE1991A00373E99 /* RTCVideoRenderer.h in Headers */,
 				413A24611FE1991A00373E99 /* RTCVideoSource.h in Headers */,
@@ -15702,6 +15707,7 @@
 				5CDD8AB71E43C00F00621E92 /* rtp_file_source.h in Headers */,
 				5CDD88B11E43BE3C00621E92 /* rtp_format.h in Headers */,
 				5CDD88A51E43BE3C00621E92 /* rtp_format_h264.h in Headers */,
+				410091E7242E2AA300C5EDA2 /* rtp_format_h265.h in Headers */,
 				5CDD88A71E43BE3C00621E92 /* rtp_format_video_generic.h in Headers */,
 				5CDD88AC1E43BE3C00621E92 /* rtp_format_vp8.h in Headers */,
 				5CDD88AF1E43BE3C00621E92 /* rtp_format_vp9.h in Headers */,
@@ -16022,7 +16028,6 @@
 				410091DE242E0BBC00C5EDA2 /* video_frame_type.h in Headers */,
 				4102F6CF212733B7006AE8D7 /* video_quality_observer.h in Headers */,
 				419C82C41FE20DCD0040C30F /* video_receive_stream.h in Headers */,
-				4100920E242E3A4600C5EDA2 /* RTCH265ProfileLevelId.h in Headers */,
 				5CDD85CB1E43B5C000621E92 /* video_receive_stream.h in Headers */,
 				41893A17242A757A007FDC41 /* video_receiver2.h in Headers */,
 				5C4B4C211E431F75002651C8 /* video_render_frames.h in Headers */,
@@ -17420,7 +17425,6 @@
 				5CDD8B721E43C2B500621E92 /* augmented_cb_corr.c in Sources */,
 				5CDD86401E43B8B500621E92 /* auto_corr_to_refl_coef.c in Sources */,
 				5CDD86411E43B8B500621E92 /* auto_correlation.c in Sources */,
-				41E84BD324373C1A00D34E41 /* RTCVideoEncoderH265.mm in Sources */,
 				4131C405234C7B7E0028A615 /* auto_correlation.cc in Sources */,
 				5CDD8A071E43BFB300621E92 /* background_noise.cc in Sources */,
 				41A08BC8212695DE001D5D7B /* bad_optional_access.cc in Sources */,
@@ -17598,7 +17602,6 @@
 				5CD285C01E6A63430094FDC8 /* echo_remover.cc in Sources */,
 				5CD285BE1E6A63430094FDC8 /* echo_remover_metrics.cc in Sources */,
 				5CDD8B961E43C2B500621E92 /* encode.c in Sources */,
-				41E84BD224373C1400D34E41 /* RTCVideoDecoderH265.mm in Sources */,
 				5CDD87B71E43BC0500621E92 /* encode.c in Sources */,
 				41433D121F79B33400387B4D /* encode.c in Sources */,
 				5CDD87B51E43BC0500621E92 /* encode_lpc_swb.c in Sources */,
@@ -17723,6 +17726,11 @@
 				4131BF98234B88A60028A615 /* h264_profile_level_id.cc in Sources */,
 				5CD285EA1E6A639F0094FDC8 /* h264_sprop_parameter_sets.cc in Sources */,
 				5CDD83D91E439A6F00621E92 /* h264_sps_pps_tracker.cc in Sources */,
+				410091FF242E362200C5EDA2 /* h265_common.cc in Sources */,
+				41E84BCE24373BDE00D34E41 /* h265_pps_parser.cc in Sources */,
+				41E84BCF24373BE200D34E41 /* h265_sps_parser.cc in Sources */,
+				41E84BD024373BE600D34E41 /* h265_vps_parser.cc in Sources */,
+				41E84BD124373C0700D34E41 /* h265_vps_sps_pps_tracker.cc in Sources */,
 				41FCBB7121B1FF7400A5DF27 /* hdr_metadata.cc in Sources */,
 				4131C068234B898D0028A615 /* helpers.cc in Sources */,
 				417953BC2169824B0028266B /* helpers.cc in Sources */,
@@ -17761,7 +17769,6 @@
 				4131C285234B8CC40028A615 /* internal_encoder_factory.cc in Sources */,
 				5CDD8BBF1E43C2B500621E92 /* interpolate.c in Sources */,
 				5CDD8BBD1E43C2B500621E92 /* interpolate_samples.c in Sources */,
-				41E84BD424373C2900D34E41 /* RTCCodecSpecificInfoH265.mm in Sources */,
 				415F1FB221272FBA00064CBF /* interpolated_gain_curve.cc in Sources */,
 				419C829A1FE20CA10040C30F /* interval_budget.cc in Sources */,
 				5CDD87C01E43BC0500621E92 /* intialize.c in Sources */,
@@ -17791,7 +17798,6 @@
 				41294094212E128D00AD95E7 /* libvpx_vp8_decoder.cc in Sources */,
 				41294092212E128D00AD95E7 /* libvpx_vp8_encoder.cc in Sources */,
 				416D3BE6212731C200775F09 /* limiter.cc in Sources */,
-				41E84BCF24373BE200D34E41 /* h265_sps_parser.cc in Sources */,
 				4131C4C5234C84520028A615 /* link_capacity_estimator.cc in Sources */,
 				4131BF4A234B88200028A615 /* local_audio_source.cc in Sources */,
 				4131C069234B898D0028A615 /* location.cc in Sources */,
@@ -17807,7 +17813,6 @@
 				5CDD87C51E43BC0500621E92 /* lpc_analysis.c in Sources */,
 				5CDD8BC11E43C2B500621E92 /* lpc_encode.c in Sources */,
 				5CDD87C71E43BC0500621E92 /* lpc_gain_swb_tables.c in Sources */,
-				410091E6242E2AA300C5EDA2 /* rtp_format_h265.cc in Sources */,
 				41433CEE1F79B33400387B4D /* lpc_masking_model.c in Sources */,
 				5CDD87C91E43BC0500621E92 /* lpc_shape_swb12_tables.c in Sources */,
 				5CDD87CB1E43BC0500621E92 /* lpc_shape_swb16_tables.c in Sources */,
@@ -17836,7 +17841,6 @@
 				4131BF18234B88200028A615 /* media_stream.cc in Sources */,
 				4131C315234B8DC20028A615 /* media_stream_interface.cc in Sources */,
 				4131BF25234B88200028A615 /* media_stream_observer.cc in Sources */,
-				41E84BD024373BE600D34E41 /* h265_vps_parser.cc in Sources */,
 				418939F7242A74F8007FDC41 /* media_transport_config.cc in Sources */,
 				418939F6242A74F8007FDC41 /* media_transport_interface.cc in Sources */,
 				4131C2F7234B8DC20028A615 /* media_types.cc in Sources */,
@@ -17905,7 +17909,6 @@
 				418938E0242A69CC007FDC41 /* overuse_frame_detector.cc in Sources */,
 				4131C1B5234B8A4A0028A615 /* p2p_constants.cc in Sources */,
 				4131C1D4234B8A4B0028A615 /* p2p_transport_channel.cc in Sources */,
-				41E84BD124373C0700D34E41 /* h265_vps_sps_pps_tracker.cc in Sources */,
 				41F2639A21267F5E00274F59 /* pa_ringbuffer.c in Sources */,
 				5CDD8FA21E43CCBE00621E92 /* paced_sender.cc in Sources */,
 				4131C4C1234C84240028A615 /* pacing_controller.cc in Sources */,
@@ -18082,6 +18085,7 @@
 				4131BF33234B88200028A615 /* rtc_stats_traversal.cc in Sources */,
 				419C841D1FE24AEF0040C30F /* rtc_stream_config.cc in Sources */,
 				417953CC216982DB0028266B /* RTCCodecSpecificInfoH264.mm in Sources */,
+				41E84BD424373C2900D34E41 /* RTCCodecSpecificInfoH265.mm in Sources */,
 				413E678B216987B900EF37ED /* RTCCVPixelBuffer.mm in Sources */,
 				417953B5216982420028266B /* RTCDefaultVideoDecoderFactory.m in Sources */,
 				417953B7216982420028266B /* RTCDefaultVideoEncoderFactory.m in Sources */,
@@ -18088,6 +18092,7 @@
 				4144B3F5216B081B004363AC /* RTCEncodedImage+Private.mm in Sources */,
 				417953FA216984BE0028266B /* RTCEncodedImage.m in Sources */,
 				4144B3D621698A1A004363AC /* RTCH264ProfileLevelId.mm in Sources */,
+				4100920A242E3A4600C5EDA2 /* RTCH265ProfileLevelId.mm in Sources */,
 				4144B3D32169896D004363AC /* RTCNativeI420Buffer.mm in Sources */,
 				4144B3D121698967004363AC /* RTCNativeMutableI420Buffer.mm in Sources */,
 				419C82B91FE20DCD0040C30F /* rtcp_demuxer.cc in Sources */,
@@ -18107,11 +18112,12 @@
 				4144B3E82169C5E3004363AC /* RTCVideoCodecInfo+Private.mm in Sources */,
 				413E67982169883900EF37ED /* RTCVideoCodecInfo.m in Sources */,
 				417953B8216982420028266B /* RTCVideoDecoderFactoryH264.m in Sources */,
-				41E84BCE24373BDE00D34E41 /* h265_pps_parser.cc in Sources */,
 				417953C72169824B0028266B /* RTCVideoDecoderH264.mm in Sources */,
+				41E84BD224373C1400D34E41 /* RTCVideoDecoderH265.mm in Sources */,
 				413E67682169854B00EF37ED /* RTCVideoDecoderVP8.mm in Sources */,
 				417953B9216982420028266B /* RTCVideoEncoderFactoryH264.m in Sources */,
 				417953CA2169824B0028266B /* RTCVideoEncoderH264.mm in Sources */,
+				41E84BD324373C1A00D34E41 /* RTCVideoEncoderH265.mm in Sources */,
 				413E67A32169889500EF37ED /* RTCVideoEncoderQpThresholds.m in Sources */,
 				4144B3F7216B09CB004363AC /* RTCVideoEncoderSettings+Private.mm in Sources */,
 				4131C565234C95610028A615 /* RTCVideoEncoderSettings.m in Sources */,
@@ -18129,6 +18135,7 @@
 				4189391E242A704E007FDC41 /* rtp_descriptor_authentication.cc in Sources */,
 				5CDD88B01E43BE3C00621E92 /* rtp_format.cc in Sources */,
 				5CDD88A41E43BE3C00621E92 /* rtp_format_h264.cc in Sources */,
+				410091E6242E2AA300C5EDA2 /* rtp_format_h265.cc in Sources */,
 				5CDD88A61E43BE3C00621E92 /* rtp_format_video_generic.cc in Sources */,
 				5CDD88AB1E43BE3C00621E92 /* rtp_format_vp8.cc in Sources */,
 				5CDD88AE1E43BE3C00621E92 /* rtp_format_vp9.cc in Sources */,
@@ -18311,7 +18318,6 @@
 				419241E221275A3000634FCF /* time_delta.cc in Sources */,
 				5CDD8A5A1E43BFB300621E92 /* time_stretch.cc in Sources */,
 				5CDD88DA1E43BE3D00621E92 /* time_util.cc in Sources */,
-				4100920A242E3A4600C5EDA2 /* RTCH265ProfileLevelId.mm in Sources */,
 				4131C14A234B89E20028A615 /* time_utils.cc in Sources */,
 				419241E321275A3000634FCF /* timestamp.cc in Sources */,
 				4131C133234B89E20028A615 /* timestamp_aligner.cc in Sources */,
@@ -18430,6 +18436,7 @@
 				5C4B4C801E431F9C002651C8 /* wav_file.cc in Sources */,
 				5C4B4C831E431F9C002651C8 /* wav_header.cc in Sources */,
 				4131C0F9234B89E20028A615 /* weak_ptr.cc in Sources */,
+				41E84BD524373F7200D34E41 /* WebKitDecoder.mm in Sources */,
 				4158649923BE05E900A0A61E /* WebKitEncoder.mm in Sources */,
 				41ECEABE20640498009D5141 /* WebKitUtilities.mm in Sources */,
 				5CDD8CAA1E43C6F700621E92 /* webrtc_cng.cc in Sources */,
@@ -18436,7 +18443,6 @@
 				5CDD83671E4325D500621E92 /* webrtc_libyuv.cc in Sources */,
 				4131C27A234B8CC40028A615 /* webrtc_media_engine.cc in Sources */,
 				4131C278234B8CC40028A615 /* webrtc_media_engine_defaults.cc in Sources */,
-				410091FF242E362200C5EDA2 /* h265_common.cc in Sources */,
 				4131BF50234B88200028A615 /* webrtc_sdp.cc in Sources */,
 				4131BEF4234B88200028A615 /* webrtc_session_description_factory.cc in Sources */,
 				5CDD86E41E43BA2800621E92 /* webrtc_vad.c in Sources */,

Modified: trunk/Source/WebKit/ChangeLog (259567 => 259568)


--- trunk/Source/WebKit/ChangeLog	2020-04-06 08:03:17 UTC (rev 259567)
+++ trunk/Source/WebKit/ChangeLog	2020-04-06 09:57:27 UTC (rev 259568)
@@ -1,3 +1,25 @@
+2020-04-06  youenn fablet  <[email protected]>
+
+        Add HEVC support in GPU Process for WebRTC
+        https://bugs.webkit.org/show_bug.cgi?id=209857
+
+        Reviewed by Eric Carlson.
+
+        * GPUProcess/webrtc/LibWebRTCCodecsProxy.h:
+        * GPUProcess/webrtc/LibWebRTCCodecsProxy.messages.in:
+        * GPUProcess/webrtc/LibWebRTCCodecsProxy.mm:
+        (WebKit::LibWebRTCCodecsProxy::createH264Decoder):
+        (WebKit::LibWebRTCCodecsProxy::createH265Decoder):
+        (WebKit::LibWebRTCCodecsProxy::createEncoder):
+        (WebKit::LibWebRTCCodecsProxy::createDecoder): Deleted.
+        * WebProcess/GPU/webrtc/LibWebRTCCodecs.cpp:
+        (WebKit::createVideoDecoder):
+        (WebKit::createVideoEncoder):
+        (WebKit::LibWebRTCCodecs::createDecoder):
+        (WebKit::formatNameFromCodecType):
+        (WebKit::LibWebRTCCodecs::createEncoder):
+        * WebProcess/GPU/webrtc/LibWebRTCCodecs.h:
+
 2020-04-05  Don Olmstead  <[email protected]>
 
         [CMake] Add WebKit::WebKit target

Modified: trunk/Source/WebKit/GPUProcess/webrtc/LibWebRTCCodecsProxy.h (259567 => 259568)


--- trunk/Source/WebKit/GPUProcess/webrtc/LibWebRTCCodecsProxy.h	2020-04-06 08:03:17 UTC (rev 259567)
+++ trunk/Source/WebKit/GPUProcess/webrtc/LibWebRTCCodecsProxy.h	2020-04-06 09:57:27 UTC (rev 259568)
@@ -62,11 +62,12 @@
 private:
     // IPC::MessageReceiver
     void didReceiveMessage(IPC::Connection&, IPC::Decoder&) final;
-    void createDecoder(RTCDecoderIdentifier);
+    void createH264Decoder(RTCDecoderIdentifier);
+    void createH265Decoder(RTCDecoderIdentifier);
     void releaseDecoder(RTCDecoderIdentifier);
     void decodeFrame(RTCDecoderIdentifier, uint32_t timeStamp, const IPC::DataReference&);
 
-    void createEncoder(RTCEncoderIdentifier, const Vector<std::pair<String, String>>&);
+    void createEncoder(RTCEncoderIdentifier, const String&, const Vector<std::pair<String, String>>&);
     void releaseEncoder(RTCEncoderIdentifier);
     void initializeEncoder(RTCEncoderIdentifier, uint16_t width, uint16_t height, unsigned startBitrate, unsigned maxBitrate, unsigned minBitrate, uint32_t maxFramerate);
     void encodeFrame(RTCEncoderIdentifier, WebCore::RemoteVideoSample&&, bool shouldEncodeAsKeyFrame);

Modified: trunk/Source/WebKit/GPUProcess/webrtc/LibWebRTCCodecsProxy.messages.in (259567 => 259568)


--- trunk/Source/WebKit/GPUProcess/webrtc/LibWebRTCCodecsProxy.messages.in	2020-04-06 08:03:17 UTC (rev 259567)
+++ trunk/Source/WebKit/GPUProcess/webrtc/LibWebRTCCodecsProxy.messages.in	2020-04-06 09:57:27 UTC (rev 259568)
@@ -24,11 +24,12 @@
 #if USE(LIBWEBRTC) && PLATFORM(COCOA) && ENABLE(GPU_PROCESS)
 
 messages -> LibWebRTCCodecsProxy NotRefCounted {
-    CreateDecoder(WebKit::RTCDecoderIdentifier id)
+    CreateH264Decoder(WebKit::RTCDecoderIdentifier id)
+    CreateH265Decoder(WebKit::RTCDecoderIdentifier id)
     ReleaseDecoder(WebKit::RTCDecoderIdentifier id)
     DecodeFrame(WebKit::RTCDecoderIdentifier id, uint32_t timeStamp, IPC::DataReference data)
 
-    CreateEncoder(WebKit::RTCEncoderIdentifier id, Vector<std::pair<String, String>> parameters);
+    CreateEncoder(WebKit::RTCEncoderIdentifier id, String formatName, Vector<std::pair<String, String>> parameters);
     ReleaseEncoder(WebKit::RTCEncoderIdentifier id)
     InitializeEncoder(WebKit::RTCEncoderIdentifier id, uint16_t width, uint16_t height, unsigned startBitrate, unsigned maxBitrate, unsigned minBitrate, uint32_t maxFramerate)
     EncodeFrame(WebKit::RTCEncoderIdentifier id, WebCore::RemoteVideoSample sample, bool shouldEncodeAsKeyFrame)

Modified: trunk/Source/WebKit/GPUProcess/webrtc/LibWebRTCCodecsProxy.mm (259567 => 259568)


--- trunk/Source/WebKit/GPUProcess/webrtc/LibWebRTCCodecsProxy.mm	2020-04-06 08:03:17 UTC (rev 259567)
+++ trunk/Source/WebKit/GPUProcess/webrtc/LibWebRTCCodecsProxy.mm	2020-04-06 09:57:27 UTC (rev 259568)
@@ -34,8 +34,8 @@
 #include "WebCoreArgumentCoders.h"
 #include <WebCore/LibWebRTCMacros.h>
 #include <WebCore/RemoteVideoSample.h>
+#include <webrtc/sdk/WebKit/WebKitDecoder.h>
 #include <webrtc/sdk/WebKit/WebKitEncoder.h>
-#include <webrtc/sdk/WebKit/WebKitUtilities.h>
 #include <wtf/MediaTime.h>
 
 namespace WebKit {
@@ -53,15 +53,24 @@
         webrtc::releaseLocalEncoder(encoder);
 }
 
-void LibWebRTCCodecsProxy::createDecoder(RTCDecoderIdentifier identifier)
+void LibWebRTCCodecsProxy::createH264Decoder(RTCDecoderIdentifier identifier)
 {
     ASSERT(!m_decoders.contains(identifier));
-    m_decoders.add(identifier, webrtc::createLocalDecoder(^(CVPixelBufferRef pixelBuffer, uint32_t timeStampNs, uint32_t timeStamp) {
+    m_decoders.add(identifier, webrtc::createLocalH264Decoder(^(CVPixelBufferRef pixelBuffer, uint32_t timeStampNs, uint32_t timeStamp) {
         if (auto sample = WebCore::RemoteVideoSample::create(pixelBuffer, MediaTime(timeStampNs, 1)))
             m_gpuConnectionToWebProcess.connection().send(Messages::LibWebRTCCodecs::CompletedDecoding { identifier, timeStamp, *sample }, 0);
     }));
 }
 
+void LibWebRTCCodecsProxy::createH265Decoder(RTCDecoderIdentifier identifier)
+{
+    ASSERT(!m_decoders.contains(identifier));
+    m_decoders.add(identifier, webrtc::createLocalH265Decoder(^(CVPixelBufferRef pixelBuffer, uint32_t timeStampNs, uint32_t timeStamp) {
+        if (auto sample = WebCore::RemoteVideoSample::create(pixelBuffer, MediaTime(timeStampNs, 1)))
+            m_gpuConnectionToWebProcess.connection().send(Messages::LibWebRTCCodecs::CompletedDecoding { identifier, timeStamp, *sample }, 0);
+    }));
+}
+
 void LibWebRTCCodecsProxy::releaseDecoder(RTCDecoderIdentifier identifier)
 {
     ASSERT(m_decoders.contains(identifier));
@@ -80,7 +89,7 @@
         m_gpuConnectionToWebProcess.connection().send(Messages::LibWebRTCCodecs::FailedDecoding { identifier }, 0);
 }
 
-void LibWebRTCCodecsProxy::createEncoder(RTCEncoderIdentifier identifier, const Vector<std::pair<String, String>>& parameters)
+void LibWebRTCCodecsProxy::createEncoder(RTCEncoderIdentifier identifier, const String& formatName, const Vector<std::pair<String, String>>& parameters)
 {
     ASSERT(!m_encoders.contains(identifier));
 
@@ -88,7 +97,7 @@
     for (auto& parameter : parameters)
         rtcParameters.emplace(parameter.first.utf8().data(), parameter.second.utf8().data());
     
-    m_encoders.add(identifier, webrtc::createLocalEncoder(webrtc::SdpVideoFormat { "H264", rtcParameters }, ^(const uint8_t* buffer, size_t size, const webrtc::WebKitEncodedFrameInfo& info, webrtc::RTPFragmentationHeader* header) {
+    m_encoders.add(identifier, webrtc::createLocalEncoder(webrtc::SdpVideoFormat { formatName.utf8().data(), rtcParameters }, ^(const uint8_t* buffer, size_t size, const webrtc::WebKitEncodedFrameInfo& info, webrtc::RTPFragmentationHeader* header) {
         
         m_gpuConnectionToWebProcess.connection().send(Messages::LibWebRTCCodecs::CompletedEncoding { identifier, IPC::DataReference { buffer, size }, info, webrtc::WebKitRTPFragmentationHeader { header } }, 0);
     }));

Modified: trunk/Source/WebKit/WebProcess/GPU/webrtc/LibWebRTCCodecs.cpp (259567 => 259568)


--- trunk/Source/WebKit/WebProcess/GPU/webrtc/LibWebRTCCodecs.cpp	2020-04-06 08:03:17 UTC (rev 259567)
+++ trunk/Source/WebKit/WebProcess/GPU/webrtc/LibWebRTCCodecs.cpp	2020-04-06 09:57:27 UTC (rev 259568)
@@ -35,20 +35,25 @@
 #include <WebCore/LibWebRTCMacros.h>
 #include <WebCore/RealtimeVideoUtilities.h>
 #include <WebCore/RemoteVideoSample.h>
-#include <pal/cf/CoreMediaSoftLink.h>
+#include <webrtc/sdk/WebKit/WebKitDecoder.h>
 #include <webrtc/sdk/WebKit/WebKitEncoder.h>
 #include <webrtc/sdk/WebKit/WebKitUtilities.h>
 #include <wtf/MainThread.h>
 
+#include <pal/cf/CoreMediaSoftLink.h>
+
 namespace WebKit {
 using namespace WebCore;
 
 static webrtc::WebKitVideoDecoder createVideoDecoder(const webrtc::SdpVideoFormat& format)
 {
-    if (format.name != "H264")
-        return nullptr;
+    if (format.name == "H264")
+        return WebProcess::singleton().libWebRTCCodecs().createDecoder(LibWebRTCCodecs::Type::H264);
 
-    return WebProcess::singleton().libWebRTCCodecs().createDecoder();
+    if (format.name == "H265")
+        return WebProcess::singleton().libWebRTCCodecs().createDecoder(LibWebRTCCodecs::Type::H265);
+
+    return nullptr;
 }
 
 static int32_t releaseVideoDecoder(webrtc::WebKitVideoDecoder decoder)
@@ -69,10 +74,13 @@
 
 static webrtc::WebKitVideoEncoder createVideoEncoder(const webrtc::SdpVideoFormat& format)
 {
-    if (format.name != "H264")
-        return nullptr;
+    if (format.name == "H264")
+        return WebProcess::singleton().libWebRTCCodecs().createEncoder(LibWebRTCCodecs::Type::H264, format.parameters);
 
-    return WebProcess::singleton().libWebRTCCodecs().createEncoder(format.parameters);
+    if (format.name == "H265")
+        return WebProcess::singleton().libWebRTCCodecs().createEncoder(LibWebRTCCodecs::Type::H265, format.parameters);
+
+    return nullptr;
 }
 
 static int32_t releaseVideoEncoder(webrtc::WebKitVideoEncoder encoder)
@@ -148,17 +156,24 @@
     webrtc::setVideoEncoderCallbacks(createVideoEncoder, releaseVideoEncoder, initializeVideoEncoder, encodeVideoFrame, registerEncodeCompleteCallback, setEncodeRatesCallback);
 }
 
-LibWebRTCCodecs::Decoder* LibWebRTCCodecs::createDecoder()
+LibWebRTCCodecs::Decoder* LibWebRTCCodecs::createDecoder(Type type)
 {
     auto decoder = makeUnique<Decoder>();
     auto* result = decoder.get();
     decoder->identifier = RTCDecoderIdentifier::generateThreadSafe();
 
-    callOnMainRunLoop([this, decoder = WTFMove(decoder)]() mutable {
+    callOnMainRunLoop([this, decoder = WTFMove(decoder), type]() mutable {
         decoder->connection = &WebProcess::singleton().ensureGPUProcessConnection().connection();
 
         auto decoderIdentifier = decoder->identifier;
-        decoder->connection->send(Messages::LibWebRTCCodecsProxy::CreateDecoder { decoderIdentifier }, 0);
+        switch (type) {
+        case Type::H264:
+            decoder->connection->send(Messages::LibWebRTCCodecsProxy::CreateH264Decoder { decoderIdentifier }, 0);
+            break;
+        case Type::H265:
+            decoder->connection->send(Messages::LibWebRTCCodecsProxy::CreateH265Decoder { decoderIdentifier }, 0);
+            break;
+        }
 
         ASSERT(!m_decoders.contains(decoderIdentifier));
         m_decoders.add(decoderIdentifier, WTFMove(decoder));
@@ -238,8 +253,18 @@
     webrtc::RemoteVideoDecoder::decodeComplete(decoder->decodedImageCallback, timeStamp, pixelBuffer.get(), remoteSample.time().toDouble());
 }
 
-LibWebRTCCodecs::Encoder* LibWebRTCCodecs::createEncoder(const std::map<std::string, std::string>& formatParameters)
+static inline String formatNameFromCodecType(LibWebRTCCodecs::Type type)
 {
+    switch (type) {
+    case LibWebRTCCodecs::Type::H264:
+        return "H264"_s;
+    case LibWebRTCCodecs::Type::H265:
+        return "H265"_s;
+    }
+}
+
+LibWebRTCCodecs::Encoder* LibWebRTCCodecs::createEncoder(Type type, const std::map<std::string, std::string>& formatParameters)
+{
     auto encoder = makeUnique<Encoder>();
     auto* result = encoder.get();
     encoder->identifier = RTCEncoderIdentifier::generateThreadSafe();
@@ -248,11 +273,11 @@
     for (auto& keyValue : formatParameters)
         parameters.append(std::make_pair(String::fromUTF8(keyValue.first.data(), keyValue.first.length()), String::fromUTF8(keyValue.second.data(), keyValue.second.length())));
 
-    callOnMainRunLoop([this, encoder = WTFMove(encoder), parameters = WTFMove(parameters)]() mutable {
+    callOnMainRunLoop([this, encoder = WTFMove(encoder), type, parameters = WTFMove(parameters)]() mutable {
         auto encoderIdentifier = encoder->identifier;
         ASSERT(!m_encoders.contains(encoderIdentifier));
 
-        WebProcess::singleton().ensureGPUProcessConnection().connection().send(Messages::LibWebRTCCodecsProxy::CreateEncoder { encoderIdentifier, parameters }, 0);
+        WebProcess::singleton().ensureGPUProcessConnection().connection().send(Messages::LibWebRTCCodecsProxy::CreateEncoder { encoderIdentifier, formatNameFromCodecType(type), parameters }, 0);
         m_encoders.add(encoderIdentifier, WTFMove(encoder));
     });
     return result;

Modified: trunk/Source/WebKit/WebProcess/GPU/webrtc/LibWebRTCCodecs.h (259567 => 259568)


--- trunk/Source/WebKit/WebProcess/GPU/webrtc/LibWebRTCCodecs.h	2020-04-06 08:03:17 UTC (rev 259567)
+++ trunk/Source/WebKit/WebProcess/GPU/webrtc/LibWebRTCCodecs.h	2020-04-06 09:57:27 UTC (rev 259568)
@@ -72,7 +72,8 @@
         RefPtr<IPC::Connection> connection;
     };
 
-    Decoder* createDecoder();
+    enum class Type { H264, H265 };
+    Decoder* createDecoder(Type);
     int32_t releaseDecoder(Decoder&);
     int32_t decodeFrame(Decoder&, uint32_t timeStamp, const uint8_t*, size_t);
     void registerDecodeFrameCallback(Decoder&, void* decodedImageCallback);
@@ -86,7 +87,7 @@
         RefPtr<IPC::Connection> connection;
     };
 
-    Encoder* createEncoder(const std::map<std::string, std::string>&);
+    Encoder* createEncoder(Type, const std::map<std::string, std::string>&);
     int32_t releaseEncoder(Encoder&);
     int32_t initializeEncoder(Encoder&, uint16_t width, uint16_t height, unsigned startBitrate, unsigned maxBitrate, unsigned minBitrate, uint32_t maxFramerate);
     int32_t encodeFrame(Encoder&, const WebCore::RemoteVideoSample&, bool shouldEncodeAsKeyFrame);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to