From d8b88d8b94c1974f20f510eaeae60f6cdddfe77e Mon Sep 17 00:00:00 2001 From: Harald Alvestrand Date: Tue, 30 May 2023 10:13:17 +0000 Subject: [PATCH] Use the VideoMediaChannelShim for all cases MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This allows us to decouple implementation classes from the MediaChannel class. Bug: webrtc:13931 Change-Id: I22f166cac17c344f943a0382048e8086a193affa Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/307000 Commit-Queue: Harald Alvestrand Reviewed-by: Henrik Boström Cr-Commit-Position: refs/heads/main@{#40179} --- media/base/media_channel_shim.h | 7 +++++-- media/engine/webrtc_video_engine.cc | 19 +++++++++++-------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/media/base/media_channel_shim.h b/media/base/media_channel_shim.h index 458d2a0811..c50c5b117f 100644 --- a/media/base/media_channel_shim.h +++ b/media/base/media_channel_shim.h @@ -195,8 +195,11 @@ class VideoMediaShimChannel : public VideoMediaChannel { void SetSendCodecChangedCallback( absl::AnyInvocable callback) override { // This callback is used internally by the shim, so should not be called by - // users. - RTC_CHECK_NOTREACHED(); + // users for the "both" case. + if (send_impl_ && receive_impl_) { + RTC_CHECK_NOTREACHED(); + } + send_impl()->SetSendCodecChangedCallback(std::move(callback)); } // Implementation of Delayable diff --git a/media/engine/webrtc_video_engine.cc b/media/engine/webrtc_video_engine.cc index bf547b788d..9f7219d803 100644 --- a/media/engine/webrtc_video_engine.cc +++ b/media/engine/webrtc_video_engine.cc @@ -627,22 +627,25 @@ VideoMediaChannel* WebRtcVideoEngine::CreateMediaChannel( const webrtc::CryptoOptions& crypto_options, webrtc::VideoBitrateAllocatorFactory* video_bitrate_allocator_factory) { RTC_LOG(LS_INFO) << "CreateMediaChannel. Options: " << options.ToString(); - if (role == MediaChannel::Role::kBoth) { - auto send_channel = std::make_unique( + std::unique_ptr send_channel; + std::unique_ptr receive_channel; + if (role == MediaChannel::Role::kSend || role == MediaChannel::Role::kBoth) { + send_channel = std::make_unique( MediaChannel::Role::kSend, call, config, options, crypto_options, encoder_factory_.get(), decoder_factory_.get(), video_bitrate_allocator_factory); - auto receive_channel = std::make_unique( + } + if (role == MediaChannel::Role::kReceive || + role == MediaChannel::Role::kBoth) { + receive_channel = std::make_unique( MediaChannel::Role::kReceive, call, config, options, crypto_options, encoder_factory_.get(), decoder_factory_.get(), video_bitrate_allocator_factory); - return new VideoMediaShimChannel(std::move(send_channel), - std::move(receive_channel)); } - return new WebRtcVideoChannel(role, call, config, options, crypto_options, - encoder_factory_.get(), decoder_factory_.get(), - video_bitrate_allocator_factory); + return new VideoMediaShimChannel(std::move(send_channel), + std::move(receive_channel)); } + std::vector WebRtcVideoEngine::send_codecs(bool include_rtx) const { return GetPayloadTypesAndDefaultCodecs(encoder_factory_.get(), /*is_decoder_factory=*/false,