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 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
485 bool Get() const { | 485 bool Get() const { |
486 return ice_restart_; | 486 return ice_restart_; |
487 } | 487 } |
488 | 488 |
489 void Reset() { | 489 void Reset() { |
490 if (ice_restart_) { | 490 if (ice_restart_) { |
491 ice_restart_ = false; | 491 ice_restart_ = false; |
492 } | 492 } |
493 } | 493 } |
494 | 494 |
495 // This method has two purposes: 1. Return whether |new_desc| requests | |
496 // an ICE restart (i.e., new ufrag/pwd). 2. If it requests an ICE restart | |
497 // and it is an OFFER, remember this in |ice_restart_| so that the next | |
498 // Local Answer will be created with new ufrag and pwd. | |
495 bool CheckForRemoteIceRestart(const SessionDescriptionInterface* old_desc, | 499 bool CheckForRemoteIceRestart(const SessionDescriptionInterface* old_desc, |
496 const SessionDescriptionInterface* new_desc) { | 500 const SessionDescriptionInterface* new_desc) { |
497 if (!old_desc || new_desc->type() != SessionDescriptionInterface::kOffer) { | 501 if (!old_desc) { |
498 return false; | 502 return false; |
499 } | 503 } |
504 bool ice_restart = false; | |
500 const SessionDescription* new_sd = new_desc->description(); | 505 const SessionDescription* new_sd = new_desc->description(); |
501 const SessionDescription* old_sd = old_desc->description(); | 506 const SessionDescription* old_sd = old_desc->description(); |
502 const ContentInfos& contents = new_sd->contents(); | 507 const ContentInfos& contents = new_sd->contents(); |
503 for (size_t index = 0; index < contents.size(); ++index) { | 508 for (size_t index = 0; index < contents.size(); ++index) { |
504 const ContentInfo* cinfo = &contents[index]; | 509 const ContentInfo* cinfo = &contents[index]; |
505 if (cinfo->rejected) { | 510 if (cinfo->rejected) { |
506 continue; | 511 continue; |
507 } | 512 } |
508 // If the content isn't rejected, check if ufrag and password has | 513 // If the content isn't rejected, check if ufrag and password has |
509 // changed. | 514 // changed. |
510 const cricket::TransportDescription* new_transport_desc = | 515 const cricket::TransportDescription* new_transport_desc = |
511 new_sd->GetTransportDescriptionByName(cinfo->name); | 516 new_sd->GetTransportDescriptionByName(cinfo->name); |
512 const cricket::TransportDescription* old_transport_desc = | 517 const cricket::TransportDescription* old_transport_desc = |
513 old_sd->GetTransportDescriptionByName(cinfo->name); | 518 old_sd->GetTransportDescriptionByName(cinfo->name); |
514 if (!new_transport_desc || !old_transport_desc) { | 519 if (!new_transport_desc || !old_transport_desc) { |
515 // No transport description exist. This is not an ice restart. | 520 // No transport description exist. This is not an ice restart. |
516 continue; | 521 continue; |
517 } | 522 } |
518 if (cricket::IceCredentialsChanged(old_transport_desc->ice_ufrag, | 523 if (cricket::IceCredentialsChanged(old_transport_desc->ice_ufrag, |
519 old_transport_desc->ice_pwd, | 524 old_transport_desc->ice_pwd, |
520 new_transport_desc->ice_ufrag, | 525 new_transport_desc->ice_ufrag, |
521 new_transport_desc->ice_pwd)) { | 526 new_transport_desc->ice_pwd)) { |
522 LOG(LS_INFO) << "Remote peer request ice restart."; | 527 LOG(LS_INFO) << "Remote peer request ice restart."; |
523 ice_restart_ = true; | 528 ice_restart = true; |
524 return true; | 529 break; |
pthatcher1
2015/12/11 01:49:00
I think it would be more clear to put this here:
honghaiz3
2015/12/11 18:46:10
Done.
| |
525 } | 530 } |
526 } | 531 } |
527 return false; | 532 if (ice_restart && |
533 new_desc->type() == SessionDescriptionInterface::kOffer) { | |
534 ice_restart_ = true; | |
535 } | |
536 return ice_restart; | |
528 } | 537 } |
529 | 538 |
530 private: | 539 private: |
531 bool ice_restart_; | 540 bool ice_restart_; |
532 }; | 541 }; |
533 | 542 |
534 WebRtcSession::WebRtcSession(webrtc::MediaControllerInterface* media_controller, | 543 WebRtcSession::WebRtcSession(webrtc::MediaControllerInterface* media_controller, |
535 rtc::Thread* signaling_thread, | 544 rtc::Thread* signaling_thread, |
536 rtc::Thread* worker_thread, | 545 rtc::Thread* worker_thread, |
537 cricket::PortAllocator* port_allocator) | 546 cricket::PortAllocator* port_allocator) |
(...skipping 1650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2188 } | 2197 } |
2189 } | 2198 } |
2190 | 2199 |
2191 void WebRtcSession::OnSentPacket_w(cricket::TransportChannel* channel, | 2200 void WebRtcSession::OnSentPacket_w(cricket::TransportChannel* channel, |
2192 const rtc::SentPacket& sent_packet) { | 2201 const rtc::SentPacket& sent_packet) { |
2193 RTC_DCHECK(worker_thread()->IsCurrent()); | 2202 RTC_DCHECK(worker_thread()->IsCurrent()); |
2194 media_controller_->call_w()->OnSentPacket(sent_packet); | 2203 media_controller_->call_w()->OnSentPacket(sent_packet); |
2195 } | 2204 } |
2196 | 2205 |
2197 } // namespace webrtc | 2206 } // namespace webrtc |
OLD | NEW |