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 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
607 return; | 607 return; |
608 } | 608 } |
609 // Update stats here so that we have the most recent stats for tracks and | 609 // Update stats here so that we have the most recent stats for tracks and |
610 // streams that might be removed by updating the session description. | 610 // streams that might be removed by updating the session description. |
611 stats_->UpdateStats(kStatsOutputLevelStandard); | 611 stats_->UpdateStats(kStatsOutputLevelStandard); |
612 std::string error; | 612 std::string error; |
613 if (!session_->SetLocalDescription(desc, &error)) { | 613 if (!session_->SetLocalDescription(desc, &error)) { |
614 PostSetSessionDescriptionFailure(observer, error); | 614 PostSetSessionDescriptionFailure(observer, error); |
615 return; | 615 return; |
616 } | 616 } |
| 617 |
| 618 // This is necessary because an audio/video channel may have been previously |
| 619 // destroyed by removing it from the remote description, which would NOT |
| 620 // destroy the local handler. So upon receiving a new local description, |
| 621 // we may need to tell that local track handler to connect the capturer |
| 622 // to the now re-created audio/video channel. |
| 623 stream_handler_container_->RestartAllLocalTracks(); |
| 624 |
617 SetSessionDescriptionMsg* msg = new SetSessionDescriptionMsg(observer); | 625 SetSessionDescriptionMsg* msg = new SetSessionDescriptionMsg(observer); |
618 signaling_thread()->Post(this, MSG_SET_SESSIONDESCRIPTION_SUCCESS, msg); | 626 signaling_thread()->Post(this, MSG_SET_SESSIONDESCRIPTION_SUCCESS, msg); |
619 } | 627 } |
620 | 628 |
621 void PeerConnection::SetRemoteDescription( | 629 void PeerConnection::SetRemoteDescription( |
622 SetSessionDescriptionObserver* observer, | 630 SetSessionDescriptionObserver* observer, |
623 SessionDescriptionInterface* desc) { | 631 SessionDescriptionInterface* desc) { |
624 if (!VERIFY(observer != NULL)) { | 632 if (!VERIFY(observer != NULL)) { |
625 LOG(LS_ERROR) << "SetRemoteDescription - observer is NULL."; | 633 LOG(LS_ERROR) << "SetRemoteDescription - observer is NULL."; |
626 return; | 634 return; |
627 } | 635 } |
628 if (!desc) { | 636 if (!desc) { |
629 PostSetSessionDescriptionFailure(observer, "SessionDescription is NULL."); | 637 PostSetSessionDescriptionFailure(observer, "SessionDescription is NULL."); |
630 return; | 638 return; |
631 } | 639 } |
632 // Update stats here so that we have the most recent stats for tracks and | 640 // Update stats here so that we have the most recent stats for tracks and |
633 // streams that might be removed by updating the session description. | 641 // streams that might be removed by updating the session description. |
634 stats_->UpdateStats(kStatsOutputLevelStandard); | 642 stats_->UpdateStats(kStatsOutputLevelStandard); |
635 std::string error; | 643 std::string error; |
636 if (!session_->SetRemoteDescription(desc, &error)) { | 644 if (!session_->SetRemoteDescription(desc, &error)) { |
637 PostSetSessionDescriptionFailure(observer, error); | 645 PostSetSessionDescriptionFailure(observer, error); |
638 return; | 646 return; |
639 } | 647 } |
| 648 |
| 649 // This is necessary because an audio/video channel may have been previously |
| 650 // destroyed by removing it from the local description, which would NOT |
| 651 // destroy the remote handler. So upon receiving a new remote description, |
| 652 // we may need to tell that remote track handler to connect the renderer |
| 653 // to the now re-created audio/video channel. |
| 654 stream_handler_container_->RestartAllRemoteTracks(); |
| 655 |
640 SetSessionDescriptionMsg* msg = new SetSessionDescriptionMsg(observer); | 656 SetSessionDescriptionMsg* msg = new SetSessionDescriptionMsg(observer); |
641 signaling_thread()->Post(this, MSG_SET_SESSIONDESCRIPTION_SUCCESS, msg); | 657 signaling_thread()->Post(this, MSG_SET_SESSIONDESCRIPTION_SUCCESS, msg); |
642 } | 658 } |
643 | 659 |
644 void PeerConnection::PostSetSessionDescriptionFailure( | 660 void PeerConnection::PostSetSessionDescriptionFailure( |
645 SetSessionDescriptionObserver* observer, | 661 SetSessionDescriptionObserver* observer, |
646 const std::string& error) { | 662 const std::string& error) { |
647 SetSessionDescriptionMsg* msg = new SetSessionDescriptionMsg(observer); | 663 SetSessionDescriptionMsg* msg = new SetSessionDescriptionMsg(observer); |
648 msg->error = error; | 664 msg->error = error; |
649 signaling_thread()->Post(this, MSG_SET_SESSIONDESCRIPTION_FAILED, msg); | 665 signaling_thread()->Post(this, MSG_SET_SESSIONDESCRIPTION_FAILED, msg); |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
895 if (ice_gathering_state_ != kIceGatheringComplete) { | 911 if (ice_gathering_state_ != kIceGatheringComplete) { |
896 ice_gathering_state_ = kIceGatheringComplete; | 912 ice_gathering_state_ = kIceGatheringComplete; |
897 observer_->OnIceGatheringChange(ice_gathering_state_); | 913 observer_->OnIceGatheringChange(ice_gathering_state_); |
898 } | 914 } |
899 } | 915 } |
900 observer_->OnSignalingChange(signaling_state_); | 916 observer_->OnSignalingChange(signaling_state_); |
901 observer_->OnStateChange(PeerConnectionObserver::kSignalingState); | 917 observer_->OnStateChange(PeerConnectionObserver::kSignalingState); |
902 } | 918 } |
903 | 919 |
904 } // namespace webrtc | 920 } // namespace webrtc |
OLD | NEW |