From c49bcd99117c04581b9b4f4fc3aef93aee804d42 Mon Sep 17 00:00:00 2001 From: Steve Anton Date: Wed, 14 Feb 2018 14:28:13 -0800 Subject: [PATCH] Fire OnAddStream with Unified Plan Bug: webrtc:7600 Change-Id: Ic4e5560fdeb9848c65c59e0f45ca3a2a4a22a2ad Reviewed-on: https://webrtc-review.googlesource.com/53401 Reviewed-by: Peter Thatcher Reviewed-by: Taylor Brandstetter Commit-Queue: Steve Anton Cr-Commit-Position: refs/heads/master@{#22042} --- api/peerconnectioninterface.h | 2 -- pc/peerconnection.cc | 6 ++++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/api/peerconnectioninterface.h b/api/peerconnectioninterface.h index 8b4db9abde..5786859094 100644 --- a/api/peerconnectioninterface.h +++ b/api/peerconnectioninterface.h @@ -1007,8 +1007,6 @@ class PeerConnectionObserver { PeerConnectionInterface::SignalingState new_state) = 0; // Triggered when media is received on a new stream from remote peer. - // Deprecated: This callback will no longer be fired with Unified Plan - // semantics. Consider switching to OnAddTrack. virtual void OnAddStream(rtc::scoped_refptr stream) {} // Triggered when a remote peer close a stream. diff --git a/pc/peerconnection.cc b/pc/peerconnection.cc index fe34578c94..4f5bd8e75f 100644 --- a/pc/peerconnection.cc +++ b/pc/peerconnection.cc @@ -2158,6 +2158,7 @@ RTCError PeerConnection::ApplyRemoteDescription( if (IsUnifiedPlan()) { std::vector track_events; + std::vector> added_streams; for (auto transceiver : transceivers_) { const ContentInfo* content = FindMediaSectionForTransceiver(transceiver, remote_description()); @@ -2183,6 +2184,7 @@ RTCError PeerConnection::ApplyRemoteDescription( stream = MediaStreamProxy::Create(rtc::Thread::Current(), MediaStream::Create(sync_label)); remote_streams_->AddStream(stream); + added_streams.push_back(stream); } transceiver->internal()->receiver_internal()->SetStreams({stream}); TrackEvent track_event; @@ -2209,9 +2211,13 @@ RTCError PeerConnection::ApplyRemoteDescription( media_desc->streams()[0].first_ssrc()); } } + // Once all processing has finished, fire off callbacks. for (auto event : track_events) { observer_->OnAddTrack(event.receiver, event.streams); } + for (auto stream : added_streams) { + observer_->OnAddStream(stream); + } } const cricket::ContentInfo* audio_content =