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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 size_t numberOfServers = 0; | |
107 bool createIceServerArray = true; | |
106 bool ok = DictionaryHelper::get(configuration, "iceServers", iceServers); | 108 bool ok = DictionaryHelper::get(configuration, "iceServers", iceServers); |
107 if (!ok || iceServers.isUndefinedOrNull()) { | |
108 exceptionState.throwTypeError("Malformed RTCConfiguration"); | |
109 return 0; | |
110 } | |
111 | |
112 size_t numberOfServers; | |
113 ok = iceServers.length(numberOfServers); | |
114 if (!ok) { | 109 if (!ok) { |
115 exceptionState.throwTypeError("Malformed RTCConfiguration"); | 110 v8::Local<v8::Value> iceServersValue; |
116 return 0; | 111 // Failed to parse iceServers as ArrayValue, try it as a scalar. |
112 ok = DictionaryHelper::get(configuration, "iceServers", iceServersValue) ; | |
113 if (!ok || iceServersValue->IsUndefined()) { | |
114 // if iceServers is not specified (|ok| is false) or specified as | |
115 // "undefined", treat it as the special case which RTCIceServerArray | |
116 // will not be created. | |
117 createIceServerArray = false; | |
118 } else { | |
119 exceptionState.throwTypeError("Malformed RTCConfiguration"); | |
120 return 0; | |
121 } | |
122 } else { | |
123 ok = iceServers.length(numberOfServers); | |
124 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
| |
125 exceptionState.throwTypeError("Malformed RTCConfiguration"); | |
126 return 0; | |
127 } | |
117 } | 128 } |
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.
| |
118 | 129 |
119 RTCBundlePolicy bundlePolicy = RTCBundlePolicyBalanced; | 130 RTCBundlePolicy bundlePolicy = RTCBundlePolicyBalanced; |
120 String bundlePolicyString; | 131 String bundlePolicyString; |
121 if (DictionaryHelper::get(configuration, "bundlePolicy", bundlePolicyString) ) { | 132 if (DictionaryHelper::get(configuration, "bundlePolicy", bundlePolicyString) ) { |
122 if (bundlePolicyString == "max-compat") { | 133 if (bundlePolicyString == "max-compat") { |
123 bundlePolicy = RTCBundlePolicyMaxCompat; | 134 bundlePolicy = RTCBundlePolicyMaxCompat; |
124 } else if (bundlePolicyString == "max-bundle") { | 135 } else if (bundlePolicyString == "max-bundle") { |
125 bundlePolicy = RTCBundlePolicyMaxBundle; | 136 bundlePolicy = RTCBundlePolicyMaxBundle; |
126 } else if (bundlePolicyString != "balanced") { | 137 } else if (bundlePolicyString != "balanced") { |
127 exceptionState.throwTypeError("Malformed RTCBundlePolicy"); | 138 exceptionState.throwTypeError("Malformed RTCBundlePolicy"); |
128 return 0; | 139 return 0; |
129 } | 140 } |
130 } | 141 } |
131 | 142 |
132 RTCRtcpMuxPolicy rtcpMuxPolicy = RTCRtcpMuxPolicyNegotiate; | 143 RTCRtcpMuxPolicy rtcpMuxPolicy = RTCRtcpMuxPolicyNegotiate; |
133 String rtcpMuxPolicyString; | 144 String rtcpMuxPolicyString; |
134 if (DictionaryHelper::get(configuration, "rtcpMuxPolicy", rtcpMuxPolicyStrin g)) { | 145 if (DictionaryHelper::get(configuration, "rtcpMuxPolicy", rtcpMuxPolicyStrin g)) { |
135 if (rtcpMuxPolicyString == "require") { | 146 if (rtcpMuxPolicyString == "require") { |
136 rtcpMuxPolicy = RTCRtcpMuxPolicyRequire; | 147 rtcpMuxPolicy = RTCRtcpMuxPolicyRequire; |
137 } else if (rtcpMuxPolicyString != "negotiate") { | 148 } else if (rtcpMuxPolicyString != "negotiate") { |
138 exceptionState.throwTypeError("Malformed RTCRtcpMuxPolicy"); | 149 exceptionState.throwTypeError("Malformed RTCRtcpMuxPolicy"); |
139 return 0; | 150 return 0; |
140 } | 151 } |
141 } | 152 } |
142 | 153 |
143 RTCConfiguration* rtcConfiguration = RTCConfiguration::create(); | 154 RTCConfiguration* rtcConfiguration = RTCConfiguration::create(); |
144 rtcConfiguration->setIceTransports(iceTransports); | 155 rtcConfiguration->setIceTransports(iceTransports); |
145 rtcConfiguration->setBundlePolicy(bundlePolicy); | 156 rtcConfiguration->setBundlePolicy(bundlePolicy); |
146 rtcConfiguration->setRtcpMuxPolicy(rtcpMuxPolicy); | 157 rtcConfiguration->setRtcpMuxPolicy(rtcpMuxPolicy); |
158 if (createIceServerArray) { | |
159 rtcConfiguration->setIceServers(RTCIceServerArray::create()); | |
160 } | |
147 | 161 |
148 for (size_t i = 0; i < numberOfServers; ++i) { | 162 for (size_t i = 0; i < numberOfServers; ++i) { |
149 Dictionary iceServer; | 163 Dictionary iceServer; |
150 ok = iceServers.get(i, iceServer); | 164 ok = iceServers.get(i, iceServer); |
151 if (!ok) { | 165 if (!ok) { |
152 exceptionState.throwTypeError("Malformed RTCIceServer"); | 166 exceptionState.throwTypeError("Malformed RTCIceServer"); |
153 return 0; | 167 return 0; |
154 } | 168 } |
155 | 169 |
156 Vector<String> names; | 170 Vector<String> names; |
(...skipping 27 matching lines...) Expand all Loading... | |
184 DictionaryHelper::get(iceServer, "username", username); | 198 DictionaryHelper::get(iceServer, "username", username); |
185 DictionaryHelper::get(iceServer, "credential", credential); | 199 DictionaryHelper::get(iceServer, "credential", credential); |
186 | 200 |
187 for (Vector<String>::iterator iter = urlStrings.begin(); iter != urlStri ngs.end(); ++iter) { | 201 for (Vector<String>::iterator iter = urlStrings.begin(); iter != urlStri ngs.end(); ++iter) { |
188 KURL url(KURL(), *iter); | 202 KURL url(KURL(), *iter); |
189 if (!url.isValid() || !(url.protocolIs("turn") || url.protocolIs("tu rns") || url.protocolIs("stun"))) { | 203 if (!url.isValid() || !(url.protocolIs("turn") || url.protocolIs("tu rns") || url.protocolIs("stun"))) { |
190 exceptionState.throwTypeError("Malformed URL"); | 204 exceptionState.throwTypeError("Malformed URL"); |
191 return 0; | 205 return 0; |
192 } | 206 } |
193 | 207 |
194 rtcConfiguration->appendServer(RTCIceServer::create(url, username, c redential)); | 208 rtcConfiguration->iceServers()->appendServer(RTCIceServer::create(ur l, username, credential)); |
195 } | 209 } |
196 } | 210 } |
197 | 211 |
198 return rtcConfiguration; | 212 return rtcConfiguration; |
199 } | 213 } |
200 | 214 |
201 RTCOfferOptions* RTCPeerConnection::parseOfferOptions(const Dictionary& options, ExceptionState& exceptionState) | 215 RTCOfferOptions* RTCPeerConnection::parseOfferOptions(const Dictionary& options, ExceptionState& exceptionState) |
202 { | 216 { |
203 if (options.isUndefinedOrNull()) | 217 if (options.isUndefinedOrNull()) |
204 return 0; | 218 return 0; |
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
835 { | 849 { |
836 visitor->trace(m_localStreams); | 850 visitor->trace(m_localStreams); |
837 visitor->trace(m_remoteStreams); | 851 visitor->trace(m_remoteStreams); |
838 visitor->trace(m_dataChannels); | 852 visitor->trace(m_dataChannels); |
839 visitor->trace(m_scheduledEvents); | 853 visitor->trace(m_scheduledEvents); |
840 RefCountedGarbageCollectedEventTargetWithInlineData<RTCPeerConnection>::trac e(visitor); | 854 RefCountedGarbageCollectedEventTargetWithInlineData<RTCPeerConnection>::trac e(visitor); |
841 ActiveDOMObject::trace(visitor); | 855 ActiveDOMObject::trace(visitor); |
842 } | 856 } |
843 | 857 |
844 } // namespace blink | 858 } // namespace blink |
OLD | NEW |