| Index: Source/modules/mediastream/RTCPeerConnection.cpp
|
| diff --git a/Source/modules/mediastream/RTCPeerConnection.cpp b/Source/modules/mediastream/RTCPeerConnection.cpp
|
| index b3ae4317d8a5817b673b7bd3035222e7243f6680..820b87fc5689929b2aae39f0c94ad14f1766f28c 100644
|
| --- a/Source/modules/mediastream/RTCPeerConnection.cpp
|
| +++ b/Source/modules/mediastream/RTCPeerConnection.cpp
|
| @@ -103,17 +103,28 @@ RTCConfiguration* RTCPeerConnection::parseConfiguration(const Dictionary& config
|
| }
|
|
|
| ArrayValue iceServers;
|
| + size_t numberOfServers = 0;
|
| + bool enableLocalhostCandidate = false;
|
| bool ok = DictionaryHelper::get(configuration, "iceServers", iceServers);
|
| - if (!ok || iceServers.isUndefinedOrNull()) {
|
| - exceptionState.throwTypeError("Malformed RTCConfiguration");
|
| - return 0;
|
| - }
|
| -
|
| - size_t numberOfServers;
|
| - ok = iceServers.length(numberOfServers);
|
| if (!ok) {
|
| - exceptionState.throwTypeError("Malformed RTCConfiguration");
|
| - return 0;
|
| + v8::Local<v8::Value> iceServersValue;
|
| + // Failed to parse iceServers as ArrayValue, try it as a scalar.
|
| + ok = DictionaryHelper::get(configuration, "iceServers", iceServersValue);
|
| + if (!ok || iceServersValue->IsUndefined()) {
|
| + // if iceServers is not specified (|ok| is false) or specified as
|
| + // "undefined", treat it as the special case which generates
|
| + // localhost candidate.
|
| + enableLocalhostCandidate = true;
|
| + } else {
|
| + exceptionState.throwTypeError("Malformed RTCConfiguration");
|
| + return 0;
|
| + }
|
| + } else {
|
| + ok = iceServers.length(numberOfServers);
|
| + if (!ok) {
|
| + exceptionState.throwTypeError("Malformed RTCConfiguration");
|
| + return 0;
|
| + }
|
| }
|
|
|
| RTCBundlePolicy bundlePolicy = RTCBundlePolicyBalanced;
|
| @@ -144,6 +155,7 @@ RTCConfiguration* RTCPeerConnection::parseConfiguration(const Dictionary& config
|
| rtcConfiguration->setIceTransports(iceTransports);
|
| rtcConfiguration->setBundlePolicy(bundlePolicy);
|
| rtcConfiguration->setRtcpMuxPolicy(rtcpMuxPolicy);
|
| + rtcConfiguration->setEnableLocalhostCandidate(enableLocalhostCandidate);
|
|
|
| for (size_t i = 0; i < numberOfServers; ++i) {
|
| Dictionary iceServer;
|
|
|