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 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 SetSessionDescriptionMsg* msg = new SetSessionDescriptionMsg(observer); | 617 SetSessionDescriptionMsg* msg = new SetSessionDescriptionMsg(observer); |
618 signaling_thread()->Post(this, MSG_SET_SESSIONDESCRIPTION_SUCCESS, msg); | 618 signaling_thread()->Post(this, MSG_SET_SESSIONDESCRIPTION_SUCCESS, msg); |
| 619 // MaybeStartGathering needs to be called after posting |
| 620 // MSG_SET_SESSIONDESCRIPTION_SUCCESS, so that we don't signal any candidates |
| 621 // before signaling that SetLocalDescription completed. |
| 622 session_->MaybeStartGathering(); |
619 } | 623 } |
620 | 624 |
621 void PeerConnection::SetRemoteDescription( | 625 void PeerConnection::SetRemoteDescription( |
622 SetSessionDescriptionObserver* observer, | 626 SetSessionDescriptionObserver* observer, |
623 SessionDescriptionInterface* desc) { | 627 SessionDescriptionInterface* desc) { |
624 if (!VERIFY(observer != NULL)) { | 628 if (!VERIFY(observer != NULL)) { |
625 LOG(LS_ERROR) << "SetRemoteDescription - observer is NULL."; | 629 LOG(LS_ERROR) << "SetRemoteDescription - observer is NULL."; |
626 return; | 630 return; |
627 } | 631 } |
628 if (!desc) { | 632 if (!desc) { |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
861 stream_handler_container_->RemoveLocalTrack(stream, video_track); | 865 stream_handler_container_->RemoveLocalTrack(stream, video_track); |
862 } | 866 } |
863 | 867 |
864 void PeerConnection::OnRemoveLocalStream(MediaStreamInterface* stream) { | 868 void PeerConnection::OnRemoveLocalStream(MediaStreamInterface* stream) { |
865 stream_handler_container_->RemoveLocalStream(stream); | 869 stream_handler_container_->RemoveLocalStream(stream); |
866 } | 870 } |
867 | 871 |
868 void PeerConnection::OnIceConnectionChange( | 872 void PeerConnection::OnIceConnectionChange( |
869 PeerConnectionInterface::IceConnectionState new_state) { | 873 PeerConnectionInterface::IceConnectionState new_state) { |
870 ASSERT(signaling_thread()->IsCurrent()); | 874 ASSERT(signaling_thread()->IsCurrent()); |
| 875 // After transitioning to "closed", ignore any additional states from |
| 876 // WebRtcSession (such as "disconnected"). |
| 877 if (ice_connection_state_ == kIceConnectionClosed) { |
| 878 return; |
| 879 } |
871 ice_connection_state_ = new_state; | 880 ice_connection_state_ = new_state; |
872 observer_->OnIceConnectionChange(ice_connection_state_); | 881 observer_->OnIceConnectionChange(ice_connection_state_); |
873 } | 882 } |
874 | 883 |
875 void PeerConnection::OnIceGatheringChange( | 884 void PeerConnection::OnIceGatheringChange( |
876 PeerConnectionInterface::IceGatheringState new_state) { | 885 PeerConnectionInterface::IceGatheringState new_state) { |
877 ASSERT(signaling_thread()->IsCurrent()); | 886 ASSERT(signaling_thread()->IsCurrent()); |
878 if (IsClosed()) { | 887 if (IsClosed()) { |
879 return; | 888 return; |
880 } | 889 } |
(...skipping 25 matching lines...) Expand all Loading... |
906 if (ice_gathering_state_ != kIceGatheringComplete) { | 915 if (ice_gathering_state_ != kIceGatheringComplete) { |
907 ice_gathering_state_ = kIceGatheringComplete; | 916 ice_gathering_state_ = kIceGatheringComplete; |
908 observer_->OnIceGatheringChange(ice_gathering_state_); | 917 observer_->OnIceGatheringChange(ice_gathering_state_); |
909 } | 918 } |
910 } | 919 } |
911 observer_->OnSignalingChange(signaling_state_); | 920 observer_->OnSignalingChange(signaling_state_); |
912 observer_->OnStateChange(PeerConnectionObserver::kSignalingState); | 921 observer_->OnStateChange(PeerConnectionObserver::kSignalingState); |
913 } | 922 } |
914 | 923 |
915 } // namespace webrtc | 924 } // namespace webrtc |
OLD | NEW |