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,