Skip to content

Commit

Permalink
Add abstract decoder support in LibWebRTCCodecsProxy
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=248753
rdar://problem/102976377

Reviewed by Eric Carlson.

Add WebRTCVideoDecoder interface to allow moving WebRTC decoders from libwebrtc to WebCore.
This is better to do this since we are now using these decoders for WebCodecs.
Add a specific class to wrap existing libwebrtc decoders with the new interface.

* Source/WebCore/PAL/pal/cf/CoreMediaSoftLink.cpp:
* Source/WebCore/PAL/pal/cf/CoreMediaSoftLink.h:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/platform/mediastream/cocoa/WebRTCVideoDecoder.h: Added.
* Source/WebCore/platform/mediastream/cocoa/WebRTCVideoDecoder.mm: Added.
(WebCore::WebRTCVideoDecoder::createFromLocalDecoder):
* Source/WebKit/GPUProcess/webrtc/LibWebRTCCodecsProxy.h:
* Source/WebKit/GPUProcess/webrtc/LibWebRTCCodecsProxy.mm:
(WebKit::LibWebRTCCodecsProxy::stopListeningForIPC):
(WebKit::LibWebRTCCodecsProxy::createLocalDecoder):
(WebKit::LibWebRTCCodecsProxy::createDecoder):
(WebKit::LibWebRTCCodecsProxy::releaseDecoder):
(WebKit::LibWebRTCCodecsProxy::flushDecoder):
(WebKit::LibWebRTCCodecsProxy::setDecoderFormatDescription):
* Source/WebKit/WebProcess/GPU/webrtc/LibWebRTCCodecs.cpp:

Canonical link: https://commits.webkit.org/257463@main
  • Loading branch information
youennf committed Dec 7, 2022
1 parent c3cabf5 commit 0a22679
Show file tree
Hide file tree
Showing 8 changed files with 182 additions and 15 deletions.
1 change: 1 addition & 0 deletions Source/WebCore/PAL/pal/cf/CoreMediaSoftLink.cpp
Expand Up @@ -52,6 +52,7 @@ SOFT_LINK_FUNCTION_FOR_SOURCE_WITH_EXPORT(PAL, CoreMedia, CMBlockBufferGetDataLe
SOFT_LINK_FUNCTION_FOR_SOURCE_WITH_EXPORT(PAL, CoreMedia, CMBlockBufferIsRangeContiguous, Boolean, (CMBlockBufferRef theBuffer, size_t offset, size_t length), (theBuffer, offset, length), PAL_EXPORT)
SOFT_LINK_FUNCTION_FOR_SOURCE_WITH_EXPORT(PAL, CoreMedia, CMBlockBufferReplaceDataBytes, OSStatus, (const void* sourceBytes, CMBlockBufferRef destinationBuffer, size_t offsetIntoDestination, size_t dataLength), (sourceBytes, destinationBuffer, offsetIntoDestination, dataLength), PAL_EXPORT)
SOFT_LINK_FUNCTION_FOR_SOURCE_WITH_EXPORT(PAL, CoreMedia, CMFormatDescriptionGetExtension, CFPropertyListRef, (CMFormatDescriptionRef desc, CFStringRef extensionKey), (desc, extensionKey), PAL_EXPORT)
SOFT_LINK_FUNCTION_FOR_SOURCE_WITH_EXPORT(PAL, CoreMedia, CMFormatDescriptionEqual, Boolean, (CMFormatDescriptionRef desc, CMFormatDescriptionRef other), (desc, other), PAL_EXPORT)
SOFT_LINK_FUNCTION_FOR_SOURCE_WITH_EXPORT(PAL, CoreMedia, CMFormatDescriptionGetExtensions, CFDictionaryRef, (CMFormatDescriptionRef desc), (desc), PAL_EXPORT)
SOFT_LINK_FUNCTION_FOR_SOURCE_WITH_EXPORT(PAL, CoreMedia, CMSampleBufferGetTypeID, CFTypeID, (void), (), PAL_EXPORT)
SOFT_LINK_FUNCTION_FOR_SOURCE_WITH_EXPORT(PAL, CoreMedia, CMSampleBufferGetDataBuffer, CMBlockBufferRef, (CMSampleBufferRef sbuf), (sbuf), PAL_EXPORT)
Expand Down
2 changes: 2 additions & 0 deletions Source/WebCore/PAL/pal/cf/CoreMediaSoftLink.h
Expand Up @@ -58,6 +58,8 @@ SOFT_LINK_FUNCTION_FOR_HEADER(PAL, CoreMedia, CMFormatDescriptionGetExtensions,
#define CMFormatDescriptionGetExtensions softLink_CoreMedia_CMFormatDescriptionGetExtensions
SOFT_LINK_FUNCTION_FOR_HEADER(PAL, CoreMedia, CMFormatDescriptionGetExtension, CFPropertyListRef, (CMFormatDescriptionRef desc, CFStringRef extensionKey), (desc, extensionKey))
#define CMFormatDescriptionGetExtension softLink_CoreMedia_CMFormatDescriptionGetExtension
SOFT_LINK_FUNCTION_FOR_HEADER(PAL, CoreMedia, CMFormatDescriptionEqual, Boolean, (CMFormatDescriptionRef desc, CMFormatDescriptionRef other), (desc, other))
#define CMFormatDescriptionEqual softLink_CoreMedia_CMFormatDescriptionEqual
SOFT_LINK_FUNCTION_FOR_HEADER(PAL, CoreMedia, CMSampleBufferGetTypeID, CFTypeID, (void), ())
#define CMSampleBufferGetTypeID softLink_CoreMedia_CMSampleBufferGetTypeID
SOFT_LINK_FUNCTION_FOR_HEADER(PAL, CoreMedia, CMSampleBufferGetDataBuffer, CMBlockBufferRef, (CMSampleBufferRef sbuf), (sbuf))
Expand Down
8 changes: 8 additions & 0 deletions Source/WebCore/WebCore.xcodeproj/project.pbxproj
Expand Up @@ -1107,6 +1107,8 @@
411223C52603567D00B0A0B6 /* DetachedRTCDataChannel.h in Headers */ = {isa = PBXBuildFile; fileRef = 411223C32603567C00B0A0B6 /* DetachedRTCDataChannel.h */; settings = {ATTRIBUTES = (Private, ); }; };
4112B5431F9F9CA000E67875 /* ServiceWorkerThreadProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = 4112B53F1F9F9C9B00E67875 /* ServiceWorkerThreadProxy.h */; settings = {ATTRIBUTES = (Private, ); }; };
4114FE3225BEBD19009D9F20 /* RTCRtcpParameters.h in Headers */ = {isa = PBXBuildFile; fileRef = 4114FE2F25BEBD18009D9F20 /* RTCRtcpParameters.h */; };
411A0F0D293DED7E00306498 /* WebRTCVideoDecoder.mm in Sources */ = {isa = PBXBuildFile; fileRef = 411A0F0B293DED7900306498 /* WebRTCVideoDecoder.mm */; };
411A0F0E293DED7E00306498 /* WebRTCVideoDecoder.h in Headers */ = {isa = PBXBuildFile; fileRef = 411A0F0C293DED7C00306498 /* WebRTCVideoDecoder.h */; settings = {ATTRIBUTES = (Private, ); }; };
41201F3727F2F74900D56CC2 /* NotificationEventType.h in Headers */ = {isa = PBXBuildFile; fileRef = 41201F3627F2F74600D56CC2 /* NotificationEventType.h */; settings = {ATTRIBUTES = (Private, ); }; };
4123081B138C429700BCCFCA /* WebCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 93F19B1A08245E5A001E9ABC /* WebCore.framework */; };
41230913138C42FF00BCCFCA /* JavaScriptCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F8216299029F4FB501000131 /* JavaScriptCore.framework */; };
Expand Down Expand Up @@ -8879,6 +8881,8 @@
41189EF71AD8232800B90A0D /* ReadableStreamDefaultController.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ReadableStreamDefaultController.idl; sourceTree = "<group>"; };
41189EF71AD8232800B93F64 /* ReadableByteStreamController.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ReadableByteStreamController.idl; sourceTree = "<group>"; };
41189EF71AD8232800B95672 /* ReadableStreamBYOBRequest.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ReadableStreamBYOBRequest.idl; sourceTree = "<group>"; };
411A0F0B293DED7900306498 /* WebRTCVideoDecoder.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebRTCVideoDecoder.mm; sourceTree = "<group>"; };
411A0F0C293DED7C00306498 /* WebRTCVideoDecoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebRTCVideoDecoder.h; sourceTree = "<group>"; };
41201F3627F2F74600D56CC2 /* NotificationEventType.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NotificationEventType.h; sourceTree = "<group>"; };
41209E24257A2FBB00120ACA /* SFrameUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SFrameUtils.h; sourceTree = "<group>"; };
41209E26257A2FBB00120ACA /* SFrameUtils.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SFrameUtils.cpp; sourceTree = "<group>"; };
Expand Down Expand Up @@ -22166,6 +22170,8 @@
07BB1E6F27176CCA001DF289 /* DisplayCaptureSourceCocoa.h */,
41878FAB272934E6002E1EDD /* IncomingAudioMediaStreamTrackRendererUnit.cpp */,
41878FAA27282057002E1EDD /* IncomingAudioMediaStreamTrackRendererUnit.h */,
411A0F0C293DED7C00306498 /* WebRTCVideoDecoder.h */,
411A0F0B293DED7900306498 /* WebRTCVideoDecoder.mm */,
);
path = cocoa;
sourceTree = "<group>";
Expand Down Expand Up @@ -39467,6 +39473,7 @@
E1A3162D134BC32D007C9A4F /* WebNSAttributedStringExtras.h in Headers */,
CD5896E21CD2B15100B3BCC8 /* WebPlaybackControlsManager.h in Headers */,
9A9FA6F02896E9EB0055A13B /* WebRTCProvider.h in Headers */,
411A0F0E293DED7E00306498 /* WebRTCVideoDecoder.h in Headers */,
1CAF34810A6C405200ABE06E /* WebScriptObject.h in Headers */,
1CAF34830A6C405200ABE06E /* WebScriptObjectPrivate.h in Headers */,
1A569D1B0D7E2B82007C3983 /* WebScriptObjectProtocol.h in Headers */,
Expand Down Expand Up @@ -40841,6 +40848,7 @@
2D06214F1DA63A9100A7FB26 /* WebKitMediaKeySession.cpp in Sources */,
7C48A6D0191C9D6500026674 /* WebKitNamespace.cpp in Sources */,
07F5CFF62582A52900662EF5 /* WebMAudioUtilitiesCocoa.mm in Sources */,
411A0F0D293DED7E00306498 /* WebRTCVideoDecoder.mm in Sources */,
1CAF34820A6C405200ABE06E /* WebScriptObject.mm in Sources */,
CECDC93C21F2972900976BD1 /* WebVideoFullscreenControllerAVKit.mm in Sources */,
A14832C2187F65C700DA63A6 /* WKUtilities.c in Sources */,
Expand Down
58 changes: 58 additions & 0 deletions Source/WebCore/platform/mediastream/cocoa/WebRTCVideoDecoder.h
@@ -0,0 +1,58 @@
/*
* Copyright (C) 2022 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

#if USE(LIBWEBRTC)

#include <wtf/UniqueRef.h>

namespace webrtc {
using LocalDecoder = void*;
}

namespace WebCore {

class WebRTCVideoDecoder {
public:
virtual ~WebRTCVideoDecoder() = default;

#if USE(LIBWEBRTC)
WEBCORE_EXPORT static UniqueRef<WebRTCVideoDecoder> createFromLocalDecoder(webrtc::LocalDecoder);
#endif

virtual void flush() = 0;
virtual void setFormat(const uint8_t*, size_t, uint16_t width, uint16_t height) = 0;
virtual int32_t decodeFrame(int64_t timeStamp, const uint8_t*, size_t) = 0;
virtual void setFrameSize(uint16_t width, uint16_t height) = 0;
};

#if USE(APPLE_INTERNAL_SDK)
#import <WebKitAdditions/WebRTCVideoDecoderAdditions.h>
#endif

}

#endif // USE(LIBWEBRTC)
74 changes: 74 additions & 0 deletions Source/WebCore/platform/mediastream/cocoa/WebRTCVideoDecoder.mm
@@ -0,0 +1,74 @@
/*
* Copyright (C) 2022 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 "config.h"
#include "WebRTCVideoDecoder.h"

#if USE(LIBWEBRTC)

ALLOW_UNUSED_PARAMETERS_BEGIN
ALLOW_COMMA_BEGIN

#include <webrtc/sdk/WebKit/WebKitDecoder.h>

ALLOW_UNUSED_PARAMETERS_END
ALLOW_COMMA_END

namespace WebCore {

class WebRTCLocalVideoDecoder final : public WebRTCVideoDecoder {
WTF_MAKE_FAST_ALLOCATED;
public:
explicit WebRTCLocalVideoDecoder(webrtc::LocalDecoder decoder)
: m_decoder(decoder)
{
}
~WebRTCLocalVideoDecoder()
{
webrtc::releaseLocalDecoder(m_decoder);
}

private:
void flush() final { webrtc::flushLocalDecoder(m_decoder); }
void setFormat(const uint8_t* data, size_t size, uint16_t width, uint16_t height) final { webrtc::setDecodingFormat(m_decoder, data, size, width, height); }
int32_t decodeFrame(int64_t timeStamp, const uint8_t* data, size_t size) final { return webrtc::decodeFrame(m_decoder, timeStamp, data, size); }
void setFrameSize(uint16_t width, uint16_t height) final { webrtc::setDecoderFrameSize(m_decoder, width, height); }

webrtc::LocalDecoder m_decoder;
};

UniqueRef<WebRTCVideoDecoder> WebRTCVideoDecoder::createFromLocalDecoder(webrtc::LocalDecoder decoder)
{
return makeUniqueRef<WebRTCLocalVideoDecoder>(decoder);
}

}

#if USE(APPLE_INTERNAL_SDK)
#import <WebKitAdditions/WebRTCVideoDecoderAdditions.mm>
#endif

#endif

16 changes: 13 additions & 3 deletions Source/WebKit/GPUProcess/webrtc/LibWebRTCCodecsProxy.h
Expand Up @@ -37,6 +37,7 @@
#include "VideoCodecType.h"
#include "WorkQueueMessageReceiver.h"
#include <WebCore/ProcessIdentity.h>
#include <WebCore/WebRTCVideoDecoder.h>
#include <atomic>
#include <wtf/ThreadAssertions.h>

Expand All @@ -47,7 +48,6 @@ class Semaphore;
}

namespace webrtc {
using LocalDecoder = void*;
using LocalEncoder = void*;
}

Expand All @@ -70,11 +70,21 @@ class LibWebRTCCodecsProxy final : public IPC::WorkQueueMessageReceiver {
void stopListeningForIPC(Ref<LibWebRTCCodecsProxy>&& refFromConnection);
bool allowsExitUnderMemoryPressure() const;

class Decoder {
public:
virtual ~Decoder() = default;

virtual void flush() = 0;
virtual void setFormat(const uint8_t*, size_t, uint16_t width, uint16_t height) = 0;
virtual int32_t decodeFrame(int64_t timeStamp, const uint8_t*, size_t) = 0;
virtual void setFrameSize(uint16_t width, uint16_t height) = 0;
};

private:
explicit LibWebRTCCodecsProxy(GPUConnectionToWebProcess&);
void initialize();
auto createDecoderCallback(VideoDecoderIdentifier, bool useRemoteFrames);
void* createLocalDecoder(VideoDecoderIdentifier, VideoCodecType, bool useRemoteFrames);
std::unique_ptr<WebCore::WebRTCVideoDecoder> createLocalDecoder(VideoDecoderIdentifier, VideoCodecType, bool useRemoteFrames);
WorkQueue& workQueue() const { return m_queue; }

// IPC::WorkQueueMessageReceiver overrides.
Expand Down Expand Up @@ -107,7 +117,7 @@ class LibWebRTCCodecsProxy final : public IPC::WorkQueueMessageReceiver {
Ref<WorkQueue> m_queue;
Ref<RemoteVideoFrameObjectHeap> m_videoFrameObjectHeap;
WebCore::ProcessIdentity m_resourceOwner;
HashMap<VideoDecoderIdentifier, webrtc::LocalDecoder> m_decoders WTF_GUARDED_BY_CAPABILITY(workQueue());
HashMap<VideoDecoderIdentifier, UniqueRef<WebCore::WebRTCVideoDecoder>> m_decoders WTF_GUARDED_BY_CAPABILITY(workQueue());
HashMap<VideoEncoderIdentifier, Encoder> m_encoders WTF_GUARDED_BY_CAPABILITY(workQueue());
std::atomic<bool> m_hasEncodersOrDecoders { false };

Expand Down
32 changes: 20 additions & 12 deletions Source/WebKit/GPUProcess/webrtc/LibWebRTCCodecsProxy.mm
Expand Up @@ -81,8 +81,7 @@
m_queue->dispatch([this, protectedThis = WTFMove(refFromConnection)] {
assertIsCurrent(workQueue());
auto decoders = WTFMove(m_decoders);
for (auto decoder : decoders.values())
webrtc::releaseLocalDecoder(decoder);
decoders.clear();
auto encoders = WTFMove(m_encoders);
for (auto& encoder : encoders.values())
webrtc::releaseLocalEncoder(encoder.webrtcEncoder);
Expand Down Expand Up @@ -116,16 +115,21 @@
};
}

void* LibWebRTCCodecsProxy::createLocalDecoder(VideoDecoderIdentifier identifier, VideoCodecType codecType, bool useRemoteFrames)
std::unique_ptr<WebCore::WebRTCVideoDecoder> LibWebRTCCodecsProxy::createLocalDecoder(VideoDecoderIdentifier identifier, VideoCodecType codecType, bool useRemoteFrames)
{
auto block = makeBlockPtr(createDecoderCallback(identifier, useRemoteFrames));

#if USE(APPLE_INTERNAL_SDK)
#include <WebKitAdditions/LibWebRTCCodecsProxyAdditions.mm>
#endif

switch (codecType) {
case VideoCodecType::H264:
return webrtc::createLocalH264Decoder(block.get());
return WebRTCVideoDecoder::createFromLocalDecoder(webrtc::createLocalH264Decoder(block.get())).moveToUniquePtr();
case VideoCodecType::H265:
return webrtc::createLocalH265Decoder(block.get());
return WebRTCVideoDecoder::createFromLocalDecoder(webrtc::createLocalH265Decoder(block.get())).moveToUniquePtr();
case VideoCodecType::VP9:
return webrtc::createLocalVP9Decoder(block.get());
return WebRTCVideoDecoder::createFromLocalDecoder(webrtc::createLocalVP9Decoder(block.get())).moveToUniquePtr();
default:
break;
}
Expand All @@ -136,7 +140,12 @@
void LibWebRTCCodecsProxy::createDecoder(VideoDecoderIdentifier identifier, VideoCodecType codecType, bool useRemoteFrames)
{
assertIsCurrent(workQueue());
auto result = m_decoders.add(identifier, createLocalDecoder(identifier, codecType, useRemoteFrames));
auto decoder = createLocalDecoder(identifier, codecType, useRemoteFrames);
if (!decoder) {
ASSERT(IPC::isTestingIPC());
return;
}
auto result = m_decoders.add(identifier, makeUniqueRefFromNonNullUniquePtr(WTFMove(decoder)));
ASSERT_UNUSED(result, result.isNewEntry || IPC::isTestingIPC());
m_hasEncodersOrDecoders = true;
}
Expand All @@ -149,7 +158,6 @@
ASSERT_IS_TESTING_IPC();
return;
}
webrtc::releaseLocalDecoder(decoder);
m_hasEncodersOrDecoders = !m_encoders.isEmpty() || !m_decoders.isEmpty();
}

Expand All @@ -161,7 +169,7 @@
ASSERT_IS_TESTING_IPC();
return;
}
webrtc::flushLocalDecoder(decoder);
decoder->flush();
m_connection->send(Messages::LibWebRTCCodecs::FlushDecoderCompleted { identifier }, 0);
}

Expand All @@ -173,7 +181,7 @@
ASSERT_IS_TESTING_IPC();
return;
}
webrtc::setDecodingFormat(decoder, data.data(), data.size(), width, height);
decoder->setFormat(data.data(), data.size(), width, height);
}

void LibWebRTCCodecsProxy::decodeFrame(VideoDecoderIdentifier identifier, int64_t timeStamp, const IPC::DataReference& data) WTF_IGNORES_THREAD_SAFETY_ANALYSIS
Expand All @@ -184,7 +192,7 @@
ASSERT_IS_TESTING_IPC();
return;
}
if (webrtc::decodeFrame(decoder, timeStamp, data.data(), data.size()))
if (decoder->decodeFrame(timeStamp, data.data(), data.size()))
m_connection->send(Messages::LibWebRTCCodecs::FailedDecoding { identifier }, 0);
}

Expand All @@ -196,7 +204,7 @@
ASSERT_IS_TESTING_IPC();
return;
}
webrtc::setDecoderFrameSize(decoder, width, height);
decoder->setFrameSize(width, height);
}

void LibWebRTCCodecsProxy::createEncoder(VideoEncoderIdentifier identifier, VideoCodecType codecType, const Vector<std::pair<String, String>>& parameters, bool useLowLatency, bool useAnnexB)
Expand Down
6 changes: 6 additions & 0 deletions Source/WebKit/WebProcess/GPU/webrtc/LibWebRTCCodecs.cpp
Expand Up @@ -57,6 +57,10 @@ ALLOW_COMMA_END
namespace WebKit {
using namespace WebCore;

#if USE(APPLE_INTERNAL_SDK)
#include <WebKitAdditions/LibWebRTCCodecsAdditions.mm>
#else

static webrtc::WebKitVideoDecoder createVideoDecoder(const webrtc::SdpVideoFormat& format)
{
auto& codecs = WebProcess::singleton().libWebRTCCodecs();
Expand Down Expand Up @@ -92,6 +96,8 @@ std::optional<VideoCodecType> LibWebRTCCodecs::videoCodecTypeFromWebCodec(const
return { };
}

#endif

static int32_t releaseVideoDecoder(webrtc::WebKitVideoDecoder::Value decoder)
{
return WebProcess::singleton().libWebRTCCodecs().releaseDecoder(*static_cast<LibWebRTCCodecs::Decoder*>(decoder));
Expand Down

0 comments on commit 0a22679

Please sign in to comment.