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

Side by Side 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 iceTransports = RTCIceTransportsNone; 96 iceTransports = RTCIceTransportsNone;
97 } else if (iceTransportsString == "relay") { 97 } else if (iceTransportsString == "relay") {
98 iceTransports = RTCIceTransportsRelay; 98 iceTransports = RTCIceTransportsRelay;
99 } else if (iceTransportsString != "all") { 99 } else if (iceTransportsString != "all") {
100 exceptionState.throwTypeError("Malformed RTCIceTransports"); 100 exceptionState.throwTypeError("Malformed RTCIceTransports");
101 return 0; 101 return 0;
102 } 102 }
103 } 103 }
104 104
105 ArrayValue iceServers; 105 ArrayValue iceServers;
106 bool ok = DictionaryHelper::get(configuration, "iceServers", iceServers); 106 size_t numberOfServers = 0;
107 if (!ok || iceServers.isUndefinedOrNull()) { 107 bool createIceServerArray = true;
108 exceptionState.throwTypeError("Malformed RTCConfiguration"); 108 if (DictionaryHelper::get(configuration, "iceServers", iceServers)) {
109 return 0; 109 if (!iceServers.length(numberOfServers)) {
110 } 110 exceptionState.throwTypeError("Malformed RTCConfiguration");
111 111 return 0;
112 size_t numberOfServers; 112 }
tommi (sloooow) - chröme 2015/09/16 18:19:45 do we need to check for numberOfServers==0 or do w
guoweis_left_chromium 2015/09/16 22:10:20 for iceServers:[] case, we do want to create the s
113 ok = iceServers.length(numberOfServers); 113 } else {
114 if (!ok) { 114 v8::Local<v8::Value> iceServersValue;
115 exceptionState.throwTypeError("Malformed RTCConfiguration"); 115 // Failed to parse iceServers as ArrayValue, try it as a scalar. If
116 return 0; 116 // iceServers is not specified (get returns false) or specified as
117 // "undefined", treat it as the special case which RTCIceServerArray
118 // will not be created.
119 bool ok = (!DictionaryHelper::get(configuration, "iceServers", iceServer sValue)
120 || iceServersValue->IsUndefined());
121 if (!ok) {
122 exceptionState.throwTypeError("Malformed RTCConfiguration");
123 return 0;
124 }
125 createIceServerArray = false;
117 } 126 }
118 127
119 RTCBundlePolicy bundlePolicy = RTCBundlePolicyBalanced; 128 RTCBundlePolicy bundlePolicy = RTCBundlePolicyBalanced;
120 String bundlePolicyString; 129 String bundlePolicyString;
121 if (DictionaryHelper::get(configuration, "bundlePolicy", bundlePolicyString) ) { 130 if (DictionaryHelper::get(configuration, "bundlePolicy", bundlePolicyString) ) {
122 if (bundlePolicyString == "max-compat") { 131 if (bundlePolicyString == "max-compat") {
123 bundlePolicy = RTCBundlePolicyMaxCompat; 132 bundlePolicy = RTCBundlePolicyMaxCompat;
124 } else if (bundlePolicyString == "max-bundle") { 133 } else if (bundlePolicyString == "max-bundle") {
125 bundlePolicy = RTCBundlePolicyMaxBundle; 134 bundlePolicy = RTCBundlePolicyMaxBundle;
126 } else if (bundlePolicyString != "balanced") { 135 } else if (bundlePolicyString != "balanced") {
(...skipping 10 matching lines...) Expand all
137 } else if (rtcpMuxPolicyString != "negotiate") { 146 } else if (rtcpMuxPolicyString != "negotiate") {
138 exceptionState.throwTypeError("Malformed RTCRtcpMuxPolicy"); 147 exceptionState.throwTypeError("Malformed RTCRtcpMuxPolicy");
139 return 0; 148 return 0;
140 } 149 }
141 } 150 }
142 151
143 RTCConfiguration* rtcConfiguration = RTCConfiguration::create(); 152 RTCConfiguration* rtcConfiguration = RTCConfiguration::create();
144 rtcConfiguration->setIceTransports(iceTransports); 153 rtcConfiguration->setIceTransports(iceTransports);
145 rtcConfiguration->setBundlePolicy(bundlePolicy); 154 rtcConfiguration->setBundlePolicy(bundlePolicy);
146 rtcConfiguration->setRtcpMuxPolicy(rtcpMuxPolicy); 155 rtcConfiguration->setRtcpMuxPolicy(rtcpMuxPolicy);
156 if (createIceServerArray) {
157 rtcConfiguration->setIceServers(RTCIceServerArray::create());
158 }
147 159
148 for (size_t i = 0; i < numberOfServers; ++i) { 160 for (size_t i = 0; i < numberOfServers; ++i) {
149 Dictionary iceServer; 161 Dictionary iceServer;
150 ok = iceServers.get(i, iceServer); 162 bool ok = iceServers.get(i, iceServer);
151 if (!ok) { 163 if (!ok) {
152 exceptionState.throwTypeError("Malformed RTCIceServer"); 164 exceptionState.throwTypeError("Malformed RTCIceServer");
153 return 0; 165 return 0;
154 } 166 }
155 167
156 Vector<String> names; 168 Vector<String> names;
157 iceServer.getPropertyNames(names); 169 iceServer.getPropertyNames(names);
158 170
159 Vector<String> urlStrings; 171 Vector<String> urlStrings;
160 if (names.contains("urls")) { 172 if (names.contains("urls")) {
(...skipping 23 matching lines...) Expand all
184 DictionaryHelper::get(iceServer, "username", username); 196 DictionaryHelper::get(iceServer, "username", username);
185 DictionaryHelper::get(iceServer, "credential", credential); 197 DictionaryHelper::get(iceServer, "credential", credential);
186 198
187 for (Vector<String>::iterator iter = urlStrings.begin(); iter != urlStri ngs.end(); ++iter) { 199 for (Vector<String>::iterator iter = urlStrings.begin(); iter != urlStri ngs.end(); ++iter) {
188 KURL url(KURL(), *iter); 200 KURL url(KURL(), *iter);
189 if (!url.isValid() || !(url.protocolIs("turn") || url.protocolIs("tu rns") || url.protocolIs("stun"))) { 201 if (!url.isValid() || !(url.protocolIs("turn") || url.protocolIs("tu rns") || url.protocolIs("stun"))) {
190 exceptionState.throwTypeError("Malformed URL"); 202 exceptionState.throwTypeError("Malformed URL");
191 return 0; 203 return 0;
192 } 204 }
193 205
194 rtcConfiguration->appendServer(RTCIceServer::create(url, username, c redential)); 206 rtcConfiguration->iceServers()->appendServer(RTCIceServer::create(ur l, username, credential));
195 } 207 }
196 } 208 }
197 209
198 return rtcConfiguration; 210 return rtcConfiguration;
199 } 211 }
200 212
201 RTCOfferOptions* RTCPeerConnection::parseOfferOptions(const Dictionary& options, ExceptionState& exceptionState) 213 RTCOfferOptions* RTCPeerConnection::parseOfferOptions(const Dictionary& options, ExceptionState& exceptionState)
202 { 214 {
203 if (options.isUndefinedOrNull()) 215 if (options.isUndefinedOrNull())
204 return 0; 216 return 0;
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after
835 { 847 {
836 visitor->trace(m_localStreams); 848 visitor->trace(m_localStreams);
837 visitor->trace(m_remoteStreams); 849 visitor->trace(m_remoteStreams);
838 visitor->trace(m_dataChannels); 850 visitor->trace(m_dataChannels);
839 visitor->trace(m_scheduledEvents); 851 visitor->trace(m_scheduledEvents);
840 RefCountedGarbageCollectedEventTargetWithInlineData<RTCPeerConnection>::trac e(visitor); 852 RefCountedGarbageCollectedEventTargetWithInlineData<RTCPeerConnection>::trac e(visitor);
841 ActiveDOMObject::trace(visitor); 853 ActiveDOMObject::trace(visitor);
842 } 854 }
843 855
844 } // namespace blink 856 } // namespace blink
OLDNEW
« no previous file with comments | « LayoutTests/fast/mediastream/RTCPeerConnection-expected.txt ('k') | Source/platform/exported/WebRTCConfiguration.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698