Adds integration of the FrameEncryptor/FrameDecryptor into the MediaChannel.
This change passes a pointer (non-owning) down to the MediaChannel when set
in the RtpSender / RtpReceiver. This currently is not used to encrypt frames.
Bug: webrtc:9681
Change-Id: I385fa8b948427803cd3f9cef918c31d7754d1b4f
Reviewed-on: https://webrtc-review.googlesource.com/97000
Reviewed-by: Fredrik Solenberg <solenberg@webrtc.org>
Reviewed-by: Steve Anton <steveanton@webrtc.org>
Reviewed-by: Emad Omara <emadomara@webrtc.org>
Commit-Queue: Benjamin Wright <benwright@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24694}
diff --git a/pc/rtpsender.cc b/pc/rtpsender.cc
index 2a7eca5..b7c23b8 100644
--- a/pc/rtpsender.cc
+++ b/pc/rtpsender.cc
@@ -85,6 +85,20 @@
return false;
}
+// Attaches the frame encryptor to the media channel through an invoke on a
+// worker thread. This set must be done on the corresponding worker thread that
+// the media channel was created on.
+void AttachFrameEncryptorToMediaChannel(
+ rtc::Thread* worker_thread,
+ webrtc::FrameEncryptorInterface* frame_encryptor,
+ cricket::MediaChannel* media_channel) {
+ if (media_channel) {
+ return worker_thread->Invoke<void>(RTC_FROM_HERE, [&] {
+ media_channel->SetFrameEncryptor(frame_encryptor);
+ });
+ }
+}
+
} // namespace
LocalAudioSinkAdapter::LocalAudioSinkAdapter() : sink_(nullptr) {}
@@ -277,6 +291,8 @@
void AudioRtpSender::SetFrameEncryptor(
rtc::scoped_refptr<FrameEncryptorInterface> frame_encryptor) {
frame_encryptor_ = std::move(frame_encryptor);
+ AttachFrameEncryptorToMediaChannel(worker_thread_, frame_encryptor_.get(),
+ media_channel_);
}
rtc::scoped_refptr<FrameEncryptorInterface> AudioRtpSender::GetFrameEncryptor()
@@ -325,6 +341,13 @@
stopped_ = true;
}
+void AudioRtpSender::SetVoiceMediaChannel(
+ cricket::VoiceMediaChannel* voice_media_channel) {
+ media_channel_ = voice_media_channel;
+ AttachFrameEncryptorToMediaChannel(worker_thread_, frame_encryptor_.get(),
+ media_channel_);
+}
+
void AudioRtpSender::SetAudioSend() {
RTC_DCHECK(!stopped_);
RTC_DCHECK(can_send_track());
@@ -483,6 +506,8 @@
void VideoRtpSender::SetFrameEncryptor(
rtc::scoped_refptr<FrameEncryptorInterface> frame_encryptor) {
frame_encryptor_ = std::move(frame_encryptor);
+ AttachFrameEncryptorToMediaChannel(worker_thread_, frame_encryptor_.get(),
+ media_channel_);
}
rtc::scoped_refptr<FrameEncryptorInterface> VideoRtpSender::GetFrameEncryptor()
@@ -521,6 +546,13 @@
stopped_ = true;
}
+void VideoRtpSender::SetVideoMediaChannel(
+ cricket::VideoMediaChannel* video_media_channel) {
+ media_channel_ = video_media_channel;
+ AttachFrameEncryptorToMediaChannel(worker_thread_, frame_encryptor_.get(),
+ media_channel_);
+}
+
void VideoRtpSender::SetVideoSend() {
RTC_DCHECK(!stopped_);
RTC_DCHECK(can_send_track());