Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add abstract decoder support in LibWebRTCCodecsProxy
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
Showing
8 changed files
with
182 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
Source/WebCore/platform/mediastream/cocoa/WebRTCVideoDecoder.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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
74
Source/WebCore/platform/mediastream/cocoa/WebRTCVideoDecoder.mm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters