Index: webrtc/api/rtpreceiver.cc |
diff --git a/webrtc/api/rtpreceiver.cc b/webrtc/api/rtpreceiver.cc |
index 9df336e1f042ca79afb2814905af52c2840a7753..882bc2be8d4b46e6daf1575af5c34d7d3d9fb650 100644 |
--- a/webrtc/api/rtpreceiver.cc |
+++ b/webrtc/api/rtpreceiver.cc |
@@ -35,6 +35,8 @@ AudioRtpReceiver::AudioRtpReceiver(MediaStreamInterface* stream, |
track_->GetSource()->RegisterAudioObserver(this); |
Reconfigure(); |
stream->AddTrack(track_); |
+ provider_->SignalFirstAudioPacketReceived.connect( |
+ this, &AudioRtpReceiver::OnFirstAudioPacketReceived); |
} |
AudioRtpReceiver::~AudioRtpReceiver() { |
@@ -83,6 +85,22 @@ void AudioRtpReceiver::Reconfigure() { |
provider_->SetAudioPlayout(ssrc_, track_->enabled()); |
} |
+void AudioRtpReceiver::SetObserver(RtpReceiverObserverInterface* observer) { |
+ observer_ = observer; |
+ // If received the first packet before setting the observer, call the |
+ // observer. |
+ if (received_first_packet_) { |
+ observer_->OnFirstPacketReceived(media_type()); |
+ } |
+} |
+ |
+void AudioRtpReceiver::OnFirstAudioPacketReceived() { |
+ if (observer_) { |
+ observer_->OnFirstPacketReceived(media_type()); |
+ } |
+ received_first_packet_ = true; |
+} |
+ |
VideoRtpReceiver::VideoRtpReceiver(MediaStreamInterface* stream, |
const std::string& track_id, |
rtc::Thread* worker_thread, |
@@ -104,6 +122,8 @@ VideoRtpReceiver::VideoRtpReceiver(MediaStreamInterface* stream, |
source_->SetState(MediaSourceInterface::kLive); |
provider_->SetVideoPlayout(ssrc_, true, &broadcaster_); |
stream->AddTrack(track_); |
+ provider_->SignalFirstVideoPacketReceived.connect( |
+ this, &VideoRtpReceiver::OnFirstVideoPacketReceived); |
} |
VideoRtpReceiver::~VideoRtpReceiver() { |
@@ -132,4 +152,20 @@ void VideoRtpReceiver::Stop() { |
provider_ = nullptr; |
} |
+void VideoRtpReceiver::SetObserver(RtpReceiverObserverInterface* observer) { |
+ observer_ = observer; |
+ // If received the first packet before setting the observer, call the |
+ // observer. |
+ if (received_first_packet_) { |
+ observer_->OnFirstPacketReceived(media_type()); |
+ } |
+} |
+ |
+void VideoRtpReceiver::OnFirstVideoPacketReceived() { |
+ if (observer_) { |
+ observer_->OnFirstPacketReceived(media_type()); |
+ } |
+ received_first_packet_ = true; |
+} |
+ |
} // namespace webrtc |