Index: webrtc/ortc/rtptransportcontrolleradapter.cc |
diff --git a/webrtc/ortc/rtptransportcontrolleradapter.cc b/webrtc/ortc/rtptransportcontrolleradapter.cc |
index 08e943a200ad1249784dd9267c7e341b6ba7462d..ad5d8b5d68f813f890e9f99e1d9b3f001f6583b2 100644 |
--- a/webrtc/ortc/rtptransportcontrolleradapter.cc |
+++ b/webrtc/ortc/rtptransportcontrolleradapter.cc |
@@ -11,8 +11,8 @@ |
#include "webrtc/ortc/rtptransportcontrolleradapter.h" |
#include <algorithm> // For "remove", "find". |
-#include <sstream> |
#include <set> |
+#include <sstream> |
#include <unordered_map> |
#include <utility> // For std::move. |
@@ -138,6 +138,21 @@ RtpTransportControllerAdapter::CreateProxiedRtpTransport( |
return result; |
} |
+RTCErrorOr<std::unique_ptr<SrtpTransportInterface>> |
+RtpTransportControllerAdapter::CreateProxiedSrtpTransport( |
+ const RtcpParameters& rtcp_parameters, |
+ PacketTransportInterface* rtp, |
+ PacketTransportInterface* rtcp) { |
+ auto result = |
+ RtpTransportAdapter::CreateSrtpProxied(rtcp_parameters, rtp, rtcp, this); |
+ if (result.ok()) { |
+ transport_proxies_.push_back(result.value().get()); |
+ transport_proxies_.back()->GetInternal()->SignalDestroyed.connect( |
+ this, &RtpTransportControllerAdapter::OnRtpTransportDestroyed); |
+ } |
+ return result; |
+} |
+ |
RTCErrorOr<std::unique_ptr<OrtcRtpSenderInterface>> |
RtpTransportControllerAdapter::CreateProxiedRtpSender( |
cricket::MediaType kind, |
@@ -605,6 +620,11 @@ RTCError RtpTransportControllerAdapter::AttachAudioSender( |
"RtpSender and RtpReceiver is not currently " |
"supported."); |
} |
+ RTCError err = MaybeSetCryptos(inner_transport, &local_audio_description_, |
+ &remote_audio_description_); |
+ if (!err.ok()) { |
+ return err; |
+ } |
// If setting new transport, extract its RTCP parameters and create voice |
// channel. |
if (!inner_audio_transport_) { |
@@ -635,6 +655,11 @@ RTCError RtpTransportControllerAdapter::AttachVideoSender( |
"RtpSender and RtpReceiver is not currently " |
"supported."); |
} |
+ RTCError err = MaybeSetCryptos(inner_transport, &local_video_description_, |
+ &remote_video_description_); |
+ if (!err.ok()) { |
+ return err; |
+ } |
// If setting new transport, extract its RTCP parameters and create video |
// channel. |
if (!inner_video_transport_) { |
@@ -665,6 +690,11 @@ RTCError RtpTransportControllerAdapter::AttachAudioReceiver( |
"RtpReceiver and RtpReceiver is not currently " |
"supported."); |
} |
+ RTCError err = MaybeSetCryptos(inner_transport, &local_audio_description_, |
+ &remote_audio_description_); |
+ if (!err.ok()) { |
+ return err; |
+ } |
// If setting new transport, extract its RTCP parameters and create voice |
// channel. |
if (!inner_audio_transport_) { |
@@ -695,6 +725,11 @@ RTCError RtpTransportControllerAdapter::AttachVideoReceiver( |
"RtpReceiver and RtpReceiver is not currently " |
"supported."); |
} |
+ RTCError err = MaybeSetCryptos(inner_transport, &local_video_description_, |
+ &remote_video_description_); |
+ if (!err.ok()) { |
+ return err; |
+ } |
// If setting new transport, extract its RTCP parameters and create video |
// channel. |
if (!inner_video_transport_) { |
@@ -896,4 +931,25 @@ RtpTransportControllerAdapter::MakeSendStreamParamsVec( |
return result; |
} |
+RTCError RtpTransportControllerAdapter::MaybeSetCryptos( |
+ RtpTransportInterface* rtp_transport, |
+ cricket::MediaContentDescription* local_description, |
+ cricket::MediaContentDescription* remote_description) { |
+ if (rtp_transport->GetInternal()->is_srtp_transport()) { |
+ if (!rtp_transport->GetInternal()->send_key() || |
+ !rtp_transport->GetInternal()->receive_key()) { |
+ LOG_AND_RETURN_ERROR(webrtc::RTCErrorType::UNSUPPORTED_PARAMETER, |
+ "The SRTP send key or receive key is not set.") |
+ } |
+ std::vector<cricket::CryptoParams> cryptos; |
+ cryptos.push_back(*(rtp_transport->GetInternal()->receive_key())); |
+ local_description->set_cryptos(cryptos); |
+ |
+ cryptos.clear(); |
+ cryptos.push_back(*(rtp_transport->GetInternal()->send_key())); |
+ remote_description->set_cryptos(cryptos); |
+ } |
+ return RTCError::OK(); |
+} |
+ |
} // namespace webrtc |