Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(277)

Unified Diff: webrtc/pc/peerconnection.cc

Issue 2990683002: Add PeerConnectionObserver::OnRemoveTrack callback.
Patch Set: Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/pc/peerconnection.h ('k') | webrtc/pc/peerconnectioninterface_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) {
« no previous file with comments | « webrtc/pc/peerconnection.h ('k') | webrtc/pc/peerconnectioninterface_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698