OLD | NEW |
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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 iceTransports = RTCIceTransportsNone; | 136 iceTransports = RTCIceTransportsNone; |
137 } else if (iceTransportsString == "relay") { | 137 } else if (iceTransportsString == "relay") { |
138 iceTransports = RTCIceTransportsRelay; | 138 iceTransports = RTCIceTransportsRelay; |
139 } else if (iceTransportsString != "all") { | 139 } else if (iceTransportsString != "all") { |
140 exceptionState.throwTypeError("Malformed RTCIceTransports"); | 140 exceptionState.throwTypeError("Malformed RTCIceTransports"); |
141 return 0; | 141 return 0; |
142 } | 142 } |
143 } | 143 } |
144 | 144 |
145 ArrayValue iceServers; | 145 ArrayValue iceServers; |
146 size_t numberOfServers = 0; | 146 bool ok = DictionaryHelper::get(configuration, "iceServers", iceServers); |
147 bool createIceServerArray = true; | 147 if (!ok || iceServers.isUndefinedOrNull()) { |
148 if (DictionaryHelper::get(configuration, "iceServers", iceServers)) { | 148 exceptionState.throwTypeError("Malformed RTCConfiguration"); |
149 if (!iceServers.length(numberOfServers)) { | 149 return 0; |
150 exceptionState.throwTypeError("Malformed RTCConfiguration"); | 150 } |
151 return 0; | 151 |
152 } | 152 size_t numberOfServers; |
153 } else { | 153 ok = iceServers.length(numberOfServers); |
154 v8::Local<v8::Value> iceServersValue; | 154 if (!ok) { |
155 // Failed to parse iceServers as ArrayValue, try it as a scalar. If | 155 exceptionState.throwTypeError("Malformed RTCConfiguration"); |
156 // iceServers is not specified (get returns false) or specified as | 156 return 0; |
157 // "undefined", treat it as the special case which RTCIceServerArray | |
158 // will not be created. | |
159 bool ok = (!DictionaryHelper::get(configuration, "iceServers", iceServer
sValue) | |
160 || iceServersValue->IsUndefined()); | |
161 if (!ok) { | |
162 exceptionState.throwTypeError("Malformed RTCConfiguration"); | |
163 return 0; | |
164 } | |
165 createIceServerArray = false; | |
166 } | 157 } |
167 | 158 |
168 RTCBundlePolicy bundlePolicy = RTCBundlePolicyBalanced; | 159 RTCBundlePolicy bundlePolicy = RTCBundlePolicyBalanced; |
169 String bundlePolicyString; | 160 String bundlePolicyString; |
170 if (DictionaryHelper::get(configuration, "bundlePolicy", bundlePolicyString)
) { | 161 if (DictionaryHelper::get(configuration, "bundlePolicy", bundlePolicyString)
) { |
171 if (bundlePolicyString == "max-compat") { | 162 if (bundlePolicyString == "max-compat") { |
172 bundlePolicy = RTCBundlePolicyMaxCompat; | 163 bundlePolicy = RTCBundlePolicyMaxCompat; |
173 } else if (bundlePolicyString == "max-bundle") { | 164 } else if (bundlePolicyString == "max-bundle") { |
174 bundlePolicy = RTCBundlePolicyMaxBundle; | 165 bundlePolicy = RTCBundlePolicyMaxBundle; |
175 } else if (bundlePolicyString != "balanced") { | 166 } else if (bundlePolicyString != "balanced") { |
(...skipping 10 matching lines...) Expand all Loading... |
186 } else if (rtcpMuxPolicyString != "negotiate") { | 177 } else if (rtcpMuxPolicyString != "negotiate") { |
187 exceptionState.throwTypeError("Malformed RTCRtcpMuxPolicy"); | 178 exceptionState.throwTypeError("Malformed RTCRtcpMuxPolicy"); |
188 return 0; | 179 return 0; |
189 } | 180 } |
190 } | 181 } |
191 | 182 |
192 RTCConfiguration* rtcConfiguration = RTCConfiguration::create(); | 183 RTCConfiguration* rtcConfiguration = RTCConfiguration::create(); |
193 rtcConfiguration->setIceTransports(iceTransports); | 184 rtcConfiguration->setIceTransports(iceTransports); |
194 rtcConfiguration->setBundlePolicy(bundlePolicy); | 185 rtcConfiguration->setBundlePolicy(bundlePolicy); |
195 rtcConfiguration->setRtcpMuxPolicy(rtcpMuxPolicy); | 186 rtcConfiguration->setRtcpMuxPolicy(rtcpMuxPolicy); |
196 if (createIceServerArray) { | |
197 rtcConfiguration->setIceServers(RTCIceServerArray::create()); | |
198 } | |
199 | 187 |
200 for (size_t i = 0; i < numberOfServers; ++i) { | 188 for (size_t i = 0; i < numberOfServers; ++i) { |
201 Dictionary iceServer; | 189 Dictionary iceServer; |
202 bool ok = iceServers.get(i, iceServer); | 190 ok = iceServers.get(i, iceServer); |
203 if (!ok) { | 191 if (!ok) { |
204 exceptionState.throwTypeError("Malformed RTCIceServer"); | 192 exceptionState.throwTypeError("Malformed RTCIceServer"); |
205 return 0; | 193 return 0; |
206 } | 194 } |
207 | 195 |
208 Vector<String> names; | 196 Vector<String> names; |
209 iceServer.getPropertyNames(names); | 197 iceServer.getPropertyNames(names); |
210 | 198 |
211 Vector<String> urlStrings; | 199 Vector<String> urlStrings; |
212 if (names.contains("urls")) { | 200 if (names.contains("urls")) { |
(...skipping 23 matching lines...) Expand all Loading... |
236 DictionaryHelper::get(iceServer, "username", username); | 224 DictionaryHelper::get(iceServer, "username", username); |
237 DictionaryHelper::get(iceServer, "credential", credential); | 225 DictionaryHelper::get(iceServer, "credential", credential); |
238 | 226 |
239 for (Vector<String>::iterator iter = urlStrings.begin(); iter != urlStri
ngs.end(); ++iter) { | 227 for (Vector<String>::iterator iter = urlStrings.begin(); iter != urlStri
ngs.end(); ++iter) { |
240 KURL url(KURL(), *iter); | 228 KURL url(KURL(), *iter); |
241 if (!url.isValid() || !(url.protocolIs("turn") || url.protocolIs("tu
rns") || url.protocolIs("stun"))) { | 229 if (!url.isValid() || !(url.protocolIs("turn") || url.protocolIs("tu
rns") || url.protocolIs("stun"))) { |
242 exceptionState.throwTypeError("Malformed URL"); | 230 exceptionState.throwTypeError("Malformed URL"); |
243 return 0; | 231 return 0; |
244 } | 232 } |
245 | 233 |
246 rtcConfiguration->iceServers()->appendServer(RTCIceServer::create(ur
l, username, credential)); | 234 rtcConfiguration->appendServer(RTCIceServer::create(url, username, c
redential)); |
247 } | 235 } |
248 } | 236 } |
249 | 237 |
250 ArrayValue certificates; | 238 ArrayValue certificates; |
251 if (DictionaryHelper::get(configuration, "certificates", certificates) && !c
ertificates.isUndefinedOrNull()) { | 239 if (DictionaryHelper::get(configuration, "certificates", certificates) && !c
ertificates.isUndefinedOrNull()) { |
252 size_t numberOfCertificates; | 240 size_t numberOfCertificates; |
253 certificates.length(numberOfCertificates); | 241 certificates.length(numberOfCertificates); |
254 for (size_t i = 0; i < numberOfCertificates; ++i) { | 242 for (size_t i = 0; i < numberOfCertificates; ++i) { |
255 RTCCertificate* certificate = nullptr; | 243 RTCCertificate* certificate = nullptr; |
256 | 244 |
(...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
969 { | 957 { |
970 visitor->trace(m_localStreams); | 958 visitor->trace(m_localStreams); |
971 visitor->trace(m_remoteStreams); | 959 visitor->trace(m_remoteStreams); |
972 visitor->trace(m_dataChannels); | 960 visitor->trace(m_dataChannels); |
973 visitor->trace(m_scheduledEvents); | 961 visitor->trace(m_scheduledEvents); |
974 RefCountedGarbageCollectedEventTargetWithInlineData<RTCPeerConnection>::trac
e(visitor); | 962 RefCountedGarbageCollectedEventTargetWithInlineData<RTCPeerConnection>::trac
e(visitor); |
975 ActiveDOMObject::trace(visitor); | 963 ActiveDOMObject::trace(visitor); |
976 } | 964 } |
977 | 965 |
978 } // namespace blink | 966 } // namespace blink |
OLD | NEW |