Don't reset streams for the FrameEncryptor / FrameDecryptor unless they changed.

This change prevents resets unless someone actually set a FrameEncryptor
/ FrameDecryptor.

Bug: webrtc:9795
Change-Id: I29910b9ecc2f6f8eea371c5961ac7e9780de65d2
Reviewed-on: https://webrtc-review.googlesource.com/c/104901
Reviewed-by: Steve Anton <steveanton@webrtc.org>
Commit-Queue: Benjamin Wright <benwright@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#25095}
This commit is contained in:
Benjamin Wright 2018-10-09 17:29:54 -07:00 committed by Commit Bot
parent da67c16c81
commit 6cc9cca5a6
2 changed files with 30 additions and 16 deletions

View File

@ -51,8 +51,8 @@ void MaybeAttachFrameDecryptorToMediaChannel(
rtc::Thread* worker_thread,
rtc::scoped_refptr<webrtc::FrameDecryptorInterface> frame_decryptor,
cricket::MediaChannel* media_channel) {
if (media_channel && ssrc.has_value()) {
return worker_thread->Invoke<void>(RTC_FROM_HERE, [&] {
if (media_channel && frame_decryptor && ssrc.has_value()) {
worker_thread->Invoke<void>(RTC_FROM_HERE, [&] {
media_channel->SetFrameDecryptor(*ssrc, frame_decryptor);
});
}
@ -156,9 +156,12 @@ bool AudioRtpReceiver::SetParameters(const RtpParameters& parameters) {
void AudioRtpReceiver::SetFrameDecryptor(
rtc::scoped_refptr<FrameDecryptorInterface> frame_decryptor) {
frame_decryptor_ = std::move(frame_decryptor);
// Attach the frame decryptor to the media channel if it exists.
MaybeAttachFrameDecryptorToMediaChannel(ssrc_, worker_thread_,
frame_decryptor_, media_channel_);
// Special Case: Set the frame decryptor to any value on any existing channel.
if (media_channel_ && ssrc_.has_value()) {
worker_thread_->Invoke<void>(RTC_FROM_HERE, [&] {
media_channel_->SetFrameDecryptor(*ssrc_, frame_decryptor_);
});
}
}
rtc::scoped_refptr<FrameDecryptorInterface>
@ -347,9 +350,12 @@ bool VideoRtpReceiver::SetParameters(const RtpParameters& parameters) {
void VideoRtpReceiver::SetFrameDecryptor(
rtc::scoped_refptr<FrameDecryptorInterface> frame_decryptor) {
frame_decryptor_ = std::move(frame_decryptor);
// Attach the new frame decryptor the media channel if it exists yet.
MaybeAttachFrameDecryptorToMediaChannel(ssrc_, worker_thread_,
frame_decryptor_, media_channel_);
// Special Case: Set the frame decryptor to any value on any existing channel.
if (media_channel_ && ssrc_.has_value()) {
worker_thread_->Invoke<void>(RTC_FROM_HERE, [&] {
media_channel_->SetFrameDecryptor(*ssrc_, frame_decryptor_);
});
}
}
rtc::scoped_refptr<FrameDecryptorInterface>

View File

@ -68,13 +68,13 @@ bool PerSenderRtpEncodingParameterHasValue(
// correct worker thread only if both the media channel exists and a ssrc has
// been allocated to the stream.
void MaybeAttachFrameEncryptorToMediaChannel(
const absl::optional<uint32_t> ssrc,
const uint32_t ssrc,
rtc::Thread* worker_thread,
rtc::scoped_refptr<webrtc::FrameEncryptorInterface> frame_encryptor,
cricket::MediaChannel* media_channel) {
if (media_channel && ssrc.has_value()) {
return worker_thread->Invoke<void>(RTC_FROM_HERE, [&] {
media_channel->SetFrameEncryptor(*ssrc, frame_encryptor);
if (media_channel && frame_encryptor && ssrc) {
worker_thread->Invoke<void>(RTC_FROM_HERE, [&] {
media_channel->SetFrameEncryptor(ssrc, frame_encryptor);
});
}
}
@ -305,8 +305,12 @@ rtc::scoped_refptr<DtmfSenderInterface> AudioRtpSender::GetDtmfSender() const {
void AudioRtpSender::SetFrameEncryptor(
rtc::scoped_refptr<FrameEncryptorInterface> frame_encryptor) {
frame_encryptor_ = std::move(frame_encryptor);
MaybeAttachFrameEncryptorToMediaChannel(ssrc_, worker_thread_,
frame_encryptor_, media_channel_);
// Special Case: Set the frame encryptor to any value on any existing channel.
if (media_channel_ && ssrc_) {
worker_thread_->Invoke<void>(RTC_FROM_HERE, [&] {
media_channel_->SetFrameEncryptor(ssrc_, frame_encryptor_);
});
}
}
rtc::scoped_refptr<FrameEncryptorInterface> AudioRtpSender::GetFrameEncryptor()
@ -557,8 +561,12 @@ rtc::scoped_refptr<DtmfSenderInterface> VideoRtpSender::GetDtmfSender() const {
void VideoRtpSender::SetFrameEncryptor(
rtc::scoped_refptr<FrameEncryptorInterface> frame_encryptor) {
frame_encryptor_ = std::move(frame_encryptor);
MaybeAttachFrameEncryptorToMediaChannel(ssrc_, worker_thread_,
frame_encryptor_, media_channel_);
// Special Case: Set the frame encryptor to any value on any existing channel.
if (media_channel_ && ssrc_) {
worker_thread_->Invoke<void>(RTC_FROM_HERE, [&] {
media_channel_->SetFrameEncryptor(ssrc_, frame_encryptor_);
});
}
}
rtc::scoped_refptr<FrameEncryptorInterface> VideoRtpSender::GetFrameEncryptor()