Use new TransportController implementation in PeerConnection.
The TransportController will be replaced by the JsepTransportController
and JsepTransport will be replace be JsepTransport2.
The JsepTransportController will take the entire SessionDescription
and handle the RtcpMux, Sdes and BUNDLE internally.
The ownership model is also changed. The P2P layer transports are not
ref-counted and will be owned by the JsepTransport2.
In ORTC aspect, RtpTransportAdapter is now a wrapper over RtpTransport
or SrtpTransport and it implements the public and internal interface
by calling the transport underneath.
Bug: webrtc:8587
Change-Id: Ia7fa61288a566f211f8560072ea0eecaf19e48df
Reviewed-on: https://webrtc-review.googlesource.com/59586
Commit-Queue: Zhi Huang <zhihuang@webrtc.org>
Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22693}
diff --git a/pc/channelmanager_unittest.cc b/pc/channelmanager_unittest.cc
index d318ac5..38da139 100644
--- a/pc/channelmanager_unittest.cc
+++ b/pc/channelmanager_unittest.cc
@@ -15,8 +15,8 @@
#include "media/base/fakevideocapturer.h"
#include "media/base/testutils.h"
#include "media/engine/fakewebrtccall.h"
+#include "p2p/base/fakedtlstransport.h"
#include "pc/channelmanager.h"
-#include "pc/test/faketransportcontroller.h"
#include "rtc_base/gunit.h"
#include "rtc_base/logging.h"
#include "rtc_base/thread.h"
@@ -47,13 +47,47 @@
std::unique_ptr<DataEngineInterface>(fdme_),
rtc::Thread::Current(),
rtc::Thread::Current())),
- fake_call_(),
- transport_controller_(
- new cricket::FakeTransportController(ICEROLE_CONTROLLING)) {
+ fake_call_() {
fme_->SetAudioCodecs(MAKE_VECTOR(kAudioCodecs));
fme_->SetVideoCodecs(MAKE_VECTOR(kVideoCodecs));
}
+ std::unique_ptr<webrtc::RtpTransportInternal> CreateDtlsSrtpTransport() {
+ rtp_dtls_transport_ = rtc::MakeUnique<FakeDtlsTransport>(
+ "fake_dtls_transport", cricket::ICE_CANDIDATE_COMPONENT_RTP);
+ auto rtp_transport =
+ rtc::MakeUnique<webrtc::RtpTransport>(/*rtcp_mux_required=*/true);
+ auto srtp_transport =
+ rtc::MakeUnique<webrtc::SrtpTransport>(std::move(rtp_transport));
+ auto dtls_srtp_transport =
+ rtc::MakeUnique<webrtc::DtlsSrtpTransport>(std::move(srtp_transport));
+ dtls_srtp_transport->SetDtlsTransports(rtp_dtls_transport_.get(),
+ /*rtcp_dtls_transport=*/nullptr);
+ return dtls_srtp_transport;
+ }
+
+ void TestCreateDestroyChannels(webrtc::RtpTransportInternal* rtp_transport) {
+ cricket::VoiceChannel* voice_channel = cm_->CreateVoiceChannel(
+ &fake_call_, cricket::MediaConfig(), rtp_transport,
+ rtc::Thread::Current(), cricket::CN_AUDIO, kDefaultSrtpRequired,
+ rtc::CryptoOptions(), AudioOptions());
+ EXPECT_TRUE(voice_channel != nullptr);
+ cricket::VideoChannel* video_channel = cm_->CreateVideoChannel(
+ &fake_call_, cricket::MediaConfig(), rtp_transport,
+ rtc::Thread::Current(), cricket::CN_VIDEO, kDefaultSrtpRequired,
+ rtc::CryptoOptions(), VideoOptions());
+ EXPECT_TRUE(video_channel != nullptr);
+ cricket::RtpDataChannel* rtp_data_channel = cm_->CreateRtpDataChannel(
+ cricket::MediaConfig(), rtp_transport, rtc::Thread::Current(),
+ cricket::CN_DATA, kDefaultSrtpRequired, rtc::CryptoOptions());
+ EXPECT_TRUE(rtp_data_channel != nullptr);
+ cm_->DestroyVideoChannel(video_channel);
+ cm_->DestroyVoiceChannel(voice_channel);
+ cm_->DestroyRtpDataChannel(rtp_data_channel);
+ cm_->Terminate();
+ }
+
+ std::unique_ptr<DtlsTransportInternal> rtp_dtls_transport_;
std::unique_ptr<rtc::Thread> network_;
std::unique_ptr<rtc::Thread> worker_;
// |fme_| and |fdme_| are actually owned by |cm_|.
@@ -61,7 +95,6 @@
cricket::FakeDataEngine* fdme_;
std::unique_ptr<cricket::ChannelManager> cm_;
cricket::FakeCall fake_call_;
- std::unique_ptr<cricket::FakeTransportController> transport_controller_;
};
// Test that we startup/shutdown properly.
@@ -93,68 +126,6 @@
EXPECT_FALSE(cm_->initialized());
}
-// Test that we can create and destroy a voice and video channel.
-TEST_F(ChannelManagerTest, CreateDestroyChannels) {
- EXPECT_TRUE(cm_->Init());
- cricket::DtlsTransportInternal* rtp_transport =
- transport_controller_->CreateDtlsTransport(
- cricket::CN_AUDIO, cricket::ICE_CANDIDATE_COMPONENT_RTP);
- cricket::VoiceChannel* voice_channel = cm_->CreateVoiceChannel(
- &fake_call_, cricket::MediaConfig(),
- rtp_transport, nullptr /*rtcp_transport*/,
- rtc::Thread::Current(), cricket::CN_AUDIO, kDefaultSrtpRequired,
- AudioOptions());
- EXPECT_TRUE(voice_channel != nullptr);
- cricket::VideoChannel* video_channel = cm_->CreateVideoChannel(
- &fake_call_, cricket::MediaConfig(),
- rtp_transport, nullptr /*rtcp_transport*/,
- rtc::Thread::Current(), cricket::CN_VIDEO, kDefaultSrtpRequired,
- VideoOptions());
- EXPECT_TRUE(video_channel != nullptr);
- cricket::RtpDataChannel* rtp_data_channel = cm_->CreateRtpDataChannel(
- cricket::MediaConfig(), rtp_transport, nullptr /*rtcp_transport*/,
- rtc::Thread::Current(), cricket::CN_DATA, kDefaultSrtpRequired);
- EXPECT_TRUE(rtp_data_channel != nullptr);
- cm_->DestroyVideoChannel(video_channel);
- cm_->DestroyVoiceChannel(voice_channel);
- cm_->DestroyRtpDataChannel(rtp_data_channel);
- cm_->Terminate();
-}
-
-// Test that we can create and destroy a voice and video channel with a worker.
-TEST_F(ChannelManagerTest, CreateDestroyChannelsOnThread) {
- network_->Start();
- worker_->Start();
- EXPECT_TRUE(cm_->set_worker_thread(worker_.get()));
- EXPECT_TRUE(cm_->set_network_thread(network_.get()));
- EXPECT_TRUE(cm_->Init());
- transport_controller_.reset(new cricket::FakeTransportController(
- network_.get(), ICEROLE_CONTROLLING));
- cricket::DtlsTransportInternal* rtp_transport =
- transport_controller_->CreateDtlsTransport(
- cricket::CN_AUDIO, cricket::ICE_CANDIDATE_COMPONENT_RTP);
- cricket::VoiceChannel* voice_channel = cm_->CreateVoiceChannel(
- &fake_call_, cricket::MediaConfig(),
- rtp_transport, nullptr /*rtcp_transport*/,
- rtc::Thread::Current(), cricket::CN_AUDIO, kDefaultSrtpRequired,
- AudioOptions());
- EXPECT_TRUE(voice_channel != nullptr);
- cricket::VideoChannel* video_channel = cm_->CreateVideoChannel(
- &fake_call_, cricket::MediaConfig(),
- rtp_transport, nullptr /*rtcp_transport*/,
- rtc::Thread::Current(), cricket::CN_VIDEO, kDefaultSrtpRequired,
- VideoOptions());
- EXPECT_TRUE(video_channel != nullptr);
- cricket::RtpDataChannel* rtp_data_channel = cm_->CreateRtpDataChannel(
- cricket::MediaConfig(), rtp_transport, nullptr /*rtcp_transport*/,
- rtc::Thread::Current(), cricket::CN_DATA, kDefaultSrtpRequired);
- EXPECT_TRUE(rtp_data_channel != nullptr);
- cm_->DestroyVideoChannel(video_channel);
- cm_->DestroyVoiceChannel(voice_channel);
- cm_->DestroyRtpDataChannel(rtp_data_channel);
- cm_->Terminate();
-}
-
TEST_F(ChannelManagerTest, SetVideoRtxEnabled) {
std::vector<VideoCodec> codecs;
const VideoCodec rtx_codec(96, "rtx");
@@ -185,89 +156,20 @@
EXPECT_TRUE(ContainsMatchingCodec(codecs, rtx_codec));
}
-enum class RTPTransportType { kRtp, kSrtp, kDtlsSrtp };
-
-class ChannelManagerTestWithRtpTransport
- : public ChannelManagerTest,
- public ::testing::WithParamInterface<RTPTransportType> {
- public:
- std::unique_ptr<webrtc::RtpTransportInternal> CreateRtpTransport() {
- RTPTransportType type = GetParam();
- switch (type) {
- case RTPTransportType::kRtp:
- return CreatePlainRtpTransport();
- case RTPTransportType::kSrtp:
- return CreateSrtpTransport();
- case RTPTransportType::kDtlsSrtp:
- return CreateDtlsSrtpTransport();
- }
- return nullptr;
- }
-
- void TestCreateDestroyChannels(webrtc::RtpTransportInternal* rtp_transport) {
- cricket::VoiceChannel* voice_channel = cm_->CreateVoiceChannel(
- &fake_call_, cricket::MediaConfig(), rtp_transport,
- rtc::Thread::Current(), cricket::CN_AUDIO, kDefaultSrtpRequired,
- AudioOptions());
- EXPECT_TRUE(voice_channel != nullptr);
- cricket::VideoChannel* video_channel = cm_->CreateVideoChannel(
- &fake_call_, cricket::MediaConfig(), rtp_transport,
- rtc::Thread::Current(), cricket::CN_VIDEO, kDefaultSrtpRequired,
- VideoOptions());
- EXPECT_TRUE(video_channel != nullptr);
- cricket::RtpDataChannel* rtp_data_channel = cm_->CreateRtpDataChannel(
- cricket::MediaConfig(), rtp_transport, rtc::Thread::Current(),
- cricket::CN_DATA, kDefaultSrtpRequired);
- EXPECT_TRUE(rtp_data_channel != nullptr);
- cm_->DestroyVideoChannel(video_channel);
- cm_->DestroyVoiceChannel(voice_channel);
- cm_->DestroyRtpDataChannel(rtp_data_channel);
- cm_->Terminate();
- }
-
- private:
- std::unique_ptr<webrtc::RtpTransportInternal> CreatePlainRtpTransport() {
- return rtc::MakeUnique<webrtc::RtpTransport>(/*rtcp_mux_required=*/true);
- }
-
- std::unique_ptr<webrtc::RtpTransportInternal> CreateSrtpTransport() {
- auto rtp_transport =
- rtc::MakeUnique<webrtc::RtpTransport>(/*rtcp_mux_required=*/true);
- auto srtp_transport =
- rtc::MakeUnique<webrtc::SrtpTransport>(std::move(rtp_transport));
- return srtp_transport;
- }
-
- std::unique_ptr<webrtc::RtpTransportInternal> CreateDtlsSrtpTransport() {
- auto rtp_transport =
- rtc::MakeUnique<webrtc::RtpTransport>(/*rtcp_mux_required=*/true);
- auto srtp_transport =
- rtc::MakeUnique<webrtc::SrtpTransport>(std::move(rtp_transport));
- auto dtls_srtp_transport_ =
- rtc::MakeUnique<webrtc::DtlsSrtpTransport>(std::move(srtp_transport));
- return dtls_srtp_transport_;
- }
-};
-
-TEST_P(ChannelManagerTestWithRtpTransport, CreateDestroyChannels) {
+TEST_F(ChannelManagerTest, CreateDestroyChannels) {
EXPECT_TRUE(cm_->Init());
- auto rtp_transport = CreateRtpTransport();
+ auto rtp_transport = CreateDtlsSrtpTransport();
TestCreateDestroyChannels(rtp_transport.get());
}
-TEST_P(ChannelManagerTestWithRtpTransport, CreateDestroyChannelsOnThread) {
+TEST_F(ChannelManagerTest, CreateDestroyChannelsOnThread) {
network_->Start();
worker_->Start();
EXPECT_TRUE(cm_->set_worker_thread(worker_.get()));
EXPECT_TRUE(cm_->set_network_thread(network_.get()));
EXPECT_TRUE(cm_->Init());
- auto rtp_transport = CreateRtpTransport();
+ auto rtp_transport = CreateDtlsSrtpTransport();
TestCreateDestroyChannels(rtp_transport.get());
}
-INSTANTIATE_TEST_CASE_P(ChannelManagerTest,
- ChannelManagerTestWithRtpTransport,
- ::testing::Values(RTPTransportType::kRtp,
- RTPTransportType::kSrtp,
- RTPTransportType::kDtlsSrtp));
} // namespace cricket