| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2017 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2017 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 PROXY_CONSTMETHOD0(PacketTransportInterface*, GetRtpPacketTransport) | 25 PROXY_CONSTMETHOD0(PacketTransportInterface*, GetRtpPacketTransport) |
| 26 PROXY_CONSTMETHOD0(PacketTransportInterface*, GetRtcpPacketTransport) | 26 PROXY_CONSTMETHOD0(PacketTransportInterface*, GetRtcpPacketTransport) |
| 27 PROXY_METHOD1(RTCError, SetRtcpParameters, const RtcpParameters&) | 27 PROXY_METHOD1(RTCError, SetRtcpParameters, const RtcpParameters&) |
| 28 PROXY_CONSTMETHOD0(RtcpParameters, GetRtcpParameters) | 28 PROXY_CONSTMETHOD0(RtcpParameters, GetRtcpParameters) |
| 29 protected: | 29 protected: |
| 30 RtpTransportAdapter* GetInternal() override { | 30 RtpTransportAdapter* GetInternal() override { |
| 31 return internal(); | 31 return internal(); |
| 32 } | 32 } |
| 33 END_PROXY_MAP() | 33 END_PROXY_MAP() |
| 34 | 34 |
| 35 BEGIN_OWNED_PROXY_MAP(SrtpTransport) |
| 36 PROXY_SIGNALING_THREAD_DESTRUCTOR() |
| 37 PROXY_CONSTMETHOD0(PacketTransportInterface*, GetRtpPacketTransport) |
| 38 PROXY_CONSTMETHOD0(PacketTransportInterface*, GetRtcpPacketTransport) |
| 39 PROXY_METHOD1(RTCError, SetRtcpParameters, const RtcpParameters&) |
| 40 PROXY_CONSTMETHOD0(RtcpParameters, GetRtcpParameters) |
| 41 PROXY_METHOD1(RTCError, SetSrtpSendKey, const cricket::CryptoParams&) |
| 42 PROXY_METHOD1(RTCError, SetSrtpReceiveKey, const cricket::CryptoParams&) |
| 43 protected: |
| 44 RtpTransportAdapter* GetInternal() override { |
| 45 return internal(); |
| 46 } |
| 47 END_PROXY_MAP() |
| 48 |
| 35 // static | 49 // static |
| 36 RTCErrorOr<std::unique_ptr<RtpTransportInterface>> | 50 RTCErrorOr<std::unique_ptr<RtpTransportInterface>> |
| 37 RtpTransportAdapter::CreateProxied( | 51 RtpTransportAdapter::CreateProxied( |
| 38 const RtcpParameters& rtcp_parameters, | 52 const RtcpParameters& rtcp_parameters, |
| 39 PacketTransportInterface* rtp, | 53 PacketTransportInterface* rtp, |
| 40 PacketTransportInterface* rtcp, | 54 PacketTransportInterface* rtcp, |
| 41 RtpTransportControllerAdapter* rtp_transport_controller) { | 55 RtpTransportControllerAdapter* rtp_transport_controller) { |
| 42 if (!rtp) { | 56 if (!rtp) { |
| 43 LOG_AND_RETURN_ERROR(RTCErrorType::INVALID_PARAMETER, | 57 LOG_AND_RETURN_ERROR(RTCErrorType::INVALID_PARAMETER, |
| 44 "Must provide an RTP packet transport."); | 58 "Must provide an RTP packet transport."); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 57 // Since OrtcFactory::CreateRtpTransport creates an RtpTransportController | 71 // Since OrtcFactory::CreateRtpTransport creates an RtpTransportController |
| 58 // automatically when one isn't passed in, this should never be reached. | 72 // automatically when one isn't passed in, this should never be reached. |
| 59 RTC_NOTREACHED(); | 73 RTC_NOTREACHED(); |
| 60 LOG_AND_RETURN_ERROR(RTCErrorType::INVALID_PARAMETER, | 74 LOG_AND_RETURN_ERROR(RTCErrorType::INVALID_PARAMETER, |
| 61 "Must provide an RTP transport controller."); | 75 "Must provide an RTP transport controller."); |
| 62 } | 76 } |
| 63 return RtpTransportProxyWithInternal<RtpTransportAdapter>::Create( | 77 return RtpTransportProxyWithInternal<RtpTransportAdapter>::Create( |
| 64 rtp_transport_controller->signaling_thread(), | 78 rtp_transport_controller->signaling_thread(), |
| 65 rtp_transport_controller->worker_thread(), | 79 rtp_transport_controller->worker_thread(), |
| 66 std::unique_ptr<RtpTransportAdapter>(new RtpTransportAdapter( | 80 std::unique_ptr<RtpTransportAdapter>(new RtpTransportAdapter( |
| 67 rtcp_parameters, rtp, rtcp, rtp_transport_controller))); | 81 rtcp_parameters, rtp, rtcp, rtp_transport_controller, |
| 82 /*is_srtp_transport*/ false))); |
| 83 } |
| 84 |
| 85 RTCErrorOr<std::unique_ptr<SrtpTransportInterface>> |
| 86 RtpTransportAdapter::CreateSrtpProxied( |
| 87 const RtcpParameters& rtcp_parameters, |
| 88 PacketTransportInterface* rtp, |
| 89 PacketTransportInterface* rtcp, |
| 90 RtpTransportControllerAdapter* rtp_transport_controller) { |
| 91 if (!rtp) { |
| 92 LOG_AND_RETURN_ERROR(RTCErrorType::INVALID_PARAMETER, |
| 93 "Must provide an RTP packet transport."); |
| 94 } |
| 95 if (!rtcp_parameters.mux && !rtcp) { |
| 96 LOG_AND_RETURN_ERROR( |
| 97 RTCErrorType::INVALID_PARAMETER, |
| 98 "Must provide an RTCP packet transport when RTCP muxing is not used."); |
| 99 } |
| 100 if (rtcp_parameters.mux && rtcp) { |
| 101 LOG_AND_RETURN_ERROR(RTCErrorType::INVALID_PARAMETER, |
| 102 "Creating an RtpTransport with RTCP muxing enabled, " |
| 103 "with a separate RTCP packet transport?"); |
| 104 } |
| 105 if (!rtp_transport_controller) { |
| 106 // Since OrtcFactory::CreateRtpTransport creates an RtpTransportController |
| 107 // automatically when one isn't passed in, this should never be reached. |
| 108 RTC_NOTREACHED(); |
| 109 LOG_AND_RETURN_ERROR(RTCErrorType::INVALID_PARAMETER, |
| 110 "Must provide an RTP transport controller."); |
| 111 } |
| 112 return SrtpTransportProxyWithInternal<RtpTransportAdapter>::Create( |
| 113 rtp_transport_controller->signaling_thread(), |
| 114 rtp_transport_controller->worker_thread(), |
| 115 std::unique_ptr<RtpTransportAdapter>(new RtpTransportAdapter( |
| 116 rtcp_parameters, rtp, rtcp, rtp_transport_controller, |
| 117 /*is_srtp_transport*/ true))); |
| 68 } | 118 } |
| 69 | 119 |
| 70 void RtpTransportAdapter::TakeOwnershipOfRtpTransportController( | 120 void RtpTransportAdapter::TakeOwnershipOfRtpTransportController( |
| 71 std::unique_ptr<RtpTransportControllerInterface> controller) { | 121 std::unique_ptr<RtpTransportControllerInterface> controller) { |
| 72 RTC_DCHECK_EQ(rtp_transport_controller_, controller->GetInternal()); | 122 RTC_DCHECK_EQ(rtp_transport_controller_, controller->GetInternal()); |
| 73 RTC_DCHECK(owned_rtp_transport_controller_.get() == nullptr); | 123 RTC_DCHECK(owned_rtp_transport_controller_.get() == nullptr); |
| 74 owned_rtp_transport_controller_ = std::move(controller); | 124 owned_rtp_transport_controller_ = std::move(controller); |
| 75 } | 125 } |
| 76 | 126 |
| 77 RtpTransportAdapter::RtpTransportAdapter( | 127 RtpTransportAdapter::RtpTransportAdapter( |
| 78 const RtcpParameters& rtcp_parameters, | 128 const RtcpParameters& rtcp_parameters, |
| 79 PacketTransportInterface* rtp, | 129 PacketTransportInterface* rtp, |
| 80 PacketTransportInterface* rtcp, | 130 PacketTransportInterface* rtcp, |
| 81 RtpTransportControllerAdapter* rtp_transport_controller) | 131 RtpTransportControllerAdapter* rtp_transport_controller, |
| 132 bool is_srtp_transport) |
| 82 : rtp_packet_transport_(rtp), | 133 : rtp_packet_transport_(rtp), |
| 83 rtcp_packet_transport_(rtcp), | 134 rtcp_packet_transport_(rtcp), |
| 84 rtp_transport_controller_(rtp_transport_controller), | 135 rtp_transport_controller_(rtp_transport_controller), |
| 85 rtcp_parameters_(rtcp_parameters) { | 136 rtcp_parameters_(rtcp_parameters), |
| 137 is_srtp_transport_(is_srtp_transport) { |
| 86 RTC_DCHECK(rtp_transport_controller); | 138 RTC_DCHECK(rtp_transport_controller); |
| 87 // CNAME should have been filled by OrtcFactory if empty. | 139 // CNAME should have been filled by OrtcFactory if empty. |
| 88 RTC_DCHECK(!rtcp_parameters_.cname.empty()); | 140 RTC_DCHECK(!rtcp_parameters_.cname.empty()); |
| 89 } | 141 } |
| 90 | 142 |
| 91 RtpTransportAdapter::~RtpTransportAdapter() { | 143 RtpTransportAdapter::~RtpTransportAdapter() { |
| 92 SignalDestroyed(this); | 144 SignalDestroyed(this); |
| 93 } | 145 } |
| 94 | 146 |
| 95 PacketTransportInterface* RtpTransportAdapter::GetRtpPacketTransport() const { | 147 PacketTransportInterface* RtpTransportAdapter::GetRtpPacketTransport() const { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 119 if (!err.ok()) { | 171 if (!err.ok()) { |
| 120 return err; | 172 return err; |
| 121 } | 173 } |
| 122 rtcp_parameters_ = copy; | 174 rtcp_parameters_ = copy; |
| 123 if (rtcp_parameters_.mux) { | 175 if (rtcp_parameters_.mux) { |
| 124 rtcp_packet_transport_ = nullptr; | 176 rtcp_packet_transport_ = nullptr; |
| 125 } | 177 } |
| 126 return RTCError::OK(); | 178 return RTCError::OK(); |
| 127 } | 179 } |
| 128 | 180 |
| 181 RTCError RtpTransportAdapter::SetSrtpSendKey( |
| 182 const cricket::CryptoParams& params) { |
| 183 if (send_key_) { |
| 184 LOG_AND_RETURN_ERROR( |
| 185 webrtc::RTCErrorType::UNSUPPORTED_OPERATION, |
| 186 "Setting the SRTP send key twice is currently unsupported."); |
| 187 } |
| 188 if (receive_key_ && receive_key_->cipher_suite != params.cipher_suite) { |
| 189 LOG_AND_RETURN_ERROR( |
| 190 webrtc::RTCErrorType::UNSUPPORTED_OPERATION, |
| 191 "The send key and receive key must have the same cipher suite."); |
| 192 } |
| 193 send_key_ = rtc::Optional<cricket::CryptoParams>(params); |
| 194 return RTCError::OK(); |
| 195 } |
| 196 |
| 197 RTCError RtpTransportAdapter::SetSrtpReceiveKey( |
| 198 const cricket::CryptoParams& params) { |
| 199 if (receive_key_) { |
| 200 LOG_AND_RETURN_ERROR( |
| 201 webrtc::RTCErrorType::UNSUPPORTED_OPERATION, |
| 202 "Setting the SRTP receive key twice is currently unsupported."); |
| 203 } |
| 204 if (send_key_ && send_key_->cipher_suite != params.cipher_suite) { |
| 205 LOG_AND_RETURN_ERROR( |
| 206 webrtc::RTCErrorType::UNSUPPORTED_OPERATION, |
| 207 "The send key and receive key must have the same cipher suite."); |
| 208 } |
| 209 receive_key_ = rtc::Optional<cricket::CryptoParams>(params); |
| 210 return RTCError::OK(); |
| 211 } |
| 212 |
| 129 } // namespace webrtc | 213 } // namespace webrtc |
| OLD | NEW |