Simplify ChannelManager initialization.

* A ChannelManager instance is now created via ChannelManager::Create()
* Initialization is performed inside Create(), RAII.
* All member variables in CM are now either const or RTC_GUARDED_BY
  the worker thread.
* Removed dead code (initialization and capturing states are gone).
* ChannelManager now requires construction/destruction on worker thread.
  - one fewer threads that its aware of.
* media_engine_ pointer removed from ConnectionContext.
* Thread policy changes moved from ChannelManager to ConnectionContext.

These changes will make a few other issues easier to fix, so tagging
those bugs with this CL.

Bug: webrtc:12601, webrtc:11988, webrtc:11992, webrtc:11994
Change-Id: I3284cf0a08c773e628af4124e8f52e9faddbe57a
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/212617
Commit-Queue: Tommi <tommi@webrtc.org>
Reviewed-by: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33614}
This commit is contained in:
Tomas Gunnarsson
2021-04-01 16:49:42 +02:00
committed by Commit Bot
parent 97a387d7f3
commit 0b5ec183b5
10 changed files with 177 additions and 228 deletions

View File

@ -82,21 +82,23 @@ TEST(RtpTransceiverTest, CanUnsetChannelOnStoppedTransceiver) {
class RtpTransceiverUnifiedPlanTest : public ::testing::Test {
public:
RtpTransceiverUnifiedPlanTest()
: channel_manager_(std::make_unique<cricket::FakeMediaEngine>(),
std::make_unique<cricket::FakeDataEngine>(),
rtc::Thread::Current(),
rtc::Thread::Current()),
: channel_manager_(cricket::ChannelManager::Create(
std::make_unique<cricket::FakeMediaEngine>(),
std::make_unique<cricket::FakeDataEngine>(),
false,
rtc::Thread::Current(),
rtc::Thread::Current())),
transceiver_(RtpSenderProxyWithInternal<RtpSenderInternal>::Create(
rtc::Thread::Current(),
new rtc::RefCountedObject<MockRtpSenderInternal>()),
RtpReceiverProxyWithInternal<RtpReceiverInternal>::Create(
rtc::Thread::Current(),
new rtc::RefCountedObject<MockRtpReceiverInternal>()),
&channel_manager_,
channel_manager_.GetSupportedAudioRtpHeaderExtensions(),
channel_manager_.get(),
channel_manager_->GetSupportedAudioRtpHeaderExtensions(),
/* on_negotiation_needed= */ [] {}) {}
cricket::ChannelManager channel_manager_;
std::unique_ptr<cricket::ChannelManager> channel_manager_;
RtpTransceiver transceiver_;
};
@ -117,10 +119,12 @@ TEST_F(RtpTransceiverUnifiedPlanTest, StopSetsDirection) {
class RtpTransceiverTestForHeaderExtensions : public ::testing::Test {
public:
RtpTransceiverTestForHeaderExtensions()
: channel_manager_(std::make_unique<cricket::FakeMediaEngine>(),
std::make_unique<cricket::FakeDataEngine>(),
rtc::Thread::Current(),
rtc::Thread::Current()),
: channel_manager_(cricket::ChannelManager::Create(
std::make_unique<cricket::FakeMediaEngine>(),
std::make_unique<cricket::FakeDataEngine>(),
false,
rtc::Thread::Current(),
rtc::Thread::Current())),
extensions_(
{RtpHeaderExtensionCapability("uri1",
1,
@ -140,11 +144,11 @@ class RtpTransceiverTestForHeaderExtensions : public ::testing::Test {
RtpReceiverProxyWithInternal<RtpReceiverInternal>::Create(
rtc::Thread::Current(),
new rtc::RefCountedObject<MockRtpReceiverInternal>()),
&channel_manager_,
channel_manager_.get(),
extensions_,
/* on_negotiation_needed= */ [] {}) {}
cricket::ChannelManager channel_manager_;
std::unique_ptr<cricket::ChannelManager> channel_manager_;
std::vector<RtpHeaderExtensionCapability> extensions_;
RtpTransceiver transceiver_;
};