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

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

Issue 2997983002: Completed the functionalities of SrtpTransport. (Closed)
Patch Set: Remove the UpdateRtpParams method. Created 3 years, 3 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
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
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 int flags, 574 int flags,
575 typename T::Content* content) { 575 typename T::Content* content) {
576 // Base implementation. 576 // Base implementation.
577 } 577 }
578 578
579 // Tests that can be used by derived classes. 579 // Tests that can be used by derived classes.
580 580
581 // Basic sanity check. 581 // Basic sanity check.
582 void TestInit() { 582 void TestInit() {
583 CreateChannels(0, 0); 583 CreateChannels(0, 0);
584 EXPECT_FALSE(channel1_->secure()); 584 EXPECT_FALSE(channel1_->srtp_active());
585 EXPECT_FALSE(media_channel1_->sending()); 585 EXPECT_FALSE(media_channel1_->sending());
586 if (verify_playout_) { 586 if (verify_playout_) {
587 EXPECT_FALSE(media_channel1_->playout()); 587 EXPECT_FALSE(media_channel1_->playout());
588 } 588 }
589 EXPECT_TRUE(media_channel1_->codecs().empty()); 589 EXPECT_TRUE(media_channel1_->codecs().empty());
590 EXPECT_TRUE(media_channel1_->recv_streams().empty()); 590 EXPECT_TRUE(media_channel1_->recv_streams().empty());
591 EXPECT_TRUE(media_channel1_->rtp_packets().empty()); 591 EXPECT_TRUE(media_channel1_->rtp_packets().empty());
592 EXPECT_TRUE(media_channel1_->rtcp_packets().empty()); 592 EXPECT_TRUE(media_channel1_->rtcp_packets().empty());
593 } 593 }
594 594
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
889 889
890 // Channel 1 replies but stop sending stream1. 890 // Channel 1 replies but stop sending stream1.
891 typename T::Content content4; 891 typename T::Content content4;
892 CreateContent(SECURE, kPcmuCodec, kH264Codec, &content4); 892 CreateContent(SECURE, kPcmuCodec, kH264Codec, &content4);
893 EXPECT_TRUE(channel1_->SetLocalContent(&content4, CA_ANSWER, NULL)); 893 EXPECT_TRUE(channel1_->SetLocalContent(&content4, CA_ANSWER, NULL));
894 EXPECT_EQ(0u, media_channel1_->send_streams().size()); 894 EXPECT_EQ(0u, media_channel1_->send_streams().size());
895 895
896 EXPECT_TRUE(channel2_->SetRemoteContent(&content4, CA_ANSWER, NULL)); 896 EXPECT_TRUE(channel2_->SetRemoteContent(&content4, CA_ANSWER, NULL));
897 EXPECT_EQ(0u, media_channel2_->recv_streams().size()); 897 EXPECT_EQ(0u, media_channel2_->recv_streams().size());
898 898
899 EXPECT_TRUE(channel1_->secure()); 899 EXPECT_TRUE(channel1_->srtp_active());
900 EXPECT_TRUE(channel2_->secure()); 900 EXPECT_TRUE(channel2_->srtp_active());
901 SendCustomRtp2(kSsrc2, 0); 901 SendCustomRtp2(kSsrc2, 0);
902 WaitForThreads(); 902 WaitForThreads();
903 EXPECT_TRUE(CheckCustomRtp1(kSsrc2, 0)); 903 EXPECT_TRUE(CheckCustomRtp1(kSsrc2, 0));
904 } 904 }
905 905
906 enum EncryptedHeaderTestScenario { 906 enum EncryptedHeaderTestScenario {
907 // Offer/Answer are processed before DTLS completes. 907 // Offer/Answer are processed before DTLS completes.
908 DEFAULT, 908 DEFAULT,
909 // DTLS completes before any Offer/Answer have been sent. 909 // DTLS completes before any Offer/Answer have been sent.
910 DTLS_BEFORE_OFFER_ANSWER, 910 DTLS_BEFORE_OFFER_ANSWER,
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
1248 EXPECT_EQ(kLastPacketId, 1248 EXPECT_EQ(kLastPacketId,
1249 media_channel1->last_network_route().last_sent_packet_id); 1249 media_channel1->last_network_route().last_sent_packet_id);
1250 constexpr int kTransportOverheadPerPacket = 28; // Ipv4(20) + UDP(8). 1250 constexpr int kTransportOverheadPerPacket = 28; // Ipv4(20) + UDP(8).
1251 EXPECT_EQ(kTransportOverheadPerPacket, 1251 EXPECT_EQ(kTransportOverheadPerPacket,
1252 media_channel1->transport_overhead_per_packet()); 1252 media_channel1->transport_overhead_per_packet());
1253 } 1253 }
1254 1254
1255 // Test setting up a call. 1255 // Test setting up a call.
1256 void TestCallSetup() { 1256 void TestCallSetup() {
1257 CreateChannels(0, 0); 1257 CreateChannels(0, 0);
1258 EXPECT_FALSE(channel1_->secure()); 1258 EXPECT_FALSE(channel1_->srtp_active());
1259 EXPECT_TRUE(SendInitiate()); 1259 EXPECT_TRUE(SendInitiate());
1260 if (verify_playout_) { 1260 if (verify_playout_) {
1261 EXPECT_TRUE(media_channel1_->playout()); 1261 EXPECT_TRUE(media_channel1_->playout());
1262 } 1262 }
1263 EXPECT_FALSE(media_channel1_->sending()); 1263 EXPECT_FALSE(media_channel1_->sending());
1264 EXPECT_TRUE(SendAccept()); 1264 EXPECT_TRUE(SendAccept());
1265 EXPECT_FALSE(channel1_->secure()); 1265 EXPECT_FALSE(channel1_->srtp_active());
1266 EXPECT_TRUE(media_channel1_->sending()); 1266 EXPECT_TRUE(media_channel1_->sending());
1267 EXPECT_EQ(1U, media_channel1_->codecs().size()); 1267 EXPECT_EQ(1U, media_channel1_->codecs().size());
1268 if (verify_playout_) { 1268 if (verify_playout_) {
1269 EXPECT_TRUE(media_channel2_->playout()); 1269 EXPECT_TRUE(media_channel2_->playout());
1270 } 1270 }
1271 EXPECT_TRUE(media_channel2_->sending()); 1271 EXPECT_TRUE(media_channel2_->sending());
1272 EXPECT_EQ(1U, media_channel2_->codecs().size()); 1272 EXPECT_EQ(1U, media_channel2_->codecs().size());
1273 } 1273 }
1274 1274
1275 // Test that we don't crash if packets are sent during call teardown 1275 // Test that we don't crash if packets are sent during call teardown
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
1530 // You can pass in DTLS, RTCP_MUX, and RAW_PACKET_TRANSPORT as flags. 1530 // You can pass in DTLS, RTCP_MUX, and RAW_PACKET_TRANSPORT as flags.
1531 void SendSrtpToSrtp(int flags1_in = 0, int flags2_in = 0) { 1531 void SendSrtpToSrtp(int flags1_in = 0, int flags2_in = 0) {
1532 RTC_CHECK((flags1_in & ~(RTCP_MUX | DTLS | RAW_PACKET_TRANSPORT)) == 0); 1532 RTC_CHECK((flags1_in & ~(RTCP_MUX | DTLS | RAW_PACKET_TRANSPORT)) == 0);
1533 RTC_CHECK((flags2_in & ~(RTCP_MUX | DTLS | RAW_PACKET_TRANSPORT)) == 0); 1533 RTC_CHECK((flags2_in & ~(RTCP_MUX | DTLS | RAW_PACKET_TRANSPORT)) == 0);
1534 1534
1535 int flags1 = SECURE | flags1_in; 1535 int flags1 = SECURE | flags1_in;
1536 int flags2 = SECURE | flags2_in; 1536 int flags2 = SECURE | flags2_in;
1537 bool dtls1 = !!(flags1_in & DTLS); 1537 bool dtls1 = !!(flags1_in & DTLS);
1538 bool dtls2 = !!(flags2_in & DTLS); 1538 bool dtls2 = !!(flags2_in & DTLS);
1539 CreateChannels(flags1, flags2); 1539 CreateChannels(flags1, flags2);
1540 EXPECT_FALSE(channel1_->secure()); 1540 EXPECT_FALSE(channel1_->srtp_active());
1541 EXPECT_FALSE(channel2_->secure()); 1541 EXPECT_FALSE(channel2_->srtp_active());
1542 EXPECT_TRUE(SendInitiate()); 1542 EXPECT_TRUE(SendInitiate());
1543 WaitForThreads(); 1543 WaitForThreads();
1544 EXPECT_TRUE(channel1_->writable()); 1544 EXPECT_TRUE(channel1_->writable());
1545 EXPECT_TRUE(channel2_->writable()); 1545 EXPECT_TRUE(channel2_->writable());
1546 EXPECT_TRUE(SendAccept()); 1546 EXPECT_TRUE(SendAccept());
1547 EXPECT_TRUE(channel1_->secure()); 1547 EXPECT_TRUE(channel1_->srtp_active());
1548 EXPECT_TRUE(channel2_->secure()); 1548 EXPECT_TRUE(channel2_->srtp_active());
1549 EXPECT_EQ(dtls1 && dtls2, channel1_->secure_dtls()); 1549 EXPECT_EQ(dtls1 && dtls2, channel1_->dtls_active());
1550 EXPECT_EQ(dtls1 && dtls2, channel2_->secure_dtls()); 1550 EXPECT_EQ(dtls1 && dtls2, channel2_->dtls_active());
1551 SendRtp1(); 1551 SendRtp1();
1552 SendRtp2(); 1552 SendRtp2();
1553 SendRtcp1(); 1553 SendRtcp1();
1554 SendRtcp2(); 1554 SendRtcp2();
1555 WaitForThreads(); 1555 WaitForThreads();
1556 EXPECT_TRUE(CheckRtp1()); 1556 EXPECT_TRUE(CheckRtp1());
1557 EXPECT_TRUE(CheckRtp2()); 1557 EXPECT_TRUE(CheckRtp2());
1558 EXPECT_TRUE(CheckNoRtp1()); 1558 EXPECT_TRUE(CheckNoRtp1());
1559 EXPECT_TRUE(CheckNoRtp2()); 1559 EXPECT_TRUE(CheckNoRtp2());
1560 EXPECT_TRUE(CheckRtcp1()); 1560 EXPECT_TRUE(CheckRtcp1());
1561 EXPECT_TRUE(CheckRtcp2()); 1561 EXPECT_TRUE(CheckRtcp2());
1562 EXPECT_TRUE(CheckNoRtcp1()); 1562 EXPECT_TRUE(CheckNoRtcp1());
1563 EXPECT_TRUE(CheckNoRtcp2()); 1563 EXPECT_TRUE(CheckNoRtcp2());
1564 } 1564 }
1565 1565
1566 // Test that we properly handling SRTP negotiating down to RTP. 1566 // Test that we properly handling SRTP negotiating down to RTP.
1567 void SendSrtpToRtp() { 1567 void SendSrtpToRtp() {
1568 CreateChannels(SECURE, 0); 1568 CreateChannels(SECURE, 0);
1569 EXPECT_FALSE(channel1_->secure()); 1569 EXPECT_FALSE(channel1_->srtp_active());
1570 EXPECT_FALSE(channel2_->secure()); 1570 EXPECT_FALSE(channel2_->srtp_active());
1571 EXPECT_TRUE(SendInitiate()); 1571 EXPECT_TRUE(SendInitiate());
1572 EXPECT_TRUE(SendAccept()); 1572 EXPECT_TRUE(SendAccept());
1573 EXPECT_FALSE(channel1_->secure()); 1573 EXPECT_FALSE(channel1_->srtp_active());
1574 EXPECT_FALSE(channel2_->secure()); 1574 EXPECT_FALSE(channel2_->srtp_active());
1575 SendRtp1(); 1575 SendRtp1();
1576 SendRtp2(); 1576 SendRtp2();
1577 SendRtcp1(); 1577 SendRtcp1();
1578 SendRtcp2(); 1578 SendRtcp2();
1579 WaitForThreads(); 1579 WaitForThreads();
1580 EXPECT_TRUE(CheckRtp1()); 1580 EXPECT_TRUE(CheckRtp1());
1581 EXPECT_TRUE(CheckRtp2()); 1581 EXPECT_TRUE(CheckRtp2());
1582 EXPECT_TRUE(CheckNoRtp1()); 1582 EXPECT_TRUE(CheckNoRtp1());
1583 EXPECT_TRUE(CheckNoRtp2()); 1583 EXPECT_TRUE(CheckNoRtp2());
1584 EXPECT_TRUE(CheckRtcp1()); 1584 EXPECT_TRUE(CheckRtcp1());
1585 EXPECT_TRUE(CheckRtcp2()); 1585 EXPECT_TRUE(CheckRtcp2());
1586 EXPECT_TRUE(CheckNoRtcp1()); 1586 EXPECT_TRUE(CheckNoRtcp1());
1587 EXPECT_TRUE(CheckNoRtcp2()); 1587 EXPECT_TRUE(CheckNoRtcp2());
1588 } 1588 }
1589 1589
1590 // Test that we can send and receive early media when a provisional answer is 1590 // Test that we can send and receive early media when a provisional answer is
1591 // sent and received. The test uses SRTP, RTCP mux and SSRC mux. 1591 // sent and received. The test uses SRTP, RTCP mux and SSRC mux.
1592 void SendEarlyMediaUsingRtcpMuxSrtp() { 1592 void SendEarlyMediaUsingRtcpMuxSrtp() {
1593 int sequence_number1_1 = 0, sequence_number2_2 = 0; 1593 int sequence_number1_1 = 0, sequence_number2_2 = 0;
1594 1594
1595 CreateChannels(SSRC_MUX | RTCP_MUX | SECURE, 1595 CreateChannels(SSRC_MUX | RTCP_MUX | SECURE,
1596 SSRC_MUX | RTCP_MUX | SECURE); 1596 SSRC_MUX | RTCP_MUX | SECURE);
1597 EXPECT_TRUE(SendOffer()); 1597 EXPECT_TRUE(SendOffer());
1598 EXPECT_TRUE(SendProvisionalAnswer()); 1598 EXPECT_TRUE(SendProvisionalAnswer());
1599 EXPECT_TRUE(channel1_->secure()); 1599 EXPECT_TRUE(channel1_->srtp_active());
1600 EXPECT_TRUE(channel2_->secure()); 1600 EXPECT_TRUE(channel2_->srtp_active());
1601 EXPECT_TRUE(channel1_->NeedsRtcpTransport()); 1601 EXPECT_TRUE(channel1_->NeedsRtcpTransport());
1602 EXPECT_TRUE(channel2_->NeedsRtcpTransport()); 1602 EXPECT_TRUE(channel2_->NeedsRtcpTransport());
1603 WaitForThreads(); // Wait for 'sending' flag go through network thread. 1603 WaitForThreads(); // Wait for 'sending' flag go through network thread.
1604 SendCustomRtcp1(kSsrc1); 1604 SendCustomRtcp1(kSsrc1);
1605 SendCustomRtp1(kSsrc1, ++sequence_number1_1); 1605 SendCustomRtp1(kSsrc1, ++sequence_number1_1);
1606 WaitForThreads(); 1606 WaitForThreads();
1607 EXPECT_TRUE(CheckCustomRtcp2(kSsrc1)); 1607 EXPECT_TRUE(CheckCustomRtcp2(kSsrc1));
1608 EXPECT_TRUE(CheckCustomRtp2(kSsrc1, sequence_number1_1)); 1608 EXPECT_TRUE(CheckCustomRtp2(kSsrc1, sequence_number1_1));
1609 1609
1610 // Send packets from callee and verify that it is received. 1610 // Send packets from callee and verify that it is received.
1611 SendCustomRtcp2(kSsrc2); 1611 SendCustomRtcp2(kSsrc2);
1612 SendCustomRtp2(kSsrc2, ++sequence_number2_2); 1612 SendCustomRtp2(kSsrc2, ++sequence_number2_2);
1613 WaitForThreads(); 1613 WaitForThreads();
1614 EXPECT_TRUE(CheckCustomRtcp1(kSsrc2)); 1614 EXPECT_TRUE(CheckCustomRtcp1(kSsrc2));
1615 EXPECT_TRUE(CheckCustomRtp1(kSsrc2, sequence_number2_2)); 1615 EXPECT_TRUE(CheckCustomRtp1(kSsrc2, sequence_number2_2));
1616 1616
1617 // Complete call setup and ensure everything is still OK. 1617 // Complete call setup and ensure everything is still OK.
1618 EXPECT_EQ(0, rtcp_mux_activated_callbacks1_); 1618 EXPECT_EQ(0, rtcp_mux_activated_callbacks1_);
1619 EXPECT_EQ(0, rtcp_mux_activated_callbacks2_); 1619 EXPECT_EQ(0, rtcp_mux_activated_callbacks2_);
1620 EXPECT_TRUE(SendFinalAnswer()); 1620 EXPECT_TRUE(SendFinalAnswer());
1621 EXPECT_FALSE(channel1_->NeedsRtcpTransport()); 1621 EXPECT_FALSE(channel1_->NeedsRtcpTransport());
1622 EXPECT_FALSE(channel2_->NeedsRtcpTransport()); 1622 EXPECT_FALSE(channel2_->NeedsRtcpTransport());
1623 EXPECT_EQ(1, rtcp_mux_activated_callbacks1_); 1623 EXPECT_EQ(1, rtcp_mux_activated_callbacks1_);
1624 EXPECT_EQ(1, rtcp_mux_activated_callbacks2_); 1624 EXPECT_EQ(1, rtcp_mux_activated_callbacks2_);
1625 EXPECT_TRUE(channel1_->secure()); 1625 EXPECT_TRUE(channel1_->srtp_active());
1626 EXPECT_TRUE(channel2_->secure()); 1626 EXPECT_TRUE(channel2_->srtp_active());
1627 SendCustomRtcp1(kSsrc1); 1627 SendCustomRtcp1(kSsrc1);
1628 SendCustomRtp1(kSsrc1, ++sequence_number1_1); 1628 SendCustomRtp1(kSsrc1, ++sequence_number1_1);
1629 SendCustomRtcp2(kSsrc2); 1629 SendCustomRtcp2(kSsrc2);
1630 SendCustomRtp2(kSsrc2, ++sequence_number2_2); 1630 SendCustomRtp2(kSsrc2, ++sequence_number2_2);
1631 WaitForThreads(); 1631 WaitForThreads();
1632 EXPECT_TRUE(CheckCustomRtcp2(kSsrc1)); 1632 EXPECT_TRUE(CheckCustomRtcp2(kSsrc1));
1633 EXPECT_TRUE(CheckCustomRtp2(kSsrc1, sequence_number1_1)); 1633 EXPECT_TRUE(CheckCustomRtp2(kSsrc1, sequence_number1_1));
1634 EXPECT_TRUE(CheckCustomRtcp1(kSsrc2)); 1634 EXPECT_TRUE(CheckCustomRtcp1(kSsrc2));
1635 EXPECT_TRUE(CheckCustomRtp1(kSsrc2, sequence_number2_2)); 1635 EXPECT_TRUE(CheckCustomRtp1(kSsrc2, sequence_number2_2));
1636 } 1636 }
(...skipping 2262 matching lines...) Expand 10 before | Expand all | Expand 10 after
3899 ASSERT_TRUE(voice_channel_.Init_w(nullptr, nullptr, &fake_rtp_dtls_transport_, 3899 ASSERT_TRUE(voice_channel_.Init_w(nullptr, nullptr, &fake_rtp_dtls_transport_,
3900 &fake_rtcp_dtls_transport_)); 3900 &fake_rtcp_dtls_transport_));
3901 EXPECT_DEATH(voice_channel_.SetTransports(&fake_rtp_dtls_transport_, 3901 EXPECT_DEATH(voice_channel_.SetTransports(&fake_rtp_dtls_transport_,
3902 &fake_rtp_dtls_transport_), 3902 &fake_rtp_dtls_transport_),
3903 ""); 3903 "");
3904 } 3904 }
3905 3905
3906 #endif // RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) 3906 #endif // RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID)
3907 3907
3908 // TODO(pthatcher): TestSetReceiver? 3908 // TODO(pthatcher): TestSetReceiver?
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698