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/fakeclock.h" | 15 #include "webrtc/base/fakeclock.h" |
16 #include "webrtc/base/gunit.h" | 16 #include "webrtc/base/gunit.h" |
17 #include "webrtc/base/logging.h" | 17 #include "webrtc/base/logging.h" |
18 #include "webrtc/base/sslstreamadapter.h" | 18 #include "webrtc/base/sslstreamadapter.h" |
19 #include "webrtc/media/base/fakemediaengine.h" | 19 #include "webrtc/media/base/fakemediaengine.h" |
20 #include "webrtc/media/base/fakertp.h" | 20 #include "webrtc/media/base/fakertp.h" |
21 #include "webrtc/media/base/mediachannel.h" | 21 #include "webrtc/media/base/mediachannel.h" |
22 #include "webrtc/media/base/testutils.h" | 22 #include "webrtc/media/base/testutils.h" |
| 23 #include "webrtc/p2p/base/dtlstransportinternal.h" |
23 #include "webrtc/p2p/base/faketransportcontroller.h" | 24 #include "webrtc/p2p/base/faketransportcontroller.h" |
24 #include "webrtc/p2p/base/transportchannelimpl.h" | |
25 #include "webrtc/pc/channel.h" | 25 #include "webrtc/pc/channel.h" |
26 | 26 |
27 #define MAYBE_SKIP_TEST(feature) \ | 27 #define MAYBE_SKIP_TEST(feature) \ |
28 if (!(rtc::SSLStreamAdapter::feature())) { \ | 28 if (!(rtc::SSLStreamAdapter::feature())) { \ |
29 LOG(LS_INFO) << "Feature disabled... skipping"; \ | 29 LOG(LS_INFO) << "Feature disabled... skipping"; \ |
30 return; \ | 30 return; \ |
31 } | 31 } |
32 | 32 |
33 using cricket::CA_OFFER; | 33 using cricket::CA_OFFER; |
34 using cricket::CA_PRANSWER; | 34 using cricket::CA_PRANSWER; |
35 using cricket::CA_ANSWER; | 35 using cricket::CA_ANSWER; |
36 using cricket::CA_UPDATE; | 36 using cricket::CA_UPDATE; |
| 37 using cricket::DtlsTransportInternal; |
37 using cricket::FakeVoiceMediaChannel; | 38 using cricket::FakeVoiceMediaChannel; |
38 using cricket::StreamParams; | 39 using cricket::StreamParams; |
39 using cricket::TransportChannel; | |
40 | 40 |
41 namespace { | 41 namespace { |
42 const cricket::AudioCodec kPcmuCodec(0, "PCMU", 64000, 8000, 1); | 42 const cricket::AudioCodec kPcmuCodec(0, "PCMU", 64000, 8000, 1); |
43 const cricket::AudioCodec kPcmaCodec(8, "PCMA", 64000, 8000, 1); | 43 const cricket::AudioCodec kPcmaCodec(8, "PCMA", 64000, 8000, 1); |
44 const cricket::AudioCodec kIsacCodec(103, "ISAC", 40000, 16000, 1); | 44 const cricket::AudioCodec kIsacCodec(103, "ISAC", 40000, 16000, 1); |
45 const cricket::VideoCodec kH264Codec(97, "H264"); | 45 const cricket::VideoCodec kH264Codec(97, "H264"); |
46 const cricket::VideoCodec kH264SvcCodec(99, "H264-SVC"); | 46 const cricket::VideoCodec kH264SvcCodec(99, "H264-SVC"); |
47 const cricket::DataCodec kGoogleDataCodec(101, "google-data"); | 47 const cricket::DataCodec kGoogleDataCodec(101, "google-data"); |
48 const uint32_t kSsrc1 = 0x1111; | 48 const uint32_t kSsrc1 = 0x1111; |
49 const uint32_t kSsrc2 = 0x2222; | 49 const uint32_t kSsrc2 = 0x2222; |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 rtc::Thread* signaling_thread = | 208 rtc::Thread* signaling_thread = |
209 transport_controller ? transport_controller->signaling_thread() | 209 transport_controller ? transport_controller->signaling_thread() |
210 : nullptr; | 210 : nullptr; |
211 typename T::Channel* channel = new typename T::Channel( | 211 typename T::Channel* channel = new typename T::Channel( |
212 worker_thread, network_thread, signaling_thread, engine, ch, | 212 worker_thread, network_thread, signaling_thread, engine, ch, |
213 cricket::CN_AUDIO, (flags & RTCP_MUX_REQUIRED) != 0, | 213 cricket::CN_AUDIO, (flags & RTCP_MUX_REQUIRED) != 0, |
214 (flags & SECURE) != 0); | 214 (flags & SECURE) != 0); |
215 rtc::CryptoOptions crypto_options; | 215 rtc::CryptoOptions crypto_options; |
216 crypto_options.enable_gcm_crypto_suites = (flags & GCM_CIPHER) != 0; | 216 crypto_options.enable_gcm_crypto_suites = (flags & GCM_CIPHER) != 0; |
217 channel->SetCryptoOptions(crypto_options); | 217 channel->SetCryptoOptions(crypto_options); |
218 cricket::TransportChannel* rtp_transport = | 218 cricket::DtlsTransportInternal* rtp_dtls_transport = |
219 transport_controller->CreateTransportChannel( | 219 transport_controller->CreateDtlsTransport( |
220 channel->content_name(), cricket::ICE_CANDIDATE_COMPONENT_RTP); | 220 channel->content_name(), cricket::ICE_CANDIDATE_COMPONENT_RTP); |
221 cricket::TransportChannel* rtcp_transport = nullptr; | 221 cricket::DtlsTransportInternal* rtcp_dtls_transport = nullptr; |
222 if (channel->NeedsRtcpTransport()) { | 222 if (channel->NeedsRtcpTransport()) { |
223 rtcp_transport = transport_controller->CreateTransportChannel( | 223 rtcp_dtls_transport = transport_controller->CreateDtlsTransport( |
224 channel->content_name(), cricket::ICE_CANDIDATE_COMPONENT_RTCP); | 224 channel->content_name(), cricket::ICE_CANDIDATE_COMPONENT_RTCP); |
225 } | 225 } |
226 if (!channel->Init_w(rtp_transport, rtcp_transport)) { | 226 if (!channel->Init_w(rtp_dtls_transport, rtcp_dtls_transport)) { |
227 delete channel; | 227 delete channel; |
228 channel = NULL; | 228 channel = NULL; |
229 } | 229 } |
230 return channel; | 230 return channel; |
231 } | 231 } |
232 | 232 |
233 bool SendInitiate() { | 233 bool SendInitiate() { |
234 bool result = channel1_->SetLocalContent(&local_media_content1_, | 234 bool result = channel1_->SetLocalContent(&local_media_content1_, |
235 CA_OFFER, NULL); | 235 CA_OFFER, NULL); |
236 if (result) { | 236 if (result) { |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 return true; | 291 return true; |
292 } | 292 } |
293 | 293 |
294 bool AddStream1(int id) { | 294 bool AddStream1(int id) { |
295 return channel1_->AddRecvStream(cricket::StreamParams::CreateLegacy(id)); | 295 return channel1_->AddRecvStream(cricket::StreamParams::CreateLegacy(id)); |
296 } | 296 } |
297 bool RemoveStream1(int id) { | 297 bool RemoveStream1(int id) { |
298 return channel1_->RemoveRecvStream(id); | 298 return channel1_->RemoveRecvStream(id); |
299 } | 299 } |
300 | 300 |
301 std::vector<cricket::TransportChannelImpl*> GetChannels1() { | 301 std::vector<cricket::DtlsTransportInternal*> GetChannels1() { |
302 return transport_controller1_->channels_for_testing(); | 302 return transport_controller1_->channels_for_testing(); |
303 } | 303 } |
304 | 304 |
305 std::vector<cricket::TransportChannelImpl*> GetChannels2() { | 305 std::vector<cricket::DtlsTransportInternal*> GetChannels2() { |
306 return transport_controller2_->channels_for_testing(); | 306 return transport_controller2_->channels_for_testing(); |
307 } | 307 } |
308 | 308 |
309 cricket::FakeTransportChannel* GetFakeChannel1(int component) { | 309 cricket::FakeDtlsTransport* GetFakeChannel1(int component) { |
310 return transport_controller1_->GetFakeTransportChannel_n( | 310 return transport_controller1_->GetFakeDtlsTransport_n( |
311 channel1_->content_name(), component); | 311 channel1_->content_name(), component); |
312 } | 312 } |
313 | 313 |
314 cricket::FakeTransportChannel* GetFakeChannel2(int component) { | 314 cricket::FakeDtlsTransport* GetFakeChannel2(int component) { |
315 return transport_controller2_->GetFakeTransportChannel_n( | 315 return transport_controller2_->GetFakeDtlsTransport_n( |
316 channel2_->content_name(), component); | 316 channel2_->content_name(), component); |
317 } | 317 } |
318 | 318 |
319 void SendRtp1() { | 319 void SendRtp1() { |
320 media_channel1_->SendRtp(rtp_packet_.data(), rtp_packet_.size(), | 320 media_channel1_->SendRtp(rtp_packet_.data(), rtp_packet_.size(), |
321 rtc::PacketOptions()); | 321 rtc::PacketOptions()); |
322 } | 322 } |
323 void SendRtp2() { | 323 void SendRtp2() { |
324 media_channel2_->SendRtp(rtp_packet_.data(), rtp_packet_.size(), | 324 media_channel2_->SendRtp(rtp_packet_.data(), rtp_packet_.size(), |
325 rtc::PacketOptions()); | 325 rtc::PacketOptions()); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 bool CheckNoRtcp1() { | 403 bool CheckNoRtcp1() { |
404 return media_channel1_->CheckNoRtcp(); | 404 return media_channel1_->CheckNoRtcp(); |
405 } | 405 } |
406 bool CheckNoRtcp2() { | 406 bool CheckNoRtcp2() { |
407 return media_channel2_->CheckNoRtcp(); | 407 return media_channel2_->CheckNoRtcp(); |
408 } | 408 } |
409 // Checks that the channel is using GCM iff GCM_CIPHER is set in flags. | 409 // Checks that the channel is using GCM iff GCM_CIPHER is set in flags. |
410 // Returns true if so. | 410 // Returns true if so. |
411 bool CheckGcmCipher(typename T::Channel* channel, int flags) { | 411 bool CheckGcmCipher(typename T::Channel* channel, int flags) { |
412 int suite; | 412 int suite; |
413 if (!channel->rtp_transport()->GetSrtpCryptoSuite(&suite)) { | 413 if (!channel->rtp_dtls_transport()->GetSrtpCryptoSuite(&suite)) { |
414 return false; | 414 return false; |
415 } | 415 } |
416 | 416 |
417 if (flags & GCM_CIPHER) { | 417 if (flags & GCM_CIPHER) { |
418 return rtc::IsGcmCryptoSuite(suite); | 418 return rtc::IsGcmCryptoSuite(suite); |
419 } else { | 419 } else { |
420 return (suite != rtc::SRTP_INVALID_CRYPTO_SUITE && | 420 return (suite != rtc::SRTP_INVALID_CRYPTO_SUITE && |
421 !rtc::IsGcmCryptoSuite(suite)); | 421 !rtc::IsGcmCryptoSuite(suite)); |
422 } | 422 } |
423 } | 423 } |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
533 EXPECT_TRUE(channel1_->SetRemoteContent(&content, CA_ANSWER, NULL)); | 533 EXPECT_TRUE(channel1_->SetRemoteContent(&content, CA_ANSWER, NULL)); |
534 ASSERT_EQ(1U, media_channel1_->codecs().size()); | 534 ASSERT_EQ(1U, media_channel1_->codecs().size()); |
535 EXPECT_TRUE(CodecMatches(content.codecs()[0], | 535 EXPECT_TRUE(CodecMatches(content.codecs()[0], |
536 media_channel1_->codecs()[0])); | 536 media_channel1_->codecs()[0])); |
537 } | 537 } |
538 | 538 |
539 // Test that SetLocalContent and SetRemoteContent properly set RTCP | 539 // Test that SetLocalContent and SetRemoteContent properly set RTCP |
540 // mux. | 540 // mux. |
541 void TestSetContentsRtcpMux() { | 541 void TestSetContentsRtcpMux() { |
542 CreateChannels(0, 0); | 542 CreateChannels(0, 0); |
543 EXPECT_TRUE(channel1_->rtcp_transport() != NULL); | 543 EXPECT_TRUE(channel1_->rtcp_dtls_transport() != NULL); |
544 EXPECT_TRUE(channel2_->rtcp_transport() != NULL); | 544 EXPECT_TRUE(channel2_->rtcp_dtls_transport() != NULL); |
545 typename T::Content content; | 545 typename T::Content content; |
546 CreateContent(0, kPcmuCodec, kH264Codec, &content); | 546 CreateContent(0, kPcmuCodec, kH264Codec, &content); |
547 // Both sides agree on mux. Should no longer be a separate RTCP channel. | 547 // Both sides agree on mux. Should no longer be a separate RTCP channel. |
548 content.set_rtcp_mux(true); | 548 content.set_rtcp_mux(true); |
549 EXPECT_TRUE(channel1_->SetLocalContent(&content, CA_OFFER, NULL)); | 549 EXPECT_TRUE(channel1_->SetLocalContent(&content, CA_OFFER, NULL)); |
550 EXPECT_TRUE(channel1_->SetRemoteContent(&content, CA_ANSWER, NULL)); | 550 EXPECT_TRUE(channel1_->SetRemoteContent(&content, CA_ANSWER, NULL)); |
551 EXPECT_TRUE(channel1_->rtcp_transport() == NULL); | 551 EXPECT_TRUE(channel1_->rtcp_dtls_transport() == NULL); |
552 // Only initiator supports mux. Should still have a separate RTCP channel. | 552 // Only initiator supports mux. Should still have a separate RTCP channel. |
553 EXPECT_TRUE(channel2_->SetLocalContent(&content, CA_OFFER, NULL)); | 553 EXPECT_TRUE(channel2_->SetLocalContent(&content, CA_OFFER, NULL)); |
554 content.set_rtcp_mux(false); | 554 content.set_rtcp_mux(false); |
555 EXPECT_TRUE(channel2_->SetRemoteContent(&content, CA_ANSWER, NULL)); | 555 EXPECT_TRUE(channel2_->SetRemoteContent(&content, CA_ANSWER, NULL)); |
556 EXPECT_TRUE(channel2_->rtcp_transport() != NULL); | 556 EXPECT_TRUE(channel2_->rtcp_dtls_transport() != NULL); |
557 } | 557 } |
558 | 558 |
559 // Test that SetLocalContent and SetRemoteContent properly set RTCP | 559 // Test that SetLocalContent and SetRemoteContent properly set RTCP |
560 // mux when a provisional answer is received. | 560 // mux when a provisional answer is received. |
561 void TestSetContentsRtcpMuxWithPrAnswer() { | 561 void TestSetContentsRtcpMuxWithPrAnswer() { |
562 CreateChannels(0, 0); | 562 CreateChannels(0, 0); |
563 EXPECT_TRUE(channel1_->rtcp_transport() != NULL); | 563 EXPECT_TRUE(channel1_->rtcp_dtls_transport() != NULL); |
564 EXPECT_TRUE(channel2_->rtcp_transport() != NULL); | 564 EXPECT_TRUE(channel2_->rtcp_dtls_transport() != NULL); |
565 typename T::Content content; | 565 typename T::Content content; |
566 CreateContent(0, kPcmuCodec, kH264Codec, &content); | 566 CreateContent(0, kPcmuCodec, kH264Codec, &content); |
567 content.set_rtcp_mux(true); | 567 content.set_rtcp_mux(true); |
568 EXPECT_TRUE(channel1_->SetLocalContent(&content, CA_OFFER, NULL)); | 568 EXPECT_TRUE(channel1_->SetLocalContent(&content, CA_OFFER, NULL)); |
569 EXPECT_TRUE(channel1_->SetRemoteContent(&content, CA_PRANSWER, NULL)); | 569 EXPECT_TRUE(channel1_->SetRemoteContent(&content, CA_PRANSWER, NULL)); |
570 EXPECT_TRUE(channel1_->rtcp_transport() != NULL); | 570 EXPECT_TRUE(channel1_->rtcp_dtls_transport() != NULL); |
571 EXPECT_TRUE(channel1_->SetRemoteContent(&content, CA_ANSWER, NULL)); | 571 EXPECT_TRUE(channel1_->SetRemoteContent(&content, CA_ANSWER, NULL)); |
572 // Both sides agree on mux. Should no longer be a separate RTCP channel. | 572 // Both sides agree on mux. Should no longer be a separate RTCP channel. |
573 EXPECT_TRUE(channel1_->rtcp_transport() == NULL); | 573 EXPECT_TRUE(channel1_->rtcp_dtls_transport() == NULL); |
574 // Only initiator supports mux. Should still have a separate RTCP channel. | 574 // Only initiator supports mux. Should still have a separate RTCP channel. |
575 EXPECT_TRUE(channel2_->SetLocalContent(&content, CA_OFFER, NULL)); | 575 EXPECT_TRUE(channel2_->SetLocalContent(&content, CA_OFFER, NULL)); |
576 content.set_rtcp_mux(false); | 576 content.set_rtcp_mux(false); |
577 EXPECT_TRUE(channel2_->SetRemoteContent(&content, CA_PRANSWER, NULL)); | 577 EXPECT_TRUE(channel2_->SetRemoteContent(&content, CA_PRANSWER, NULL)); |
578 EXPECT_TRUE(channel2_->SetRemoteContent(&content, CA_ANSWER, NULL)); | 578 EXPECT_TRUE(channel2_->SetRemoteContent(&content, CA_ANSWER, NULL)); |
579 EXPECT_TRUE(channel2_->rtcp_transport() != NULL); | 579 EXPECT_TRUE(channel2_->rtcp_dtls_transport() != NULL); |
580 } | 580 } |
581 | 581 |
582 // Test that SetRemoteContent properly deals with a content update. | 582 // Test that SetRemoteContent properly deals with a content update. |
583 void TestSetRemoteContentUpdate() { | 583 void TestSetRemoteContentUpdate() { |
584 CreateChannels(0, 0); | 584 CreateChannels(0, 0); |
585 typename T::Content content; | 585 typename T::Content content; |
586 CreateContent(RTCP_MUX | SECURE, kPcmuCodec, kH264Codec, &content); | 586 CreateContent(RTCP_MUX | SECURE, kPcmuCodec, kH264Codec, &content); |
587 EXPECT_EQ(0U, media_channel1_->codecs().size()); | 587 EXPECT_EQ(0U, media_channel1_->codecs().size()); |
588 EXPECT_TRUE(channel1_->SetLocalContent(&content, CA_OFFER, NULL)); | 588 EXPECT_TRUE(channel1_->SetLocalContent(&content, CA_OFFER, NULL)); |
589 EXPECT_TRUE(channel1_->SetRemoteContent(&content, CA_ANSWER, NULL)); | 589 EXPECT_TRUE(channel1_->SetRemoteContent(&content, CA_ANSWER, NULL)); |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
949 | 949 |
950 // Tests that when the transport channel signals a candidate pair change | 950 // Tests that when the transport channel signals a candidate pair change |
951 // event, the media channel will receive a call on the network route change. | 951 // event, the media channel will receive a call on the network route change. |
952 void TestNetworkRouteChanges() { | 952 void TestNetworkRouteChanges() { |
953 constexpr uint16_t kLocalNetId = 1; | 953 constexpr uint16_t kLocalNetId = 1; |
954 constexpr uint16_t kRemoteNetId = 2; | 954 constexpr uint16_t kRemoteNetId = 2; |
955 constexpr int kLastPacketId = 100; | 955 constexpr int kLastPacketId = 100; |
956 | 956 |
957 CreateChannels(0, 0); | 957 CreateChannels(0, 0); |
958 | 958 |
959 cricket::TransportChannel* transport_channel1 = channel1_->rtp_transport(); | 959 cricket::DtlsTransportInternal* transport_channel1 = |
| 960 channel1_->rtp_dtls_transport(); |
960 ASSERT_TRUE(transport_channel1); | 961 ASSERT_TRUE(transport_channel1); |
961 typename T::MediaChannel* media_channel1 = | 962 typename T::MediaChannel* media_channel1 = |
962 static_cast<typename T::MediaChannel*>(channel1_->media_channel()); | 963 static_cast<typename T::MediaChannel*>(channel1_->media_channel()); |
963 ASSERT_TRUE(media_channel1); | 964 ASSERT_TRUE(media_channel1); |
964 | 965 |
965 media_channel1->set_num_network_route_changes(0); | 966 media_channel1->set_num_network_route_changes(0); |
966 network_thread_->Invoke<void>(RTC_FROM_HERE, [transport_channel1] { | 967 network_thread_->Invoke<void>(RTC_FROM_HERE, [transport_channel1] { |
967 // The transport channel becomes disconnected. | 968 // The transport channel becomes disconnected. |
968 transport_channel1->SignalSelectedCandidatePairChanged( | 969 transport_channel1->ice_transport()->SignalSelectedCandidatePairChanged( |
969 transport_channel1, nullptr, -1, false); | 970 transport_channel1->ice_transport(), nullptr, -1, false); |
970 }); | 971 }); |
971 WaitForThreads(); | 972 WaitForThreads(); |
972 EXPECT_EQ(1, media_channel1->num_network_route_changes()); | 973 EXPECT_EQ(1, media_channel1->num_network_route_changes()); |
973 EXPECT_FALSE(media_channel1->last_network_route().connected); | 974 EXPECT_FALSE(media_channel1->last_network_route().connected); |
974 media_channel1->set_num_network_route_changes(0); | 975 media_channel1->set_num_network_route_changes(0); |
975 | 976 |
976 network_thread_->Invoke<void>(RTC_FROM_HERE, [this, transport_channel1, | 977 network_thread_->Invoke<void>(RTC_FROM_HERE, [this, transport_channel1, |
977 media_channel1, kLocalNetId, | 978 media_channel1, kLocalNetId, |
978 kRemoteNetId, kLastPacketId] { | 979 kRemoteNetId, kLastPacketId] { |
979 // The transport channel becomes connected. | 980 // The transport channel becomes connected. |
980 rtc::SocketAddress local_address("192.168.1.1", 1000 /* port number */); | 981 rtc::SocketAddress local_address("192.168.1.1", 1000 /* port number */); |
981 rtc::SocketAddress remote_address("192.168.1.2", 2000 /* port number */); | 982 rtc::SocketAddress remote_address("192.168.1.2", 2000 /* port number */); |
982 std::unique_ptr<cricket::CandidatePairInterface> candidate_pair( | 983 std::unique_ptr<cricket::CandidatePairInterface> candidate_pair( |
983 transport_controller1_->CreateFakeCandidatePair( | 984 transport_controller1_->CreateFakeCandidatePair( |
984 local_address, kLocalNetId, remote_address, kRemoteNetId)); | 985 local_address, kLocalNetId, remote_address, kRemoteNetId)); |
985 transport_channel1->SignalSelectedCandidatePairChanged( | 986 transport_channel1->ice_transport()->SignalSelectedCandidatePairChanged( |
986 transport_channel1, candidate_pair.get(), kLastPacketId, true); | 987 transport_channel1->ice_transport(), candidate_pair.get(), |
| 988 kLastPacketId, true); |
987 }); | 989 }); |
988 WaitForThreads(); | 990 WaitForThreads(); |
989 EXPECT_EQ(1, media_channel1->num_network_route_changes()); | 991 EXPECT_EQ(1, media_channel1->num_network_route_changes()); |
990 rtc::NetworkRoute expected_network_route(true, kLocalNetId, kRemoteNetId, | 992 rtc::NetworkRoute expected_network_route(true, kLocalNetId, kRemoteNetId, |
991 kLastPacketId); | 993 kLastPacketId); |
992 EXPECT_EQ(expected_network_route, media_channel1->last_network_route()); | 994 EXPECT_EQ(expected_network_route, media_channel1->last_network_route()); |
993 EXPECT_EQ(kLastPacketId, | 995 EXPECT_EQ(kLastPacketId, |
994 media_channel1->last_network_route().last_sent_packet_id); | 996 media_channel1->last_network_route().last_sent_packet_id); |
995 constexpr int kTransportOverheadPerPacket = 28; // Ipv4(20) + UDP(8). | 997 constexpr int kTransportOverheadPerPacket = 28; // Ipv4(20) + UDP(8). |
996 EXPECT_EQ(kTransportOverheadPerPacket, | 998 EXPECT_EQ(kTransportOverheadPerPacket, |
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1465 network_thread_->Invoke<void>( | 1467 network_thread_->Invoke<void>( |
1466 RTC_FROM_HERE, [this] { GetFakeChannel1(1)->SetDestination(nullptr); }); | 1468 RTC_FROM_HERE, [this] { GetFakeChannel1(1)->SetDestination(nullptr); }); |
1467 EXPECT_TRUE(media_channel1_->sending()); | 1469 EXPECT_TRUE(media_channel1_->sending()); |
1468 | 1470 |
1469 // Should fail also. | 1471 // Should fail also. |
1470 SendRtp1(); | 1472 SendRtp1(); |
1471 SendRtp2(); | 1473 SendRtp2(); |
1472 WaitForThreads(); | 1474 WaitForThreads(); |
1473 EXPECT_TRUE(CheckRtp1()); | 1475 EXPECT_TRUE(CheckRtp1()); |
1474 EXPECT_TRUE(CheckNoRtp2()); | 1476 EXPECT_TRUE(CheckNoRtp2()); |
| 1477 EXPECT_TRUE(CheckNoRtp1()); |
1475 | 1478 |
1476 // Gain writability back | 1479 // Gain writability back |
1477 network_thread_->Invoke<void>(RTC_FROM_HERE, [this] { | 1480 network_thread_->Invoke<void>(RTC_FROM_HERE, [this] { |
1478 GetFakeChannel1(1)->SetDestination(GetFakeChannel2(1)); | 1481 GetFakeChannel1(1)->SetDestination(GetFakeChannel2(1)); |
1479 }); | 1482 }); |
1480 EXPECT_TRUE(media_channel1_->sending()); | 1483 EXPECT_TRUE(media_channel1_->sending()); |
1481 SendRtp1(); | 1484 SendRtp1(); |
1482 SendRtp2(); | 1485 SendRtp2(); |
1483 WaitForThreads(); | 1486 WaitForThreads(); |
1484 EXPECT_TRUE(CheckRtp1()); | 1487 EXPECT_TRUE(CheckRtp1()); |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1774 rtc::PacketOptions()); | 1777 rtc::PacketOptions()); |
1775 WaitForThreads(); | 1778 WaitForThreads(); |
1776 EXPECT_EQ(cricket::SrtpFilter::ERROR_FAIL, error_handler.error_); | 1779 EXPECT_EQ(cricket::SrtpFilter::ERROR_FAIL, error_handler.error_); |
1777 EXPECT_EQ(cricket::SrtpFilter::PROTECT, error_handler.mode_); | 1780 EXPECT_EQ(cricket::SrtpFilter::PROTECT, error_handler.mode_); |
1778 | 1781 |
1779 // Testing failures in receiving packets. | 1782 // Testing failures in receiving packets. |
1780 error_handler.error_ = cricket::SrtpFilter::ERROR_NONE; | 1783 error_handler.error_ = cricket::SrtpFilter::ERROR_NONE; |
1781 error_handler.mode_ = cricket::SrtpFilter::UNPROTECT; | 1784 error_handler.mode_ = cricket::SrtpFilter::UNPROTECT; |
1782 | 1785 |
1783 network_thread_->Invoke<void>(RTC_FROM_HERE, [this] { | 1786 network_thread_->Invoke<void>(RTC_FROM_HERE, [this] { |
1784 cricket::TransportChannel* transport_channel = channel2_->rtp_transport(); | 1787 cricket::DtlsTransportInternal* transport_channel = |
| 1788 channel2_->rtp_dtls_transport(); |
1785 transport_channel->SignalReadPacket( | 1789 transport_channel->SignalReadPacket( |
1786 transport_channel, reinterpret_cast<const char*>(kBadPacket), | 1790 transport_channel, reinterpret_cast<const char*>(kBadPacket), |
1787 sizeof(kBadPacket), rtc::PacketTime(), 0); | 1791 sizeof(kBadPacket), rtc::PacketTime(), 0); |
1788 }); | 1792 }); |
1789 EXPECT_EQ(cricket::SrtpFilter::ERROR_FAIL, error_handler.error_); | 1793 EXPECT_EQ(cricket::SrtpFilter::ERROR_FAIL, error_handler.error_); |
1790 EXPECT_EQ(cricket::SrtpFilter::UNPROTECT, error_handler.mode_); | 1794 EXPECT_EQ(cricket::SrtpFilter::UNPROTECT, error_handler.mode_); |
1791 // Terminate channels before the fake clock is destroyed. | 1795 // Terminate channels before the fake clock is destroyed. |
1792 EXPECT_TRUE(SendTerminate()); | 1796 EXPECT_TRUE(SendTerminate()); |
1793 } | 1797 } |
1794 | 1798 |
1795 void TestOnReadyToSend() { | 1799 void TestOnReadyToSend() { |
1796 CreateChannels(0, 0); | 1800 CreateChannels(0, 0); |
1797 TransportChannel* rtp = channel1_->rtp_transport(); | 1801 DtlsTransportInternal* rtp = channel1_->rtp_dtls_transport(); |
1798 TransportChannel* rtcp = channel1_->rtcp_transport(); | 1802 DtlsTransportInternal* rtcp = channel1_->rtcp_dtls_transport(); |
1799 EXPECT_FALSE(media_channel1_->ready_to_send()); | 1803 EXPECT_FALSE(media_channel1_->ready_to_send()); |
1800 | 1804 |
1801 network_thread_->Invoke<void>(RTC_FROM_HERE, | 1805 network_thread_->Invoke<void>(RTC_FROM_HERE, |
1802 [rtp] { rtp->SignalReadyToSend(rtp); }); | 1806 [rtp] { rtp->SignalReadyToSend(rtp); }); |
1803 WaitForThreads(); | 1807 WaitForThreads(); |
1804 EXPECT_FALSE(media_channel1_->ready_to_send()); | 1808 EXPECT_FALSE(media_channel1_->ready_to_send()); |
1805 | 1809 |
1806 network_thread_->Invoke<void>(RTC_FROM_HERE, | 1810 network_thread_->Invoke<void>(RTC_FROM_HERE, |
1807 [rtcp] { rtcp->SignalReadyToSend(rtcp); }); | 1811 [rtcp] { rtcp->SignalReadyToSend(rtcp); }); |
1808 WaitForThreads(); | 1812 WaitForThreads(); |
(...skipping 29 matching lines...) Expand all Loading... |
1838 } | 1842 } |
1839 | 1843 |
1840 void TestOnReadyToSendWithRtcpMux() { | 1844 void TestOnReadyToSendWithRtcpMux() { |
1841 CreateChannels(0, 0); | 1845 CreateChannels(0, 0); |
1842 typename T::Content content; | 1846 typename T::Content content; |
1843 CreateContent(0, kPcmuCodec, kH264Codec, &content); | 1847 CreateContent(0, kPcmuCodec, kH264Codec, &content); |
1844 // Both sides agree on mux. Should no longer be a separate RTCP channel. | 1848 // Both sides agree on mux. Should no longer be a separate RTCP channel. |
1845 content.set_rtcp_mux(true); | 1849 content.set_rtcp_mux(true); |
1846 EXPECT_TRUE(channel1_->SetLocalContent(&content, CA_OFFER, NULL)); | 1850 EXPECT_TRUE(channel1_->SetLocalContent(&content, CA_OFFER, NULL)); |
1847 EXPECT_TRUE(channel1_->SetRemoteContent(&content, CA_ANSWER, NULL)); | 1851 EXPECT_TRUE(channel1_->SetRemoteContent(&content, CA_ANSWER, NULL)); |
1848 EXPECT_TRUE(channel1_->rtcp_transport() == NULL); | 1852 EXPECT_TRUE(channel1_->rtcp_dtls_transport() == NULL); |
1849 TransportChannel* rtp = channel1_->rtp_transport(); | 1853 DtlsTransportInternal* rtp = channel1_->rtp_dtls_transport(); |
1850 EXPECT_FALSE(media_channel1_->ready_to_send()); | 1854 EXPECT_FALSE(media_channel1_->ready_to_send()); |
1851 // In the case of rtcp mux, the SignalReadyToSend() from rtp channel | 1855 // In the case of rtcp mux, the SignalReadyToSend() from rtp channel |
1852 // should trigger the MediaChannel's OnReadyToSend. | 1856 // should trigger the MediaChannel's OnReadyToSend. |
1853 network_thread_->Invoke<void>(RTC_FROM_HERE, | 1857 network_thread_->Invoke<void>(RTC_FROM_HERE, |
1854 [rtp] { rtp->SignalReadyToSend(rtp); }); | 1858 [rtp] { rtp->SignalReadyToSend(rtp); }); |
1855 WaitForThreads(); | 1859 WaitForThreads(); |
1856 EXPECT_TRUE(media_channel1_->ready_to_send()); | 1860 EXPECT_TRUE(media_channel1_->ready_to_send()); |
1857 | 1861 |
1858 network_thread_->Invoke<void>(RTC_FROM_HERE, [this] { | 1862 network_thread_->Invoke<void>(RTC_FROM_HERE, [this] { |
1859 channel1_->SetTransportChannelReadyToSend(false, false); | 1863 channel1_->SetTransportChannelReadyToSend(false, false); |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2018 cricket::TransportController* transport_controller, | 2022 cricket::TransportController* transport_controller, |
2019 int flags) { | 2023 int flags) { |
2020 rtc::Thread* signaling_thread = | 2024 rtc::Thread* signaling_thread = |
2021 transport_controller ? transport_controller->signaling_thread() : nullptr; | 2025 transport_controller ? transport_controller->signaling_thread() : nullptr; |
2022 cricket::VideoChannel* channel = new cricket::VideoChannel( | 2026 cricket::VideoChannel* channel = new cricket::VideoChannel( |
2023 worker_thread, network_thread, signaling_thread, ch, cricket::CN_VIDEO, | 2027 worker_thread, network_thread, signaling_thread, ch, cricket::CN_VIDEO, |
2024 (flags & RTCP_MUX_REQUIRED) != 0, (flags & SECURE) != 0); | 2028 (flags & RTCP_MUX_REQUIRED) != 0, (flags & SECURE) != 0); |
2025 rtc::CryptoOptions crypto_options; | 2029 rtc::CryptoOptions crypto_options; |
2026 crypto_options.enable_gcm_crypto_suites = (flags & GCM_CIPHER) != 0; | 2030 crypto_options.enable_gcm_crypto_suites = (flags & GCM_CIPHER) != 0; |
2027 channel->SetCryptoOptions(crypto_options); | 2031 channel->SetCryptoOptions(crypto_options); |
2028 cricket::TransportChannel* rtp_transport = | 2032 cricket::DtlsTransportInternal* rtp_dtls_transport = |
2029 transport_controller->CreateTransportChannel( | 2033 transport_controller->CreateDtlsTransport( |
2030 channel->content_name(), cricket::ICE_CANDIDATE_COMPONENT_RTP); | 2034 channel->content_name(), cricket::ICE_CANDIDATE_COMPONENT_RTP); |
2031 cricket::TransportChannel* rtcp_transport = nullptr; | 2035 cricket::DtlsTransportInternal* rtcp_dtls_transport = nullptr; |
2032 if (channel->NeedsRtcpTransport()) { | 2036 if (channel->NeedsRtcpTransport()) { |
2033 rtcp_transport = transport_controller->CreateTransportChannel( | 2037 rtcp_dtls_transport = transport_controller->CreateDtlsTransport( |
2034 channel->content_name(), cricket::ICE_CANDIDATE_COMPONENT_RTCP); | 2038 channel->content_name(), cricket::ICE_CANDIDATE_COMPONENT_RTCP); |
2035 } | 2039 } |
2036 if (!channel->Init_w(rtp_transport, rtcp_transport)) { | 2040 if (!channel->Init_w(rtp_dtls_transport, rtcp_dtls_transport)) { |
2037 delete channel; | 2041 delete channel; |
2038 channel = NULL; | 2042 channel = NULL; |
2039 } | 2043 } |
2040 return channel; | 2044 return channel; |
2041 } | 2045 } |
2042 | 2046 |
2043 // override to add 0 parameter | 2047 // override to add 0 parameter |
2044 template<> | 2048 template<> |
2045 bool ChannelTest<VideoTraits>::AddStream1(int id) { | 2049 bool ChannelTest<VideoTraits>::AddStream1(int id) { |
2046 return channel1_->AddRecvStream(cricket::StreamParams::CreateLegacy(id)); | 2050 return channel1_->AddRecvStream(cricket::StreamParams::CreateLegacy(id)); |
(...skipping 1205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3252 cricket::TransportController* transport_controller, | 3256 cricket::TransportController* transport_controller, |
3253 int flags) { | 3257 int flags) { |
3254 rtc::Thread* signaling_thread = | 3258 rtc::Thread* signaling_thread = |
3255 transport_controller ? transport_controller->signaling_thread() : nullptr; | 3259 transport_controller ? transport_controller->signaling_thread() : nullptr; |
3256 cricket::RtpDataChannel* channel = new cricket::RtpDataChannel( | 3260 cricket::RtpDataChannel* channel = new cricket::RtpDataChannel( |
3257 worker_thread, network_thread, signaling_thread, ch, cricket::CN_DATA, | 3261 worker_thread, network_thread, signaling_thread, ch, cricket::CN_DATA, |
3258 (flags & RTCP_MUX_REQUIRED) != 0, (flags & SECURE) != 0); | 3262 (flags & RTCP_MUX_REQUIRED) != 0, (flags & SECURE) != 0); |
3259 rtc::CryptoOptions crypto_options; | 3263 rtc::CryptoOptions crypto_options; |
3260 crypto_options.enable_gcm_crypto_suites = (flags & GCM_CIPHER) != 0; | 3264 crypto_options.enable_gcm_crypto_suites = (flags & GCM_CIPHER) != 0; |
3261 channel->SetCryptoOptions(crypto_options); | 3265 channel->SetCryptoOptions(crypto_options); |
3262 cricket::TransportChannel* rtp_transport = | 3266 cricket::DtlsTransportInternal* rtp_dtls_transport = |
3263 transport_controller->CreateTransportChannel( | 3267 transport_controller->CreateDtlsTransport( |
3264 channel->content_name(), cricket::ICE_CANDIDATE_COMPONENT_RTP); | 3268 channel->content_name(), cricket::ICE_CANDIDATE_COMPONENT_RTP); |
3265 cricket::TransportChannel* rtcp_transport = nullptr; | 3269 cricket::DtlsTransportInternal* rtcp_dtls_transport = nullptr; |
3266 if (channel->NeedsRtcpTransport()) { | 3270 if (channel->NeedsRtcpTransport()) { |
3267 rtcp_transport = transport_controller->CreateTransportChannel( | 3271 rtcp_dtls_transport = transport_controller->CreateDtlsTransport( |
3268 channel->content_name(), cricket::ICE_CANDIDATE_COMPONENT_RTCP); | 3272 channel->content_name(), cricket::ICE_CANDIDATE_COMPONENT_RTCP); |
3269 } | 3273 } |
3270 if (!channel->Init_w(rtp_transport, rtcp_transport)) { | 3274 if (!channel->Init_w(rtp_dtls_transport, rtcp_dtls_transport)) { |
3271 delete channel; | 3275 delete channel; |
3272 channel = NULL; | 3276 channel = NULL; |
3273 } | 3277 } |
3274 return channel; | 3278 return channel; |
3275 } | 3279 } |
3276 | 3280 |
3277 template <> | 3281 template <> |
3278 void ChannelTest<DataTraits>::CreateContent( | 3282 void ChannelTest<DataTraits>::CreateContent( |
3279 int flags, | 3283 int flags, |
3280 const cricket::AudioCodec& audio_codec, | 3284 const cricket::AudioCodec& audio_codec, |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3571 }; | 3575 }; |
3572 rtc::CopyOnWriteBuffer payload(data, 3); | 3576 rtc::CopyOnWriteBuffer payload(data, 3); |
3573 cricket::SendDataResult result; | 3577 cricket::SendDataResult result; |
3574 ASSERT_TRUE(media_channel1_->SendData(params, payload, &result)); | 3578 ASSERT_TRUE(media_channel1_->SendData(params, payload, &result)); |
3575 EXPECT_EQ(params.ssrc, | 3579 EXPECT_EQ(params.ssrc, |
3576 media_channel1_->last_sent_data_params().ssrc); | 3580 media_channel1_->last_sent_data_params().ssrc); |
3577 EXPECT_EQ("foo", media_channel1_->last_sent_data()); | 3581 EXPECT_EQ("foo", media_channel1_->last_sent_data()); |
3578 } | 3582 } |
3579 | 3583 |
3580 // TODO(pthatcher): TestSetReceiver? | 3584 // TODO(pthatcher): TestSetReceiver? |
OLD | NEW |