Remove more trampoline functions from ChannelManager

Bug: webrtc:13931
Change-Id: I3a1b48aeffd91ee6abaf78eb1ec69c1653b210e6
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/262640
Reviewed-by: Florent Castelli <orphis@webrtc.org>
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#36898}
This commit is contained in:
Harald Alvestrand
2022-05-16 10:36:43 +00:00
committed by WebRTC LUCI CQ
parent 2698353d43
commit 35f4b4c755
9 changed files with 48 additions and 77 deletions

View File

@ -121,34 +121,6 @@ void ChannelManager::GetSupportedVideoReceiveCodecs(
} }
} }
RtpHeaderExtensions ChannelManager::GetDefaultEnabledAudioRtpHeaderExtensions()
const {
if (!media_engine_)
return {};
return GetDefaultEnabledRtpHeaderExtensions(media_engine_->voice());
}
std::vector<webrtc::RtpHeaderExtensionCapability>
ChannelManager::GetSupportedAudioRtpHeaderExtensions() const {
if (!media_engine_)
return {};
return media_engine_->voice().GetRtpHeaderExtensions();
}
RtpHeaderExtensions ChannelManager::GetDefaultEnabledVideoRtpHeaderExtensions()
const {
if (!media_engine_)
return {};
return GetDefaultEnabledRtpHeaderExtensions(media_engine_->video());
}
std::vector<webrtc::RtpHeaderExtensionCapability>
ChannelManager::GetSupportedVideoRtpHeaderExtensions() const {
if (!media_engine_)
return {};
return media_engine_->video().GetRtpHeaderExtensions();
}
std::unique_ptr<VoiceChannel> ChannelManager::CreateVoiceChannel( std::unique_ptr<VoiceChannel> ChannelManager::CreateVoiceChannel(
webrtc::Call* call, webrtc::Call* call,
const MediaConfig& media_config, const MediaConfig& media_config,
@ -224,15 +196,4 @@ std::unique_ptr<VideoChannel> ChannelManager::CreateVideoChannel(
return video_channel; return video_channel;
} }
bool ChannelManager::StartAecDump(webrtc::FileWrapper file,
int64_t max_size_bytes) {
RTC_DCHECK_RUN_ON(worker_thread_);
return media_engine_->voice().StartAecDump(std::move(file), max_size_bytes);
}
void ChannelManager::StopAecDump() {
RTC_DCHECK_RUN_ON(worker_thread_);
media_engine_->voice().StopAecDump();
}
} // namespace cricket } // namespace cricket

View File

@ -69,12 +69,6 @@ class ChannelManager : public ChannelFactoryInterface {
void GetSupportedAudioReceiveCodecs(std::vector<AudioCodec>* codecs) const; void GetSupportedAudioReceiveCodecs(std::vector<AudioCodec>* codecs) const;
void GetSupportedVideoSendCodecs(std::vector<VideoCodec>* codecs) const; void GetSupportedVideoSendCodecs(std::vector<VideoCodec>* codecs) const;
void GetSupportedVideoReceiveCodecs(std::vector<VideoCodec>* codecs) const; void GetSupportedVideoReceiveCodecs(std::vector<VideoCodec>* codecs) const;
RtpHeaderExtensions GetDefaultEnabledAudioRtpHeaderExtensions() const;
std::vector<webrtc::RtpHeaderExtensionCapability>
GetSupportedAudioRtpHeaderExtensions() const;
RtpHeaderExtensions GetDefaultEnabledVideoRtpHeaderExtensions() const;
std::vector<webrtc::RtpHeaderExtensionCapability>
GetSupportedVideoRtpHeaderExtensions() const;
// The operations below all occur on the worker thread. // The operations below all occur on the worker thread.
// The caller is responsible for ensuring that destruction happens // The caller is responsible for ensuring that destruction happens
@ -102,14 +96,6 @@ class ChannelManager : public ChannelFactoryInterface {
webrtc::VideoBitrateAllocatorFactory* video_bitrate_allocator_factory) webrtc::VideoBitrateAllocatorFactory* video_bitrate_allocator_factory)
override; override;
// Starts AEC dump using existing file, with a specified maximum file size in
// bytes. When the limit is reached, logging will stop and the file will be
// closed. If max_size_bytes is set to <= 0, no limit will be used.
bool StartAecDump(webrtc::FileWrapper file, int64_t max_size_bytes);
// Stops recording AEC dump.
void StopAecDump();
protected: protected:
ChannelManager(std::unique_ptr<MediaEngineInterface> media_engine, ChannelManager(std::unique_ptr<MediaEngineInterface> media_engine,
bool enable_rtx, bool enable_rtx,

View File

@ -129,17 +129,17 @@ RtpCapabilities PeerConnectionFactory::GetRtpSenderCapabilities(
switch (kind) { switch (kind) {
case cricket::MEDIA_TYPE_AUDIO: { case cricket::MEDIA_TYPE_AUDIO: {
cricket::AudioCodecs cricket_codecs; cricket::AudioCodecs cricket_codecs;
channel_manager()->GetSupportedAudioSendCodecs(&cricket_codecs); cricket_codecs = media_engine()->voice().send_codecs();
return ToRtpCapabilities( auto extensions =
cricket_codecs, GetDefaultEnabledRtpHeaderExtensions(media_engine()->voice());
channel_manager()->GetDefaultEnabledAudioRtpHeaderExtensions()); return ToRtpCapabilities(cricket_codecs, extensions);
} }
case cricket::MEDIA_TYPE_VIDEO: { case cricket::MEDIA_TYPE_VIDEO: {
cricket::VideoCodecs cricket_codecs; cricket::VideoCodecs cricket_codecs;
channel_manager()->GetSupportedVideoSendCodecs(&cricket_codecs); cricket_codecs = media_engine()->video().send_codecs();
return ToRtpCapabilities( auto extensions =
cricket_codecs, GetDefaultEnabledRtpHeaderExtensions(media_engine()->video());
channel_manager()->GetDefaultEnabledVideoRtpHeaderExtensions()); return ToRtpCapabilities(cricket_codecs, extensions);
} }
case cricket::MEDIA_TYPE_DATA: case cricket::MEDIA_TYPE_DATA:
return RtpCapabilities(); return RtpCapabilities();
@ -156,17 +156,17 @@ RtpCapabilities PeerConnectionFactory::GetRtpReceiverCapabilities(
switch (kind) { switch (kind) {
case cricket::MEDIA_TYPE_AUDIO: { case cricket::MEDIA_TYPE_AUDIO: {
cricket::AudioCodecs cricket_codecs; cricket::AudioCodecs cricket_codecs;
channel_manager()->GetSupportedAudioReceiveCodecs(&cricket_codecs); cricket_codecs = media_engine()->voice().recv_codecs();
return ToRtpCapabilities( auto extensions =
cricket_codecs, GetDefaultEnabledRtpHeaderExtensions(media_engine()->voice());
channel_manager()->GetDefaultEnabledAudioRtpHeaderExtensions()); return ToRtpCapabilities(cricket_codecs, extensions);
} }
case cricket::MEDIA_TYPE_VIDEO: { case cricket::MEDIA_TYPE_VIDEO: {
cricket::VideoCodecs cricket_codecs; cricket::VideoCodecs cricket_codecs;
channel_manager()->GetSupportedVideoReceiveCodecs(&cricket_codecs); channel_manager()->GetSupportedVideoReceiveCodecs(&cricket_codecs);
return ToRtpCapabilities( auto extensions =
cricket_codecs, GetDefaultEnabledRtpHeaderExtensions(media_engine()->video());
channel_manager()->GetDefaultEnabledVideoRtpHeaderExtensions()); return ToRtpCapabilities(cricket_codecs, extensions);
} }
case cricket::MEDIA_TYPE_DATA: case cricket::MEDIA_TYPE_DATA:
return RtpCapabilities(); return RtpCapabilities();
@ -187,12 +187,19 @@ PeerConnectionFactory::CreateAudioSource(const cricket::AudioOptions& options) {
bool PeerConnectionFactory::StartAecDump(FILE* file, int64_t max_size_bytes) { bool PeerConnectionFactory::StartAecDump(FILE* file, int64_t max_size_bytes) {
RTC_DCHECK_RUN_ON(worker_thread()); RTC_DCHECK_RUN_ON(worker_thread());
return channel_manager()->StartAecDump(FileWrapper(file), max_size_bytes); return media_engine()->voice().StartAecDump(FileWrapper(file),
max_size_bytes);
} }
void PeerConnectionFactory::StopAecDump() { void PeerConnectionFactory::StopAecDump() {
RTC_DCHECK_RUN_ON(worker_thread()); RTC_DCHECK_RUN_ON(worker_thread());
channel_manager()->StopAecDump(); media_engine()->voice().StopAecDump();
}
cricket::MediaEngineInterface* PeerConnectionFactory::media_engine() const {
RTC_DCHECK(context_);
RTC_DCHECK(context_->channel_manager());
return context_->channel_manager()->media_engine();
} }
RTCErrorOr<rtc::scoped_refptr<PeerConnectionInterface>> RTCErrorOr<rtc::scoped_refptr<PeerConnectionInterface>>

View File

@ -120,6 +120,8 @@ class PeerConnectionFactory : public PeerConnectionFactoryInterface {
return context_->field_trials(); return context_->field_trials();
} }
cricket::MediaEngineInterface* media_engine() const;
protected: protected:
// Constructor used by the static Create() method. Modifies the dependencies. // Constructor used by the static Create() method. Modifies the dependencies.
PeerConnectionFactory(rtc::scoped_refptr<ConnectionContext> context, PeerConnectionFactory(rtc::scoped_refptr<ConnectionContext> context,

View File

@ -126,7 +126,7 @@ class RtpTransceiverUnifiedPlanTest : public ::testing::Test {
rtc::Thread::Current(), rtc::Thread::Current(),
receiver_), receiver_),
&channel_manager_, &channel_manager_,
channel_manager_.GetSupportedAudioRtpHeaderExtensions(), channel_manager_.media_engine()->voice().GetRtpHeaderExtensions(),
/* on_negotiation_needed= */ [] {})) {} /* on_negotiation_needed= */ [] {})) {}
static rtc::scoped_refptr<MockRtpReceiverInternal> MockReceiver() { static rtc::scoped_refptr<MockRtpReceiverInternal> MockReceiver() {

View File

@ -273,8 +273,8 @@ RtpTransmissionManager::CreateAndAddTransceiver(
rtc::make_ref_counted<RtpTransceiver>( rtc::make_ref_counted<RtpTransceiver>(
sender, receiver, channel_manager(), sender, receiver, channel_manager(),
sender->media_type() == cricket::MEDIA_TYPE_AUDIO sender->media_type() == cricket::MEDIA_TYPE_AUDIO
? channel_manager()->GetSupportedAudioRtpHeaderExtensions() ? media_engine()->voice().GetRtpHeaderExtensions()
: channel_manager()->GetSupportedVideoRtpHeaderExtensions(), : media_engine()->video().GetRtpHeaderExtensions(),
[this_weak_ptr = weak_ptr_factory_.GetWeakPtr()]() { [this_weak_ptr = weak_ptr_factory_.GetWeakPtr()]() {
if (this_weak_ptr) { if (this_weak_ptr) {
this_weak_ptr->OnNegotiationNeeded(); this_weak_ptr->OnNegotiationNeeded();
@ -690,4 +690,8 @@ RtpTransmissionManager::FindReceiverById(const std::string& receiver_id) const {
return nullptr; return nullptr;
} }
cricket::MediaEngineInterface* RtpTransmissionManager::media_engine() const {
return channel_manager()->media_engine();
}
} // namespace webrtc } // namespace webrtc

View File

@ -244,6 +244,8 @@ class RtpTransmissionManager : public RtpSenderBase::SetStreamsObserver {
PeerConnectionObserver* Observer() const; PeerConnectionObserver* Observer() const;
void OnNegotiationNeeded(); void OnNegotiationNeeded();
cricket::MediaEngineInterface* media_engine() const;
TransceiverList transceivers_; TransceiverList transceivers_;
// These lists store sender info seen in local/remote descriptions. // These lists store sender info seen in local/remote descriptions.

View File

@ -1255,12 +1255,20 @@ void SdpOfferAnswerHandler::Initialize(
cricket::ChannelManager* SdpOfferAnswerHandler::channel_manager() const { cricket::ChannelManager* SdpOfferAnswerHandler::channel_manager() const {
return context_->channel_manager(); return context_->channel_manager();
} }
cricket::MediaEngineInterface* SdpOfferAnswerHandler::media_engine() const {
RTC_DCHECK(context_);
RTC_DCHECK(context_->channel_manager());
return context_->channel_manager()->media_engine();
}
TransceiverList* SdpOfferAnswerHandler::transceivers() { TransceiverList* SdpOfferAnswerHandler::transceivers() {
if (!pc_->rtp_manager()) { if (!pc_->rtp_manager()) {
return nullptr; return nullptr;
} }
return pc_->rtp_manager()->transceivers(); return pc_->rtp_manager()->transceivers();
} }
const TransceiverList* SdpOfferAnswerHandler::transceivers() const { const TransceiverList* SdpOfferAnswerHandler::transceivers() const {
if (!pc_->rtp_manager()) { if (!pc_->rtp_manager()) {
return nullptr; return nullptr;
@ -3886,7 +3894,7 @@ void SdpOfferAnswerHandler::GetOptionsForPlanBOffer(
cricket::MEDIA_TYPE_AUDIO, cricket::CN_AUDIO, cricket::MEDIA_TYPE_AUDIO, cricket::CN_AUDIO,
RtpTransceiverDirectionFromSendRecv(send_audio, recv_audio), false); RtpTransceiverDirectionFromSendRecv(send_audio, recv_audio), false);
options.header_extensions = options.header_extensions =
channel_manager()->GetSupportedAudioRtpHeaderExtensions(); media_engine()->voice().GetRtpHeaderExtensions();
session_options->media_description_options.push_back(options); session_options->media_description_options.push_back(options);
audio_index = session_options->media_description_options.size() - 1; audio_index = session_options->media_description_options.size() - 1;
} }
@ -3895,7 +3903,7 @@ void SdpOfferAnswerHandler::GetOptionsForPlanBOffer(
cricket::MEDIA_TYPE_VIDEO, cricket::CN_VIDEO, cricket::MEDIA_TYPE_VIDEO, cricket::CN_VIDEO,
RtpTransceiverDirectionFromSendRecv(send_video, recv_video), false); RtpTransceiverDirectionFromSendRecv(send_video, recv_video), false);
options.header_extensions = options.header_extensions =
channel_manager()->GetSupportedVideoRtpHeaderExtensions(); media_engine()->video().GetRtpHeaderExtensions();
session_options->media_description_options.push_back(options); session_options->media_description_options.push_back(options);
video_index = session_options->media_description_options.size() - 1; video_index = session_options->media_description_options.size() - 1;
} }
@ -4960,7 +4968,7 @@ void SdpOfferAnswerHandler::GenerateMediaDescriptionOptions(
*audio_index = session_options->media_description_options.size() - 1; *audio_index = session_options->media_description_options.size() - 1;
} }
session_options->media_description_options.back().header_extensions = session_options->media_description_options.back().header_extensions =
channel_manager()->GetSupportedAudioRtpHeaderExtensions(); media_engine()->voice().GetRtpHeaderExtensions();
} else if (IsVideoContent(&content)) { } else if (IsVideoContent(&content)) {
// If we already have an video m= section, reject this extra one. // If we already have an video m= section, reject this extra one.
if (*video_index) { if (*video_index) {
@ -4977,7 +4985,7 @@ void SdpOfferAnswerHandler::GenerateMediaDescriptionOptions(
*video_index = session_options->media_description_options.size() - 1; *video_index = session_options->media_description_options.size() - 1;
} }
session_options->media_description_options.back().header_extensions = session_options->media_description_options.back().header_extensions =
channel_manager()->GetSupportedVideoRtpHeaderExtensions(); media_engine()->video().GetRtpHeaderExtensions();
} else if (IsUnsupportedContent(&content)) { } else if (IsUnsupportedContent(&content)) {
session_options->media_description_options.push_back( session_options->media_description_options.push_back(
cricket::MediaDescriptionOptions(cricket::MEDIA_TYPE_UNSUPPORTED, cricket::MediaDescriptionOptions(cricket::MEDIA_TYPE_UNSUPPORTED,

View File

@ -576,6 +576,7 @@ class SdpOfferAnswerHandler : public SdpStateProvider,
// ================================================================== // ==================================================================
// Access to pc_ variables // Access to pc_ variables
cricket::ChannelManager* channel_manager() const; cricket::ChannelManager* channel_manager() const;
cricket::MediaEngineInterface* media_engine() const;
TransceiverList* transceivers(); TransceiverList* transceivers();
const TransceiverList* transceivers() const; const TransceiverList* transceivers() const;
DataChannelController* data_channel_controller(); DataChannelController* data_channel_controller();