Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1146)

Unified Diff: Source/modules/mediastream/RTCPeerConnection.cpp

Issue 1315413004: Enable generation of local host candidate. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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;

Powered by Google App Engine
This is Rietveld 408576698