Don't recreate the VideoReceiveStream on SetFrameDecryptor in the MediaEngine.

This change introduces new logic to allow the injection of the FrameDecryptor
into an arbitrary already running VideoReceiveStream without resetting it. It
does this by taking advantage of the BufferedFrameDecryptor which will
forcefully be created regardless of whether a FrameDecryptor is passed in
during construction of the VideoReceiver if the
crypto_option.require_frame_encryption is true. By allowing the
BufferedFrameDecryptor to swap out which FrameDecryptor it uses this allows the
Receiver to switch decryptors without resetting the stream.

This is intended to mostly be used when you set your FrameDecryptor at a point
post creation for the first time.

Bug: webrtc:10416
Change-Id: If656b2acc447e2e77537cfa394729e5c3a8b660a
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/130361
Commit-Queue: Stefan Holmer <stefan@webrtc.org>
Reviewed-by: Stefan Holmer <stefan@webrtc.org>
Reviewed-by: Jonas Oreland <jonaso@webrtc.org>
Reviewed-by: Niels Moller <nisse@webrtc.org>
Reviewed-by: Rasmus Brandt <brandtr@webrtc.org>
Reviewed-by: Philip Eliasson <philipel@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#27458}
This commit is contained in:
Benjamin Wright
2019-04-03 10:44:18 -07:00
committed by Commit Bot
parent 144575b65a
commit a556448138
11 changed files with 85 additions and 49 deletions

View File

@ -175,11 +175,14 @@ RtpVideoStreamReceiver::RtpVideoStreamReceiver(
clock_, kPacketBufferStartSize, packet_buffer_max_size, this);
reference_finder_ =
absl::make_unique<video_coding::RtpFrameReferenceFinder>(this);
// Only construct the encrypted receiver if frame encryption is enabled.
if (frame_decryptor != nullptr ||
config_.crypto_options.sframe.require_frame_encryption) {
if (config_.crypto_options.sframe.require_frame_encryption) {
buffered_frame_decryptor_ =
absl::make_unique<BufferedFrameDecryptor>(this, this, frame_decryptor);
absl::make_unique<BufferedFrameDecryptor>(this, this);
if (frame_decryptor != nullptr) {
buffered_frame_decryptor_->SetFrameDecryptor(std::move(frame_decryptor));
}
}
}
@ -452,6 +455,16 @@ void RtpVideoStreamReceiver::OnDecryptionStatusChange(int status) {
frames_decryptable_.store(status == 0);
}
void RtpVideoStreamReceiver::SetFrameDecryptor(
rtc::scoped_refptr<FrameDecryptorInterface> frame_decryptor) {
RTC_DCHECK_RUN_ON(&network_tc_);
if (buffered_frame_decryptor_ == nullptr) {
buffered_frame_decryptor_ =
absl::make_unique<BufferedFrameDecryptor>(this, this);
}
buffered_frame_decryptor_->SetFrameDecryptor(std::move(frame_decryptor));
}
void RtpVideoStreamReceiver::UpdateRtt(int64_t max_rtt_ms) {
if (nack_module_)
nack_module_->UpdateRtt(max_rtt_ms);