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/rtpsenderreceiver_unittest.cc b/pc/rtpsenderreceiver_unittest.cc
index 279aba2..69089a5 100644
--- a/pc/rtpsenderreceiver_unittest.cc
+++ b/pc/rtpsenderreceiver_unittest.cc
@@ -16,6 +16,7 @@
#include "media/base/fakemediaengine.h"
#include "media/base/rtpdataengine.h"
#include "media/engine/fakewebrtccall.h"
+#include "p2p/base/fakedtlstransport.h"
#include "pc/audiotrack.h"
#include "pc/channelmanager.h"
#include "pc/localaudiosource.h"
@@ -24,7 +25,6 @@
#include "pc/rtpreceiver.h"
#include "pc/rtpsender.h"
#include "pc/streamcollection.h"
-#include "pc/test/faketransportcontroller.h"
#include "pc/test/fakevideotracksource.h"
#include "pc/videotrack.h"
#include "pc/videotracksource.h"
@@ -69,17 +69,18 @@
// Create channels to be used by the RtpSenders and RtpReceivers.
channel_manager_.Init();
bool srtp_required = true;
- cricket::DtlsTransportInternal* rtp_transport =
- fake_transport_controller_.CreateDtlsTransport(
- cricket::CN_AUDIO, cricket::ICE_CANDIDATE_COMPONENT_RTP);
+ rtp_dtls_transport_ = rtc::MakeUnique<cricket::FakeDtlsTransport>(
+ "fake_dtls_transport", cricket::ICE_CANDIDATE_COMPONENT_RTP);
+ rtp_transport_ = CreateDtlsSrtpTransport();
+
voice_channel_ = channel_manager_.CreateVoiceChannel(
- &fake_call_, cricket::MediaConfig(),
- rtp_transport, nullptr, rtc::Thread::Current(),
- cricket::CN_AUDIO, srtp_required, cricket::AudioOptions());
+ &fake_call_, cricket::MediaConfig(), rtp_transport_.get(),
+ rtc::Thread::Current(), cricket::CN_AUDIO, srtp_required,
+ rtc::CryptoOptions(), cricket::AudioOptions());
video_channel_ = channel_manager_.CreateVideoChannel(
- &fake_call_, cricket::MediaConfig(),
- rtp_transport, nullptr, rtc::Thread::Current(),
- cricket::CN_VIDEO, srtp_required, cricket::VideoOptions());
+ &fake_call_, cricket::MediaConfig(), rtp_transport_.get(),
+ rtc::Thread::Current(), cricket::CN_VIDEO, srtp_required,
+ rtc::CryptoOptions(), cricket::VideoOptions());
voice_channel_->Enable(true);
video_channel_->Enable(true);
voice_media_channel_ = media_engine_->GetVoiceChannel(0);
@@ -111,6 +112,18 @@
cricket::StreamParams::CreateLegacy(kVideoSsrc2));
}
+ 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));
+ dtls_srtp_transport->SetDtlsTransports(rtp_dtls_transport_.get(),
+ /*rtcp_dtls_transport=*/nullptr);
+ return dtls_srtp_transport;
+ }
+
// Needed to use DTMF sender.
void AddDtmfCodec() {
cricket::AudioSendParameters params;
@@ -268,9 +281,12 @@
rtc::Thread* const network_thread_;
rtc::Thread* const worker_thread_;
webrtc::RtcEventLogNullImpl event_log_;
+ // The |rtp_dtls_transport_| and |rtp_transport_| should be destroyed after
+ // the |channel_manager|.
+ std::unique_ptr<cricket::DtlsTransportInternal> rtp_dtls_transport_;
+ std::unique_ptr<webrtc::RtpTransportInternal> rtp_transport_;
// |media_engine_| is actually owned by |channel_manager_|.
cricket::FakeMediaEngine* media_engine_;
- cricket::FakeTransportController fake_transport_controller_;
cricket::ChannelManager channel_manager_;
cricket::FakeCall fake_call_;
cricket::VoiceChannel* voice_channel_;