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

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, 3 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..f68455d803fe916ebdc0d454a8aa06baab86343e 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 createIceServerArray = true;
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 RTCIceServerArray
+ // will not be created.
+ createIceServerArray = false;
+ } else {
+ exceptionState.throwTypeError("Malformed RTCConfiguration");
+ return 0;
+ }
+ } else {
+ ok = iceServers.length(numberOfServers);
+ if (!ok) {
tommi (sloooow) - chröme 2015/09/16 06:19:27 do we need to handle numberOfServers == 0? (looks
guoweis_left_chromium 2015/09/16 17:29:05 numberOfServers == 0, i.e. iceServers:[], is treat
tommi (sloooow) - chröme 2015/09/16 18:19:45 ok, but whenever numberOfServers is 0, won't (or s
guoweis_left_chromium 2015/09/16 22:10:20 when there is no iceServers specified (or undefine
+ exceptionState.throwTypeError("Malformed RTCConfiguration");
+ return 0;
+ }
}
pthatcher2 2015/09/16 04:09:58 Can you put the early returns first? if (Dictiona
guoweis_left_chromium 2015/09/16 17:29:05 Done.
RTCBundlePolicy bundlePolicy = RTCBundlePolicyBalanced;
@@ -144,6 +155,9 @@ RTCConfiguration* RTCPeerConnection::parseConfiguration(const Dictionary& config
rtcConfiguration->setIceTransports(iceTransports);
rtcConfiguration->setBundlePolicy(bundlePolicy);
rtcConfiguration->setRtcpMuxPolicy(rtcpMuxPolicy);
+ if (createIceServerArray) {
+ rtcConfiguration->setIceServers(RTCIceServerArray::create());
+ }
for (size_t i = 0; i < numberOfServers; ++i) {
Dictionary iceServer;
@@ -191,7 +205,7 @@ RTCConfiguration* RTCPeerConnection::parseConfiguration(const Dictionary& config
return 0;
}
- rtcConfiguration->appendServer(RTCIceServer::create(url, username, credential));
+ rtcConfiguration->iceServers()->appendServer(RTCIceServer::create(url, username, credential));
}
}

Powered by Google App Engine
This is Rietveld 408576698