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}
This commit is contained in:
Zhi Huang
2018-03-30 10:48:35 -07:00
committed by Commit Bot
parent 80e9339e39
commit e830e683c4
51 changed files with 1604 additions and 6969 deletions

View File

@ -17,6 +17,7 @@
#include "api/proxy.h"
#include "rtc_base/logging.h"
#include "rtc_base/ptr_util.h"
namespace webrtc {
@ -115,10 +116,11 @@ RtpTransportAdapter::CreateSrtpProxied(
LOG_AND_RETURN_ERROR(RTCErrorType::INVALID_PARAMETER,
"Must provide an RTP transport controller.");
}
std::unique_ptr<RtpTransportAdapter> transport_adapter(
new RtpTransportAdapter(parameters.rtcp, rtp, rtcp,
rtp_transport_controller,
true /*is_srtp_transport*/));
std::unique_ptr<RtpTransportAdapter> transport_adapter;
transport_adapter.reset(new RtpTransportAdapter(parameters.rtcp, rtp, rtcp,
rtp_transport_controller,
true /*is_srtp_transport*/));
RTCError params_result = transport_adapter->SetParameters(parameters);
if (!params_result.ok()) {
return std::move(params_result);
@ -145,25 +147,40 @@ RtpTransportAdapter::RtpTransportAdapter(
: rtp_packet_transport_(rtp),
rtcp_packet_transport_(rtcp),
rtp_transport_controller_(rtp_transport_controller),
is_srtp_transport_(is_srtp_transport) {
network_thread_(rtp_transport_controller_->network_thread()) {
parameters_.rtcp = rtcp_params;
// CNAME should have been filled by OrtcFactory if empty.
RTC_DCHECK(!parameters_.rtcp.cname.empty());
RTC_DCHECK(rtp_transport_controller);
if (is_srtp_transport) {
srtp_transport_ = rtc::MakeUnique<SrtpTransport>(rtcp == nullptr);
transport_ = srtp_transport_.get();
} else {
unencrypted_rtp_transport_ = rtc::MakeUnique<RtpTransport>(rtcp == nullptr);
transport_ = unencrypted_rtp_transport_.get();
}
RTC_DCHECK(transport_);
network_thread_->Invoke<void>(RTC_FROM_HERE, [=] {
SetRtpPacketTransport(rtp->GetInternal());
if (rtcp) {
SetRtcpPacketTransport(rtcp->GetInternal());
}
});
transport_->SignalReadyToSend.connect(this,
&RtpTransportAdapter::OnReadyToSend);
transport_->SignalPacketReceived.connect(
this, &RtpTransportAdapter::OnPacketReceived);
transport_->SignalWritableState.connect(
this, &RtpTransportAdapter::OnWritableState);
}
RtpTransportAdapter::~RtpTransportAdapter() {
SignalDestroyed(this);
}
PacketTransportInterface* RtpTransportAdapter::GetRtpPacketTransport() const {
return rtp_packet_transport_;
}
PacketTransportInterface* RtpTransportAdapter::GetRtcpPacketTransport() const {
return rtcp_packet_transport_;
}
RTCError RtpTransportAdapter::SetParameters(
const RtpTransportParameters& parameters) {
if (!parameters.rtcp.mux && parameters_.rtcp.mux) {
@ -194,34 +211,20 @@ RTCError RtpTransportAdapter::SetParameters(
RTCError RtpTransportAdapter::SetSrtpSendKey(
const cricket::CryptoParams& params) {
if (send_key_) {
LOG_AND_RETURN_ERROR(
webrtc::RTCErrorType::UNSUPPORTED_OPERATION,
"Setting the SRTP send key twice is currently unsupported.");
if (!network_thread_->IsCurrent()) {
return network_thread_->Invoke<RTCError>(
RTC_FROM_HERE, [&] { return SetSrtpSendKey(params); });
}
if (receive_key_ && receive_key_->cipher_suite != params.cipher_suite) {
LOG_AND_RETURN_ERROR(
webrtc::RTCErrorType::UNSUPPORTED_OPERATION,
"The send key and receive key must have the same cipher suite.");
}
send_key_ = params;
return RTCError::OK();
return transport_->SetSrtpSendKey(params);
}
RTCError RtpTransportAdapter::SetSrtpReceiveKey(
const cricket::CryptoParams& params) {
if (receive_key_) {
LOG_AND_RETURN_ERROR(
webrtc::RTCErrorType::UNSUPPORTED_OPERATION,
"Setting the SRTP receive key twice is currently unsupported.");
if (!network_thread_->IsCurrent()) {
return network_thread_->Invoke<RTCError>(
RTC_FROM_HERE, [&] { return SetSrtpReceiveKey(params); });
}
if (send_key_ && send_key_->cipher_suite != params.cipher_suite) {
LOG_AND_RETURN_ERROR(
webrtc::RTCErrorType::UNSUPPORTED_OPERATION,
"The send key and receive key must have the same cipher suite.");
}
receive_key_ = params;
return RTCError::OK();
return transport_->SetSrtpReceiveKey(params);
}
} // namespace webrtc