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 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 | 483 |
484 void OnMediaMonitor(typename T::Channel* channel, | 484 void OnMediaMonitor(typename T::Channel* channel, |
485 const typename T::MediaInfo& info) { | 485 const typename T::MediaInfo& info) { |
486 if (channel == channel1_.get()) { | 486 if (channel == channel1_.get()) { |
487 media_info_callbacks1_++; | 487 media_info_callbacks1_++; |
488 } else if (channel == channel2_.get()) { | 488 } else if (channel == channel2_.get()) { |
489 media_info_callbacks2_++; | 489 media_info_callbacks2_++; |
490 } | 490 } |
491 } | 491 } |
492 | 492 |
| 493 cricket::CandidatePairInterface* last_selected_candidate_pair() { |
| 494 return last_selected_candidate_pair_; |
| 495 } |
| 496 |
493 void AddLegacyStreamInContent(uint32_t ssrc, | 497 void AddLegacyStreamInContent(uint32_t ssrc, |
494 int flags, | 498 int flags, |
495 typename T::Content* content) { | 499 typename T::Content* content) { |
496 // Base implementation. | 500 // Base implementation. |
497 } | 501 } |
498 | 502 |
499 // Tests that can be used by derived classes. | 503 // Tests that can be used by derived classes. |
500 | 504 |
501 // Basic sanity check. | 505 // Basic sanity check. |
502 void TestInit() { | 506 void TestInit() { |
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
944 if (verify_playout_) { | 948 if (verify_playout_) { |
945 EXPECT_TRUE(media_channel1_->playout()); | 949 EXPECT_TRUE(media_channel1_->playout()); |
946 } | 950 } |
947 EXPECT_TRUE(media_channel1_->sending()); | 951 EXPECT_TRUE(media_channel1_->sending()); |
948 if (verify_playout_) { | 952 if (verify_playout_) { |
949 EXPECT_TRUE(media_channel2_->playout()); | 953 EXPECT_TRUE(media_channel2_->playout()); |
950 } | 954 } |
951 EXPECT_TRUE(media_channel2_->sending()); | 955 EXPECT_TRUE(media_channel2_->sending()); |
952 } | 956 } |
953 | 957 |
| 958 // Tests that when the transport channel signals a candidate pair change |
| 959 // event, the media channel will receive a call on the network route change. |
| 960 void TestNetworkRouteChanges() { |
| 961 CreateChannels(0, 0); |
| 962 |
| 963 cricket::TransportChannel* transport_channel1 = |
| 964 channel1_->transport_channel(); |
| 965 ASSERT_TRUE(transport_channel1 != nullptr); |
| 966 typename T::MediaChannel* media_channel1 = |
| 967 static_cast<typename T::MediaChannel*>(channel1_->media_channel()); |
| 968 ASSERT_TRUE(media_channel1 != nullptr); |
| 969 |
| 970 media_channel1_->set_num_network_route_changes(0); |
| 971 // The transport channel becomes disconnected. |
| 972 transport_channel1->SignalSelectedCandidatePairChanged(transport_channel1, |
| 973 nullptr); |
| 974 EXPECT_EQ(1, media_channel1_->num_network_route_changes()); |
| 975 EXPECT_FALSE(media_channel1->last_network_route().connected); |
| 976 |
| 977 media_channel1_->set_num_network_route_changes(0); |
| 978 // The transport channel becomes connected. |
| 979 rtc::SocketAddress local_address("192.168.1.1", 1000 /* port number */); |
| 980 rtc::SocketAddress remote_address("192.168.1.2", 2000 /* port number */); |
| 981 uint16_t local_net_id = 1; |
| 982 uint16_t remote_net_id = 2; |
| 983 rtc::scoped_ptr<cricket::CandidatePairInterface> candidate_pair( |
| 984 transport_controller1_.CreateFakeCandidatePair( |
| 985 local_address, local_net_id, remote_address, remote_net_id)); |
| 986 transport_channel1->SignalSelectedCandidatePairChanged( |
| 987 transport_channel1, candidate_pair.get()); |
| 988 EXPECT_EQ(1, media_channel1_->num_network_route_changes()); |
| 989 cricket::NetworkRoute expected_network_route(local_net_id, remote_net_id); |
| 990 EXPECT_EQ(expected_network_route, media_channel1->last_network_route()); |
| 991 } |
| 992 |
954 // Test setting up a call. | 993 // Test setting up a call. |
955 void TestCallSetup() { | 994 void TestCallSetup() { |
956 CreateChannels(0, 0); | 995 CreateChannels(0, 0); |
957 EXPECT_FALSE(channel1_->secure()); | 996 EXPECT_FALSE(channel1_->secure()); |
958 EXPECT_TRUE(SendInitiate()); | 997 EXPECT_TRUE(SendInitiate()); |
959 if (verify_playout_) { | 998 if (verify_playout_) { |
960 EXPECT_TRUE(media_channel1_->playout()); | 999 EXPECT_TRUE(media_channel1_->playout()); |
961 } | 1000 } |
962 EXPECT_FALSE(media_channel1_->sending()); | 1001 EXPECT_FALSE(media_channel1_->sending()); |
963 EXPECT_TRUE(SendAccept()); | 1002 EXPECT_TRUE(SendAccept()); |
(...skipping 900 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1864 std::unique_ptr<typename T::Channel> channel2_; | 1903 std::unique_ptr<typename T::Channel> channel2_; |
1865 typename T::Content local_media_content1_; | 1904 typename T::Content local_media_content1_; |
1866 typename T::Content local_media_content2_; | 1905 typename T::Content local_media_content2_; |
1867 typename T::Content remote_media_content1_; | 1906 typename T::Content remote_media_content1_; |
1868 typename T::Content remote_media_content2_; | 1907 typename T::Content remote_media_content2_; |
1869 // The RTP and RTCP packets to send in the tests. | 1908 // The RTP and RTCP packets to send in the tests. |
1870 std::string rtp_packet_; | 1909 std::string rtp_packet_; |
1871 std::string rtcp_packet_; | 1910 std::string rtcp_packet_; |
1872 int media_info_callbacks1_; | 1911 int media_info_callbacks1_; |
1873 int media_info_callbacks2_; | 1912 int media_info_callbacks2_; |
| 1913 cricket::CandidatePairInterface* last_selected_candidate_pair_; |
1874 }; | 1914 }; |
1875 | 1915 |
1876 template<> | 1916 template<> |
1877 void ChannelTest<VoiceTraits>::CreateContent( | 1917 void ChannelTest<VoiceTraits>::CreateContent( |
1878 int flags, | 1918 int flags, |
1879 const cricket::AudioCodec& audio_codec, | 1919 const cricket::AudioCodec& audio_codec, |
1880 const cricket::VideoCodec& video_codec, | 1920 const cricket::VideoCodec& video_codec, |
1881 cricket::AudioContentDescription* audio) { | 1921 cricket::AudioContentDescription* audio) { |
1882 audio->AddCodec(audio_codec); | 1922 audio->AddCodec(audio_codec); |
1883 audio->set_rtcp_mux((flags & RTCP_MUX) != 0); | 1923 audio->set_rtcp_mux((flags & RTCP_MUX) != 0); |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1989 VideoChannelTest() | 2029 VideoChannelTest() |
1990 : Base(false, | 2030 : Base(false, |
1991 kH264Packet, | 2031 kH264Packet, |
1992 sizeof(kH264Packet), | 2032 sizeof(kH264Packet), |
1993 kRtcpReport, | 2033 kRtcpReport, |
1994 sizeof(kRtcpReport)) {} | 2034 sizeof(kRtcpReport)) {} |
1995 }; | 2035 }; |
1996 | 2036 |
1997 | 2037 |
1998 // VoiceChannelTest | 2038 // VoiceChannelTest |
1999 | |
2000 TEST_F(VoiceChannelTest, TestInit) { | 2039 TEST_F(VoiceChannelTest, TestInit) { |
2001 Base::TestInit(); | 2040 Base::TestInit(); |
2002 EXPECT_FALSE(media_channel1_->IsStreamMuted(0)); | 2041 EXPECT_FALSE(media_channel1_->IsStreamMuted(0)); |
2003 EXPECT_TRUE(media_channel1_->dtmf_info_queue().empty()); | 2042 EXPECT_TRUE(media_channel1_->dtmf_info_queue().empty()); |
2004 } | 2043 } |
2005 | 2044 |
2006 TEST_F(VoiceChannelTest, TestSetContents) { | 2045 TEST_F(VoiceChannelTest, TestSetContents) { |
2007 Base::TestSetContents(); | 2046 Base::TestSetContents(); |
2008 } | 2047 } |
2009 | 2048 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2062 EXPECT_TRUE(channel1_->SetAudioSend(kSsrc1, false, nullptr, nullptr)); | 2101 EXPECT_TRUE(channel1_->SetAudioSend(kSsrc1, false, nullptr, nullptr)); |
2063 EXPECT_TRUE(media_channel1_->IsStreamMuted(kSsrc1)); | 2102 EXPECT_TRUE(media_channel1_->IsStreamMuted(kSsrc1)); |
2064 EXPECT_TRUE(channel1_->SetAudioSend(kSsrc1, true, nullptr, nullptr)); | 2103 EXPECT_TRUE(channel1_->SetAudioSend(kSsrc1, true, nullptr, nullptr)); |
2065 EXPECT_FALSE(media_channel1_->IsStreamMuted(kSsrc1)); | 2104 EXPECT_FALSE(media_channel1_->IsStreamMuted(kSsrc1)); |
2066 } | 2105 } |
2067 | 2106 |
2068 TEST_F(VoiceChannelTest, TestMediaContentDirection) { | 2107 TEST_F(VoiceChannelTest, TestMediaContentDirection) { |
2069 Base::TestMediaContentDirection(); | 2108 Base::TestMediaContentDirection(); |
2070 } | 2109 } |
2071 | 2110 |
| 2111 TEST_F(VoiceChannelTest, TestNetworkRouteChanges) { |
| 2112 Base::TestNetworkRouteChanges(); |
| 2113 } |
| 2114 |
2072 TEST_F(VoiceChannelTest, TestCallSetup) { | 2115 TEST_F(VoiceChannelTest, TestCallSetup) { |
2073 Base::TestCallSetup(); | 2116 Base::TestCallSetup(); |
2074 } | 2117 } |
2075 | 2118 |
2076 TEST_F(VoiceChannelTest, TestCallTeardownRtcpMux) { | 2119 TEST_F(VoiceChannelTest, TestCallTeardownRtcpMux) { |
2077 Base::TestCallTeardownRtcpMux(); | 2120 Base::TestCallTeardownRtcpMux(); |
2078 } | 2121 } |
2079 | 2122 |
2080 TEST_F(VoiceChannelTest, SendRtpToRtp) { | 2123 TEST_F(VoiceChannelTest, SendRtpToRtp) { |
2081 Base::SendRtpToRtp(); | 2124 Base::SendRtpToRtp(); |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2392 EXPECT_TRUE(channel1_->SetVideoSend(kSsrc1, false, nullptr)); | 2435 EXPECT_TRUE(channel1_->SetVideoSend(kSsrc1, false, nullptr)); |
2393 EXPECT_TRUE(media_channel1_->IsStreamMuted(kSsrc1)); | 2436 EXPECT_TRUE(media_channel1_->IsStreamMuted(kSsrc1)); |
2394 EXPECT_TRUE(channel1_->SetVideoSend(kSsrc1, true, nullptr)); | 2437 EXPECT_TRUE(channel1_->SetVideoSend(kSsrc1, true, nullptr)); |
2395 EXPECT_FALSE(media_channel1_->IsStreamMuted(kSsrc1)); | 2438 EXPECT_FALSE(media_channel1_->IsStreamMuted(kSsrc1)); |
2396 } | 2439 } |
2397 | 2440 |
2398 TEST_F(VideoChannelTest, TestMediaContentDirection) { | 2441 TEST_F(VideoChannelTest, TestMediaContentDirection) { |
2399 Base::TestMediaContentDirection(); | 2442 Base::TestMediaContentDirection(); |
2400 } | 2443 } |
2401 | 2444 |
| 2445 TEST_F(VideoChannelTest, TestNetworkRouteChanges) { |
| 2446 Base::TestNetworkRouteChanges(); |
| 2447 } |
| 2448 |
2402 TEST_F(VideoChannelTest, TestCallSetup) { | 2449 TEST_F(VideoChannelTest, TestCallSetup) { |
2403 Base::TestCallSetup(); | 2450 Base::TestCallSetup(); |
2404 } | 2451 } |
2405 | 2452 |
2406 TEST_F(VideoChannelTest, TestCallTeardownRtcpMux) { | 2453 TEST_F(VideoChannelTest, TestCallTeardownRtcpMux) { |
2407 Base::TestCallTeardownRtcpMux(); | 2454 Base::TestCallTeardownRtcpMux(); |
2408 } | 2455 } |
2409 | 2456 |
2410 TEST_F(VideoChannelTest, SendRtpToRtp) { | 2457 TEST_F(VideoChannelTest, SendRtpToRtp) { |
2411 Base::SendRtpToRtp(); | 2458 Base::SendRtpToRtp(); |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2771 }; | 2818 }; |
2772 rtc::CopyOnWriteBuffer payload(data, 3); | 2819 rtc::CopyOnWriteBuffer payload(data, 3); |
2773 cricket::SendDataResult result; | 2820 cricket::SendDataResult result; |
2774 ASSERT_TRUE(media_channel1_->SendData(params, payload, &result)); | 2821 ASSERT_TRUE(media_channel1_->SendData(params, payload, &result)); |
2775 EXPECT_EQ(params.ssrc, | 2822 EXPECT_EQ(params.ssrc, |
2776 media_channel1_->last_sent_data_params().ssrc); | 2823 media_channel1_->last_sent_data_params().ssrc); |
2777 EXPECT_EQ("foo", media_channel1_->last_sent_data()); | 2824 EXPECT_EQ("foo", media_channel1_->last_sent_data()); |
2778 } | 2825 } |
2779 | 2826 |
2780 // TODO(pthatcher): TestSetReceiver? | 2827 // TODO(pthatcher): TestSetReceiver? |
OLD | NEW |