OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 bool Get() const { | 425 bool Get() const { |
426 return ice_restart_; | 426 return ice_restart_; |
427 } | 427 } |
428 | 428 |
429 void Reset() { | 429 void Reset() { |
430 if (ice_restart_) { | 430 if (ice_restart_) { |
431 ice_restart_ = false; | 431 ice_restart_ = false; |
432 } | 432 } |
433 } | 433 } |
434 | 434 |
435 void CheckForRemoteIceRestart( | 435 bool CheckForRemoteIceRestart(const SessionDescriptionInterface* old_desc, |
436 const SessionDescriptionInterface* old_desc, | 436 const SessionDescriptionInterface* new_desc) { |
437 const SessionDescriptionInterface* new_desc) { | |
438 if (!old_desc || new_desc->type() != SessionDescriptionInterface::kOffer) { | 437 if (!old_desc || new_desc->type() != SessionDescriptionInterface::kOffer) { |
439 return; | 438 return false; |
440 } | 439 } |
441 const SessionDescription* new_sd = new_desc->description(); | 440 const SessionDescription* new_sd = new_desc->description(); |
442 const SessionDescription* old_sd = old_desc->description(); | 441 const SessionDescription* old_sd = old_desc->description(); |
443 const ContentInfos& contents = new_sd->contents(); | 442 const ContentInfos& contents = new_sd->contents(); |
444 for (size_t index = 0; index < contents.size(); ++index) { | 443 for (size_t index = 0; index < contents.size(); ++index) { |
445 const ContentInfo* cinfo = &contents[index]; | 444 const ContentInfo* cinfo = &contents[index]; |
446 if (cinfo->rejected) { | 445 if (cinfo->rejected) { |
447 continue; | 446 continue; |
448 } | 447 } |
449 // If the content isn't rejected, check if ufrag and password has | 448 // If the content isn't rejected, check if ufrag and password has |
450 // changed. | 449 // changed. |
451 const cricket::TransportDescription* new_transport_desc = | 450 const cricket::TransportDescription* new_transport_desc = |
452 new_sd->GetTransportDescriptionByName(cinfo->name); | 451 new_sd->GetTransportDescriptionByName(cinfo->name); |
453 const cricket::TransportDescription* old_transport_desc = | 452 const cricket::TransportDescription* old_transport_desc = |
454 old_sd->GetTransportDescriptionByName(cinfo->name); | 453 old_sd->GetTransportDescriptionByName(cinfo->name); |
455 if (!new_transport_desc || !old_transport_desc) { | 454 if (!new_transport_desc || !old_transport_desc) { |
456 // No transport description exist. This is not an ice restart. | 455 // No transport description exist. This is not an ice restart. |
457 continue; | 456 continue; |
458 } | 457 } |
459 if (cricket::IceCredentialsChanged(old_transport_desc->ice_ufrag, | 458 if (cricket::IceCredentialsChanged(old_transport_desc->ice_ufrag, |
460 old_transport_desc->ice_pwd, | 459 old_transport_desc->ice_pwd, |
461 new_transport_desc->ice_ufrag, | 460 new_transport_desc->ice_ufrag, |
462 new_transport_desc->ice_pwd)) { | 461 new_transport_desc->ice_pwd)) { |
463 LOG(LS_INFO) << "Remote peer request ice restart."; | 462 LOG(LS_INFO) << "Remote peer request ice restart."; |
464 ice_restart_ = true; | 463 ice_restart_ = true; |
465 break; | 464 return true; |
466 } | 465 } |
467 } | 466 } |
| 467 return false; |
468 } | 468 } |
469 | 469 |
470 private: | 470 private: |
471 bool ice_restart_; | 471 bool ice_restart_; |
472 }; | 472 }; |
473 | 473 |
474 WebRtcSession::WebRtcSession( | 474 WebRtcSession::WebRtcSession( |
475 cricket::ChannelManager* channel_manager, | 475 cricket::ChannelManager* channel_manager, |
476 rtc::Thread* signaling_thread, | 476 rtc::Thread* signaling_thread, |
477 rtc::Thread* worker_thread, | 477 rtc::Thread* worker_thread, |
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
831 } | 831 } |
832 | 832 |
833 // Update remote MediaStreams. | 833 // Update remote MediaStreams. |
834 mediastream_signaling_->OnRemoteDescriptionChanged(desc); | 834 mediastream_signaling_->OnRemoteDescriptionChanged(desc); |
835 if (local_description() && !UseCandidatesInSessionDescription(desc)) { | 835 if (local_description() && !UseCandidatesInSessionDescription(desc)) { |
836 return BadRemoteSdp(desc->type(), kInvalidCandidates, err_desc); | 836 return BadRemoteSdp(desc->type(), kInvalidCandidates, err_desc); |
837 } | 837 } |
838 | 838 |
839 // Copy all saved candidates. | 839 // Copy all saved candidates. |
840 CopySavedCandidates(desc); | 840 CopySavedCandidates(desc); |
841 // We retain all received candidates. | 841 |
842 WebRtcSessionDescriptionFactory::CopyCandidatesFromSessionDescription( | |
843 remote_desc_.get(), desc); | |
844 // Check if this new SessionDescription contains new ice ufrag and password | 842 // Check if this new SessionDescription contains new ice ufrag and password |
845 // that indicates the remote peer requests ice restart. | 843 // that indicates the remote peer requests ice restart. |
846 ice_restart_latch_->CheckForRemoteIceRestart(remote_desc_.get(), | 844 bool ice_restart = |
847 desc); | 845 ice_restart_latch_->CheckForRemoteIceRestart(remote_desc_.get(), desc); |
| 846 // We retain all received candidates only if ICE is not restarted. |
| 847 // When ICE is restarted, all previous candidates belong to an old generation |
| 848 // and should not be kept. |
| 849 if (!ice_restart) { |
| 850 WebRtcSessionDescriptionFactory::CopyCandidatesFromSessionDescription( |
| 851 remote_desc_.get(), desc); |
| 852 } |
| 853 |
848 remote_desc_.reset(desc_temp.release()); | 854 remote_desc_.reset(desc_temp.release()); |
849 | 855 |
850 rtc::SSLRole role; | 856 rtc::SSLRole role; |
851 if (data_channel_type_ == cricket::DCT_SCTP && GetSslRole(&role)) { | 857 if (data_channel_type_ == cricket::DCT_SCTP && GetSslRole(&role)) { |
852 mediastream_signaling_->OnDtlsRoleReadyForSctp(role); | 858 mediastream_signaling_->OnDtlsRoleReadyForSctp(role); |
853 } | 859 } |
854 | 860 |
855 if (error() != cricket::BaseSession::ERROR_NONE) { | 861 if (error() != cricket::BaseSession::ERROR_NONE) { |
856 return BadRemoteSdp(desc->type(), GetSessionErrorMsg(), err_desc); | 862 return BadRemoteSdp(desc->type(), GetSessionErrorMsg(), err_desc); |
857 } | 863 } |
(...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1515 if (!ReadyToUseRemoteCandidate(candidate, remote_desc, &valid)) { | 1521 if (!ReadyToUseRemoteCandidate(candidate, remote_desc, &valid)) { |
1516 if (valid) { | 1522 if (valid) { |
1517 LOG(LS_INFO) << "UseCandidatesInSessionDescription: Candidate saved."; | 1523 LOG(LS_INFO) << "UseCandidatesInSessionDescription: Candidate saved."; |
1518 saved_candidates_.push_back( | 1524 saved_candidates_.push_back( |
1519 new JsepIceCandidate(candidate->sdp_mid(), | 1525 new JsepIceCandidate(candidate->sdp_mid(), |
1520 candidate->sdp_mline_index(), | 1526 candidate->sdp_mline_index(), |
1521 candidate->candidate())); | 1527 candidate->candidate())); |
1522 } | 1528 } |
1523 continue; | 1529 continue; |
1524 } | 1530 } |
1525 | |
1526 ret = UseCandidate(candidate); | 1531 ret = UseCandidate(candidate); |
1527 if (!ret) | 1532 if (!ret) |
1528 break; | 1533 break; |
1529 } | 1534 } |
1530 } | 1535 } |
1531 return ret; | 1536 return ret; |
1532 } | 1537 } |
1533 | 1538 |
1534 bool WebRtcSession::UseCandidate( | 1539 bool WebRtcSession::UseCandidate( |
1535 const IceCandidateInterface* candidate) { | 1540 const IceCandidateInterface* candidate) { |
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1960 | 1965 |
1961 if (!srtp_cipher.empty()) { | 1966 if (!srtp_cipher.empty()) { |
1962 metrics_observer_->AddHistogramSample(srtp_name, srtp_cipher); | 1967 metrics_observer_->AddHistogramSample(srtp_name, srtp_cipher); |
1963 } | 1968 } |
1964 if (!ssl_cipher.empty()) { | 1969 if (!ssl_cipher.empty()) { |
1965 metrics_observer_->AddHistogramSample(ssl_name, ssl_cipher); | 1970 metrics_observer_->AddHistogramSample(ssl_name, ssl_cipher); |
1966 } | 1971 } |
1967 } | 1972 } |
1968 | 1973 |
1969 } // namespace webrtc | 1974 } // namespace webrtc |
OLD | NEW |