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

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

Issue 2812243005: Move ready to send logic from BaseChannel to RtpTransport. (Closed)
Patch Set: Remove dcheck that does not currently hold. Created 3 years, 7 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/rtptransport.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
(...skipping 1826 matching lines...) Expand 10 before | Expand all | Expand 10 after
1837 fake_rtp_dtls_transport2_.get(), 1837 fake_rtp_dtls_transport2_.get(),
1838 reinterpret_cast<const char*>(kBadPacket), sizeof(kBadPacket), 1838 reinterpret_cast<const char*>(kBadPacket), sizeof(kBadPacket),
1839 rtc::PacketTime(), 0); 1839 rtc::PacketTime(), 0);
1840 }); 1840 });
1841 EXPECT_EQ(cricket::SrtpFilter::ERROR_FAIL, error_handler.error_); 1841 EXPECT_EQ(cricket::SrtpFilter::ERROR_FAIL, error_handler.error_);
1842 EXPECT_EQ(cricket::SrtpFilter::UNPROTECT, error_handler.mode_); 1842 EXPECT_EQ(cricket::SrtpFilter::UNPROTECT, error_handler.mode_);
1843 // Terminate channels/threads before the fake clock is destroyed. 1843 // Terminate channels/threads before the fake clock is destroyed.
1844 EXPECT_TRUE(Terminate()); 1844 EXPECT_TRUE(Terminate());
1845 } 1845 }
1846 1846
1847 void TestOnReadyToSend() { 1847 void TestOnTransportReadyToSend() {
1848 CreateChannels(0, 0); 1848 CreateChannels(0, 0);
1849 cricket::FakeDtlsTransport* rtp = fake_rtp_dtls_transport1_.get();
1850 cricket::FakeDtlsTransport* rtcp = fake_rtcp_dtls_transport1_.get();
1851 EXPECT_FALSE(media_channel1_->ready_to_send()); 1849 EXPECT_FALSE(media_channel1_->ready_to_send());
1852 1850
1853 network_thread_->Invoke<void>(RTC_FROM_HERE, 1851 channel1_->OnTransportReadyToSend(true);
1854 [rtp] { rtp->SignalReadyToSend(rtp); });
1855 WaitForThreads();
1856 EXPECT_FALSE(media_channel1_->ready_to_send());
1857
1858 network_thread_->Invoke<void>(RTC_FROM_HERE,
1859 [rtcp] { rtcp->SignalReadyToSend(rtcp); });
1860 WaitForThreads();
1861 // MediaChannel::OnReadyToSend only be called when both rtp and rtcp
1862 // channel are ready to send.
1863 EXPECT_TRUE(media_channel1_->ready_to_send());
1864
1865 // rtp channel becomes not ready to send will be propagated to mediachannel
1866 network_thread_->Invoke<void>(RTC_FROM_HERE, [this] {
1867 channel1_->SetTransportChannelReadyToSend(false, false);
1868 });
1869 WaitForThreads();
1870 EXPECT_FALSE(media_channel1_->ready_to_send());
1871
1872 network_thread_->Invoke<void>(RTC_FROM_HERE, [this] {
1873 channel1_->SetTransportChannelReadyToSend(false, true);
1874 });
1875 WaitForThreads(); 1852 WaitForThreads();
1876 EXPECT_TRUE(media_channel1_->ready_to_send()); 1853 EXPECT_TRUE(media_channel1_->ready_to_send());
1877 1854
1878 // rtcp channel becomes not ready to send will be propagated to mediachannel 1855 channel1_->OnTransportReadyToSend(false);
1879 network_thread_->Invoke<void>(RTC_FROM_HERE, [this] {
1880 channel1_->SetTransportChannelReadyToSend(true, false);
1881 });
1882 WaitForThreads(); 1856 WaitForThreads();
1883 EXPECT_FALSE(media_channel1_->ready_to_send()); 1857 EXPECT_FALSE(media_channel1_->ready_to_send());
1884
1885 network_thread_->Invoke<void>(RTC_FROM_HERE, [this] {
1886 channel1_->SetTransportChannelReadyToSend(true, true);
1887 });
1888 WaitForThreads();
1889 EXPECT_TRUE(media_channel1_->ready_to_send());
1890 } 1858 }
1891 1859
1892 void TestOnReadyToSendWithRtcpMux() { 1860 void TestOnTransportReadyToSendWithRtcpMux() {
1893 CreateChannels(0, 0); 1861 CreateChannels(0, 0);
1894 typename T::Content content; 1862 typename T::Content content;
1895 CreateContent(0, kPcmuCodec, kH264Codec, &content); 1863 CreateContent(0, kPcmuCodec, kH264Codec, &content);
1896 // Both sides agree on mux. Should signal that RTCP mux is fully active. 1864 // Both sides agree on mux. Should signal that RTCP mux is fully active.
1897 content.set_rtcp_mux(true); 1865 content.set_rtcp_mux(true);
1898 EXPECT_TRUE(channel1_->SetLocalContent(&content, CA_OFFER, NULL)); 1866 EXPECT_TRUE(channel1_->SetLocalContent(&content, CA_OFFER, NULL));
1899 EXPECT_EQ(0, rtcp_mux_activated_callbacks1_); 1867 EXPECT_EQ(0, rtcp_mux_activated_callbacks1_);
1900 EXPECT_TRUE(channel1_->SetRemoteContent(&content, CA_ANSWER, NULL)); 1868 EXPECT_TRUE(channel1_->SetRemoteContent(&content, CA_ANSWER, NULL));
1901 EXPECT_EQ(1, rtcp_mux_activated_callbacks1_); 1869 EXPECT_EQ(1, rtcp_mux_activated_callbacks1_);
1902 cricket::FakeDtlsTransport* rtp = fake_rtp_dtls_transport1_.get(); 1870 cricket::FakeDtlsTransport* rtp = fake_rtp_dtls_transport1_.get();
1903 EXPECT_FALSE(media_channel1_->ready_to_send()); 1871 EXPECT_FALSE(media_channel1_->ready_to_send());
1904 // In the case of rtcp mux, the SignalReadyToSend() from rtp channel 1872 // In the case of rtcp mux, the SignalReadyToSend() from rtp channel
1905 // should trigger the MediaChannel's OnReadyToSend. 1873 // should trigger the MediaChannel's OnReadyToSend.
1906 network_thread_->Invoke<void>(RTC_FROM_HERE, 1874 network_thread_->Invoke<void>(RTC_FROM_HERE,
1907 [rtp] { rtp->SignalReadyToSend(rtp); }); 1875 [rtp] { rtp->SignalReadyToSend(rtp); });
1908 WaitForThreads(); 1876 WaitForThreads();
1909 EXPECT_TRUE(media_channel1_->ready_to_send()); 1877 EXPECT_TRUE(media_channel1_->ready_to_send());
1910 1878
1911 network_thread_->Invoke<void>(RTC_FROM_HERE, [this] { 1879 // TODO(zstein): Find a way to test this without making
1912 channel1_->SetTransportChannelReadyToSend(false, false); 1880 // OnTransportReadyToSend public.
1913 }); 1881 network_thread_->Invoke<void>(
1882 RTC_FROM_HERE, [this] { channel1_->OnTransportReadyToSend(false); });
1914 WaitForThreads(); 1883 WaitForThreads();
1915 EXPECT_FALSE(media_channel1_->ready_to_send()); 1884 EXPECT_FALSE(media_channel1_->ready_to_send());
1916 } 1885 }
1917 1886
1918 bool SetRemoteContentWithBitrateLimit(int remote_limit) { 1887 bool SetRemoteContentWithBitrateLimit(int remote_limit) {
1919 typename T::Content content; 1888 typename T::Content content;
1920 CreateContent(0, kPcmuCodec, kH264Codec, &content); 1889 CreateContent(0, kPcmuCodec, kH264Codec, &content);
1921 content.set_bandwidth(remote_limit); 1890 content.set_bandwidth(remote_limit);
1922 return channel1_->SetRemoteContent(&content, CA_OFFER, NULL); 1891 return channel1_->SetRemoteContent(&content, CA_OFFER, NULL);
1923 } 1892 }
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
2383 } 2352 }
2384 2353
2385 TEST_F(VoiceChannelSingleThreadTest, TestFlushRtcp) { 2354 TEST_F(VoiceChannelSingleThreadTest, TestFlushRtcp) {
2386 Base::TestFlushRtcp(); 2355 Base::TestFlushRtcp();
2387 } 2356 }
2388 2357
2389 TEST_F(VoiceChannelSingleThreadTest, TestSrtpError) { 2358 TEST_F(VoiceChannelSingleThreadTest, TestSrtpError) {
2390 Base::TestSrtpError(kAudioPts[0]); 2359 Base::TestSrtpError(kAudioPts[0]);
2391 } 2360 }
2392 2361
2393 TEST_F(VoiceChannelSingleThreadTest, TestOnReadyToSend) { 2362 TEST_F(VoiceChannelSingleThreadTest, TestOnTransportReadyToSend) {
2394 Base::TestOnReadyToSend(); 2363 Base::TestOnTransportReadyToSend();
2395 } 2364 }
2396 2365
2397 TEST_F(VoiceChannelSingleThreadTest, TestOnReadyToSendWithRtcpMux) { 2366 TEST_F(VoiceChannelSingleThreadTest, TestOnTransportReadyToSendWithRtcpMux) {
2398 Base::TestOnReadyToSendWithRtcpMux(); 2367 Base::TestOnTransportReadyToSendWithRtcpMux();
2399 } 2368 }
2400 2369
2401 // Test that we can scale the output volume properly for 1:1 calls. 2370 // Test that we can scale the output volume properly for 1:1 calls.
2402 TEST_F(VoiceChannelSingleThreadTest, TestScaleVolume1to1Call) { 2371 TEST_F(VoiceChannelSingleThreadTest, TestScaleVolume1to1Call) {
2403 CreateChannels(0, 0); 2372 CreateChannels(0, 0);
2404 EXPECT_TRUE(SendInitiate()); 2373 EXPECT_TRUE(SendInitiate());
2405 EXPECT_TRUE(SendAccept()); 2374 EXPECT_TRUE(SendAccept());
2406 double volume; 2375 double volume;
2407 2376
2408 // Default is (1.0). 2377 // Default is (1.0).
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
2704 } 2673 }
2705 2674
2706 TEST_F(VoiceChannelDoubleThreadTest, TestFlushRtcp) { 2675 TEST_F(VoiceChannelDoubleThreadTest, TestFlushRtcp) {
2707 Base::TestFlushRtcp(); 2676 Base::TestFlushRtcp();
2708 } 2677 }
2709 2678
2710 TEST_F(VoiceChannelDoubleThreadTest, TestSrtpError) { 2679 TEST_F(VoiceChannelDoubleThreadTest, TestSrtpError) {
2711 Base::TestSrtpError(kAudioPts[0]); 2680 Base::TestSrtpError(kAudioPts[0]);
2712 } 2681 }
2713 2682
2714 TEST_F(VoiceChannelDoubleThreadTest, TestOnReadyToSend) { 2683 TEST_F(VoiceChannelDoubleThreadTest, TestOnTransportReadyToSend) {
2715 Base::TestOnReadyToSend(); 2684 Base::TestOnTransportReadyToSend();
2716 } 2685 }
2717 2686
2718 TEST_F(VoiceChannelDoubleThreadTest, TestOnReadyToSendWithRtcpMux) { 2687 TEST_F(VoiceChannelDoubleThreadTest, TestOnTransportReadyToSendWithRtcpMux) {
2719 Base::TestOnReadyToSendWithRtcpMux(); 2688 Base::TestOnTransportReadyToSendWithRtcpMux();
2720 } 2689 }
2721 2690
2722 // Test that we can scale the output volume properly for 1:1 calls. 2691 // Test that we can scale the output volume properly for 1:1 calls.
2723 TEST_F(VoiceChannelDoubleThreadTest, TestScaleVolume1to1Call) { 2692 TEST_F(VoiceChannelDoubleThreadTest, TestScaleVolume1to1Call) {
2724 CreateChannels(0, 0); 2693 CreateChannels(0, 0);
2725 EXPECT_TRUE(SendInitiate()); 2694 EXPECT_TRUE(SendInitiate());
2726 EXPECT_TRUE(SendAccept()); 2695 EXPECT_TRUE(SendAccept());
2727 double volume; 2696 double volume;
2728 2697
2729 // Default is (1.0). 2698 // Default is (1.0).
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
3017 } 2986 }
3018 2987
3019 TEST_F(VideoChannelSingleThreadTest, SendBundleToBundleWithRtcpMuxSecure) { 2988 TEST_F(VideoChannelSingleThreadTest, SendBundleToBundleWithRtcpMuxSecure) {
3020 Base::SendBundleToBundle(kVideoPts, arraysize(kVideoPts), true, true); 2989 Base::SendBundleToBundle(kVideoPts, arraysize(kVideoPts), true, true);
3021 } 2990 }
3022 2991
3023 TEST_F(VideoChannelSingleThreadTest, TestSrtpError) { 2992 TEST_F(VideoChannelSingleThreadTest, TestSrtpError) {
3024 Base::TestSrtpError(kVideoPts[0]); 2993 Base::TestSrtpError(kVideoPts[0]);
3025 } 2994 }
3026 2995
3027 TEST_F(VideoChannelSingleThreadTest, TestOnReadyToSend) { 2996 TEST_F(VideoChannelSingleThreadTest, TestOnTransportReadyToSend) {
3028 Base::TestOnReadyToSend(); 2997 Base::TestOnTransportReadyToSend();
3029 } 2998 }
3030 2999
3031 TEST_F(VideoChannelSingleThreadTest, TestOnReadyToSendWithRtcpMux) { 3000 TEST_F(VideoChannelSingleThreadTest, TestOnTransportReadyToSendWithRtcpMux) {
3032 Base::TestOnReadyToSendWithRtcpMux(); 3001 Base::TestOnTransportReadyToSendWithRtcpMux();
3033 } 3002 }
3034 3003
3035 TEST_F(VideoChannelSingleThreadTest, DefaultMaxBitrateIsUnlimited) { 3004 TEST_F(VideoChannelSingleThreadTest, DefaultMaxBitrateIsUnlimited) {
3036 Base::DefaultMaxBitrateIsUnlimited(); 3005 Base::DefaultMaxBitrateIsUnlimited();
3037 } 3006 }
3038 3007
3039 TEST_F(VideoChannelSingleThreadTest, CanChangeMaxBitrate) { 3008 TEST_F(VideoChannelSingleThreadTest, CanChangeMaxBitrate) {
3040 Base::CanChangeMaxBitrate(); 3009 Base::CanChangeMaxBitrate();
3041 } 3010 }
3042 3011
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
3252 } 3221 }
3253 3222
3254 TEST_F(VideoChannelDoubleThreadTest, SendBundleToBundleWithRtcpMuxSecure) { 3223 TEST_F(VideoChannelDoubleThreadTest, SendBundleToBundleWithRtcpMuxSecure) {
3255 Base::SendBundleToBundle(kVideoPts, arraysize(kVideoPts), true, true); 3224 Base::SendBundleToBundle(kVideoPts, arraysize(kVideoPts), true, true);
3256 } 3225 }
3257 3226
3258 TEST_F(VideoChannelDoubleThreadTest, TestSrtpError) { 3227 TEST_F(VideoChannelDoubleThreadTest, TestSrtpError) {
3259 Base::TestSrtpError(kVideoPts[0]); 3228 Base::TestSrtpError(kVideoPts[0]);
3260 } 3229 }
3261 3230
3262 TEST_F(VideoChannelDoubleThreadTest, TestOnReadyToSend) { 3231 TEST_F(VideoChannelDoubleThreadTest, TestOnTransportReadyToSend) {
3263 Base::TestOnReadyToSend(); 3232 Base::TestOnTransportReadyToSend();
3264 } 3233 }
3265 3234
3266 TEST_F(VideoChannelDoubleThreadTest, TestOnReadyToSendWithRtcpMux) { 3235 TEST_F(VideoChannelDoubleThreadTest, TestOnTransportReadyToSendWithRtcpMux) {
3267 Base::TestOnReadyToSendWithRtcpMux(); 3236 Base::TestOnTransportReadyToSendWithRtcpMux();
3268 } 3237 }
3269 3238
3270 TEST_F(VideoChannelDoubleThreadTest, DefaultMaxBitrateIsUnlimited) { 3239 TEST_F(VideoChannelDoubleThreadTest, DefaultMaxBitrateIsUnlimited) {
3271 Base::DefaultMaxBitrateIsUnlimited(); 3240 Base::DefaultMaxBitrateIsUnlimited();
3272 } 3241 }
3273 3242
3274 TEST_F(VideoChannelDoubleThreadTest, CanChangeMaxBitrate) { 3243 TEST_F(VideoChannelDoubleThreadTest, CanChangeMaxBitrate) {
3275 Base::CanChangeMaxBitrate(); 3244 Base::CanChangeMaxBitrate();
3276 } 3245 }
3277 3246
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
3404 } 3373 }
3405 3374
3406 TEST_F(RtpDataChannelSingleThreadTest, TestCallSetup) { 3375 TEST_F(RtpDataChannelSingleThreadTest, TestCallSetup) {
3407 Base::TestCallSetup(); 3376 Base::TestCallSetup();
3408 } 3377 }
3409 3378
3410 TEST_F(RtpDataChannelSingleThreadTest, TestCallTeardownRtcpMux) { 3379 TEST_F(RtpDataChannelSingleThreadTest, TestCallTeardownRtcpMux) {
3411 Base::TestCallTeardownRtcpMux(); 3380 Base::TestCallTeardownRtcpMux();
3412 } 3381 }
3413 3382
3414 TEST_F(RtpDataChannelSingleThreadTest, TestOnReadyToSend) { 3383 TEST_F(RtpDataChannelSingleThreadTest, TestOnTransportReadyToSend) {
3415 Base::TestOnReadyToSend(); 3384 Base::TestOnTransportReadyToSend();
3416 } 3385 }
3417 3386
3418 TEST_F(RtpDataChannelSingleThreadTest, TestOnReadyToSendWithRtcpMux) { 3387 TEST_F(RtpDataChannelSingleThreadTest, TestOnTransportReadyToSendWithRtcpMux) {
3419 Base::TestOnReadyToSendWithRtcpMux(); 3388 Base::TestOnTransportReadyToSendWithRtcpMux();
3420 } 3389 }
3421 3390
3422 TEST_F(RtpDataChannelSingleThreadTest, SendRtpToRtp) { 3391 TEST_F(RtpDataChannelSingleThreadTest, SendRtpToRtp) {
3423 Base::SendRtpToRtp(); 3392 Base::SendRtpToRtp();
3424 } 3393 }
3425 3394
3426 TEST_F(RtpDataChannelSingleThreadTest, SendRtcpToRtcp) { 3395 TEST_F(RtpDataChannelSingleThreadTest, SendRtcpToRtcp) {
3427 Base::SendRtcpToRtcp(); 3396 Base::SendRtcpToRtcp();
3428 } 3397 }
3429 3398
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
3536 } 3505 }
3537 3506
3538 TEST_F(RtpDataChannelDoubleThreadTest, TestCallSetup) { 3507 TEST_F(RtpDataChannelDoubleThreadTest, TestCallSetup) {
3539 Base::TestCallSetup(); 3508 Base::TestCallSetup();
3540 } 3509 }
3541 3510
3542 TEST_F(RtpDataChannelDoubleThreadTest, TestCallTeardownRtcpMux) { 3511 TEST_F(RtpDataChannelDoubleThreadTest, TestCallTeardownRtcpMux) {
3543 Base::TestCallTeardownRtcpMux(); 3512 Base::TestCallTeardownRtcpMux();
3544 } 3513 }
3545 3514
3546 TEST_F(RtpDataChannelDoubleThreadTest, TestOnReadyToSend) { 3515 TEST_F(RtpDataChannelDoubleThreadTest, TestOnTransportReadyToSend) {
3547 Base::TestOnReadyToSend(); 3516 Base::TestOnTransportReadyToSend();
3548 } 3517 }
3549 3518
3550 TEST_F(RtpDataChannelDoubleThreadTest, TestOnReadyToSendWithRtcpMux) { 3519 TEST_F(RtpDataChannelDoubleThreadTest, TestOnTransportReadyToSendWithRtcpMux) {
3551 Base::TestOnReadyToSendWithRtcpMux(); 3520 Base::TestOnTransportReadyToSendWithRtcpMux();
3552 } 3521 }
3553 3522
3554 TEST_F(RtpDataChannelDoubleThreadTest, SendRtpToRtp) { 3523 TEST_F(RtpDataChannelDoubleThreadTest, SendRtpToRtp) {
3555 Base::SendRtpToRtp(); 3524 Base::SendRtpToRtp();
3556 } 3525 }
3557 3526
3558 TEST_F(RtpDataChannelDoubleThreadTest, SendRtcpToRtcp) { 3527 TEST_F(RtpDataChannelDoubleThreadTest, SendRtcpToRtcp) {
3559 Base::SendRtcpToRtcp(); 3528 Base::SendRtcpToRtcp();
3560 } 3529 }
3561 3530
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
3721 ASSERT_TRUE(voice_channel_.Init_w(nullptr, nullptr, &fake_rtp_dtls_transport_, 3690 ASSERT_TRUE(voice_channel_.Init_w(nullptr, nullptr, &fake_rtp_dtls_transport_,
3722 &fake_rtcp_dtls_transport_)); 3691 &fake_rtcp_dtls_transport_));
3723 EXPECT_DEATH(voice_channel_.SetTransports(&fake_rtp_dtls_transport_, 3692 EXPECT_DEATH(voice_channel_.SetTransports(&fake_rtp_dtls_transport_,
3724 &fake_rtp_dtls_transport_), 3693 &fake_rtp_dtls_transport_),
3725 ""); 3694 "");
3726 } 3695 }
3727 3696
3728 #endif // RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) 3697 #endif // RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID)
3729 3698
3730 // TODO(pthatcher): TestSetReceiver? 3699 // TODO(pthatcher): TestSetReceiver?
OLDNEW
« no previous file with comments | « webrtc/pc/channel.cc ('k') | webrtc/pc/rtptransport.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698