OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2009 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2009 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 |
11 #include <memory> | 11 #include <memory> |
12 | 12 |
13 #include "webrtc/base/array_view.h" | 13 #include "webrtc/base/array_view.h" |
14 #include "webrtc/base/buffer.h" | 14 #include "webrtc/base/buffer.h" |
15 #include "webrtc/base/checks.h" | 15 #include "webrtc/base/checks.h" |
16 #include "webrtc/base/fakeclock.h" | 16 #include "webrtc/base/fakeclock.h" |
17 #include "webrtc/base/gunit.h" | 17 #include "webrtc/base/gunit.h" |
18 #include "webrtc/base/logging.h" | 18 #include "webrtc/base/logging.h" |
19 #include "webrtc/base/sslstreamadapter.h" | 19 #include "webrtc/base/sslstreamadapter.h" |
20 #include "webrtc/media/base/fakemediaengine.h" | 20 #include "webrtc/media/base/fakemediaengine.h" |
21 #include "webrtc/media/base/fakertp.h" | 21 #include "webrtc/media/base/fakertp.h" |
22 #include "webrtc/media/base/mediachannel.h" | 22 #include "webrtc/media/base/mediachannel.h" |
23 #include "webrtc/media/base/testutils.h" | 23 #include "webrtc/media/base/testutils.h" |
24 #include "webrtc/p2p/base/dtlstransportinternal.h" | 24 #include "webrtc/p2p/base/fakecandidatepair.h" |
25 #include "webrtc/p2p/base/faketransportcontroller.h" | 25 #include "webrtc/p2p/base/fakedtlstransport.h" |
| 26 #include "webrtc/p2p/base/fakepackettransport.h" |
26 #include "webrtc/pc/channel.h" | 27 #include "webrtc/pc/channel.h" |
27 | 28 |
28 using cricket::CA_OFFER; | 29 using cricket::CA_OFFER; |
29 using cricket::CA_PRANSWER; | 30 using cricket::CA_PRANSWER; |
30 using cricket::CA_ANSWER; | 31 using cricket::CA_ANSWER; |
31 using cricket::CA_UPDATE; | 32 using cricket::CA_UPDATE; |
32 using cricket::DtlsTransportInternal; | 33 using cricket::DtlsTransportInternal; |
33 using cricket::FakeVoiceMediaChannel; | 34 using cricket::FakeVoiceMediaChannel; |
34 using cricket::StreamParams; | 35 using cricket::StreamParams; |
35 | 36 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 // Base class for Voice/Video/RtpDataChannel tests | 90 // Base class for Voice/Video/RtpDataChannel tests |
90 template<class T> | 91 template<class T> |
91 class ChannelTest : public testing::Test, public sigslot::has_slots<> { | 92 class ChannelTest : public testing::Test, public sigslot::has_slots<> { |
92 public: | 93 public: |
93 enum Flags { | 94 enum Flags { |
94 RTCP_MUX = 0x1, | 95 RTCP_MUX = 0x1, |
95 RTCP_MUX_REQUIRED = 0x2, | 96 RTCP_MUX_REQUIRED = 0x2, |
96 SECURE = 0x4, | 97 SECURE = 0x4, |
97 SSRC_MUX = 0x8, | 98 SSRC_MUX = 0x8, |
98 DTLS = 0x10, | 99 DTLS = 0x10, |
99 GCM_CIPHER = 0x20 | 100 GCM_CIPHER = 0x20, |
| 101 // Use BaseChannel with PacketTransportInterface rather than |
| 102 // DtlsTransportInternal. |
| 103 RAW_PACKET_TRANSPORT = 0x40, |
100 }; | 104 }; |
101 | 105 |
102 ChannelTest(bool verify_playout, | 106 ChannelTest(bool verify_playout, |
103 rtc::ArrayView<const uint8_t> rtp_data, | 107 rtc::ArrayView<const uint8_t> rtp_data, |
104 rtc::ArrayView<const uint8_t> rtcp_data, | 108 rtc::ArrayView<const uint8_t> rtcp_data, |
105 NetworkIsWorker network_is_worker) | 109 NetworkIsWorker network_is_worker) |
106 : verify_playout_(verify_playout), | 110 : verify_playout_(verify_playout), |
107 media_channel1_(NULL), | |
108 media_channel2_(NULL), | |
109 rtp_packet_(rtp_data.data(), rtp_data.size()), | 111 rtp_packet_(rtp_data.data(), rtp_data.size()), |
110 rtcp_packet_(rtcp_data.data(), rtcp_data.size()), | 112 rtcp_packet_(rtcp_data.data(), rtcp_data.size()) { |
111 media_info_callbacks1_(), | |
112 media_info_callbacks2_() { | |
113 if (network_is_worker == NetworkIsWorker::Yes) { | 113 if (network_is_worker == NetworkIsWorker::Yes) { |
114 network_thread_ = rtc::Thread::Current(); | 114 network_thread_ = rtc::Thread::Current(); |
115 } else { | 115 } else { |
116 network_thread_keeper_ = rtc::Thread::Create(); | 116 network_thread_keeper_ = rtc::Thread::Create(); |
117 network_thread_keeper_->SetName("Network", nullptr); | 117 network_thread_keeper_->SetName("Network", nullptr); |
118 network_thread_keeper_->Start(); | |
119 network_thread_ = network_thread_keeper_.get(); | 118 network_thread_ = network_thread_keeper_.get(); |
120 } | 119 } |
121 transport_controller1_.reset(new cricket::FakeTransportController( | |
122 network_thread_, cricket::ICEROLE_CONTROLLING)); | |
123 transport_controller2_.reset(new cricket::FakeTransportController( | |
124 network_thread_, cricket::ICEROLE_CONTROLLED)); | |
125 } | 120 } |
126 | 121 |
127 void CreateChannels(int flags1, int flags2) { | 122 void CreateChannels(int flags1, int flags2) { |
128 CreateChannels(new typename T::MediaChannel(NULL, typename T::Options()), | 123 CreateChannels(new typename T::MediaChannel(NULL, typename T::Options()), |
129 new typename T::MediaChannel(NULL, typename T::Options()), | 124 new typename T::MediaChannel(NULL, typename T::Options()), |
130 flags1, flags2); | 125 flags1, flags2); |
131 } | 126 } |
132 void CreateChannels(typename T::MediaChannel* ch1, | 127 void CreateChannels(typename T::MediaChannel* ch1, |
133 typename T::MediaChannel* ch2, | 128 typename T::MediaChannel* ch2, |
134 int flags1, | 129 int flags1, |
135 int flags2) { | 130 int flags2) { |
| 131 // Network thread is started in CreateChannels, to allow the test to |
| 132 // configure a fake clock before any threads are spawned and attempt to |
| 133 // access the time. |
| 134 if (network_thread_keeper_) { |
| 135 network_thread_keeper_->Start(); |
| 136 } |
136 // Make sure RTCP_MUX_REQUIRED isn't set without RTCP_MUX. | 137 // Make sure RTCP_MUX_REQUIRED isn't set without RTCP_MUX. |
137 ASSERT_NE(RTCP_MUX_REQUIRED, flags1 & (RTCP_MUX | RTCP_MUX_REQUIRED)); | 138 RTC_DCHECK_NE(RTCP_MUX_REQUIRED, flags1 & (RTCP_MUX | RTCP_MUX_REQUIRED)); |
138 ASSERT_NE(RTCP_MUX_REQUIRED, flags2 & (RTCP_MUX | RTCP_MUX_REQUIRED)); | 139 RTC_DCHECK_NE(RTCP_MUX_REQUIRED, flags2 & (RTCP_MUX | RTCP_MUX_REQUIRED)); |
| 140 // Make sure if using raw packet transports, they're used for both |
| 141 // channels. |
| 142 RTC_DCHECK_EQ(flags1 & RAW_PACKET_TRANSPORT, flags2 & RAW_PACKET_TRANSPORT); |
139 rtc::Thread* worker_thread = rtc::Thread::Current(); | 143 rtc::Thread* worker_thread = rtc::Thread::Current(); |
140 media_channel1_ = ch1; | 144 media_channel1_ = ch1; |
141 media_channel2_ = ch2; | 145 media_channel2_ = ch2; |
| 146 rtc::PacketTransportInterface* rtp1 = nullptr; |
| 147 rtc::PacketTransportInterface* rtcp1 = nullptr; |
| 148 rtc::PacketTransportInterface* rtp2 = nullptr; |
| 149 rtc::PacketTransportInterface* rtcp2 = nullptr; |
| 150 // Based on flags, create fake DTLS or raw packet transports. |
| 151 if (flags1 & RAW_PACKET_TRANSPORT) { |
| 152 fake_rtp_packet_transport1_.reset( |
| 153 new rtc::FakePacketTransport("channel1_rtp")); |
| 154 rtp1 = fake_rtp_packet_transport1_.get(); |
| 155 if (!(flags1 & RTCP_MUX_REQUIRED)) { |
| 156 fake_rtcp_packet_transport1_.reset( |
| 157 new rtc::FakePacketTransport("channel1_rtcp")); |
| 158 rtcp1 = fake_rtcp_packet_transport1_.get(); |
| 159 } |
| 160 } else { |
| 161 // Confirmed to work with KT_RSA and KT_ECDSA. |
| 162 fake_rtp_dtls_transport1_.reset(new cricket::FakeDtlsTransport( |
| 163 "channel1", cricket::ICE_CANDIDATE_COMPONENT_RTP)); |
| 164 rtp1 = fake_rtp_dtls_transport1_.get(); |
| 165 if (!(flags1 & RTCP_MUX_REQUIRED)) { |
| 166 fake_rtcp_dtls_transport1_.reset(new cricket::FakeDtlsTransport( |
| 167 "channel1", cricket::ICE_CANDIDATE_COMPONENT_RTCP)); |
| 168 rtcp1 = fake_rtcp_dtls_transport1_.get(); |
| 169 } |
| 170 if (flags1 & DTLS) { |
| 171 auto cert1 = |
| 172 rtc::RTCCertificate::Create(std::unique_ptr<rtc::SSLIdentity>( |
| 173 rtc::SSLIdentity::Generate("session1", rtc::KT_DEFAULT))); |
| 174 fake_rtp_dtls_transport1_->SetLocalCertificate(cert1); |
| 175 if (fake_rtcp_dtls_transport1_) { |
| 176 fake_rtcp_dtls_transport1_->SetLocalCertificate(cert1); |
| 177 } |
| 178 } |
| 179 } |
| 180 // Based on flags, create fake DTLS or raw packet transports. |
| 181 if (flags2 & RAW_PACKET_TRANSPORT) { |
| 182 fake_rtp_packet_transport2_.reset( |
| 183 new rtc::FakePacketTransport("channel2_rtp")); |
| 184 rtp2 = fake_rtp_packet_transport2_.get(); |
| 185 if (!(flags2 & RTCP_MUX_REQUIRED)) { |
| 186 fake_rtcp_packet_transport2_.reset( |
| 187 new rtc::FakePacketTransport("channel2_rtcp")); |
| 188 rtcp2 = fake_rtcp_packet_transport2_.get(); |
| 189 } |
| 190 } else { |
| 191 // Confirmed to work with KT_RSA and KT_ECDSA. |
| 192 fake_rtp_dtls_transport2_.reset(new cricket::FakeDtlsTransport( |
| 193 "channel2", cricket::ICE_CANDIDATE_COMPONENT_RTP)); |
| 194 rtp2 = fake_rtp_dtls_transport2_.get(); |
| 195 if (!(flags2 & RTCP_MUX_REQUIRED)) { |
| 196 fake_rtcp_dtls_transport2_.reset(new cricket::FakeDtlsTransport( |
| 197 "channel2", cricket::ICE_CANDIDATE_COMPONENT_RTCP)); |
| 198 rtcp2 = fake_rtcp_dtls_transport2_.get(); |
| 199 } |
| 200 if (flags2 & DTLS) { |
| 201 auto cert2 = |
| 202 rtc::RTCCertificate::Create(std::unique_ptr<rtc::SSLIdentity>( |
| 203 rtc::SSLIdentity::Generate("session2", rtc::KT_DEFAULT))); |
| 204 fake_rtp_dtls_transport2_->SetLocalCertificate(cert2); |
| 205 if (fake_rtcp_dtls_transport2_) { |
| 206 fake_rtcp_dtls_transport2_->SetLocalCertificate(cert2); |
| 207 } |
| 208 } |
| 209 } |
142 channel1_.reset( | 210 channel1_.reset( |
143 CreateChannel(worker_thread, network_thread_, &media_engine_, ch1, | 211 CreateChannel(worker_thread, network_thread_, &media_engine_, ch1, |
144 transport_controller1_.get(), flags1)); | 212 fake_rtp_dtls_transport1_.get(), |
| 213 fake_rtcp_dtls_transport1_.get(), rtp1, rtcp1, flags1)); |
145 channel2_.reset( | 214 channel2_.reset( |
146 CreateChannel(worker_thread, network_thread_, &media_engine_, ch2, | 215 CreateChannel(worker_thread, network_thread_, &media_engine_, ch2, |
147 transport_controller2_.get(), flags2)); | 216 fake_rtp_dtls_transport2_.get(), |
| 217 fake_rtcp_dtls_transport2_.get(), rtp2, rtcp2, flags2)); |
148 channel1_->SignalMediaMonitor.connect(this, | 218 channel1_->SignalMediaMonitor.connect(this, |
149 &ChannelTest<T>::OnMediaMonitor1); | 219 &ChannelTest<T>::OnMediaMonitor1); |
150 channel2_->SignalMediaMonitor.connect(this, | 220 channel2_->SignalMediaMonitor.connect(this, |
151 &ChannelTest<T>::OnMediaMonitor2); | 221 &ChannelTest<T>::OnMediaMonitor2); |
152 channel1_->SignalRtcpMuxFullyActive.connect( | 222 channel1_->SignalRtcpMuxFullyActive.connect( |
153 transport_controller1_.get(), | 223 this, &ChannelTest<T>::OnRtcpMuxFullyActive1); |
154 &cricket::FakeTransportController::DestroyRtcpTransport); | |
155 channel2_->SignalRtcpMuxFullyActive.connect( | 224 channel2_->SignalRtcpMuxFullyActive.connect( |
156 transport_controller2_.get(), | 225 this, &ChannelTest<T>::OnRtcpMuxFullyActive2); |
157 &cricket::FakeTransportController::DestroyRtcpTransport); | |
158 if ((flags1 & DTLS) && (flags2 & DTLS)) { | 226 if ((flags1 & DTLS) && (flags2 & DTLS)) { |
159 flags1 = (flags1 & ~SECURE); | 227 flags1 = (flags1 & ~SECURE); |
160 flags2 = (flags2 & ~SECURE); | 228 flags2 = (flags2 & ~SECURE); |
161 } | 229 } |
162 CreateContent(flags1, kPcmuCodec, kH264Codec, | 230 CreateContent(flags1, kPcmuCodec, kH264Codec, |
163 &local_media_content1_); | 231 &local_media_content1_); |
164 CreateContent(flags2, kPcmuCodec, kH264Codec, | 232 CreateContent(flags2, kPcmuCodec, kH264Codec, |
165 &local_media_content2_); | 233 &local_media_content2_); |
166 CopyContent(local_media_content1_, &remote_media_content1_); | 234 CopyContent(local_media_content1_, &remote_media_content1_); |
167 CopyContent(local_media_content2_, &remote_media_content2_); | 235 CopyContent(local_media_content2_, &remote_media_content2_); |
168 | 236 |
169 if (flags1 & DTLS) { | |
170 // Confirmed to work with KT_RSA and KT_ECDSA. | |
171 transport_controller1_->SetLocalCertificate( | |
172 rtc::RTCCertificate::Create(std::unique_ptr<rtc::SSLIdentity>( | |
173 rtc::SSLIdentity::Generate("session1", rtc::KT_DEFAULT)))); | |
174 } | |
175 if (flags2 & DTLS) { | |
176 // Confirmed to work with KT_RSA and KT_ECDSA. | |
177 transport_controller2_->SetLocalCertificate( | |
178 rtc::RTCCertificate::Create(std::unique_ptr<rtc::SSLIdentity>( | |
179 rtc::SSLIdentity::Generate("session2", rtc::KT_DEFAULT)))); | |
180 } | |
181 | |
182 // Add stream information (SSRC) to the local content but not to the remote | 237 // Add stream information (SSRC) to the local content but not to the remote |
183 // content. This means that we per default know the SSRC of what we send but | 238 // content. This means that we per default know the SSRC of what we send but |
184 // not what we receive. | 239 // not what we receive. |
185 AddLegacyStreamInContent(kSsrc1, flags1, &local_media_content1_); | 240 AddLegacyStreamInContent(kSsrc1, flags1, &local_media_content1_); |
186 AddLegacyStreamInContent(kSsrc2, flags2, &local_media_content2_); | 241 AddLegacyStreamInContent(kSsrc2, flags2, &local_media_content2_); |
187 | 242 |
188 // If SSRC_MUX is used we also need to know the SSRC of the incoming stream. | 243 // If SSRC_MUX is used we also need to know the SSRC of the incoming stream. |
189 if (flags1 & SSRC_MUX) { | 244 if (flags1 & SSRC_MUX) { |
190 AddLegacyStreamInContent(kSsrc1, flags1, &remote_media_content1_); | 245 AddLegacyStreamInContent(kSsrc1, flags1, &remote_media_content1_); |
191 } | 246 } |
192 if (flags2 & SSRC_MUX) { | 247 if (flags2 & SSRC_MUX) { |
193 AddLegacyStreamInContent(kSsrc2, flags2, &remote_media_content2_); | 248 AddLegacyStreamInContent(kSsrc2, flags2, &remote_media_content2_); |
194 } | 249 } |
195 } | 250 } |
196 typename T::Channel* CreateChannel( | 251 typename T::Channel* CreateChannel( |
197 rtc::Thread* worker_thread, | 252 rtc::Thread* worker_thread, |
198 rtc::Thread* network_thread, | 253 rtc::Thread* network_thread, |
199 cricket::MediaEngineInterface* engine, | 254 cricket::MediaEngineInterface* engine, |
200 typename T::MediaChannel* ch, | 255 typename T::MediaChannel* ch, |
201 cricket::TransportController* transport_controller, | 256 cricket::DtlsTransportInternal* fake_rtp_dtls_transport, |
| 257 cricket::DtlsTransportInternal* fake_rtcp_dtls_transport, |
| 258 rtc::PacketTransportInterface* fake_rtp_packet_transport, |
| 259 rtc::PacketTransportInterface* fake_rtcp_packet_transport, |
202 int flags) { | 260 int flags) { |
203 rtc::Thread* signaling_thread = | 261 rtc::Thread* signaling_thread = rtc::Thread::Current(); |
204 transport_controller ? transport_controller->signaling_thread() | |
205 : nullptr; | |
206 typename T::Channel* channel = new typename T::Channel( | 262 typename T::Channel* channel = new typename T::Channel( |
207 worker_thread, network_thread, signaling_thread, engine, ch, | 263 worker_thread, network_thread, signaling_thread, engine, ch, |
208 cricket::CN_AUDIO, (flags & RTCP_MUX_REQUIRED) != 0, | 264 cricket::CN_AUDIO, (flags & RTCP_MUX_REQUIRED) != 0, |
209 (flags & SECURE) != 0); | 265 (flags & SECURE) != 0); |
210 rtc::CryptoOptions crypto_options; | 266 rtc::CryptoOptions crypto_options; |
211 crypto_options.enable_gcm_crypto_suites = (flags & GCM_CIPHER) != 0; | 267 crypto_options.enable_gcm_crypto_suites = (flags & GCM_CIPHER) != 0; |
212 channel->SetCryptoOptions(crypto_options); | 268 channel->SetCryptoOptions(crypto_options); |
213 cricket::DtlsTransportInternal* rtp_dtls_transport = | 269 if (!channel->NeedsRtcpTransport()) { |
214 transport_controller->CreateDtlsTransport( | 270 fake_rtcp_dtls_transport = nullptr; |
215 channel->content_name(), cricket::ICE_CANDIDATE_COMPONENT_RTP); | |
216 cricket::DtlsTransportInternal* rtcp_dtls_transport = nullptr; | |
217 if (channel->NeedsRtcpTransport()) { | |
218 rtcp_dtls_transport = transport_controller->CreateDtlsTransport( | |
219 channel->content_name(), cricket::ICE_CANDIDATE_COMPONENT_RTCP); | |
220 } | 271 } |
221 if (!channel->Init_w(rtp_dtls_transport, rtcp_dtls_transport)) { | 272 if (!channel->Init_w(fake_rtp_dtls_transport, fake_rtcp_dtls_transport, |
| 273 fake_rtp_packet_transport, |
| 274 fake_rtcp_packet_transport)) { |
222 delete channel; | 275 delete channel; |
223 channel = NULL; | 276 channel = NULL; |
224 } | 277 } |
225 return channel; | 278 return channel; |
226 } | 279 } |
227 | 280 |
| 281 void ConnectFakeTransports() { |
| 282 network_thread_->Invoke<void>(RTC_FROM_HERE, [this] { |
| 283 bool asymmetric = false; |
| 284 // Depending on test flags, could be using DTLS or raw packet transport. |
| 285 if (fake_rtp_dtls_transport1_ && fake_rtp_dtls_transport2_) { |
| 286 fake_rtp_dtls_transport1_->SetDestination( |
| 287 fake_rtp_dtls_transport2_.get(), asymmetric); |
| 288 } |
| 289 if (fake_rtcp_dtls_transport1_ && fake_rtcp_dtls_transport2_) { |
| 290 fake_rtcp_dtls_transport1_->SetDestination( |
| 291 fake_rtcp_dtls_transport2_.get(), asymmetric); |
| 292 } |
| 293 if (fake_rtp_packet_transport1_ && fake_rtp_packet_transport2_) { |
| 294 fake_rtp_packet_transport1_->SetDestination( |
| 295 fake_rtp_packet_transport2_.get(), asymmetric); |
| 296 } |
| 297 if (fake_rtcp_packet_transport1_ && fake_rtcp_packet_transport2_) { |
| 298 fake_rtcp_packet_transport1_->SetDestination( |
| 299 fake_rtcp_packet_transport2_.get(), asymmetric); |
| 300 } |
| 301 }); |
| 302 } |
| 303 |
228 bool SendInitiate() { | 304 bool SendInitiate() { |
229 bool result = channel1_->SetLocalContent(&local_media_content1_, | 305 bool result = channel1_->SetLocalContent(&local_media_content1_, |
230 CA_OFFER, NULL); | 306 CA_OFFER, NULL); |
231 if (result) { | 307 if (result) { |
232 channel1_->Enable(true); | 308 channel1_->Enable(true); |
233 result = channel2_->SetRemoteContent(&remote_media_content1_, | 309 result = channel2_->SetRemoteContent(&remote_media_content1_, |
234 CA_OFFER, NULL); | 310 CA_OFFER, NULL); |
235 if (result) { | 311 if (result) { |
236 transport_controller1_->Connect(transport_controller2_.get()); | 312 ConnectFakeTransports(); |
237 | |
238 result = channel2_->SetLocalContent(&local_media_content2_, | 313 result = channel2_->SetLocalContent(&local_media_content2_, |
239 CA_ANSWER, NULL); | 314 CA_ANSWER, NULL); |
240 } | 315 } |
241 } | 316 } |
242 return result; | 317 return result; |
243 } | 318 } |
244 | 319 |
245 bool SendAccept() { | 320 bool SendAccept() { |
246 channel2_->Enable(true); | 321 channel2_->Enable(true); |
247 return channel1_->SetRemoteContent(&remote_media_content2_, | 322 return channel1_->SetRemoteContent(&remote_media_content2_, |
(...skipping 11 matching lines...) Expand all Loading... |
259 return result; | 334 return result; |
260 } | 335 } |
261 | 336 |
262 bool SendProvisionalAnswer() { | 337 bool SendProvisionalAnswer() { |
263 bool result = channel2_->SetLocalContent(&local_media_content2_, | 338 bool result = channel2_->SetLocalContent(&local_media_content2_, |
264 CA_PRANSWER, NULL); | 339 CA_PRANSWER, NULL); |
265 if (result) { | 340 if (result) { |
266 channel2_->Enable(true); | 341 channel2_->Enable(true); |
267 result = channel1_->SetRemoteContent(&remote_media_content2_, | 342 result = channel1_->SetRemoteContent(&remote_media_content2_, |
268 CA_PRANSWER, NULL); | 343 CA_PRANSWER, NULL); |
269 transport_controller1_->Connect(transport_controller2_.get()); | 344 ConnectFakeTransports(); |
270 } | 345 } |
271 return result; | 346 return result; |
272 } | 347 } |
273 | 348 |
274 bool SendFinalAnswer() { | 349 bool SendFinalAnswer() { |
275 bool result = channel2_->SetLocalContent(&local_media_content2_, | 350 bool result = channel2_->SetLocalContent(&local_media_content2_, |
276 CA_ANSWER, NULL); | 351 CA_ANSWER, NULL); |
277 if (result) | 352 if (result) |
278 result = channel1_->SetRemoteContent(&remote_media_content2_, | 353 result = channel1_->SetRemoteContent(&remote_media_content2_, |
279 CA_ANSWER, NULL); | 354 CA_ANSWER, NULL); |
280 return result; | 355 return result; |
281 } | 356 } |
282 | 357 |
283 bool SendTerminate() { | 358 bool Terminate() { |
284 channel1_.reset(); | 359 channel1_.reset(); |
285 channel2_.reset(); | 360 channel2_.reset(); |
| 361 fake_rtp_dtls_transport1_.reset(); |
| 362 fake_rtcp_dtls_transport1_.reset(); |
| 363 fake_rtp_dtls_transport2_.reset(); |
| 364 fake_rtcp_dtls_transport2_.reset(); |
| 365 fake_rtp_packet_transport1_.reset(); |
| 366 fake_rtcp_packet_transport1_.reset(); |
| 367 fake_rtp_packet_transport2_.reset(); |
| 368 fake_rtcp_packet_transport2_.reset(); |
| 369 if (network_thread_keeper_) { |
| 370 network_thread_keeper_.reset(); |
| 371 } |
286 return true; | 372 return true; |
287 } | 373 } |
288 | 374 |
289 bool AddStream1(int id) { | 375 bool AddStream1(int id) { |
290 return channel1_->AddRecvStream(cricket::StreamParams::CreateLegacy(id)); | 376 return channel1_->AddRecvStream(cricket::StreamParams::CreateLegacy(id)); |
291 } | 377 } |
292 bool RemoveStream1(int id) { | 378 bool RemoveStream1(int id) { |
293 return channel1_->RemoveRecvStream(id); | 379 return channel1_->RemoveRecvStream(id); |
294 } | 380 } |
295 | 381 |
296 std::vector<cricket::DtlsTransportInternal*> GetChannels1() { | |
297 return transport_controller1_->channels_for_testing(); | |
298 } | |
299 | |
300 std::vector<cricket::DtlsTransportInternal*> GetChannels2() { | |
301 return transport_controller2_->channels_for_testing(); | |
302 } | |
303 | |
304 cricket::FakeDtlsTransport* GetFakeChannel1(int component) { | |
305 return transport_controller1_->GetFakeDtlsTransport_n( | |
306 channel1_->content_name(), component); | |
307 } | |
308 | |
309 cricket::FakeDtlsTransport* GetFakeChannel2(int component) { | |
310 return transport_controller2_->GetFakeDtlsTransport_n( | |
311 channel2_->content_name(), component); | |
312 } | |
313 | |
314 void SendRtp1() { | 382 void SendRtp1() { |
315 media_channel1_->SendRtp(rtp_packet_.data(), rtp_packet_.size(), | 383 media_channel1_->SendRtp(rtp_packet_.data(), rtp_packet_.size(), |
316 rtc::PacketOptions()); | 384 rtc::PacketOptions()); |
317 } | 385 } |
318 void SendRtp2() { | 386 void SendRtp2() { |
319 media_channel2_->SendRtp(rtp_packet_.data(), rtp_packet_.size(), | 387 media_channel2_->SendRtp(rtp_packet_.data(), rtp_packet_.size(), |
320 rtc::PacketOptions()); | 388 rtc::PacketOptions()); |
321 } | 389 } |
322 void SendRtcp1() { | 390 void SendRtcp1() { |
323 media_channel1_->SendRtcp(rtcp_packet_.data(), rtcp_packet_.size()); | 391 media_channel1_->SendRtcp(rtcp_packet_.data(), rtcp_packet_.size()); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 bool CheckNoRtcp1() { | 466 bool CheckNoRtcp1() { |
399 return media_channel1_->CheckNoRtcp(); | 467 return media_channel1_->CheckNoRtcp(); |
400 } | 468 } |
401 bool CheckNoRtcp2() { | 469 bool CheckNoRtcp2() { |
402 return media_channel2_->CheckNoRtcp(); | 470 return media_channel2_->CheckNoRtcp(); |
403 } | 471 } |
404 // Checks that the channel is using GCM iff GCM_CIPHER is set in flags. | 472 // Checks that the channel is using GCM iff GCM_CIPHER is set in flags. |
405 // Returns true if so. | 473 // Returns true if so. |
406 bool CheckGcmCipher(typename T::Channel* channel, int flags) { | 474 bool CheckGcmCipher(typename T::Channel* channel, int flags) { |
407 int suite; | 475 int suite; |
408 if (!channel->rtp_dtls_transport()->GetSrtpCryptoSuite(&suite)) { | 476 cricket::FakeDtlsTransport* transport = |
| 477 (channel == channel1_.get()) ? fake_rtp_dtls_transport1_.get() |
| 478 : fake_rtp_dtls_transport2_.get(); |
| 479 RTC_DCHECK(transport); |
| 480 if (!transport->GetSrtpCryptoSuite(&suite)) { |
409 return false; | 481 return false; |
410 } | 482 } |
411 | 483 |
412 if (flags & GCM_CIPHER) { | 484 if (flags & GCM_CIPHER) { |
413 return rtc::IsGcmCryptoSuite(suite); | 485 return rtc::IsGcmCryptoSuite(suite); |
414 } else { | 486 } else { |
415 return (suite != rtc::SRTP_INVALID_CRYPTO_SUITE && | 487 return (suite != rtc::SRTP_INVALID_CRYPTO_SUITE && |
416 !rtc::IsGcmCryptoSuite(suite)); | 488 !rtc::IsGcmCryptoSuite(suite)); |
417 } | 489 } |
418 } | 490 } |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
469 void OnMediaMonitor1(typename T::Channel* channel, | 541 void OnMediaMonitor1(typename T::Channel* channel, |
470 const typename T::MediaInfo& info) { | 542 const typename T::MediaInfo& info) { |
471 RTC_DCHECK_EQ(channel, channel1_.get()); | 543 RTC_DCHECK_EQ(channel, channel1_.get()); |
472 media_info_callbacks1_++; | 544 media_info_callbacks1_++; |
473 } | 545 } |
474 void OnMediaMonitor2(typename T::Channel* channel, | 546 void OnMediaMonitor2(typename T::Channel* channel, |
475 const typename T::MediaInfo& info) { | 547 const typename T::MediaInfo& info) { |
476 RTC_DCHECK_EQ(channel, channel2_.get()); | 548 RTC_DCHECK_EQ(channel, channel2_.get()); |
477 media_info_callbacks2_++; | 549 media_info_callbacks2_++; |
478 } | 550 } |
| 551 void OnRtcpMuxFullyActive1(const std::string&) { |
| 552 rtcp_mux_activated_callbacks1_++; |
| 553 } |
| 554 void OnRtcpMuxFullyActive2(const std::string&) { |
| 555 rtcp_mux_activated_callbacks2_++; |
| 556 } |
479 | 557 |
480 cricket::CandidatePairInterface* last_selected_candidate_pair() { | 558 cricket::CandidatePairInterface* last_selected_candidate_pair() { |
481 return last_selected_candidate_pair_; | 559 return last_selected_candidate_pair_; |
482 } | 560 } |
483 | 561 |
484 void AddLegacyStreamInContent(uint32_t ssrc, | 562 void AddLegacyStreamInContent(uint32_t ssrc, |
485 int flags, | 563 int flags, |
486 typename T::Content* content) { | 564 typename T::Content* content) { |
487 // Base implementation. | 565 // Base implementation. |
488 } | 566 } |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
528 EXPECT_TRUE(channel1_->SetRemoteContent(&content, CA_ANSWER, NULL)); | 606 EXPECT_TRUE(channel1_->SetRemoteContent(&content, CA_ANSWER, NULL)); |
529 ASSERT_EQ(1U, media_channel1_->codecs().size()); | 607 ASSERT_EQ(1U, media_channel1_->codecs().size()); |
530 EXPECT_TRUE(CodecMatches(content.codecs()[0], | 608 EXPECT_TRUE(CodecMatches(content.codecs()[0], |
531 media_channel1_->codecs()[0])); | 609 media_channel1_->codecs()[0])); |
532 } | 610 } |
533 | 611 |
534 // Test that SetLocalContent and SetRemoteContent properly set RTCP | 612 // Test that SetLocalContent and SetRemoteContent properly set RTCP |
535 // mux. | 613 // mux. |
536 void TestSetContentsRtcpMux() { | 614 void TestSetContentsRtcpMux() { |
537 CreateChannels(0, 0); | 615 CreateChannels(0, 0); |
538 EXPECT_TRUE(channel1_->rtcp_dtls_transport() != NULL); | |
539 EXPECT_TRUE(channel2_->rtcp_dtls_transport() != NULL); | |
540 typename T::Content content; | 616 typename T::Content content; |
541 CreateContent(0, kPcmuCodec, kH264Codec, &content); | 617 CreateContent(0, kPcmuCodec, kH264Codec, &content); |
542 // Both sides agree on mux. Should no longer be a separate RTCP channel. | 618 // Both sides agree on mux. Should no longer be a separate RTCP channel. |
543 content.set_rtcp_mux(true); | 619 content.set_rtcp_mux(true); |
544 EXPECT_TRUE(channel1_->SetLocalContent(&content, CA_OFFER, NULL)); | 620 EXPECT_TRUE(channel1_->SetLocalContent(&content, CA_OFFER, NULL)); |
545 EXPECT_TRUE(channel1_->SetRemoteContent(&content, CA_ANSWER, NULL)); | 621 EXPECT_TRUE(channel1_->SetRemoteContent(&content, CA_ANSWER, NULL)); |
546 EXPECT_TRUE(channel1_->rtcp_dtls_transport() == NULL); | |
547 // Only initiator supports mux. Should still have a separate RTCP channel. | 622 // Only initiator supports mux. Should still have a separate RTCP channel. |
548 EXPECT_TRUE(channel2_->SetLocalContent(&content, CA_OFFER, NULL)); | 623 EXPECT_TRUE(channel2_->SetLocalContent(&content, CA_OFFER, NULL)); |
549 content.set_rtcp_mux(false); | 624 content.set_rtcp_mux(false); |
550 EXPECT_TRUE(channel2_->SetRemoteContent(&content, CA_ANSWER, NULL)); | 625 EXPECT_TRUE(channel2_->SetRemoteContent(&content, CA_ANSWER, NULL)); |
551 EXPECT_TRUE(channel2_->rtcp_dtls_transport() != NULL); | |
552 } | 626 } |
553 | 627 |
554 // Test that SetLocalContent and SetRemoteContent properly set RTCP | 628 // Test that SetLocalContent and SetRemoteContent properly set RTCP |
555 // mux when a provisional answer is received. | 629 // mux when a provisional answer is received. |
556 void TestSetContentsRtcpMuxWithPrAnswer() { | 630 void TestSetContentsRtcpMuxWithPrAnswer() { |
557 CreateChannels(0, 0); | 631 CreateChannels(0, 0); |
558 EXPECT_TRUE(channel1_->rtcp_dtls_transport() != NULL); | |
559 EXPECT_TRUE(channel2_->rtcp_dtls_transport() != NULL); | |
560 typename T::Content content; | 632 typename T::Content content; |
561 CreateContent(0, kPcmuCodec, kH264Codec, &content); | 633 CreateContent(0, kPcmuCodec, kH264Codec, &content); |
562 content.set_rtcp_mux(true); | 634 content.set_rtcp_mux(true); |
563 EXPECT_TRUE(channel1_->SetLocalContent(&content, CA_OFFER, NULL)); | 635 EXPECT_TRUE(channel1_->SetLocalContent(&content, CA_OFFER, NULL)); |
564 EXPECT_TRUE(channel1_->SetRemoteContent(&content, CA_PRANSWER, NULL)); | 636 EXPECT_TRUE(channel1_->SetRemoteContent(&content, CA_PRANSWER, NULL)); |
565 EXPECT_TRUE(channel1_->rtcp_dtls_transport() != NULL); | 637 // Both sides agree on mux. Should signal RTCP mux as fully activated. |
| 638 EXPECT_EQ(0, rtcp_mux_activated_callbacks1_); |
566 EXPECT_TRUE(channel1_->SetRemoteContent(&content, CA_ANSWER, NULL)); | 639 EXPECT_TRUE(channel1_->SetRemoteContent(&content, CA_ANSWER, NULL)); |
567 // Both sides agree on mux. Should no longer be a separate RTCP channel. | 640 EXPECT_EQ(1, rtcp_mux_activated_callbacks1_); |
568 EXPECT_TRUE(channel1_->rtcp_dtls_transport() == NULL); | |
569 // Only initiator supports mux. Should still have a separate RTCP channel. | 641 // Only initiator supports mux. Should still have a separate RTCP channel. |
570 EXPECT_TRUE(channel2_->SetLocalContent(&content, CA_OFFER, NULL)); | 642 EXPECT_TRUE(channel2_->SetLocalContent(&content, CA_OFFER, NULL)); |
571 content.set_rtcp_mux(false); | 643 content.set_rtcp_mux(false); |
572 EXPECT_TRUE(channel2_->SetRemoteContent(&content, CA_PRANSWER, NULL)); | 644 EXPECT_TRUE(channel2_->SetRemoteContent(&content, CA_PRANSWER, NULL)); |
573 EXPECT_TRUE(channel2_->SetRemoteContent(&content, CA_ANSWER, NULL)); | 645 EXPECT_TRUE(channel2_->SetRemoteContent(&content, CA_ANSWER, NULL)); |
574 EXPECT_TRUE(channel2_->rtcp_dtls_transport() != NULL); | 646 EXPECT_EQ(0, rtcp_mux_activated_callbacks2_); |
575 } | 647 } |
576 | 648 |
577 // Test that SetRemoteContent properly deals with a content update. | 649 // Test that SetRemoteContent properly deals with a content update. |
578 void TestSetRemoteContentUpdate() { | 650 void TestSetRemoteContentUpdate() { |
579 CreateChannels(0, 0); | 651 CreateChannels(0, 0); |
580 typename T::Content content; | 652 typename T::Content content; |
581 CreateContent(RTCP_MUX | SECURE, kPcmuCodec, kH264Codec, &content); | 653 CreateContent(RTCP_MUX | SECURE, kPcmuCodec, kH264Codec, &content); |
582 EXPECT_EQ(0U, media_channel1_->codecs().size()); | 654 EXPECT_EQ(0U, media_channel1_->codecs().size()); |
583 EXPECT_TRUE(channel1_->SetLocalContent(&content, CA_OFFER, NULL)); | 655 EXPECT_TRUE(channel1_->SetLocalContent(&content, CA_OFFER, NULL)); |
584 EXPECT_TRUE(channel1_->SetRemoteContent(&content, CA_ANSWER, NULL)); | 656 EXPECT_TRUE(channel1_->SetRemoteContent(&content, CA_ANSWER, NULL)); |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
770 CreateChannels(0, 0); | 842 CreateChannels(0, 0); |
771 typename T::Content content1; | 843 typename T::Content content1; |
772 CreateContent(0, kPcmuCodec, kH264Codec, &content1); | 844 CreateContent(0, kPcmuCodec, kH264Codec, &content1); |
773 content1.AddStream(stream1); | 845 content1.AddStream(stream1); |
774 EXPECT_TRUE(channel1_->SetLocalContent(&content1, CA_OFFER, NULL)); | 846 EXPECT_TRUE(channel1_->SetLocalContent(&content1, CA_OFFER, NULL)); |
775 EXPECT_TRUE(channel1_->Enable(true)); | 847 EXPECT_TRUE(channel1_->Enable(true)); |
776 EXPECT_EQ(1u, media_channel1_->send_streams().size()); | 848 EXPECT_EQ(1u, media_channel1_->send_streams().size()); |
777 | 849 |
778 EXPECT_TRUE(channel2_->SetRemoteContent(&content1, CA_OFFER, NULL)); | 850 EXPECT_TRUE(channel2_->SetRemoteContent(&content1, CA_OFFER, NULL)); |
779 EXPECT_EQ(1u, media_channel2_->recv_streams().size()); | 851 EXPECT_EQ(1u, media_channel2_->recv_streams().size()); |
780 transport_controller1_->Connect(transport_controller2_.get()); | 852 ConnectFakeTransports(); |
781 | 853 |
782 // Channel 2 do not send anything. | 854 // Channel 2 do not send anything. |
783 typename T::Content content2; | 855 typename T::Content content2; |
784 CreateContent(0, kPcmuCodec, kH264Codec, &content2); | 856 CreateContent(0, kPcmuCodec, kH264Codec, &content2); |
785 EXPECT_TRUE(channel1_->SetRemoteContent(&content2, CA_ANSWER, NULL)); | 857 EXPECT_TRUE(channel1_->SetRemoteContent(&content2, CA_ANSWER, NULL)); |
786 EXPECT_EQ(0u, media_channel1_->recv_streams().size()); | 858 EXPECT_EQ(0u, media_channel1_->recv_streams().size()); |
787 EXPECT_TRUE(channel2_->SetLocalContent(&content2, CA_ANSWER, NULL)); | 859 EXPECT_TRUE(channel2_->SetLocalContent(&content2, CA_ANSWER, NULL)); |
788 EXPECT_TRUE(channel2_->Enable(true)); | 860 EXPECT_TRUE(channel2_->Enable(true)); |
789 EXPECT_EQ(0u, media_channel2_->send_streams().size()); | 861 EXPECT_EQ(0u, media_channel2_->send_streams().size()); |
790 | 862 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
847 if (verify_playout_) { | 919 if (verify_playout_) { |
848 EXPECT_FALSE(media_channel2_->playout()); | 920 EXPECT_FALSE(media_channel2_->playout()); |
849 } | 921 } |
850 EXPECT_FALSE(media_channel2_->sending()); | 922 EXPECT_FALSE(media_channel2_->sending()); |
851 EXPECT_TRUE(channel2_->SetLocalContent(&local_media_content2_, | 923 EXPECT_TRUE(channel2_->SetLocalContent(&local_media_content2_, |
852 CA_ANSWER, NULL)); | 924 CA_ANSWER, NULL)); |
853 if (verify_playout_) { | 925 if (verify_playout_) { |
854 EXPECT_FALSE(media_channel2_->playout()); | 926 EXPECT_FALSE(media_channel2_->playout()); |
855 } | 927 } |
856 EXPECT_FALSE(media_channel2_->sending()); | 928 EXPECT_FALSE(media_channel2_->sending()); |
857 transport_controller1_->Connect(transport_controller2_.get()); | 929 ConnectFakeTransports(); |
858 if (verify_playout_) { | 930 if (verify_playout_) { |
859 EXPECT_TRUE(media_channel1_->playout()); | 931 EXPECT_TRUE(media_channel1_->playout()); |
860 } | 932 } |
861 EXPECT_FALSE(media_channel1_->sending()); | 933 EXPECT_FALSE(media_channel1_->sending()); |
862 if (verify_playout_) { | 934 if (verify_playout_) { |
863 EXPECT_FALSE(media_channel2_->playout()); | 935 EXPECT_FALSE(media_channel2_->playout()); |
864 } | 936 } |
865 EXPECT_FALSE(media_channel2_->sending()); | 937 EXPECT_FALSE(media_channel2_->sending()); |
866 EXPECT_TRUE(channel2_->Enable(true)); | 938 EXPECT_TRUE(channel2_->Enable(true)); |
867 if (verify_playout_) { | 939 if (verify_playout_) { |
(...skipping 27 matching lines...) Expand all Loading... |
895 EXPECT_FALSE(media_channel1_->sending()); | 967 EXPECT_FALSE(media_channel1_->sending()); |
896 if (verify_playout_) { | 968 if (verify_playout_) { |
897 EXPECT_FALSE(media_channel2_->playout()); | 969 EXPECT_FALSE(media_channel2_->playout()); |
898 } | 970 } |
899 EXPECT_FALSE(media_channel2_->sending()); | 971 EXPECT_FALSE(media_channel2_->sending()); |
900 | 972 |
901 EXPECT_TRUE(channel1_->SetLocalContent(&content1, CA_OFFER, NULL)); | 973 EXPECT_TRUE(channel1_->SetLocalContent(&content1, CA_OFFER, NULL)); |
902 EXPECT_TRUE(channel2_->SetRemoteContent(&content1, CA_OFFER, NULL)); | 974 EXPECT_TRUE(channel2_->SetRemoteContent(&content1, CA_OFFER, NULL)); |
903 EXPECT_TRUE(channel2_->SetLocalContent(&content2, CA_PRANSWER, NULL)); | 975 EXPECT_TRUE(channel2_->SetLocalContent(&content2, CA_PRANSWER, NULL)); |
904 EXPECT_TRUE(channel1_->SetRemoteContent(&content2, CA_PRANSWER, NULL)); | 976 EXPECT_TRUE(channel1_->SetRemoteContent(&content2, CA_PRANSWER, NULL)); |
905 transport_controller1_->Connect(transport_controller2_.get()); | 977 ConnectFakeTransports(); |
906 | 978 |
907 if (verify_playout_) { | 979 if (verify_playout_) { |
908 EXPECT_TRUE(media_channel1_->playout()); | 980 EXPECT_TRUE(media_channel1_->playout()); |
909 } | 981 } |
910 EXPECT_FALSE(media_channel1_->sending()); // remote InActive | 982 EXPECT_FALSE(media_channel1_->sending()); // remote InActive |
911 if (verify_playout_) { | 983 if (verify_playout_) { |
912 EXPECT_FALSE(media_channel2_->playout()); // local InActive | 984 EXPECT_FALSE(media_channel2_->playout()); // local InActive |
913 } | 985 } |
914 EXPECT_FALSE(media_channel2_->sending()); // local InActive | 986 EXPECT_FALSE(media_channel2_->sending()); // local InActive |
915 | 987 |
(...skipping 28 matching lines...) Expand all Loading... |
944 | 1016 |
945 // Tests that when the transport channel signals a candidate pair change | 1017 // Tests that when the transport channel signals a candidate pair change |
946 // event, the media channel will receive a call on the network route change. | 1018 // event, the media channel will receive a call on the network route change. |
947 void TestNetworkRouteChanges() { | 1019 void TestNetworkRouteChanges() { |
948 constexpr uint16_t kLocalNetId = 1; | 1020 constexpr uint16_t kLocalNetId = 1; |
949 constexpr uint16_t kRemoteNetId = 2; | 1021 constexpr uint16_t kRemoteNetId = 2; |
950 constexpr int kLastPacketId = 100; | 1022 constexpr int kLastPacketId = 100; |
951 | 1023 |
952 CreateChannels(0, 0); | 1024 CreateChannels(0, 0); |
953 | 1025 |
954 cricket::DtlsTransportInternal* transport_channel1 = | |
955 channel1_->rtp_dtls_transport(); | |
956 ASSERT_TRUE(transport_channel1); | |
957 typename T::MediaChannel* media_channel1 = | 1026 typename T::MediaChannel* media_channel1 = |
958 static_cast<typename T::MediaChannel*>(channel1_->media_channel()); | 1027 static_cast<typename T::MediaChannel*>(channel1_->media_channel()); |
959 ASSERT_TRUE(media_channel1); | 1028 ASSERT_TRUE(media_channel1); |
960 | 1029 |
961 media_channel1->set_num_network_route_changes(0); | 1030 media_channel1->set_num_network_route_changes(0); |
962 network_thread_->Invoke<void>(RTC_FROM_HERE, [transport_channel1] { | 1031 network_thread_->Invoke<void>(RTC_FROM_HERE, [this] { |
963 // The transport channel becomes disconnected. | 1032 // The transport channel becomes disconnected. |
964 transport_channel1->ice_transport()->SignalSelectedCandidatePairChanged( | 1033 fake_rtp_dtls_transport1_->ice_transport() |
965 transport_channel1->ice_transport(), nullptr, -1, false); | 1034 ->SignalSelectedCandidatePairChanged( |
| 1035 fake_rtp_dtls_transport1_->ice_transport(), nullptr, -1, false); |
966 }); | 1036 }); |
967 WaitForThreads(); | 1037 WaitForThreads(); |
968 EXPECT_EQ(1, media_channel1->num_network_route_changes()); | 1038 EXPECT_EQ(1, media_channel1->num_network_route_changes()); |
969 EXPECT_FALSE(media_channel1->last_network_route().connected); | 1039 EXPECT_FALSE(media_channel1->last_network_route().connected); |
970 media_channel1->set_num_network_route_changes(0); | 1040 media_channel1->set_num_network_route_changes(0); |
971 | 1041 |
972 network_thread_->Invoke<void>(RTC_FROM_HERE, [this, transport_channel1, | 1042 network_thread_->Invoke<void>(RTC_FROM_HERE, [this, media_channel1, |
973 media_channel1, kLocalNetId, | 1043 kLocalNetId, kRemoteNetId, |
974 kRemoteNetId, kLastPacketId] { | 1044 kLastPacketId] { |
975 // The transport channel becomes connected. | 1045 // The transport channel becomes connected. |
976 rtc::SocketAddress local_address("192.168.1.1", 1000 /* port number */); | 1046 rtc::SocketAddress local_address("192.168.1.1", 1000 /* port number */); |
977 rtc::SocketAddress remote_address("192.168.1.2", 2000 /* port number */); | 1047 rtc::SocketAddress remote_address("192.168.1.2", 2000 /* port number */); |
978 std::unique_ptr<cricket::CandidatePairInterface> candidate_pair( | 1048 auto candidate_pair = cricket::FakeCandidatePair::Create( |
979 transport_controller1_->CreateFakeCandidatePair( | 1049 local_address, kLocalNetId, remote_address, kRemoteNetId); |
980 local_address, kLocalNetId, remote_address, kRemoteNetId)); | 1050 fake_rtp_dtls_transport1_->ice_transport() |
981 transport_channel1->ice_transport()->SignalSelectedCandidatePairChanged( | 1051 ->SignalSelectedCandidatePairChanged( |
982 transport_channel1->ice_transport(), candidate_pair.get(), | 1052 fake_rtp_dtls_transport1_->ice_transport(), candidate_pair.get(), |
983 kLastPacketId, true); | 1053 kLastPacketId, true); |
984 }); | 1054 }); |
985 WaitForThreads(); | 1055 WaitForThreads(); |
986 EXPECT_EQ(1, media_channel1->num_network_route_changes()); | 1056 EXPECT_EQ(1, media_channel1->num_network_route_changes()); |
987 rtc::NetworkRoute expected_network_route(true, kLocalNetId, kRemoteNetId, | 1057 rtc::NetworkRoute expected_network_route(true, kLocalNetId, kRemoteNetId, |
988 kLastPacketId); | 1058 kLastPacketId); |
989 EXPECT_EQ(expected_network_route, media_channel1->last_network_route()); | 1059 EXPECT_EQ(expected_network_route, media_channel1->last_network_route()); |
990 EXPECT_EQ(kLastPacketId, | 1060 EXPECT_EQ(kLastPacketId, |
991 media_channel1->last_network_route().last_sent_packet_id); | 1061 media_channel1->last_network_route().last_sent_packet_id); |
992 constexpr int kTransportOverheadPerPacket = 28; // Ipv4(20) + UDP(8). | 1062 constexpr int kTransportOverheadPerPacket = 28; // Ipv4(20) + UDP(8). |
993 EXPECT_EQ(kTransportOverheadPerPacket, | 1063 EXPECT_EQ(kTransportOverheadPerPacket, |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1025 ~LastWordMediaChannel() { | 1095 ~LastWordMediaChannel() { |
1026 T::MediaChannel::SendRtp(kPcmuFrame, sizeof(kPcmuFrame), | 1096 T::MediaChannel::SendRtp(kPcmuFrame, sizeof(kPcmuFrame), |
1027 rtc::PacketOptions()); | 1097 rtc::PacketOptions()); |
1028 T::MediaChannel::SendRtcp(kRtcpReport, sizeof(kRtcpReport)); | 1098 T::MediaChannel::SendRtcp(kRtcpReport, sizeof(kRtcpReport)); |
1029 } | 1099 } |
1030 }; | 1100 }; |
1031 CreateChannels(new LastWordMediaChannel(), new LastWordMediaChannel(), | 1101 CreateChannels(new LastWordMediaChannel(), new LastWordMediaChannel(), |
1032 RTCP_MUX, RTCP_MUX); | 1102 RTCP_MUX, RTCP_MUX); |
1033 EXPECT_TRUE(SendInitiate()); | 1103 EXPECT_TRUE(SendInitiate()); |
1034 EXPECT_TRUE(SendAccept()); | 1104 EXPECT_TRUE(SendAccept()); |
1035 EXPECT_TRUE(SendTerminate()); | 1105 EXPECT_TRUE(Terminate()); |
1036 } | 1106 } |
1037 | 1107 |
1038 // Send voice RTP data to the other side and ensure it gets there. | 1108 // Send voice RTP data to the other side and ensure it gets there. |
1039 void SendRtpToRtp() { | 1109 void SendRtpToRtp() { |
1040 CreateChannels(RTCP_MUX | RTCP_MUX_REQUIRED, RTCP_MUX | RTCP_MUX_REQUIRED); | 1110 CreateChannels(RTCP_MUX | RTCP_MUX_REQUIRED, RTCP_MUX | RTCP_MUX_REQUIRED); |
1041 EXPECT_TRUE(SendInitiate()); | 1111 EXPECT_TRUE(SendInitiate()); |
1042 EXPECT_TRUE(SendAccept()); | 1112 EXPECT_TRUE(SendAccept()); |
1043 EXPECT_EQ(1U, GetChannels1().size()); | 1113 EXPECT_FALSE(channel1_->NeedsRtcpTransport()); |
1044 EXPECT_EQ(1U, GetChannels2().size()); | 1114 EXPECT_FALSE(channel2_->NeedsRtcpTransport()); |
1045 SendRtp1(); | 1115 SendRtp1(); |
1046 SendRtp2(); | 1116 SendRtp2(); |
1047 WaitForThreads(); | 1117 WaitForThreads(); |
1048 EXPECT_TRUE(CheckRtp1()); | 1118 EXPECT_TRUE(CheckRtp1()); |
1049 EXPECT_TRUE(CheckRtp2()); | 1119 EXPECT_TRUE(CheckRtp2()); |
1050 EXPECT_TRUE(CheckNoRtp1()); | 1120 EXPECT_TRUE(CheckNoRtp1()); |
1051 EXPECT_TRUE(CheckNoRtp2()); | 1121 EXPECT_TRUE(CheckNoRtp2()); |
1052 } | 1122 } |
1053 | 1123 |
1054 void TestDeinit() { | 1124 void TestDeinit() { |
1055 CreateChannels(0, 0); | 1125 CreateChannels(0, 0); |
1056 EXPECT_TRUE(SendInitiate()); | 1126 EXPECT_TRUE(SendInitiate()); |
1057 EXPECT_TRUE(SendAccept()); | 1127 EXPECT_TRUE(SendAccept()); |
1058 SendRtp1(); | 1128 SendRtp1(); |
1059 SendRtp2(); | 1129 SendRtp2(); |
1060 SendRtcp1(); | 1130 SendRtcp1(); |
1061 SendRtcp2(); | 1131 SendRtcp2(); |
1062 // Do not wait, destroy channels. | 1132 // Do not wait, destroy channels. |
1063 channel1_.reset(nullptr); | 1133 channel1_.reset(nullptr); |
1064 channel2_.reset(nullptr); | 1134 channel2_.reset(nullptr); |
1065 } | 1135 } |
1066 | 1136 |
1067 // Check that RTCP can be transmitted between both sides. | 1137 // Check that RTCP can be transmitted between both sides. |
1068 void SendRtcpToRtcp() { | 1138 void SendRtcpToRtcp() { |
1069 CreateChannels(0, 0); | 1139 CreateChannels(0, 0); |
1070 EXPECT_TRUE(SendInitiate()); | 1140 EXPECT_TRUE(SendInitiate()); |
1071 EXPECT_TRUE(SendAccept()); | 1141 EXPECT_TRUE(SendAccept()); |
1072 EXPECT_EQ(2U, GetChannels1().size()); | 1142 EXPECT_TRUE(channel1_->NeedsRtcpTransport()); |
1073 EXPECT_EQ(2U, GetChannels2().size()); | 1143 EXPECT_TRUE(channel2_->NeedsRtcpTransport()); |
1074 SendRtcp1(); | 1144 SendRtcp1(); |
1075 SendRtcp2(); | 1145 SendRtcp2(); |
1076 WaitForThreads(); | 1146 WaitForThreads(); |
1077 EXPECT_TRUE(CheckRtcp1()); | 1147 EXPECT_TRUE(CheckRtcp1()); |
1078 EXPECT_TRUE(CheckRtcp2()); | 1148 EXPECT_TRUE(CheckRtcp2()); |
1079 EXPECT_TRUE(CheckNoRtcp1()); | 1149 EXPECT_TRUE(CheckNoRtcp1()); |
1080 EXPECT_TRUE(CheckNoRtcp2()); | 1150 EXPECT_TRUE(CheckNoRtcp2()); |
1081 } | 1151 } |
1082 | 1152 |
1083 // Check that RTCP is transmitted if only the initiator supports mux. | 1153 // Check that RTCP is transmitted if only the initiator supports mux. |
1084 void SendRtcpMuxToRtcp() { | 1154 void SendRtcpMuxToRtcp() { |
1085 CreateChannels(RTCP_MUX, 0); | 1155 CreateChannels(RTCP_MUX, 0); |
1086 EXPECT_TRUE(SendInitiate()); | 1156 EXPECT_TRUE(SendInitiate()); |
1087 EXPECT_TRUE(SendAccept()); | 1157 EXPECT_TRUE(SendAccept()); |
1088 EXPECT_EQ(2U, GetChannels1().size()); | 1158 EXPECT_TRUE(channel1_->NeedsRtcpTransport()); |
1089 EXPECT_EQ(2U, GetChannels2().size()); | 1159 EXPECT_TRUE(channel2_->NeedsRtcpTransport()); |
1090 SendRtcp1(); | 1160 SendRtcp1(); |
1091 SendRtcp2(); | 1161 SendRtcp2(); |
1092 WaitForThreads(); | 1162 WaitForThreads(); |
1093 EXPECT_TRUE(CheckRtcp1()); | 1163 EXPECT_TRUE(CheckRtcp1()); |
1094 EXPECT_TRUE(CheckRtcp2()); | 1164 EXPECT_TRUE(CheckRtcp2()); |
1095 EXPECT_TRUE(CheckNoRtcp1()); | 1165 EXPECT_TRUE(CheckNoRtcp1()); |
1096 EXPECT_TRUE(CheckNoRtcp2()); | 1166 EXPECT_TRUE(CheckNoRtcp2()); |
1097 } | 1167 } |
1098 | 1168 |
1099 // Check that RTP and RTCP are transmitted ok when both sides support mux. | 1169 // Check that RTP and RTCP are transmitted ok when both sides support mux. |
1100 void SendRtcpMuxToRtcpMux() { | 1170 void SendRtcpMuxToRtcpMux() { |
1101 CreateChannels(RTCP_MUX, RTCP_MUX); | 1171 CreateChannels(RTCP_MUX, RTCP_MUX); |
1102 EXPECT_TRUE(SendInitiate()); | 1172 EXPECT_TRUE(SendInitiate()); |
1103 EXPECT_EQ(2U, GetChannels1().size()); | 1173 EXPECT_TRUE(channel1_->NeedsRtcpTransport()); |
1104 EXPECT_EQ(1U, GetChannels2().size()); | 1174 EXPECT_FALSE(channel2_->NeedsRtcpTransport()); |
| 1175 EXPECT_EQ(0, rtcp_mux_activated_callbacks1_); |
1105 EXPECT_TRUE(SendAccept()); | 1176 EXPECT_TRUE(SendAccept()); |
1106 EXPECT_EQ(1U, GetChannels1().size()); | 1177 EXPECT_FALSE(channel1_->NeedsRtcpTransport()); |
| 1178 EXPECT_EQ(1, rtcp_mux_activated_callbacks1_); |
1107 SendRtp1(); | 1179 SendRtp1(); |
1108 SendRtp2(); | 1180 SendRtp2(); |
1109 SendRtcp1(); | 1181 SendRtcp1(); |
1110 SendRtcp2(); | 1182 SendRtcp2(); |
1111 WaitForThreads(); | 1183 WaitForThreads(); |
1112 EXPECT_TRUE(CheckRtp1()); | 1184 EXPECT_TRUE(CheckRtp1()); |
1113 EXPECT_TRUE(CheckRtp2()); | 1185 EXPECT_TRUE(CheckRtp2()); |
1114 EXPECT_TRUE(CheckNoRtp1()); | 1186 EXPECT_TRUE(CheckNoRtp1()); |
1115 EXPECT_TRUE(CheckNoRtp2()); | 1187 EXPECT_TRUE(CheckNoRtp2()); |
1116 EXPECT_TRUE(CheckRtcp1()); | 1188 EXPECT_TRUE(CheckRtcp1()); |
1117 EXPECT_TRUE(CheckRtcp2()); | 1189 EXPECT_TRUE(CheckRtcp2()); |
1118 EXPECT_TRUE(CheckNoRtcp1()); | 1190 EXPECT_TRUE(CheckNoRtcp1()); |
1119 EXPECT_TRUE(CheckNoRtcp2()); | 1191 EXPECT_TRUE(CheckNoRtcp2()); |
1120 } | 1192 } |
1121 | 1193 |
1122 // Check that RTP and RTCP are transmitted ok when both sides | 1194 // Check that RTP and RTCP are transmitted ok when both sides |
1123 // support mux and one the offerer requires mux. | 1195 // support mux and one the offerer requires mux. |
1124 void SendRequireRtcpMuxToRtcpMux() { | 1196 void SendRequireRtcpMuxToRtcpMux() { |
1125 CreateChannels(RTCP_MUX | RTCP_MUX_REQUIRED, RTCP_MUX); | 1197 CreateChannels(RTCP_MUX | RTCP_MUX_REQUIRED, RTCP_MUX); |
1126 EXPECT_TRUE(SendInitiate()); | 1198 EXPECT_TRUE(SendInitiate()); |
1127 EXPECT_EQ(1U, GetChannels1().size()); | 1199 EXPECT_FALSE(channel1_->NeedsRtcpTransport()); |
1128 EXPECT_EQ(1U, GetChannels2().size()); | 1200 EXPECT_FALSE(channel2_->NeedsRtcpTransport()); |
1129 EXPECT_TRUE(SendAccept()); | 1201 EXPECT_TRUE(SendAccept()); |
1130 SendRtp1(); | 1202 SendRtp1(); |
1131 SendRtp2(); | 1203 SendRtp2(); |
1132 SendRtcp1(); | 1204 SendRtcp1(); |
1133 SendRtcp2(); | 1205 SendRtcp2(); |
1134 WaitForThreads(); | 1206 WaitForThreads(); |
1135 EXPECT_TRUE(CheckRtp1()); | 1207 EXPECT_TRUE(CheckRtp1()); |
1136 EXPECT_TRUE(CheckRtp2()); | 1208 EXPECT_TRUE(CheckRtp2()); |
1137 EXPECT_TRUE(CheckNoRtp1()); | 1209 EXPECT_TRUE(CheckNoRtp1()); |
1138 EXPECT_TRUE(CheckNoRtp2()); | 1210 EXPECT_TRUE(CheckNoRtp2()); |
1139 EXPECT_TRUE(CheckRtcp1()); | 1211 EXPECT_TRUE(CheckRtcp1()); |
1140 EXPECT_TRUE(CheckRtcp2()); | 1212 EXPECT_TRUE(CheckRtcp2()); |
1141 EXPECT_TRUE(CheckNoRtcp1()); | 1213 EXPECT_TRUE(CheckNoRtcp1()); |
1142 EXPECT_TRUE(CheckNoRtcp2()); | 1214 EXPECT_TRUE(CheckNoRtcp2()); |
1143 } | 1215 } |
1144 | 1216 |
1145 // Check that RTP and RTCP are transmitted ok when both sides | 1217 // Check that RTP and RTCP are transmitted ok when both sides |
1146 // support mux and only the answerer requires rtcp mux. | 1218 // support mux and only the answerer requires rtcp mux. |
1147 void SendRtcpMuxToRequireRtcpMux() { | 1219 void SendRtcpMuxToRequireRtcpMux() { |
1148 CreateChannels(RTCP_MUX, RTCP_MUX | RTCP_MUX_REQUIRED); | 1220 CreateChannels(RTCP_MUX, RTCP_MUX | RTCP_MUX_REQUIRED); |
1149 EXPECT_TRUE(SendInitiate()); | 1221 EXPECT_TRUE(SendInitiate()); |
1150 EXPECT_EQ(2U, GetChannels1().size()); | 1222 EXPECT_TRUE(channel1_->NeedsRtcpTransport()); |
1151 EXPECT_EQ(1U, GetChannels2().size()); | 1223 EXPECT_FALSE(channel2_->NeedsRtcpTransport()); |
| 1224 EXPECT_EQ(0, rtcp_mux_activated_callbacks1_); |
1152 EXPECT_TRUE(SendAccept()); | 1225 EXPECT_TRUE(SendAccept()); |
1153 EXPECT_EQ(1U, GetChannels1().size()); | 1226 EXPECT_FALSE(channel1_->NeedsRtcpTransport()); |
| 1227 EXPECT_EQ(1, rtcp_mux_activated_callbacks1_); |
1154 SendRtp1(); | 1228 SendRtp1(); |
1155 SendRtp2(); | 1229 SendRtp2(); |
1156 SendRtcp1(); | 1230 SendRtcp1(); |
1157 SendRtcp2(); | 1231 SendRtcp2(); |
1158 WaitForThreads(); | 1232 WaitForThreads(); |
1159 EXPECT_TRUE(CheckRtp1()); | 1233 EXPECT_TRUE(CheckRtp1()); |
1160 EXPECT_TRUE(CheckRtp2()); | 1234 EXPECT_TRUE(CheckRtp2()); |
1161 EXPECT_TRUE(CheckNoRtp1()); | 1235 EXPECT_TRUE(CheckNoRtp1()); |
1162 EXPECT_TRUE(CheckNoRtp2()); | 1236 EXPECT_TRUE(CheckNoRtp2()); |
1163 EXPECT_TRUE(CheckRtcp1()); | 1237 EXPECT_TRUE(CheckRtcp1()); |
1164 EXPECT_TRUE(CheckRtcp2()); | 1238 EXPECT_TRUE(CheckRtcp2()); |
1165 EXPECT_TRUE(CheckNoRtcp1()); | 1239 EXPECT_TRUE(CheckNoRtcp1()); |
1166 EXPECT_TRUE(CheckNoRtcp2()); | 1240 EXPECT_TRUE(CheckNoRtcp2()); |
1167 } | 1241 } |
1168 | 1242 |
1169 // Check that RTP and RTCP are transmitted ok when both sides | 1243 // Check that RTP and RTCP are transmitted ok when both sides |
1170 // require mux. | 1244 // require mux. |
1171 void SendRequireRtcpMuxToRequireRtcpMux() { | 1245 void SendRequireRtcpMuxToRequireRtcpMux() { |
1172 CreateChannels(RTCP_MUX | RTCP_MUX_REQUIRED, RTCP_MUX | RTCP_MUX_REQUIRED); | 1246 CreateChannels(RTCP_MUX | RTCP_MUX_REQUIRED, RTCP_MUX | RTCP_MUX_REQUIRED); |
1173 EXPECT_TRUE(SendInitiate()); | 1247 EXPECT_TRUE(SendInitiate()); |
1174 EXPECT_EQ(1U, GetChannels1().size()); | 1248 EXPECT_FALSE(channel1_->NeedsRtcpTransport()); |
1175 EXPECT_EQ(1U, GetChannels2().size()); | 1249 EXPECT_FALSE(channel2_->NeedsRtcpTransport()); |
1176 EXPECT_TRUE(SendAccept()); | 1250 EXPECT_TRUE(SendAccept()); |
1177 EXPECT_EQ(1U, GetChannels1().size()); | 1251 EXPECT_FALSE(channel1_->NeedsRtcpTransport()); |
1178 SendRtp1(); | 1252 SendRtp1(); |
1179 SendRtp2(); | 1253 SendRtp2(); |
1180 SendRtcp1(); | 1254 SendRtcp1(); |
1181 SendRtcp2(); | 1255 SendRtcp2(); |
1182 WaitForThreads(); | 1256 WaitForThreads(); |
1183 EXPECT_TRUE(CheckRtp1()); | 1257 EXPECT_TRUE(CheckRtp1()); |
1184 EXPECT_TRUE(CheckRtp2()); | 1258 EXPECT_TRUE(CheckRtp2()); |
1185 EXPECT_TRUE(CheckNoRtp1()); | 1259 EXPECT_TRUE(CheckNoRtp1()); |
1186 EXPECT_TRUE(CheckNoRtp2()); | 1260 EXPECT_TRUE(CheckNoRtp2()); |
1187 EXPECT_TRUE(CheckRtcp1()); | 1261 EXPECT_TRUE(CheckRtcp1()); |
1188 EXPECT_TRUE(CheckRtcp2()); | 1262 EXPECT_TRUE(CheckRtcp2()); |
1189 EXPECT_TRUE(CheckNoRtcp1()); | 1263 EXPECT_TRUE(CheckNoRtcp1()); |
1190 EXPECT_TRUE(CheckNoRtcp2()); | 1264 EXPECT_TRUE(CheckNoRtcp2()); |
1191 } | 1265 } |
1192 | 1266 |
1193 // Check that SendAccept fails if the answerer doesn't support mux | 1267 // Check that SendAccept fails if the answerer doesn't support mux |
1194 // and the offerer requires it. | 1268 // and the offerer requires it. |
1195 void SendRequireRtcpMuxToNoRtcpMux() { | 1269 void SendRequireRtcpMuxToNoRtcpMux() { |
1196 CreateChannels(RTCP_MUX | RTCP_MUX_REQUIRED, 0); | 1270 CreateChannels(RTCP_MUX | RTCP_MUX_REQUIRED, 0); |
1197 EXPECT_TRUE(SendInitiate()); | 1271 EXPECT_TRUE(SendInitiate()); |
1198 EXPECT_EQ(1U, GetChannels1().size()); | 1272 EXPECT_FALSE(channel1_->NeedsRtcpTransport()); |
1199 EXPECT_EQ(2U, GetChannels2().size()); | 1273 EXPECT_TRUE(channel2_->NeedsRtcpTransport()); |
1200 EXPECT_FALSE(SendAccept()); | 1274 EXPECT_FALSE(SendAccept()); |
1201 } | 1275 } |
1202 | 1276 |
1203 // Check that RTCP data sent by the initiator before the accept is not muxed. | 1277 // Check that RTCP data sent by the initiator before the accept is not muxed. |
1204 void SendEarlyRtcpMuxToRtcp() { | 1278 void SendEarlyRtcpMuxToRtcp() { |
1205 CreateChannels(RTCP_MUX, 0); | 1279 CreateChannels(RTCP_MUX, 0); |
1206 EXPECT_TRUE(SendInitiate()); | 1280 EXPECT_TRUE(SendInitiate()); |
1207 EXPECT_EQ(2U, GetChannels1().size()); | 1281 EXPECT_TRUE(channel1_->NeedsRtcpTransport()); |
1208 EXPECT_EQ(2U, GetChannels2().size()); | 1282 EXPECT_TRUE(channel2_->NeedsRtcpTransport()); |
1209 | 1283 |
1210 // RTCP can be sent before the call is accepted, if the transport is ready. | 1284 // RTCP can be sent before the call is accepted, if the transport is ready. |
1211 // It should not be muxed though, as the remote side doesn't support mux. | 1285 // It should not be muxed though, as the remote side doesn't support mux. |
1212 SendRtcp1(); | 1286 SendRtcp1(); |
1213 WaitForThreads(); | 1287 WaitForThreads(); |
1214 EXPECT_TRUE(CheckNoRtp2()); | 1288 EXPECT_TRUE(CheckNoRtp2()); |
1215 EXPECT_TRUE(CheckRtcp2()); | 1289 EXPECT_TRUE(CheckRtcp2()); |
1216 | 1290 |
1217 // Send RTCP packet from callee and verify that it is received. | 1291 // Send RTCP packet from callee and verify that it is received. |
1218 SendRtcp2(); | 1292 SendRtcp2(); |
1219 WaitForThreads(); | 1293 WaitForThreads(); |
1220 EXPECT_TRUE(CheckNoRtp1()); | 1294 EXPECT_TRUE(CheckNoRtp1()); |
1221 EXPECT_TRUE(CheckRtcp1()); | 1295 EXPECT_TRUE(CheckRtcp1()); |
1222 | 1296 |
1223 // Complete call setup and ensure everything is still OK. | 1297 // Complete call setup and ensure everything is still OK. |
1224 EXPECT_TRUE(SendAccept()); | 1298 EXPECT_TRUE(SendAccept()); |
1225 EXPECT_EQ(2U, GetChannels1().size()); | 1299 EXPECT_TRUE(channel1_->NeedsRtcpTransport()); |
1226 SendRtcp1(); | 1300 SendRtcp1(); |
1227 SendRtcp2(); | 1301 SendRtcp2(); |
1228 WaitForThreads(); | 1302 WaitForThreads(); |
1229 EXPECT_TRUE(CheckRtcp2()); | 1303 EXPECT_TRUE(CheckRtcp2()); |
1230 EXPECT_TRUE(CheckRtcp1()); | 1304 EXPECT_TRUE(CheckRtcp1()); |
1231 } | 1305 } |
1232 | 1306 |
1233 | 1307 |
1234 // Check that RTCP data is not muxed until both sides have enabled muxing, | 1308 // Check that RTCP data is not muxed until both sides have enabled muxing, |
1235 // but that we properly demux before we get the accept message, since there | 1309 // but that we properly demux before we get the accept message, since there |
1236 // is a race between RTP data and the jingle accept. | 1310 // is a race between RTP data and the jingle accept. |
1237 void SendEarlyRtcpMuxToRtcpMux() { | 1311 void SendEarlyRtcpMuxToRtcpMux() { |
1238 CreateChannels(RTCP_MUX, RTCP_MUX); | 1312 CreateChannels(RTCP_MUX, RTCP_MUX); |
1239 EXPECT_TRUE(SendInitiate()); | 1313 EXPECT_TRUE(SendInitiate()); |
1240 EXPECT_EQ(2U, GetChannels1().size()); | 1314 EXPECT_TRUE(channel1_->NeedsRtcpTransport()); |
1241 EXPECT_EQ(1U, GetChannels2().size()); | 1315 EXPECT_FALSE(channel2_->NeedsRtcpTransport()); |
1242 | 1316 |
1243 // RTCP can't be sent yet, since the RTCP transport isn't writable, and | 1317 // RTCP can't be sent yet, since the RTCP transport isn't writable, and |
1244 // we haven't yet received the accept that says we should mux. | 1318 // we haven't yet received the accept that says we should mux. |
1245 SendRtcp1(); | 1319 SendRtcp1(); |
1246 WaitForThreads(); | 1320 WaitForThreads(); |
1247 EXPECT_TRUE(CheckNoRtcp2()); | 1321 EXPECT_TRUE(CheckNoRtcp2()); |
1248 | 1322 |
1249 // Send muxed RTCP packet from callee and verify that it is received. | 1323 // Send muxed RTCP packet from callee and verify that it is received. |
1250 SendRtcp2(); | 1324 SendRtcp2(); |
1251 WaitForThreads(); | 1325 WaitForThreads(); |
1252 EXPECT_TRUE(CheckNoRtp1()); | 1326 EXPECT_TRUE(CheckNoRtp1()); |
1253 EXPECT_TRUE(CheckRtcp1()); | 1327 EXPECT_TRUE(CheckRtcp1()); |
1254 | 1328 |
1255 // Complete call setup and ensure everything is still OK. | 1329 // Complete call setup and ensure everything is still OK. |
| 1330 EXPECT_EQ(0, rtcp_mux_activated_callbacks1_); |
1256 EXPECT_TRUE(SendAccept()); | 1331 EXPECT_TRUE(SendAccept()); |
1257 EXPECT_EQ(1U, GetChannels1().size()); | 1332 EXPECT_FALSE(channel1_->NeedsRtcpTransport()); |
| 1333 EXPECT_EQ(1, rtcp_mux_activated_callbacks1_); |
1258 SendRtcp1(); | 1334 SendRtcp1(); |
1259 SendRtcp2(); | 1335 SendRtcp2(); |
1260 WaitForThreads(); | 1336 WaitForThreads(); |
1261 EXPECT_TRUE(CheckRtcp2()); | 1337 EXPECT_TRUE(CheckRtcp2()); |
1262 EXPECT_TRUE(CheckRtcp1()); | 1338 EXPECT_TRUE(CheckRtcp1()); |
1263 } | 1339 } |
1264 | 1340 |
1265 // Test that we properly send SRTP with RTCP in both directions. | 1341 // Test that we properly send SRTP with RTCP in both directions. |
1266 // You can pass in DTLS and/or RTCP_MUX as flags. | 1342 // You can pass in DTLS, RTCP_MUX, GCM_CIPHER and RAW_PACKET_TRANSPORT as |
| 1343 // flags. |
1267 void SendSrtpToSrtp(int flags1_in = 0, int flags2_in = 0) { | 1344 void SendSrtpToSrtp(int flags1_in = 0, int flags2_in = 0) { |
1268 RTC_CHECK((flags1_in & ~(RTCP_MUX | DTLS | GCM_CIPHER)) == 0); | 1345 RTC_CHECK((flags1_in & |
1269 RTC_CHECK((flags2_in & ~(RTCP_MUX | DTLS | GCM_CIPHER)) == 0); | 1346 ~(RTCP_MUX | DTLS | GCM_CIPHER | RAW_PACKET_TRANSPORT)) == 0); |
| 1347 RTC_CHECK((flags2_in & |
| 1348 ~(RTCP_MUX | DTLS | GCM_CIPHER | RAW_PACKET_TRANSPORT)) == 0); |
1270 | 1349 |
1271 int flags1 = SECURE | flags1_in; | 1350 int flags1 = SECURE | flags1_in; |
1272 int flags2 = SECURE | flags2_in; | 1351 int flags2 = SECURE | flags2_in; |
1273 bool dtls1 = !!(flags1_in & DTLS); | 1352 bool dtls1 = !!(flags1_in & DTLS); |
1274 bool dtls2 = !!(flags2_in & DTLS); | 1353 bool dtls2 = !!(flags2_in & DTLS); |
1275 CreateChannels(flags1, flags2); | 1354 CreateChannels(flags1, flags2); |
1276 EXPECT_FALSE(channel1_->secure()); | 1355 EXPECT_FALSE(channel1_->secure()); |
1277 EXPECT_FALSE(channel2_->secure()); | 1356 EXPECT_FALSE(channel2_->secure()); |
1278 EXPECT_TRUE(SendInitiate()); | 1357 EXPECT_TRUE(SendInitiate()); |
1279 WaitForThreads(); | 1358 WaitForThreads(); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1335 // sent and received. The test uses SRTP, RTCP mux and SSRC mux. | 1414 // sent and received. The test uses SRTP, RTCP mux and SSRC mux. |
1336 void SendEarlyMediaUsingRtcpMuxSrtp() { | 1415 void SendEarlyMediaUsingRtcpMuxSrtp() { |
1337 int sequence_number1_1 = 0, sequence_number2_2 = 0; | 1416 int sequence_number1_1 = 0, sequence_number2_2 = 0; |
1338 | 1417 |
1339 CreateChannels(SSRC_MUX | RTCP_MUX | SECURE, | 1418 CreateChannels(SSRC_MUX | RTCP_MUX | SECURE, |
1340 SSRC_MUX | RTCP_MUX | SECURE); | 1419 SSRC_MUX | RTCP_MUX | SECURE); |
1341 EXPECT_TRUE(SendOffer()); | 1420 EXPECT_TRUE(SendOffer()); |
1342 EXPECT_TRUE(SendProvisionalAnswer()); | 1421 EXPECT_TRUE(SendProvisionalAnswer()); |
1343 EXPECT_TRUE(channel1_->secure()); | 1422 EXPECT_TRUE(channel1_->secure()); |
1344 EXPECT_TRUE(channel2_->secure()); | 1423 EXPECT_TRUE(channel2_->secure()); |
1345 EXPECT_EQ(2U, GetChannels1().size()); | 1424 EXPECT_TRUE(channel1_->NeedsRtcpTransport()); |
1346 EXPECT_EQ(2U, GetChannels2().size()); | 1425 EXPECT_TRUE(channel2_->NeedsRtcpTransport()); |
1347 WaitForThreads(); // Wait for 'sending' flag go through network thread. | 1426 WaitForThreads(); // Wait for 'sending' flag go through network thread. |
1348 SendCustomRtcp1(kSsrc1); | 1427 SendCustomRtcp1(kSsrc1); |
1349 SendCustomRtp1(kSsrc1, ++sequence_number1_1); | 1428 SendCustomRtp1(kSsrc1, ++sequence_number1_1); |
1350 WaitForThreads(); | 1429 WaitForThreads(); |
1351 EXPECT_TRUE(CheckCustomRtcp2(kSsrc1)); | 1430 EXPECT_TRUE(CheckCustomRtcp2(kSsrc1)); |
1352 EXPECT_TRUE(CheckCustomRtp2(kSsrc1, sequence_number1_1)); | 1431 EXPECT_TRUE(CheckCustomRtp2(kSsrc1, sequence_number1_1)); |
1353 | 1432 |
1354 // Send packets from callee and verify that it is received. | 1433 // Send packets from callee and verify that it is received. |
1355 SendCustomRtcp2(kSsrc2); | 1434 SendCustomRtcp2(kSsrc2); |
1356 SendCustomRtp2(kSsrc2, ++sequence_number2_2); | 1435 SendCustomRtp2(kSsrc2, ++sequence_number2_2); |
1357 WaitForThreads(); | 1436 WaitForThreads(); |
1358 EXPECT_TRUE(CheckCustomRtcp1(kSsrc2)); | 1437 EXPECT_TRUE(CheckCustomRtcp1(kSsrc2)); |
1359 EXPECT_TRUE(CheckCustomRtp1(kSsrc2, sequence_number2_2)); | 1438 EXPECT_TRUE(CheckCustomRtp1(kSsrc2, sequence_number2_2)); |
1360 | 1439 |
1361 // Complete call setup and ensure everything is still OK. | 1440 // Complete call setup and ensure everything is still OK. |
| 1441 EXPECT_EQ(0, rtcp_mux_activated_callbacks1_); |
| 1442 EXPECT_EQ(0, rtcp_mux_activated_callbacks2_); |
1362 EXPECT_TRUE(SendFinalAnswer()); | 1443 EXPECT_TRUE(SendFinalAnswer()); |
1363 EXPECT_EQ(1U, GetChannels1().size()); | 1444 EXPECT_FALSE(channel1_->NeedsRtcpTransport()); |
1364 EXPECT_EQ(1U, GetChannels2().size()); | 1445 EXPECT_FALSE(channel2_->NeedsRtcpTransport()); |
| 1446 EXPECT_EQ(1, rtcp_mux_activated_callbacks1_); |
| 1447 EXPECT_EQ(1, rtcp_mux_activated_callbacks2_); |
1365 EXPECT_TRUE(channel1_->secure()); | 1448 EXPECT_TRUE(channel1_->secure()); |
1366 EXPECT_TRUE(channel2_->secure()); | 1449 EXPECT_TRUE(channel2_->secure()); |
1367 SendCustomRtcp1(kSsrc1); | 1450 SendCustomRtcp1(kSsrc1); |
1368 SendCustomRtp1(kSsrc1, ++sequence_number1_1); | 1451 SendCustomRtp1(kSsrc1, ++sequence_number1_1); |
1369 SendCustomRtcp2(kSsrc2); | 1452 SendCustomRtcp2(kSsrc2); |
1370 SendCustomRtp2(kSsrc2, ++sequence_number2_2); | 1453 SendCustomRtp2(kSsrc2, ++sequence_number2_2); |
1371 WaitForThreads(); | 1454 WaitForThreads(); |
1372 EXPECT_TRUE(CheckCustomRtcp2(kSsrc1)); | 1455 EXPECT_TRUE(CheckCustomRtcp2(kSsrc1)); |
1373 EXPECT_TRUE(CheckCustomRtp2(kSsrc1, sequence_number1_1)); | 1456 EXPECT_TRUE(CheckCustomRtp2(kSsrc1, sequence_number1_1)); |
1374 EXPECT_TRUE(CheckCustomRtcp1(kSsrc2)); | 1457 EXPECT_TRUE(CheckCustomRtcp1(kSsrc2)); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1420 EXPECT_TRUE(CheckNoRtcp1()); | 1503 EXPECT_TRUE(CheckNoRtcp1()); |
1421 EXPECT_TRUE(CheckNoRtcp2()); | 1504 EXPECT_TRUE(CheckNoRtcp2()); |
1422 } | 1505 } |
1423 | 1506 |
1424 // Test that the mediachannel retains its sending state after the transport | 1507 // Test that the mediachannel retains its sending state after the transport |
1425 // becomes non-writable. | 1508 // becomes non-writable. |
1426 void SendWithWritabilityLoss() { | 1509 void SendWithWritabilityLoss() { |
1427 CreateChannels(RTCP_MUX | RTCP_MUX_REQUIRED, RTCP_MUX | RTCP_MUX_REQUIRED); | 1510 CreateChannels(RTCP_MUX | RTCP_MUX_REQUIRED, RTCP_MUX | RTCP_MUX_REQUIRED); |
1428 EXPECT_TRUE(SendInitiate()); | 1511 EXPECT_TRUE(SendInitiate()); |
1429 EXPECT_TRUE(SendAccept()); | 1512 EXPECT_TRUE(SendAccept()); |
1430 EXPECT_EQ(1U, GetChannels1().size()); | 1513 EXPECT_FALSE(channel1_->NeedsRtcpTransport()); |
1431 EXPECT_EQ(1U, GetChannels2().size()); | 1514 EXPECT_FALSE(channel2_->NeedsRtcpTransport()); |
1432 SendRtp1(); | 1515 SendRtp1(); |
1433 SendRtp2(); | 1516 SendRtp2(); |
1434 WaitForThreads(); | 1517 WaitForThreads(); |
1435 EXPECT_TRUE(CheckRtp1()); | 1518 EXPECT_TRUE(CheckRtp1()); |
1436 EXPECT_TRUE(CheckRtp2()); | 1519 EXPECT_TRUE(CheckRtp2()); |
1437 EXPECT_TRUE(CheckNoRtp1()); | 1520 EXPECT_TRUE(CheckNoRtp1()); |
1438 EXPECT_TRUE(CheckNoRtp2()); | 1521 EXPECT_TRUE(CheckNoRtp2()); |
1439 | 1522 |
1440 // Lose writability, which should fail. | 1523 // Lose writability, which should fail. |
1441 network_thread_->Invoke<void>( | 1524 network_thread_->Invoke<void>(RTC_FROM_HERE, [this] { |
1442 RTC_FROM_HERE, [this] { GetFakeChannel1(1)->SetWritable(false); }); | 1525 fake_rtp_dtls_transport1_->SetWritable(false); |
| 1526 }); |
1443 SendRtp1(); | 1527 SendRtp1(); |
1444 SendRtp2(); | 1528 SendRtp2(); |
1445 WaitForThreads(); | 1529 WaitForThreads(); |
1446 EXPECT_TRUE(CheckRtp1()); | 1530 EXPECT_TRUE(CheckRtp1()); |
1447 EXPECT_TRUE(CheckNoRtp2()); | 1531 EXPECT_TRUE(CheckNoRtp2()); |
1448 | 1532 |
1449 // Regain writability | 1533 // Regain writability |
1450 network_thread_->Invoke<void>( | 1534 network_thread_->Invoke<void>(RTC_FROM_HERE, [this] { |
1451 RTC_FROM_HERE, [this] { GetFakeChannel1(1)->SetWritable(true); }); | 1535 fake_rtp_dtls_transport1_->SetWritable(true); |
| 1536 }); |
1452 EXPECT_TRUE(media_channel1_->sending()); | 1537 EXPECT_TRUE(media_channel1_->sending()); |
1453 SendRtp1(); | 1538 SendRtp1(); |
1454 SendRtp2(); | 1539 SendRtp2(); |
1455 WaitForThreads(); | 1540 WaitForThreads(); |
1456 EXPECT_TRUE(CheckRtp1()); | 1541 EXPECT_TRUE(CheckRtp1()); |
1457 EXPECT_TRUE(CheckRtp2()); | 1542 EXPECT_TRUE(CheckRtp2()); |
1458 EXPECT_TRUE(CheckNoRtp1()); | 1543 EXPECT_TRUE(CheckNoRtp1()); |
1459 EXPECT_TRUE(CheckNoRtp2()); | 1544 EXPECT_TRUE(CheckNoRtp2()); |
1460 | 1545 |
1461 // Lose writability completely | 1546 // Lose writability completely |
1462 network_thread_->Invoke<void>( | 1547 network_thread_->Invoke<void>(RTC_FROM_HERE, [this] { |
1463 RTC_FROM_HERE, [this] { GetFakeChannel1(1)->SetDestination(nullptr); }); | 1548 bool asymmetric = true; |
| 1549 fake_rtp_dtls_transport1_->SetDestination(nullptr, asymmetric); |
| 1550 }); |
1464 EXPECT_TRUE(media_channel1_->sending()); | 1551 EXPECT_TRUE(media_channel1_->sending()); |
1465 | 1552 |
1466 // Should fail also. | 1553 // Should fail also. |
1467 SendRtp1(); | 1554 SendRtp1(); |
1468 SendRtp2(); | 1555 SendRtp2(); |
1469 WaitForThreads(); | 1556 WaitForThreads(); |
1470 EXPECT_TRUE(CheckRtp1()); | 1557 EXPECT_TRUE(CheckRtp1()); |
1471 EXPECT_TRUE(CheckNoRtp2()); | 1558 EXPECT_TRUE(CheckNoRtp2()); |
1472 EXPECT_TRUE(CheckNoRtp1()); | 1559 EXPECT_TRUE(CheckNoRtp1()); |
1473 | 1560 |
1474 // Gain writability back | 1561 // Gain writability back |
1475 network_thread_->Invoke<void>(RTC_FROM_HERE, [this] { | 1562 network_thread_->Invoke<void>(RTC_FROM_HERE, [this] { |
1476 GetFakeChannel1(1)->SetDestination(GetFakeChannel2(1)); | 1563 bool asymmetric = true; |
| 1564 fake_rtp_dtls_transport1_->SetDestination(fake_rtp_dtls_transport2_.get(), |
| 1565 asymmetric); |
1477 }); | 1566 }); |
1478 EXPECT_TRUE(media_channel1_->sending()); | 1567 EXPECT_TRUE(media_channel1_->sending()); |
1479 SendRtp1(); | 1568 SendRtp1(); |
1480 SendRtp2(); | 1569 SendRtp2(); |
1481 WaitForThreads(); | 1570 WaitForThreads(); |
1482 EXPECT_TRUE(CheckRtp1()); | 1571 EXPECT_TRUE(CheckRtp1()); |
1483 EXPECT_TRUE(CheckRtp2()); | 1572 EXPECT_TRUE(CheckRtp2()); |
1484 EXPECT_TRUE(CheckNoRtp1()); | 1573 EXPECT_TRUE(CheckNoRtp1()); |
1485 EXPECT_TRUE(CheckNoRtp2()); | 1574 EXPECT_TRUE(CheckNoRtp2()); |
1486 } | 1575 } |
1487 | 1576 |
1488 void SendBundleToBundle( | 1577 void SendBundleToBundle( |
1489 const int* pl_types, int len, bool rtcp_mux, bool secure) { | 1578 const int* pl_types, int len, bool rtcp_mux, bool secure) { |
1490 ASSERT_EQ(2, len); | 1579 ASSERT_EQ(2, len); |
1491 int sequence_number1_1 = 0, sequence_number2_2 = 0; | 1580 int sequence_number1_1 = 0, sequence_number2_2 = 0; |
1492 // Only pl_type1 was added to the bundle filter for both |channel1_| | 1581 // Only pl_type1 was added to the bundle filter for both |channel1_| |
1493 // and |channel2_|. | 1582 // and |channel2_|. |
1494 int pl_type1 = pl_types[0]; | 1583 int pl_type1 = pl_types[0]; |
1495 int pl_type2 = pl_types[1]; | 1584 int pl_type2 = pl_types[1]; |
1496 int flags = SSRC_MUX; | 1585 int flags = SSRC_MUX; |
1497 if (secure) flags |= SECURE; | 1586 if (secure) flags |= SECURE; |
1498 uint32_t expected_channels = 2U; | |
1499 if (rtcp_mux) { | 1587 if (rtcp_mux) { |
1500 flags |= RTCP_MUX; | 1588 flags |= RTCP_MUX; |
1501 expected_channels = 1U; | |
1502 } | 1589 } |
1503 CreateChannels(flags, flags); | 1590 CreateChannels(flags, flags); |
1504 EXPECT_TRUE(SendInitiate()); | 1591 EXPECT_TRUE(SendInitiate()); |
1505 EXPECT_EQ(2U, GetChannels1().size()); | 1592 EXPECT_TRUE(channel1_->NeedsRtcpTransport()); |
1506 EXPECT_EQ(expected_channels, GetChannels2().size()); | 1593 EXPECT_EQ(rtcp_mux, !channel2_->NeedsRtcpTransport()); |
1507 EXPECT_TRUE(SendAccept()); | 1594 EXPECT_TRUE(SendAccept()); |
1508 EXPECT_EQ(expected_channels, GetChannels1().size()); | 1595 EXPECT_EQ(rtcp_mux, !channel1_->NeedsRtcpTransport()); |
1509 EXPECT_EQ(expected_channels, GetChannels2().size()); | 1596 EXPECT_EQ(rtcp_mux, !channel2_->NeedsRtcpTransport()); |
1510 EXPECT_TRUE(channel1_->bundle_filter()->FindPayloadType(pl_type1)); | 1597 EXPECT_TRUE(channel1_->bundle_filter()->FindPayloadType(pl_type1)); |
1511 EXPECT_TRUE(channel2_->bundle_filter()->FindPayloadType(pl_type1)); | 1598 EXPECT_TRUE(channel2_->bundle_filter()->FindPayloadType(pl_type1)); |
1512 EXPECT_FALSE(channel1_->bundle_filter()->FindPayloadType(pl_type2)); | 1599 EXPECT_FALSE(channel1_->bundle_filter()->FindPayloadType(pl_type2)); |
1513 EXPECT_FALSE(channel2_->bundle_filter()->FindPayloadType(pl_type2)); | 1600 EXPECT_FALSE(channel2_->bundle_filter()->FindPayloadType(pl_type2)); |
1514 | 1601 |
1515 // Both channels can receive pl_type1 only. | 1602 // Both channels can receive pl_type1 only. |
1516 SendCustomRtp1(kSsrc1, ++sequence_number1_1, pl_type1); | 1603 SendCustomRtp1(kSsrc1, ++sequence_number1_1, pl_type1); |
1517 SendCustomRtp2(kSsrc2, ++sequence_number2_2, pl_type1); | 1604 SendCustomRtp2(kSsrc2, ++sequence_number2_2, pl_type1); |
1518 WaitForThreads(); | 1605 WaitForThreads(); |
1519 EXPECT_TRUE(CheckCustomRtp2(kSsrc1, sequence_number1_1, pl_type1)); | 1606 EXPECT_TRUE(CheckCustomRtp2(kSsrc1, sequence_number1_1, pl_type1)); |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1679 sdesc3.get(), cricket::CA_ANSWER, &err)); | 1766 sdesc3.get(), cricket::CA_ANSWER, &err)); |
1680 EXPECT_TRUE(media_channel1_->HasSendStream(1)); | 1767 EXPECT_TRUE(media_channel1_->HasSendStream(1)); |
1681 EXPECT_FALSE(media_channel1_->HasRecvStream(2)); | 1768 EXPECT_FALSE(media_channel1_->HasRecvStream(2)); |
1682 EXPECT_TRUE(media_channel1_->HasRecvStream(3)); | 1769 EXPECT_TRUE(media_channel1_->HasRecvStream(3)); |
1683 } | 1770 } |
1684 | 1771 |
1685 void TestFlushRtcp() { | 1772 void TestFlushRtcp() { |
1686 CreateChannels(0, 0); | 1773 CreateChannels(0, 0); |
1687 EXPECT_TRUE(SendInitiate()); | 1774 EXPECT_TRUE(SendInitiate()); |
1688 EXPECT_TRUE(SendAccept()); | 1775 EXPECT_TRUE(SendAccept()); |
1689 EXPECT_EQ(2U, GetChannels1().size()); | 1776 EXPECT_TRUE(channel1_->NeedsRtcpTransport()); |
1690 EXPECT_EQ(2U, GetChannels2().size()); | 1777 EXPECT_TRUE(channel2_->NeedsRtcpTransport()); |
1691 | 1778 |
1692 // Send RTCP1 from a different thread. | 1779 // Send RTCP1 from a different thread. |
1693 ScopedCallThread send_rtcp([this] { SendRtcp1(); }); | 1780 ScopedCallThread send_rtcp([this] { SendRtcp1(); }); |
1694 // The sending message is only posted. channel2_ should be empty. | 1781 // The sending message is only posted. channel2_ should be empty. |
1695 EXPECT_TRUE(CheckNoRtcp2()); | 1782 EXPECT_TRUE(CheckNoRtcp2()); |
1696 rtc::Thread* wait_for[] = {send_rtcp.thread()}; | 1783 rtc::Thread* wait_for[] = {send_rtcp.thread()}; |
1697 WaitForThreads(wait_for); // Ensure rtcp was posted | 1784 WaitForThreads(wait_for); // Ensure rtcp was posted |
1698 | 1785 |
1699 // When channel1_ is deleted, the RTCP packet should be sent out to | 1786 // When channel1_ is deleted, the RTCP packet should be sent out to |
1700 // channel2_. | 1787 // channel2_. |
(...skipping 25 matching lines...) Expand all Loading... |
1726 0x84, static_cast<unsigned char>(pl_type), | 1813 0x84, static_cast<unsigned char>(pl_type), |
1727 0x00, 0x01, | 1814 0x00, 0x01, |
1728 0x00, 0x00, | 1815 0x00, 0x00, |
1729 0x00, 0x00, | 1816 0x00, 0x00, |
1730 0x00, 0x00, | 1817 0x00, 0x00, |
1731 0x00, 0x01}; | 1818 0x00, 0x01}; |
1732 | 1819 |
1733 // Using fake clock because this tests that SRTP errors are signaled at | 1820 // Using fake clock because this tests that SRTP errors are signaled at |
1734 // specific times based on set_signal_silent_time. | 1821 // specific times based on set_signal_silent_time. |
1735 rtc::ScopedFakeClock fake_clock; | 1822 rtc::ScopedFakeClock fake_clock; |
| 1823 |
| 1824 CreateChannels(SECURE, SECURE); |
1736 // Some code uses a time of 0 as a special value, so we must start with | 1825 // Some code uses a time of 0 as a special value, so we must start with |
1737 // a non-zero time. | 1826 // a non-zero time. |
1738 // TODO(deadbeef): Fix this. | 1827 // TODO(deadbeef): Fix this. |
1739 fake_clock.AdvanceTime(rtc::TimeDelta::FromSeconds(1)); | 1828 fake_clock.AdvanceTime(rtc::TimeDelta::FromSeconds(1)); |
1740 | 1829 |
1741 CreateChannels(SECURE, SECURE); | |
1742 EXPECT_FALSE(channel1_->secure()); | 1830 EXPECT_FALSE(channel1_->secure()); |
1743 EXPECT_FALSE(channel2_->secure()); | 1831 EXPECT_FALSE(channel2_->secure()); |
1744 EXPECT_TRUE(SendInitiate()); | 1832 EXPECT_TRUE(SendInitiate()); |
1745 EXPECT_TRUE(SendAccept()); | 1833 EXPECT_TRUE(SendAccept()); |
1746 EXPECT_TRUE(channel1_->secure()); | 1834 EXPECT_TRUE(channel1_->secure()); |
1747 EXPECT_TRUE(channel2_->secure()); | 1835 EXPECT_TRUE(channel2_->secure()); |
1748 channel2_->srtp_filter()->set_signal_silent_time(250); | 1836 channel2_->srtp_filter()->set_signal_silent_time(250); |
1749 channel2_->srtp_filter()->SignalSrtpError.connect( | 1837 channel2_->srtp_filter()->SignalSrtpError.connect( |
1750 &error_handler, &SrtpErrorHandler::OnSrtpError); | 1838 &error_handler, &SrtpErrorHandler::OnSrtpError); |
1751 | 1839 |
(...skipping 20 matching lines...) Expand all Loading... |
1772 rtc::PacketOptions()); | 1860 rtc::PacketOptions()); |
1773 WaitForThreads(); | 1861 WaitForThreads(); |
1774 EXPECT_EQ(cricket::SrtpFilter::ERROR_FAIL, error_handler.error_); | 1862 EXPECT_EQ(cricket::SrtpFilter::ERROR_FAIL, error_handler.error_); |
1775 EXPECT_EQ(cricket::SrtpFilter::PROTECT, error_handler.mode_); | 1863 EXPECT_EQ(cricket::SrtpFilter::PROTECT, error_handler.mode_); |
1776 | 1864 |
1777 // Testing failures in receiving packets. | 1865 // Testing failures in receiving packets. |
1778 error_handler.error_ = cricket::SrtpFilter::ERROR_NONE; | 1866 error_handler.error_ = cricket::SrtpFilter::ERROR_NONE; |
1779 error_handler.mode_ = cricket::SrtpFilter::UNPROTECT; | 1867 error_handler.mode_ = cricket::SrtpFilter::UNPROTECT; |
1780 | 1868 |
1781 network_thread_->Invoke<void>(RTC_FROM_HERE, [this] { | 1869 network_thread_->Invoke<void>(RTC_FROM_HERE, [this] { |
1782 cricket::DtlsTransportInternal* transport_channel = | 1870 fake_rtp_dtls_transport2_->SignalReadPacket( |
1783 channel2_->rtp_dtls_transport(); | 1871 fake_rtp_dtls_transport2_.get(), |
1784 transport_channel->SignalReadPacket( | 1872 reinterpret_cast<const char*>(kBadPacket), sizeof(kBadPacket), |
1785 transport_channel, reinterpret_cast<const char*>(kBadPacket), | 1873 rtc::PacketTime(), 0); |
1786 sizeof(kBadPacket), rtc::PacketTime(), 0); | |
1787 }); | 1874 }); |
1788 EXPECT_EQ(cricket::SrtpFilter::ERROR_FAIL, error_handler.error_); | 1875 EXPECT_EQ(cricket::SrtpFilter::ERROR_FAIL, error_handler.error_); |
1789 EXPECT_EQ(cricket::SrtpFilter::UNPROTECT, error_handler.mode_); | 1876 EXPECT_EQ(cricket::SrtpFilter::UNPROTECT, error_handler.mode_); |
1790 // Terminate channels before the fake clock is destroyed. | 1877 // Terminate channels/threads before the fake clock is destroyed. |
1791 EXPECT_TRUE(SendTerminate()); | 1878 EXPECT_TRUE(Terminate()); |
1792 } | 1879 } |
1793 | 1880 |
1794 void TestOnReadyToSend() { | 1881 void TestOnReadyToSend() { |
1795 CreateChannels(0, 0); | 1882 CreateChannels(0, 0); |
1796 DtlsTransportInternal* rtp = channel1_->rtp_dtls_transport(); | 1883 cricket::FakeDtlsTransport* rtp = fake_rtp_dtls_transport1_.get(); |
1797 DtlsTransportInternal* rtcp = channel1_->rtcp_dtls_transport(); | 1884 cricket::FakeDtlsTransport* rtcp = fake_rtcp_dtls_transport1_.get(); |
1798 EXPECT_FALSE(media_channel1_->ready_to_send()); | 1885 EXPECT_FALSE(media_channel1_->ready_to_send()); |
1799 | 1886 |
1800 network_thread_->Invoke<void>(RTC_FROM_HERE, | 1887 network_thread_->Invoke<void>(RTC_FROM_HERE, |
1801 [rtp] { rtp->SignalReadyToSend(rtp); }); | 1888 [rtp] { rtp->SignalReadyToSend(rtp); }); |
1802 WaitForThreads(); | 1889 WaitForThreads(); |
1803 EXPECT_FALSE(media_channel1_->ready_to_send()); | 1890 EXPECT_FALSE(media_channel1_->ready_to_send()); |
1804 | 1891 |
1805 network_thread_->Invoke<void>(RTC_FROM_HERE, | 1892 network_thread_->Invoke<void>(RTC_FROM_HERE, |
1806 [rtcp] { rtcp->SignalReadyToSend(rtcp); }); | 1893 [rtcp] { rtcp->SignalReadyToSend(rtcp); }); |
1807 WaitForThreads(); | 1894 WaitForThreads(); |
(...skipping 25 matching lines...) Expand all Loading... |
1833 channel1_->SetTransportChannelReadyToSend(true, true); | 1920 channel1_->SetTransportChannelReadyToSend(true, true); |
1834 }); | 1921 }); |
1835 WaitForThreads(); | 1922 WaitForThreads(); |
1836 EXPECT_TRUE(media_channel1_->ready_to_send()); | 1923 EXPECT_TRUE(media_channel1_->ready_to_send()); |
1837 } | 1924 } |
1838 | 1925 |
1839 void TestOnReadyToSendWithRtcpMux() { | 1926 void TestOnReadyToSendWithRtcpMux() { |
1840 CreateChannels(0, 0); | 1927 CreateChannels(0, 0); |
1841 typename T::Content content; | 1928 typename T::Content content; |
1842 CreateContent(0, kPcmuCodec, kH264Codec, &content); | 1929 CreateContent(0, kPcmuCodec, kH264Codec, &content); |
1843 // Both sides agree on mux. Should no longer be a separate RTCP channel. | 1930 // Both sides agree on mux. Should signal that RTCP mux is fully active. |
1844 content.set_rtcp_mux(true); | 1931 content.set_rtcp_mux(true); |
1845 EXPECT_TRUE(channel1_->SetLocalContent(&content, CA_OFFER, NULL)); | 1932 EXPECT_TRUE(channel1_->SetLocalContent(&content, CA_OFFER, NULL)); |
| 1933 EXPECT_EQ(0, rtcp_mux_activated_callbacks1_); |
1846 EXPECT_TRUE(channel1_->SetRemoteContent(&content, CA_ANSWER, NULL)); | 1934 EXPECT_TRUE(channel1_->SetRemoteContent(&content, CA_ANSWER, NULL)); |
1847 EXPECT_TRUE(channel1_->rtcp_dtls_transport() == NULL); | 1935 EXPECT_EQ(1, rtcp_mux_activated_callbacks1_); |
1848 DtlsTransportInternal* rtp = channel1_->rtp_dtls_transport(); | 1936 cricket::FakeDtlsTransport* rtp = fake_rtp_dtls_transport1_.get(); |
1849 EXPECT_FALSE(media_channel1_->ready_to_send()); | 1937 EXPECT_FALSE(media_channel1_->ready_to_send()); |
1850 // In the case of rtcp mux, the SignalReadyToSend() from rtp channel | 1938 // In the case of rtcp mux, the SignalReadyToSend() from rtp channel |
1851 // should trigger the MediaChannel's OnReadyToSend. | 1939 // should trigger the MediaChannel's OnReadyToSend. |
1852 network_thread_->Invoke<void>(RTC_FROM_HERE, | 1940 network_thread_->Invoke<void>(RTC_FROM_HERE, |
1853 [rtp] { rtp->SignalReadyToSend(rtp); }); | 1941 [rtp] { rtp->SignalReadyToSend(rtp); }); |
1854 WaitForThreads(); | 1942 WaitForThreads(); |
1855 EXPECT_TRUE(media_channel1_->ready_to_send()); | 1943 EXPECT_TRUE(media_channel1_->ready_to_send()); |
1856 | 1944 |
1857 network_thread_->Invoke<void>(RTC_FROM_HERE, [this] { | 1945 network_thread_->Invoke<void>(RTC_FROM_HERE, [this] { |
1858 channel1_->SetTransportChannelReadyToSend(false, false); | 1946 channel1_->SetTransportChannelReadyToSend(false, false); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1929 RTC_FROM_HERE, [this] { ProcessThreadQueue(network_thread_); }); | 2017 RTC_FROM_HERE, [this] { ProcessThreadQueue(network_thread_); }); |
1930 } | 2018 } |
1931 // Worker thread = current Thread process received messages. | 2019 // Worker thread = current Thread process received messages. |
1932 ProcessThreadQueue(rtc::Thread::Current()); | 2020 ProcessThreadQueue(rtc::Thread::Current()); |
1933 } | 2021 } |
1934 // TODO(pbos): Remove playout from all media channels and let renderers mute | 2022 // TODO(pbos): Remove playout from all media channels and let renderers mute |
1935 // themselves. | 2023 // themselves. |
1936 const bool verify_playout_; | 2024 const bool verify_playout_; |
1937 std::unique_ptr<rtc::Thread> network_thread_keeper_; | 2025 std::unique_ptr<rtc::Thread> network_thread_keeper_; |
1938 rtc::Thread* network_thread_; | 2026 rtc::Thread* network_thread_; |
1939 std::unique_ptr<cricket::FakeTransportController> transport_controller1_; | 2027 std::unique_ptr<cricket::FakeDtlsTransport> fake_rtp_dtls_transport1_; |
1940 std::unique_ptr<cricket::FakeTransportController> transport_controller2_; | 2028 std::unique_ptr<cricket::FakeDtlsTransport> fake_rtcp_dtls_transport1_; |
| 2029 std::unique_ptr<cricket::FakeDtlsTransport> fake_rtp_dtls_transport2_; |
| 2030 std::unique_ptr<cricket::FakeDtlsTransport> fake_rtcp_dtls_transport2_; |
| 2031 std::unique_ptr<rtc::FakePacketTransport> fake_rtp_packet_transport1_; |
| 2032 std::unique_ptr<rtc::FakePacketTransport> fake_rtcp_packet_transport1_; |
| 2033 std::unique_ptr<rtc::FakePacketTransport> fake_rtp_packet_transport2_; |
| 2034 std::unique_ptr<rtc::FakePacketTransport> fake_rtcp_packet_transport2_; |
1941 cricket::FakeMediaEngine media_engine_; | 2035 cricket::FakeMediaEngine media_engine_; |
1942 // The media channels are owned by the voice channel objects below. | 2036 // The media channels are owned by the voice channel objects below. |
1943 typename T::MediaChannel* media_channel1_; | 2037 typename T::MediaChannel* media_channel1_ = nullptr; |
1944 typename T::MediaChannel* media_channel2_; | 2038 typename T::MediaChannel* media_channel2_ = nullptr; |
1945 std::unique_ptr<typename T::Channel> channel1_; | 2039 std::unique_ptr<typename T::Channel> channel1_; |
1946 std::unique_ptr<typename T::Channel> channel2_; | 2040 std::unique_ptr<typename T::Channel> channel2_; |
1947 typename T::Content local_media_content1_; | 2041 typename T::Content local_media_content1_; |
1948 typename T::Content local_media_content2_; | 2042 typename T::Content local_media_content2_; |
1949 typename T::Content remote_media_content1_; | 2043 typename T::Content remote_media_content1_; |
1950 typename T::Content remote_media_content2_; | 2044 typename T::Content remote_media_content2_; |
1951 // The RTP and RTCP packets to send in the tests. | 2045 // The RTP and RTCP packets to send in the tests. |
1952 rtc::Buffer rtp_packet_; | 2046 rtc::Buffer rtp_packet_; |
1953 rtc::Buffer rtcp_packet_; | 2047 rtc::Buffer rtcp_packet_; |
1954 int media_info_callbacks1_; | 2048 int media_info_callbacks1_ = 0; |
1955 int media_info_callbacks2_; | 2049 int media_info_callbacks2_ = 0; |
| 2050 int rtcp_mux_activated_callbacks1_ = 0; |
| 2051 int rtcp_mux_activated_callbacks2_ = 0; |
1956 cricket::CandidatePairInterface* last_selected_candidate_pair_; | 2052 cricket::CandidatePairInterface* last_selected_candidate_pair_; |
1957 }; | 2053 }; |
1958 | 2054 |
1959 template<> | 2055 template<> |
1960 void ChannelTest<VoiceTraits>::CreateContent( | 2056 void ChannelTest<VoiceTraits>::CreateContent( |
1961 int flags, | 2057 int flags, |
1962 const cricket::AudioCodec& audio_codec, | 2058 const cricket::AudioCodec& audio_codec, |
1963 const cricket::VideoCodec& video_codec, | 2059 const cricket::VideoCodec& video_codec, |
1964 cricket::AudioContentDescription* audio) { | 2060 cricket::AudioContentDescription* audio) { |
1965 audio->AddCodec(audio_codec); | 2061 audio->AddCodec(audio_codec); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2007 : Base(true, kPcmuFrame, kRtcpReport, NetworkIsWorker::No) {} | 2103 : Base(true, kPcmuFrame, kRtcpReport, NetworkIsWorker::No) {} |
2008 }; | 2104 }; |
2009 | 2105 |
2010 // override to add NULL parameter | 2106 // override to add NULL parameter |
2011 template <> | 2107 template <> |
2012 cricket::VideoChannel* ChannelTest<VideoTraits>::CreateChannel( | 2108 cricket::VideoChannel* ChannelTest<VideoTraits>::CreateChannel( |
2013 rtc::Thread* worker_thread, | 2109 rtc::Thread* worker_thread, |
2014 rtc::Thread* network_thread, | 2110 rtc::Thread* network_thread, |
2015 cricket::MediaEngineInterface* engine, | 2111 cricket::MediaEngineInterface* engine, |
2016 cricket::FakeVideoMediaChannel* ch, | 2112 cricket::FakeVideoMediaChannel* ch, |
2017 cricket::TransportController* transport_controller, | 2113 cricket::DtlsTransportInternal* fake_rtp_dtls_transport, |
| 2114 cricket::DtlsTransportInternal* fake_rtcp_dtls_transport, |
| 2115 rtc::PacketTransportInterface* fake_rtp_packet_transport, |
| 2116 rtc::PacketTransportInterface* fake_rtcp_packet_transport, |
2018 int flags) { | 2117 int flags) { |
2019 rtc::Thread* signaling_thread = | 2118 rtc::Thread* signaling_thread = rtc::Thread::Current(); |
2020 transport_controller ? transport_controller->signaling_thread() : nullptr; | |
2021 cricket::VideoChannel* channel = new cricket::VideoChannel( | 2119 cricket::VideoChannel* channel = new cricket::VideoChannel( |
2022 worker_thread, network_thread, signaling_thread, ch, cricket::CN_VIDEO, | 2120 worker_thread, network_thread, signaling_thread, ch, cricket::CN_VIDEO, |
2023 (flags & RTCP_MUX_REQUIRED) != 0, (flags & SECURE) != 0); | 2121 (flags & RTCP_MUX_REQUIRED) != 0, (flags & SECURE) != 0); |
2024 rtc::CryptoOptions crypto_options; | 2122 rtc::CryptoOptions crypto_options; |
2025 crypto_options.enable_gcm_crypto_suites = (flags & GCM_CIPHER) != 0; | 2123 crypto_options.enable_gcm_crypto_suites = (flags & GCM_CIPHER) != 0; |
2026 channel->SetCryptoOptions(crypto_options); | 2124 channel->SetCryptoOptions(crypto_options); |
2027 cricket::DtlsTransportInternal* rtp_dtls_transport = | 2125 if (!channel->NeedsRtcpTransport()) { |
2028 transport_controller->CreateDtlsTransport( | 2126 fake_rtcp_dtls_transport = nullptr; |
2029 channel->content_name(), cricket::ICE_CANDIDATE_COMPONENT_RTP); | |
2030 cricket::DtlsTransportInternal* rtcp_dtls_transport = nullptr; | |
2031 if (channel->NeedsRtcpTransport()) { | |
2032 rtcp_dtls_transport = transport_controller->CreateDtlsTransport( | |
2033 channel->content_name(), cricket::ICE_CANDIDATE_COMPONENT_RTCP); | |
2034 } | 2127 } |
2035 if (!channel->Init_w(rtp_dtls_transport, rtcp_dtls_transport)) { | 2128 if (!channel->Init_w(fake_rtp_dtls_transport, fake_rtcp_dtls_transport, |
| 2129 fake_rtp_packet_transport, fake_rtcp_packet_transport)) { |
2036 delete channel; | 2130 delete channel; |
2037 channel = NULL; | 2131 channel = NULL; |
2038 } | 2132 } |
2039 return channel; | 2133 return channel; |
2040 } | 2134 } |
2041 | 2135 |
2042 // override to add 0 parameter | 2136 // override to add 0 parameter |
2043 template<> | 2137 template<> |
2044 bool ChannelTest<VideoTraits>::AddStream1(int id) { | 2138 bool ChannelTest<VideoTraits>::AddStream1(int id) { |
2045 return channel1_->AddRecvStream(cricket::StreamParams::CreateLegacy(id)); | 2139 return channel1_->AddRecvStream(cricket::StreamParams::CreateLegacy(id)); |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2253 } | 2347 } |
2254 | 2348 |
2255 TEST_F(VoiceChannelSingleThreadTest, SendDtlsSrtpToDtlsSrtpGcmTwo) { | 2349 TEST_F(VoiceChannelSingleThreadTest, SendDtlsSrtpToDtlsSrtpGcmTwo) { |
2256 Base::SendSrtpToSrtp(DTLS, DTLS | GCM_CIPHER); | 2350 Base::SendSrtpToSrtp(DTLS, DTLS | GCM_CIPHER); |
2257 } | 2351 } |
2258 | 2352 |
2259 TEST_F(VoiceChannelSingleThreadTest, SendDtlsSrtpToDtlsSrtpRtcpMux) { | 2353 TEST_F(VoiceChannelSingleThreadTest, SendDtlsSrtpToDtlsSrtpRtcpMux) { |
2260 Base::SendSrtpToSrtp(DTLS | RTCP_MUX, DTLS | RTCP_MUX); | 2354 Base::SendSrtpToSrtp(DTLS | RTCP_MUX, DTLS | RTCP_MUX); |
2261 } | 2355 } |
2262 | 2356 |
| 2357 // Test using the channel with a raw packet interface, as opposed to a DTLS |
| 2358 // transport interface. |
| 2359 TEST_F(VoiceChannelSingleThreadTest, SendSrtpToSrtpWithRawPacketTransport) { |
| 2360 Base::SendSrtpToSrtp(RAW_PACKET_TRANSPORT, RAW_PACKET_TRANSPORT); |
| 2361 } |
| 2362 |
2263 TEST_F(VoiceChannelSingleThreadTest, SendEarlyMediaUsingRtcpMuxSrtp) { | 2363 TEST_F(VoiceChannelSingleThreadTest, SendEarlyMediaUsingRtcpMuxSrtp) { |
2264 Base::SendEarlyMediaUsingRtcpMuxSrtp(); | 2364 Base::SendEarlyMediaUsingRtcpMuxSrtp(); |
2265 } | 2365 } |
2266 | 2366 |
2267 TEST_F(VoiceChannelSingleThreadTest, SendRtpToRtpOnThread) { | 2367 TEST_F(VoiceChannelSingleThreadTest, SendRtpToRtpOnThread) { |
2268 Base::SendRtpToRtpOnThread(); | 2368 Base::SendRtpToRtpOnThread(); |
2269 } | 2369 } |
2270 | 2370 |
2271 TEST_F(VoiceChannelSingleThreadTest, SendSrtpToSrtpOnThread) { | 2371 TEST_F(VoiceChannelSingleThreadTest, SendSrtpToSrtpOnThread) { |
2272 Base::SendSrtpToSrtpOnThread(); | 2372 Base::SendSrtpToSrtpOnThread(); |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2580 } | 2680 } |
2581 | 2681 |
2582 TEST_F(VoiceChannelDoubleThreadTest, SendDtlsSrtpToDtlsSrtpGcmTwo) { | 2682 TEST_F(VoiceChannelDoubleThreadTest, SendDtlsSrtpToDtlsSrtpGcmTwo) { |
2583 Base::SendSrtpToSrtp(DTLS, DTLS | GCM_CIPHER); | 2683 Base::SendSrtpToSrtp(DTLS, DTLS | GCM_CIPHER); |
2584 } | 2684 } |
2585 | 2685 |
2586 TEST_F(VoiceChannelDoubleThreadTest, SendDtlsSrtpToDtlsSrtpRtcpMux) { | 2686 TEST_F(VoiceChannelDoubleThreadTest, SendDtlsSrtpToDtlsSrtpRtcpMux) { |
2587 Base::SendSrtpToSrtp(DTLS | RTCP_MUX, DTLS | RTCP_MUX); | 2687 Base::SendSrtpToSrtp(DTLS | RTCP_MUX, DTLS | RTCP_MUX); |
2588 } | 2688 } |
2589 | 2689 |
| 2690 // Test using the channel with a raw packet interface, as opposed to a DTLS |
| 2691 // transport interface. |
| 2692 TEST_F(VoiceChannelDoubleThreadTest, SendSrtpToSrtpWithRawPacketTransport) { |
| 2693 Base::SendSrtpToSrtp(RAW_PACKET_TRANSPORT, RAW_PACKET_TRANSPORT); |
| 2694 } |
| 2695 |
2590 TEST_F(VoiceChannelDoubleThreadTest, SendEarlyMediaUsingRtcpMuxSrtp) { | 2696 TEST_F(VoiceChannelDoubleThreadTest, SendEarlyMediaUsingRtcpMuxSrtp) { |
2591 Base::SendEarlyMediaUsingRtcpMuxSrtp(); | 2697 Base::SendEarlyMediaUsingRtcpMuxSrtp(); |
2592 } | 2698 } |
2593 | 2699 |
2594 TEST_F(VoiceChannelDoubleThreadTest, SendRtpToRtpOnThread) { | 2700 TEST_F(VoiceChannelDoubleThreadTest, SendRtpToRtpOnThread) { |
2595 Base::SendRtpToRtpOnThread(); | 2701 Base::SendRtpToRtpOnThread(); |
2596 } | 2702 } |
2597 | 2703 |
2598 TEST_F(VoiceChannelDoubleThreadTest, SendSrtpToSrtpOnThread) { | 2704 TEST_F(VoiceChannelDoubleThreadTest, SendSrtpToSrtpOnThread) { |
2599 Base::SendSrtpToSrtpOnThread(); | 2705 Base::SendSrtpToSrtpOnThread(); |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2887 } | 2993 } |
2888 | 2994 |
2889 TEST_F(VideoChannelSingleThreadTest, SendDtlsSrtpToDtlsSrtp) { | 2995 TEST_F(VideoChannelSingleThreadTest, SendDtlsSrtpToDtlsSrtp) { |
2890 Base::SendSrtpToSrtp(DTLS, DTLS); | 2996 Base::SendSrtpToSrtp(DTLS, DTLS); |
2891 } | 2997 } |
2892 | 2998 |
2893 TEST_F(VideoChannelSingleThreadTest, SendDtlsSrtpToDtlsSrtpRtcpMux) { | 2999 TEST_F(VideoChannelSingleThreadTest, SendDtlsSrtpToDtlsSrtpRtcpMux) { |
2894 Base::SendSrtpToSrtp(DTLS | RTCP_MUX, DTLS | RTCP_MUX); | 3000 Base::SendSrtpToSrtp(DTLS | RTCP_MUX, DTLS | RTCP_MUX); |
2895 } | 3001 } |
2896 | 3002 |
| 3003 // Test using the channel with a raw packet interface, as opposed to a DTLS |
| 3004 // transport interface. |
| 3005 TEST_F(VideoChannelSingleThreadTest, SendSrtpToSrtpWithRawPacketTransport) { |
| 3006 Base::SendSrtpToSrtp(RAW_PACKET_TRANSPORT, RAW_PACKET_TRANSPORT); |
| 3007 } |
| 3008 |
2897 TEST_F(VideoChannelSingleThreadTest, SendSrtcpMux) { | 3009 TEST_F(VideoChannelSingleThreadTest, SendSrtcpMux) { |
2898 Base::SendSrtpToSrtp(RTCP_MUX, RTCP_MUX); | 3010 Base::SendSrtpToSrtp(RTCP_MUX, RTCP_MUX); |
2899 } | 3011 } |
2900 | 3012 |
2901 TEST_F(VideoChannelSingleThreadTest, SendEarlyMediaUsingRtcpMuxSrtp) { | 3013 TEST_F(VideoChannelSingleThreadTest, SendEarlyMediaUsingRtcpMuxSrtp) { |
2902 Base::SendEarlyMediaUsingRtcpMuxSrtp(); | 3014 Base::SendEarlyMediaUsingRtcpMuxSrtp(); |
2903 } | 3015 } |
2904 | 3016 |
2905 TEST_F(VideoChannelSingleThreadTest, SendRtpToRtpOnThread) { | 3017 TEST_F(VideoChannelSingleThreadTest, SendRtpToRtpOnThread) { |
2906 Base::SendRtpToRtpOnThread(); | 3018 Base::SendRtpToRtpOnThread(); |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3116 } | 3228 } |
3117 | 3229 |
3118 TEST_F(VideoChannelDoubleThreadTest, SendDtlsSrtpToDtlsSrtp) { | 3230 TEST_F(VideoChannelDoubleThreadTest, SendDtlsSrtpToDtlsSrtp) { |
3119 Base::SendSrtpToSrtp(DTLS, DTLS); | 3231 Base::SendSrtpToSrtp(DTLS, DTLS); |
3120 } | 3232 } |
3121 | 3233 |
3122 TEST_F(VideoChannelDoubleThreadTest, SendDtlsSrtpToDtlsSrtpRtcpMux) { | 3234 TEST_F(VideoChannelDoubleThreadTest, SendDtlsSrtpToDtlsSrtpRtcpMux) { |
3123 Base::SendSrtpToSrtp(DTLS | RTCP_MUX, DTLS | RTCP_MUX); | 3235 Base::SendSrtpToSrtp(DTLS | RTCP_MUX, DTLS | RTCP_MUX); |
3124 } | 3236 } |
3125 | 3237 |
| 3238 // Test using the channel with a raw packet interface, as opposed to a DTLS |
| 3239 // transport interface. |
| 3240 TEST_F(VideoChannelDoubleThreadTest, SendSrtpToSrtpWithRawPacketTransport) { |
| 3241 Base::SendSrtpToSrtp(RAW_PACKET_TRANSPORT, RAW_PACKET_TRANSPORT); |
| 3242 } |
| 3243 |
3126 TEST_F(VideoChannelDoubleThreadTest, SendSrtcpMux) { | 3244 TEST_F(VideoChannelDoubleThreadTest, SendSrtcpMux) { |
3127 Base::SendSrtpToSrtp(RTCP_MUX, RTCP_MUX); | 3245 Base::SendSrtpToSrtp(RTCP_MUX, RTCP_MUX); |
3128 } | 3246 } |
3129 | 3247 |
3130 TEST_F(VideoChannelDoubleThreadTest, SendEarlyMediaUsingRtcpMuxSrtp) { | 3248 TEST_F(VideoChannelDoubleThreadTest, SendEarlyMediaUsingRtcpMuxSrtp) { |
3131 Base::SendEarlyMediaUsingRtcpMuxSrtp(); | 3249 Base::SendEarlyMediaUsingRtcpMuxSrtp(); |
3132 } | 3250 } |
3133 | 3251 |
3134 TEST_F(VideoChannelDoubleThreadTest, SendRtpToRtpOnThread) { | 3252 TEST_F(VideoChannelDoubleThreadTest, SendRtpToRtpOnThread) { |
3135 Base::SendRtpToRtpOnThread(); | 3253 Base::SendRtpToRtpOnThread(); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3223 : Base(true, kDataPacket, kRtcpReport, NetworkIsWorker::No) {} | 3341 : Base(true, kDataPacket, kRtcpReport, NetworkIsWorker::No) {} |
3224 }; | 3342 }; |
3225 | 3343 |
3226 // Override to avoid engine channel parameter. | 3344 // Override to avoid engine channel parameter. |
3227 template <> | 3345 template <> |
3228 cricket::RtpDataChannel* ChannelTest<DataTraits>::CreateChannel( | 3346 cricket::RtpDataChannel* ChannelTest<DataTraits>::CreateChannel( |
3229 rtc::Thread* worker_thread, | 3347 rtc::Thread* worker_thread, |
3230 rtc::Thread* network_thread, | 3348 rtc::Thread* network_thread, |
3231 cricket::MediaEngineInterface* engine, | 3349 cricket::MediaEngineInterface* engine, |
3232 cricket::FakeDataMediaChannel* ch, | 3350 cricket::FakeDataMediaChannel* ch, |
3233 cricket::TransportController* transport_controller, | 3351 cricket::DtlsTransportInternal* fake_rtp_dtls_transport, |
| 3352 cricket::DtlsTransportInternal* fake_rtcp_dtls_transport, |
| 3353 rtc::PacketTransportInterface* fake_rtp_packet_transport, |
| 3354 rtc::PacketTransportInterface* fake_rtcp_packet_transport, |
3234 int flags) { | 3355 int flags) { |
3235 rtc::Thread* signaling_thread = | 3356 rtc::Thread* signaling_thread = rtc::Thread::Current(); |
3236 transport_controller ? transport_controller->signaling_thread() : nullptr; | |
3237 cricket::RtpDataChannel* channel = new cricket::RtpDataChannel( | 3357 cricket::RtpDataChannel* channel = new cricket::RtpDataChannel( |
3238 worker_thread, network_thread, signaling_thread, ch, cricket::CN_DATA, | 3358 worker_thread, network_thread, signaling_thread, ch, cricket::CN_DATA, |
3239 (flags & RTCP_MUX_REQUIRED) != 0, (flags & SECURE) != 0); | 3359 (flags & RTCP_MUX_REQUIRED) != 0, (flags & SECURE) != 0); |
3240 rtc::CryptoOptions crypto_options; | 3360 rtc::CryptoOptions crypto_options; |
3241 crypto_options.enable_gcm_crypto_suites = (flags & GCM_CIPHER) != 0; | 3361 crypto_options.enable_gcm_crypto_suites = (flags & GCM_CIPHER) != 0; |
3242 channel->SetCryptoOptions(crypto_options); | 3362 channel->SetCryptoOptions(crypto_options); |
3243 cricket::DtlsTransportInternal* rtp_dtls_transport = | 3363 if (!channel->NeedsRtcpTransport()) { |
3244 transport_controller->CreateDtlsTransport( | 3364 fake_rtcp_dtls_transport = nullptr; |
3245 channel->content_name(), cricket::ICE_CANDIDATE_COMPONENT_RTP); | |
3246 cricket::DtlsTransportInternal* rtcp_dtls_transport = nullptr; | |
3247 if (channel->NeedsRtcpTransport()) { | |
3248 rtcp_dtls_transport = transport_controller->CreateDtlsTransport( | |
3249 channel->content_name(), cricket::ICE_CANDIDATE_COMPONENT_RTCP); | |
3250 } | 3365 } |
3251 if (!channel->Init_w(rtp_dtls_transport, rtcp_dtls_transport)) { | 3366 if (!channel->Init_w(fake_rtp_dtls_transport, fake_rtcp_dtls_transport, |
| 3367 fake_rtp_packet_transport, fake_rtcp_packet_transport)) { |
3252 delete channel; | 3368 delete channel; |
3253 channel = NULL; | 3369 channel = NULL; |
3254 } | 3370 } |
3255 return channel; | 3371 return channel; |
3256 } | 3372 } |
3257 | 3373 |
3258 template <> | 3374 template <> |
3259 void ChannelTest<DataTraits>::CreateContent( | 3375 void ChannelTest<DataTraits>::CreateContent( |
3260 int flags, | 3376 int flags, |
3261 const cricket::AudioCodec& audio_codec, | 3377 const cricket::AudioCodec& audio_codec, |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3558 EXPECT_EQ("foo", media_channel1_->last_sent_data()); | 3674 EXPECT_EQ("foo", media_channel1_->last_sent_data()); |
3559 } | 3675 } |
3560 | 3676 |
3561 #if RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) | 3677 #if RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) |
3562 | 3678 |
3563 // Verifies some DCHECKs are in place. | 3679 // Verifies some DCHECKs are in place. |
3564 // Uses VoiceChannel, but any BaseChannel subclass would work. | 3680 // Uses VoiceChannel, but any BaseChannel subclass would work. |
3565 class BaseChannelDeathTest : public testing::Test { | 3681 class BaseChannelDeathTest : public testing::Test { |
3566 public: | 3682 public: |
3567 BaseChannelDeathTest() | 3683 BaseChannelDeathTest() |
3568 : // RTCP mux not required, SRTP required. | 3684 : fake_rtp_dtls_transport_("foo", cricket::ICE_CANDIDATE_COMPONENT_RTP), |
| 3685 fake_rtcp_dtls_transport_("foo", cricket::ICE_CANDIDATE_COMPONENT_RTCP), |
| 3686 // RTCP mux not required, SRTP required. |
3569 voice_channel_( | 3687 voice_channel_( |
3570 rtc::Thread::Current(), | 3688 rtc::Thread::Current(), |
3571 rtc::Thread::Current(), | 3689 rtc::Thread::Current(), |
3572 rtc::Thread::Current(), | 3690 rtc::Thread::Current(), |
3573 &fake_media_engine_, | 3691 &fake_media_engine_, |
3574 new cricket::FakeVoiceMediaChannel(nullptr, | 3692 new cricket::FakeVoiceMediaChannel(nullptr, |
3575 cricket::AudioOptions()), | 3693 cricket::AudioOptions()), |
3576 cricket::CN_AUDIO, | 3694 cricket::CN_AUDIO, |
3577 false, | 3695 false, |
3578 true) { | 3696 true) {} |
3579 rtp_transport_ = fake_transport_controller_.CreateDtlsTransport( | |
3580 "foo", cricket::ICE_CANDIDATE_COMPONENT_RTP); | |
3581 rtcp_transport_ = fake_transport_controller_.CreateDtlsTransport( | |
3582 "foo", cricket::ICE_CANDIDATE_COMPONENT_RTCP); | |
3583 EXPECT_TRUE(voice_channel_.Init_w(rtp_transport_, rtcp_transport_)); | |
3584 } | |
3585 | 3697 |
3586 protected: | 3698 protected: |
3587 cricket::FakeTransportController fake_transport_controller_; | |
3588 cricket::FakeMediaEngine fake_media_engine_; | 3699 cricket::FakeMediaEngine fake_media_engine_; |
| 3700 cricket::FakeDtlsTransport fake_rtp_dtls_transport_; |
| 3701 cricket::FakeDtlsTransport fake_rtcp_dtls_transport_; |
3589 cricket::VoiceChannel voice_channel_; | 3702 cricket::VoiceChannel voice_channel_; |
3590 // Will be cleaned up by FakeTransportController, don't need to worry about | |
3591 // deleting them in this test. | |
3592 cricket::DtlsTransportInternal* rtp_transport_; | |
3593 cricket::DtlsTransportInternal* rtcp_transport_; | |
3594 }; | 3703 }; |
3595 | 3704 |
3596 TEST_F(BaseChannelDeathTest, SetTransportWithNullRtpTransport) { | 3705 TEST_F(BaseChannelDeathTest, SetTransportsWithNullRtpTransport) { |
3597 cricket::DtlsTransportInternal* new_rtcp_transport = | 3706 ASSERT_TRUE(voice_channel_.Init_w( |
3598 fake_transport_controller_.CreateDtlsTransport( | 3707 &fake_rtp_dtls_transport_, &fake_rtcp_dtls_transport_, |
3599 "bar", cricket::ICE_CANDIDATE_COMPONENT_RTCP); | 3708 &fake_rtp_dtls_transport_, &fake_rtcp_dtls_transport_)); |
3600 EXPECT_DEATH(voice_channel_.SetTransports(nullptr, new_rtcp_transport), ""); | 3709 cricket::FakeDtlsTransport new_rtcp_transport( |
| 3710 "bar", cricket::ICE_CANDIDATE_COMPONENT_RTCP); |
| 3711 EXPECT_DEATH(voice_channel_.SetTransports(nullptr, &new_rtcp_transport), ""); |
3601 } | 3712 } |
3602 | 3713 |
3603 TEST_F(BaseChannelDeathTest, SetTransportWithMissingRtcpTransport) { | 3714 TEST_F(BaseChannelDeathTest, SetTransportsWithMissingRtcpTransport) { |
3604 cricket::DtlsTransportInternal* new_rtp_transport = | 3715 ASSERT_TRUE(voice_channel_.Init_w( |
3605 fake_transport_controller_.CreateDtlsTransport( | 3716 &fake_rtp_dtls_transport_, &fake_rtcp_dtls_transport_, |
3606 "bar", cricket::ICE_CANDIDATE_COMPONENT_RTP); | 3717 &fake_rtp_dtls_transport_, &fake_rtcp_dtls_transport_)); |
3607 EXPECT_DEATH(voice_channel_.SetTransports(new_rtp_transport, nullptr), ""); | 3718 cricket::FakeDtlsTransport new_rtp_transport( |
| 3719 "bar", cricket::ICE_CANDIDATE_COMPONENT_RTP); |
| 3720 EXPECT_DEATH(voice_channel_.SetTransports(&new_rtp_transport, nullptr), ""); |
3608 } | 3721 } |
3609 | 3722 |
3610 TEST_F(BaseChannelDeathTest, SetTransportWithUnneededRtcpTransport) { | 3723 TEST_F(BaseChannelDeathTest, SetTransportsWithUnneededRtcpTransport) { |
| 3724 ASSERT_TRUE(voice_channel_.Init_w( |
| 3725 &fake_rtp_dtls_transport_, &fake_rtcp_dtls_transport_, |
| 3726 &fake_rtp_dtls_transport_, &fake_rtcp_dtls_transport_)); |
3611 // Activate RTCP muxing, simulating offer/answer negotiation. | 3727 // Activate RTCP muxing, simulating offer/answer negotiation. |
3612 cricket::AudioContentDescription content; | 3728 cricket::AudioContentDescription content; |
3613 content.set_rtcp_mux(true); | 3729 content.set_rtcp_mux(true); |
3614 ASSERT_TRUE(voice_channel_.SetLocalContent(&content, CA_OFFER, nullptr)); | 3730 ASSERT_TRUE(voice_channel_.SetLocalContent(&content, CA_OFFER, nullptr)); |
3615 ASSERT_TRUE(voice_channel_.SetRemoteContent(&content, CA_ANSWER, nullptr)); | 3731 ASSERT_TRUE(voice_channel_.SetRemoteContent(&content, CA_ANSWER, nullptr)); |
3616 cricket::DtlsTransportInternal* new_rtp_transport = | 3732 cricket::FakeDtlsTransport new_rtp_transport( |
3617 fake_transport_controller_.CreateDtlsTransport( | 3733 "bar", cricket::ICE_CANDIDATE_COMPONENT_RTP); |
3618 "bar", cricket::ICE_CANDIDATE_COMPONENT_RTP); | 3734 cricket::FakeDtlsTransport new_rtcp_transport( |
3619 cricket::DtlsTransportInternal* new_rtcp_transport = | 3735 "bar", cricket::ICE_CANDIDATE_COMPONENT_RTCP); |
3620 fake_transport_controller_.CreateDtlsTransport( | |
3621 "bar", cricket::ICE_CANDIDATE_COMPONENT_RTCP); | |
3622 // After muxing is enabled, no RTCP transport should be passed in here. | 3736 // After muxing is enabled, no RTCP transport should be passed in here. |
3623 EXPECT_DEATH( | 3737 EXPECT_DEATH( |
3624 voice_channel_.SetTransports(new_rtp_transport, new_rtcp_transport), ""); | 3738 voice_channel_.SetTransports(&new_rtp_transport, &new_rtcp_transport), |
| 3739 ""); |
3625 } | 3740 } |
3626 | 3741 |
3627 // This test will probably go away if/when we move the transport name out of | 3742 // This test will probably go away if/when we move the transport name out of |
3628 // the transport classes and into their parent classes. | 3743 // the transport classes and into their parent classes. |
3629 TEST_F(BaseChannelDeathTest, SetTransportWithMismatchingTransportNames) { | 3744 TEST_F(BaseChannelDeathTest, SetTransportsWithMismatchingTransportNames) { |
3630 cricket::DtlsTransportInternal* new_rtp_transport = | 3745 ASSERT_TRUE(voice_channel_.Init_w( |
3631 fake_transport_controller_.CreateDtlsTransport( | 3746 &fake_rtp_dtls_transport_, &fake_rtcp_dtls_transport_, |
3632 "bar", cricket::ICE_CANDIDATE_COMPONENT_RTP); | 3747 &fake_rtp_dtls_transport_, &fake_rtcp_dtls_transport_)); |
3633 cricket::DtlsTransportInternal* new_rtcp_transport = | 3748 cricket::FakeDtlsTransport new_rtp_transport( |
3634 fake_transport_controller_.CreateDtlsTransport( | 3749 "bar", cricket::ICE_CANDIDATE_COMPONENT_RTP); |
3635 "baz", cricket::ICE_CANDIDATE_COMPONENT_RTCP); | 3750 cricket::FakeDtlsTransport new_rtcp_transport( |
| 3751 "baz", cricket::ICE_CANDIDATE_COMPONENT_RTCP); |
3636 EXPECT_DEATH( | 3752 EXPECT_DEATH( |
3637 voice_channel_.SetTransports(new_rtp_transport, new_rtcp_transport), ""); | 3753 voice_channel_.SetTransports(&new_rtp_transport, &new_rtcp_transport), |
| 3754 ""); |
| 3755 } |
| 3756 |
| 3757 // Not expected to support going from DtlsTransportInternal to |
| 3758 // PacketTransportInterface. |
| 3759 TEST_F(BaseChannelDeathTest, SetTransportsDtlsToNonDtls) { |
| 3760 ASSERT_TRUE(voice_channel_.Init_w( |
| 3761 &fake_rtp_dtls_transport_, &fake_rtcp_dtls_transport_, |
| 3762 &fake_rtp_dtls_transport_, &fake_rtcp_dtls_transport_)); |
| 3763 EXPECT_DEATH( |
| 3764 voice_channel_.SetTransports(static_cast<rtc::PacketTransportInterface*>( |
| 3765 &fake_rtp_dtls_transport_), |
| 3766 static_cast<rtc::PacketTransportInterface*>( |
| 3767 &fake_rtp_dtls_transport_)), |
| 3768 ""); |
| 3769 } |
| 3770 |
| 3771 // Not expected to support going from PacketTransportInterface to |
| 3772 // DtlsTransportInternal. |
| 3773 TEST_F(BaseChannelDeathTest, SetTransportsNonDtlsToDtls) { |
| 3774 ASSERT_TRUE(voice_channel_.Init_w(nullptr, nullptr, &fake_rtp_dtls_transport_, |
| 3775 &fake_rtcp_dtls_transport_)); |
| 3776 EXPECT_DEATH(voice_channel_.SetTransports(&fake_rtp_dtls_transport_, |
| 3777 &fake_rtp_dtls_transport_), |
| 3778 ""); |
3638 } | 3779 } |
3639 | 3780 |
3640 #endif // RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) | 3781 #endif // RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) |
3641 | 3782 |
3642 // TODO(pthatcher): TestSetReceiver? | 3783 // TODO(pthatcher): TestSetReceiver? |
OLD | NEW |