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 =