Added a callback function OnAddTrack to PeerConnectionObserver
Added the callback in native c++ API.
The callback function is called when a track is added and a new RtpReceiver is created.
The application can tell when tracks are added to the streams by listening to this callback.
BUG=webrtc:6112
Review-Url: https://codereview.webrtc.org/2505173002
Cr-Commit-Position: refs/heads/master@{#15142}
diff --git a/webrtc/api/peerconnection.cc b/webrtc/api/peerconnection.cc
index a1ce6ab..46bdec5 100644
--- a/webrtc/api/peerconnection.cc
+++ b/webrtc/api/peerconnection.cc
@@ -1426,20 +1426,29 @@
void PeerConnection::CreateAudioReceiver(MediaStreamInterface* stream,
const std::string& track_id,
uint32_t ssrc) {
- receivers_.push_back(
- RtpReceiverProxyWithInternal<RtpReceiverInternal>::Create(
+ rtc::scoped_refptr<RtpReceiverProxyWithInternal<RtpReceiverInternal>>
+ receiver = RtpReceiverProxyWithInternal<RtpReceiverInternal>::Create(
signaling_thread(), new AudioRtpReceiver(stream, track_id, ssrc,
- session_->voice_channel())));
+ session_->voice_channel()));
+
+ receivers_.push_back(receiver);
+ std::vector<rtc::scoped_refptr<MediaStreamInterface>> streams;
+ streams.push_back(rtc::scoped_refptr<MediaStreamInterface>(stream));
+ observer_->OnAddTrack(receiver, streams);
}
void PeerConnection::CreateVideoReceiver(MediaStreamInterface* stream,
const std::string& track_id,
uint32_t ssrc) {
- receivers_.push_back(
- RtpReceiverProxyWithInternal<RtpReceiverInternal>::Create(
+ rtc::scoped_refptr<RtpReceiverProxyWithInternal<RtpReceiverInternal>>
+ receiver = RtpReceiverProxyWithInternal<RtpReceiverInternal>::Create(
signaling_thread(),
new VideoRtpReceiver(stream, track_id, factory_->worker_thread(),
- ssrc, session_->video_channel())));
+ ssrc, session_->video_channel()));
+ receivers_.push_back(receiver);
+ std::vector<rtc::scoped_refptr<MediaStreamInterface>> streams;
+ streams.push_back(rtc::scoped_refptr<MediaStreamInterface>(stream));
+ observer_->OnAddTrack(receiver, streams);
}
// TODO(deadbeef): Keep RtpReceivers around even if track goes away in remote