haikuwebkit/LayoutTests/webrtc/vp9-vtb.html

95 lines
3.4 KiB
HTML
Raw Permalink Normal View History

WebRTC VP9 Decoder should be able to use VTB https://bugs.webkit.org/show_bug.cgi?id=217811 Reviewed by Eric Carlson. Source/ThirdParty/libwebrtc: Add RTCVideoDecoderVTBVP9 as a VP9 decoder using the VTB API. Enable this code path by default if VP9 is enabled and hardware VP9 decoding is supported. Allow to override this setting for testing purposes. Add SPI header files in case they are not available. * Configurations/libwebrtc.iOS.exp: * Configurations/libwebrtc.iOSsim.exp: * Configurations/libwebrtc.mac.exp: * Source/webrtc/sdk/WebKit/CMBaseObjectSPI.h: Added. * Source/webrtc/sdk/WebKit/VTVideoDecoderSPI.h: Added. * Source/webrtc/sdk/WebKit/WebKitDecoder.mm: (webrtc::createWebKitDecoderFactory): * Source/webrtc/sdk/WebKit/WebKitUtilities.h: * Source/webrtc/sdk/WebKit/WebKitVP9Decoder.cpp: (webrtc::createWebKitVP9Decoder): * Source/webrtc/sdk/objc/api/video_codec/RTCWrappedNativeVideoDecoder.mm: (-[RTCWrappedNativeVideoDecoder implementationName]): * Source/webrtc/sdk/objc/components/video_codec/RTCDefaultVideoDecoderFactory.h: * Source/webrtc/sdk/objc/components/video_codec/RTCDefaultVideoDecoderFactory.m: (-[RTCDefaultVideoDecoderFactory initWithH265:vp9:vp9VTB:]): (-[RTCDefaultVideoDecoderFactory createDecoder:]): * Source/webrtc/sdk/objc/components/video_codec/RTCVideoDecoderVTBVP9.h: Added. * Source/webrtc/sdk/objc/components/video_codec/RTCVideoDecoderVTBVP9.mm: Added. (RTCFrameDecodeParams::RTCFrameDecodeParams): (VP9BufferToCMSampleBuffer): (vp9DecompressionOutputCallback): (-[RTCVideoDecoderVTBVP9 dealloc]): (-[RTCVideoDecoderVTBVP9 startDecodeWithNumberOfCores:]): (-[RTCVideoDecoderVTBVP9 decode:missingFrames:codecSpecificInfo:renderTimeMs:]): (-[RTCVideoDecoderVTBVP9 decodeData:size:timeStamp:]): (-[RTCVideoDecoderVTBVP9 setCallback:]): (-[RTCVideoDecoderVTBVP9 setError:]): (-[RTCVideoDecoderVTBVP9 releaseDecoder]): (-[RTCVideoDecoderVTBVP9 resetDecompressionSession]): (-[RTCVideoDecoderVTBVP9 configureDecompressionSession]): (-[RTCVideoDecoderVTBVP9 destroyDecompressionSession]): (-[RTCVideoDecoderVTBVP9 setVideoFormat:]): (-[RTCVideoDecoderVTBVP9 implementationName]): * Source/webrtc/sdk/objc/native/src/objc_video_decoder_factory.mm: (webrtc::ObjCVideoDecoderFactory::CreateVideoDecoder): * libwebrtc.xcodeproj/project.pbxproj: Source/WebCore: Add testing support to enable VP9 decoding through VTB for WebRTC. Test: webrtc/vp9-vtb.html * platform/mediastream/libwebrtc/LibWebRTCProvider.h: * platform/mediastream/libwebrtc/LibWebRTCProviderCocoa.cpp: (WebCore::LibWebRTCProviderCocoa::createDecoderFactory): * testing/Internals.cpp: (WebCore::Internals::setWebRTCVP9VTBSupport): * testing/Internals.h: * testing/Internals.idl: LayoutTests: * TestExpectations: * platform/mac-wk1/TestExpectations: * platform/mac-wk2/TestExpectations: * webrtc/vp9-vtb-expected.txt: Added. * webrtc/vp9-vtb.html: Added. Canonical link: https://commits.webkit.org/230745@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@268805 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-10-21 17:14:25 +00:00
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>VP9 VTB in WebRTC</title>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
</head>
<body>
<video id="video" autoplay playsInline width="320" height="240"></video>
<canvas id="canvas1" width="320" height="240"></canvas>
<canvas id="canvas2" width="320" height="240"></canvas>
<canvas id="canvas3" width="320" height="240"></canvas>
<script src ="routines.js"></script>
<script>
let hasVP9;
test(() => {
if (window.internals) {
Introduce an experimental flag specific to VP9 profile 2 https://bugs.webkit.org/show_bug.cgi?id=219350 Reviewed by Eric Carlson. Source/ThirdParty/libwebrtc: Allow to enable profile 0 but not profile 2 for VP9 encoder and decoder. * Source/webrtc/sdk/WebKit/WebKitDecoder.mm: (webrtc::createWebKitDecoderFactory): * Source/webrtc/sdk/WebKit/WebKitEncoder.mm: (webrtc::createWebKitEncoderFactory): * Source/webrtc/sdk/WebKit/WebKitUtilities.h: * Source/webrtc/sdk/objc/components/video_codec/RTCDefaultVideoDecoderFactory.h: * Source/webrtc/sdk/objc/components/video_codec/RTCDefaultVideoDecoderFactory.m: (-[RTCDefaultVideoDecoderFactory initWithH265:vp9Profile0:vp9Profile2:vp9VTB:]): (-[RTCDefaultVideoDecoderFactory supportedCodecs]): (-[RTCDefaultVideoDecoderFactory initWithH265:vp9:vp9VTB:]): Deleted. * Source/webrtc/sdk/objc/components/video_codec/RTCDefaultVideoEncoderFactory.h: * Source/webrtc/sdk/objc/components/video_codec/RTCDefaultVideoEncoderFactory.m: (-[RTCDefaultVideoEncoderFactory initWithH265:vp9Profile0:vp9Profile2:lowLatencyH264:]): (+[RTCDefaultVideoEncoderFactory supportedCodecs]): (+[RTCDefaultVideoEncoderFactory supportedCodecsWithH265:vp9Profile0:vp9Profile2:]): (-[RTCDefaultVideoEncoderFactory supportedCodecs]): (-[RTCDefaultVideoEncoderFactory initWithH265:vp9:lowLatencyH264:]): Deleted. (+[RTCDefaultVideoEncoderFactory supportedCodecsWithH265:vp9:]): Deleted. Source/WebCore: Introduce an experimental flag for VP9 profile 2. Pass it to libwebrtc backend when creating codec factories. Profile 2 support is only enabled if profile 0 support is also enabled. Covered by updated test. * page/Page.cpp: (WebCore::m_shouldRelaxThirdPartyCookieBlocking): * page/RuntimeEnabledFeatures.h: (WebCore::RuntimeEnabledFeatures::webRTCVP9Profile0CodecEnabled const): (WebCore::RuntimeEnabledFeatures::setWebRTCVP9Profile0CodecEnabled): (WebCore::RuntimeEnabledFeatures::webRTCVP9Profile2CodecEnabled const): (WebCore::RuntimeEnabledFeatures::setWebRTCVP9Profile2CodecEnabled): (WebCore::RuntimeEnabledFeatures::webRTCVP9CodecEnabled const): Deleted. (WebCore::RuntimeEnabledFeatures::setWebRTCVP9CodecEnabled): Deleted. * platform/mediastream/libwebrtc/LibWebRTCProvider.h: (WebCore::LibWebRTCProvider::setVP9Support): * platform/mediastream/libwebrtc/LibWebRTCProviderCocoa.cpp: (WebCore::LibWebRTCProviderCocoa::createDecoderFactory): (WebCore::LibWebRTCProviderCocoa::createEncoderFactory): * testing/Internals.cpp: (WebCore::Internals::setWebRTCVP9Support): * testing/Internals.h: * testing/Internals.idl: Source/WebKit: * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::updatePreferences): Source/WTF: * Scripts/Preferences/WebPreferencesExperimental.yaml: LayoutTests: * webrtc/vp9-expected.txt: * webrtc/vp9-vtb.html: * webrtc/vp9.html: Canonical link: https://commits.webkit.org/231965@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@270256 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-11-30 19:36:55 +00:00
window.internals.setWebRTCVP9Support(true, true);
WebRTC VP9 Decoder should be able to use VTB https://bugs.webkit.org/show_bug.cgi?id=217811 Reviewed by Eric Carlson. Source/ThirdParty/libwebrtc: Add RTCVideoDecoderVTBVP9 as a VP9 decoder using the VTB API. Enable this code path by default if VP9 is enabled and hardware VP9 decoding is supported. Allow to override this setting for testing purposes. Add SPI header files in case they are not available. * Configurations/libwebrtc.iOS.exp: * Configurations/libwebrtc.iOSsim.exp: * Configurations/libwebrtc.mac.exp: * Source/webrtc/sdk/WebKit/CMBaseObjectSPI.h: Added. * Source/webrtc/sdk/WebKit/VTVideoDecoderSPI.h: Added. * Source/webrtc/sdk/WebKit/WebKitDecoder.mm: (webrtc::createWebKitDecoderFactory): * Source/webrtc/sdk/WebKit/WebKitUtilities.h: * Source/webrtc/sdk/WebKit/WebKitVP9Decoder.cpp: (webrtc::createWebKitVP9Decoder): * Source/webrtc/sdk/objc/api/video_codec/RTCWrappedNativeVideoDecoder.mm: (-[RTCWrappedNativeVideoDecoder implementationName]): * Source/webrtc/sdk/objc/components/video_codec/RTCDefaultVideoDecoderFactory.h: * Source/webrtc/sdk/objc/components/video_codec/RTCDefaultVideoDecoderFactory.m: (-[RTCDefaultVideoDecoderFactory initWithH265:vp9:vp9VTB:]): (-[RTCDefaultVideoDecoderFactory createDecoder:]): * Source/webrtc/sdk/objc/components/video_codec/RTCVideoDecoderVTBVP9.h: Added. * Source/webrtc/sdk/objc/components/video_codec/RTCVideoDecoderVTBVP9.mm: Added. (RTCFrameDecodeParams::RTCFrameDecodeParams): (VP9BufferToCMSampleBuffer): (vp9DecompressionOutputCallback): (-[RTCVideoDecoderVTBVP9 dealloc]): (-[RTCVideoDecoderVTBVP9 startDecodeWithNumberOfCores:]): (-[RTCVideoDecoderVTBVP9 decode:missingFrames:codecSpecificInfo:renderTimeMs:]): (-[RTCVideoDecoderVTBVP9 decodeData:size:timeStamp:]): (-[RTCVideoDecoderVTBVP9 setCallback:]): (-[RTCVideoDecoderVTBVP9 setError:]): (-[RTCVideoDecoderVTBVP9 releaseDecoder]): (-[RTCVideoDecoderVTBVP9 resetDecompressionSession]): (-[RTCVideoDecoderVTBVP9 configureDecompressionSession]): (-[RTCVideoDecoderVTBVP9 destroyDecompressionSession]): (-[RTCVideoDecoderVTBVP9 setVideoFormat:]): (-[RTCVideoDecoderVTBVP9 implementationName]): * Source/webrtc/sdk/objc/native/src/objc_video_decoder_factory.mm: (webrtc::ObjCVideoDecoderFactory::CreateVideoDecoder): * libwebrtc.xcodeproj/project.pbxproj: Source/WebCore: Add testing support to enable VP9 decoding through VTB for WebRTC. Test: webrtc/vp9-vtb.html * platform/mediastream/libwebrtc/LibWebRTCProvider.h: * platform/mediastream/libwebrtc/LibWebRTCProviderCocoa.cpp: (WebCore::LibWebRTCProviderCocoa::createDecoderFactory): * testing/Internals.cpp: (WebCore::Internals::setWebRTCVP9VTBSupport): * testing/Internals.h: * testing/Internals.idl: LayoutTests: * TestExpectations: * platform/mac-wk1/TestExpectations: * platform/mac-wk2/TestExpectations: * webrtc/vp9-vtb-expected.txt: Added. * webrtc/vp9-vtb.html: Added. Canonical link: https://commits.webkit.org/230745@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@268805 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-10-21 17:14:25 +00:00
window.internals.setWebRTCVP9VTBSupport(true);
}
codecs = RTCRtpSender.getCapabilities("video").codecs;
hasVP9 = codecs.some((codec) => { return codec.mimeType == "video/VP9"; });
assert_true(hasVP9);
}, "VP9 in getCapabilities");
if (hasVP9) {
promise_test(async (test) => {
const pc = new RTCPeerConnection();
pc.addTransceiver("video");
const description = await pc.createOffer();
pc.close();
assert_true(description.sdp.indexOf("VP9") !== -1, "VP9 codec is in the SDP");
}, "Verify VP9 activation")
var track;
var remoteTrack;
var receivingConnection;
promise_test((test) => {
return navigator.mediaDevices.getUserMedia({video: {width: 320, height: 240, facingMode: "environment"}}).then((localStream) => {
return new Promise((resolve, reject) => {
track = localStream.getVideoTracks()[0];
createConnections((firstConnection) => {
firstConnection.addTrack(track, localStream);
}, (secondConnection) => {
receivingConnection = secondConnection;
secondConnection.ontrack = (trackEvent) => {
remoteTrack = trackEvent.track;
resolve(trackEvent.streams[0]);
};
}, { observeOffer : (offer) => {
offer.sdp = setCodec(offer.sdp, "VP9");
return offer;
}
});
setTimeout(() => reject("Test timed out"), 5000);
});
}).then((remoteStream) => {
video.srcObject = remoteStream;
return video.play();
});
}, "Setting video exchange");
promise_test(() => {
if (receivingConnection.connectionState === "connected")
return Promise.resolve();
return new Promise((resolve, reject) => {
receivingConnection.onconnectionstatechange = () => {
if (receivingConnection.connectionState === "connected")
resolve();
};
setTimeout(() => reject("Test timed out"), 5000);
});
}, "Ensuring connection state is connected");
promise_test((test) => {
return checkVideoBlack(false, canvas1, video);
}, "Track is enabled, video should not be black");
promise_test((test) => {
track.enabled = false;
return checkVideoBlack(true, canvas2, video);
}, "Track is disabled, video should be black");
promise_test((test) => {
track.enabled = true;
return checkVideoBlack(false, canvas2, video);
}, "Track is enabled, video should not be black 2");
}
</script>
</body>
</html>