Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Side by Side Diff: webrtc/pc/channel_unittest.cc

Issue 2639203004: Revert of make the DtlsTransportWrapper inherit form DtlsTransportInternal (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/pc/channel.cc ('k') | webrtc/pc/channelmanager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
25 #include "webrtc/p2p/base/faketransportcontroller.h" 24 #include "webrtc/p2p/base/faketransportcontroller.h"
25 #include "webrtc/p2p/base/transportchannelimpl.h"
26 #include "webrtc/pc/channel.h" 26 #include "webrtc/pc/channel.h"
27 27
28 #define MAYBE_SKIP_TEST(feature) \ 28 #define MAYBE_SKIP_TEST(feature) \
29 if (!(rtc::SSLStreamAdapter::feature())) { \ 29 if (!(rtc::SSLStreamAdapter::feature())) { \
30 LOG(LS_INFO) << "Feature disabled... skipping"; \ 30 LOG(LS_INFO) << "Feature disabled... skipping"; \
31 return; \ 31 return; \
32 } 32 }
33 33
34 using cricket::CA_OFFER; 34 using cricket::CA_OFFER;
35 using cricket::CA_PRANSWER; 35 using cricket::CA_PRANSWER;
36 using cricket::CA_ANSWER; 36 using cricket::CA_ANSWER;
37 using cricket::CA_UPDATE; 37 using cricket::CA_UPDATE;
38 using cricket::DtlsTransportInternal;
39 using cricket::FakeVoiceMediaChannel; 38 using cricket::FakeVoiceMediaChannel;
40 using cricket::StreamParams; 39 using cricket::StreamParams;
40 using cricket::TransportChannel;
41 41
42 namespace { 42 namespace {
43 const cricket::AudioCodec kPcmuCodec(0, "PCMU", 64000, 8000, 1); 43 const cricket::AudioCodec kPcmuCodec(0, "PCMU", 64000, 8000, 1);
44 const cricket::AudioCodec kPcmaCodec(8, "PCMA", 64000, 8000, 1); 44 const cricket::AudioCodec kPcmaCodec(8, "PCMA", 64000, 8000, 1);
45 const cricket::AudioCodec kIsacCodec(103, "ISAC", 40000, 16000, 1); 45 const cricket::AudioCodec kIsacCodec(103, "ISAC", 40000, 16000, 1);
46 const cricket::VideoCodec kH264Codec(97, "H264"); 46 const cricket::VideoCodec kH264Codec(97, "H264");
47 const cricket::VideoCodec kH264SvcCodec(99, "H264-SVC"); 47 const cricket::VideoCodec kH264SvcCodec(99, "H264-SVC");
48 const cricket::DataCodec kGoogleDataCodec(101, "google-data"); 48 const cricket::DataCodec kGoogleDataCodec(101, "google-data");
49 const uint32_t kSsrc1 = 0x1111; 49 const uint32_t kSsrc1 = 0x1111;
50 const uint32_t kSsrc2 = 0x2222; 50 const uint32_t kSsrc2 = 0x2222;
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 rtc::Thread* signaling_thread = 209 rtc::Thread* signaling_thread =
210 transport_controller ? transport_controller->signaling_thread() 210 transport_controller ? transport_controller->signaling_thread()
211 : nullptr; 211 : nullptr;
212 typename T::Channel* channel = new typename T::Channel( 212 typename T::Channel* channel = new typename T::Channel(
213 worker_thread, network_thread, signaling_thread, engine, ch, 213 worker_thread, network_thread, signaling_thread, engine, ch,
214 cricket::CN_AUDIO, (flags & RTCP_MUX_REQUIRED) != 0, 214 cricket::CN_AUDIO, (flags & RTCP_MUX_REQUIRED) != 0,
215 (flags & SECURE) != 0); 215 (flags & SECURE) != 0);
216 rtc::CryptoOptions crypto_options; 216 rtc::CryptoOptions crypto_options;
217 crypto_options.enable_gcm_crypto_suites = (flags & GCM_CIPHER) != 0; 217 crypto_options.enable_gcm_crypto_suites = (flags & GCM_CIPHER) != 0;
218 channel->SetCryptoOptions(crypto_options); 218 channel->SetCryptoOptions(crypto_options);
219 cricket::DtlsTransportInternal* rtp_dtls_transport = 219 cricket::TransportChannel* rtp_transport =
220 transport_controller->CreateDtlsTransport( 220 transport_controller->CreateTransportChannel(
221 channel->content_name(), cricket::ICE_CANDIDATE_COMPONENT_RTP); 221 channel->content_name(), cricket::ICE_CANDIDATE_COMPONENT_RTP);
222 cricket::DtlsTransportInternal* rtcp_dtls_transport = nullptr; 222 cricket::TransportChannel* rtcp_transport = nullptr;
223 if (channel->NeedsRtcpTransport()) { 223 if (channel->NeedsRtcpTransport()) {
224 rtcp_dtls_transport = transport_controller->CreateDtlsTransport( 224 rtcp_transport = transport_controller->CreateTransportChannel(
225 channel->content_name(), cricket::ICE_CANDIDATE_COMPONENT_RTCP); 225 channel->content_name(), cricket::ICE_CANDIDATE_COMPONENT_RTCP);
226 } 226 }
227 if (!channel->Init_w(rtp_dtls_transport, rtcp_dtls_transport)) { 227 if (!channel->Init_w(rtp_transport, rtcp_transport)) {
228 delete channel; 228 delete channel;
229 channel = NULL; 229 channel = NULL;
230 } 230 }
231 return channel; 231 return channel;
232 } 232 }
233 233
234 bool SendInitiate() { 234 bool SendInitiate() {
235 bool result = channel1_->SetLocalContent(&local_media_content1_, 235 bool result = channel1_->SetLocalContent(&local_media_content1_,
236 CA_OFFER, NULL); 236 CA_OFFER, NULL);
237 if (result) { 237 if (result) {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 return true; 292 return true;
293 } 293 }
294 294
295 bool AddStream1(int id) { 295 bool AddStream1(int id) {
296 return channel1_->AddRecvStream(cricket::StreamParams::CreateLegacy(id)); 296 return channel1_->AddRecvStream(cricket::StreamParams::CreateLegacy(id));
297 } 297 }
298 bool RemoveStream1(int id) { 298 bool RemoveStream1(int id) {
299 return channel1_->RemoveRecvStream(id); 299 return channel1_->RemoveRecvStream(id);
300 } 300 }
301 301
302 std::vector<cricket::DtlsTransportInternal*> GetChannels1() { 302 std::vector<cricket::TransportChannelImpl*> GetChannels1() {
303 return transport_controller1_->channels_for_testing(); 303 return transport_controller1_->channels_for_testing();
304 } 304 }
305 305
306 std::vector<cricket::DtlsTransportInternal*> GetChannels2() { 306 std::vector<cricket::TransportChannelImpl*> GetChannels2() {
307 return transport_controller2_->channels_for_testing(); 307 return transport_controller2_->channels_for_testing();
308 } 308 }
309 309
310 cricket::FakeDtlsTransport* GetFakeChannel1(int component) { 310 cricket::FakeTransportChannel* GetFakeChannel1(int component) {
311 return transport_controller1_->GetFakeDtlsTransport_n( 311 return transport_controller1_->GetFakeTransportChannel_n(
312 channel1_->content_name(), component); 312 channel1_->content_name(), component);
313 } 313 }
314 314
315 cricket::FakeDtlsTransport* GetFakeChannel2(int component) { 315 cricket::FakeTransportChannel* GetFakeChannel2(int component) {
316 return transport_controller2_->GetFakeDtlsTransport_n( 316 return transport_controller2_->GetFakeTransportChannel_n(
317 channel2_->content_name(), component); 317 channel2_->content_name(), component);
318 } 318 }
319 319
320 void SendRtp1() { 320 void SendRtp1() {
321 media_channel1_->SendRtp(rtp_packet_.data(), rtp_packet_.size(), 321 media_channel1_->SendRtp(rtp_packet_.data(), rtp_packet_.size(),
322 rtc::PacketOptions()); 322 rtc::PacketOptions());
323 } 323 }
324 void SendRtp2() { 324 void SendRtp2() {
325 media_channel2_->SendRtp(rtp_packet_.data(), rtp_packet_.size(), 325 media_channel2_->SendRtp(rtp_packet_.data(), rtp_packet_.size(),
326 rtc::PacketOptions()); 326 rtc::PacketOptions());
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 bool CheckNoRtcp1() { 404 bool CheckNoRtcp1() {
405 return media_channel1_->CheckNoRtcp(); 405 return media_channel1_->CheckNoRtcp();
406 } 406 }
407 bool CheckNoRtcp2() { 407 bool CheckNoRtcp2() {
408 return media_channel2_->CheckNoRtcp(); 408 return media_channel2_->CheckNoRtcp();
409 } 409 }
410 // Checks that the channel is using GCM iff GCM_CIPHER is set in flags. 410 // Checks that the channel is using GCM iff GCM_CIPHER is set in flags.
411 // Returns true if so. 411 // Returns true if so.
412 bool CheckGcmCipher(typename T::Channel* channel, int flags) { 412 bool CheckGcmCipher(typename T::Channel* channel, int flags) {
413 int suite; 413 int suite;
414 if (!channel->rtp_dtls_transport()->GetSrtpCryptoSuite(&suite)) { 414 if (!channel->rtp_transport()->GetSrtpCryptoSuite(&suite)) {
415 return false; 415 return false;
416 } 416 }
417 417
418 if (flags & GCM_CIPHER) { 418 if (flags & GCM_CIPHER) {
419 return rtc::IsGcmCryptoSuite(suite); 419 return rtc::IsGcmCryptoSuite(suite);
420 } else { 420 } else {
421 return (suite != rtc::SRTP_INVALID_CRYPTO_SUITE && 421 return (suite != rtc::SRTP_INVALID_CRYPTO_SUITE &&
422 !rtc::IsGcmCryptoSuite(suite)); 422 !rtc::IsGcmCryptoSuite(suite));
423 } 423 }
424 } 424 }
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 EXPECT_TRUE(channel1_->SetRemoteContent(&content, CA_ANSWER, NULL)); 534 EXPECT_TRUE(channel1_->SetRemoteContent(&content, CA_ANSWER, NULL));
535 ASSERT_EQ(1U, media_channel1_->codecs().size()); 535 ASSERT_EQ(1U, media_channel1_->codecs().size());
536 EXPECT_TRUE(CodecMatches(content.codecs()[0], 536 EXPECT_TRUE(CodecMatches(content.codecs()[0],
537 media_channel1_->codecs()[0])); 537 media_channel1_->codecs()[0]));
538 } 538 }
539 539
540 // Test that SetLocalContent and SetRemoteContent properly set RTCP 540 // Test that SetLocalContent and SetRemoteContent properly set RTCP
541 // mux. 541 // mux.
542 void TestSetContentsRtcpMux() { 542 void TestSetContentsRtcpMux() {
543 CreateChannels(0, 0); 543 CreateChannels(0, 0);
544 EXPECT_TRUE(channel1_->rtcp_dtls_transport() != NULL); 544 EXPECT_TRUE(channel1_->rtcp_transport() != NULL);
545 EXPECT_TRUE(channel2_->rtcp_dtls_transport() != NULL); 545 EXPECT_TRUE(channel2_->rtcp_transport() != NULL);
546 typename T::Content content; 546 typename T::Content content;
547 CreateContent(0, kPcmuCodec, kH264Codec, &content); 547 CreateContent(0, kPcmuCodec, kH264Codec, &content);
548 // Both sides agree on mux. Should no longer be a separate RTCP channel. 548 // Both sides agree on mux. Should no longer be a separate RTCP channel.
549 content.set_rtcp_mux(true); 549 content.set_rtcp_mux(true);
550 EXPECT_TRUE(channel1_->SetLocalContent(&content, CA_OFFER, NULL)); 550 EXPECT_TRUE(channel1_->SetLocalContent(&content, CA_OFFER, NULL));
551 EXPECT_TRUE(channel1_->SetRemoteContent(&content, CA_ANSWER, NULL)); 551 EXPECT_TRUE(channel1_->SetRemoteContent(&content, CA_ANSWER, NULL));
552 EXPECT_TRUE(channel1_->rtcp_dtls_transport() == NULL); 552 EXPECT_TRUE(channel1_->rtcp_transport() == NULL);
553 // Only initiator supports mux. Should still have a separate RTCP channel. 553 // Only initiator supports mux. Should still have a separate RTCP channel.
554 EXPECT_TRUE(channel2_->SetLocalContent(&content, CA_OFFER, NULL)); 554 EXPECT_TRUE(channel2_->SetLocalContent(&content, CA_OFFER, NULL));
555 content.set_rtcp_mux(false); 555 content.set_rtcp_mux(false);
556 EXPECT_TRUE(channel2_->SetRemoteContent(&content, CA_ANSWER, NULL)); 556 EXPECT_TRUE(channel2_->SetRemoteContent(&content, CA_ANSWER, NULL));
557 EXPECT_TRUE(channel2_->rtcp_dtls_transport() != NULL); 557 EXPECT_TRUE(channel2_->rtcp_transport() != NULL);
558 } 558 }
559 559
560 // Test that SetLocalContent and SetRemoteContent properly set RTCP 560 // Test that SetLocalContent and SetRemoteContent properly set RTCP
561 // mux when a provisional answer is received. 561 // mux when a provisional answer is received.
562 void TestSetContentsRtcpMuxWithPrAnswer() { 562 void TestSetContentsRtcpMuxWithPrAnswer() {
563 CreateChannels(0, 0); 563 CreateChannels(0, 0);
564 EXPECT_TRUE(channel1_->rtcp_dtls_transport() != NULL); 564 EXPECT_TRUE(channel1_->rtcp_transport() != NULL);
565 EXPECT_TRUE(channel2_->rtcp_dtls_transport() != NULL); 565 EXPECT_TRUE(channel2_->rtcp_transport() != NULL);
566 typename T::Content content; 566 typename T::Content content;
567 CreateContent(0, kPcmuCodec, kH264Codec, &content); 567 CreateContent(0, kPcmuCodec, kH264Codec, &content);
568 content.set_rtcp_mux(true); 568 content.set_rtcp_mux(true);
569 EXPECT_TRUE(channel1_->SetLocalContent(&content, CA_OFFER, NULL)); 569 EXPECT_TRUE(channel1_->SetLocalContent(&content, CA_OFFER, NULL));
570 EXPECT_TRUE(channel1_->SetRemoteContent(&content, CA_PRANSWER, NULL)); 570 EXPECT_TRUE(channel1_->SetRemoteContent(&content, CA_PRANSWER, NULL));
571 EXPECT_TRUE(channel1_->rtcp_dtls_transport() != NULL); 571 EXPECT_TRUE(channel1_->rtcp_transport() != NULL);
572 EXPECT_TRUE(channel1_->SetRemoteContent(&content, CA_ANSWER, NULL)); 572 EXPECT_TRUE(channel1_->SetRemoteContent(&content, CA_ANSWER, NULL));
573 // Both sides agree on mux. Should no longer be a separate RTCP channel. 573 // Both sides agree on mux. Should no longer be a separate RTCP channel.
574 EXPECT_TRUE(channel1_->rtcp_dtls_transport() == NULL); 574 EXPECT_TRUE(channel1_->rtcp_transport() == NULL);
575 // Only initiator supports mux. Should still have a separate RTCP channel. 575 // Only initiator supports mux. Should still have a separate RTCP channel.
576 EXPECT_TRUE(channel2_->SetLocalContent(&content, CA_OFFER, NULL)); 576 EXPECT_TRUE(channel2_->SetLocalContent(&content, CA_OFFER, NULL));
577 content.set_rtcp_mux(false); 577 content.set_rtcp_mux(false);
578 EXPECT_TRUE(channel2_->SetRemoteContent(&content, CA_PRANSWER, NULL)); 578 EXPECT_TRUE(channel2_->SetRemoteContent(&content, CA_PRANSWER, NULL));
579 EXPECT_TRUE(channel2_->SetRemoteContent(&content, CA_ANSWER, NULL)); 579 EXPECT_TRUE(channel2_->SetRemoteContent(&content, CA_ANSWER, NULL));
580 EXPECT_TRUE(channel2_->rtcp_dtls_transport() != NULL); 580 EXPECT_TRUE(channel2_->rtcp_transport() != NULL);
581 } 581 }
582 582
583 // Test that SetRemoteContent properly deals with a content update. 583 // Test that SetRemoteContent properly deals with a content update.
584 void TestSetRemoteContentUpdate() { 584 void TestSetRemoteContentUpdate() {
585 CreateChannels(0, 0); 585 CreateChannels(0, 0);
586 typename T::Content content; 586 typename T::Content content;
587 CreateContent(RTCP_MUX | SECURE, kPcmuCodec, kH264Codec, &content); 587 CreateContent(RTCP_MUX | SECURE, kPcmuCodec, kH264Codec, &content);
588 EXPECT_EQ(0U, media_channel1_->codecs().size()); 588 EXPECT_EQ(0U, media_channel1_->codecs().size());
589 EXPECT_TRUE(channel1_->SetLocalContent(&content, CA_OFFER, NULL)); 589 EXPECT_TRUE(channel1_->SetLocalContent(&content, CA_OFFER, NULL));
590 EXPECT_TRUE(channel1_->SetRemoteContent(&content, CA_ANSWER, NULL)); 590 EXPECT_TRUE(channel1_->SetRemoteContent(&content, CA_ANSWER, NULL));
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
950 950
951 // Tests that when the transport channel signals a candidate pair change 951 // Tests that when the transport channel signals a candidate pair change
952 // event, the media channel will receive a call on the network route change. 952 // event, the media channel will receive a call on the network route change.
953 void TestNetworkRouteChanges() { 953 void TestNetworkRouteChanges() {
954 constexpr uint16_t kLocalNetId = 1; 954 constexpr uint16_t kLocalNetId = 1;
955 constexpr uint16_t kRemoteNetId = 2; 955 constexpr uint16_t kRemoteNetId = 2;
956 constexpr int kLastPacketId = 100; 956 constexpr int kLastPacketId = 100;
957 957
958 CreateChannels(0, 0); 958 CreateChannels(0, 0);
959 959
960 cricket::DtlsTransportInternal* transport_channel1 = 960 cricket::TransportChannel* transport_channel1 = channel1_->rtp_transport();
961 channel1_->rtp_dtls_transport();
962 ASSERT_TRUE(transport_channel1); 961 ASSERT_TRUE(transport_channel1);
963 typename T::MediaChannel* media_channel1 = 962 typename T::MediaChannel* media_channel1 =
964 static_cast<typename T::MediaChannel*>(channel1_->media_channel()); 963 static_cast<typename T::MediaChannel*>(channel1_->media_channel());
965 ASSERT_TRUE(media_channel1); 964 ASSERT_TRUE(media_channel1);
966 965
967 media_channel1->set_num_network_route_changes(0); 966 media_channel1->set_num_network_route_changes(0);
968 network_thread_->Invoke<void>(RTC_FROM_HERE, [transport_channel1] { 967 network_thread_->Invoke<void>(RTC_FROM_HERE, [transport_channel1] {
969 // The transport channel becomes disconnected. 968 // The transport channel becomes disconnected.
970 transport_channel1->ice_transport()->SignalSelectedCandidatePairChanged( 969 transport_channel1->SignalSelectedCandidatePairChanged(
971 transport_channel1->ice_transport(), nullptr, -1, false); 970 transport_channel1, nullptr, -1, false);
972 }); 971 });
973 WaitForThreads(); 972 WaitForThreads();
974 EXPECT_EQ(1, media_channel1->num_network_route_changes()); 973 EXPECT_EQ(1, media_channel1->num_network_route_changes());
975 EXPECT_FALSE(media_channel1->last_network_route().connected); 974 EXPECT_FALSE(media_channel1->last_network_route().connected);
976 media_channel1->set_num_network_route_changes(0); 975 media_channel1->set_num_network_route_changes(0);
977 976
978 network_thread_->Invoke<void>(RTC_FROM_HERE, [this, transport_channel1, 977 network_thread_->Invoke<void>(RTC_FROM_HERE, [this, transport_channel1,
979 media_channel1, kLocalNetId, 978 media_channel1, kLocalNetId,
980 kRemoteNetId, kLastPacketId] { 979 kRemoteNetId, kLastPacketId] {
981 // The transport channel becomes connected. 980 // The transport channel becomes connected.
982 rtc::SocketAddress local_address("192.168.1.1", 1000 /* port number */); 981 rtc::SocketAddress local_address("192.168.1.1", 1000 /* port number */);
983 rtc::SocketAddress remote_address("192.168.1.2", 2000 /* port number */); 982 rtc::SocketAddress remote_address("192.168.1.2", 2000 /* port number */);
984 std::unique_ptr<cricket::CandidatePairInterface> candidate_pair( 983 std::unique_ptr<cricket::CandidatePairInterface> candidate_pair(
985 transport_controller1_->CreateFakeCandidatePair( 984 transport_controller1_->CreateFakeCandidatePair(
986 local_address, kLocalNetId, remote_address, kRemoteNetId)); 985 local_address, kLocalNetId, remote_address, kRemoteNetId));
987 transport_channel1->ice_transport()->SignalSelectedCandidatePairChanged( 986 transport_channel1->SignalSelectedCandidatePairChanged(
988 transport_channel1->ice_transport(), candidate_pair.get(), 987 transport_channel1, candidate_pair.get(), kLastPacketId, true);
989 kLastPacketId, true);
990 }); 988 });
991 WaitForThreads(); 989 WaitForThreads();
992 EXPECT_EQ(1, media_channel1->num_network_route_changes()); 990 EXPECT_EQ(1, media_channel1->num_network_route_changes());
993 rtc::NetworkRoute expected_network_route(true, kLocalNetId, kRemoteNetId, 991 rtc::NetworkRoute expected_network_route(true, kLocalNetId, kRemoteNetId,
994 kLastPacketId); 992 kLastPacketId);
995 EXPECT_EQ(expected_network_route, media_channel1->last_network_route()); 993 EXPECT_EQ(expected_network_route, media_channel1->last_network_route());
996 EXPECT_EQ(kLastPacketId, 994 EXPECT_EQ(kLastPacketId,
997 media_channel1->last_network_route().last_sent_packet_id); 995 media_channel1->last_network_route().last_sent_packet_id);
998 constexpr int kTransportOverheadPerPacket = 28; // Ipv4(20) + UDP(8). 996 constexpr int kTransportOverheadPerPacket = 28; // Ipv4(20) + UDP(8).
999 EXPECT_EQ(kTransportOverheadPerPacket, 997 EXPECT_EQ(kTransportOverheadPerPacket,
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
1468 network_thread_->Invoke<void>( 1466 network_thread_->Invoke<void>(
1469 RTC_FROM_HERE, [this] { GetFakeChannel1(1)->SetDestination(nullptr); }); 1467 RTC_FROM_HERE, [this] { GetFakeChannel1(1)->SetDestination(nullptr); });
1470 EXPECT_TRUE(media_channel1_->sending()); 1468 EXPECT_TRUE(media_channel1_->sending());
1471 1469
1472 // Should fail also. 1470 // Should fail also.
1473 SendRtp1(); 1471 SendRtp1();
1474 SendRtp2(); 1472 SendRtp2();
1475 WaitForThreads(); 1473 WaitForThreads();
1476 EXPECT_TRUE(CheckRtp1()); 1474 EXPECT_TRUE(CheckRtp1());
1477 EXPECT_TRUE(CheckNoRtp2()); 1475 EXPECT_TRUE(CheckNoRtp2());
1478 EXPECT_TRUE(CheckNoRtp1());
1479 1476
1480 // Gain writability back 1477 // Gain writability back
1481 network_thread_->Invoke<void>(RTC_FROM_HERE, [this] { 1478 network_thread_->Invoke<void>(RTC_FROM_HERE, [this] {
1482 GetFakeChannel1(1)->SetDestination(GetFakeChannel2(1)); 1479 GetFakeChannel1(1)->SetDestination(GetFakeChannel2(1));
1483 }); 1480 });
1484 EXPECT_TRUE(media_channel1_->sending()); 1481 EXPECT_TRUE(media_channel1_->sending());
1485 SendRtp1(); 1482 SendRtp1();
1486 SendRtp2(); 1483 SendRtp2();
1487 WaitForThreads(); 1484 WaitForThreads();
1488 EXPECT_TRUE(CheckRtp1()); 1485 EXPECT_TRUE(CheckRtp1());
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
1778 rtc::PacketOptions()); 1775 rtc::PacketOptions());
1779 WaitForThreads(); 1776 WaitForThreads();
1780 EXPECT_EQ(cricket::SrtpFilter::ERROR_FAIL, error_handler.error_); 1777 EXPECT_EQ(cricket::SrtpFilter::ERROR_FAIL, error_handler.error_);
1781 EXPECT_EQ(cricket::SrtpFilter::PROTECT, error_handler.mode_); 1778 EXPECT_EQ(cricket::SrtpFilter::PROTECT, error_handler.mode_);
1782 1779
1783 // Testing failures in receiving packets. 1780 // Testing failures in receiving packets.
1784 error_handler.error_ = cricket::SrtpFilter::ERROR_NONE; 1781 error_handler.error_ = cricket::SrtpFilter::ERROR_NONE;
1785 error_handler.mode_ = cricket::SrtpFilter::UNPROTECT; 1782 error_handler.mode_ = cricket::SrtpFilter::UNPROTECT;
1786 1783
1787 network_thread_->Invoke<void>(RTC_FROM_HERE, [this] { 1784 network_thread_->Invoke<void>(RTC_FROM_HERE, [this] {
1788 cricket::DtlsTransportInternal* transport_channel = 1785 cricket::TransportChannel* transport_channel = channel2_->rtp_transport();
1789 channel2_->rtp_dtls_transport();
1790 transport_channel->SignalReadPacket( 1786 transport_channel->SignalReadPacket(
1791 transport_channel, reinterpret_cast<const char*>(kBadPacket), 1787 transport_channel, reinterpret_cast<const char*>(kBadPacket),
1792 sizeof(kBadPacket), rtc::PacketTime(), 0); 1788 sizeof(kBadPacket), rtc::PacketTime(), 0);
1793 }); 1789 });
1794 EXPECT_EQ(cricket::SrtpFilter::ERROR_FAIL, error_handler.error_); 1790 EXPECT_EQ(cricket::SrtpFilter::ERROR_FAIL, error_handler.error_);
1795 EXPECT_EQ(cricket::SrtpFilter::UNPROTECT, error_handler.mode_); 1791 EXPECT_EQ(cricket::SrtpFilter::UNPROTECT, error_handler.mode_);
1796 // Terminate channels before the fake clock is destroyed. 1792 // Terminate channels before the fake clock is destroyed.
1797 EXPECT_TRUE(SendTerminate()); 1793 EXPECT_TRUE(SendTerminate());
1798 } 1794 }
1799 1795
1800 void TestOnReadyToSend() { 1796 void TestOnReadyToSend() {
1801 CreateChannels(0, 0); 1797 CreateChannels(0, 0);
1802 DtlsTransportInternal* rtp = channel1_->rtp_dtls_transport(); 1798 TransportChannel* rtp = channel1_->rtp_transport();
1803 DtlsTransportInternal* rtcp = channel1_->rtcp_dtls_transport(); 1799 TransportChannel* rtcp = channel1_->rtcp_transport();
1804 EXPECT_FALSE(media_channel1_->ready_to_send()); 1800 EXPECT_FALSE(media_channel1_->ready_to_send());
1805 1801
1806 network_thread_->Invoke<void>(RTC_FROM_HERE, 1802 network_thread_->Invoke<void>(RTC_FROM_HERE,
1807 [rtp] { rtp->SignalReadyToSend(rtp); }); 1803 [rtp] { rtp->SignalReadyToSend(rtp); });
1808 WaitForThreads(); 1804 WaitForThreads();
1809 EXPECT_FALSE(media_channel1_->ready_to_send()); 1805 EXPECT_FALSE(media_channel1_->ready_to_send());
1810 1806
1811 network_thread_->Invoke<void>(RTC_FROM_HERE, 1807 network_thread_->Invoke<void>(RTC_FROM_HERE,
1812 [rtcp] { rtcp->SignalReadyToSend(rtcp); }); 1808 [rtcp] { rtcp->SignalReadyToSend(rtcp); });
1813 WaitForThreads(); 1809 WaitForThreads();
(...skipping 29 matching lines...) Expand all
1843 } 1839 }
1844 1840
1845 void TestOnReadyToSendWithRtcpMux() { 1841 void TestOnReadyToSendWithRtcpMux() {
1846 CreateChannels(0, 0); 1842 CreateChannels(0, 0);
1847 typename T::Content content; 1843 typename T::Content content;
1848 CreateContent(0, kPcmuCodec, kH264Codec, &content); 1844 CreateContent(0, kPcmuCodec, kH264Codec, &content);
1849 // Both sides agree on mux. Should no longer be a separate RTCP channel. 1845 // Both sides agree on mux. Should no longer be a separate RTCP channel.
1850 content.set_rtcp_mux(true); 1846 content.set_rtcp_mux(true);
1851 EXPECT_TRUE(channel1_->SetLocalContent(&content, CA_OFFER, NULL)); 1847 EXPECT_TRUE(channel1_->SetLocalContent(&content, CA_OFFER, NULL));
1852 EXPECT_TRUE(channel1_->SetRemoteContent(&content, CA_ANSWER, NULL)); 1848 EXPECT_TRUE(channel1_->SetRemoteContent(&content, CA_ANSWER, NULL));
1853 EXPECT_TRUE(channel1_->rtcp_dtls_transport() == NULL); 1849 EXPECT_TRUE(channel1_->rtcp_transport() == NULL);
1854 DtlsTransportInternal* rtp = channel1_->rtp_dtls_transport(); 1850 TransportChannel* rtp = channel1_->rtp_transport();
1855 EXPECT_FALSE(media_channel1_->ready_to_send()); 1851 EXPECT_FALSE(media_channel1_->ready_to_send());
1856 // In the case of rtcp mux, the SignalReadyToSend() from rtp channel 1852 // In the case of rtcp mux, the SignalReadyToSend() from rtp channel
1857 // should trigger the MediaChannel's OnReadyToSend. 1853 // should trigger the MediaChannel's OnReadyToSend.
1858 network_thread_->Invoke<void>(RTC_FROM_HERE, 1854 network_thread_->Invoke<void>(RTC_FROM_HERE,
1859 [rtp] { rtp->SignalReadyToSend(rtp); }); 1855 [rtp] { rtp->SignalReadyToSend(rtp); });
1860 WaitForThreads(); 1856 WaitForThreads();
1861 EXPECT_TRUE(media_channel1_->ready_to_send()); 1857 EXPECT_TRUE(media_channel1_->ready_to_send());
1862 1858
1863 network_thread_->Invoke<void>(RTC_FROM_HERE, [this] { 1859 network_thread_->Invoke<void>(RTC_FROM_HERE, [this] {
1864 channel1_->SetTransportChannelReadyToSend(false, false); 1860 channel1_->SetTransportChannelReadyToSend(false, false);
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
2023 cricket::TransportController* transport_controller, 2019 cricket::TransportController* transport_controller,
2024 int flags) { 2020 int flags) {
2025 rtc::Thread* signaling_thread = 2021 rtc::Thread* signaling_thread =
2026 transport_controller ? transport_controller->signaling_thread() : nullptr; 2022 transport_controller ? transport_controller->signaling_thread() : nullptr;
2027 cricket::VideoChannel* channel = new cricket::VideoChannel( 2023 cricket::VideoChannel* channel = new cricket::VideoChannel(
2028 worker_thread, network_thread, signaling_thread, ch, cricket::CN_VIDEO, 2024 worker_thread, network_thread, signaling_thread, ch, cricket::CN_VIDEO,
2029 (flags & RTCP_MUX_REQUIRED) != 0, (flags & SECURE) != 0); 2025 (flags & RTCP_MUX_REQUIRED) != 0, (flags & SECURE) != 0);
2030 rtc::CryptoOptions crypto_options; 2026 rtc::CryptoOptions crypto_options;
2031 crypto_options.enable_gcm_crypto_suites = (flags & GCM_CIPHER) != 0; 2027 crypto_options.enable_gcm_crypto_suites = (flags & GCM_CIPHER) != 0;
2032 channel->SetCryptoOptions(crypto_options); 2028 channel->SetCryptoOptions(crypto_options);
2033 cricket::DtlsTransportInternal* rtp_dtls_transport = 2029 cricket::TransportChannel* rtp_transport =
2034 transport_controller->CreateDtlsTransport( 2030 transport_controller->CreateTransportChannel(
2035 channel->content_name(), cricket::ICE_CANDIDATE_COMPONENT_RTP); 2031 channel->content_name(), cricket::ICE_CANDIDATE_COMPONENT_RTP);
2036 cricket::DtlsTransportInternal* rtcp_dtls_transport = nullptr; 2032 cricket::TransportChannel* rtcp_transport = nullptr;
2037 if (channel->NeedsRtcpTransport()) { 2033 if (channel->NeedsRtcpTransport()) {
2038 rtcp_dtls_transport = transport_controller->CreateDtlsTransport( 2034 rtcp_transport = transport_controller->CreateTransportChannel(
2039 channel->content_name(), cricket::ICE_CANDIDATE_COMPONENT_RTCP); 2035 channel->content_name(), cricket::ICE_CANDIDATE_COMPONENT_RTCP);
2040 } 2036 }
2041 if (!channel->Init_w(rtp_dtls_transport, rtcp_dtls_transport)) { 2037 if (!channel->Init_w(rtp_transport, rtcp_transport)) {
2042 delete channel; 2038 delete channel;
2043 channel = NULL; 2039 channel = NULL;
2044 } 2040 }
2045 return channel; 2041 return channel;
2046 } 2042 }
2047 2043
2048 // override to add 0 parameter 2044 // override to add 0 parameter
2049 template<> 2045 template<>
2050 bool ChannelTest<VideoTraits>::AddStream1(int id) { 2046 bool ChannelTest<VideoTraits>::AddStream1(int id) {
2051 return channel1_->AddRecvStream(cricket::StreamParams::CreateLegacy(id)); 2047 return channel1_->AddRecvStream(cricket::StreamParams::CreateLegacy(id));
(...skipping 1205 matching lines...) Expand 10 before | Expand all | Expand 10 after
3257 cricket::TransportController* transport_controller, 3253 cricket::TransportController* transport_controller,
3258 int flags) { 3254 int flags) {
3259 rtc::Thread* signaling_thread = 3255 rtc::Thread* signaling_thread =
3260 transport_controller ? transport_controller->signaling_thread() : nullptr; 3256 transport_controller ? transport_controller->signaling_thread() : nullptr;
3261 cricket::RtpDataChannel* channel = new cricket::RtpDataChannel( 3257 cricket::RtpDataChannel* channel = new cricket::RtpDataChannel(
3262 worker_thread, network_thread, signaling_thread, ch, cricket::CN_DATA, 3258 worker_thread, network_thread, signaling_thread, ch, cricket::CN_DATA,
3263 (flags & RTCP_MUX_REQUIRED) != 0, (flags & SECURE) != 0); 3259 (flags & RTCP_MUX_REQUIRED) != 0, (flags & SECURE) != 0);
3264 rtc::CryptoOptions crypto_options; 3260 rtc::CryptoOptions crypto_options;
3265 crypto_options.enable_gcm_crypto_suites = (flags & GCM_CIPHER) != 0; 3261 crypto_options.enable_gcm_crypto_suites = (flags & GCM_CIPHER) != 0;
3266 channel->SetCryptoOptions(crypto_options); 3262 channel->SetCryptoOptions(crypto_options);
3267 cricket::DtlsTransportInternal* rtp_dtls_transport = 3263 cricket::TransportChannel* rtp_transport =
3268 transport_controller->CreateDtlsTransport( 3264 transport_controller->CreateTransportChannel(
3269 channel->content_name(), cricket::ICE_CANDIDATE_COMPONENT_RTP); 3265 channel->content_name(), cricket::ICE_CANDIDATE_COMPONENT_RTP);
3270 cricket::DtlsTransportInternal* rtcp_dtls_transport = nullptr; 3266 cricket::TransportChannel* rtcp_transport = nullptr;
3271 if (channel->NeedsRtcpTransport()) { 3267 if (channel->NeedsRtcpTransport()) {
3272 rtcp_dtls_transport = transport_controller->CreateDtlsTransport( 3268 rtcp_transport = transport_controller->CreateTransportChannel(
3273 channel->content_name(), cricket::ICE_CANDIDATE_COMPONENT_RTCP); 3269 channel->content_name(), cricket::ICE_CANDIDATE_COMPONENT_RTCP);
3274 } 3270 }
3275 if (!channel->Init_w(rtp_dtls_transport, rtcp_dtls_transport)) { 3271 if (!channel->Init_w(rtp_transport, rtcp_transport)) {
3276 delete channel; 3272 delete channel;
3277 channel = NULL; 3273 channel = NULL;
3278 } 3274 }
3279 return channel; 3275 return channel;
3280 } 3276 }
3281 3277
3282 template <> 3278 template <>
3283 void ChannelTest<DataTraits>::CreateContent( 3279 void ChannelTest<DataTraits>::CreateContent(
3284 int flags, 3280 int flags,
3285 const cricket::AudioCodec& audio_codec, 3281 const cricket::AudioCodec& audio_codec,
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
3593 voice_channel_( 3589 voice_channel_(
3594 rtc::Thread::Current(), 3590 rtc::Thread::Current(),
3595 rtc::Thread::Current(), 3591 rtc::Thread::Current(),
3596 rtc::Thread::Current(), 3592 rtc::Thread::Current(),
3597 &fake_media_engine_, 3593 &fake_media_engine_,
3598 new cricket::FakeVoiceMediaChannel(nullptr, 3594 new cricket::FakeVoiceMediaChannel(nullptr,
3599 cricket::AudioOptions()), 3595 cricket::AudioOptions()),
3600 cricket::CN_AUDIO, 3596 cricket::CN_AUDIO,
3601 false, 3597 false,
3602 true) { 3598 true) {
3603 rtp_transport_ = fake_transport_controller_.CreateDtlsTransport( 3599 rtp_transport_ = fake_transport_controller_.CreateTransportChannel(
3604 "foo", cricket::ICE_CANDIDATE_COMPONENT_RTP); 3600 "foo", cricket::ICE_CANDIDATE_COMPONENT_RTP);
3605 rtcp_transport_ = fake_transport_controller_.CreateDtlsTransport( 3601 rtcp_transport_ = fake_transport_controller_.CreateTransportChannel(
3606 "foo", cricket::ICE_CANDIDATE_COMPONENT_RTCP); 3602 "foo", cricket::ICE_CANDIDATE_COMPONENT_RTCP);
3607 EXPECT_TRUE(voice_channel_.Init_w(rtp_transport_, rtcp_transport_)); 3603 EXPECT_TRUE(voice_channel_.Init_w(rtp_transport_, rtcp_transport_));
3608 } 3604 }
3609 3605
3610 protected: 3606 protected:
3611 cricket::FakeTransportController fake_transport_controller_; 3607 cricket::FakeTransportController fake_transport_controller_;
3612 cricket::FakeMediaEngine fake_media_engine_; 3608 cricket::FakeMediaEngine fake_media_engine_;
3613 cricket::VoiceChannel voice_channel_; 3609 cricket::VoiceChannel voice_channel_;
3614 // Will be cleaned up by FakeTransportController, don't need to worry about 3610 // Will be cleaned up by FakeTransportController, don't need to worry about
3615 // deleting them in this test. 3611 // deleting them in this test.
3616 cricket::DtlsTransportInternal* rtp_transport_; 3612 cricket::TransportChannel* rtp_transport_;
3617 cricket::DtlsTransportInternal* rtcp_transport_; 3613 cricket::TransportChannel* rtcp_transport_;
3618 }; 3614 };
3619 3615
3620 TEST_F(BaseChannelDeathTest, SetTransportWithNullRtpTransport) { 3616 TEST_F(BaseChannelDeathTest, SetTransportWithNullRtpTransport) {
3621 cricket::DtlsTransportInternal* new_rtcp_transport = 3617 cricket::TransportChannel* new_rtcp_transport =
3622 fake_transport_controller_.CreateDtlsTransport( 3618 fake_transport_controller_.CreateTransportChannel(
3623 "bar", cricket::ICE_CANDIDATE_COMPONENT_RTCP); 3619 "bar", cricket::ICE_CANDIDATE_COMPONENT_RTCP);
3624 EXPECT_DEATH(voice_channel_.SetTransports(nullptr, new_rtcp_transport), ""); 3620 EXPECT_DEATH(voice_channel_.SetTransports(nullptr, new_rtcp_transport), "");
3625 } 3621 }
3626 3622
3627 TEST_F(BaseChannelDeathTest, SetTransportWithMissingRtcpTransport) { 3623 TEST_F(BaseChannelDeathTest, SetTransportWithMissingRtcpTransport) {
3628 cricket::DtlsTransportInternal* new_rtp_transport = 3624 cricket::TransportChannel* new_rtp_transport =
3629 fake_transport_controller_.CreateDtlsTransport( 3625 fake_transport_controller_.CreateTransportChannel(
3630 "bar", cricket::ICE_CANDIDATE_COMPONENT_RTP); 3626 "bar", cricket::ICE_CANDIDATE_COMPONENT_RTP);
3631 EXPECT_DEATH(voice_channel_.SetTransports(new_rtp_transport, nullptr), ""); 3627 EXPECT_DEATH(voice_channel_.SetTransports(new_rtp_transport, nullptr), "");
3632 } 3628 }
3633 3629
3634 TEST_F(BaseChannelDeathTest, SetTransportWithUnneededRtcpTransport) { 3630 TEST_F(BaseChannelDeathTest, SetTransportWithUnneededRtcpTransport) {
3635 // Activate RTCP muxing, simulating offer/answer negotiation. 3631 // Activate RTCP muxing, simulating offer/answer negotiation.
3636 cricket::AudioContentDescription content; 3632 cricket::AudioContentDescription content;
3637 content.set_rtcp_mux(true); 3633 content.set_rtcp_mux(true);
3638 ASSERT_TRUE(voice_channel_.SetLocalContent(&content, CA_OFFER, nullptr)); 3634 ASSERT_TRUE(voice_channel_.SetLocalContent(&content, CA_OFFER, nullptr));
3639 ASSERT_TRUE(voice_channel_.SetRemoteContent(&content, CA_ANSWER, nullptr)); 3635 ASSERT_TRUE(voice_channel_.SetRemoteContent(&content, CA_ANSWER, nullptr));
3640 cricket::DtlsTransportInternal* new_rtp_transport = 3636 cricket::TransportChannel* new_rtp_transport =
3641 fake_transport_controller_.CreateDtlsTransport( 3637 fake_transport_controller_.CreateTransportChannel(
3642 "bar", cricket::ICE_CANDIDATE_COMPONENT_RTP); 3638 "bar", cricket::ICE_CANDIDATE_COMPONENT_RTP);
3643 cricket::DtlsTransportInternal* new_rtcp_transport = 3639 cricket::TransportChannel* new_rtcp_transport =
3644 fake_transport_controller_.CreateDtlsTransport( 3640 fake_transport_controller_.CreateTransportChannel(
3645 "bar", cricket::ICE_CANDIDATE_COMPONENT_RTCP); 3641 "bar", cricket::ICE_CANDIDATE_COMPONENT_RTCP);
3646 // After muxing is enabled, no RTCP transport should be passed in here. 3642 // After muxing is enabled, no RTCP transport should be passed in here.
3647 EXPECT_DEATH( 3643 EXPECT_DEATH(
3648 voice_channel_.SetTransports(new_rtp_transport, new_rtcp_transport), ""); 3644 voice_channel_.SetTransports(new_rtp_transport, new_rtcp_transport), "");
3649 } 3645 }
3650 3646
3651 // This test will probably go away if/when we move the transport name out of 3647 // This test will probably go away if/when we move the transport name out of
3652 // the transport classes and into their parent classes. 3648 // the transport classes and into their parent classes.
3653 TEST_F(BaseChannelDeathTest, SetTransportWithMismatchingTransportNames) { 3649 TEST_F(BaseChannelDeathTest, SetTransportWithMismatchingTransportNames) {
3654 cricket::DtlsTransportInternal* new_rtp_transport = 3650 cricket::TransportChannel* new_rtp_transport =
3655 fake_transport_controller_.CreateDtlsTransport( 3651 fake_transport_controller_.CreateTransportChannel(
3656 "bar", cricket::ICE_CANDIDATE_COMPONENT_RTP); 3652 "bar", cricket::ICE_CANDIDATE_COMPONENT_RTP);
3657 cricket::DtlsTransportInternal* new_rtcp_transport = 3653 cricket::TransportChannel* new_rtcp_transport =
3658 fake_transport_controller_.CreateDtlsTransport( 3654 fake_transport_controller_.CreateTransportChannel(
3659 "baz", cricket::ICE_CANDIDATE_COMPONENT_RTCP); 3655 "baz", cricket::ICE_CANDIDATE_COMPONENT_RTCP);
3660 EXPECT_DEATH( 3656 EXPECT_DEATH(
3661 voice_channel_.SetTransports(new_rtp_transport, new_rtcp_transport), ""); 3657 voice_channel_.SetTransports(new_rtp_transport, new_rtcp_transport), "");
3662 } 3658 }
3663 3659
3664 #endif // RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) 3660 #endif // RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID)
3665 3661
3666 // TODO(pthatcher): TestSetReceiver? 3662 // TODO(pthatcher): TestSetReceiver?
OLDNEW
« no previous file with comments | « webrtc/pc/channel.cc ('k') | webrtc/pc/channelmanager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698