Add support for RTCMuxPolicy
authoryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 4 Nov 2018 07:55:02 +0000 (07:55 +0000)
committeryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 4 Nov 2018 07:55:02 +0000 (07:55 +0000)
https://bugs.webkit.org/show_bug.cgi?id=191188

Reviewed by Eric Carlson.

LayoutTests/imported/w3c:

* web-platform-tests/webrtc/RTCConfiguration-rtcpMuxPolicy-expected.txt:
* web-platform-tests/webrtc/rtcpeerconnection/rtcpeerconnection-constructor-expected.txt:

Source/WebCore:

Add support for RTCMuxPolicy dictionary option for both constructor and setConfiguration.
Make sure setConfiguration throws if trying to change this policy.
Pipe this parameter up to libwebrtc.
Covered by rebased test.

* Modules/mediastream/RTCConfiguration.h:
* Modules/mediastream/RTCConfiguration.idl:
* Modules/mediastream/RTCPeerConnection.cpp:
(WebCore::iceServersFromConfiguration):
(WebCore::RTCPeerConnection::initializeConfiguration):
(WebCore::RTCPeerConnection::setConfiguration):
* Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp:
(WebCore::rtcpMuxPolicyfromConfiguration):
(WebCore::configurationFromMediaEndpointConfiguration):
* WebCore.xcodeproj/project.pbxproj:
* platform/mediastream/MediaEndpointConfiguration.cpp:
(WebCore::MediaEndpointConfiguration::MediaEndpointConfiguration):
* platform/mediastream/MediaEndpointConfiguration.h:
* platform/mediastream/RTCPMuxPolicy.h: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@237778 268f45cc-cd09-0410-ab3c-d52691b4dbfc

12 files changed:
LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/webrtc/RTCConfiguration-rtcpMuxPolicy-expected.txt
LayoutTests/imported/w3c/web-platform-tests/webrtc/rtcpeerconnection/rtcpeerconnection-constructor-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/Modules/mediastream/RTCConfiguration.h
Source/WebCore/Modules/mediastream/RTCConfiguration.idl
Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp
Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/platform/mediastream/MediaEndpointConfiguration.cpp
Source/WebCore/platform/mediastream/MediaEndpointConfiguration.h
Source/WebCore/platform/mediastream/RTCPMuxPolicy.h [new file with mode: 0644]

index a33666e..7f98d23 100644 (file)
@@ -1,3 +1,13 @@
+2018-11-04  Youenn Fablet  <youenn@apple.com>
+
+        Add support for RTCMuxPolicy
+        https://bugs.webkit.org/show_bug.cgi?id=191188
+
+        Reviewed by Eric Carlson.
+
+        * web-platform-tests/webrtc/RTCConfiguration-rtcpMuxPolicy-expected.txt:
+        * web-platform-tests/webrtc/rtcpeerconnection/rtcpeerconnection-constructor-expected.txt:
+
 2018-11-03  Youenn Fablet  <youenn@apple.com>
 
         Refresh WPT webrtc tests
index 8621d0d..6dd6362 100644 (file)
@@ -1,22 +1,15 @@
 
-FAIL new RTCPeerConnection() should have default rtcpMuxPolicy require assert_equals: expected (string) "require" but got (undefined) undefined
-FAIL new RTCPeerConnection({ rtcpMuxPolicy: undefined }) should have default rtcpMuxPolicy require assert_equals: expected (string) "require" but got (undefined) undefined
-FAIL new RTCPeerConnection({ rtcpMuxPolicy: 'require' }) should succeed assert_equals: expected (string) "require" but got (undefined) undefined
-FAIL new RTCPeerConnection({ rtcpMuxPolicy: 'negotiate' }) may succeed or throw NotSupportedError assert_equals: expected (string) "negotiate" but got (undefined) undefined
-FAIL new RTCPeerConnection(config) - with { rtcpMuxPolicy: null } should throw TypeError assert_throws: function "() =>
-      makePc({ rtcpMuxPolicy: null })" did not throw
-FAIL setConfiguration(config) - with { rtcpMuxPolicy: null } should throw TypeError assert_throws: function "() =>
-      makePc({ rtcpMuxPolicy: null })" did not throw
-FAIL new RTCPeerConnection(config) - with { rtcpMuxPolicy: 'invalid' } should throw TypeError assert_throws: function "() =>
-      makePc({ rtcpMuxPolicy: 'invalid' })" did not throw
-FAIL setConfiguration(config) - with { rtcpMuxPolicy: 'invalid' } should throw TypeError assert_throws: function "() =>
-      makePc({ rtcpMuxPolicy: 'invalid' })" did not throw
-FAIL setConfiguration({ rtcpMuxPolicy: 'negotiate' }) with initial rtcpMuxPolicy require should throw InvalidModificationError assert_throws: function "() =>
-      pc.setConfiguration({ rtcpMuxPolicy: 'negotiate' })" did not throw
-FAIL setConfiguration({ rtcpMuxPolicy: 'require' }) with initial rtcpMuxPolicy negotiate should throw InvalidModificationError assert_throws: function "() =>
-      pc.setConfiguration({ rtcpMuxPolicy: 'require' })" did not throw
-FAIL setConfiguration({}) with initial rtcpMuxPolicy negotiate should throw InvalidModificationError assert_throws: function "() =>
-      pc.setConfiguration({})" did not throw
+PASS new RTCPeerConnection() should have default rtcpMuxPolicy require 
+PASS new RTCPeerConnection({ rtcpMuxPolicy: undefined }) should have default rtcpMuxPolicy require 
+PASS new RTCPeerConnection({ rtcpMuxPolicy: 'require' }) should succeed 
+PASS new RTCPeerConnection({ rtcpMuxPolicy: 'negotiate' }) may succeed or throw NotSupportedError 
+PASS new RTCPeerConnection(config) - with { rtcpMuxPolicy: null } should throw TypeError 
+PASS setConfiguration(config) - with { rtcpMuxPolicy: null } should throw TypeError 
+PASS new RTCPeerConnection(config) - with { rtcpMuxPolicy: 'invalid' } should throw TypeError 
+PASS setConfiguration(config) - with { rtcpMuxPolicy: 'invalid' } should throw TypeError 
+PASS setConfiguration({ rtcpMuxPolicy: 'negotiate' }) with initial rtcpMuxPolicy require should throw InvalidModificationError 
+PASS setConfiguration({ rtcpMuxPolicy: 'require' }) with initial rtcpMuxPolicy negotiate should throw InvalidModificationError 
+PASS setConfiguration({}) with initial rtcpMuxPolicy negotiate should throw InvalidModificationError 
 FAIL setRemoteDescription throws InvalidAccessError when called with an offer without rtcp-mux and rtcpMuxPolicy is set to require assert_throws: function "function () { throw e }" threw object "OperationError: Failed to set remote offer sdp: The m= section:audio1 is invalid. RTCP-MUX is not enabled when it is required." that is not a DOMException InvalidAccessError: property "code" is equal to 0, expected 15
 FAIL setRemoteDescription throws InvalidAccessError when called with an answer without rtcp-mux and rtcpMuxPolicy is set to require assert_throws: function "function () { throw e }" threw object "OperationError: Failed to set remote answer sdp: The order of m-lines in answer doesn't match order in offer. Rejecting answer." that is not a DOMException InvalidAccessError: property "code" is equal to 0, expected 15
 
index ffac831..e4e15cf 100644 (file)
@@ -53,15 +53,11 @@ PASS new RTCPeerConnection({ bundlePolicy: "balanced" })
 PASS new RTCPeerConnection({ bundlePolicy: "max-compat" }) 
 PASS new RTCPeerConnection({ bundlePolicy: "max-bundle" }) 
 PASS new RTCPeerConnection({ bundlePolicy: "invalid" }) 
-FAIL new RTCPeerConnection({ rtcpMuxPolicy: null }) assert_throws: function "function () {
-        eval(expr);
-      }" did not throw
+PASS new RTCPeerConnection({ rtcpMuxPolicy: null }) 
 PASS new RTCPeerConnection({ rtcpMuxPolicy: undefined }) 
 PASS new RTCPeerConnection({ rtcpMuxPolicy: "negotiate" }) 
 PASS new RTCPeerConnection({ rtcpMuxPolicy: "require" }) 
-FAIL new RTCPeerConnection({ rtcpMuxPolicy: "invalid" }) assert_throws: function "function () {
-        eval(expr);
-      }" did not throw
+PASS new RTCPeerConnection({ rtcpMuxPolicy: "invalid" }) 
 FAIL new RTCPeerConnection({ peerIdentity: toStringThrows }) assert_throws: function "function () {
         eval(expr);
       }" did not throw
index 9a5c19c..36d59d8 100644 (file)
@@ -1,3 +1,30 @@
+2018-11-04  Youenn Fablet  <youenn@apple.com>
+
+        Add support for RTCMuxPolicy
+        https://bugs.webkit.org/show_bug.cgi?id=191188
+
+        Reviewed by Eric Carlson.
+
+        Add support for RTCMuxPolicy dictionary option for both constructor and setConfiguration.
+        Make sure setConfiguration throws if trying to change this policy.
+        Pipe this parameter up to libwebrtc.
+        Covered by rebased test.
+
+        * Modules/mediastream/RTCConfiguration.h:
+        * Modules/mediastream/RTCConfiguration.idl:
+        * Modules/mediastream/RTCPeerConnection.cpp:
+        (WebCore::iceServersFromConfiguration):
+        (WebCore::RTCPeerConnection::initializeConfiguration):
+        (WebCore::RTCPeerConnection::setConfiguration):
+        * Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp:
+        (WebCore::rtcpMuxPolicyfromConfiguration):
+        (WebCore::configurationFromMediaEndpointConfiguration):
+        * WebCore.xcodeproj/project.pbxproj:
+        * platform/mediastream/MediaEndpointConfiguration.cpp:
+        (WebCore::MediaEndpointConfiguration::MediaEndpointConfiguration):
+        * platform/mediastream/MediaEndpointConfiguration.h:
+        * platform/mediastream/RTCPMuxPolicy.h: Added.
+
 2018-11-03  Devin Rousso  <drousso@apple.com>
 
         Web Inspector: Canvas: capture changes to <canvas> that would affect the recorded context
index 6453928..dd1e17c 100644 (file)
@@ -37,6 +37,7 @@
 #include "RTCCertificate.h"
 #include "RTCIceServer.h"
 #include "RTCIceTransportPolicy.h"
+#include "RTCPMuxPolicy.h"
 
 namespace WebCore {
 
@@ -44,6 +45,7 @@ struct RTCConfiguration {
     std::optional<Vector<RTCIceServer>> iceServers;
     RTCIceTransportPolicy iceTransportPolicy;
     RTCBundlePolicy bundlePolicy;
+    RTCPMuxPolicy rtcpMuxPolicy;
     unsigned short iceCandidatePoolSize;
     Vector<RefPtr<RTCCertificate>> certificates;
 };
index ae0d46d..6b04bb9 100644 (file)
 [
     Conditional=WEB_RTC,
     EnabledAtRuntime=PeerConnection,
+    ImplementedAs=RTCPMuxPolicy
+] enum RTCPMuxPolicy {
+    "negotiate",
+    "require"
+};
+
+[
+    Conditional=WEB_RTC,
+    EnabledAtRuntime=PeerConnection,
     JSGenerateToJSObject,
 ] dictionary RTCConfiguration {
     sequence<RTCIceServer> iceServers;
     RTCIceTransportPolicy iceTransportPolicy = "all";
     RTCBundlePolicy bundlePolicy = "balanced";
-    // FIXME 169662: missing rtcpMuxPolicy
+    RTCPMuxPolicy rtcpMuxPolicy = "require";
     // FIXME 169662: missing peerIdentity
     sequence<RTCCertificate> certificates;
     [EnforceRange] octet iceCandidatePoolSize = 0;
index 1c74116..4a3fb57 100644 (file)
@@ -260,7 +260,10 @@ void RTCPeerConnection::queuedAddIceCandidate(RTCIceCandidate* rtcCandidate, DOM
 static inline ExceptionOr<Vector<MediaEndpointConfiguration::IceServerInfo>> iceServersFromConfiguration(RTCConfiguration& newConfiguration, const RTCConfiguration* existingConfiguration, bool isLocalDescriptionSet)
 {
     if (existingConfiguration && newConfiguration.bundlePolicy != existingConfiguration->bundlePolicy)
-        return Exception { InvalidModificationError, "IceTransportPolicy does not match existing policy" };
+        return Exception { InvalidModificationError, "BundlePolicy does not match existing policy" };
+
+    if (existingConfiguration && newConfiguration.rtcpMuxPolicy != existingConfiguration->rtcpMuxPolicy)
+        return Exception { InvalidModificationError, "RTCPMuxPolicy does not match existing policy" };
 
     if (existingConfiguration && newConfiguration.iceCandidatePoolSize != existingConfiguration->iceCandidatePoolSize && isLocalDescriptionSet)
         return Exception { InvalidModificationError, "IceTransportPolicy pool size does not match existing pool size" };
@@ -320,7 +323,7 @@ ExceptionOr<void> RTCPeerConnection::initializeConfiguration(RTCConfiguration&&
     if (certificates.hasException())
         return certificates.releaseException();
 
-    if (!m_backend->setConfiguration({ servers.releaseReturnValue(), configuration.iceTransportPolicy, configuration.bundlePolicy, configuration.iceCandidatePoolSize, certificates.releaseReturnValue() }))
+    if (!m_backend->setConfiguration({ servers.releaseReturnValue(), configuration.iceTransportPolicy, configuration.bundlePolicy, configuration.rtcpMuxPolicy, configuration.iceCandidatePoolSize, certificates.releaseReturnValue() }))
         return Exception { InvalidAccessError, "Bad Configuration Parameters" };
 
     m_configuration = WTFMove(configuration);
@@ -351,7 +354,7 @@ ExceptionOr<void> RTCPeerConnection::setConfiguration(RTCConfiguration&& configu
         }
     }
 
-    if (!m_backend->setConfiguration({ servers.releaseReturnValue(), configuration.iceTransportPolicy, configuration.bundlePolicy, configuration.iceCandidatePoolSize, { } }))
+    if (!m_backend->setConfiguration({ servers.releaseReturnValue(), configuration.iceTransportPolicy, configuration.bundlePolicy, configuration.rtcpMuxPolicy, configuration.iceCandidatePoolSize, { } }))
         return Exception { InvalidAccessError, "Bad Configuration Parameters" };
 
     m_configuration = WTFMove(configuration);
index c3eb706..2cd9d37 100644 (file)
@@ -88,6 +88,19 @@ static inline webrtc::PeerConnectionInterface::BundlePolicy bundlePolicyfromConf
     return webrtc::PeerConnectionInterface::kBundlePolicyMaxCompat;
 }
 
+static inline webrtc::PeerConnectionInterface::RtcpMuxPolicy rtcpMuxPolicyfromConfiguration(const MediaEndpointConfiguration& configuration)
+{
+    switch (configuration.rtcpMuxPolicy) {
+    case RTCPMuxPolicy::Negotiate:
+        return webrtc::PeerConnectionInterface::kRtcpMuxPolicyNegotiate;
+    case RTCPMuxPolicy::Require:
+        return webrtc::PeerConnectionInterface::kRtcpMuxPolicyRequire;
+    }
+
+    ASSERT_NOT_REACHED();
+    return webrtc::PeerConnectionInterface::kRtcpMuxPolicyRequire;
+}
+
 static inline webrtc::PeerConnectionInterface::IceTransportsType iceTransportPolicyfromConfiguration(const MediaEndpointConfiguration& configuration)
 {
     switch (configuration.iceTransportPolicy) {
@@ -107,6 +120,7 @@ static webrtc::PeerConnectionInterface::RTCConfiguration configurationFromMediaE
 
     rtcConfiguration.type = iceTransportPolicyfromConfiguration(configuration);
     rtcConfiguration.bundle_policy = bundlePolicyfromConfiguration(configuration);
+    rtcConfiguration.rtcp_mux_policy = rtcpMuxPolicyfromConfiguration(configuration);
 
     for (auto& server : configuration.iceServers) {
         webrtc::PeerConnectionInterface::IceServer iceServer;
index 161391a..ffe523b 100644 (file)
                4129C9871F58662D009D7403 /* ReadableStreamSink.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ReadableStreamSink.cpp; sourceTree = "<group>"; };
                4129DF831BB5B7F700322A16 /* JSReadableStreamPrivateConstructors.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSReadableStreamPrivateConstructors.cpp; sourceTree = "<group>"; };
                4129DF841BB5B7F700322A16 /* JSReadableStreamPrivateConstructors.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSReadableStreamPrivateConstructors.h; sourceTree = "<group>"; };
+               412BA5FE218C651800365474 /* RTCPMuxPolicy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RTCPMuxPolicy.h; sourceTree = "<group>"; };
                413015D51C7B570400091C6E /* FetchResponse.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FetchResponse.cpp; sourceTree = "<group>"; };
                413015D51C7B570400091C6F /* FetchBodySource.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FetchBodySource.cpp; sourceTree = "<group>"; };
                413015D61C7B570400091C6E /* FetchResponse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FetchResponse.h; sourceTree = "<group>"; };
                                313591011E7DDC6000F30630 /* RTCIceGatheringState.h */,
                                313591021E7DDC6000F30630 /* RTCIceTransportPolicy.h */,
                                313591031E7DDC6000F30630 /* RTCIceTransportState.h */,
+                               412BA5FE218C651800365474 /* RTCPMuxPolicy.h */,
                                07221BAA17CF0AD400848E51 /* RTCPeerConnectionHandlerClient.h */,
                                41A48A9D1E8312EB00D2AC2D /* RTCPeerConnectionState.h */,
                                31EB54DD1E7DC74400C1623B /* RTCRtpTransceiverDirection.h */,
index 7c2f1af..8d2593f 100644 (file)
 
 namespace WebCore {
 
-MediaEndpointConfiguration::MediaEndpointConfiguration(Vector<IceServerInfo>&& iceServers, RTCIceTransportPolicy iceTransportPolicy, RTCBundlePolicy bundlePolicy, unsigned short iceCandidatePoolSize, Vector<CertificatePEM>&& certificates)
+MediaEndpointConfiguration::MediaEndpointConfiguration(Vector<IceServerInfo>&& iceServers, RTCIceTransportPolicy iceTransportPolicy, RTCBundlePolicy bundlePolicy, RTCPMuxPolicy rtcpMuxPolicy, unsigned short iceCandidatePoolSize, Vector<CertificatePEM>&& certificates)
     : iceServers(WTFMove(iceServers))
     , iceTransportPolicy(iceTransportPolicy)
     , bundlePolicy(bundlePolicy)
+    , rtcpMuxPolicy(rtcpMuxPolicy)
     , iceCandidatePoolSize(iceCandidatePoolSize)
     , certificates(WTFMove(certificates))
 {
index 08748fc..b8617f3 100644 (file)
@@ -35,6 +35,7 @@
 
 #include "RTCBundlePolicy.h"
 #include "RTCIceTransportPolicy.h"
+#include "RTCPMuxPolicy.h"
 #include "URL.h"
 #include <wtf/Vector.h>
 #include <wtf/text/WTFString.h>
@@ -55,11 +56,12 @@ struct MediaEndpointConfiguration {
         String privateKey;
     };
 
-    MediaEndpointConfiguration(Vector<IceServerInfo>&&, RTCIceTransportPolicy, RTCBundlePolicy, unsigned short, Vector<CertificatePEM>&&);
+    MediaEndpointConfiguration(Vector<IceServerInfo>&&, RTCIceTransportPolicy, RTCBundlePolicy, RTCPMuxPolicy, unsigned short, Vector<CertificatePEM>&&);
 
     Vector<IceServerInfo> iceServers;
     RTCIceTransportPolicy iceTransportPolicy;
     RTCBundlePolicy bundlePolicy;
+    RTCPMuxPolicy rtcpMuxPolicy;
     unsigned short iceCandidatePoolSize;
     Vector<CertificatePEM> certificates;
 };
diff --git a/Source/WebCore/platform/mediastream/RTCPMuxPolicy.h b/Source/WebCore/platform/mediastream/RTCPMuxPolicy.h
new file mode 100644 (file)
index 0000000..2e2f82d
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2018 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_RTC)
+
+namespace WebCore {
+
+enum class RTCPMuxPolicy {
+    Negotiate,
+    Require
+};
+
+}; // namespace WebCore
+
+#endif