Index: talk/app/webrtc/peerconnection.cc |
diff --git a/talk/app/webrtc/peerconnection.cc b/talk/app/webrtc/peerconnection.cc |
index caa892d00b9b04802c15908b04f97bd4ddf3cfb1..efdea66a0f5bc639abfe0f870da5e40b2668f7eb 100644 |
--- a/talk/app/webrtc/peerconnection.cc |
+++ b/talk/app/webrtc/peerconnection.cc |
@@ -1088,6 +1088,8 @@ void PeerConnection::SetRemoteDescription( |
const cricket::SessionDescription* remote_desc = desc->description(); |
+ remote_info_.msid_supported |= remote_desc->msid_supported(); |
+ |
// We wait to signal new streams until we finish processing the description, |
// since only at that point will new streams have all their tracks. |
rtc::scoped_refptr<StreamCollection> new_streams(StreamCollection::Create()); |
@@ -1098,6 +1100,7 @@ void PeerConnection::SetRemoteDescription( |
if (audio_content) { |
if (audio_content->rejected) { |
RemoveTracks(cricket::MEDIA_TYPE_AUDIO); |
+ remote_info_.default_audio_track_needed = false; |
} else { |
const cricket::AudioContentDescription* desc = |
static_cast<const cricket::AudioContentDescription*>( |
@@ -1116,6 +1119,7 @@ void PeerConnection::SetRemoteDescription( |
if (video_content) { |
if (video_content->rejected) { |
RemoveTracks(cricket::MEDIA_TYPE_VIDEO); |
+ remote_info_.default_video_track_needed = false; |
} else { |
const cricket::VideoContentDescription* desc = |
static_cast<const cricket::VideoContentDescription*>( |
@@ -1147,14 +1151,8 @@ void PeerConnection::SetRemoteDescription( |
observer_->OnAddStream(new_stream); |
} |
- // Find removed MediaStreams. |
- if (remote_info_.IsDefaultMediaStreamNeeded() && |
- remote_streams_->find(kDefaultStreamLabel) != nullptr) { |
- // The default media stream already exists. No need to do anything. |
- } else { |
- UpdateEndedRemoteMediaStreams(); |
- remote_info_.msid_supported |= remote_streams_->count() > 0; |
- } |
+ MaybeRemoveDefaultTracks(); |
+ UpdateEndedRemoteMediaStreams(); |
MaybeCreateDefaultStream(); |
SetSessionDescriptionMsg* msg = new SetSessionDescriptionMsg(observer); |
@@ -1503,14 +1501,14 @@ void PeerConnection::UpdateRemoteStreamsList( |
TrackInfos* current_tracks = GetRemoteTracks(media_type); |
// Find removed tracks. I.e., tracks where the track id or ssrc don't match |
- // the |
- // new StreamParam. |
+ // the new StreamParam. |
auto track_it = current_tracks->begin(); |
while (track_it != current_tracks->end()) { |
const TrackInfo& info = *track_it; |
const cricket::StreamParams* params = |
cricket::GetStreamBySsrc(streams, info.ssrc); |
- if (!params || params->id != info.track_id) { |
+ if (info.stream_label != kDefaultStreamLabel && |
pthatcher1
2015/12/02 22:05:53
Would it be cleaner to put this inside of UpdateRe
|
+ (!params || params->id != info.track_id)) { |
OnRemoteTrackRemoved(info.stream_label, info.track_id, media_type); |
track_it = current_tracks->erase(track_it); |
} else { |
@@ -1533,6 +1531,9 @@ void PeerConnection::UpdateRemoteStreamsList( |
stream = remote_stream_factory_->CreateMediaStream(stream_label); |
remote_streams_->AddStream(stream); |
new_streams->AddStream(stream); |
+ // Just in case the peer supports MSID, but doesn't indicate so with |
+ // "a=msid-semantic"... |
+ remote_info_.msid_supported = true; |
} |
const TrackInfo* track_info = |
@@ -1604,6 +1605,40 @@ void PeerConnection::UpdateEndedRemoteMediaStreams() { |
} |
} |
+void PeerConnection::MaybeRemoveDefaultTracks() { |
+ rtc::scoped_refptr<MediaStreamInterface> default_remote_stream = |
+ remote_streams_->find(kDefaultStreamLabel); |
+ if (!default_remote_stream) { |
+ return; |
+ } |
+ |
+ if ((!remote_info_.IsDefaultMediaStreamNeeded() || |
+ !remote_info_.default_audio_track_needed) && |
+ default_remote_stream->GetAudioTracks().size() > 0) { |
+ auto it = |
+ std::find(remote_audio_tracks_.begin(), remote_audio_tracks_.end(), |
+ TrackInfo(kDefaultStreamLabel, kDefaultAudioTrackLabel, 0)); |
+ if (it != remote_audio_tracks_.end()) { |
+ OnRemoteTrackRemoved(kDefaultStreamLabel, kDefaultAudioTrackLabel, |
+ cricket::MEDIA_TYPE_AUDIO); |
+ remote_audio_tracks_.erase(it); |
+ } |
+ } |
+ |
+ if ((!remote_info_.IsDefaultMediaStreamNeeded() || |
+ !remote_info_.default_video_track_needed) && |
+ default_remote_stream->GetVideoTracks().size() > 0) { |
+ auto it = |
+ std::find(remote_video_tracks_.begin(), remote_video_tracks_.end(), |
+ TrackInfo(kDefaultStreamLabel, kDefaultVideoTrackLabel, 0)); |
+ if (it != remote_video_tracks_.end()) { |
+ OnRemoteTrackRemoved(kDefaultStreamLabel, kDefaultVideoTrackLabel, |
+ cricket::MEDIA_TYPE_VIDEO); |
+ remote_video_tracks_.erase(it); |
+ } |
+ } |
+} |
+ |
void PeerConnection::MaybeCreateDefaultStream() { |
if (!remote_info_.IsDefaultMediaStreamNeeded()) { |
return; |