From b0ef5e4bcd36e0d532a575c6f4739eef9ddff252 Mon Sep 17 00:00:00 2001 From: Harald Alvestrand Date: Mon, 5 Jun 2023 10:29:32 +0000 Subject: [PATCH] Declare factory functions for video sender and receiver Later CLs will switch to these functions, and eventually the CreateMediaChannel will be deprecated and removed. Bug: webrtc:13931 Change-Id: I4c5ab89659a47a501728cac217bb1a877fa50047 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/307800 Reviewed-by: Tomas Gunnarsson Commit-Queue: Harald Alvestrand Cr-Commit-Position: refs/heads/main@{#40221} --- media/base/media_engine.h | 21 ++++++++++++++++++++ media/engine/webrtc_video_engine.cc | 30 ++++++++++++++++++++++++----- media/engine/webrtc_video_engine.h | 13 +++++++++++++ 3 files changed, 59 insertions(+), 5 deletions(-) diff --git a/media/base/media_engine.h b/media/base/media_engine.h index d3ef1f4bb8..dc8579a517 100644 --- a/media/base/media_engine.h +++ b/media/base/media_engine.h @@ -163,6 +163,27 @@ class VideoEngineInterface : public RtpHeaderExtensionQueryInterface { VideoEngineInterface(const VideoEngineInterface&) = delete; VideoEngineInterface& operator=(const VideoEngineInterface&) = delete; + virtual std::unique_ptr CreateSendChannel( + webrtc::Call* call, + const MediaConfig& config, + const VideoOptions& options, + const webrtc::CryptoOptions& crypto_options, + webrtc::VideoBitrateAllocatorFactory* video_bitrate_allocator_factory) { + // Default implementation, delete when all is updated + RTC_CHECK_NOTREACHED(); + return nullptr; + } + + virtual std::unique_ptr + CreateReceiveChannel(webrtc::Call* call, + const MediaConfig& config, + const VideoOptions& options, + const webrtc::CryptoOptions& crypto_options) { + // Default implementation, delete when all is updated + RTC_CHECK_NOTREACHED(); + return nullptr; + } + // Creates a video media channel. // Returns NULL on failure. virtual VideoMediaChannel* CreateMediaChannel( diff --git a/media/engine/webrtc_video_engine.cc b/media/engine/webrtc_video_engine.cc index 3a229f8078..825b2aaa50 100644 --- a/media/engine/webrtc_video_engine.cc +++ b/media/engine/webrtc_video_engine.cc @@ -825,6 +825,27 @@ WebRtcVideoEngine::~WebRtcVideoEngine() { RTC_DLOG(LS_INFO) << "WebRtcVideoEngine::~WebRtcVideoEngine"; } +std::unique_ptr +WebRtcVideoEngine::CreateSendChannel( + webrtc::Call* call, + const MediaConfig& config, + const VideoOptions& options, + const webrtc::CryptoOptions& crypto_options, + webrtc::VideoBitrateAllocatorFactory* video_bitrate_allocator_factory) { + return std::make_unique( + call, config, options, crypto_options, encoder_factory_.get(), + decoder_factory_.get(), video_bitrate_allocator_factory); +} +std::unique_ptr +WebRtcVideoEngine::CreateReceiveChannel( + webrtc::Call* call, + const MediaConfig& config, + const VideoOptions& options, + const webrtc::CryptoOptions& crypto_options) { + return std::make_unique( + call, config, options, crypto_options, decoder_factory_.get()); +} + VideoMediaChannel* WebRtcVideoEngine::CreateMediaChannel( MediaChannel::Role role, webrtc::Call* call, @@ -836,14 +857,13 @@ VideoMediaChannel* WebRtcVideoEngine::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( - call, config, options, crypto_options, encoder_factory_.get(), - decoder_factory_.get(), video_bitrate_allocator_factory); + send_channel = CreateSendChannel(call, config, options, crypto_options, + video_bitrate_allocator_factory); } if (role == MediaChannel::Role::kReceive || role == MediaChannel::Role::kBoth) { - receive_channel = std::make_unique( - call, config, options, crypto_options, decoder_factory_.get()); + receive_channel = + CreateReceiveChannel(call, config, options, crypto_options); } return new VideoMediaShimChannel(std::move(send_channel), std::move(receive_channel)); diff --git a/media/engine/webrtc_video_engine.h b/media/engine/webrtc_video_engine.h index 3c486b4971..3e22604cf9 100644 --- a/media/engine/webrtc_video_engine.h +++ b/media/engine/webrtc_video_engine.h @@ -104,6 +104,19 @@ class WebRtcVideoEngine : public VideoEngineInterface { ~WebRtcVideoEngine() override; + std::unique_ptr CreateSendChannel( + webrtc::Call* call, + const MediaConfig& config, + const VideoOptions& options, + const webrtc::CryptoOptions& crypto_options, + webrtc::VideoBitrateAllocatorFactory* video_bitrate_allocator_factory) + override; + std::unique_ptr CreateReceiveChannel( + webrtc::Call* call, + const MediaConfig& config, + const VideoOptions& options, + const webrtc::CryptoOptions& crypto_options) override; + VideoMediaChannel* CreateMediaChannel( MediaChannel::Role role, webrtc::Call* call,