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