Index: talk/app/webrtc/mediastreamsignaling.cc |
diff --git a/talk/app/webrtc/mediastreamsignaling.cc b/talk/app/webrtc/mediastreamsignaling.cc |
index 1f5f14fd7b55a3e6641349058f03ed1c38bfdb4a..d126ac5967c0e35d37a6391ca1ccea5eb5fd7aef 100644 |
--- a/talk/app/webrtc/mediastreamsignaling.cc |
+++ b/talk/app/webrtc/mediastreamsignaling.cc |
@@ -525,7 +525,13 @@ void MediaStreamSignaling::OnLocalDescriptionChanged( |
GetFirstAudioContent(desc->description()); |
if (audio_content) { |
if (audio_content->rejected) { |
- RejectRemoteTracks(cricket::MEDIA_TYPE_AUDIO); |
+ SetRemoteTracksState(cricket::MEDIA_TYPE_AUDIO, |
+ MediaStreamTrackInterface::kEnded); |
+ } else { |
+ // This is needed in case the local description caused the track to be |
+ // rejected, then later accepted, without being destroyed. |
+ SetRemoteTracksState(cricket::MEDIA_TYPE_AUDIO, |
+ MediaStreamTrackInterface::kLive); |
} |
const cricket::AudioContentDescription* audio_desc = |
static_cast<const cricket::AudioContentDescription*>( |
@@ -537,7 +543,13 @@ void MediaStreamSignaling::OnLocalDescriptionChanged( |
GetFirstVideoContent(desc->description()); |
if (video_content) { |
if (video_content->rejected) { |
- RejectRemoteTracks(cricket::MEDIA_TYPE_VIDEO); |
+ SetRemoteTracksState(cricket::MEDIA_TYPE_VIDEO, |
+ MediaStreamTrackInterface::kEnded); |
+ } else { |
+ // This is needed in case the local description caused the track to be |
+ // rejected, then later accepted, without being destroyed. |
+ SetRemoteTracksState(cricket::MEDIA_TYPE_VIDEO, |
+ MediaStreamTrackInterface::kLive); |
} |
const cricket::VideoContentDescription* video_desc = |
static_cast<const cricket::VideoContentDescription*>( |
@@ -559,11 +571,13 @@ void MediaStreamSignaling::OnLocalDescriptionChanged( |
} |
void MediaStreamSignaling::OnAudioChannelClose() { |
- RejectRemoteTracks(cricket::MEDIA_TYPE_AUDIO); |
+ SetRemoteTracksState(cricket::MEDIA_TYPE_AUDIO, |
+ MediaStreamTrackInterface::kEnded); |
} |
void MediaStreamSignaling::OnVideoChannelClose() { |
- RejectRemoteTracks(cricket::MEDIA_TYPE_VIDEO); |
+ SetRemoteTracksState(cricket::MEDIA_TYPE_VIDEO, |
+ MediaStreamTrackInterface::kEnded); |
} |
void MediaStreamSignaling::OnDataChannelClose() { |
@@ -678,7 +692,9 @@ void MediaStreamSignaling::OnRemoteTrackRemoved( |
} |
} |
-void MediaStreamSignaling::RejectRemoteTracks(cricket::MediaType media_type) { |
+void MediaStreamSignaling::SetRemoteTracksState( |
+ cricket::MediaType media_type, |
+ MediaStreamTrackInterface::TrackState state) { |
TrackInfos* current_tracks = GetRemoteTracks(media_type); |
for (TrackInfos::iterator track_it = current_tracks->begin(); |
track_it != current_tracks->end(); ++track_it) { |
@@ -689,7 +705,7 @@ void MediaStreamSignaling::RejectRemoteTracks(cricket::MediaType media_type) { |
// There's no guarantee the track is still available, e.g. the track may |
// have been removed from the stream by javascript. |
if (track) { |
- track->set_state(webrtc::MediaStreamTrackInterface::kEnded); |
+ track->set_state(state); |
} |
} |
if (media_type == cricket::MEDIA_TYPE_VIDEO) { |
@@ -697,7 +713,7 @@ void MediaStreamSignaling::RejectRemoteTracks(cricket::MediaType media_type) { |
// There's no guarantee the track is still available, e.g. the track may |
// have been removed from the stream by javascript. |
if (track) { |
- track->set_state(webrtc::MediaStreamTrackInterface::kEnded); |
+ track->set_state(state); |
} |
} |
} |