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

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

Issue 2938013003: Delete SignalSrtpError. (Closed)
Patch Set: Delete left-over declaration of set_signal_silent_time. Created 3 years, 6 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 1738 matching lines...) Expand 10 before | Expand all | Expand 10 after
1749 rtc::Thread* wait_for[] = {send_rtcp.thread()}; 1749 rtc::Thread* wait_for[] = {send_rtcp.thread()};
1750 WaitForThreads(wait_for); // Ensure rtcp was posted 1750 WaitForThreads(wait_for); // Ensure rtcp was posted
1751 1751
1752 // When channel1_ is deleted, the RTCP packet should be sent out to 1752 // When channel1_ is deleted, the RTCP packet should be sent out to
1753 // channel2_. 1753 // channel2_.
1754 channel1_.reset(); 1754 channel1_.reset();
1755 WaitForThreads(); 1755 WaitForThreads();
1756 EXPECT_TRUE(CheckRtcp2()); 1756 EXPECT_TRUE(CheckRtcp2());
1757 } 1757 }
1758 1758
1759 void TestSrtpError(int pl_type) {
1760 struct SrtpErrorHandler : public sigslot::has_slots<> {
1761 SrtpErrorHandler() :
1762 mode_(cricket::SrtpFilter::UNPROTECT),
1763 error_(cricket::SrtpFilter::ERROR_NONE) {}
1764 void OnSrtpError(uint32 ssrc, cricket::SrtpFilter::Mode mode,
1765 cricket::SrtpFilter::Error error) {
1766 mode_ = mode;
1767 error_ = error;
1768 }
1769 cricket::SrtpFilter::Mode mode_;
1770 cricket::SrtpFilter::Error error_;
1771 } error_handler;
1772
1773 // For Audio, only pl_type 0 is added to the bundle filter.
1774 // For Video, only pl_type 97 is added to the bundle filter.
1775 // So we need to pass in pl_type so that the packet can pass through
1776 // the bundle filter before it can be processed by the srtp filter.
1777 // The packet is not a valid srtp packet because it is too short.
1778 static unsigned const char kBadPacket[] = {
1779 0x84, static_cast<unsigned char>(pl_type),
1780 0x00, 0x01,
1781 0x00, 0x00,
1782 0x00, 0x00,
1783 0x00, 0x00,
1784 0x00, 0x01};
1785
1786 // Using fake clock because this tests that SRTP errors are signaled at
1787 // specific times based on set_signal_silent_time.
1788 rtc::ScopedFakeClock fake_clock;
1789
1790 CreateChannels(SECURE, SECURE);
1791 // Some code uses a time of 0 as a special value, so we must start with
1792 // a non-zero time.
1793 // TODO(deadbeef): Fix this.
1794 fake_clock.AdvanceTime(rtc::TimeDelta::FromSeconds(1));
1795
1796 EXPECT_FALSE(channel1_->secure());
1797 EXPECT_FALSE(channel2_->secure());
1798 EXPECT_TRUE(SendInitiate());
1799 EXPECT_TRUE(SendAccept());
1800 EXPECT_TRUE(channel1_->secure());
1801 EXPECT_TRUE(channel2_->secure());
1802 channel2_->srtp_filter()->set_signal_silent_time(250);
1803 channel2_->srtp_filter()->SignalSrtpError.connect(
1804 &error_handler, &SrtpErrorHandler::OnSrtpError);
1805
1806 // Testing failures in sending packets.
1807 media_channel2_->SendRtp(kBadPacket, sizeof(kBadPacket),
1808 rtc::PacketOptions());
1809 WaitForThreads();
1810 // The first failure will trigger an error.
1811 EXPECT_EQ(cricket::SrtpFilter::ERROR_FAIL, error_handler.error_);
1812 EXPECT_EQ(cricket::SrtpFilter::PROTECT, error_handler.mode_);
1813 error_handler.error_ = cricket::SrtpFilter::ERROR_NONE;
1814 error_handler.mode_ = cricket::SrtpFilter::UNPROTECT;
1815 // The next 250 ms failures will not trigger an error.
1816 media_channel2_->SendRtp(kBadPacket, sizeof(kBadPacket),
1817 rtc::PacketOptions());
1818 // Wait for a while to ensure no message comes in.
1819 WaitForThreads();
1820 fake_clock.AdvanceTime(rtc::TimeDelta::FromMilliseconds(200));
1821 EXPECT_EQ(cricket::SrtpFilter::ERROR_NONE, error_handler.error_);
1822 EXPECT_EQ(cricket::SrtpFilter::UNPROTECT, error_handler.mode_);
1823 // Wait for a little more - the error will be triggered again.
1824 fake_clock.AdvanceTime(rtc::TimeDelta::FromMilliseconds(200));
1825 media_channel2_->SendRtp(kBadPacket, sizeof(kBadPacket),
1826 rtc::PacketOptions());
1827 WaitForThreads();
1828 EXPECT_EQ(cricket::SrtpFilter::ERROR_FAIL, error_handler.error_);
1829 EXPECT_EQ(cricket::SrtpFilter::PROTECT, error_handler.mode_);
1830
1831 // Testing failures in receiving packets.
1832 error_handler.error_ = cricket::SrtpFilter::ERROR_NONE;
1833 error_handler.mode_ = cricket::SrtpFilter::UNPROTECT;
1834
1835 network_thread_->Invoke<void>(RTC_FROM_HERE, [this] {
1836 fake_rtp_dtls_transport2_->SignalReadPacket(
1837 fake_rtp_dtls_transport2_.get(),
1838 reinterpret_cast<const char*>(kBadPacket), sizeof(kBadPacket),
1839 rtc::PacketTime(), 0);
1840 });
1841 EXPECT_EQ(cricket::SrtpFilter::ERROR_FAIL, error_handler.error_);
1842 EXPECT_EQ(cricket::SrtpFilter::UNPROTECT, error_handler.mode_);
1843 // Terminate channels/threads before the fake clock is destroyed.
1844 EXPECT_TRUE(Terminate());
1845 }
1846
1847 void TestOnTransportReadyToSend() { 1759 void TestOnTransportReadyToSend() {
1848 CreateChannels(0, 0); 1760 CreateChannels(0, 0);
1849 EXPECT_FALSE(media_channel1_->ready_to_send()); 1761 EXPECT_FALSE(media_channel1_->ready_to_send());
1850 1762
1851 channel1_->OnTransportReadyToSend(true); 1763 channel1_->OnTransportReadyToSend(true);
1852 WaitForThreads(); 1764 WaitForThreads();
1853 EXPECT_TRUE(media_channel1_->ready_to_send()); 1765 EXPECT_TRUE(media_channel1_->ready_to_send());
1854 1766
1855 channel1_->OnTransportReadyToSend(false); 1767 channel1_->OnTransportReadyToSend(false);
1856 WaitForThreads(); 1768 WaitForThreads();
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after
2348 } 2260 }
2349 2261
2350 TEST_F(VoiceChannelSingleThreadTest, TestReceivePrAnswer) { 2262 TEST_F(VoiceChannelSingleThreadTest, TestReceivePrAnswer) {
2351 Base::TestReceivePrAnswer(); 2263 Base::TestReceivePrAnswer();
2352 } 2264 }
2353 2265
2354 TEST_F(VoiceChannelSingleThreadTest, TestFlushRtcp) { 2266 TEST_F(VoiceChannelSingleThreadTest, TestFlushRtcp) {
2355 Base::TestFlushRtcp(); 2267 Base::TestFlushRtcp();
2356 } 2268 }
2357 2269
2358 TEST_F(VoiceChannelSingleThreadTest, TestSrtpError) {
2359 Base::TestSrtpError(kAudioPts[0]);
2360 }
2361
2362 TEST_F(VoiceChannelSingleThreadTest, TestOnTransportReadyToSend) { 2270 TEST_F(VoiceChannelSingleThreadTest, TestOnTransportReadyToSend) {
2363 Base::TestOnTransportReadyToSend(); 2271 Base::TestOnTransportReadyToSend();
2364 } 2272 }
2365 2273
2366 TEST_F(VoiceChannelSingleThreadTest, TestOnTransportReadyToSendWithRtcpMux) { 2274 TEST_F(VoiceChannelSingleThreadTest, TestOnTransportReadyToSendWithRtcpMux) {
2367 Base::TestOnTransportReadyToSendWithRtcpMux(); 2275 Base::TestOnTransportReadyToSendWithRtcpMux();
2368 } 2276 }
2369 2277
2370 // Test that we can scale the output volume properly for 1:1 calls. 2278 // Test that we can scale the output volume properly for 1:1 calls.
2371 TEST_F(VoiceChannelSingleThreadTest, TestScaleVolume1to1Call) { 2279 TEST_F(VoiceChannelSingleThreadTest, TestScaleVolume1to1Call) {
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
2669 } 2577 }
2670 2578
2671 TEST_F(VoiceChannelDoubleThreadTest, TestReceivePrAnswer) { 2579 TEST_F(VoiceChannelDoubleThreadTest, TestReceivePrAnswer) {
2672 Base::TestReceivePrAnswer(); 2580 Base::TestReceivePrAnswer();
2673 } 2581 }
2674 2582
2675 TEST_F(VoiceChannelDoubleThreadTest, TestFlushRtcp) { 2583 TEST_F(VoiceChannelDoubleThreadTest, TestFlushRtcp) {
2676 Base::TestFlushRtcp(); 2584 Base::TestFlushRtcp();
2677 } 2585 }
2678 2586
2679 TEST_F(VoiceChannelDoubleThreadTest, TestSrtpError) {
2680 Base::TestSrtpError(kAudioPts[0]);
2681 }
2682
2683 TEST_F(VoiceChannelDoubleThreadTest, TestOnTransportReadyToSend) { 2587 TEST_F(VoiceChannelDoubleThreadTest, TestOnTransportReadyToSend) {
2684 Base::TestOnTransportReadyToSend(); 2588 Base::TestOnTransportReadyToSend();
2685 } 2589 }
2686 2590
2687 TEST_F(VoiceChannelDoubleThreadTest, TestOnTransportReadyToSendWithRtcpMux) { 2591 TEST_F(VoiceChannelDoubleThreadTest, TestOnTransportReadyToSendWithRtcpMux) {
2688 Base::TestOnTransportReadyToSendWithRtcpMux(); 2592 Base::TestOnTransportReadyToSendWithRtcpMux();
2689 } 2593 }
2690 2594
2691 // Test that we can scale the output volume properly for 1:1 calls. 2595 // Test that we can scale the output volume properly for 1:1 calls.
2692 TEST_F(VoiceChannelDoubleThreadTest, TestScaleVolume1to1Call) { 2596 TEST_F(VoiceChannelDoubleThreadTest, TestScaleVolume1to1Call) {
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
2982 } 2886 }
2983 2887
2984 TEST_F(VideoChannelSingleThreadTest, SendBundleToBundleWithRtcpMux) { 2888 TEST_F(VideoChannelSingleThreadTest, SendBundleToBundleWithRtcpMux) {
2985 Base::SendBundleToBundle(kVideoPts, arraysize(kVideoPts), true, false); 2889 Base::SendBundleToBundle(kVideoPts, arraysize(kVideoPts), true, false);
2986 } 2890 }
2987 2891
2988 TEST_F(VideoChannelSingleThreadTest, SendBundleToBundleWithRtcpMuxSecure) { 2892 TEST_F(VideoChannelSingleThreadTest, SendBundleToBundleWithRtcpMuxSecure) {
2989 Base::SendBundleToBundle(kVideoPts, arraysize(kVideoPts), true, true); 2893 Base::SendBundleToBundle(kVideoPts, arraysize(kVideoPts), true, true);
2990 } 2894 }
2991 2895
2992 TEST_F(VideoChannelSingleThreadTest, TestSrtpError) {
2993 Base::TestSrtpError(kVideoPts[0]);
2994 }
2995
2996 TEST_F(VideoChannelSingleThreadTest, TestOnTransportReadyToSend) { 2896 TEST_F(VideoChannelSingleThreadTest, TestOnTransportReadyToSend) {
2997 Base::TestOnTransportReadyToSend(); 2897 Base::TestOnTransportReadyToSend();
2998 } 2898 }
2999 2899
3000 TEST_F(VideoChannelSingleThreadTest, TestOnTransportReadyToSendWithRtcpMux) { 2900 TEST_F(VideoChannelSingleThreadTest, TestOnTransportReadyToSendWithRtcpMux) {
3001 Base::TestOnTransportReadyToSendWithRtcpMux(); 2901 Base::TestOnTransportReadyToSendWithRtcpMux();
3002 } 2902 }
3003 2903
3004 TEST_F(VideoChannelSingleThreadTest, DefaultMaxBitrateIsUnlimited) { 2904 TEST_F(VideoChannelSingleThreadTest, DefaultMaxBitrateIsUnlimited) {
3005 Base::DefaultMaxBitrateIsUnlimited(); 2905 Base::DefaultMaxBitrateIsUnlimited();
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
3217 } 3117 }
3218 3118
3219 TEST_F(VideoChannelDoubleThreadTest, SendBundleToBundleWithRtcpMux) { 3119 TEST_F(VideoChannelDoubleThreadTest, SendBundleToBundleWithRtcpMux) {
3220 Base::SendBundleToBundle(kVideoPts, arraysize(kVideoPts), true, false); 3120 Base::SendBundleToBundle(kVideoPts, arraysize(kVideoPts), true, false);
3221 } 3121 }
3222 3122
3223 TEST_F(VideoChannelDoubleThreadTest, SendBundleToBundleWithRtcpMuxSecure) { 3123 TEST_F(VideoChannelDoubleThreadTest, SendBundleToBundleWithRtcpMuxSecure) {
3224 Base::SendBundleToBundle(kVideoPts, arraysize(kVideoPts), true, true); 3124 Base::SendBundleToBundle(kVideoPts, arraysize(kVideoPts), true, true);
3225 } 3125 }
3226 3126
3227 TEST_F(VideoChannelDoubleThreadTest, TestSrtpError) {
3228 Base::TestSrtpError(kVideoPts[0]);
3229 }
3230
3231 TEST_F(VideoChannelDoubleThreadTest, TestOnTransportReadyToSend) { 3127 TEST_F(VideoChannelDoubleThreadTest, TestOnTransportReadyToSend) {
3232 Base::TestOnTransportReadyToSend(); 3128 Base::TestOnTransportReadyToSend();
3233 } 3129 }
3234 3130
3235 TEST_F(VideoChannelDoubleThreadTest, TestOnTransportReadyToSendWithRtcpMux) { 3131 TEST_F(VideoChannelDoubleThreadTest, TestOnTransportReadyToSendWithRtcpMux) {
3236 Base::TestOnTransportReadyToSendWithRtcpMux(); 3132 Base::TestOnTransportReadyToSendWithRtcpMux();
3237 } 3133 }
3238 3134
3239 TEST_F(VideoChannelDoubleThreadTest, DefaultMaxBitrateIsUnlimited) { 3135 TEST_F(VideoChannelDoubleThreadTest, DefaultMaxBitrateIsUnlimited) {
3240 Base::DefaultMaxBitrateIsUnlimited(); 3136 Base::DefaultMaxBitrateIsUnlimited();
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after
3690 ASSERT_TRUE(voice_channel_.Init_w(nullptr, nullptr, &fake_rtp_dtls_transport_, 3586 ASSERT_TRUE(voice_channel_.Init_w(nullptr, nullptr, &fake_rtp_dtls_transport_,
3691 &fake_rtcp_dtls_transport_)); 3587 &fake_rtcp_dtls_transport_));
3692 EXPECT_DEATH(voice_channel_.SetTransports(&fake_rtp_dtls_transport_, 3588 EXPECT_DEATH(voice_channel_.SetTransports(&fake_rtp_dtls_transport_,
3693 &fake_rtp_dtls_transport_), 3589 &fake_rtp_dtls_transport_),
3694 ""); 3590 "");
3695 } 3591 }
3696 3592
3697 #endif // RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) 3593 #endif // RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID)
3698 3594
3699 // TODO(pthatcher): TestSetReceiver? 3595 // TODO(pthatcher): TestSetReceiver?
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698