From 77c6230ef502e03c8bcca4006ca8fb0eebc60d8b Mon Sep 17 00:00:00 2001 From: Harald Alvestrand Date: Mon, 5 Jun 2023 14:19:40 +0000 Subject: [PATCH] Add create functions for voice media send and receive channels. Bug: webrtc:13931 Change-Id: I1aa0cd1651a50bde1c8d1ceccc69b2a124c81294 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/307840 Reviewed-by: Tony Herre Commit-Queue: Harald Alvestrand Cr-Commit-Position: refs/heads/main@{#40224} --- media/base/media_engine.h | 22 +++++++++++++++++++++ media/engine/webrtc_voice_engine.cc | 30 +++++++++++++++++++++++++---- media/engine/webrtc_voice_engine.h | 16 ++++++++++++++- 3 files changed, 63 insertions(+), 5 deletions(-) diff --git a/media/base/media_engine.h b/media/base/media_engine.h index dc8579a517..0d10248ed0 100644 --- a/media/base/media_engine.h +++ b/media/base/media_engine.h @@ -98,6 +98,28 @@ class VoiceEngineInterface : public RtpHeaderExtensionQueryInterface { // TODO(solenberg): Remove once VoE API refactoring is done. virtual rtc::scoped_refptr GetAudioState() const = 0; + virtual std::unique_ptr CreateSendChannel( + webrtc::Call* call, + const MediaConfig& config, + const AudioOptions& options, + const webrtc::CryptoOptions& crypto_options, + webrtc::AudioCodecPairId codec_pair_id) { + // TODO(hta): Make pure virtual when all downstream has updated + RTC_CHECK_NOTREACHED(); + return nullptr; + } + + virtual std::unique_ptr + CreateReceiveChannel(webrtc::Call* call, + const MediaConfig& config, + const AudioOptions& options, + const webrtc::CryptoOptions& crypto_options, + webrtc::AudioCodecPairId codec_pair_id) { + // TODO(hta): Make pure virtual when all downstream has updated + RTC_CHECK_NOTREACHED(); + return nullptr; + } + // MediaChannel creation // Creates a voice media channel. Returns NULL on failure. virtual VoiceMediaChannel* CreateMediaChannel( diff --git a/media/engine/webrtc_voice_engine.cc b/media/engine/webrtc_voice_engine.cc index c09e1374ea..0dc4b7a8a6 100644 --- a/media/engine/webrtc_voice_engine.cc +++ b/media/engine/webrtc_voice_engine.cc @@ -433,6 +433,28 @@ rtc::scoped_refptr WebRtcVoiceEngine::GetAudioState() return audio_state_; } +std::unique_ptr +WebRtcVoiceEngine::CreateSendChannel( + webrtc::Call* call, + const MediaConfig& config, + const AudioOptions& options, + const webrtc::CryptoOptions& crypto_options, + webrtc::AudioCodecPairId codec_pair_id) { + return std::make_unique( + this, config, options, crypto_options, call, codec_pair_id); +} + +std::unique_ptr +WebRtcVoiceEngine::CreateReceiveChannel( + webrtc::Call* call, + const MediaConfig& config, + const AudioOptions& options, + const webrtc::CryptoOptions& crypto_options, + webrtc::AudioCodecPairId codec_pair_id) { + return std::make_unique( + this, config, options, crypto_options, call, codec_pair_id); +} + VoiceMediaChannel* WebRtcVoiceEngine::CreateMediaChannel( MediaChannel::Role role, webrtc::Call* call, @@ -444,13 +466,13 @@ VoiceMediaChannel* WebRtcVoiceEngine::CreateMediaChannel( std::unique_ptr send_channel; std::unique_ptr receive_channel; if (role == MediaChannel::Role::kSend || role == MediaChannel::Role::kBoth) { - send_channel = std::make_unique( - this, config, options, crypto_options, call, codec_pair_id); + send_channel = + CreateSendChannel(call, config, options, crypto_options, codec_pair_id); } if (role == MediaChannel::Role::kReceive || role == MediaChannel::Role::kBoth) { - receive_channel = std::make_unique( - this, config, options, crypto_options, call, codec_pair_id); + receive_channel = CreateReceiveChannel(call, config, options, + crypto_options, codec_pair_id); } return new VoiceMediaShimChannel(std::move(send_channel), std::move(receive_channel)); diff --git a/media/engine/webrtc_voice_engine.h b/media/engine/webrtc_voice_engine.h index d7661a61d2..327beed3d0 100644 --- a/media/engine/webrtc_voice_engine.h +++ b/media/engine/webrtc_voice_engine.h @@ -105,8 +105,22 @@ class WebRtcVoiceEngine final : public VoiceEngineInterface { // Does initialization that needs to occur on the worker thread. void Init() override; - rtc::scoped_refptr GetAudioState() const override; + + std::unique_ptr CreateSendChannel( + webrtc::Call* call, + const MediaConfig& config, + const AudioOptions& options, + const webrtc::CryptoOptions& crypto_options, + webrtc::AudioCodecPairId codec_pair_id) override; + + std::unique_ptr CreateReceiveChannel( + webrtc::Call* call, + const MediaConfig& config, + const AudioOptions& options, + const webrtc::CryptoOptions& crypto_options, + webrtc::AudioCodecPairId codec_pair_id) override; + VoiceMediaChannel* CreateMediaChannel( MediaChannel::Role role, webrtc::Call* call,