Index: webrtc/pc/peerconnection.cc |
diff --git a/webrtc/pc/peerconnection.cc b/webrtc/pc/peerconnection.cc |
index f006b23cbda5197d9646f9e233ab15176f99b3af..240ef92e77530d0a86c3a6cf8883dcf09dcda001 100644 |
--- a/webrtc/pc/peerconnection.cc |
+++ b/webrtc/pc/peerconnection.cc |
@@ -1486,14 +1486,21 @@ void PeerConnection::CreateVideoReceiver(MediaStreamInterface* stream, |
// TODO(deadbeef): Keep RtpReceivers around even if track goes away in remote |
// description. |
-void PeerConnection::DestroyReceiver(const std::string& track_id) { |
+void PeerConnection::DestroyReceiver(MediaStreamInterface* stream, |
+ const std::string& track_id) { |
auto it = FindReceiverForTrack(track_id); |
if (it == receivers_.end()) { |
LOG(LS_WARNING) << "RtpReceiver for track with id " << track_id |
<< " doesn't exist."; |
} else { |
+ rtc::scoped_refptr<RtpReceiverInterface> receiver(*it); |
+ std::vector<rtc::scoped_refptr<MediaStreamInterface>> streams; |
+ streams.push_back(rtc::scoped_refptr<MediaStreamInterface>(stream)); |
+ |
(*it)->internal()->Stop(); |
receivers_.erase(it); |
+ |
+ observer_->OnRemoveTrack(receiver, streams); |
} |
} |
@@ -1917,7 +1924,7 @@ void PeerConnection::OnRemoteTrackRemoved(const std::string& stream_label, |
if (media_type == cricket::MEDIA_TYPE_AUDIO) { |
// When the MediaEngine audio channel is destroyed, the RemoteAudioSource |
// will be notified which will end the AudioRtpReceiver::track(). |
- DestroyReceiver(track_id); |
+ DestroyReceiver(stream, track_id); |
rtc::scoped_refptr<AudioTrackInterface> audio_track = |
stream->FindAudioTrack(track_id); |
if (audio_track) { |
@@ -1926,7 +1933,7 @@ void PeerConnection::OnRemoteTrackRemoved(const std::string& stream_label, |
} else if (media_type == cricket::MEDIA_TYPE_VIDEO) { |
// Stopping or destroying a VideoRtpReceiver will end the |
// VideoRtpReceiver::track(). |
- DestroyReceiver(track_id); |
+ DestroyReceiver(stream, track_id); |
rtc::scoped_refptr<VideoTrackInterface> video_track = |
stream->FindVideoTrack(track_id); |
if (video_track) { |