OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2012 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 static const char kAudioTrackLabelBase[] = "audio_track"; | 93 static const char kAudioTrackLabelBase[] = "audio_track"; |
94 static const char kDataChannelLabel[] = "data_channel"; | 94 static const char kDataChannelLabel[] = "data_channel"; |
95 | 95 |
96 // Disable for TSan v2, see | 96 // Disable for TSan v2, see |
97 // https://code.google.com/p/webrtc/issues/detail?id=1205 for details. | 97 // https://code.google.com/p/webrtc/issues/detail?id=1205 for details. |
98 // This declaration is also #ifdef'd as it causes unused-variable errors. | 98 // This declaration is also #ifdef'd as it causes unused-variable errors. |
99 #if !defined(THREAD_SANITIZER) | 99 #if !defined(THREAD_SANITIZER) |
100 // SRTP cipher name negotiated by the tests. This must be updated if the | 100 // SRTP cipher name negotiated by the tests. This must be updated if the |
101 // default changes. | 101 // default changes. |
102 static const int kDefaultSrtpCryptoSuite = rtc::SRTP_AES128_CM_SHA1_32; | 102 static const int kDefaultSrtpCryptoSuite = rtc::SRTP_AES128_CM_SHA1_32; |
| 103 static const int kDefaultSrtpCryptoSuiteGcm = rtc::SRTP_AEAD_AES_256_GCM; |
103 #endif | 104 #endif |
104 | 105 |
105 static void RemoveLinesFromSdp(const std::string& line_start, | 106 static void RemoveLinesFromSdp(const std::string& line_start, |
106 std::string* sdp) { | 107 std::string* sdp) { |
107 const char kSdpLineEnd[] = "\r\n"; | 108 const char kSdpLineEnd[] = "\r\n"; |
108 size_t ssrc_pos = 0; | 109 size_t ssrc_pos = 0; |
109 while ((ssrc_pos = sdp->find(line_start, ssrc_pos)) != | 110 while ((ssrc_pos = sdp->find(line_start, ssrc_pos)) != |
110 std::string::npos) { | 111 std::string::npos) { |
111 size_t end_ssrc = sdp->find(kSdpLineEnd, ssrc_pos); | 112 size_t end_ssrc = sdp->find(kSdpLineEnd, ssrc_pos); |
112 sdp->erase(ssrc_pos, end_ssrc - ssrc_pos + strlen(kSdpLineEnd)); | 113 sdp->erase(ssrc_pos, end_ssrc - ssrc_pos + strlen(kSdpLineEnd)); |
(...skipping 1181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1294 | 1295 |
1295 // Set the |receiving_client_| to the |client| passed in and return the | 1296 // Set the |receiving_client_| to the |client| passed in and return the |
1296 // original |receiving_client_|. | 1297 // original |receiving_client_|. |
1297 PeerConnectionTestClient* set_receiving_client( | 1298 PeerConnectionTestClient* set_receiving_client( |
1298 PeerConnectionTestClient* client) { | 1299 PeerConnectionTestClient* client) { |
1299 PeerConnectionTestClient* old = receiving_client_.release(); | 1300 PeerConnectionTestClient* old = receiving_client_.release(); |
1300 receiving_client_.reset(client); | 1301 receiving_client_.reset(client); |
1301 return old; | 1302 return old; |
1302 } | 1303 } |
1303 | 1304 |
| 1305 void TestGcmNegotiation(bool local_gcm_enabled, bool remote_gcm_enabled, |
| 1306 int expected_cipher_suite) { |
| 1307 PeerConnectionFactory::Options init_options; |
| 1308 init_options.crypto_options.enable_gcm_crypto_suites = local_gcm_enabled; |
| 1309 PeerConnectionFactory::Options recv_options; |
| 1310 recv_options.crypto_options.enable_gcm_crypto_suites = remote_gcm_enabled; |
| 1311 ASSERT_TRUE( |
| 1312 CreateTestClients(nullptr, &init_options, nullptr, &recv_options)); |
| 1313 rtc::scoped_refptr<webrtc::FakeMetricsObserver> |
| 1314 init_observer = |
| 1315 new rtc::RefCountedObject<webrtc::FakeMetricsObserver>(); |
| 1316 initializing_client()->pc()->RegisterUMAObserver(init_observer); |
| 1317 LocalP2PTest(); |
| 1318 |
| 1319 EXPECT_EQ_WAIT(rtc::SrtpCryptoSuiteToName(expected_cipher_suite), |
| 1320 initializing_client()->GetSrtpCipherStats(), |
| 1321 kMaxWaitForStatsMs); |
| 1322 EXPECT_EQ(1, |
| 1323 init_observer->GetEnumCounter(webrtc::kEnumCounterAudioSrtpCipher, |
| 1324 expected_cipher_suite)); |
| 1325 } |
| 1326 |
1304 private: | 1327 private: |
1305 // |worker_thread_| is used by both |initiating_client_| and | 1328 // |worker_thread_| is used by both |initiating_client_| and |
1306 // |receiving_client_|. Must be destroyed last. | 1329 // |receiving_client_|. Must be destroyed last. |
1307 rtc::Thread worker_thread_; | 1330 rtc::Thread worker_thread_; |
1308 std::unique_ptr<rtc::PhysicalSocketServer> pss_; | 1331 std::unique_ptr<rtc::PhysicalSocketServer> pss_; |
1309 std::unique_ptr<rtc::VirtualSocketServer> ss_; | 1332 std::unique_ptr<rtc::VirtualSocketServer> ss_; |
1310 rtc::SocketServerScope ss_scope_; | 1333 rtc::SocketServerScope ss_scope_; |
1311 std::unique_ptr<PeerConnectionTestClient> initiating_client_; | 1334 std::unique_ptr<PeerConnectionTestClient> initiating_client_; |
1312 std::unique_ptr<PeerConnectionTestClient> receiving_client_; | 1335 std::unique_ptr<PeerConnectionTestClient> receiving_client_; |
1313 bool prefer_constraint_apis_ = true; | 1336 bool prefer_constraint_apis_ = true; |
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1715 initializing_client()->GetDtlsCipherStats(), rtc::KT_DEFAULT), | 1738 initializing_client()->GetDtlsCipherStats(), rtc::KT_DEFAULT), |
1716 kMaxWaitForStatsMs); | 1739 kMaxWaitForStatsMs); |
1717 EXPECT_EQ_WAIT(rtc::SrtpCryptoSuiteToName(kDefaultSrtpCryptoSuite), | 1740 EXPECT_EQ_WAIT(rtc::SrtpCryptoSuiteToName(kDefaultSrtpCryptoSuite), |
1718 initializing_client()->GetSrtpCipherStats(), | 1741 initializing_client()->GetSrtpCipherStats(), |
1719 kMaxWaitForStatsMs); | 1742 kMaxWaitForStatsMs); |
1720 EXPECT_EQ(1, | 1743 EXPECT_EQ(1, |
1721 init_observer->GetEnumCounter(webrtc::kEnumCounterAudioSrtpCipher, | 1744 init_observer->GetEnumCounter(webrtc::kEnumCounterAudioSrtpCipher, |
1722 kDefaultSrtpCryptoSuite)); | 1745 kDefaultSrtpCryptoSuite)); |
1723 } | 1746 } |
1724 | 1747 |
| 1748 // Test that a non-GCM cipher is used if both sides only support non-GCM. |
| 1749 TEST_F(P2PTestConductor, GetGcmNone) { |
| 1750 TestGcmNegotiation(false, false, kDefaultSrtpCryptoSuite); |
| 1751 } |
| 1752 |
| 1753 // Test that a GCM cipher is used if both ends support it. |
| 1754 TEST_F(P2PTestConductor, GetGcmBoth) { |
| 1755 TestGcmNegotiation(true, true, kDefaultSrtpCryptoSuiteGcm); |
| 1756 } |
| 1757 |
| 1758 // Test that GCM isn't used if only the initiator supports it. |
| 1759 TEST_F(P2PTestConductor, GetGcmInit) { |
| 1760 TestGcmNegotiation(true, false, kDefaultSrtpCryptoSuite); |
| 1761 } |
| 1762 |
| 1763 // Test that GCM isn't used if only the receiver supports it. |
| 1764 TEST_F(P2PTestConductor, GetGcmRecv) { |
| 1765 TestGcmNegotiation(false, true, kDefaultSrtpCryptoSuite); |
| 1766 } |
| 1767 |
1725 // This test sets up a call between two parties with audio, video and an RTP | 1768 // This test sets up a call between two parties with audio, video and an RTP |
1726 // data channel. | 1769 // data channel. |
1727 TEST_F(P2PTestConductor, LocalP2PTestRtpDataChannel) { | 1770 TEST_F(P2PTestConductor, LocalP2PTestRtpDataChannel) { |
1728 FakeConstraints setup_constraints; | 1771 FakeConstraints setup_constraints; |
1729 setup_constraints.SetAllowRtpDataChannels(); | 1772 setup_constraints.SetAllowRtpDataChannels(); |
1730 ASSERT_TRUE(CreateTestClients(&setup_constraints, &setup_constraints)); | 1773 ASSERT_TRUE(CreateTestClients(&setup_constraints, &setup_constraints)); |
1731 initializing_client()->CreateDataChannel(); | 1774 initializing_client()->CreateDataChannel(); |
1732 LocalP2PTest(); | 1775 LocalP2PTest(); |
1733 ASSERT_TRUE(initializing_client()->data_channel() != nullptr); | 1776 ASSERT_TRUE(initializing_client()->data_channel() != nullptr); |
1734 ASSERT_TRUE(receiving_client()->data_channel() != nullptr); | 1777 ASSERT_TRUE(receiving_client()->data_channel() != nullptr); |
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2199 server.urls.push_back("turn:hostname2"); | 2242 server.urls.push_back("turn:hostname2"); |
2200 servers.push_back(server); | 2243 servers.push_back(server); |
2201 EXPECT_TRUE(webrtc::ParseIceServers(servers, &stun_servers_, &turn_servers_)); | 2244 EXPECT_TRUE(webrtc::ParseIceServers(servers, &stun_servers_, &turn_servers_)); |
2202 EXPECT_EQ(2U, turn_servers_.size()); | 2245 EXPECT_EQ(2U, turn_servers_.size()); |
2203 EXPECT_NE(turn_servers_[0].priority, turn_servers_[1].priority); | 2246 EXPECT_NE(turn_servers_[0].priority, turn_servers_[1].priority); |
2204 } | 2247 } |
2205 | 2248 |
2206 #endif // if !defined(THREAD_SANITIZER) | 2249 #endif // if !defined(THREAD_SANITIZER) |
2207 | 2250 |
2208 } // namespace | 2251 } // namespace |
OLD | NEW |