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 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 if (!HasChannel(cand->component())) { | 270 if (!HasChannel(cand->component())) { |
271 *error = "Candidate has unknown component: " + cand->ToString() + | 271 *error = "Candidate has unknown component: " + cand->ToString() + |
272 " for content: " + content_name_; | 272 " for content: " + content_name_; |
273 return false; | 273 return false; |
274 } | 274 } |
275 } | 275 } |
276 transport_->get()->OnRemoteCandidates(candidates); | 276 transport_->get()->OnRemoteCandidates(candidates); |
277 return true; | 277 return true; |
278 } | 278 } |
279 | 279 |
280 void TransportProxy::SetIdentity( | 280 void TransportProxy::SetCertificate( |
281 rtc::SSLIdentity* identity) { | 281 const rtc::scoped_refptr<rtc::RTCCertificate>& certificate) { |
282 transport_->get()->SetIdentity(identity); | 282 transport_->get()->SetCertificate(certificate); |
283 } | 283 } |
284 | 284 |
285 std::string BaseSession::StateToString(State state) { | 285 std::string BaseSession::StateToString(State state) { |
286 switch (state) { | 286 switch (state) { |
287 case STATE_INIT: | 287 case STATE_INIT: |
288 return "STATE_INIT"; | 288 return "STATE_INIT"; |
289 case STATE_SENTINITIATE: | 289 case STATE_SENTINITIATE: |
290 return "STATE_SENTINITIATE"; | 290 return "STATE_SENTINITIATE"; |
291 case STATE_RECEIVEDINITIATE: | 291 case STATE_RECEIVEDINITIATE: |
292 return "STATE_RECEIVEDINITIATE"; | 292 return "STATE_RECEIVEDINITIATE"; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 const std::string& content_type, | 329 const std::string& content_type, |
330 bool initiator) | 330 bool initiator) |
331 : state_(STATE_INIT), | 331 : state_(STATE_INIT), |
332 error_(ERROR_NONE), | 332 error_(ERROR_NONE), |
333 signaling_thread_(signaling_thread), | 333 signaling_thread_(signaling_thread), |
334 worker_thread_(worker_thread), | 334 worker_thread_(worker_thread), |
335 port_allocator_(port_allocator), | 335 port_allocator_(port_allocator), |
336 sid_(sid), | 336 sid_(sid), |
337 content_type_(content_type), | 337 content_type_(content_type), |
338 initiator_(initiator), | 338 initiator_(initiator), |
339 identity_(NULL), | |
340 ssl_max_version_(rtc::SSL_PROTOCOL_DTLS_10), | 339 ssl_max_version_(rtc::SSL_PROTOCOL_DTLS_10), |
341 ice_tiebreaker_(rtc::CreateRandomId64()), | 340 ice_tiebreaker_(rtc::CreateRandomId64()), |
342 role_switch_(false), | 341 role_switch_(false), |
343 ice_receiving_timeout_(-1) { | 342 ice_receiving_timeout_(-1) { |
344 ASSERT(signaling_thread->IsCurrent()); | 343 ASSERT(signaling_thread->IsCurrent()); |
345 } | 344 } |
346 | 345 |
347 BaseSession::~BaseSession() { | 346 BaseSession::~BaseSession() { |
348 ASSERT(signaling_thread()->IsCurrent()); | 347 ASSERT(signaling_thread()->IsCurrent()); |
349 | 348 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 // TODO(tommi): Assert on thread correctness. | 382 // TODO(tommi): Assert on thread correctness. |
384 if (sdesc != remote_description_) | 383 if (sdesc != remote_description_) |
385 remote_description_.reset(sdesc); | 384 remote_description_.reset(sdesc); |
386 } | 385 } |
387 | 386 |
388 const SessionDescription* BaseSession::initiator_description() const { | 387 const SessionDescription* BaseSession::initiator_description() const { |
389 // TODO(tommi): Assert on thread correctness. | 388 // TODO(tommi): Assert on thread correctness. |
390 return initiator_ ? local_description_.get() : remote_description_.get(); | 389 return initiator_ ? local_description_.get() : remote_description_.get(); |
391 } | 390 } |
392 | 391 |
393 bool BaseSession::SetIdentity(rtc::SSLIdentity* identity) { | 392 bool BaseSession::SetCertificate( |
394 if (identity_) | 393 const rtc::scoped_refptr<rtc::RTCCertificate>& certificate) { |
| 394 if (certificate_) |
395 return false; | 395 return false; |
396 identity_ = identity; | 396 if (!certificate) |
| 397 return false; |
| 398 certificate_ = certificate; |
397 for (TransportMap::iterator iter = transports_.begin(); | 399 for (TransportMap::iterator iter = transports_.begin(); |
398 iter != transports_.end(); ++iter) { | 400 iter != transports_.end(); ++iter) { |
399 iter->second->SetIdentity(identity_); | 401 iter->second->SetCertificate(certificate_); |
400 } | 402 } |
401 return true; | 403 return true; |
402 } | 404 } |
403 | 405 |
404 bool BaseSession::SetSslMaxProtocolVersion(rtc::SSLProtocolVersion version) { | 406 bool BaseSession::SetSslMaxProtocolVersion(rtc::SSLProtocolVersion version) { |
405 if (state_ != STATE_INIT) { | 407 if (state_ != STATE_INIT) { |
406 return false; | 408 return false; |
407 } | 409 } |
408 | 410 |
409 ssl_max_version_ = version; | 411 ssl_max_version_ = version; |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
536 this, &BaseSession::OnRoleConflict); | 538 this, &BaseSession::OnRoleConflict); |
537 transport->SignalCompleted.connect( | 539 transport->SignalCompleted.connect( |
538 this, &BaseSession::OnTransportCompleted); | 540 this, &BaseSession::OnTransportCompleted); |
539 transport->SignalFailed.connect( | 541 transport->SignalFailed.connect( |
540 this, &BaseSession::OnTransportFailed); | 542 this, &BaseSession::OnTransportFailed); |
541 | 543 |
542 transproxy = new TransportProxy(worker_thread_, sid_, content_name, | 544 transproxy = new TransportProxy(worker_thread_, sid_, content_name, |
543 new TransportWrapper(transport)); | 545 new TransportWrapper(transport)); |
544 transproxy->SignalCandidatesReady.connect( | 546 transproxy->SignalCandidatesReady.connect( |
545 this, &BaseSession::OnTransportProxyCandidatesReady); | 547 this, &BaseSession::OnTransportProxyCandidatesReady); |
546 if (identity_) | 548 if (certificate_) |
547 transproxy->SetIdentity(identity_); | 549 transproxy->SetCertificate(certificate_); |
548 transports_[content_name] = transproxy; | 550 transports_[content_name] = transproxy; |
549 | 551 |
550 return transproxy; | 552 return transproxy; |
551 } | 553 } |
552 | 554 |
553 Transport* BaseSession::GetTransport(const std::string& content_name) { | 555 Transport* BaseSession::GetTransport(const std::string& content_name) { |
554 TransportProxy* transproxy = GetTransportProxy(content_name); | 556 TransportProxy* transproxy = GetTransportProxy(content_name); |
555 if (transproxy == NULL) | 557 if (transproxy == NULL) |
556 return NULL; | 558 return NULL; |
557 return transproxy->impl(); | 559 return transproxy->impl(); |
(...skipping 10 matching lines...) Expand all Loading... |
568 TransportMap::iterator iter = transports_.find(content_name); | 570 TransportMap::iterator iter = transports_.find(content_name); |
569 if (iter != transports_.end()) { | 571 if (iter != transports_.end()) { |
570 delete iter->second; | 572 delete iter->second; |
571 transports_.erase(content_name); | 573 transports_.erase(content_name); |
572 } | 574 } |
573 } | 575 } |
574 | 576 |
575 Transport* BaseSession::CreateTransport(const std::string& content_name) { | 577 Transport* BaseSession::CreateTransport(const std::string& content_name) { |
576 Transport* transport = new DtlsTransport<P2PTransport>( | 578 Transport* transport = new DtlsTransport<P2PTransport>( |
577 signaling_thread(), worker_thread(), content_name, port_allocator(), | 579 signaling_thread(), worker_thread(), content_name, port_allocator(), |
578 identity_); | 580 certificate_); |
579 transport->SetChannelReceivingTimeout(ice_receiving_timeout_); | 581 transport->SetChannelReceivingTimeout(ice_receiving_timeout_); |
580 return transport; | 582 return transport; |
581 } | 583 } |
582 | 584 |
583 void BaseSession::SetState(State state) { | 585 void BaseSession::SetState(State state) { |
584 ASSERT(signaling_thread_->IsCurrent()); | 586 ASSERT(signaling_thread_->IsCurrent()); |
585 if (state != state_) { | 587 if (state != state_) { |
586 LogState(state_, state); | 588 LogState(state_, state); |
587 state_ = state; | 589 state_ = state; |
588 SignalState(this, state_); | 590 SignalState(this, state_); |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
807 | 809 |
808 default: | 810 default: |
809 // Explicitly ignoring some states here. | 811 // Explicitly ignoring some states here. |
810 break; | 812 break; |
811 } | 813 } |
812 break; | 814 break; |
813 } | 815 } |
814 } | 816 } |
815 | 817 |
816 } // namespace cricket | 818 } // namespace cricket |
OLD | NEW |