Skip to content

Commit 8af3589

Browse files
youennfphiln
authored andcommitted
Add experimental AV1 WebRTC support
https://bugs.webkit.org/show_bug.cgi?id=248172 rdar://problem/102579632 Reviewed by Eric Carlson. Add libaom to libwebrtc third party. Make it compile on macOS/iOS. Enable AV1 support in libwebrtc. Expose API to turn on/off AV1 in libwebrtc. Expose a new experimental AV1 flag and turn on/off aom in libwebrtc based on it.. Coverd by added test. * LayoutTests/imported/w3c/web-platform-tests/media-capabilities/decodingInfo.webrtc-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/media-capabilities/encodingInfo.webrtc-expected.txt: * LayoutTests/webrtc/video-av1-expected.txt: Added. * LayoutTests/webrtc/video-av1.html: Added. * Source/ThirdParty/libwebrtc/Configurations/libaom.xcconfig: Added. * Source/ThirdParty/libwebrtc/Configurations/libwebrtc.iOS.exp: * Source/ThirdParty/libwebrtc/Configurations/libwebrtc.iOSsim.exp: * Source/ThirdParty/libwebrtc/Configurations/libwebrtc.mac.exp: * Source/ThirdParty/libwebrtc/Configurations/libwebrtc.xcconfig: * Source/ThirdParty/libwebrtc/Source/third_party/libaom: Added. (WebCore::Layout::BlockLayoutState::floatingState): (WebCore::Layout::BlockLayoutState::BlockLayoutState): (WebCore::Layout::BlockLayoutState::setLineClamp): Deleted. * Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitDecoder.h: * Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitDecoder.mm: * Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitEncoder.h: * Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitEncoder.mm: * Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitUtilities.h: * Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/api/video_codec/RTCVideoCodecConstants.h: * Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/api/video_codec/RTCVideoCodecConstants.mm: * Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/api/video_codec/RTCVideoDecoderAV1.h: * Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/api/video_codec/RTCVideoDecoderAV1.mm: * Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/api/video_codec/RTCVideoEncoderAV1.h: * Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/api/video_codec/RTCVideoEncoderAV1.mm: * Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/components/video_codec/RTCDefaultVideoDecoderFactory.h: * Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/components/video_codec/RTCDefaultVideoDecoderFactory.m: * Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/components/video_codec/RTCDefaultVideoEncoderFactory.h: * Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/components/video_codec/RTCDefaultVideoEncoderFactory.m: * Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/native/src/objc_video_encoder_factory.mm: * Source/ThirdParty/libwebrtc/libwebrtc.xcodeproj/project.pbxproj: * Source/WTF/Scripts/Preferences/WebPreferencesExperimental.yaml: * Source/WebCore/page/Page.cpp: * Source/WebCore/platform/mediastream/WebRTCProvider.cpp: * Source/WebCore/platform/mediastream/WebRTCProvider.h: * Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCProvider.cpp: (WebCore::LibWebRTCProvider::videoDecodingCapabilitiesOverride): (WebCore::LibWebRTCProvider::videoEncodingCapabilitiesOverride): * Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCProviderCocoa.cpp: Canonical link: https://commits.webkit.org/257228@main
1 parent 4678f30 commit 8af3589

1,236 files changed

Lines changed: 668234 additions & 62 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

LayoutTests/imported/w3c/web-platform-tests/media-capabilities/decodingInfo.webrtc-expected.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,5 @@ PASS Test that decodingInfo returns supported true for the codec video/H265 retu
2323
PASS Test that decodingInfo returns supported true for the codec video/VP8 returned by RTCRtpReceiver.getCapabilities()
2424
PASS Test that decodingInfo returns supported true for the codec video/VP9; profile-id=0 returned by RTCRtpReceiver.getCapabilities()
2525
PASS Test that decodingInfo returns supported true for the codec video/VP9; profile-id=2 returned by RTCRtpReceiver.getCapabilities()
26+
PASS Test that decodingInfo returns supported true for the codec video/AV1 returned by RTCRtpReceiver.getCapabilities()
2627

LayoutTests/imported/w3c/web-platform-tests/media-capabilities/encodingInfo.webrtc-expected.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,5 @@ PASS Test that encodingInfo returns supported true for the codec video/H265 retu
2323
PASS Test that encodingInfo returns supported true for the codec video/VP8 returned by RTCRtpSender.getCapabilities()
2424
PASS Test that encodingInfo returns supported true for the codec video/VP9; profile-id=0 returned by RTCRtpSender.getCapabilities()
2525
PASS Test that encodingInfo returns supported true for the codec video/VP9; profile-id=2 returned by RTCRtpSender.getCapabilities()
26+
PASS Test that encodingInfo returns supported true for the codec video/AV1 returned by RTCRtpSender.getCapabilities()
2627

LayoutTests/platform/glib/TestExpectations

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1470,6 +1470,8 @@ webkit.org/b/235885 webrtc/datachannel/datachannel-stats.html [ Skip ]
14701470
webkit.org/b/235885 webrtc/datachannel/getStats-no-prflx-remote-candidate.html [ Skip ]
14711471
webkit.org/b/235885 fast/mediastream/RTCPeerConnection-statsSelector.html [ Skip ]
14721472

1473+
webrtc/video-av1.html [ Skip ]
1474+
14731475
# GStreamer's DTLS agent currently generates RSA certificates only. DTLS 1.2 is not supported yet (AFAIK).
14741476
webrtc/datachannel/dtls10.html [ Failure ]
14751477

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Video should be running, go to black and running.
2+
Following, should be a snapshot of the video, a black frame and a snapshot of the video.
3+
4+
5+
PASS Verify AV1 activation
6+
PASS Setting video exchange
7+
PASS Ensuring connection state is connected
8+
PASS Track is enabled, video should not be black
9+
PASS Track is disabled, video should be black
10+
PASS If disabled, black frames should still be coming
11+
PASS Track is enabled, video should not be black 2
12+

LayoutTests/webrtc/video-av1.html

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>Testing muting video</title>
6+
<script src="../resources/testharness.js"></script>
7+
<script src="../resources/testharnessreport.js"></script>
8+
</head>
9+
<body>
10+
<div>Video should be running, go to black and running.</div>
11+
<div>Following, should be a snapshot of the video, a black frame and a snapshot of the video.</div>
12+
<video id="video" autoplay playsInline width="320" height="240"></video>
13+
<canvas id="canvas1" width="320" height="240"></canvas>
14+
<canvas id="canvas2" width="320" height="240"></canvas>
15+
<canvas id="canvas3" width="320" height="240"></canvas>
16+
<script src ="routines.js"></script>
17+
<script>
18+
promise_test(async (test) => {
19+
const codecs = RTCRtpSender.getCapabilities("video").codecs;
20+
assert_true(codecs.some((codec) => { return codec.mimeType.indexOf("AV1") >= 0 }), "AV1 is listed as a codec");
21+
22+
codecs.forEach((codec) => {
23+
if (codec.mimeType.indexOf("AV1") >=0)
24+
assert_equals(codec.sdpFmtpLine, undefined, "AV1 codec.sdpFmtpLine is undefined");
25+
});
26+
27+
const pc = new RTCPeerConnection();
28+
pc.addTransceiver("video");
29+
const description = await pc.createOffer();
30+
pc.close();
31+
assert_true(description.sdp.indexOf("AV1") !== -1, "AV1 codec is in the SDP");
32+
}, "Verify AV1 activation")
33+
34+
var track;
35+
var remoteTrack;
36+
var receivingConnection;
37+
promise_test((test) => {
38+
return navigator.mediaDevices.getUserMedia({video: {width: 320, height: 240, facingMode: "environment"}}).then((localStream) => {
39+
return new Promise((resolve, reject) => {
40+
track = localStream.getVideoTracks()[0];
41+
42+
createConnections((firstConnection) => {
43+
firstConnection.addTrack(track, localStream);
44+
firstConnection.getTransceivers()[0].setCodecPreferences([{mimeType: "video/AV1", clockRate: 90000}]);
45+
}, (secondConnection) => {
46+
receivingConnection = secondConnection;
47+
secondConnection.ontrack = (trackEvent) => {
48+
remoteTrack = trackEvent.track;
49+
resolve(trackEvent.streams[0]);
50+
};
51+
}, { observeOffer : test.step_func((offer) => {
52+
assert_false(offer.sdp.includes("H264"), "No H264");
53+
assert_true(offer.sdp.includes("AV1"), "AV1");
54+
return offer;
55+
})
56+
});
57+
setTimeout(() => reject("Test timed out"), 5000);
58+
});
59+
}).then((remoteStream) => {
60+
video.srcObject = remoteStream;
61+
return video.play();
62+
});
63+
}, "Setting video exchange");
64+
65+
promise_test(() => {
66+
if (receivingConnection.connectionState === "connected")
67+
return Promise.resolve();
68+
return new Promise((resolve, reject) => {
69+
receivingConnection.onconnectionstatechange = () => {
70+
if (receivingConnection.connectionState === "connected")
71+
resolve();
72+
};
73+
setTimeout(() => reject("Test timed out"), 5000);
74+
});
75+
}, "Ensuring connection state is connected");
76+
77+
promise_test((test) => {
78+
return checkVideoBlack(false, canvas1, video);
79+
}, "Track is enabled, video should not be black");
80+
81+
promise_test((test) => {
82+
track.enabled = false;
83+
return checkVideoBlack(true, canvas2, video);
84+
}, "Track is disabled, video should be black");
85+
86+
async function getInboundRTPStatsNumberOfDecodedFrames(connection)
87+
{
88+
var report = await connection.getStats();
89+
var framesDecoded;
90+
report.forEach((statItem) => {
91+
if (statItem.type === "inbound-rtp")
92+
framesDecoded = statItem.framesDecoded;
93+
});
94+
return framesDecoded;
95+
}
96+
97+
async function testFrameDecodedIncreased(connection, count, previousFramesNumber)
98+
{
99+
if (previousFramesNumber === undefined) {
100+
let number = await getInboundRTPStatsNumberOfDecodedFrames(connection);
101+
await waitFor(1000);
102+
return testFrameDecodedIncreased(connection, 0, number);
103+
}
104+
105+
var number = await getInboundRTPStatsNumberOfDecodedFrames(connection);
106+
if (previousFramesNumber && number > previousFramesNumber)
107+
return;
108+
109+
if (count >= 20)
110+
return Promise.reject("test increasing frame encoded timed out");
111+
112+
await waitFor(1000);
113+
return testFrameDecodedIncreased(connection, ++count, previousFramesNumber);
114+
}
115+
116+
promise_test((test) => {
117+
return testFrameDecodedIncreased(receivingConnection);
118+
}, "If disabled, black frames should still be coming");
119+
120+
promise_test((test) => {
121+
track.enabled = true;
122+
return checkVideoBlack(false, canvas2, video);
123+
}, "Track is enabled, video should not be black 2");
124+
125+
</script>
126+
</body>
127+
</html>
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
PRODUCT_NAME = aom;
2+
3+
CLANG_WARN_BOOL_CONVERSION = YES;
4+
CLANG_WARN_ENUM_CONVERSION = YES;
5+
CLANG_WARN_INT_CONVERSION = YES;
6+
CLANG_WARN_STRICT_PROTOTYPES = NO;
7+
CLANG_WARN_IMPLICIT_FUNCTION_DECLARATION = NO;
8+
GCC_WARN_64_TO_32_BIT_CONVERSION = NO;
9+
COMBINE_HIDPI_IMAGES = NO;
10+
ENABLE_STRICT_OBJC_MSGSEND = YES;
11+
GCC_WARN_UNUSED_FUNCTION = NO;
12+
13+
WARNING_CFLAGS = -Wno-implicit-function-declaration -Wno-strict-prototypes;
14+
15+
// FIXME: Enable x86 optimization
16+
HEADER_SEARCH_PATHS[arch=x86_64] = Source/third_party/libaom/source/config/linux/generic Source/third_party/libaom/source/libaom Source/third_party/libaom/source/config;
17+
HEADER_SEARCH_PATHS[arch=arm64*] = Source/third_party/libaom/source/config/ios/arm64 Source/third_party/libaom/source/libaom Source/third_party/libaom/source/config;
18+
19+
INSTALL_PATH = $(INSTALL_PATH_PREFIX)$(WK_LIBRARY_INSTALL_PATH);
20+
PUBLIC_HEADERS_FOLDER_PATH = $(INSTALL_PATH_PREFIX)$(WK_LIBRARY_HEADERS_FOLDER_PATH)/libwebrtc;
21+
USE_HEADERMAP = NO;
22+
23+
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) CONFIG_REALTIME_ONLY=1 WEBRTC_WEBKIT_BUILD CONFIG_TUNE_VMAF=0
24+
25+
GCC_PREPROCESSOR_DEFINITIONS[sdk=iphonesimulator*] = $(inherited);
26+
GCC_PREPROCESSOR_DEFINITIONS[sdk=macosx*] = $(inherited) $(GCC_PREPROCESSOR_DEFINITIONS_$(WK_IS_CATALYST))
27+
GCC_PREPROCESSOR_DEFINITIONS_YES = WEBRTC_WEBKIT_MAC_CATALIST
28+
29+
ARM_FILES = *_neon.c arm_cpudetect.c *_arm.c
30+
X86_FILES = *_sse2.c *_ssse3.c *_sse4.c *_avx2.c *_avx2.cc *_avx.c *.asm
31+
32+
EXCLUDED_SOURCE_FILE_NAMES[arch=x86_64] = $(ARM_FILES) $(EXCLUDED_SOURCE_FILE_NAMES_$(WK_IS_CATALYST));
33+
EXCLUDED_SOURCE_FILE_NAMES_YES = *_sse4.c *_avx.c;
34+
EXCLUDED_SOURCE_FILE_NAMES[arch=arm64*] = $(X86_FILES) *_mmx.c
35+
EXCLUDED_SOURCE_FILE_NAMES[sdk=iphonesimulator*][arch=x86_64] = $(ARM_FILES) $(X86_FILES)
36+
37+
OTHER_LDFLAGS = $(inherited) $(SOURCE_VERSION_LDFLAGS);

Source/ThirdParty/libwebrtc/Configurations/libwebrtc.iOS.exp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ __ZN6webrtc27SessionDescriptionInterface16RemoveCandidatesERKNSt3__16vectorIN7cr
8282
__ZNK6webrtc21IceCandidateInterface10server_urlEv
8383
__ZN6webrtc18pixelBufferToFrameEP10__CVBuffer
8484
__ZN6webrtc20setApplicationStatusEb
85-
__ZN6webrtc26createWebKitDecoderFactoryENS_10WebKitH265ENS_9WebKitVP9ENS_12WebKitVP9VTBE
86-
__ZN6webrtc26createWebKitEncoderFactoryENS_10WebKitH265ENS_9WebKitVP9ENS_20WebKitH264LowLatencyE
85+
__ZN6webrtc26createWebKitDecoderFactoryENS_10WebKitH265ENS_9WebKitVP9ENS_12WebKitVP9VTBENS_9WebKitAv1E
86+
__ZN6webrtc26createWebKitEncoderFactoryENS_10WebKitH265ENS_9WebKitVP9ENS_20WebKitH264LowLatencyENS_9WebKitAv1E
8787
__ZN6webrtc29setH264HardwareEncoderAllowedEb
8888
__ZN6webrtc24registerWebKitVP8DecoderEv
8989
__ZN6webrtc24registerWebKitVP9DecoderEv

Source/ThirdParty/libwebrtc/Configurations/libwebrtc.iOSsim.exp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ __ZN6webrtc27SessionDescriptionInterface16RemoveCandidatesERKNSt3__16vectorIN7cr
8282
__ZNK6webrtc21IceCandidateInterface10server_urlEv
8383
__ZN6webrtc18pixelBufferToFrameEP10__CVBuffer
8484
__ZN6webrtc20setApplicationStatusEb
85-
__ZN6webrtc26createWebKitDecoderFactoryENS_10WebKitH265ENS_9WebKitVP9ENS_12WebKitVP9VTBE
86-
__ZN6webrtc26createWebKitEncoderFactoryENS_10WebKitH265ENS_9WebKitVP9ENS_20WebKitH264LowLatencyE
85+
__ZN6webrtc26createWebKitDecoderFactoryENS_10WebKitH265ENS_9WebKitVP9ENS_12WebKitVP9VTBENS_9WebKitAv1E
86+
__ZN6webrtc26createWebKitEncoderFactoryENS_10WebKitH265ENS_9WebKitVP9ENS_20WebKitH264LowLatencyENS_9WebKitAv1E
8787
__ZN6webrtc29setH264HardwareEncoderAllowedEb
8888
__ZN6webrtc24registerWebKitVP8DecoderEv
8989
__ZN6webrtc24registerWebKitVP9DecoderEv

Source/ThirdParty/libwebrtc/Configurations/libwebrtc.mac.exp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ __ZN6webrtc27SessionDescriptionInterface16RemoveCandidatesERKNSt3__16vectorIN7cr
8282
__ZNK6webrtc21IceCandidateInterface10server_urlEv
8383
__ZN6webrtc18pixelBufferToFrameEP10__CVBuffer
8484
__ZN6webrtc20setApplicationStatusEb
85-
__ZN6webrtc26createWebKitDecoderFactoryENS_10WebKitH265ENS_9WebKitVP9ENS_12WebKitVP9VTBE
86-
__ZN6webrtc26createWebKitEncoderFactoryENS_10WebKitH265ENS_9WebKitVP9ENS_20WebKitH264LowLatencyE
85+
__ZN6webrtc26createWebKitDecoderFactoryENS_10WebKitH265ENS_9WebKitVP9ENS_12WebKitVP9VTBENS_9WebKitAv1E
86+
__ZN6webrtc26createWebKitEncoderFactoryENS_10WebKitH265ENS_9WebKitVP9ENS_20WebKitH264LowLatencyENS_9WebKitAv1E
8787
__ZN6webrtc29setH264HardwareEncoderAllowedEb
8888
__ZN6webrtc24registerWebKitVP8DecoderEv
8989
__ZN6webrtc24registerWebKitVP9DecoderEv

0 commit comments

Comments
 (0)