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 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 if (!HasChannel(cand->component())) { | 274 if (!HasChannel(cand->component())) { |
275 *error = "Candidate has unknown component: " + cand->ToString() + | 275 *error = "Candidate has unknown component: " + cand->ToString() + |
276 " for content: " + content_name_; | 276 " for content: " + content_name_; |
277 return false; | 277 return false; |
278 } | 278 } |
279 } | 279 } |
280 transport_->get()->OnRemoteCandidates(candidates); | 280 transport_->get()->OnRemoteCandidates(candidates); |
281 return true; | 281 return true; |
282 } | 282 } |
283 | 283 |
284 void TransportProxy::SetIdentity( | 284 void TransportProxy::SetCertificate( |
285 rtc::SSLIdentity* identity) { | 285 const rtc::scoped_refptr<webrtc::DtlsCertificate>& certificate) { |
286 transport_->get()->SetIdentity(identity); | 286 transport_->get()->SetCertificate(certificate); |
287 } | 287 } |
288 | 288 |
289 std::string BaseSession::StateToString(State state) { | 289 std::string BaseSession::StateToString(State state) { |
290 switch (state) { | 290 switch (state) { |
291 case STATE_INIT: | 291 case STATE_INIT: |
292 return "STATE_INIT"; | 292 return "STATE_INIT"; |
293 case STATE_SENTINITIATE: | 293 case STATE_SENTINITIATE: |
294 return "STATE_SENTINITIATE"; | 294 return "STATE_SENTINITIATE"; |
295 case STATE_RECEIVEDINITIATE: | 295 case STATE_RECEIVEDINITIATE: |
296 return "STATE_RECEIVEDINITIATE"; | 296 return "STATE_RECEIVEDINITIATE"; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 bool initiator) | 334 bool initiator) |
335 : state_(STATE_INIT), | 335 : state_(STATE_INIT), |
336 error_(ERROR_NONE), | 336 error_(ERROR_NONE), |
337 signaling_thread_(signaling_thread), | 337 signaling_thread_(signaling_thread), |
338 worker_thread_(worker_thread), | 338 worker_thread_(worker_thread), |
339 port_allocator_(port_allocator), | 339 port_allocator_(port_allocator), |
340 sid_(sid), | 340 sid_(sid), |
341 content_type_(content_type), | 341 content_type_(content_type), |
342 transport_type_(NS_GINGLE_P2P), | 342 transport_type_(NS_GINGLE_P2P), |
343 initiator_(initiator), | 343 initiator_(initiator), |
344 identity_(NULL), | |
345 ssl_max_version_(rtc::SSL_PROTOCOL_DTLS_10), | 344 ssl_max_version_(rtc::SSL_PROTOCOL_DTLS_10), |
346 ice_tiebreaker_(rtc::CreateRandomId64()), | 345 ice_tiebreaker_(rtc::CreateRandomId64()), |
347 role_switch_(false), | 346 role_switch_(false), |
348 ice_receiving_timeout_(-1) { | 347 ice_receiving_timeout_(-1) { |
349 ASSERT(signaling_thread->IsCurrent()); | 348 ASSERT(signaling_thread->IsCurrent()); |
350 } | 349 } |
351 | 350 |
352 BaseSession::~BaseSession() { | 351 BaseSession::~BaseSession() { |
353 ASSERT(signaling_thread()->IsCurrent()); | 352 ASSERT(signaling_thread()->IsCurrent()); |
354 | 353 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 // TODO(tommi): Assert on thread correctness. | 387 // TODO(tommi): Assert on thread correctness. |
389 if (sdesc != remote_description_) | 388 if (sdesc != remote_description_) |
390 remote_description_.reset(sdesc); | 389 remote_description_.reset(sdesc); |
391 } | 390 } |
392 | 391 |
393 const SessionDescription* BaseSession::initiator_description() const { | 392 const SessionDescription* BaseSession::initiator_description() const { |
394 // TODO(tommi): Assert on thread correctness. | 393 // TODO(tommi): Assert on thread correctness. |
395 return initiator_ ? local_description_.get() : remote_description_.get(); | 394 return initiator_ ? local_description_.get() : remote_description_.get(); |
396 } | 395 } |
397 | 396 |
398 bool BaseSession::SetIdentity(rtc::SSLIdentity* identity) { | 397 bool BaseSession::SetCertificate( |
399 if (identity_) | 398 const rtc::scoped_refptr<webrtc::DtlsCertificate>& certificate) { |
| 399 if (certificate_) |
400 return false; | 400 return false; |
401 identity_ = identity; | 401 certificate_ = certificate; |
402 for (TransportMap::iterator iter = transports_.begin(); | 402 for (TransportMap::iterator iter = transports_.begin(); |
403 iter != transports_.end(); ++iter) { | 403 iter != transports_.end(); ++iter) { |
404 iter->second->SetIdentity(identity_); | 404 iter->second->SetCertificate(certificate_); |
405 } | 405 } |
406 return true; | 406 return true; |
407 } | 407 } |
408 | 408 |
409 bool BaseSession::SetSslMaxProtocolVersion(rtc::SSLProtocolVersion version) { | 409 bool BaseSession::SetSslMaxProtocolVersion(rtc::SSLProtocolVersion version) { |
410 if (state_ != STATE_INIT) { | 410 if (state_ != STATE_INIT) { |
411 return false; | 411 return false; |
412 } | 412 } |
413 | 413 |
414 ssl_max_version_ = version; | 414 ssl_max_version_ = version; |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
541 this, &BaseSession::OnRoleConflict); | 541 this, &BaseSession::OnRoleConflict); |
542 transport->SignalCompleted.connect( | 542 transport->SignalCompleted.connect( |
543 this, &BaseSession::OnTransportCompleted); | 543 this, &BaseSession::OnTransportCompleted); |
544 transport->SignalFailed.connect( | 544 transport->SignalFailed.connect( |
545 this, &BaseSession::OnTransportFailed); | 545 this, &BaseSession::OnTransportFailed); |
546 | 546 |
547 transproxy = new TransportProxy(worker_thread_, sid_, content_name, | 547 transproxy = new TransportProxy(worker_thread_, sid_, content_name, |
548 new TransportWrapper(transport)); | 548 new TransportWrapper(transport)); |
549 transproxy->SignalCandidatesReady.connect( | 549 transproxy->SignalCandidatesReady.connect( |
550 this, &BaseSession::OnTransportProxyCandidatesReady); | 550 this, &BaseSession::OnTransportProxyCandidatesReady); |
551 if (identity_) | 551 if (certificate_) |
552 transproxy->SetIdentity(identity_); | 552 transproxy->SetCertificate(certificate_); |
553 transports_[content_name] = transproxy; | 553 transports_[content_name] = transproxy; |
554 | 554 |
555 return transproxy; | 555 return transproxy; |
556 } | 556 } |
557 | 557 |
558 Transport* BaseSession::GetTransport(const std::string& content_name) { | 558 Transport* BaseSession::GetTransport(const std::string& content_name) { |
559 TransportProxy* transproxy = GetTransportProxy(content_name); | 559 TransportProxy* transproxy = GetTransportProxy(content_name); |
560 if (transproxy == NULL) | 560 if (transproxy == NULL) |
561 return NULL; | 561 return NULL; |
562 return transproxy->impl(); | 562 return transproxy->impl(); |
(...skipping 11 matching lines...) Expand all Loading... |
574 if (iter != transports_.end()) { | 574 if (iter != transports_.end()) { |
575 delete iter->second; | 575 delete iter->second; |
576 transports_.erase(content_name); | 576 transports_.erase(content_name); |
577 } | 577 } |
578 } | 578 } |
579 | 579 |
580 Transport* BaseSession::CreateTransport(const std::string& content_name) { | 580 Transport* BaseSession::CreateTransport(const std::string& content_name) { |
581 ASSERT(transport_type_ == NS_GINGLE_P2P); | 581 ASSERT(transport_type_ == NS_GINGLE_P2P); |
582 Transport* transport = new DtlsTransport<P2PTransport>( | 582 Transport* transport = new DtlsTransport<P2PTransport>( |
583 signaling_thread(), worker_thread(), content_name, port_allocator(), | 583 signaling_thread(), worker_thread(), content_name, port_allocator(), |
584 identity_); | 584 certificate_); |
585 transport->SetChannelReceivingTimeout(ice_receiving_timeout_); | 585 transport->SetChannelReceivingTimeout(ice_receiving_timeout_); |
586 return transport; | 586 return transport; |
587 } | 587 } |
588 | 588 |
589 void BaseSession::SetState(State state) { | 589 void BaseSession::SetState(State state) { |
590 ASSERT(signaling_thread_->IsCurrent()); | 590 ASSERT(signaling_thread_->IsCurrent()); |
591 if (state != state_) { | 591 if (state != state_) { |
592 LogState(state_, state); | 592 LogState(state_, state); |
593 state_ = state; | 593 state_ = state; |
594 SignalState(this, state_); | 594 SignalState(this, state_); |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
814 | 814 |
815 default: | 815 default: |
816 // Explicitly ignoring some states here. | 816 // Explicitly ignoring some states here. |
817 break; | 817 break; |
818 } | 818 } |
819 break; | 819 break; |
820 } | 820 } |
821 } | 821 } |
822 | 822 |
823 } // namespace cricket | 823 } // namespace cricket |
OLD | NEW |