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), | |
138 have_send_key_(false), | |
139 have_receive_key_(false) { | |
86 RTC_DCHECK(rtp_transport_controller); | 140 RTC_DCHECK(rtp_transport_controller); |
87 // CNAME should have been filled by OrtcFactory if empty. | 141 // CNAME should have been filled by OrtcFactory if empty. |
88 RTC_DCHECK(!rtcp_parameters_.cname.empty()); | 142 RTC_DCHECK(!rtcp_parameters_.cname.empty()); |
89 } | 143 } |
90 | 144 |
91 RtpTransportAdapter::~RtpTransportAdapter() { | 145 RtpTransportAdapter::~RtpTransportAdapter() { |
92 SignalDestroyed(this); | 146 SignalDestroyed(this); |
93 } | 147 } |
94 | 148 |
95 PacketTransportInterface* RtpTransportAdapter::GetRtpPacketTransport() const { | 149 PacketTransportInterface* RtpTransportAdapter::GetRtpPacketTransport() const { |
(...skipping 23 matching lines...) Expand all Loading... | |
119 if (!err.ok()) { | 173 if (!err.ok()) { |
120 return err; | 174 return err; |
121 } | 175 } |
122 rtcp_parameters_ = copy; | 176 rtcp_parameters_ = copy; |
123 if (rtcp_parameters_.mux) { | 177 if (rtcp_parameters_.mux) { |
124 rtcp_packet_transport_ = nullptr; | 178 rtcp_packet_transport_ = nullptr; |
125 } | 179 } |
126 return RTCError::OK(); | 180 return RTCError::OK(); |
127 } | 181 } |
128 | 182 |
183 RTCError RtpTransportAdapter::SetSrtpSendKey( | |
184 const cricket::CryptoParams& params) { | |
185 if (have_send_key_) { | |
186 LOG_AND_RETURN_ERROR( | |
187 webrtc::RTCErrorType::UNSUPPORTED_OPERATION, | |
188 "Setting the SRTP send key twice is currently unsupported."); | |
189 } | |
Taylor Brandstetter
2017/03/01 19:18:08
I think it would make sense to check that the cryp
Zhi Huang
2017/03/02 23:35:39
Done.
| |
190 send_key_ = params; | |
191 have_send_key_ = true; | |
192 return RTCError::OK(); | |
193 } | |
194 | |
195 RTCError RtpTransportAdapter::SetSrtpReceiveKey( | |
196 const cricket::CryptoParams& params) { | |
197 if (have_receive_key_) { | |
198 LOG_AND_RETURN_ERROR( | |
199 webrtc::RTCErrorType::UNSUPPORTED_OPERATION, | |
200 "Setting the SRTP receive key twice is currently unsupported."); | |
201 } | |
202 receive_key_ = params; | |
203 have_receive_key_ = true; | |
204 return RTCError::OK(); | |
205 } | |
206 | |
129 } // namespace webrtc | 207 } // namespace webrtc |
OLD | NEW |