Skip to content
Permalink
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
youennf committed Oct 8, 2022
1 parent e844ed6 commit c946458d447464be29d85328c0173468fdcb00f7
Show file tree
Hide file tree
Showing 24 changed files with 302 additions and 25 deletions.
@@ -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"

@@ -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"

@@ -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"

@@ -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"

@@ -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"

@@ -1,5 +1,3 @@
CONSOLE MESSAGE: Error: assert_unreached: Not supported Reached unreachable code
CONSOLE MESSAGE: Error: assert_unreached: Not supported Reached unreachable code

FAIL SVC L1T2 promise_test: Unhandled rejection with value: object "ReferenceError: Can't find variable: OffscreenCanvas"
FAIL SVC L1T3 promise_test: Unhandled rejection with value: object "ReferenceError: Can't find variable: OffscreenCanvas"
@@ -702,6 +702,7 @@ set(WebCore_NON_SVG_IDL_FILES
Modules/webauthn/ResidentKeyRequirement.idl
Modules/webauthn/UserVerificationRequirement.idl

Modules/webcodecs/AvcEncoderConfig.idl
Modules/webcodecs/BitrateMode.idl
Modules/webcodecs/LatencyMode.idl
Modules/webcodecs/HardwareAcceleration.idl
@@ -773,6 +773,7 @@ $(PROJECT_DIR)/Modules/webauthn/PublicKeyCredentialRequestOptions.idl
$(PROJECT_DIR)/Modules/webauthn/PublicKeyCredentialType.idl
$(PROJECT_DIR)/Modules/webauthn/ResidentKeyRequirement.idl
$(PROJECT_DIR)/Modules/webauthn/UserVerificationRequirement.idl
$(PROJECT_DIR)/Modules/webcodecs/AvcEncoderConfig.idl
$(PROJECT_DIR)/Modules/webcodecs/BitrateMode.idl
$(PROJECT_DIR)/Modules/webcodecs/HardwareAcceleration.idl
$(PROJECT_DIR)/Modules/webcodecs/LatencyMode.idl
@@ -278,6 +278,8 @@ $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSAuthenticatorTransport.cpp
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSAuthenticatorTransport.h
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSAutomationRate.cpp
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSAutomationRate.h
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSAvcEncoderConfig.cpp
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSAvcEncoderConfig.h
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSBarProp.cpp
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSBarProp.h
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSBaseAudioContext.cpp
@@ -671,6 +671,7 @@ JS_BINDING_IDLS := \
$(WebCore)/Modules/webauthn/PublicKeyCredentialType.idl \
$(WebCore)/Modules/webauthn/ResidentKeyRequirement.idl \
$(WebCore)/Modules/webauthn/UserVerificationRequirement.idl \
$(WebCore)/Modules/webcodecs/AvcEncoderConfig.idl \
$(WebCore)/Modules/webcodecs/BitrateMode.idl \
$(WebCore)/Modules/webcodecs/LatencyMode.idl \
$(WebCore)/Modules/webcodecs/HardwareAcceleration.idl \
@@ -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)
@@ -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";
};
@@ -100,7 +100,8 @@ ExceptionOr<void> WebCodecsVideoEncoder::configure(WebCodecsVideoEncoderConfig&&
});
};
}
VideoEncoder::create(config.codec, { config.width, config.height }, [this, weakedThis = WeakPtr { *this }](auto&& result) {
bool useAnnexB = config.avc && config.avc->format == AvcBitstreamFormat::Annexb;
VideoEncoder::create(config.codec, { config.width, config.height, useAnnexB }, [this, weakedThis = WeakPtr { *this }](auto&& result) {
if (!weakedThis)
return;

@@ -27,6 +27,7 @@

#if ENABLE(WEB_CODECS)

#include "AvcEncoderConfig.h"
#include "BitrateMode.h"
#include "HardwareAcceleration.h"
#include "LatencyMode.h"
@@ -46,6 +47,7 @@ struct WebCodecsVideoEncoderConfig {
String scalabilityMode;
BitrateMode bitrateMode { BitrateMode::Variable };
LatencyMode latencyMode { LatencyMode::Quality };
std::optional<AvcEncoderConfig> avc;
};

}
@@ -43,4 +43,5 @@ typedef [EnforceRange] unsigned long long WebCodecsVideoEncoderConfigBitrate;
DOMString scalabilityMode;
BitrateMode bitrateMode = "variable";
LatencyMode latencyMode = "quality";
AvcEncoderConfig avc;
};
@@ -3027,6 +3027,7 @@ JSBeforeUnloadEvent.cpp
JSBiquadFilterNode.cpp
JSBiquadFilterOptions.cpp
JSBiquadFilterType.cpp
JSAvcEncoderConfig.cpp
JSBitrateMode.cpp
JSBlob.cpp
JSBlobCallback.cpp
@@ -1285,10 +1285,11 @@
41EB797E27C3E45E001C3E3E /* VideoFrameLibWebRTC.h in Headers */ = {isa = PBXBuildFile; fileRef = 41EB797C27C3E45D001C3E3E /* VideoFrameLibWebRTC.h */; settings = {ATTRIBUTES = (Private, ); }; };
41F062140F5F192600A07EAC /* InspectorDatabaseResource.h in Headers */ = {isa = PBXBuildFile; fileRef = 41F062120F5F192600A07EAC /* InspectorDatabaseResource.h */; };
41F1D21F0EF35C2A00DA8753 /* ScriptCachedFrameData.h in Headers */ = {isa = PBXBuildFile; fileRef = 41F1D21D0EF35C2A00DA8753 /* ScriptCachedFrameData.h */; settings = {ATTRIBUTES = (Private, ); }; };
41F898B428EAEAA30070549C /* VideoEncoder.h in Headers */ = {isa = PBXBuildFile; fileRef = 41F898B228EAEAA20070549C /* VideoEncoder.h */; };
41F898B428EAEAA30070549C /* VideoEncoder.h in Headers */ = {isa = PBXBuildFile; fileRef = 41F898B228EAEAA20070549C /* VideoEncoder.h */; settings = {ATTRIBUTES = (Private, ); }; };
41F898B528EAEAA30070549C /* VideoEncoder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41F898B328EAEAA20070549C /* VideoEncoder.cpp */; };
41F898B828EAEADB0070549C /* LibWebRTCVPXVideoEncoder.h in Headers */ = {isa = PBXBuildFile; fileRef = 41F898B628EAEADA0070549C /* LibWebRTCVPXVideoEncoder.h */; };
41F898B928EAEADB0070549C /* LibWebRTCVPXVideoEncoder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41F898B728EAEADA0070549C /* LibWebRTCVPXVideoEncoder.cpp */; };
41F898F628ED702A0070549C /* AvcEncoderConfig.h in Headers */ = {isa = PBXBuildFile; fileRef = 41F898F428ED6F970070549C /* AvcEncoderConfig.h */; };
41FABD2D1F4DFE4A006A6C97 /* DOMCacheEngine.h in Headers */ = {isa = PBXBuildFile; fileRef = 41FABD2B1F4DFE42006A6C97 /* DOMCacheEngine.h */; settings = {ATTRIBUTES = (Private, ); }; };
41FCCC3B2746675600892AD6 /* CoreAudioCaptureSource.h in Headers */ = {isa = PBXBuildFile; fileRef = 3F3BB5831E709EE400C701F2 /* CoreAudioCaptureSource.h */; settings = {ATTRIBUTES = (Private, ); }; };
41FCD6B923CE015500C62567 /* SampleBufferDisplayLayer.h in Headers */ = {isa = PBXBuildFile; fileRef = 414598BE23C8AAB8002B9CC8 /* SampleBufferDisplayLayer.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -9297,6 +9298,8 @@
41F898B328EAEAA20070549C /* VideoEncoder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VideoEncoder.cpp; sourceTree = "<group>"; };
41F898B628EAEADA0070549C /* LibWebRTCVPXVideoEncoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LibWebRTCVPXVideoEncoder.h; sourceTree = "<group>"; };
41F898B728EAEADA0070549C /* LibWebRTCVPXVideoEncoder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LibWebRTCVPXVideoEncoder.cpp; sourceTree = "<group>"; };
41F898F428ED6F970070549C /* AvcEncoderConfig.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AvcEncoderConfig.h; sourceTree = "<group>"; };
41F898F528ED6F970070549C /* AvcEncoderConfig.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = AvcEncoderConfig.idl; sourceTree = "<group>"; };
41FABD2B1F4DFE42006A6C97 /* DOMCacheEngine.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMCacheEngine.h; sourceTree = "<group>"; };
41FABD2E1F4E0251006A6C97 /* DOMCacheEngine.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DOMCacheEngine.cpp; sourceTree = "<group>"; };
41FB278D1F34C28200795487 /* WindowOrWorkerGlobalScopeCaches.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WindowOrWorkerGlobalScopeCaches.h; sourceTree = "<group>"; };
@@ -31205,6 +31208,8 @@
CD1F9AEA26FD20A600617EB6 /* webcodecs */ = {
isa = PBXGroup;
children = (
41F898F428ED6F970070549C /* AvcEncoderConfig.h */,
41F898F528ED6F970070549C /* AvcEncoderConfig.idl */,
419BD1AB28E593800089D7B7 /* BitrateMode.h */,
419BD1A928E5937D0089D7B7 /* BitrateMode.idl */,
4110A21628E3440E00321D09 /* HardwareAcceleration.h */,
@@ -34712,6 +34717,7 @@
CDC675271EAEA9D400727C84 /* AVAudioSessionCaptureDevice.h in Headers */,
CDC675231EAEA9B700727C84 /* AVAudioSessionCaptureDeviceManager.h in Headers */,
070363E2181A1CDC00C074A5 /* AVCaptureDeviceManager.h in Headers */,
41F898F628ED702A0070549C /* AvcEncoderConfig.h in Headers */,
CD336F6217F9F64700DDDCD0 /* AVTrackPrivateAVFObjCImpl.h in Headers */,
070363E6181A1CDC00C074A5 /* AVVideoCaptureSource.h in Headers */,
29AE213521ABA48A00869283 /* AXIsolatedObject.h in Headers */,
@@ -32,12 +32,24 @@

namespace WebCore {

VideoEncoder::CreatorFunction VideoEncoder::s_customCreator = nullptr;

void VideoEncoder::setCreatorCallback(CreatorFunction&& function)
{
s_customCreator = WTFMove(function);
}

void VideoEncoder::create(const String& codecName, const Config& config, CreateCallback&& callback, OutputCallback&& outputCallback, PostTaskCallback&& postCallback)
{
UNUSED_PARAM(codecName);
UNUSED_PARAM(outputCallback);
UNUSED_PARAM(postCallback);
if (s_customCreator) {
s_customCreator(codecName, config, WTFMove(callback), WTFMove(outputCallback), WTFMove(postCallback));
return;
}
createLocalEncoder(codecName, config, WTFMove(callback), WTFMove(outputCallback), WTFMove(postCallback));
}

void VideoEncoder::createLocalEncoder(const String& codecName, const Config& config, CreateCallback&& callback, OutputCallback&& outputCallback, PostTaskCallback&& postCallback)
{
#if USE(LIBWEBRTC)
if (codecName == "vp8"_s) {
UniqueRef<VideoEncoder> encoder = makeUniqueRef<LibWebRTCVPXVideoEncoder>(LibWebRTCVPXVideoEncoder::Type::VP8, config, WTFMove(outputCallback), WTFMove(postCallback));
@@ -49,6 +61,10 @@ void VideoEncoder::create(const String& codecName, const Config& config, CreateC
callback(WTFMove(encoder));
return;
}
#else
UNUSED_PARAM(codecName);
UNUSED_PARAM(outputCallback);
UNUSED_PARAM(postCallback);
#endif

callback(makeUnexpected("Not supported"_s));
@@ -41,6 +41,7 @@ class VideoEncoder {
struct Config {
uint64_t width { 0 };
uint64_t height { 0 };
bool useAnnexB { false };
};
struct EncodedFrame {
Vector<uint8_t> data;
@@ -58,14 +59,21 @@ class VideoEncoder {
using PostTaskCallback = Function<void(Function<void()>&&)>;
using OutputCallback = Function<void(EncodedFrame&&)>;
using CreateCallback = CompletionHandler<void(CreateResult&&)>;

using CreatorFunction = void(*)(const String&, const Config&, CreateCallback&&, OutputCallback&&, PostTaskCallback&&);
WEBCORE_EXPORT static void setCreatorCallback(CreatorFunction&&);

static void create(const String&, const Config&, CreateCallback&&, OutputCallback&&, PostTaskCallback&&);
WEBCORE_EXPORT static void createLocalEncoder(const String&, const Config&, CreateCallback&&, OutputCallback&&, PostTaskCallback&&);

using EncodeCallback = Function<void(String&&)>;
virtual void encode(RawFrame&&, bool shouldGenerateKeyFrame, EncodeCallback&&) = 0;

virtual void flush(Function<void()>&&) = 0;
virtual void reset() = 0;
virtual void close() = 0;

static CreatorFunction s_customCreator;
};

}

0 comments on commit c946458

Please sign in to comment.