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); |
tommi
2015/08/25 10:28:08
thread safe? (ok to touch transport_ on any thread
hbos
2015/08/25 15:45:44
The |transport_| object's SetCertificate posts to
| |
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_ || !certificate) | |
tommi
2015/08/25 10:28:08
I'm not sure I understand this check... is it not
hbos
2015/08/25 15:45:44
You could only set it to null if it was already nu
tommi
2015/08/25 16:34:53
point(less) taken
| |
395 return false; | 395 return false; |
396 identity_ = identity; | 396 certificate_ = certificate; |
397 for (TransportMap::iterator iter = transports_.begin(); | 397 for (TransportMap::iterator iter = transports_.begin(); |
398 iter != transports_.end(); ++iter) { | 398 iter != transports_.end(); ++iter) { |
399 iter->second->SetIdentity(identity_); | 399 iter->second->SetCertificate(certificate_); |
400 } | 400 } |
401 return true; | 401 return true; |
402 } | 402 } |
403 | 403 |
404 bool BaseSession::SetSslMaxProtocolVersion(rtc::SSLProtocolVersion version) { | 404 bool BaseSession::SetSslMaxProtocolVersion(rtc::SSLProtocolVersion version) { |
405 if (state_ != STATE_INIT) { | 405 if (state_ != STATE_INIT) { |
406 return false; | 406 return false; |
407 } | 407 } |
408 | 408 |
409 ssl_max_version_ = version; | 409 ssl_max_version_ = version; |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
536 this, &BaseSession::OnRoleConflict); | 536 this, &BaseSession::OnRoleConflict); |
537 transport->SignalCompleted.connect( | 537 transport->SignalCompleted.connect( |
538 this, &BaseSession::OnTransportCompleted); | 538 this, &BaseSession::OnTransportCompleted); |
539 transport->SignalFailed.connect( | 539 transport->SignalFailed.connect( |
540 this, &BaseSession::OnTransportFailed); | 540 this, &BaseSession::OnTransportFailed); |
541 | 541 |
542 transproxy = new TransportProxy(worker_thread_, sid_, content_name, | 542 transproxy = new TransportProxy(worker_thread_, sid_, content_name, |
543 new TransportWrapper(transport)); | 543 new TransportWrapper(transport)); |
544 transproxy->SignalCandidatesReady.connect( | 544 transproxy->SignalCandidatesReady.connect( |
545 this, &BaseSession::OnTransportProxyCandidatesReady); | 545 this, &BaseSession::OnTransportProxyCandidatesReady); |
546 if (identity_) | 546 if (certificate_) |
547 transproxy->SetIdentity(identity_); | 547 transproxy->SetCertificate(certificate_); |
548 transports_[content_name] = transproxy; | 548 transports_[content_name] = transproxy; |
549 | 549 |
550 return transproxy; | 550 return transproxy; |
551 } | 551 } |
552 | 552 |
553 Transport* BaseSession::GetTransport(const std::string& content_name) { | 553 Transport* BaseSession::GetTransport(const std::string& content_name) { |
554 TransportProxy* transproxy = GetTransportProxy(content_name); | 554 TransportProxy* transproxy = GetTransportProxy(content_name); |
555 if (transproxy == NULL) | 555 if (transproxy == NULL) |
556 return NULL; | 556 return NULL; |
557 return transproxy->impl(); | 557 return transproxy->impl(); |
(...skipping 10 matching lines...) Expand all Loading... | |
568 TransportMap::iterator iter = transports_.find(content_name); | 568 TransportMap::iterator iter = transports_.find(content_name); |
569 if (iter != transports_.end()) { | 569 if (iter != transports_.end()) { |
570 delete iter->second; | 570 delete iter->second; |
571 transports_.erase(content_name); | 571 transports_.erase(content_name); |
572 } | 572 } |
573 } | 573 } |
574 | 574 |
575 Transport* BaseSession::CreateTransport(const std::string& content_name) { | 575 Transport* BaseSession::CreateTransport(const std::string& content_name) { |
576 Transport* transport = new DtlsTransport<P2PTransport>( | 576 Transport* transport = new DtlsTransport<P2PTransport>( |
577 signaling_thread(), worker_thread(), content_name, port_allocator(), | 577 signaling_thread(), worker_thread(), content_name, port_allocator(), |
578 identity_); | 578 certificate_); |
579 transport->SetChannelReceivingTimeout(ice_receiving_timeout_); | 579 transport->SetChannelReceivingTimeout(ice_receiving_timeout_); |
580 return transport; | 580 return transport; |
581 } | 581 } |
582 | 582 |
583 void BaseSession::SetState(State state) { | 583 void BaseSession::SetState(State state) { |
584 ASSERT(signaling_thread_->IsCurrent()); | 584 ASSERT(signaling_thread_->IsCurrent()); |
585 if (state != state_) { | 585 if (state != state_) { |
586 LogState(state_, state); | 586 LogState(state_, state); |
587 state_ = state; | 587 state_ = state; |
588 SignalState(this, state_); | 588 SignalState(this, state_); |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
807 | 807 |
808 default: | 808 default: |
809 // Explicitly ignoring some states here. | 809 // Explicitly ignoring some states here. |
810 break; | 810 break; |
811 } | 811 } |
812 break; | 812 break; |
813 } | 813 } |
814 } | 814 } |
815 | 815 |
816 } // namespace cricket | 816 } // namespace cricket |
OLD | NEW |