Add VP9 WebRTC codec runtime flag
https://bugs.webkit.org/show_bug.cgi?id=213724

Reviewed by Eric Carlson.

Source/ThirdParty/libwebrtc:

Update WebKit binding code to switch on/off VP9 encoder/decoder.
We still use vp9_noop for now, so encoder/decoder is not functional.

* Configurations/libwebrtc.iOS.exp:
* Configurations/libwebrtc.iOSsim.exp:
* Configurations/libwebrtc.mac.exp:
* Configurations/libwebrtc.xcconfig:
* Configurations/libwebrtcpcrtc.xcconfig:
* Source/webrtc/modules/video_coding/codecs/vp9/vp9_noop.cc:
* Source/webrtc/sdk/WebKit/WebKitDecoder.mm:
(webrtc::createWebKitDecoderFactory):
* Source/webrtc/sdk/WebKit/WebKitEncoder.mm:
(webrtc::createWebKitEncoderFactory):
(webrtc::setH264HardwareEncoderAllowed):
(webrtc::isH264HardwareEncoderAllowed):
* Source/webrtc/sdk/WebKit/WebKitUtilities.h:
* Source/webrtc/sdk/WebKit/WebKitUtilities.mm:
* Source/webrtc/sdk/objc/api/video_codec/RTCVideoDecoderVP9.h:
* Source/webrtc/sdk/objc/api/video_codec/RTCVideoEncoderVP9.h:
* Source/webrtc/sdk/objc/components/video_codec/RTCDefaultVideoDecoderFactory.h:
* Source/webrtc/sdk/objc/components/video_codec/RTCDefaultVideoDecoderFactory.m:
(-[RTCDefaultVideoDecoderFactory initWithH265:vp9:]):
(-[RTCDefaultVideoDecoderFactory supportedCodecs]):
* Source/webrtc/sdk/objc/components/video_codec/RTCDefaultVideoEncoderFactory.h:
* Source/webrtc/sdk/objc/components/video_codec/RTCDefaultVideoEncoderFactory.m:
(-[RTCDefaultVideoEncoderFactory initWithH265:vp9:]):
(-[RTCDefaultVideoEncoderFactory supportedCodecs]):
* libwebrtc.xcodeproj/project.pbxproj:

Source/WebCore:

Add binding code to switch on/off VP9 in WebRTC factories based on runtime flag.

Test: webrtc/vp9.html

* page/Page.cpp:
(WebCore::m_shouldRelaxThirdPartyCookieBlocking):
* page/RuntimeEnabledFeatures.h:
(WebCore::RuntimeEnabledFeatures::webRTCVP9CodecEnabled const):
(WebCore::RuntimeEnabledFeatures::setWebRTCVP9CodecEnabled):
* platform/mediastream/libwebrtc/LibWebRTCProvider.h:
* platform/mediastream/libwebrtc/LibWebRTCProviderCocoa.cpp:
(WebCore::LibWebRTCProviderCocoa::createDecoderFactory):
(WebCore::LibWebRTCProviderCocoa::createEncoderFactory):
* testing/Internals.cpp:
(WebCore::Internals::setWebRTCH265Support):
(WebCore::Internals::setWebRTCVP9Support):
* testing/Internals.h:
* testing/Internals.idl:

Source/WebKit:

* Shared/WebPreferences.yaml:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::updatePreferences):

LayoutTests:

* webrtc/h265.html:
* webrtc/vp9-expected.txt: Added.
* webrtc/vp9.html: Added.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@263734 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 8c849c4..46f671f 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,14 @@
+2020-06-30  Youenn Fablet  <youenn@apple.com>
+
+        Add VP9 WebRTC codec runtime flag
+        https://bugs.webkit.org/show_bug.cgi?id=213724
+
+        Reviewed by Eric Carlson.
+
+        * webrtc/h265.html:
+        * webrtc/vp9-expected.txt: Added.
+        * webrtc/vp9.html: Added.
+
 2020-06-30  Diego Pino Garcia  <dpino@igalia.com>
 
         [GLIB] Unreviewed test gardening. Add more OffscreenCanvas flaky failures.
diff --git a/LayoutTests/webrtc/h265.html b/LayoutTests/webrtc/h265.html
index d188b6a..71a3a5f 100644
--- a/LayoutTests/webrtc/h265.html
+++ b/LayoutTests/webrtc/h265.html
@@ -18,9 +18,16 @@
 var hasH265 = false;
 test(() => {
     if (window.internals)
-        window.internals.clearPeerConnectionFactory();
+        window.internals.setWebRTCH265Support(false);
 
-    const codecs = RTCRtpSender.getCapabilities("video").codecs;
+    let codecs = RTCRtpSender.getCapabilities("video").codecs;
+    hasH265 = codecs.some((codec) => { return codec.mimeType == "video/H265"; });
+    assert_false(hasH265);
+
+    if (window.internals)
+        window.internals.setWebRTCH265Support(true);
+
+    codecs = RTCRtpSender.getCapabilities("video").codecs;
     hasH265 = codecs.some((codec) => { return codec.mimeType == "video/H265"; });
     assert_true(hasH265);
 }, "H265 in getCapabilities");
diff --git a/LayoutTests/webrtc/vp9-expected.txt b/LayoutTests/webrtc/vp9-expected.txt
new file mode 100644
index 0000000..6ca93b7
--- /dev/null
+++ b/LayoutTests/webrtc/vp9-expected.txt
@@ -0,0 +1,4 @@
+
+PASS VP9 in getCapabilities 
+PASS Verify VP9 activation 
+
diff --git a/LayoutTests/webrtc/vp9.html b/LayoutTests/webrtc/vp9.html
new file mode 100644
index 0000000..a99d276
--- /dev/null
+++ b/LayoutTests/webrtc/vp9.html
@@ -0,0 +1,39 @@
+<!doctype html>
+<html>
+    <head>
+        <meta charset="utf-8">
+        <title>VP9 in WebRTC</title>
+        <script src="../resources/testharness.js"></script>
+        <script src="../resources/testharnessreport.js"></script>
+    </head>
+    <body>
+        <script>
+let hasVP9;
+test(() => {
+    if (window.internals)
+        window.internals.setWebRTCVP9Support(false);
+
+    let codecs = RTCRtpSender.getCapabilities("video").codecs;
+    hasVP9 = codecs.some((codec) => { return codec.mimeType == "video/VP9"; });
+    assert_false(hasVP9);
+
+    if (window.internals)
+        window.internals.setWebRTCVP9Support(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")
+}
+        </script>
+    </body>
+</html>
diff --git a/Source/ThirdParty/libwebrtc/ChangeLog b/Source/ThirdParty/libwebrtc/ChangeLog
index ad31a63..057b5ba 100644
--- a/Source/ThirdParty/libwebrtc/ChangeLog
+++ b/Source/ThirdParty/libwebrtc/ChangeLog
@@ -1,3 +1,39 @@
+2020-06-30  Youenn Fablet  <youenn@apple.com>
+
+        Add VP9 WebRTC codec runtime flag
+        https://bugs.webkit.org/show_bug.cgi?id=213724
+
+        Reviewed by Eric Carlson.
+
+        Update WebKit binding code to switch on/off VP9 encoder/decoder.
+        We still use vp9_noop for now, so encoder/decoder is not functional.
+
+        * Configurations/libwebrtc.iOS.exp:
+        * Configurations/libwebrtc.iOSsim.exp:
+        * Configurations/libwebrtc.mac.exp:
+        * Configurations/libwebrtc.xcconfig:
+        * Configurations/libwebrtcpcrtc.xcconfig:
+        * Source/webrtc/modules/video_coding/codecs/vp9/vp9_noop.cc:
+        * Source/webrtc/sdk/WebKit/WebKitDecoder.mm:
+        (webrtc::createWebKitDecoderFactory):
+        * Source/webrtc/sdk/WebKit/WebKitEncoder.mm:
+        (webrtc::createWebKitEncoderFactory):
+        (webrtc::setH264HardwareEncoderAllowed):
+        (webrtc::isH264HardwareEncoderAllowed):
+        * Source/webrtc/sdk/WebKit/WebKitUtilities.h:
+        * Source/webrtc/sdk/WebKit/WebKitUtilities.mm:
+        * Source/webrtc/sdk/objc/api/video_codec/RTCVideoDecoderVP9.h:
+        * Source/webrtc/sdk/objc/api/video_codec/RTCVideoEncoderVP9.h:
+        * Source/webrtc/sdk/objc/components/video_codec/RTCDefaultVideoDecoderFactory.h:
+        * Source/webrtc/sdk/objc/components/video_codec/RTCDefaultVideoDecoderFactory.m:
+        (-[RTCDefaultVideoDecoderFactory initWithH265:vp9:]):
+        (-[RTCDefaultVideoDecoderFactory supportedCodecs]):
+        * Source/webrtc/sdk/objc/components/video_codec/RTCDefaultVideoEncoderFactory.h:
+        * Source/webrtc/sdk/objc/components/video_codec/RTCDefaultVideoEncoderFactory.m:
+        (-[RTCDefaultVideoEncoderFactory initWithH265:vp9:]):
+        (-[RTCDefaultVideoEncoderFactory supportedCodecs]):
+        * libwebrtc.xcodeproj/project.pbxproj:
+
 2020-06-24  Youenn Fablet  <youenn@apple.com>
 
         Add logging to WebRTC video pipeline to check for frame rate stability
diff --git a/Source/ThirdParty/libwebrtc/Configurations/libwebrtc.iOS.exp b/Source/ThirdParty/libwebrtc/Configurations/libwebrtc.iOS.exp
index c51700e..1186d81 100644
--- a/Source/ThirdParty/libwebrtc/Configurations/libwebrtc.iOS.exp
+++ b/Source/ThirdParty/libwebrtc/Configurations/libwebrtc.iOS.exp
@@ -104,8 +104,8 @@
 __ZN6webrtc27SessionDescriptionInterface16RemoveCandidatesERKNSt3__16vectorIN7cricket9CandidateENS1_9allocatorIS4_EEEE
 __ZNK6webrtc21IceCandidateInterface10server_urlEv
 __ZN6webrtc20setApplicationStatusEb
-__ZN6webrtc26createWebKitDecoderFactoryENS_18WebKitCodecSupportE
-__ZN6webrtc26createWebKitEncoderFactoryENS_18WebKitCodecSupportE
+__ZN6webrtc26createWebKitDecoderFactoryENS_10WebKitH265ENS_9WebKitVP9E
+__ZN6webrtc26createWebKitEncoderFactoryENS_10WebKitH265ENS_9WebKitVP9E
 __ZN6webrtc29setH264HardwareEncoderAllowedEb
 __ZN6webrtc20pixelBufferFromFrameERKNS_10VideoFrameERKNSt3__18functionIFP10__CVBuffermmEEE
 __ZN6webrtc18pixelBufferToFrameEP10__CVBuffer
diff --git a/Source/ThirdParty/libwebrtc/Configurations/libwebrtc.iOSsim.exp b/Source/ThirdParty/libwebrtc/Configurations/libwebrtc.iOSsim.exp
index c51700e..1186d81 100644
--- a/Source/ThirdParty/libwebrtc/Configurations/libwebrtc.iOSsim.exp
+++ b/Source/ThirdParty/libwebrtc/Configurations/libwebrtc.iOSsim.exp
@@ -104,8 +104,8 @@
 __ZN6webrtc27SessionDescriptionInterface16RemoveCandidatesERKNSt3__16vectorIN7cricket9CandidateENS1_9allocatorIS4_EEEE
 __ZNK6webrtc21IceCandidateInterface10server_urlEv
 __ZN6webrtc20setApplicationStatusEb
-__ZN6webrtc26createWebKitDecoderFactoryENS_18WebKitCodecSupportE
-__ZN6webrtc26createWebKitEncoderFactoryENS_18WebKitCodecSupportE
+__ZN6webrtc26createWebKitDecoderFactoryENS_10WebKitH265ENS_9WebKitVP9E
+__ZN6webrtc26createWebKitEncoderFactoryENS_10WebKitH265ENS_9WebKitVP9E
 __ZN6webrtc29setH264HardwareEncoderAllowedEb
 __ZN6webrtc20pixelBufferFromFrameERKNS_10VideoFrameERKNSt3__18functionIFP10__CVBuffermmEEE
 __ZN6webrtc18pixelBufferToFrameEP10__CVBuffer
diff --git a/Source/ThirdParty/libwebrtc/Configurations/libwebrtc.mac.exp b/Source/ThirdParty/libwebrtc/Configurations/libwebrtc.mac.exp
index a47d962..2006dd0 100644
--- a/Source/ThirdParty/libwebrtc/Configurations/libwebrtc.mac.exp
+++ b/Source/ThirdParty/libwebrtc/Configurations/libwebrtc.mac.exp
@@ -104,8 +104,8 @@
 __ZN6webrtc27SessionDescriptionInterface16RemoveCandidatesERKNSt3__16vectorIN7cricket9CandidateENS1_9allocatorIS4_EEEE
 __ZNK6webrtc21IceCandidateInterface10server_urlEv
 __ZN6webrtc20setApplicationStatusEb
-__ZN6webrtc26createWebKitDecoderFactoryENS_18WebKitCodecSupportE
-__ZN6webrtc26createWebKitEncoderFactoryENS_18WebKitCodecSupportE
+__ZN6webrtc26createWebKitDecoderFactoryENS_10WebKitH265ENS_9WebKitVP9E
+__ZN6webrtc26createWebKitEncoderFactoryENS_10WebKitH265ENS_9WebKitVP9E
 __ZN6webrtc29setH264HardwareEncoderAllowedEb
 __ZN6webrtc20pixelBufferFromFrameERKNS_10VideoFrameERKNSt3__18functionIFP10__CVBuffermmEEE
 __ZN6webrtc18pixelBufferToFrameEP10__CVBuffer
diff --git a/Source/ThirdParty/libwebrtc/Configurations/libwebrtc.xcconfig b/Source/ThirdParty/libwebrtc/Configurations/libwebrtc.xcconfig
index 76034d9..464f2f7 100644
--- a/Source/ThirdParty/libwebrtc/Configurations/libwebrtc.xcconfig
+++ b/Source/ThirdParty/libwebrtc/Configurations/libwebrtc.xcconfig
@@ -26,7 +26,7 @@
 WARNING_CFLAGS = -Wno-deprecated-declarations $(inherited);
 
 // FIXME: Set WEBRTC_USE_BUILTIN_ISAC_FIX and WEBRTC_USE_BUILTIN_ISAC_FLOAT for iOS and Mac
-GCC_PREPROCESSOR_DEFINITIONS = GTEST_RELATIVE_PATH WEBRTC_OPUS_SUPPORT_120MS_PTIME=0 WEBRTC_POSIX WEBRTC_MAC SSL_USE_OPENSSL FEATURE_ENABLE_SSL HAVE_SRTP HAVE_NETINET_IN_H HAVE_OPENSSL_SSL_H SCTP_PROCESS_LEVEL_LOCKS SCTP_SIMPLE_ALLOCATOR SCTP_USE_OPENSSL_SHA1 __Userspace__ HAVE_SA_LEN HAVE_SCONN_LEN __APPLE_USE_RFC_2292 __Userspace_os_Darwin NON_WINDOWS_DEFINE HAVE_WEBRTC_VIDEO HAVE_WEBRTC_VOICE WEBRTC_INTELLIGIBILITY_ENHANCER=0 WEBRTC_APM_DEBUG_DUMP=0 WEBRTC_NS_FLOAT WEBRTC_USE_BUILTIN_ILBC WEBRTC_CODEC_ILBC WEBRTC_USE_BUILTIN_OPUS WEBRTC_CODEC_OPUS WEBRTC_CODEC_ISAC WEBRTC_CODEC_RED HAVE_STDINT_H HAVE_STDLIB_H HAVE_UINT64_T OPENSSL HAVE_CONFIG_H WEBRTC_WEBKIT_BUILD HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE  HAVE_SCTP WEBRTC_CODEC_G711 WEBRTC_CODEC_G722 WEBRTC_OPUS_VARIABLE_COMPLEXITY=0 WEBRTC_USE_BUILTIN_ISAC_FIX=1 WEBRTC_USE_BUILTIN_ISAC_FLOAT=0 USE_BUILTIN_SW_CODECS WEBRTC_WEBKIT_BUILD $(inherited);
+GCC_PREPROCESSOR_DEFINITIONS = GTEST_RELATIVE_PATH WEBRTC_OPUS_SUPPORT_120MS_PTIME=0 WEBRTC_POSIX WEBRTC_MAC SSL_USE_OPENSSL FEATURE_ENABLE_SSL HAVE_SRTP HAVE_NETINET_IN_H HAVE_OPENSSL_SSL_H SCTP_PROCESS_LEVEL_LOCKS SCTP_SIMPLE_ALLOCATOR SCTP_USE_OPENSSL_SHA1 __Userspace__ HAVE_SA_LEN HAVE_SCONN_LEN __APPLE_USE_RFC_2292 __Userspace_os_Darwin NON_WINDOWS_DEFINE HAVE_WEBRTC_VIDEO HAVE_WEBRTC_VOICE WEBRTC_INTELLIGIBILITY_ENHANCER=0 WEBRTC_APM_DEBUG_DUMP=0 WEBRTC_NS_FLOAT WEBRTC_USE_BUILTIN_ILBC WEBRTC_CODEC_ILBC WEBRTC_USE_BUILTIN_OPUS WEBRTC_CODEC_OPUS WEBRTC_CODEC_ISAC WEBRTC_CODEC_RED HAVE_STDINT_H HAVE_STDLIB_H HAVE_UINT64_T OPENSSL HAVE_CONFIG_H WEBRTC_WEBKIT_BUILD HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE  HAVE_SCTP WEBRTC_CODEC_G711 WEBRTC_CODEC_G722 WEBRTC_OPUS_VARIABLE_COMPLEXITY=0 WEBRTC_USE_BUILTIN_ISAC_FIX=1 WEBRTC_USE_BUILTIN_ISAC_FLOAT=0 USE_BUILTIN_SW_CODECS WEBRTC_WEBKIT_BUILD RTC_ENABLE_VP9 $(inherited);
 
 GCC_PREPROCESSOR_DEFINITIONS[sdk=macosx*] = $(inherited) WEBRTC_USE_VTB_HARDWARE_ENCODER;
 GCC_PREPROCESSOR_DEFINITIONS[sdk=iphoneos*] = $(inherited) WEBRTC_IOS;
diff --git a/Source/ThirdParty/libwebrtc/Configurations/libwebrtcpcrtc.xcconfig b/Source/ThirdParty/libwebrtc/Configurations/libwebrtcpcrtc.xcconfig
index 90fee5c..a99dd1f 100644
--- a/Source/ThirdParty/libwebrtc/Configurations/libwebrtcpcrtc.xcconfig
+++ b/Source/ThirdParty/libwebrtc/Configurations/libwebrtcpcrtc.xcconfig
@@ -12,7 +12,7 @@
 PUBLIC_HEADERS_FOLDER_PATH = /usr/local/include/libwebrtc;
 USE_HEADERMAP = NO;
 
-GCC_PREPROCESSOR_DEFINITIONS = WEBRTC_POSIX WEBRTC_MAC SSL_USE_OPENSSL FEATURE_ENABLE_SSL HAVE_SRTP HAVE_OPENSSL_SSL_H SCTP_PROCESS_LEVEL_LOCKS SCTP_SIMPLE_ALLOCATOR SCTP_USE_OPENSSL_SHA1 __Userspace__ HAVE_SA_LEN HAVE_SCONN_LEN __APPLE_USE_RFC_2292 __Userspace_os_Darwin NON_WINDOWS_DEFINE HAVE_WEBRTC_VIDEO HAVE_WEBRTC_VOICE WEBRTC_INTELLIGIBILITY_ENHANCER=0 WEBRTC_APM_DEBUG_DUMP=0 WEBRTC_NS_FLOAT WEBRTC_USE_BUILTIN_ILBC WEBRTC_CODEC_ILBC WEBRTC_USE_BUILTIN_OPUS WEBRTC_CODEC_OPUS WEBRTC_CODEC_ISAC WEBRTC_CODEC_RED HAVE_STDINT_H HAVE_STDLIB_H HAVE_UINT64_T OPENSSL HAVE_CONFIG_H WEBRTC_WEBKIT_BUILD HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE HAVE_NETINET_IN_H HAVE_SCTP $(inherited);
+GCC_PREPROCESSOR_DEFINITIONS = WEBRTC_POSIX WEBRTC_MAC SSL_USE_OPENSSL FEATURE_ENABLE_SSL HAVE_SRTP HAVE_OPENSSL_SSL_H SCTP_PROCESS_LEVEL_LOCKS SCTP_SIMPLE_ALLOCATOR SCTP_USE_OPENSSL_SHA1 __Userspace__ HAVE_SA_LEN HAVE_SCONN_LEN __APPLE_USE_RFC_2292 __Userspace_os_Darwin NON_WINDOWS_DEFINE HAVE_WEBRTC_VIDEO HAVE_WEBRTC_VOICE WEBRTC_INTELLIGIBILITY_ENHANCER=0 WEBRTC_APM_DEBUG_DUMP=0 WEBRTC_NS_FLOAT WEBRTC_USE_BUILTIN_ILBC WEBRTC_CODEC_ILBC WEBRTC_USE_BUILTIN_OPUS WEBRTC_CODEC_OPUS WEBRTC_CODEC_ISAC WEBRTC_CODEC_RED HAVE_STDINT_H HAVE_STDLIB_H HAVE_UINT64_T OPENSSL HAVE_CONFIG_H WEBRTC_WEBKIT_BUILD HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE HAVE_NETINET_IN_H HAVE_SCTP RTC_ENABLE_VP9 $(inherited);
 
 GCC_PREPROCESSOR_DEFINITIONS[sdk=macosx*] = $(inherited);
 GCC_PREPROCESSOR_DEFINITIONS[sdk=iphoneos*] = $(inherited) WEBRTC_IOS;
diff --git a/Source/ThirdParty/libwebrtc/Source/webrtc/modules/video_coding/codecs/vp9/vp9_noop.cc b/Source/ThirdParty/libwebrtc/Source/webrtc/modules/video_coding/codecs/vp9/vp9_noop.cc
index 0253a81e..249fc74 100644
--- a/Source/ThirdParty/libwebrtc/Source/webrtc/modules/video_coding/codecs/vp9/vp9_noop.cc
+++ b/Source/ThirdParty/libwebrtc/Source/webrtc/modules/video_coding/codecs/vp9/vp9_noop.cc
@@ -9,9 +9,7 @@
  *
  */
 
-#if defined(RTC_ENABLE_VP9)
-#error
-#endif  // !defined(RTC_ENABLE_VP9)
+// FIXME: Use libvpx to support VP9 encoder and decoder.
 
 #include "modules/video_coding/codecs/vp9/include/vp9.h"
 
diff --git a/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitDecoder.mm b/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitDecoder.mm
index 0550505..d05d062 100644
--- a/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitDecoder.mm
+++ b/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitDecoder.mm
@@ -167,9 +167,9 @@
     return std::make_unique<RemoteVideoDecoder>(identifier);
 }
 
-std::unique_ptr<webrtc::VideoDecoderFactory> createWebKitDecoderFactory(WebKitCodecSupport codecSupport)
+std::unique_ptr<webrtc::VideoDecoderFactory> createWebKitDecoderFactory(WebKitH265 supportsH265, WebKitVP9 supportsVP9)
 {
-    auto internalFactory = ObjCToNativeVideoDecoderFactory([[RTCDefaultVideoDecoderFactory alloc] initWithH265: codecSupport == WebKitCodecSupport::H264VP8AndH265]);
+    auto internalFactory = ObjCToNativeVideoDecoderFactory([[RTCDefaultVideoDecoderFactory alloc] initWithH265: supportsH265 == WebKitH265::On vp9: supportsVP9 == WebKitVP9::On]);
     if (videoDecoderCallbacks().createCallback)
         return std::make_unique<RemoteVideoDecoderFactory>(std::move(internalFactory));
     return internalFactory;
diff --git a/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitEncoder.mm b/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitEncoder.mm
index 0730f37..e72cf7a 100644
--- a/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitEncoder.mm
+++ b/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitEncoder.mm
@@ -33,10 +33,11 @@
 #include "sdk/objc/api/peerconnection/RTCRtpFragmentationHeader+Private.h"
 #include "sdk/objc/api/peerconnection/RTCVideoCodecInfo+Private.h"
 #include "sdk/objc/api/peerconnection/RTCVideoEncoderSettings+Private.h"
+#include "sdk/objc/components/video_codec/RTCDefaultVideoEncoderFactory.h"
 #include "sdk/objc/components/video_codec/RTCVideoEncoderH264.h"
 #include "sdk/objc/components/video_codec/RTCVideoEncoderH265.h"
 #include "sdk/objc/native/src/objc_frame_buffer.h"
-
+#include "sdk/objc/native/api/video_encoder_factory.h"
 
 @interface WK_RTCLocalVideoH264H265Encoder : NSObject
 - (instancetype)initWithCodecInfo:(RTCVideoCodecInfo*)codecInfo;
@@ -94,6 +95,30 @@
 @end
 namespace webrtc {
 
+std::unique_ptr<webrtc::VideoEncoderFactory> createWebKitEncoderFactory(WebKitH265 supportsH265, WebKitVP9 supportsVP9)
+{
+#if ENABLE_VCP_ENCODER || ENABLE_VCP_VTB_ENCODER
+    static std::once_flag onceFlag;
+    std::call_once(onceFlag, [] {
+        webrtc::VPModuleInitialize();
+    });
+#endif
+
+    auto internalFactory = ObjCToNativeVideoEncoderFactory([[RTCDefaultVideoEncoderFactory alloc] initWithH265: supportsH265 == WebKitH265::On vp9:supportsVP9 == WebKitVP9::On]);
+    return std::make_unique<VideoEncoderFactoryWithSimulcast>(std::move(internalFactory));
+}
+
+static bool h264HardwareEncoderAllowed = true;
+void setH264HardwareEncoderAllowed(bool allowed)
+{
+    h264HardwareEncoderAllowed = allowed;
+}
+
+bool isH264HardwareEncoderAllowed()
+{
+    return h264HardwareEncoderAllowed;
+}
+
 std::unique_ptr<VideoEncoder> VideoEncoderFactoryWithSimulcast::CreateVideoEncoder(const SdpVideoFormat& format)
 {
     return std::make_unique<EncoderSimulcastProxy>(m_internalEncoderFactory.get(), format);
diff --git a/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitUtilities.h b/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitUtilities.h
index 63913f2..ce39e35 100644
--- a/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitUtilities.h
+++ b/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitUtilities.h
@@ -39,10 +39,11 @@
 class VideoEncoderFactory;
 class VideoFrame;
 
-enum class WebKitCodecSupport { H264VP8AndH265, H264AndVP8 };
+enum class WebKitH265 { Off, On };
+enum class WebKitVP9 { Off, On };
 
-std::unique_ptr<webrtc::VideoEncoderFactory> createWebKitEncoderFactory(WebKitCodecSupport);
-std::unique_ptr<webrtc::VideoDecoderFactory> createWebKitDecoderFactory(WebKitCodecSupport);
+std::unique_ptr<webrtc::VideoEncoderFactory> createWebKitEncoderFactory(WebKitH265, WebKitVP9);
+std::unique_ptr<webrtc::VideoDecoderFactory> createWebKitDecoderFactory(WebKitH265, WebKitVP9);
 
 void setApplicationStatus(bool isActive);
 
diff --git a/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitUtilities.mm b/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitUtilities.mm
index 772a09f..79aa97b 100644
--- a/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitUtilities.mm
+++ b/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitUtilities.mm
@@ -25,76 +25,10 @@
 
 #include "WebKitUtilities.h"
 
-//#include "Common/RTCUIApplicationStatusObserver.h"
-#import "WebRTC/RTCVideoCodecH264.h"
-
-#include "api/video/video_frame.h"
-#include "helpers/scoped_cftyperef.h"
 #include "native/src/objc_frame_buffer.h"
-#include "rtc_base/time_utils.h"
-#include "sdk/objc/components/video_codec/nalu_rewriter.h"
 #include "third_party/libyuv/include/libyuv/convert_from.h"
-#include "webrtc/rtc_base/checks.h"
-#include "Framework/Headers/WebRTC/RTCVideoCodecFactory.h"
-#include "Framework/Headers/WebRTC/RTCVideoFrame.h"
 #include "Framework/Headers/WebRTC/RTCVideoFrameBuffer.h"
-#include "Framework/Native/api/video_decoder_factory.h"
-#include "Framework/Native/api/video_encoder_factory.h"
-#include "VideoProcessingSoftLink.h"
-#include "WebKitEncoder.h"
 
-#include <mutex>
-
-/*
-#if !defined(WEBRTC_IOS)
-__attribute__((objc_runtime_name("WK_RTCUIApplicationStatusObserver")))
-@interface RTCUIApplicationStatusObserver : NSObject
-
-+ (instancetype)sharedInstance;
-+ (void)prepareForUse;
-
-- (BOOL)isApplicationActive;
-
-@end
-#endif
-
-@implementation RTCUIApplicationStatusObserver {
-    BOOL _isActive;
-}
-
-+ (instancetype)sharedInstance {
-    static id sharedInstance;
-    static dispatch_once_t onceToken;
-    dispatch_once(&onceToken, ^{
-        sharedInstance = [[self alloc] init];
-    });
-
-    return sharedInstance;
-}
-
-+ (void)prepareForUse {
-    __unused RTCUIApplicationStatusObserver *observer = [self sharedInstance];
-}
-
-- (id)init {
-    _isActive = YES;
-    return self;
-}
-
-- (void)setActive {
-    _isActive = YES;
-}
-
-- (void)setInactive {
-    _isActive = NO;
-}
-
-- (BOOL)isApplicationActive {
-    return _isActive;
-}
-
-@end
-*/
 namespace webrtc {
 
 void setApplicationStatus(bool isActive)
@@ -107,30 +41,6 @@
  */
 }
 
-std::unique_ptr<webrtc::VideoEncoderFactory> createWebKitEncoderFactory(WebKitCodecSupport codecSupport)
-{
-#if ENABLE_VCP_ENCODER || ENABLE_VCP_VTB_ENCODER
-    static std::once_flag onceFlag;
-    std::call_once(onceFlag, [] {
-        webrtc::VPModuleInitialize();
-    });
-#endif
-
-    auto internalFactory = ObjCToNativeVideoEncoderFactory([[RTCDefaultVideoEncoderFactory alloc] initWithH265: codecSupport == WebKitCodecSupport::H264VP8AndH265]);
-    return std::make_unique<VideoEncoderFactoryWithSimulcast>(std::move(internalFactory));
-}
-
-static bool h264HardwareEncoderAllowed = true;
-void setH264HardwareEncoderAllowed(bool allowed)
-{
-    h264HardwareEncoderAllowed = allowed;
-}
-
-bool isH264HardwareEncoderAllowed()
-{
-    return h264HardwareEncoderAllowed;
-}
-
 rtc::scoped_refptr<webrtc::VideoFrameBuffer> pixelBufferToFrame(CVPixelBufferRef pixelBuffer)
 {
     RTCCVPixelBuffer *frameBuffer = [[RTCCVPixelBuffer alloc] initWithPixelBuffer:pixelBuffer];
diff --git a/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/api/video_codec/RTCVideoDecoderVP9.h b/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/api/video_codec/RTCVideoDecoderVP9.h
index b74c1ef..0519fa6 100644
--- a/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/api/video_codec/RTCVideoDecoderVP9.h
+++ b/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/api/video_codec/RTCVideoDecoderVP9.h
@@ -14,6 +14,7 @@
 #import "RTCVideoDecoder.h"
 
 RTC_OBJC_EXPORT
+__attribute__((objc_runtime_name("WK_RTCVideoDecoderVP9")))
 @interface RTCVideoDecoderVP9 : NSObject
 
 /* This returns a VP9 decoder that can be returned from a RTCVideoDecoderFactory injected into
diff --git a/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/api/video_codec/RTCVideoEncoderVP9.h b/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/api/video_codec/RTCVideoEncoderVP9.h
index 9efea4b..8226475 100644
--- a/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/api/video_codec/RTCVideoEncoderVP9.h
+++ b/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/api/video_codec/RTCVideoEncoderVP9.h
@@ -14,6 +14,7 @@
 #import "RTCVideoEncoder.h"
 
 RTC_OBJC_EXPORT
+__attribute__((objc_runtime_name("WK_RTCVideoEncoderVP9")))
 @interface RTCVideoEncoderVP9 : NSObject
 
 /* This returns a VP9 encoder that can be returned from a RTCVideoEncoderFactory injected into
diff --git a/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/components/video_codec/RTCDefaultVideoDecoderFactory.h b/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/components/video_codec/RTCDefaultVideoDecoderFactory.h
index b838a4b..e2820b2 100644
--- a/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/components/video_codec/RTCDefaultVideoDecoderFactory.h
+++ b/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/components/video_codec/RTCDefaultVideoDecoderFactory.h
@@ -21,7 +21,7 @@
 RTC_OBJC_EXPORT
 __attribute__((objc_runtime_name("WK_RTCDefaultVideoDecoderFactory")))
 @interface RTCDefaultVideoDecoderFactory : NSObject <RTCVideoDecoderFactory>
-- (id)initWithH265:(bool)supportH265;
+- (id)initWithH265:(bool)supportH265 vp9:(bool)supportsVP9;
 @end
 
 NS_ASSUME_NONNULL_END
diff --git a/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/components/video_codec/RTCDefaultVideoDecoderFactory.m b/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/components/video_codec/RTCDefaultVideoDecoderFactory.m
index a496ae5..e5f4a20 100644
--- a/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/components/video_codec/RTCDefaultVideoDecoderFactory.m
+++ b/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/components/video_codec/RTCDefaultVideoDecoderFactory.m
@@ -24,14 +24,16 @@
 #endif
 
 @implementation RTCDefaultVideoDecoderFactory {
-  bool _supportH265;
+  bool _supportsH265;
+  bool _supportsVP9;
 }
 
-- (id)initWithH265:(bool)supportH265
+- (id)initWithH265:(bool)supportsH265 vp9:(bool)supportsVP9
 {
   self = [super init];
   if (self) {
-      _supportH265 = supportH265;
+      _supportsH265 = supportsH265;
+      _supportsVP9 = supportsVP9;
   }
   return self;
 }
@@ -57,35 +59,25 @@
 
   RTCVideoCodecInfo *vp8Info = [[RTCVideoCodecInfo alloc] initWithName:kRTCVideoCodecVp8Name];
 
+  NSMutableArray<RTCVideoCodecInfo *> *codecs = [[NSMutableArray alloc] initWithCapacity:5];
+
+  [codecs addObject:constrainedHighInfo];
+  [codecs addObject:constrainedBaselineInfo];
 #if !defined(RTC_DISABLE_H265)
-  RTCVideoCodecInfo *h265Info = [[RTCVideoCodecInfo alloc] initWithName:kRTCVideoCodecH265Name];
+  if (_supportsH265) {
+    RTCVideoCodecInfo *h265Info = [[RTCVideoCodecInfo alloc] initWithName:kRTCVideoCodecH265Name];
+    [codecs addObject:h265Info];
+  }
 #endif
- 
+  [codecs addObject:vp8Info];
 #if defined(RTC_ENABLE_VP9)
-  RTCVideoCodecInfo *vp9Info = [[RTCVideoCodecInfo alloc] initWithName:kRTCVideoCodecVp9Name];
+  if (_supportsVP9) {
+    RTCVideoCodecInfo *vp9Info = [[RTCVideoCodecInfo alloc] initWithName:kRTCVideoCodecVp9Name];
+    [codecs addObject:vp9Info];
+  }
 #endif
 
-  if (!_supportH265) {
-    return @[
-      constrainedHighInfo,
-      constrainedBaselineInfo,
-      vp8Info,
-#if defined(RTC_ENABLE_VP9)
-      vp9Info,
-#endif
-    ];
-  }
-  return @[
-    constrainedHighInfo,
-    constrainedBaselineInfo,
-#if !defined(RTC_DISABLE_H265)
-    h265Info,
-#endif
-    vp8Info,
-#if defined(RTC_ENABLE_VP9)
-    vp9Info,
-#endif
-  ];
+  return codecs;
 }
 
 - (id<RTCVideoDecoder>)createDecoder:(RTCVideoCodecInfo *)info {
diff --git a/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/components/video_codec/RTCDefaultVideoEncoderFactory.h b/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/components/video_codec/RTCDefaultVideoEncoderFactory.h
index a995daa..d760054 100644
--- a/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/components/video_codec/RTCDefaultVideoEncoderFactory.h
+++ b/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/components/video_codec/RTCDefaultVideoEncoderFactory.h
@@ -22,8 +22,9 @@
 __attribute__((objc_runtime_name("WK_RTCDefaultVideoEncoderFactory")))
 @interface RTCDefaultVideoEncoderFactory : NSObject <RTCVideoEncoderFactory>
 
-- (id)initWithH265:(bool)supportH265;
+- (id)initWithH265:(bool)supportH265 vp9:(bool)supportsVP9;
 + (NSArray<RTCVideoCodecInfo *> *)supportedCodecs;
++ (NSArray<RTCVideoCodecInfo *> *)supportedCodecsWithH265:(bool)supportsH265 vp9:(bool)supportsVP9;
 
 @end
 
diff --git a/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/components/video_codec/RTCDefaultVideoEncoderFactory.m b/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/components/video_codec/RTCDefaultVideoEncoderFactory.m
index d68609d..9fff02d 100644
--- a/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/components/video_codec/RTCDefaultVideoEncoderFactory.m
+++ b/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/components/video_codec/RTCDefaultVideoEncoderFactory.m
@@ -24,19 +24,25 @@
 #endif
 
 @implementation RTCDefaultVideoEncoderFactory {
-  bool _supportH265;
+  bool _supportsH265;
+  bool _supportsVP9;
 }
 
-- (id)initWithH265:(bool)supportH265
+- (id)initWithH265:(bool)supportsH265 vp9:(bool)supportsVP9
 {
   self = [super init];
   if (self) {
-      _supportH265 = supportH265;
+      _supportsH265 = supportsH265;
+      _supportsVP9 = supportsVP9;
   }
   return self;
 }
 
 + (NSArray<RTCVideoCodecInfo *> *)supportedCodecs {
+    return [self supportedCodecsWithH265:true vp9:true];
+}
+
++ (NSArray<RTCVideoCodecInfo *> *)supportedCodecsWithH265:(bool)supportsH265 vp9:(bool)supportsVP9 {
   NSDictionary<NSString *, NSString *> *constrainedHighParams = @{
     @"profile-level-id" : kRTCMaxSupportedH264ProfileLevelConstrainedHigh,
     @"level-asymmetry-allowed" : @"1",
@@ -55,27 +61,28 @@
       [[RTCVideoCodecInfo alloc] initWithName:kRTCVideoCodecH264Name
                                    parameters:constrainedBaselineParams];
 
-#if !defined(DISABLE_H265)
-  RTCVideoCodecInfo *h265Info = [[RTCVideoCodecInfo alloc] initWithName:kRTCVideoCodecH265Name];
+  NSMutableArray<RTCVideoCodecInfo *> *codecs = [[NSMutableArray alloc] initWithCapacity:5];
+
+  [codecs addObject:constrainedHighInfo];
+  [codecs addObject:constrainedBaselineInfo];
+#if !defined(RTC_DISABLE_H265)
+  if (supportsH265) {
+    RTCVideoCodecInfo *h265Info = [[RTCVideoCodecInfo alloc] initWithName:kRTCVideoCodecH265Name];
+    [codecs addObject:h265Info];
+  }
 #endif
 
   RTCVideoCodecInfo *vp8Info = [[RTCVideoCodecInfo alloc] initWithName:kRTCVideoCodecVp8Name];
+  [codecs addObject:vp8Info];
 
 #if defined(RTC_ENABLE_VP9)
-  RTCVideoCodecInfo *vp9Info = [[RTCVideoCodecInfo alloc] initWithName:kRTCVideoCodecVp9Name];
+  if (supportsVP9) {
+    RTCVideoCodecInfo *vp9Info = [[RTCVideoCodecInfo alloc] initWithName:kRTCVideoCodecVp9Name];
+    [codecs addObject:vp9Info];
+  }
 #endif
 
-  return @[
-    constrainedHighInfo,
-    constrainedBaselineInfo,
-#if !defined(DISABLE_H265)
-    h265Info,
-#endif
-    vp8Info,
-#if defined(RTC_ENABLE_VP9)
-    vp9Info,
-#endif
-  ];
+  return codecs;
 }
 
 - (id<RTCVideoEncoder>)createEncoder:(RTCVideoCodecInfo *)info {
@@ -99,14 +106,7 @@
 }
 
 - (NSArray<RTCVideoCodecInfo *> *)supportedCodecs {
-  NSMutableArray<RTCVideoCodecInfo *> *codecs = [[[self class] supportedCodecs] mutableCopy];
-
-  NSMutableArray<RTCVideoCodecInfo *> *orderedCodecs = [NSMutableArray array];
-  [orderedCodecs addObjectsFromArray:codecs];
-  if (!_supportH265)
-    [orderedCodecs removeObjectAtIndex:0];
-
-  return [orderedCodecs copy];
+  return [[self class] supportedCodecsWithH265:_supportsH265 vp9: _supportsVP9];
 }
 
 @end
diff --git a/Source/ThirdParty/libwebrtc/libwebrtc.xcodeproj/project.pbxproj b/Source/ThirdParty/libwebrtc/libwebrtc.xcodeproj/project.pbxproj
index 19aaeeb..56d650a 100644
--- a/Source/ThirdParty/libwebrtc/libwebrtc.xcodeproj/project.pbxproj
+++ b/Source/ThirdParty/libwebrtc/libwebrtc.xcodeproj/project.pbxproj
@@ -978,6 +978,12 @@
 		413E67A32169889500EF37ED /* RTCVideoEncoderQpThresholds.m in Sources */ = {isa = PBXBuildFile; fileRef = 413E679F2169889500EF37ED /* RTCVideoEncoderQpThresholds.m */; };
 		413E67A5216988DC00EF37ED /* video_stream_encoder_observer.cc in Sources */ = {isa = PBXBuildFile; fileRef = 413E67A4216988DC00EF37ED /* video_stream_encoder_observer.cc */; };
 		413F4D7022B0BAEF006A7A6B /* RTCVideoDecoderVP8.h in Headers */ = {isa = PBXBuildFile; fileRef = 413F4D6F22B0BAEE006A7A6B /* RTCVideoDecoderVP8.h */; };
+		414035EC24AA0EBC00BCE9B2 /* RTCVideoDecoderVP9.h in Headers */ = {isa = PBXBuildFile; fileRef = 414035E824AA0EBB00BCE9B2 /* RTCVideoDecoderVP9.h */; };
+		414035ED24AA0EBC00BCE9B2 /* RTCVideoEncoderVP9.mm in Sources */ = {isa = PBXBuildFile; fileRef = 414035E924AA0EBB00BCE9B2 /* RTCVideoEncoderVP9.mm */; };
+		414035EE24AA0EBC00BCE9B2 /* RTCVideoEncoderVP9.h in Headers */ = {isa = PBXBuildFile; fileRef = 414035EA24AA0EBB00BCE9B2 /* RTCVideoEncoderVP9.h */; };
+		414035EF24AA0EBC00BCE9B2 /* RTCVideoDecoderVP9.mm in Sources */ = {isa = PBXBuildFile; fileRef = 414035EB24AA0EBB00BCE9B2 /* RTCVideoDecoderVP9.mm */; };
+		414035F224AA0F5400BCE9B2 /* video_rtp_depacketizer_vp9.cc in Sources */ = {isa = PBXBuildFile; fileRef = 414035F024AA0F5300BCE9B2 /* video_rtp_depacketizer_vp9.cc */; };
+		414035F324AA0F5400BCE9B2 /* video_rtp_depacketizer_vp9.h in Headers */ = {isa = PBXBuildFile; fileRef = 414035F124AA0F5300BCE9B2 /* video_rtp_depacketizer_vp9.h */; };
 		4140B8201E4E3383007409E6 /* audio_encoder_pcm.cc in Sources */ = {isa = PBXBuildFile; fileRef = 4140B8181E4E3383007409E6 /* audio_encoder_pcm.cc */; };
 		4140B8211E4E3383007409E6 /* audio_encoder_pcm.h in Headers */ = {isa = PBXBuildFile; fileRef = 4140B8191E4E3383007409E6 /* audio_encoder_pcm.h */; };
 		4140B8221E4E3383007409E6 /* audio_decoder_pcm.cc in Sources */ = {isa = PBXBuildFile; fileRef = 4140B81A1E4E3383007409E6 /* audio_decoder_pcm.cc */; };
@@ -4991,6 +4997,12 @@
 		413E67A92169894C00EF37ED /* RTCNativeI420Buffer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RTCNativeI420Buffer.h; sourceTree = "<group>"; };
 		413E67AA2169894C00EF37ED /* RTCNativeMutableI420Buffer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RTCNativeMutableI420Buffer.h; sourceTree = "<group>"; };
 		413F4D6F22B0BAEE006A7A6B /* RTCVideoDecoderVP8.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RTCVideoDecoderVP8.h; sourceTree = "<group>"; };
+		414035E824AA0EBB00BCE9B2 /* RTCVideoDecoderVP9.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RTCVideoDecoderVP9.h; sourceTree = "<group>"; };
+		414035E924AA0EBB00BCE9B2 /* RTCVideoEncoderVP9.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RTCVideoEncoderVP9.mm; sourceTree = "<group>"; };
+		414035EA24AA0EBB00BCE9B2 /* RTCVideoEncoderVP9.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RTCVideoEncoderVP9.h; sourceTree = "<group>"; };
+		414035EB24AA0EBB00BCE9B2 /* RTCVideoDecoderVP9.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RTCVideoDecoderVP9.mm; sourceTree = "<group>"; };
+		414035F024AA0F5300BCE9B2 /* video_rtp_depacketizer_vp9.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = video_rtp_depacketizer_vp9.cc; sourceTree = "<group>"; };
+		414035F124AA0F5300BCE9B2 /* video_rtp_depacketizer_vp9.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = video_rtp_depacketizer_vp9.h; sourceTree = "<group>"; };
 		4140B8181E4E3383007409E6 /* audio_encoder_pcm.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = audio_encoder_pcm.cc; path = g711/audio_encoder_pcm.cc; sourceTree = "<group>"; };
 		4140B8191E4E3383007409E6 /* audio_encoder_pcm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = audio_encoder_pcm.h; path = g711/audio_encoder_pcm.h; sourceTree = "<group>"; };
 		4140B81A1E4E3383007409E6 /* audio_decoder_pcm.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = audio_decoder_pcm.cc; path = g711/audio_decoder_pcm.cc; sourceTree = "<group>"; };
@@ -9282,6 +9294,10 @@
 				41795402216985200028266B /* RTCVideoDecoderVP8.mm */,
 				417954012169851F0028266B /* RTCVideoEncoderVP8.h */,
 				413E67642169854500EF37ED /* RTCVideoEncoderVP8.mm */,
+				414035E824AA0EBB00BCE9B2 /* RTCVideoDecoderVP9.h */,
+				414035EB24AA0EBB00BCE9B2 /* RTCVideoDecoderVP9.mm */,
+				414035EA24AA0EBB00BCE9B2 /* RTCVideoEncoderVP9.h */,
+				414035E924AA0EBB00BCE9B2 /* RTCVideoEncoderVP9.mm */,
 				417953FE2169851F0028266B /* RTCWrappedNativeVideoDecoder.h */,
 				41795403216985200028266B /* RTCWrappedNativeVideoDecoder.mm */,
 				41795404216985200028266B /* RTCWrappedNativeVideoEncoder.h */,
@@ -13460,6 +13476,8 @@
 				41893907242A704B007FDC41 /* video_rtp_depacketizer_raw.h */,
 				4189390A242A704C007FDC41 /* video_rtp_depacketizer_vp8.cc */,
 				4189390B242A704C007FDC41 /* video_rtp_depacketizer_vp8.h */,
+				414035F024AA0F5300BCE9B2 /* video_rtp_depacketizer_vp9.cc */,
+				414035F124AA0F5300BCE9B2 /* video_rtp_depacketizer_vp9.h */,
 			);
 			name = source;
 			path = rtp_rtcp/source;
@@ -15061,6 +15079,7 @@
 				4131C02F234B898D0028A615 /* event.h in Headers */,
 				41893A5C242A77B8007FDC41 /* event_based_exponential_moving_average.h in Headers */,
 				5CD286151E6A66130094FDC8 /* event_log_writer.h in Headers */,
+				414035EC24AA0EBC00BCE9B2 /* RTCVideoDecoderVP9.h in Headers */,
 				41893A5B242A77B8007FDC41 /* event_rate_counter.h in Headers */,
 				4131C051234B898D0028A615 /* event_tracer.h in Headers */,
 				419C83501FE246650040C30F /* exp_filter.h in Headers */,
@@ -15703,6 +15722,7 @@
 				4131C4D6234C84A30028A615 /* rtp_dependency_descriptor_extension.h in Headers */,
 				4131C4DB234C84A30028A615 /* rtp_dependency_descriptor_reader.h in Headers */,
 				4131C4DC234C84A30028A615 /* rtp_dependency_descriptor_writer.h in Headers */,
+				414035EE24AA0EBC00BCE9B2 /* RTCVideoEncoderVP9.h in Headers */,
 				4189391B242A704E007FDC41 /* rtp_descriptor_authentication.h in Headers */,
 				5CDD8AB71E43C00F00621E92 /* rtp_file_source.h in Headers */,
 				5CDD88B11E43BE3C00621E92 /* rtp_format.h in Headers */,
@@ -15987,6 +16007,7 @@
 				5CDD873E1E43BABE00621E92 /* vad_circular_buffer.h in Headers */,
 				5CDD86D71E43BA2800621E92 /* vad_core.h in Headers */,
 				5CDD86DA1E43BA2800621E92 /* vad_filterbank.h in Headers */,
+				414035F324AA0F5400BCE9B2 /* video_rtp_depacketizer_vp9.h in Headers */,
 				5CDD86DD1E43BA2800621E92 /* vad_gmm.h in Headers */,
 				5CDD86E01E43BA2800621E92 /* vad_sp.h in Headers */,
 				415F1FB621272FBA00064CBF /* vad_with_level.h in Headers */,
@@ -17396,6 +17417,7 @@
 				5CDD8FFE1E43CE3A00621E92 /* audio_encoder_pcm16b.cc in Sources */,
 				5CD285461E6A61D20094FDC8 /* audio_format.cc in Sources */,
 				41DDB26F212679D200296D47 /* audio_format_to_string.cc in Sources */,
+				414035EF24AA0EBC00BCE9B2 /* RTCVideoDecoderVP9.mm in Sources */,
 				4131C3A7234B96C30028A615 /* audio_frame.cc in Sources */,
 				5CD284921E6A5F410094FDC8 /* audio_frame_manipulator.cc in Sources */,
 				5CD2854D1E6A62130094FDC8 /* audio_frame_operations.cc in Sources */,
@@ -17789,6 +17811,7 @@
 				4131BEFC234B88200028A615 /* jsep_transport_controller.cc in Sources */,
 				4131C227234B8BB20028A615 /* keyframe_interval_settings.cc in Sources */,
 				5CDD87C41E43BC0500621E92 /* lattice.c in Sources */,
+				414035ED24AA0EBC00BCE9B2 /* RTCVideoEncoderVP9.mm in Sources */,
 				41433CF21F79B33400387B4D /* lattice.c in Sources */,
 				41433D141F79B33400387B4D /* lattice_c.c in Sources */,
 				5CDD841F1E439B2900621E92 /* legacy_encoded_audio_frame.cc in Sources */,
@@ -17866,6 +17889,7 @@
 				5CDD8A321E43BFB300621E92 /* nack_tracker.cc in Sources */,
 				417953B4216982420028266B /* nalu_rewriter.cc in Sources */,
 				4131C03C234B898D0028A615 /* nat_server.cc in Sources */,
+				414035F224AA0F5400BCE9B2 /* video_rtp_depacketizer_vp9.cc in Sources */,
 				4131C054234B898D0028A615 /* nat_socket_factory.cc in Sources */,
 				4131C089234B898D0028A615 /* nat_types.cc in Sources */,
 				5CDD8BD11E43C2B500621E92 /* nearest_neighbor.c in Sources */,
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index 66ad559..3ae4912 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,29 @@
+2020-06-30  Youenn Fablet  <youenn@apple.com>
+
+        Add VP9 WebRTC codec runtime flag
+        https://bugs.webkit.org/show_bug.cgi?id=213724
+
+        Reviewed by Eric Carlson.
+
+        Add binding code to switch on/off VP9 in WebRTC factories based on runtime flag.
+
+        Test: webrtc/vp9.html
+
+        * page/Page.cpp:
+        (WebCore::m_shouldRelaxThirdPartyCookieBlocking):
+        * page/RuntimeEnabledFeatures.h:
+        (WebCore::RuntimeEnabledFeatures::webRTCVP9CodecEnabled const):
+        (WebCore::RuntimeEnabledFeatures::setWebRTCVP9CodecEnabled):
+        * platform/mediastream/libwebrtc/LibWebRTCProvider.h:
+        * platform/mediastream/libwebrtc/LibWebRTCProviderCocoa.cpp:
+        (WebCore::LibWebRTCProviderCocoa::createDecoderFactory):
+        (WebCore::LibWebRTCProviderCocoa::createEncoderFactory):
+        * testing/Internals.cpp:
+        (WebCore::Internals::setWebRTCH265Support):
+        (WebCore::Internals::setWebRTCVP9Support):
+        * testing/Internals.h:
+        * testing/Internals.idl:
+
 2020-06-29  Antoine Quint  <graouts@webkit.org>
 
         [Web Animations] REGRESSION: Bootstrap Carousel component v4.1 regressed with Web Animations
diff --git a/Source/WebCore/page/Page.cpp b/Source/WebCore/page/Page.cpp
index 1467916b..e4fecd6 100644
--- a/Source/WebCore/page/Page.cpp
+++ b/Source/WebCore/page/Page.cpp
@@ -334,7 +334,8 @@
 #endif
 
 #if USE(LIBWEBRTC)
-    m_libWebRTCProvider->supportsH265(RuntimeEnabledFeatures::sharedFeatures().webRTCH265CodecEnabled());
+    m_libWebRTCProvider->setH265Support(RuntimeEnabledFeatures::sharedFeatures().webRTCH265CodecEnabled());
+    m_libWebRTCProvider->setVP9Support(RuntimeEnabledFeatures::sharedFeatures().webRTCVP9CodecEnabled());
 #endif
 
     if (!pageConfiguration.userScriptsShouldWaitUntilNotification)
diff --git a/Source/WebCore/page/RuntimeEnabledFeatures.h b/Source/WebCore/page/RuntimeEnabledFeatures.h
index 117f1dd..2c8d523 100644
--- a/Source/WebCore/page/RuntimeEnabledFeatures.h
+++ b/Source/WebCore/page/RuntimeEnabledFeatures.h
@@ -241,6 +241,8 @@
     void setWebRTCDTMFEnabled(bool isEnabled) { m_isWebRTCDTMFEnabled = isEnabled; }
     bool webRTCH265CodecEnabled() const { return m_isWebRTCH265CodecEnabled; }
     void setWebRTCH265CodecEnabled(bool isEnabled) { m_isWebRTCH265CodecEnabled = isEnabled; }
+    bool webRTCVP9CodecEnabled() const { return m_isWebRTCVP9CodecEnabled; }
+    void setWebRTCVP9CodecEnabled(bool isEnabled) { m_isWebRTCVP9CodecEnabled = isEnabled; }
     bool peerConnectionEnabled() const { return m_isPeerConnectionEnabled; }
     void setPeerConnectionEnabled(bool isEnabled) { m_isPeerConnectionEnabled = isEnabled; }
     bool webRTCMDNSICECandidatesEnabled() const { return m_isWebRTCMDNSICECandidatesEnabled; }
@@ -510,7 +512,8 @@
 
 #if ENABLE(WEB_RTC)
     bool m_isWebRTCDTMFEnabled { true };
-    bool m_isWebRTCH265CodecEnabled { true };
+    bool m_isWebRTCH265CodecEnabled { false };
+    bool m_isWebRTCVP9CodecEnabled { false };
     bool m_isPeerConnectionEnabled { true };
     bool m_isWebRTCMDNSICECandidatesEnabled { false };
     bool m_isWebRTCH264SimulcastEnabled { true };
diff --git a/Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCProvider.h b/Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCProvider.h
index 2e96e66..0e8fd8b 100644
--- a/Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCProvider.h
+++ b/Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCProvider.h
@@ -104,7 +104,10 @@
     void disableEnumeratingAllNetworkInterfaces();
     void enableEnumeratingAllNetworkInterfaces();
 
-    void supportsH265(bool value) { m_supportsH265 = value; }
+    void setH265Support(bool value) { m_supportsH265 = value; }
+    void setVP9Support(bool value) { m_supportsVP9 = value; }
+    bool isSupportingH265() const { return m_supportsH265; }
+    bool isSupportingVP9() const { return m_supportsVP9; }
     virtual void disableNonLocalhostConnections() { m_disableNonLocalhostConnections = true; }
 
     rtc::RTCCertificateGenerator& certificateGenerator();
@@ -146,6 +149,7 @@
     rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> m_factory;
     bool m_disableNonLocalhostConnections { false };
     bool m_supportsH265 { false };
+    bool m_supportsVP9 { false };
     bool m_enableLogging { true };
     bool m_useDTLS10 { false };
 #endif
diff --git a/Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCProviderCocoa.cpp b/Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCProviderCocoa.cpp
index dff19a5..08d2a5a 100644
--- a/Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCProviderCocoa.cpp
+++ b/Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCProviderCocoa.cpp
@@ -56,16 +56,14 @@
 {
     ASSERT(isMainThread());
 
-    auto codecSupport = m_supportsH265 ? webrtc::WebKitCodecSupport::H264VP8AndH265 : webrtc::WebKitCodecSupport::H264AndVP8;
-    return webrtc::createWebKitDecoderFactory(codecSupport);
+    return webrtc::createWebKitDecoderFactory(isSupportingH265() ? webrtc::WebKitH265::On : webrtc::WebKitH265::Off, isSupportingVP9() ? webrtc::WebKitVP9::On : webrtc::WebKitVP9::Off);
 }
 
 std::unique_ptr<webrtc::VideoEncoderFactory> LibWebRTCProviderCocoa::createEncoderFactory()
 {
     ASSERT(isMainThread());
 
-    auto codecSupport = m_supportsH265 ? webrtc::WebKitCodecSupport::H264VP8AndH265 : webrtc::WebKitCodecSupport::H264AndVP8;
-    return webrtc::createWebKitEncoderFactory(codecSupport);
+    return webrtc::createWebKitEncoderFactory(isSupportingH265() ? webrtc::WebKitH265::On : webrtc::WebKitH265::Off, isSupportingVP9() ? webrtc::WebKitVP9::On : webrtc::WebKitVP9::Off);
 }
 
 void LibWebRTCProviderCocoa::setActive(bool value)
diff --git a/Source/WebCore/testing/Internals.cpp b/Source/WebCore/testing/Internals.cpp
index 452502d..6bbd6cc 100644
--- a/Source/WebCore/testing/Internals.cpp
+++ b/Source/WebCore/testing/Internals.cpp
@@ -1613,6 +1613,25 @@
 {
     connection.applyRotationForOutgoingVideoSources();
 }
+void Internals::setWebRTCH265Support(bool value)
+{
+#if USE(LIBWEBRTC)
+    if (auto* page = contextDocument()->page()) {
+        page->libWebRTCProvider().setH265Support(value);
+        page->libWebRTCProvider().clearFactory();
+    }
+#endif
+}
+
+void Internals::setWebRTCVP9Support(bool value)
+{
+#if USE(LIBWEBRTC)
+    if (auto* page = contextDocument()->page()) {
+        page->libWebRTCProvider().setVP9Support(value);
+        page->libWebRTCProvider().clearFactory();
+    }
+#endif
+}
 
 void Internals::setEnableWebRTCEncryption(bool value)
 {
diff --git a/Source/WebCore/testing/Internals.h b/Source/WebCore/testing/Internals.h
index 127c9f4..18a9e64 100644
--- a/Source/WebCore/testing/Internals.h
+++ b/Source/WebCore/testing/Internals.h
@@ -597,6 +597,8 @@
     void stopPeerConnection(RTCPeerConnection&);
     void clearPeerConnectionFactory();
     void applyRotationForOutgoingVideoSources(RTCPeerConnection&);
+    void setWebRTCH265Support(bool);
+    void setWebRTCVP9Support(bool);
     void setEnableWebRTCEncryption(bool);
     void setUseDTLS10(bool);
     void setUseGPUProcessForWebRTC(bool);
diff --git a/Source/WebCore/testing/Internals.idl b/Source/WebCore/testing/Internals.idl
index ba0e1a6..822ed5f 100644
--- a/Source/WebCore/testing/Internals.idl
+++ b/Source/WebCore/testing/Internals.idl
@@ -776,6 +776,8 @@
 
     [Conditional=WEB_RTC] void setH264HardwareEncoderAllowed(boolean allowed);
     [Conditional=WEB_RTC] void applyRotationForOutgoingVideoSources(RTCPeerConnection connection);
+    [Conditional=WEB_RTC] void setWebRTCH265Support(boolean allowed);
+    [Conditional=WEB_RTC] void setWebRTCVP9Support(boolean allowed);
 
     [Conditional=MEDIA_STREAM] void setMockAudioTrackChannelNumber(MediaStreamTrack track, unsigned short count);
     [Conditional=MEDIA_STREAM] void setShouldInterruptAudioOnPageVisibilityChange(boolean shouldInterrupt);
diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog
index bc89f07..b950599 100644
--- a/Source/WebKit/ChangeLog
+++ b/Source/WebKit/ChangeLog
@@ -1,3 +1,14 @@
+2020-06-30  Youenn Fablet  <youenn@apple.com>
+
+        Add VP9 WebRTC codec runtime flag
+        https://bugs.webkit.org/show_bug.cgi?id=213724
+
+        Reviewed by Eric Carlson.
+
+        * Shared/WebPreferences.yaml:
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::updatePreferences):
+
 2020-06-29  Brady Eidson  <beidson@apple.com>
 
         JavaScript cannot be injected into iframes
diff --git a/Source/WebKit/Shared/WebPreferences.yaml b/Source/WebKit/Shared/WebPreferences.yaml
index 95058b2..e560962 100644
--- a/Source/WebKit/Shared/WebPreferences.yaml
+++ b/Source/WebKit/Shared/WebPreferences.yaml
@@ -606,6 +606,15 @@
   humanReadableDescription: "Enable WebRTC H265 codec"
   category: experimental
 
+WebRTCVP9CodecEnabled:
+  type: bool
+  defaultValue: false
+  webcoreBinding: RuntimeEnabledFeatures
+  condition: ENABLE(WEB_RTC)
+  humanReadableName: "WebRTC VP9 codec"
+  humanReadableDescription: "Enable WebRTC VP9 codec"
+  category: experimental
+
 WebRTCPlatformCodecsInGPUProcessEnabled:
   type: bool
   defaultValue: defaultWebRTCCodecsInGPUProcess()
diff --git a/Source/WebKit/WebProcess/WebPage/WebPage.cpp b/Source/WebKit/WebProcess/WebPage/WebPage.cpp
index 593e722..1bfe3bf 100644
--- a/Source/WebKit/WebProcess/WebPage/WebPage.cpp
+++ b/Source/WebKit/WebProcess/WebPage/WebPage.cpp
@@ -3728,7 +3728,8 @@
         m_drawingArea->updatePreferences(store);
 
 #if USE(LIBWEBRTC)
-    m_page->libWebRTCProvider().supportsH265(RuntimeEnabledFeatures::sharedFeatures().webRTCH265CodecEnabled());
+    m_page->libWebRTCProvider().setH265Support(RuntimeEnabledFeatures::sharedFeatures().webRTCH265CodecEnabled());
+    m_page->libWebRTCProvider().setVP9Support(RuntimeEnabledFeatures::sharedFeatures().webRTCVP9CodecEnabled());
 #endif
 
 #if ENABLE(GPU_PROCESS)