Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Implement WebCodecsVideoEncoder with GPUProcess backend
https://bugs.webkit.org/show_bug.cgi?id=246068 rdar://problem/100798062 Reviewed by Eric Carlson. Complement RemoteVideoCodecFactory with remote encoder support. Add support for AvcEncoderConfig to make sure we only support AnnexB for now. Make use of libwebrtc remote encoders through RemoteVideoCodecFactory/RemoteVideoEncoder like done for decoders. * LayoutTests/imported/w3c/web-platform-tests/webcodecs/full-cycle-test.https.any.worker_h264_annexb-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/webcodecs/full-cycle-test.https.any.worker_h264_avc-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/webcodecs/full-cycle-test.https.any_h264_annexb-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/webcodecs/full-cycle-test.https.any_h264_avc-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/webcodecs/reconfiguring-encoder.https.any.worker_h264_annexb-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/webcodecs/reconfiguring-encoder.https.any.worker_h264_avc-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/webcodecs/reconfiguring-encoder.https.any_h264_annexb-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/webcodecs/reconfiguring-encoder.https.any_h264_avc-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/webcodecs/temporal-svc-encoding.https.any.worker_h264-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/webcodecs/temporal-svc-encoding.https.any_h264-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/webcodecs/video-encoder-config.https.any-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/webcodecs/video-encoder-config.https.any.worker-expected.txt: * Source/WebCore/CMakeLists.txt: * Source/WebCore/DerivedSources-input.xcfilelist: * Source/WebCore/DerivedSources-output.xcfilelist: * Source/WebCore/DerivedSources.make: * Source/WebCore/Modules/webcodecs/AvcEncoderConfig.h: Added. * Source/WebCore/Modules/webcodecs/AvcEncoderConfig.idl: Added. * Source/WebCore/Modules/webcodecs/WebCodecsVideoEncoder.cpp: (WebCore::isValidEncoderConfig): (WebCore::WebCodecsVideoEncoder::configure): * Source/WebCore/Modules/webcodecs/WebCodecsVideoEncoderConfig.h: * Source/WebCore/Modules/webcodecs/WebCodecsVideoEncoderConfig.idl: * Source/WebCore/Sources.txt: * Source/WebCore/WebCore.xcodeproj/project.pbxproj: * Source/WebCore/platform/VideoEncoder.cpp: (WebCore::VideoEncoder::setCreatorCallback): (WebCore::VideoEncoder::create): (WebCore::VideoEncoder::createLocalEncoder): * Source/WebCore/platform/VideoEncoder.h: * Source/WebKit/WebProcess/GPU/media/RemoteVideoCodecFactory.cpp: (WebKit::RemoteVideoEncoderCallbacks::create): (WebKit::RemoteVideoEncoderCallbacks::postTask): (WebKit::RemoteVideoEncoderCallbacks::close): (WebKit::RemoteVideoEncoderCallbacks::addDuration): (WebKit::RemoteVideoCodecFactory::RemoteVideoCodecFactory): (WebKit::RemoteVideoCodecFactory::createDecoder): (WebKit::RemoteVideoCodecFactory::createEncoder): (WebKit::RemoteVideoEncoder::RemoteVideoEncoder): (WebKit::RemoteVideoEncoder::~RemoteVideoEncoder): (WebKit::RemoteVideoEncoder::encode): (WebKit::RemoteVideoEncoder::flush): (WebKit::RemoteVideoEncoder::reset): (WebKit::RemoteVideoEncoder::close): (WebKit::RemoteVideoEncoderCallbacks::RemoteVideoEncoderCallbacks): (WebKit::RemoteVideoEncoderCallbacks::notifyEncodedChunk): * Source/WebKit/WebProcess/GPU/media/RemoteVideoCodecFactory.h: * Source/WebKit/WebProcess/GPU/webrtc/LibWebRTCCodecs.cpp: (WebKit::LibWebRTCCodecs::createEncoder): (WebKit::LibWebRTCCodecs::createEncoderAndWaitUntilReady): (WebKit::LibWebRTCCodecs::createEncoderInternal): (WebKit::LibWebRTCCodecs::releaseEncoder): (WebKit::LibWebRTCCodecs::encodeFrameInternal): (WebKit::LibWebRTCCodecs::encodeFrame): (WebKit::LibWebRTCCodecs::registerEncodeFrameCallback): (WebKit::LibWebRTCCodecs::registerEncodedVideoFrameCallback): (WebKit::LibWebRTCCodecs::completedEncoding): * Source/WebKit/WebProcess/GPU/webrtc/LibWebRTCCodecs.h: (WebKit::LibWebRTCCodecs::createDecoderInternal): Deleted. * Source/WebKit/WebProcess/GPU/webrtc/SharedVideoFrame.h: Canonical link: https://commits.webkit.org/255316@main
- Loading branch information
Showing
24 changed files
with
302 additions
and
25 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
CONSOLE MESSAGE: Error: assert_unreached: Not supported Reached unreachable code | ||
|
||
FAIL Encoding and decoding cycle promise_test: Unhandled rejection with value: object "ReferenceError: Can't find variable: OffscreenCanvas" | ||
|
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
CONSOLE MESSAGE: Error: assert_unreached: Not supported Reached unreachable code | ||
CONSOLE MESSAGE: Error: assert_unreached: H264 AVC format is not yet supported Reached unreachable code | ||
|
||
FAIL Encoding and decoding cycle promise_test: Unhandled rejection with value: object "ReferenceError: Can't find variable: OffscreenCanvas" | ||
|
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
|
||
FAIL Reconfiguring encoder promise_test: Unhandled rejection with value: object "InvalidStateError: VideoEncoder is not configured" | ||
FAIL Reconfiguring encoder promise_test: Unhandled rejection with value: object "ReferenceError: Can't find variable: OffscreenCanvas" | ||
|
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 |
---|---|---|
@@ -1,4 +1,3 @@ | ||
CONSOLE MESSAGE: Error: assert_unreached: Not supported Reached unreachable code | ||
|
||
FAIL Reconfiguring encoder promise_test: Unhandled rejection with value: object "InvalidStateError: VideoEncoder is not configured" | ||
FAIL Reconfiguring encoder promise_test: Unhandled rejection with value: object "ReferenceError: Can't find variable: OffscreenCanvas" | ||
|
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
CONSOLE MESSAGE: Error: assert_unreached: Not supported Reached unreachable code | ||
CONSOLE MESSAGE: Error: assert_unreached: H264 AVC format is not yet supported Reached unreachable code | ||
|
||
FAIL Reconfiguring encoder promise_test: Unhandled rejection with value: object "InvalidStateError: VideoEncoder is not configured" | ||
|
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* 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 ENABLE(WEB_CODECS) | ||
|
||
namespace WebCore { | ||
|
||
enum class AvcBitstreamFormat { | ||
Annexb, | ||
Avc | ||
}; | ||
|
||
struct AvcEncoderConfig { | ||
using BitstreamFormat = AvcBitstreamFormat; | ||
AvcBitstreamFormat format; | ||
}; | ||
|
||
} | ||
|
||
#endif // ENABLE(WEB_CODECS) |
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,38 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
[ | ||
Conditional=WEB_CODECS | ||
] enum AvcBitstreamFormat { | ||
"annexb", | ||
"avc", | ||
}; | ||
|
||
[ | ||
Conditional=WEB_CODECS, | ||
JSGenerateToJSObject, | ||
] dictionary AvcEncoderConfig { | ||
AvcBitstreamFormat format = "avc"; | ||
}; |
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
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
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
Oops, something went wrong.