| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 const TransportDescription& description, | 169 const TransportDescription& description, |
| 170 ContentAction action, | 170 ContentAction action, |
| 171 std::string* error_desc) { | 171 std::string* error_desc) { |
| 172 bool ret = true; | 172 bool ret = true; |
| 173 | 173 |
| 174 if (!VerifyIceParams(description)) { | 174 if (!VerifyIceParams(description)) { |
| 175 return BadTransportDescription("Invalid ice-ufrag or ice-pwd length", | 175 return BadTransportDescription("Invalid ice-ufrag or ice-pwd length", |
| 176 error_desc); | 176 error_desc); |
| 177 } | 177 } |
| 178 | 178 |
| 179 bool ice_restarting = |
| 180 local_description_set_ && |
| 181 IceCredentialsChanged(local_description_->ice_ufrag, |
| 182 local_description_->ice_pwd, description.ice_ufrag, |
| 183 description.ice_pwd); |
| 179 local_description_.reset(new TransportDescription(description)); | 184 local_description_.reset(new TransportDescription(description)); |
| 180 | 185 |
| 181 rtc::SSLFingerprint* local_fp = | 186 rtc::SSLFingerprint* local_fp = |
| 182 local_description_->identity_fingerprint.get(); | 187 local_description_->identity_fingerprint.get(); |
| 183 | 188 |
| 184 if (!local_fp) { | 189 if (!local_fp) { |
| 185 certificate_ = nullptr; | 190 certificate_ = nullptr; |
| 186 } else if (!VerifyCertificateFingerprint(certificate_.get(), local_fp, | 191 } else if (!VerifyCertificateFingerprint(certificate_.get(), local_fp, |
| 187 error_desc)) { | 192 error_desc)) { |
| 188 return false; | 193 return false; |
| 189 } | 194 } |
| 190 | 195 |
| 191 for (const auto& kv : channels_) { | 196 for (const auto& kv : channels_) { |
| 192 ret &= ApplyLocalTransportDescription(kv.second, error_desc); | 197 ret &= ApplyLocalTransportDescription(kv.second, error_desc); |
| 193 } | 198 } |
| 194 if (!ret) { | 199 if (!ret) { |
| 195 return false; | 200 return false; |
| 196 } | 201 } |
| 197 | 202 |
| 198 // If PRANSWER/ANSWER is set, we should decide transport protocol type. | 203 // If PRANSWER/ANSWER is set, we should decide transport protocol type. |
| 199 if (action == CA_PRANSWER || action == CA_ANSWER) { | 204 if (action == CA_PRANSWER || action == CA_ANSWER) { |
| 200 ret &= NegotiateTransportDescription(action, error_desc); | 205 ret &= NegotiateTransportDescription(action, error_desc); |
| 201 } | 206 } |
| 202 if (ret) { | 207 if (!ret) { |
| 203 local_description_set_ = true; | 208 return false; |
| 204 } | 209 } |
| 205 | 210 |
| 206 return ret; | 211 if (needs_ice_restart_ && ice_restarting) { |
| 212 needs_ice_restart_ = false; |
| 213 LOG(LS_VERBOSE) << "needs-ice-restart flag cleared for transport " << mid(); |
| 214 } |
| 215 |
| 216 local_description_set_ = true; |
| 217 return true; |
| 207 } | 218 } |
| 208 | 219 |
| 209 bool JsepTransport::SetRemoteTransportDescription( | 220 bool JsepTransport::SetRemoteTransportDescription( |
| 210 const TransportDescription& description, | 221 const TransportDescription& description, |
| 211 ContentAction action, | 222 ContentAction action, |
| 212 std::string* error_desc) { | 223 std::string* error_desc) { |
| 213 bool ret = true; | 224 bool ret = true; |
| 214 | 225 |
| 215 if (!VerifyIceParams(description)) { | 226 if (!VerifyIceParams(description)) { |
| 216 return BadTransportDescription("Invalid ice-ufrag or ice-pwd length", | 227 return BadTransportDescription("Invalid ice-ufrag or ice-pwd length", |
| 217 error_desc); | 228 error_desc); |
| 218 } | 229 } |
| 219 | 230 |
| 220 remote_description_.reset(new TransportDescription(description)); | 231 remote_description_.reset(new TransportDescription(description)); |
| 221 for (const auto& kv : channels_) { | 232 for (const auto& kv : channels_) { |
| 222 ret &= ApplyRemoteTransportDescription(kv.second, error_desc); | 233 ret &= ApplyRemoteTransportDescription(kv.second, error_desc); |
| 223 } | 234 } |
| 224 | 235 |
| 225 // If PRANSWER/ANSWER is set, we should decide transport protocol type. | 236 // If PRANSWER/ANSWER is set, we should decide transport protocol type. |
| 226 if (action == CA_PRANSWER || action == CA_ANSWER) { | 237 if (action == CA_PRANSWER || action == CA_ANSWER) { |
| 227 ret = NegotiateTransportDescription(CA_OFFER, error_desc); | 238 ret = NegotiateTransportDescription(CA_OFFER, error_desc); |
| 228 } | 239 } |
| 229 if (ret) { | 240 if (ret) { |
| 230 remote_description_set_ = true; | 241 remote_description_set_ = true; |
| 231 } | 242 } |
| 232 | 243 |
| 233 return ret; | 244 return ret; |
| 234 } | 245 } |
| 235 | 246 |
| 247 void JsepTransport::SetNeedsIceRestartFlag() { |
| 248 if (!needs_ice_restart_) { |
| 249 needs_ice_restart_ = true; |
| 250 LOG(LS_VERBOSE) << "needs-ice-restart flag set for transport " << mid(); |
| 251 } |
| 252 } |
| 253 |
| 254 bool JsepTransport::NeedsIceRestart() const { |
| 255 return needs_ice_restart_; |
| 256 } |
| 257 |
| 236 void JsepTransport::GetSslRole(rtc::SSLRole* ssl_role) const { | 258 void JsepTransport::GetSslRole(rtc::SSLRole* ssl_role) const { |
| 237 RTC_DCHECK(ssl_role); | 259 RTC_DCHECK(ssl_role); |
| 238 *ssl_role = secure_role_; | 260 *ssl_role = secure_role_; |
| 239 } | 261 } |
| 240 | 262 |
| 241 bool JsepTransport::GetStats(TransportStats* stats) { | 263 bool JsepTransport::GetStats(TransportStats* stats) { |
| 242 stats->transport_name = mid(); | 264 stats->transport_name = mid(); |
| 243 stats->channel_stats.clear(); | 265 stats->channel_stats.clear(); |
| 244 for (auto& kv : channels_) { | 266 for (auto& kv : channels_) { |
| 245 TransportChannelImpl* channel = kv.second; | 267 TransportChannelImpl* channel = kv.second; |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 } | 452 } |
| 431 | 453 |
| 432 // If local is passive, local will act as server. | 454 // If local is passive, local will act as server. |
| 433 } | 455 } |
| 434 | 456 |
| 435 *ssl_role = is_remote_server ? rtc::SSL_CLIENT : rtc::SSL_SERVER; | 457 *ssl_role = is_remote_server ? rtc::SSL_CLIENT : rtc::SSL_SERVER; |
| 436 return true; | 458 return true; |
| 437 } | 459 } |
| 438 | 460 |
| 439 } // namespace cricket | 461 } // namespace cricket |
| OLD | NEW |