Attach video sink only after VideoSendStream is started.

By attaching the sink when all is set up, we make it possible for an
application to listen for that event - and only then start producing
frames. Otherwise frames risk being dropped during the setup phase.

Bug: webrtc:14276
Change-Id: I0a906681fc526b0ee88c60a842afb0d68e21de14
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/270660
Auto-Submit: Erik Språng <sprang@webrtc.org>
Commit-Queue: Per Kjellander <perkj@webrtc.org>
Reviewed-by: Per Kjellander <perkj@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#37696}
This commit is contained in:
Erik Språng 2022-08-04 21:02:02 +02:00 committed by WebRTC LUCI CQ
parent 7ed05c00bb
commit e94b175c42

View File

@ -2855,12 +2855,15 @@ void WebRtcVideoChannel::WebRtcVideoSendStream::RecreateWebRtcStream() {
parameters_.encoder_config.encoder_specific_settings = NULL;
// Calls stream_->UpdateActiveSimulcastLayers() to start the VideoSendStream
// if necessary conditions are met.
UpdateSendState();
// Attach the source after starting the send stream to prevent frames from
// being injected into a not-yet initializated video stream encoder.
if (source_) {
stream_->SetSource(source_, GetDegradationPreference());
}
// Call stream_->Start() if necessary conditions are met.
UpdateSendState();
}
WebRtcVideoChannel::WebRtcVideoReceiveStream::WebRtcVideoReceiveStream(