Commit 37927191 authored by foolip's avatar foolip Committed by Commit bot

Convert Dictionary handling to RTCConfiguration IDL dictionary

This preserves behavior as far as possible and adds use counters for
cases that aren't per spec. One intentional change is that the first
argument of the RTCPeerConnection constructor is made optional, as that
is a very low risk change, and requiring the dictionary makes no sense
when providing null, undefined and {iceServers:[]} already work.

Without custom bindings it is unfortunately not possible to distinguish
{certificates:null} from no certificates specified, so that is not
measured.

BUG=649343

Review-Url: https://codereview.chromium.org/2442763002
Cr-Commit-Position: refs/heads/master@{#427065}
parent eebbdeca
...@@ -8,31 +8,32 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE ...@@ -8,31 +8,32 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
PASS new webkitRTCPeerConnection(null); did not throw exception. PASS new webkitRTCPeerConnection(null); did not throw exception.
PASS new webkitRTCPeerConnection(undefined); did not throw exception. PASS new webkitRTCPeerConnection(undefined); did not throw exception.
PASS new webkitRTCPeerConnection(); threw exception TypeError: Failed to construct 'RTCPeerConnection': 1 argument required, but only 0 present.. PASS new webkitRTCPeerConnection({}); did not throw exception.
PASS new webkitRTCPeerConnection(''); threw exception TypeError: Failed to construct 'RTCPeerConnection': parameter 1 ('rtcConfiguration') is not an object.. PASS new webkitRTCPeerConnection(); did not throw exception.
PASS new webkitRTCPeerConnection(''); threw exception TypeError: Failed to construct 'RTCPeerConnection': parameter 1 ('configuration') is not an object..
PASS new webkitRTCPeerConnection({iceServers:[]}); did not throw exception. PASS new webkitRTCPeerConnection({iceServers:[]}); did not throw exception.
PASS new webkitRTCPeerConnection({iceServers:[{url:'stun:foo.com'}]}); did not throw exception. PASS new webkitRTCPeerConnection({iceServers:[{url:'stun:foo.com'}]}); did not throw exception.
PASS new webkitRTCPeerConnection({iceServers:[{url:'turn:foo.com', credential:'x'}]}); did not throw exception. PASS new webkitRTCPeerConnection({iceServers:[{url:'turn:foo.com', credential:'x'}]}); did not throw exception.
PASS new webkitRTCPeerConnection({iceServers:[{url:'turn:foo.com', credential:'x'},{url:'stun:bar.com'}]}); did not throw exception. PASS new webkitRTCPeerConnection({iceServers:[{url:'turn:foo.com', credential:'x'},{url:'stun:bar.com'}]}); did not throw exception.
PASS new webkitRTCPeerConnection({iceServers:[{urls:'stun:foo.com'}]}); did not throw exception. PASS new webkitRTCPeerConnection({iceServers:[{urls:'stun:foo.com'}]}); did not throw exception.
PASS new webkitRTCPeerConnection({iceServers:[{urls:['stun:foo.com', 'turn:foo.com']}]}); did not throw exception. PASS new webkitRTCPeerConnection({iceServers:[{urls:['stun:foo.com', 'turn:foo.com']}]}); did not throw exception.
PASS new webkitRTCPeerConnection({fooServers:[]}); threw exception TypeError: Failed to construct 'RTCPeerConnection': Malformed RTCConfiguration. PASS new webkitRTCPeerConnection({fooServers:[]}); did not throw exception.
PASS new webkitRTCPeerConnection({iceServers:true}); threw exception TypeError: Failed to construct 'RTCPeerConnection': Malformed RTCConfiguration. PASS new webkitRTCPeerConnection({iceServers:true}); threw exception TypeError: Failed to construct 'RTCPeerConnection': The value provided is neither an array, nor does it have indexed properties..
PASS new webkitRTCPeerConnection({iceServers:[1, 2, 3]}); threw exception TypeError: Failed to construct 'RTCPeerConnection': Malformed RTCIceServer. PASS new webkitRTCPeerConnection({iceServers:[1, 2, 3]}); threw exception TypeError: Failed to construct 'RTCPeerConnection': cannot convert to dictionary..
PASS new webkitRTCPeerConnection({iceServers:[{}]}); threw exception TypeError: Failed to construct 'RTCPeerConnection': Malformed RTCIceServer. PASS new webkitRTCPeerConnection({iceServers:[{}]}); threw exception TypeError: Failed to construct 'RTCPeerConnection': Malformed RTCIceServer.
PASS new webkitRTCPeerConnection({iceServers:[{url:'foo'}]}); threw exception TypeError: Failed to construct 'RTCPeerConnection': Malformed URL. PASS new webkitRTCPeerConnection({iceServers:[{url:'foo'}]}); threw exception TypeError: Failed to construct 'RTCPeerConnection': Malformed URL.
PASS new webkitRTCPeerConnection({iceServers:[{urls:[1, 'turn:foo.com']}]}); threw exception TypeError: Failed to construct 'RTCPeerConnection': Malformed URL. PASS new webkitRTCPeerConnection({iceServers:[{urls:[1, 'turn:foo.com']}]}); threw exception TypeError: Failed to construct 'RTCPeerConnection': Malformed URL.
PASS new webkitRTCPeerConnection({iceServers:[], iceTransports:'none'}); did not throw exception. PASS new webkitRTCPeerConnection({iceServers:[], iceTransports:'none'}); did not throw exception.
PASS new webkitRTCPeerConnection({iceServers:[], iceTransports:'relay'}); did not throw exception. PASS new webkitRTCPeerConnection({iceServers:[], iceTransports:'relay'}); did not throw exception.
PASS new webkitRTCPeerConnection({iceServers:[], iceTransports:'all'}); did not throw exception. PASS new webkitRTCPeerConnection({iceServers:[], iceTransports:'all'}); did not throw exception.
PASS new webkitRTCPeerConnection({iceServers:[], iceTransports:'foo'}); threw exception TypeError: Failed to construct 'RTCPeerConnection': Malformed RTCIceTransports. PASS new webkitRTCPeerConnection({iceServers:[], iceTransports:'foo'}); threw exception TypeError: Failed to construct 'RTCPeerConnection': The provided value 'foo' is not a valid enum value of type RTCIceTransports..
PASS new webkitRTCPeerConnection({iceServers:[], bundlePolicy:'balanced'}); did not throw exception. PASS new webkitRTCPeerConnection({iceServers:[], bundlePolicy:'balanced'}); did not throw exception.
PASS new webkitRTCPeerConnection({iceServers:[], bundlePolicy:'max-bundle'}); did not throw exception. PASS new webkitRTCPeerConnection({iceServers:[], bundlePolicy:'max-bundle'}); did not throw exception.
PASS new webkitRTCPeerConnection({iceServers:[], bundlePolicy:'max-compat'}); did not throw exception. PASS new webkitRTCPeerConnection({iceServers:[], bundlePolicy:'max-compat'}); did not throw exception.
PASS new webkitRTCPeerConnection({iceServers:[], bundlePolicy:'foo'}); threw exception TypeError: Failed to construct 'RTCPeerConnection': Malformed RTCBundlePolicy. PASS new webkitRTCPeerConnection({iceServers:[], bundlePolicy:'foo'}); threw exception TypeError: Failed to construct 'RTCPeerConnection': The provided value 'foo' is not a valid enum value of type RTCBundlePolicy..
PASS new webkitRTCPeerConnection({iceServers:[], rtcpMuxPolicy:'negotiate'}); did not throw exception. PASS new webkitRTCPeerConnection({iceServers:[], rtcpMuxPolicy:'negotiate'}); did not throw exception.
PASS new webkitRTCPeerConnection({iceServers:[], rtcpMuxPolicy:'require'}); did not throw exception. PASS new webkitRTCPeerConnection({iceServers:[], rtcpMuxPolicy:'require'}); did not throw exception.
PASS new webkitRTCPeerConnection({iceServers:[], rtcpMuxPolicy:'foo'}); threw exception TypeError: Failed to construct 'RTCPeerConnection': Malformed RTCRtcpMuxPolicy. PASS new webkitRTCPeerConnection({iceServers:[], rtcpMuxPolicy:'foo'}); threw exception TypeError: Failed to construct 'RTCPeerConnection': The provided value 'foo' is not a valid enum value of type RTCRtcpMuxPolicy..
PASS new webkitRTCPeerConnection(null, {mandatory:{valid_and_supported_1:1}}); did not throw exception. PASS new webkitRTCPeerConnection(null, {mandatory:{valid_and_supported_1:1}}); did not throw exception.
PASS new webkitRTCPeerConnection(null, {mandatory:{valid_and_supported_1:1, valid_and_supported_2:1}}); did not throw exception. PASS new webkitRTCPeerConnection(null, {mandatory:{valid_and_supported_1:1, valid_and_supported_2:1}}); did not throw exception.
PASS new webkitRTCPeerConnection(null, {optional:[{valid_and_supported_1:0}]}); did not throw exception. PASS new webkitRTCPeerConnection(null, {optional:[{valid_and_supported_1:0}]}); did not throw exception.
...@@ -49,9 +50,10 @@ PASS new webkitRTCPeerConnection(null, {valid_and_supported_1:1}); threw excepti ...@@ -49,9 +50,10 @@ PASS new webkitRTCPeerConnection(null, {valid_and_supported_1:1}); threw excepti
PASS new webkitRTCPeerConnection(null, {valid_but_unsupported_1:1}); threw exception TypeError: Failed to construct 'RTCPeerConnection': Malformed constraints object.. PASS new webkitRTCPeerConnection(null, {valid_but_unsupported_1:1}); threw exception TypeError: Failed to construct 'RTCPeerConnection': Malformed constraints object..
PASS new webkitRTCPeerConnection(null, {valid_and_supported_2:1, mandatory:{valid_and_supported_1:1}}); threw exception TypeError: Failed to construct 'RTCPeerConnection': Malformed constraints object.. PASS new webkitRTCPeerConnection(null, {valid_and_supported_2:1, mandatory:{valid_and_supported_1:1}}); threw exception TypeError: Failed to construct 'RTCPeerConnection': Malformed constraints object..
PASS new webkitRTCPeerConnection({iceServers:[], certificates:null}); did not throw exception. PASS new webkitRTCPeerConnection({iceServers:[], certificates:null}); did not throw exception.
PASS new webkitRTCPeerConnection({iceServers:[], certificates:undefined}); did not throw exception.
PASS new webkitRTCPeerConnection({iceServers:[], certificates:[]}); did not throw exception. PASS new webkitRTCPeerConnection({iceServers:[], certificates:[]}); did not throw exception.
PASS new webkitRTCPeerConnection({iceServers:[], certificates:[null]}); threw exception TypeError: Failed to construct 'RTCPeerConnection': Malformed sequence<RTCCertificate>. PASS new webkitRTCPeerConnection({iceServers:[], certificates:[null]}); threw exception TypeError: Failed to construct 'RTCPeerConnection': Invalid Array element type.
PASS new webkitRTCPeerConnection({iceServers:[], certificates:[1337]}); threw exception TypeError: Failed to construct 'RTCPeerConnection': Malformed sequence<RTCCertificate>. PASS new webkitRTCPeerConnection({iceServers:[], certificates:[1337]}); threw exception TypeError: Failed to construct 'RTCPeerConnection': Invalid Array element type.
PASS new webkitRTCPeerConnection({iceServers:[], certificates:[certRSA]}, null); did not throw exception. PASS new webkitRTCPeerConnection({iceServers:[], certificates:[certRSA]}, null); did not throw exception.
PASS new webkitRTCPeerConnection({iceServers:[], certificates:[certECDSA]}, null); did not throw exception. PASS new webkitRTCPeerConnection({iceServers:[], certificates:[certECDSA]}, null); did not throw exception.
PASS certExpired.expires <= new Date().getTime() is true PASS certExpired.expires <= new Date().getTime() is true
......
...@@ -9,7 +9,8 @@ description("Tests the RTCPeerConnection constructor."); ...@@ -9,7 +9,8 @@ description("Tests the RTCPeerConnection constructor.");
shouldNotThrow("new webkitRTCPeerConnection(null);"); shouldNotThrow("new webkitRTCPeerConnection(null);");
shouldNotThrow("new webkitRTCPeerConnection(undefined);"); shouldNotThrow("new webkitRTCPeerConnection(undefined);");
shouldThrow("new webkitRTCPeerConnection();"); shouldNotThrow("new webkitRTCPeerConnection({});");
shouldNotThrow("new webkitRTCPeerConnection();");
shouldThrow("new webkitRTCPeerConnection('');"); shouldThrow("new webkitRTCPeerConnection('');");
shouldNotThrow("new webkitRTCPeerConnection({iceServers:[]});"); shouldNotThrow("new webkitRTCPeerConnection({iceServers:[]});");
...@@ -19,7 +20,7 @@ shouldNotThrow("new webkitRTCPeerConnection({iceServers:[{url:'turn:foo.com', cr ...@@ -19,7 +20,7 @@ shouldNotThrow("new webkitRTCPeerConnection({iceServers:[{url:'turn:foo.com', cr
shouldNotThrow("new webkitRTCPeerConnection({iceServers:[{urls:'stun:foo.com'}]});"); shouldNotThrow("new webkitRTCPeerConnection({iceServers:[{urls:'stun:foo.com'}]});");
shouldNotThrow("new webkitRTCPeerConnection({iceServers:[{urls:['stun:foo.com', 'turn:foo.com']}]});"); shouldNotThrow("new webkitRTCPeerConnection({iceServers:[{urls:['stun:foo.com', 'turn:foo.com']}]});");
shouldThrow("new webkitRTCPeerConnection({fooServers:[]});"); shouldNotThrow("new webkitRTCPeerConnection({fooServers:[]});");
shouldThrow("new webkitRTCPeerConnection({iceServers:true});"); shouldThrow("new webkitRTCPeerConnection({iceServers:true});");
shouldThrow("new webkitRTCPeerConnection({iceServers:[1, 2, 3]});"); shouldThrow("new webkitRTCPeerConnection({iceServers:[1, 2, 3]});");
shouldThrow("new webkitRTCPeerConnection({iceServers:[{}]});"); shouldThrow("new webkitRTCPeerConnection({iceServers:[{}]});");
...@@ -60,6 +61,7 @@ shouldThrow("new webkitRTCPeerConnection(null, {valid_and_supported_2:1, mandato ...@@ -60,6 +61,7 @@ shouldThrow("new webkitRTCPeerConnection(null, {valid_and_supported_2:1, mandato
// Construct with certificates. // Construct with certificates.
shouldNotThrow("new webkitRTCPeerConnection({iceServers:[], certificates:null});"); shouldNotThrow("new webkitRTCPeerConnection({iceServers:[], certificates:null});");
shouldNotThrow("new webkitRTCPeerConnection({iceServers:[], certificates:undefined});");
shouldNotThrow("new webkitRTCPeerConnection({iceServers:[], certificates:[]});"); shouldNotThrow("new webkitRTCPeerConnection({iceServers:[], certificates:[]});");
shouldThrow("new webkitRTCPeerConnection({iceServers:[], certificates:[null]});"); shouldThrow("new webkitRTCPeerConnection({iceServers:[], certificates:[null]});");
shouldThrow("new webkitRTCPeerConnection({iceServers:[], certificates:[1337]});"); shouldThrow("new webkitRTCPeerConnection({iceServers:[], certificates:[1337]});");
......
...@@ -1376,6 +1376,9 @@ class CORE_EXPORT UseCounter { ...@@ -1376,6 +1376,9 @@ class CORE_EXPORT UseCounter {
LoopbackEmbeddedInSecureContext = 1652, LoopbackEmbeddedInSecureContext = 1652,
LoopbackEmbeddedInNonSecureContext = 1653, LoopbackEmbeddedInNonSecureContext = 1653,
BlinkMacSystemFont = 1654, BlinkMacSystemFont = 1654,
RTCConfigurationIceTransportsNone = 1655,
RTCIceServerURL = 1656,
RTCIceServerURLs = 1657,
// Add new features immediately above this line. Don't change assigned // Add new features immediately above this line. Don't change assigned
// numbers of any item, and don't reuse removed slots. // numbers of any item, and don't reuse removed slots.
......
...@@ -446,8 +446,10 @@ modules_dictionary_idl_files = ...@@ -446,8 +446,10 @@ modules_dictionary_idl_files =
"payments/PaymentRequestUpdateEventInit.idl", "payments/PaymentRequestUpdateEventInit.idl",
"payments/PaymentShippingOption.idl", "payments/PaymentShippingOption.idl",
"peerconnection/RTCAnswerOptions.idl", "peerconnection/RTCAnswerOptions.idl",
"peerconnection/RTCConfiguration.idl",
"peerconnection/RTCDTMFToneChangeEventInit.idl", "peerconnection/RTCDTMFToneChangeEventInit.idl",
"peerconnection/RTCIceCandidateInit.idl", "peerconnection/RTCIceCandidateInit.idl",
"peerconnection/RTCIceServer.idl",
"peerconnection/RTCOfferAnswerOptions.idl", "peerconnection/RTCOfferAnswerOptions.idl",
"peerconnection/RTCOfferOptions.idl", "peerconnection/RTCOfferOptions.idl",
"peerconnection/RTCSessionDescriptionInit.idl", "peerconnection/RTCSessionDescriptionInit.idl",
...@@ -766,10 +768,14 @@ generated_modules_dictionary_files = [ ...@@ -766,10 +768,14 @@ generated_modules_dictionary_files = [
"$blink_modules_output_dir/payments/PaymentShippingOption.h", "$blink_modules_output_dir/payments/PaymentShippingOption.h",
"$blink_modules_output_dir/peerconnection/RTCAnswerOptions.cpp", "$blink_modules_output_dir/peerconnection/RTCAnswerOptions.cpp",
"$blink_modules_output_dir/peerconnection/RTCAnswerOptions.h", "$blink_modules_output_dir/peerconnection/RTCAnswerOptions.h",
"$blink_modules_output_dir/peerconnection/RTCConfiguration.cpp",
"$blink_modules_output_dir/peerconnection/RTCConfiguration.h",
"$blink_modules_output_dir/peerconnection/RTCDTMFToneChangeEventInit.cpp", "$blink_modules_output_dir/peerconnection/RTCDTMFToneChangeEventInit.cpp",
"$blink_modules_output_dir/peerconnection/RTCDTMFToneChangeEventInit.h", "$blink_modules_output_dir/peerconnection/RTCDTMFToneChangeEventInit.h",
"$blink_modules_output_dir/peerconnection/RTCIceCandidateInit.cpp", "$blink_modules_output_dir/peerconnection/RTCIceCandidateInit.cpp",
"$blink_modules_output_dir/peerconnection/RTCIceCandidateInit.h", "$blink_modules_output_dir/peerconnection/RTCIceCandidateInit.h",
"$blink_modules_output_dir/peerconnection/RTCIceServer.cpp",
"$blink_modules_output_dir/peerconnection/RTCIceServer.h",
"$blink_modules_output_dir/peerconnection/RTCOfferAnswerOptions.cpp", "$blink_modules_output_dir/peerconnection/RTCOfferAnswerOptions.cpp",
"$blink_modules_output_dir/peerconnection/RTCOfferAnswerOptions.h", "$blink_modules_output_dir/peerconnection/RTCOfferAnswerOptions.h",
"$blink_modules_output_dir/peerconnection/RTCOfferOptions.cpp", "$blink_modules_output_dir/peerconnection/RTCOfferOptions.cpp",
......
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// https://w3c.github.io/webrtc-pc/#rtcicetransportpolicy-enum
// TODO(foolip): This is called RTCIceTransportPolicy in the spec, and that enum
// does not have "none" as one of its values.
enum RTCIceTransports {
"none",
"relay",
"all"
};
// https://w3c.github.io/webrtc-pc/#rtcbundlepolicy-enum
enum RTCBundlePolicy {
"balanced",
"max-compat",
"max-bundle"
};
// https://w3c.github.io/webrtc-pc/#rtcrtcpmuxpolicy-enum
enum RTCRtcpMuxPolicy {
"negotiate",
"require"
};
// https://w3c.github.io/webrtc-pc/#rtcconfiguration-dictionary
dictionary RTCConfiguration {
sequence<RTCIceServer> iceServers;
// TODO(foolip): |iceTransports| should be |iceTransportPolicy|.
RTCIceTransports iceTransports = "all";
RTCBundlePolicy bundlePolicy = "balanced";
// TODO(foolip): |rtcpMuxPolicy| default should be "require".
RTCRtcpMuxPolicy rtcpMuxPolicy;
// TODO(foolip): DOMString peerIdentity;
// TODO(foolip): |certificates| should not be nullable.
sequence<RTCCertificate>? certificates;
// TODO(foolip): unsigned short iceCandidatePoolSize = 0;
};
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// https://w3c.github.io/webrtc-pc/#rtciceserver-dictionary
dictionary RTCIceServer {
// TODO(foolip): |urls| should be required and |url| is not in the spec.
(DOMString or sequence<DOMString>) urls;
DOMString url;
DOMString username;
DOMString credential;
// TODO(foolip): RTCIceCredentialType credentialType = "password";
};
...@@ -30,7 +30,6 @@ ...@@ -30,7 +30,6 @@
#include "modules/peerconnection/RTCPeerConnection.h" #include "modules/peerconnection/RTCPeerConnection.h"
#include "bindings/core/v8/ArrayValue.h"
#include "bindings/core/v8/ExceptionMessages.h" #include "bindings/core/v8/ExceptionMessages.h"
#include "bindings/core/v8/ExceptionState.h" #include "bindings/core/v8/ExceptionState.h"
#include "bindings/core/v8/Microtask.h" #include "bindings/core/v8/Microtask.h"
...@@ -57,10 +56,12 @@ ...@@ -57,10 +56,12 @@
#include "modules/mediastream/MediaConstraintsImpl.h" #include "modules/mediastream/MediaConstraintsImpl.h"
#include "modules/mediastream/MediaStreamEvent.h" #include "modules/mediastream/MediaStreamEvent.h"
#include "modules/peerconnection/RTCAnswerOptions.h" #include "modules/peerconnection/RTCAnswerOptions.h"
#include "modules/peerconnection/RTCConfiguration.h"
#include "modules/peerconnection/RTCDTMFSender.h" #include "modules/peerconnection/RTCDTMFSender.h"
#include "modules/peerconnection/RTCDataChannel.h" #include "modules/peerconnection/RTCDataChannel.h"
#include "modules/peerconnection/RTCDataChannelEvent.h" #include "modules/peerconnection/RTCDataChannelEvent.h"
#include "modules/peerconnection/RTCIceCandidateEvent.h" #include "modules/peerconnection/RTCIceCandidateEvent.h"
#include "modules/peerconnection/RTCIceServer.h"
#include "modules/peerconnection/RTCOfferOptions.h" #include "modules/peerconnection/RTCOfferOptions.h"
#include "modules/peerconnection/RTCPeerConnectionErrorCallback.h" #include "modules/peerconnection/RTCPeerConnectionErrorCallback.h"
#include "modules/peerconnection/RTCSessionDescription.h" #include "modules/peerconnection/RTCSessionDescription.h"
...@@ -217,121 +218,79 @@ class WebRTCCertificateObserver : public WebRTCCertificateCallback { ...@@ -217,121 +218,79 @@ class WebRTCCertificateObserver : public WebRTCCertificateCallback {
Persistent<ScriptPromiseResolver> m_resolver; Persistent<ScriptPromiseResolver> m_resolver;
}; };
WebRTCConfiguration parseConfiguration(const Dictionary& configuration, WebRTCConfiguration parseConfiguration(ExecutionContext* context,
const RTCConfiguration& configuration,
ExceptionState& exceptionState, ExceptionState& exceptionState,
RtcpMuxPolicy* selectedRtcpMuxPolicy) { RtcpMuxPolicy* selectedRtcpMuxPolicy) {
WebRTCConfiguration rtcConfiguration; DCHECK(context);
if (configuration.isUndefinedOrNull()) DCHECK(selectedRtcpMuxPolicy);
return WebRTCConfiguration();
WebRTCIceTransports iceTransports = WebRTCIceTransports::kAll; WebRTCIceTransports iceTransports = WebRTCIceTransports::kAll;
String iceTransportsString; String iceTransportsString = configuration.iceTransports();
if (DictionaryHelper::get(configuration, "iceTransports",
iceTransportsString)) {
if (iceTransportsString == "none") { if (iceTransportsString == "none") {
UseCounter::count(context, UseCounter::RTCConfigurationIceTransportsNone);
iceTransports = WebRTCIceTransports::kNone; iceTransports = WebRTCIceTransports::kNone;
} else if (iceTransportsString == "relay") { } else if (iceTransportsString == "relay") {
iceTransports = WebRTCIceTransports::kRelay; iceTransports = WebRTCIceTransports::kRelay;
} else if (iceTransportsString != "all") { } else {
exceptionState.throwTypeError("Malformed RTCIceTransports"); DCHECK_EQ(iceTransportsString, "all");
return WebRTCConfiguration();
}
}
ArrayValue iceServers;
bool ok = DictionaryHelper::get(configuration, "iceServers", iceServers);
if (!ok || iceServers.isUndefinedOrNull()) {
exceptionState.throwTypeError("Malformed RTCConfiguration");
return WebRTCConfiguration();
}
size_t numberOfServers;
ok = iceServers.length(numberOfServers);
if (!ok) {
exceptionState.throwTypeError("Malformed RTCConfiguration");
return WebRTCConfiguration();
} }
WebRTCBundlePolicy bundlePolicy = WebRTCBundlePolicy::kBalanced; WebRTCBundlePolicy bundlePolicy = WebRTCBundlePolicy::kBalanced;
String bundlePolicyString; String bundlePolicyString = configuration.bundlePolicy();
if (DictionaryHelper::get(configuration, "bundlePolicy",
bundlePolicyString)) {
if (bundlePolicyString == "max-compat") { if (bundlePolicyString == "max-compat") {
bundlePolicy = WebRTCBundlePolicy::kMaxCompat; bundlePolicy = WebRTCBundlePolicy::kMaxCompat;
} else if (bundlePolicyString == "max-bundle") { } else if (bundlePolicyString == "max-bundle") {
bundlePolicy = WebRTCBundlePolicy::kMaxBundle; bundlePolicy = WebRTCBundlePolicy::kMaxBundle;
} else if (bundlePolicyString != "balanced") { } else {
exceptionState.throwTypeError("Malformed RTCBundlePolicy"); DCHECK_EQ(bundlePolicyString, "balanced");
return WebRTCConfiguration();
}
} }
// For the histogram value of "WebRTC.PeerConnection.SelectedRtcpMuxPolicy". // For the histogram value of "WebRTC.PeerConnection.SelectedRtcpMuxPolicy".
*selectedRtcpMuxPolicy = RtcpMuxPolicyDefault; *selectedRtcpMuxPolicy = RtcpMuxPolicyDefault;
WebRTCRtcpMuxPolicy rtcpMuxPolicy = WebRTCRtcpMuxPolicy::kNegotiate; WebRTCRtcpMuxPolicy rtcpMuxPolicy = WebRTCRtcpMuxPolicy::kNegotiate;
String rtcpMuxPolicyString; if (configuration.hasRtcpMuxPolicy()) {
if (DictionaryHelper::get(configuration, "rtcpMuxPolicy", String rtcpMuxPolicyString = configuration.rtcpMuxPolicy();
rtcpMuxPolicyString)) {
if (rtcpMuxPolicyString == "require") { if (rtcpMuxPolicyString == "require") {
*selectedRtcpMuxPolicy = RtcpMuxPolicyRequire; *selectedRtcpMuxPolicy = RtcpMuxPolicyRequire;
rtcpMuxPolicy = WebRTCRtcpMuxPolicy::kRequire; rtcpMuxPolicy = WebRTCRtcpMuxPolicy::kRequire;
} else if (rtcpMuxPolicyString == "negotiate") {
*selectedRtcpMuxPolicy = RtcpMuxPolicyNegotiate;
rtcpMuxPolicy = WebRTCRtcpMuxPolicy::kNegotiate;
} else { } else {
exceptionState.throwTypeError("Malformed RTCRtcpMuxPolicy"); DCHECK_EQ(rtcpMuxPolicyString, "negotiate");
return WebRTCConfiguration(); *selectedRtcpMuxPolicy = RtcpMuxPolicyNegotiate;
}
} }
rtcConfiguration.iceTransports = iceTransports;
rtcConfiguration.bundlePolicy = bundlePolicy;
rtcConfiguration.rtcpMuxPolicy = rtcpMuxPolicy;
for (size_t i = 0; i < numberOfServers; ++i) {
Dictionary iceServer;
ok = iceServers.get(i, iceServer);
if (!ok) {
exceptionState.throwTypeError("Malformed RTCIceServer");
return WebRTCConfiguration();
} }
Vector<String> names; WebRTCConfiguration webConfiguration;
iceServer.getPropertyNames(names); webConfiguration.iceTransports = iceTransports;
webConfiguration.bundlePolicy = bundlePolicy;
webConfiguration.rtcpMuxPolicy = rtcpMuxPolicy;
if (configuration.hasIceServers()) {
Vector<WebRTCIceServer> iceServers;
for (const RTCIceServer& iceServer : configuration.iceServers()) {
Vector<String> urlStrings; Vector<String> urlStrings;
if (names.contains("urls")) { if (iceServer.hasURLs()) {
if (!DictionaryHelper::get(iceServer, "urls", urlStrings) || UseCounter::count(context, UseCounter::RTCIceServerURLs);
!urlStrings.size()) { const StringOrStringSequence& urls = iceServer.urls();
String urlString; if (urls.isString()) {
if (DictionaryHelper::get(iceServer, "urls", urlString)) { urlStrings.append(urls.getAsString());
urlStrings.append(urlString);
} else {
exceptionState.throwTypeError("Malformed RTCIceServer");
return WebRTCConfiguration();
}
}
} else if (names.contains("url")) {
String urlString;
if (DictionaryHelper::get(iceServer, "url", urlString)) {
urlStrings.append(urlString);
} else { } else {
exceptionState.throwTypeError("Malformed RTCIceServer"); DCHECK(urls.isStringSequence());
return WebRTCConfiguration(); urlStrings = urls.getAsStringSequence();
} }
} else if (iceServer.hasURL()) {
UseCounter::count(context, UseCounter::RTCIceServerURL);
urlStrings.append(iceServer.url());
} else { } else {
exceptionState.throwTypeError("Malformed RTCIceServer"); exceptionState.throwTypeError("Malformed RTCIceServer");
return WebRTCConfiguration(); return WebRTCConfiguration();
} }
String username, credential; String username = iceServer.username();
DictionaryHelper::get(iceServer, "username", username); String credential = iceServer.credential();
DictionaryHelper::get(iceServer, "credential", credential);
Vector<WebRTCIceServer> iceServers; for (const String& urlString : urlStrings) {
for (Vector<String>::iterator iter = urlStrings.begin(); KURL url(KURL(), urlString);
iter != urlStrings.end(); ++iter) {
KURL url(KURL(), *iter);
if (!url.isValid() || if (!url.isValid() ||
!(url.protocolIs("turn") || url.protocolIs("turns") || !(url.protocolIs("turn") || url.protocolIs("turns") ||
url.protocolIs("stun"))) { url.protocolIs("stun"))) {
...@@ -340,36 +299,22 @@ WebRTCConfiguration parseConfiguration(const Dictionary& configuration, ...@@ -340,36 +299,22 @@ WebRTCConfiguration parseConfiguration(const Dictionary& configuration,
} }
iceServers.append(WebRTCIceServer{url, username, credential}); iceServers.append(WebRTCIceServer{url, username, credential});
} }
rtcConfiguration.iceServers = iceServers;
} }
webConfiguration.iceServers = iceServers;
ArrayValue certificates;
if (DictionaryHelper::get(configuration, "certificates", certificates) &&
!certificates.isUndefinedOrNull()) {
size_t numberOfCertificates;
certificates.length(numberOfCertificates);
WebVector<std::unique_ptr<WebRTCCertificate>> certificatesCopy(
numberOfCertificates);
for (size_t i = 0; i < numberOfCertificates; ++i) {
RTCCertificate* certificate = nullptr;
Dictionary dictCert;
certificates.get(i, dictCert);
v8::Local<v8::Value> valCert = dictCert.v8Value();
if (!valCert.IsEmpty()) {
certificate = V8RTCCertificate::toImplWithTypeCheck(
configuration.isolate(), valCert);
}
if (!certificate) {
exceptionState.throwTypeError("Malformed sequence<RTCCertificate>");
return WebRTCConfiguration();
} }
certificatesCopy[i] = certificate->certificateShallowCopy(); if (configuration.hasCertificates()) {
const HeapVector<Member<RTCCertificate>>& certificates =
configuration.certificates();
WebVector<std::unique_ptr<WebRTCCertificate>> certificatesCopy(
certificates.size());
for (size_t i = 0; i < certificates.size(); ++i) {
certificatesCopy[i] = certificates[i]->certificateShallowCopy();
} }
rtcConfiguration.certificates = std::move(certificatesCopy); webConfiguration.certificates = std::move(certificatesCopy);
} }
return rtcConfiguration;
return webConfiguration;
} }
RTCOfferOptionsPlatform* parseOfferOptions(const Dictionary& options) { RTCOfferOptionsPlatform* parseOfferOptions(const Dictionary& options) {
...@@ -452,8 +397,9 @@ DEFINE_TRACE(RTCPeerConnection::EventWrapper) { ...@@ -452,8 +397,9 @@ DEFINE_TRACE(RTCPeerConnection::EventWrapper) {
visitor->trace(m_event); visitor->trace(m_event);
} }
RTCPeerConnection* RTCPeerConnection::create(ExecutionContext* context, RTCPeerConnection* RTCPeerConnection::create(
const Dictionary& rtcConfiguration, ExecutionContext* context,
const RTCConfiguration& rtcConfiguration,
const Dictionary& mediaConstraints, const Dictionary& mediaConstraints,
ExceptionState& exceptionState) { ExceptionState& exceptionState) {
if (mediaConstraints.isObject()) if (mediaConstraints.isObject())
...@@ -467,7 +413,7 @@ RTCPeerConnection* RTCPeerConnection::create(ExecutionContext* context, ...@@ -467,7 +413,7 @@ RTCPeerConnection* RTCPeerConnection::create(ExecutionContext* context,
// "WebRTC.PeerConnection.SelectedRtcpMuxPolicy". // "WebRTC.PeerConnection.SelectedRtcpMuxPolicy".
RtcpMuxPolicy selectedRtcpMuxPolicy = RtcpMuxPolicyDefault; RtcpMuxPolicy selectedRtcpMuxPolicy = RtcpMuxPolicyDefault;
WebRTCConfiguration configuration = parseConfiguration( WebRTCConfiguration configuration = parseConfiguration(
rtcConfiguration, exceptionState, &selectedRtcpMuxPolicy); context, rtcConfiguration, exceptionState, &selectedRtcpMuxPolicy);
if (exceptionState.hadException()) if (exceptionState.hadException())
return 0; return 0;
...@@ -825,7 +771,8 @@ RTCSessionDescription* RTCPeerConnection::remoteDescription() { ...@@ -825,7 +771,8 @@ RTCSessionDescription* RTCPeerConnection::remoteDescription() {
return RTCSessionDescription::create(webSessionDescription); return RTCSessionDescription::create(webSessionDescription);
} }
void RTCPeerConnection::updateIce(const Dictionary& rtcConfiguration, void RTCPeerConnection::updateIce(ExecutionContext* context,
const RTCConfiguration& rtcConfiguration,
const Dictionary& mediaConstraints, const Dictionary& mediaConstraints,
ExceptionState& exceptionState) { ExceptionState& exceptionState) {
if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState))
...@@ -833,7 +780,7 @@ void RTCPeerConnection::updateIce(const Dictionary& rtcConfiguration, ...@@ -833,7 +780,7 @@ void RTCPeerConnection::updateIce(const Dictionary& rtcConfiguration,
RtcpMuxPolicy selectedRtcpMuxPolicy = RtcpMuxPolicyDefault; RtcpMuxPolicy selectedRtcpMuxPolicy = RtcpMuxPolicyDefault;
WebRTCConfiguration configuration = parseConfiguration( WebRTCConfiguration configuration = parseConfiguration(
rtcConfiguration, exceptionState, &selectedRtcpMuxPolicy); context, rtcConfiguration, exceptionState, &selectedRtcpMuxPolicy);
if (exceptionState.hadException()) if (exceptionState.hadException())
return; return;
......
...@@ -32,7 +32,6 @@ ...@@ -32,7 +32,6 @@
#define RTCPeerConnection_h #define RTCPeerConnection_h
#include "bindings/core/v8/ActiveScriptWrappable.h" #include "bindings/core/v8/ActiveScriptWrappable.h"
#include "bindings/core/v8/Dictionary.h"
#include "bindings/core/v8/ScriptPromise.h" #include "bindings/core/v8/ScriptPromise.h"
#include "core/dom/ActiveDOMObject.h" #include "core/dom/ActiveDOMObject.h"
#include "modules/EventTargetModules.h" #include "modules/EventTargetModules.h"
...@@ -49,6 +48,7 @@ namespace blink { ...@@ -49,6 +48,7 @@ namespace blink {
class ExceptionState; class ExceptionState;
class MediaStreamTrack; class MediaStreamTrack;
class RTCAnswerOptions; class RTCAnswerOptions;
class RTCConfiguration;
class RTCDTMFSender; class RTCDTMFSender;
class RTCDataChannel; class RTCDataChannel;
class RTCIceCandidateInitOrRTCIceCandidate; class RTCIceCandidateInitOrRTCIceCandidate;
...@@ -72,7 +72,7 @@ class RTCPeerConnection final : public EventTargetWithInlineData, ...@@ -72,7 +72,7 @@ class RTCPeerConnection final : public EventTargetWithInlineData,
public: public:
static RTCPeerConnection* create(ExecutionContext*, static RTCPeerConnection* create(ExecutionContext*,
const Dictionary&, const RTCConfiguration&,
const Dictionary&, const Dictionary&,
ExceptionState&); ExceptionState&);
~RTCPeerConnection() override; ~RTCPeerConnection() override;
...@@ -107,7 +107,8 @@ class RTCPeerConnection final : public EventTargetWithInlineData, ...@@ -107,7 +107,8 @@ class RTCPeerConnection final : public EventTargetWithInlineData,
String signalingState() const; String signalingState() const;
void updateIce(const Dictionary& rtcConfiguration, void updateIce(ExecutionContext*,
const RTCConfiguration&,
const Dictionary& mediaConstraints, const Dictionary& mediaConstraints,
ExceptionState&); ExceptionState&);
......
...@@ -63,9 +63,8 @@ enum RTCIceConnectionState { ...@@ -63,9 +63,8 @@ enum RTCIceConnectionState {
[ [
ActiveScriptWrappable, ActiveScriptWrappable,
DependentLifetime, DependentLifetime,
// TODO(guidou): There should only be one constructor argument, and it // TODO(guidou): There should only be one constructor argument.
// should be optional. Constructor(optional RTCConfiguration configuration, optional Dictionary mediaConstraints),
Constructor(Dictionary rtcConfiguration, optional Dictionary mediaConstraints),
ConstructorCallWith=ExecutionContext, ConstructorCallWith=ExecutionContext,
NoInterfaceObject, NoInterfaceObject,
RaisesException=Constructor, RaisesException=Constructor,
...@@ -122,7 +121,7 @@ enum RTCIceConnectionState { ...@@ -122,7 +121,7 @@ enum RTCIceConnectionState {
[RaisesException, CallWith=ScriptState] static Promise<RTCCertificate> generateCertificate(AlgorithmIdentifier keygenAlgorithm); [RaisesException, CallWith=ScriptState] static Promise<RTCCertificate> generateCertificate(AlgorithmIdentifier keygenAlgorithm);
// Non-standard or removed from the spec: // Non-standard or removed from the spec:
[Measure, RaisesException] void updateIce(optional Dictionary configuration, optional Dictionary mediaConstraints); [Measure, CallWith=ExecutionContext, RaisesException] void updateIce(optional RTCConfiguration configuration, optional Dictionary mediaConstraints);
[Measure] sequence<MediaStream> getLocalStreams(); [Measure] sequence<MediaStream> getLocalStreams();
[Measure] sequence<MediaStream> getRemoteStreams(); [Measure] sequence<MediaStream> getRemoteStreams();
[Measure] MediaStream getStreamById(DOMString streamId); [Measure] MediaStream getStreamById(DOMString streamId);
......
...@@ -84592,6 +84592,9 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries. ...@@ -84592,6 +84592,9 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries.
<int value="1652" label="LoopbackEmbeddedInSecureContext"/> <int value="1652" label="LoopbackEmbeddedInSecureContext"/>
<int value="1653" label="LoopbackEmbeddedInNonSecureContext"/> <int value="1653" label="LoopbackEmbeddedInNonSecureContext"/>
<int value="1654" label="BlinkMacSystemFont"/> <int value="1654" label="BlinkMacSystemFont"/>
<int value="1655" label="RTCConfigurationIceTransportsNone"/>
<int value="1656" label="RTCIceServerURL"/>
<int value="1657" label="RTCIceServerURLs"/>
</enum> </enum>
<enum name="FetchRequestMode" type="int"> <enum name="FetchRequestMode" type="int">
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment