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

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

Issue 2812243005: Move ready to send logic from BaseChannel to RtpTransport. (Closed)
Patch Set: Move Connect, Disconnect, and more ready to send logic to RtpTransport. Update tests. Introduce rtc… Created 3 years, 8 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 1860 matching lines...) Expand 10 before | Expand all | Expand 10 after
1871 fake_rtp_dtls_transport2_.get(), 1871 fake_rtp_dtls_transport2_.get(),
1872 reinterpret_cast<const char*>(kBadPacket), sizeof(kBadPacket), 1872 reinterpret_cast<const char*>(kBadPacket), sizeof(kBadPacket),
1873 rtc::PacketTime(), 0); 1873 rtc::PacketTime(), 0);
1874 }); 1874 });
1875 EXPECT_EQ(cricket::SrtpFilter::ERROR_FAIL, error_handler.error_); 1875 EXPECT_EQ(cricket::SrtpFilter::ERROR_FAIL, error_handler.error_);
1876 EXPECT_EQ(cricket::SrtpFilter::UNPROTECT, error_handler.mode_); 1876 EXPECT_EQ(cricket::SrtpFilter::UNPROTECT, error_handler.mode_);
1877 // Terminate channels/threads before the fake clock is destroyed. 1877 // Terminate channels/threads before the fake clock is destroyed.
1878 EXPECT_TRUE(Terminate()); 1878 EXPECT_TRUE(Terminate());
1879 } 1879 }
1880 1880
1881 void TestOnReadyToSend() { 1881 void TestOnTransportReadyToSend() {
Taylor Brandstetter 2017/04/19 05:56:33 Why does this test need to change? It seems correc
Zach Stein 2017/04/20 19:59:10 This test called SetTransportChannelReadyToSend, w
Taylor Brandstetter 2017/04/21 09:12:38 Yeah, I see that now. So, with the TODO to not use
1882 CreateChannels(0, 0); 1882 CreateChannels(0, 0);
1883 cricket::FakeDtlsTransport* rtp = fake_rtp_dtls_transport1_.get();
1884 cricket::FakeDtlsTransport* rtcp = fake_rtcp_dtls_transport1_.get();
1885 EXPECT_FALSE(media_channel1_->ready_to_send()); 1883 EXPECT_FALSE(media_channel1_->ready_to_send());
1886 1884
1887 network_thread_->Invoke<void>(RTC_FROM_HERE, 1885 channel1_->OnTransportReadyToSend(true);
1888 [rtp] { rtp->SignalReadyToSend(rtp); });
1889 WaitForThreads();
1890 EXPECT_FALSE(media_channel1_->ready_to_send());
1891
1892 network_thread_->Invoke<void>(RTC_FROM_HERE,
1893 [rtcp] { rtcp->SignalReadyToSend(rtcp); });
1894 WaitForThreads();
1895 // MediaChannel::OnReadyToSend only be called when both rtp and rtcp
1896 // channel are ready to send.
1897 EXPECT_TRUE(media_channel1_->ready_to_send());
1898
1899 // rtp channel becomes not ready to send will be propagated to mediachannel
1900 network_thread_->Invoke<void>(RTC_FROM_HERE, [this] {
1901 channel1_->SetTransportChannelReadyToSend(false, false);
1902 });
1903 WaitForThreads();
1904 EXPECT_FALSE(media_channel1_->ready_to_send());
1905
1906 network_thread_->Invoke<void>(RTC_FROM_HERE, [this] {
1907 channel1_->SetTransportChannelReadyToSend(false, true);
1908 });
1909 WaitForThreads(); 1886 WaitForThreads();
1910 EXPECT_TRUE(media_channel1_->ready_to_send()); 1887 EXPECT_TRUE(media_channel1_->ready_to_send());
1911 1888
1912 // rtcp channel becomes not ready to send will be propagated to mediachannel 1889 channel1_->OnTransportReadyToSend(false);
1913 network_thread_->Invoke<void>(RTC_FROM_HERE, [this] {
1914 channel1_->SetTransportChannelReadyToSend(true, false);
1915 });
1916 WaitForThreads(); 1890 WaitForThreads();
1917 EXPECT_FALSE(media_channel1_->ready_to_send()); 1891 EXPECT_FALSE(media_channel1_->ready_to_send());
1918
1919 network_thread_->Invoke<void>(RTC_FROM_HERE, [this] {
1920 channel1_->SetTransportChannelReadyToSend(true, true);
1921 });
1922 WaitForThreads();
1923 EXPECT_TRUE(media_channel1_->ready_to_send());
1924 } 1892 }
1925 1893
1926 void TestOnReadyToSendWithRtcpMux() { 1894 void TestOnTransportReadyToSendWithRtcpMux() {
1927 CreateChannels(0, 0); 1895 CreateChannels(0, 0);
1928 typename T::Content content; 1896 typename T::Content content;
1929 CreateContent(0, kPcmuCodec, kH264Codec, &content); 1897 CreateContent(0, kPcmuCodec, kH264Codec, &content);
1930 // Both sides agree on mux. Should signal that RTCP mux is fully active. 1898 // Both sides agree on mux. Should signal that RTCP mux is fully active.
1931 content.set_rtcp_mux(true); 1899 content.set_rtcp_mux(true);
1932 EXPECT_TRUE(channel1_->SetLocalContent(&content, CA_OFFER, NULL)); 1900 EXPECT_TRUE(channel1_->SetLocalContent(&content, CA_OFFER, NULL));
1933 EXPECT_EQ(0, rtcp_mux_activated_callbacks1_); 1901 EXPECT_EQ(0, rtcp_mux_activated_callbacks1_);
1934 EXPECT_TRUE(channel1_->SetRemoteContent(&content, CA_ANSWER, NULL)); 1902 EXPECT_TRUE(channel1_->SetRemoteContent(&content, CA_ANSWER, NULL));
1935 EXPECT_EQ(1, rtcp_mux_activated_callbacks1_); 1903 EXPECT_EQ(1, rtcp_mux_activated_callbacks1_);
1936 cricket::FakeDtlsTransport* rtp = fake_rtp_dtls_transport1_.get(); 1904 cricket::FakeDtlsTransport* rtp = fake_rtp_dtls_transport1_.get();
1937 EXPECT_FALSE(media_channel1_->ready_to_send()); 1905 EXPECT_FALSE(media_channel1_->ready_to_send());
1938 // In the case of rtcp mux, the SignalReadyToSend() from rtp channel 1906 // In the case of rtcp mux, the SignalReadyToSend() from rtp channel
1939 // should trigger the MediaChannel's OnReadyToSend. 1907 // should trigger the MediaChannel's OnReadyToSend.
1940 network_thread_->Invoke<void>(RTC_FROM_HERE, 1908 network_thread_->Invoke<void>(RTC_FROM_HERE,
1941 [rtp] { rtp->SignalReadyToSend(rtp); }); 1909 [rtp] { rtp->SignalReadyToSend(rtp); });
1942 WaitForThreads(); 1910 WaitForThreads();
1943 EXPECT_TRUE(media_channel1_->ready_to_send()); 1911 EXPECT_TRUE(media_channel1_->ready_to_send());
1944 1912
1945 network_thread_->Invoke<void>(RTC_FROM_HERE, [this] { 1913 network_thread_->Invoke<void>(
1946 channel1_->SetTransportChannelReadyToSend(false, false); 1914 RTC_FROM_HERE, [this] { channel1_->OnTransportReadyToSend(false); });
Taylor Brandstetter 2017/04/19 05:56:33 Can you add a TODO to not call a "for testing" met
Zach Stein 2017/04/20 19:59:10 Done.
1947 });
1948 WaitForThreads(); 1915 WaitForThreads();
1949 EXPECT_FALSE(media_channel1_->ready_to_send()); 1916 EXPECT_FALSE(media_channel1_->ready_to_send());
1950 } 1917 }
1951 1918
1952 bool SetRemoteContentWithBitrateLimit(int remote_limit) { 1919 bool SetRemoteContentWithBitrateLimit(int remote_limit) {
1953 typename T::Content content; 1920 typename T::Content content;
1954 CreateContent(0, kPcmuCodec, kH264Codec, &content); 1921 CreateContent(0, kPcmuCodec, kH264Codec, &content);
1955 content.set_bandwidth(remote_limit); 1922 content.set_bandwidth(remote_limit);
1956 return channel1_->SetRemoteContent(&content, CA_OFFER, NULL); 1923 return channel1_->SetRemoteContent(&content, CA_OFFER, NULL);
1957 } 1924 }
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after
2432 } 2399 }
2433 2400
2434 TEST_F(VoiceChannelSingleThreadTest, TestFlushRtcp) { 2401 TEST_F(VoiceChannelSingleThreadTest, TestFlushRtcp) {
2435 Base::TestFlushRtcp(); 2402 Base::TestFlushRtcp();
2436 } 2403 }
2437 2404
2438 TEST_F(VoiceChannelSingleThreadTest, TestSrtpError) { 2405 TEST_F(VoiceChannelSingleThreadTest, TestSrtpError) {
2439 Base::TestSrtpError(kAudioPts[0]); 2406 Base::TestSrtpError(kAudioPts[0]);
2440 } 2407 }
2441 2408
2442 TEST_F(VoiceChannelSingleThreadTest, TestOnReadyToSend) { 2409 TEST_F(VoiceChannelSingleThreadTest, TestOnTransportReadyToSend) {
2443 Base::TestOnReadyToSend(); 2410 Base::TestOnTransportReadyToSend();
2444 } 2411 }
2445 2412
2446 TEST_F(VoiceChannelSingleThreadTest, TestOnReadyToSendWithRtcpMux) { 2413 TEST_F(VoiceChannelSingleThreadTest, TestOnTransportReadyToSendWithRtcpMux) {
2447 Base::TestOnReadyToSendWithRtcpMux(); 2414 Base::TestOnTransportReadyToSendWithRtcpMux();
2448 } 2415 }
2449 2416
2450 // Test that we can scale the output volume properly for 1:1 calls. 2417 // Test that we can scale the output volume properly for 1:1 calls.
2451 TEST_F(VoiceChannelSingleThreadTest, TestScaleVolume1to1Call) { 2418 TEST_F(VoiceChannelSingleThreadTest, TestScaleVolume1to1Call) {
2452 CreateChannels(0, 0); 2419 CreateChannels(0, 0);
2453 EXPECT_TRUE(SendInitiate()); 2420 EXPECT_TRUE(SendInitiate());
2454 EXPECT_TRUE(SendAccept()); 2421 EXPECT_TRUE(SendAccept());
2455 double volume; 2422 double volume;
2456 2423
2457 // Default is (1.0). 2424 // Default is (1.0).
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
2765 } 2732 }
2766 2733
2767 TEST_F(VoiceChannelDoubleThreadTest, TestFlushRtcp) { 2734 TEST_F(VoiceChannelDoubleThreadTest, TestFlushRtcp) {
2768 Base::TestFlushRtcp(); 2735 Base::TestFlushRtcp();
2769 } 2736 }
2770 2737
2771 TEST_F(VoiceChannelDoubleThreadTest, TestSrtpError) { 2738 TEST_F(VoiceChannelDoubleThreadTest, TestSrtpError) {
2772 Base::TestSrtpError(kAudioPts[0]); 2739 Base::TestSrtpError(kAudioPts[0]);
2773 } 2740 }
2774 2741
2775 TEST_F(VoiceChannelDoubleThreadTest, TestOnReadyToSend) { 2742 TEST_F(VoiceChannelDoubleThreadTest, TestOnTransportReadyToSend) {
2776 Base::TestOnReadyToSend(); 2743 Base::TestOnTransportReadyToSend();
2777 } 2744 }
2778 2745
2779 TEST_F(VoiceChannelDoubleThreadTest, TestOnReadyToSendWithRtcpMux) { 2746 TEST_F(VoiceChannelDoubleThreadTest, TestOnTransportReadyToSendWithRtcpMux) {
2780 Base::TestOnReadyToSendWithRtcpMux(); 2747 Base::TestOnTransportReadyToSendWithRtcpMux();
2781 } 2748 }
2782 2749
2783 // Test that we can scale the output volume properly for 1:1 calls. 2750 // Test that we can scale the output volume properly for 1:1 calls.
2784 TEST_F(VoiceChannelDoubleThreadTest, TestScaleVolume1to1Call) { 2751 TEST_F(VoiceChannelDoubleThreadTest, TestScaleVolume1to1Call) {
2785 CreateChannels(0, 0); 2752 CreateChannels(0, 0);
2786 EXPECT_TRUE(SendInitiate()); 2753 EXPECT_TRUE(SendInitiate());
2787 EXPECT_TRUE(SendAccept()); 2754 EXPECT_TRUE(SendAccept());
2788 double volume; 2755 double volume;
2789 2756
2790 // Default is (1.0). 2757 // Default is (1.0).
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
3078 } 3045 }
3079 3046
3080 TEST_F(VideoChannelSingleThreadTest, SendBundleToBundleWithRtcpMuxSecure) { 3047 TEST_F(VideoChannelSingleThreadTest, SendBundleToBundleWithRtcpMuxSecure) {
3081 Base::SendBundleToBundle(kVideoPts, arraysize(kVideoPts), true, true); 3048 Base::SendBundleToBundle(kVideoPts, arraysize(kVideoPts), true, true);
3082 } 3049 }
3083 3050
3084 TEST_F(VideoChannelSingleThreadTest, TestSrtpError) { 3051 TEST_F(VideoChannelSingleThreadTest, TestSrtpError) {
3085 Base::TestSrtpError(kVideoPts[0]); 3052 Base::TestSrtpError(kVideoPts[0]);
3086 } 3053 }
3087 3054
3088 TEST_F(VideoChannelSingleThreadTest, TestOnReadyToSend) { 3055 TEST_F(VideoChannelSingleThreadTest, TestOnTransportReadyToSend) {
3089 Base::TestOnReadyToSend(); 3056 Base::TestOnTransportReadyToSend();
3090 } 3057 }
3091 3058
3092 TEST_F(VideoChannelSingleThreadTest, TestOnReadyToSendWithRtcpMux) { 3059 TEST_F(VideoChannelSingleThreadTest, TestOnTransportReadyToSendWithRtcpMux) {
3093 Base::TestOnReadyToSendWithRtcpMux(); 3060 Base::TestOnTransportReadyToSendWithRtcpMux();
3094 } 3061 }
3095 3062
3096 TEST_F(VideoChannelSingleThreadTest, DefaultMaxBitrateIsUnlimited) { 3063 TEST_F(VideoChannelSingleThreadTest, DefaultMaxBitrateIsUnlimited) {
3097 Base::DefaultMaxBitrateIsUnlimited(); 3064 Base::DefaultMaxBitrateIsUnlimited();
3098 } 3065 }
3099 3066
3100 TEST_F(VideoChannelSingleThreadTest, CanChangeMaxBitrate) { 3067 TEST_F(VideoChannelSingleThreadTest, CanChangeMaxBitrate) {
3101 Base::CanChangeMaxBitrate(); 3068 Base::CanChangeMaxBitrate();
3102 } 3069 }
3103 3070
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
3313 } 3280 }
3314 3281
3315 TEST_F(VideoChannelDoubleThreadTest, SendBundleToBundleWithRtcpMuxSecure) { 3282 TEST_F(VideoChannelDoubleThreadTest, SendBundleToBundleWithRtcpMuxSecure) {
3316 Base::SendBundleToBundle(kVideoPts, arraysize(kVideoPts), true, true); 3283 Base::SendBundleToBundle(kVideoPts, arraysize(kVideoPts), true, true);
3317 } 3284 }
3318 3285
3319 TEST_F(VideoChannelDoubleThreadTest, TestSrtpError) { 3286 TEST_F(VideoChannelDoubleThreadTest, TestSrtpError) {
3320 Base::TestSrtpError(kVideoPts[0]); 3287 Base::TestSrtpError(kVideoPts[0]);
3321 } 3288 }
3322 3289
3323 TEST_F(VideoChannelDoubleThreadTest, TestOnReadyToSend) { 3290 TEST_F(VideoChannelDoubleThreadTest, TestOnTransportReadyToSend) {
3324 Base::TestOnReadyToSend(); 3291 Base::TestOnTransportReadyToSend();
3325 } 3292 }
3326 3293
3327 TEST_F(VideoChannelDoubleThreadTest, TestOnReadyToSendWithRtcpMux) { 3294 TEST_F(VideoChannelDoubleThreadTest, TestOnTransportReadyToSendWithRtcpMux) {
3328 Base::TestOnReadyToSendWithRtcpMux(); 3295 Base::TestOnTransportReadyToSendWithRtcpMux();
3329 } 3296 }
3330 3297
3331 TEST_F(VideoChannelDoubleThreadTest, DefaultMaxBitrateIsUnlimited) { 3298 TEST_F(VideoChannelDoubleThreadTest, DefaultMaxBitrateIsUnlimited) {
3332 Base::DefaultMaxBitrateIsUnlimited(); 3299 Base::DefaultMaxBitrateIsUnlimited();
3333 } 3300 }
3334 3301
3335 TEST_F(VideoChannelDoubleThreadTest, CanChangeMaxBitrate) { 3302 TEST_F(VideoChannelDoubleThreadTest, CanChangeMaxBitrate) {
3336 Base::CanChangeMaxBitrate(); 3303 Base::CanChangeMaxBitrate();
3337 } 3304 }
3338 3305
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
3468 } 3435 }
3469 3436
3470 TEST_F(RtpDataChannelSingleThreadTest, TestCallSetup) { 3437 TEST_F(RtpDataChannelSingleThreadTest, TestCallSetup) {
3471 Base::TestCallSetup(); 3438 Base::TestCallSetup();
3472 } 3439 }
3473 3440
3474 TEST_F(RtpDataChannelSingleThreadTest, TestCallTeardownRtcpMux) { 3441 TEST_F(RtpDataChannelSingleThreadTest, TestCallTeardownRtcpMux) {
3475 Base::TestCallTeardownRtcpMux(); 3442 Base::TestCallTeardownRtcpMux();
3476 } 3443 }
3477 3444
3478 TEST_F(RtpDataChannelSingleThreadTest, TestOnReadyToSend) { 3445 TEST_F(RtpDataChannelSingleThreadTest, TestOnTransportReadyToSend) {
3479 Base::TestOnReadyToSend(); 3446 Base::TestOnTransportReadyToSend();
3480 } 3447 }
3481 3448
3482 TEST_F(RtpDataChannelSingleThreadTest, TestOnReadyToSendWithRtcpMux) { 3449 TEST_F(RtpDataChannelSingleThreadTest, TestOnTransportReadyToSendWithRtcpMux) {
3483 Base::TestOnReadyToSendWithRtcpMux(); 3450 Base::TestOnTransportReadyToSendWithRtcpMux();
3484 } 3451 }
3485 3452
3486 TEST_F(RtpDataChannelSingleThreadTest, SendRtpToRtp) { 3453 TEST_F(RtpDataChannelSingleThreadTest, SendRtpToRtp) {
3487 Base::SendRtpToRtp(); 3454 Base::SendRtpToRtp();
3488 } 3455 }
3489 3456
3490 TEST_F(RtpDataChannelSingleThreadTest, SendRtcpToRtcp) { 3457 TEST_F(RtpDataChannelSingleThreadTest, SendRtcpToRtcp) {
3491 Base::SendRtcpToRtcp(); 3458 Base::SendRtcpToRtcp();
3492 } 3459 }
3493 3460
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
3600 } 3567 }
3601 3568
3602 TEST_F(RtpDataChannelDoubleThreadTest, TestCallSetup) { 3569 TEST_F(RtpDataChannelDoubleThreadTest, TestCallSetup) {
3603 Base::TestCallSetup(); 3570 Base::TestCallSetup();
3604 } 3571 }
3605 3572
3606 TEST_F(RtpDataChannelDoubleThreadTest, TestCallTeardownRtcpMux) { 3573 TEST_F(RtpDataChannelDoubleThreadTest, TestCallTeardownRtcpMux) {
3607 Base::TestCallTeardownRtcpMux(); 3574 Base::TestCallTeardownRtcpMux();
3608 } 3575 }
3609 3576
3610 TEST_F(RtpDataChannelDoubleThreadTest, TestOnReadyToSend) { 3577 TEST_F(RtpDataChannelDoubleThreadTest, TestOnTransportReadyToSend) {
3611 Base::TestOnReadyToSend(); 3578 Base::TestOnTransportReadyToSend();
3612 } 3579 }
3613 3580
3614 TEST_F(RtpDataChannelDoubleThreadTest, TestOnReadyToSendWithRtcpMux) { 3581 TEST_F(RtpDataChannelDoubleThreadTest, TestOnTransportReadyToSendWithRtcpMux) {
3615 Base::TestOnReadyToSendWithRtcpMux(); 3582 Base::TestOnTransportReadyToSendWithRtcpMux();
3616 } 3583 }
3617 3584
3618 TEST_F(RtpDataChannelDoubleThreadTest, SendRtpToRtp) { 3585 TEST_F(RtpDataChannelDoubleThreadTest, SendRtpToRtp) {
3619 Base::SendRtpToRtp(); 3586 Base::SendRtpToRtp();
3620 } 3587 }
3621 3588
3622 TEST_F(RtpDataChannelDoubleThreadTest, SendRtcpToRtcp) { 3589 TEST_F(RtpDataChannelDoubleThreadTest, SendRtcpToRtcp) {
3623 Base::SendRtcpToRtcp(); 3590 Base::SendRtcpToRtcp();
3624 } 3591 }
3625 3592
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
3785 ASSERT_TRUE(voice_channel_.Init_w(nullptr, nullptr, &fake_rtp_dtls_transport_, 3752 ASSERT_TRUE(voice_channel_.Init_w(nullptr, nullptr, &fake_rtp_dtls_transport_,
3786 &fake_rtcp_dtls_transport_)); 3753 &fake_rtcp_dtls_transport_));
3787 EXPECT_DEATH(voice_channel_.SetTransports(&fake_rtp_dtls_transport_, 3754 EXPECT_DEATH(voice_channel_.SetTransports(&fake_rtp_dtls_transport_,
3788 &fake_rtp_dtls_transport_), 3755 &fake_rtp_dtls_transport_),
3789 ""); 3756 "");
3790 } 3757 }
3791 3758
3792 #endif // RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) 3759 #endif // RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID)
3793 3760
3794 // TODO(pthatcher): TestSetReceiver? 3761 // TODO(pthatcher): TestSetReceiver?
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698