OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2009 Google Inc. | 3 * Copyright 2009 Google Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
(...skipping 876 matching lines...) Loading... |
887 EXPECT_FALSE(media_channel2_->sending()); | 887 EXPECT_FALSE(media_channel2_->sending()); |
888 EXPECT_TRUE(channel2_->Enable(true)); | 888 EXPECT_TRUE(channel2_->Enable(true)); |
889 EXPECT_TRUE(media_channel2_->playout()); | 889 EXPECT_TRUE(media_channel2_->playout()); |
890 EXPECT_TRUE(media_channel2_->sending()); | 890 EXPECT_TRUE(media_channel2_->sending()); |
891 EXPECT_TRUE(channel1_->SetRemoteContent(&local_media_content2_, | 891 EXPECT_TRUE(channel1_->SetRemoteContent(&local_media_content2_, |
892 CA_ANSWER, NULL)); | 892 CA_ANSWER, NULL)); |
893 EXPECT_TRUE(media_channel1_->playout()); | 893 EXPECT_TRUE(media_channel1_->playout()); |
894 EXPECT_TRUE(media_channel1_->sending()); | 894 EXPECT_TRUE(media_channel1_->sending()); |
895 } | 895 } |
896 | 896 |
897 void TestMuteStream() { | |
898 CreateChannels(0, 0); | |
899 // Test that we can Mute the default channel even though the sending SSRC is | |
900 // unknown. | |
901 EXPECT_FALSE(media_channel1_->IsStreamMuted(0)); | |
902 EXPECT_TRUE(channel1_->MuteStream(0, true)); | |
903 EXPECT_TRUE(media_channel1_->IsStreamMuted(0)); | |
904 EXPECT_TRUE(channel1_->MuteStream(0, false)); | |
905 EXPECT_FALSE(media_channel1_->IsStreamMuted(0)); | |
906 | |
907 // Test that we can not mute an unknown SSRC. | |
908 EXPECT_FALSE(channel1_->MuteStream(kSsrc1, true)); | |
909 | |
910 SendInitiate(); | |
911 // After the local session description has been set, we can mute a stream | |
912 // with its SSRC. | |
913 EXPECT_TRUE(channel1_->MuteStream(kSsrc1, true)); | |
914 EXPECT_TRUE(media_channel1_->IsStreamMuted(kSsrc1)); | |
915 EXPECT_TRUE(channel1_->MuteStream(kSsrc1, false)); | |
916 EXPECT_FALSE(media_channel1_->IsStreamMuted(kSsrc1)); | |
917 } | |
918 | |
919 // Test that changing the MediaContentDirection in the local and remote | 897 // Test that changing the MediaContentDirection in the local and remote |
920 // session description start playout and sending at the right time. | 898 // session description start playout and sending at the right time. |
921 void TestMediaContentDirection() { | 899 void TestMediaContentDirection() { |
922 CreateChannels(0, 0); | 900 CreateChannels(0, 0); |
923 typename T::Content content1; | 901 typename T::Content content1; |
924 CreateContent(0, kPcmuCodec, kH264Codec, &content1); | 902 CreateContent(0, kPcmuCodec, kH264Codec, &content1); |
925 typename T::Content content2; | 903 typename T::Content content2; |
926 CreateContent(0, kPcmuCodec, kH264Codec, &content2); | 904 CreateContent(0, kPcmuCodec, kH264Codec, &content2); |
927 // Set |content2| to be InActive. | 905 // Set |content2| to be InActive. |
928 content2.set_direction(cricket::MD_INACTIVE); | 906 content2.set_direction(cricket::MD_INACTIVE); |
(...skipping 896 matching lines...) Loading... |
1825 | 1803 |
1826 template<> | 1804 template<> |
1827 void ChannelTest<VoiceTraits>::AddLegacyStreamInContent( | 1805 void ChannelTest<VoiceTraits>::AddLegacyStreamInContent( |
1828 uint32 ssrc, int flags, cricket::AudioContentDescription* audio) { | 1806 uint32 ssrc, int flags, cricket::AudioContentDescription* audio) { |
1829 audio->AddLegacyStream(ssrc); | 1807 audio->AddLegacyStream(ssrc); |
1830 } | 1808 } |
1831 | 1809 |
1832 class VoiceChannelTest | 1810 class VoiceChannelTest |
1833 : public ChannelTest<VoiceTraits> { | 1811 : public ChannelTest<VoiceTraits> { |
1834 public: | 1812 public: |
1835 typedef ChannelTest<VoiceTraits> | 1813 typedef ChannelTest<VoiceTraits> Base; |
1836 Base; | |
1837 VoiceChannelTest() : Base(kPcmuFrame, sizeof(kPcmuFrame), | 1814 VoiceChannelTest() : Base(kPcmuFrame, sizeof(kPcmuFrame), |
1838 kRtcpReport, sizeof(kRtcpReport)) { | 1815 kRtcpReport, sizeof(kRtcpReport)) {} |
1839 } | |
1840 | |
1841 void TestSetChannelOptions() { | |
1842 CreateChannels(0, 0); | |
1843 | |
1844 cricket::AudioOptions options1; | |
1845 options1.echo_cancellation.Set(false); | |
1846 cricket::AudioOptions options2; | |
1847 options2.echo_cancellation.Set(true); | |
1848 | |
1849 channel1_->SetChannelOptions(options1); | |
1850 channel2_->SetChannelOptions(options1); | |
1851 EXPECT_EQ(options1, media_channel1_->options()); | |
1852 EXPECT_EQ(options1, media_channel2_->options()); | |
1853 | |
1854 channel1_->SetChannelOptions(options2); | |
1855 channel2_->SetChannelOptions(options2); | |
1856 EXPECT_EQ(options2, media_channel1_->options()); | |
1857 EXPECT_EQ(options2, media_channel2_->options()); | |
1858 } | |
1859 }; | 1816 }; |
1860 | 1817 |
1861 // override to add NULL parameter | 1818 // override to add NULL parameter |
1862 template<> | 1819 template<> |
1863 cricket::VideoChannel* ChannelTest<VideoTraits>::CreateChannel( | 1820 cricket::VideoChannel* ChannelTest<VideoTraits>::CreateChannel( |
1864 rtc::Thread* thread, cricket::MediaEngineInterface* engine, | 1821 rtc::Thread* thread, cricket::MediaEngineInterface* engine, |
1865 cricket::FakeVideoMediaChannel* ch, cricket::BaseSession* session, | 1822 cricket::FakeVideoMediaChannel* ch, cricket::BaseSession* session, |
1866 bool rtcp) { | 1823 bool rtcp) { |
1867 cricket::VideoChannel* channel = new cricket::VideoChannel( | 1824 cricket::VideoChannel* channel = new cricket::VideoChannel( |
1868 thread, ch, session, cricket::CN_VIDEO, rtcp); | 1825 thread, ch, session, cricket::CN_VIDEO, rtcp); |
(...skipping 41 matching lines...) Loading... |
1910 | 1867 |
1911 template<> | 1868 template<> |
1912 void ChannelTest<VideoTraits>::AddLegacyStreamInContent( | 1869 void ChannelTest<VideoTraits>::AddLegacyStreamInContent( |
1913 uint32 ssrc, int flags, cricket::VideoContentDescription* video) { | 1870 uint32 ssrc, int flags, cricket::VideoContentDescription* video) { |
1914 video->AddLegacyStream(ssrc); | 1871 video->AddLegacyStream(ssrc); |
1915 } | 1872 } |
1916 | 1873 |
1917 class VideoChannelTest | 1874 class VideoChannelTest |
1918 : public ChannelTest<VideoTraits> { | 1875 : public ChannelTest<VideoTraits> { |
1919 public: | 1876 public: |
1920 typedef ChannelTest<VideoTraits> | 1877 typedef ChannelTest<VideoTraits> Base; |
1921 Base; | |
1922 VideoChannelTest() : Base(kH264Packet, sizeof(kH264Packet), | 1878 VideoChannelTest() : Base(kH264Packet, sizeof(kH264Packet), |
1923 kRtcpReport, sizeof(kRtcpReport)) { | 1879 kRtcpReport, sizeof(kRtcpReport)) {} |
1924 } | |
1925 | |
1926 void TestSetChannelOptions() { | |
1927 CreateChannels(0, 0); | |
1928 | |
1929 cricket::VideoOptions o1; | |
1930 o1.video_noise_reduction.Set(true); | |
1931 | |
1932 channel1_->SetChannelOptions(o1); | |
1933 channel2_->SetChannelOptions(o1); | |
1934 EXPECT_EQ(o1, media_channel1_->options()); | |
1935 EXPECT_EQ(o1, media_channel2_->options()); | |
1936 | |
1937 o1.video_start_bitrate.Set(123); | |
1938 channel1_->SetChannelOptions(o1); | |
1939 channel2_->SetChannelOptions(o1); | |
1940 EXPECT_EQ(o1, media_channel1_->options()); | |
1941 EXPECT_EQ(o1, media_channel2_->options()); | |
1942 } | |
1943 }; | 1880 }; |
1944 | 1881 |
1945 | 1882 |
1946 // VoiceChannelTest | 1883 // VoiceChannelTest |
1947 | 1884 |
1948 TEST_F(VoiceChannelTest, TestInit) { | 1885 TEST_F(VoiceChannelTest, TestInit) { |
1949 Base::TestInit(); | 1886 Base::TestInit(); |
1950 EXPECT_FALSE(media_channel1_->IsStreamMuted(0)); | 1887 EXPECT_FALSE(media_channel1_->IsStreamMuted(0)); |
1951 EXPECT_TRUE(media_channel1_->dtmf_info_queue().empty()); | 1888 EXPECT_TRUE(media_channel1_->dtmf_info_queue().empty()); |
1952 } | 1889 } |
(...skipping 32 matching lines...) Loading... |
1985 | 1922 |
1986 TEST_F(VoiceChannelTest, TestChangeStreamParamsInContent) { | 1923 TEST_F(VoiceChannelTest, TestChangeStreamParamsInContent) { |
1987 Base::TestChangeStreamParamsInContent(); | 1924 Base::TestChangeStreamParamsInContent(); |
1988 } | 1925 } |
1989 | 1926 |
1990 TEST_F(VoiceChannelTest, TestPlayoutAndSendingStates) { | 1927 TEST_F(VoiceChannelTest, TestPlayoutAndSendingStates) { |
1991 Base::TestPlayoutAndSendingStates(); | 1928 Base::TestPlayoutAndSendingStates(); |
1992 } | 1929 } |
1993 | 1930 |
1994 TEST_F(VoiceChannelTest, TestMuteStream) { | 1931 TEST_F(VoiceChannelTest, TestMuteStream) { |
1995 Base::TestMuteStream(); | 1932 CreateChannels(0, 0); |
| 1933 // Test that we can Mute the default channel even though the sending SSRC |
| 1934 // is unknown. |
| 1935 EXPECT_FALSE(media_channel1_->IsStreamMuted(0)); |
| 1936 EXPECT_TRUE(channel1_->SetAudioSend(0, true, nullptr, nullptr)); |
| 1937 EXPECT_TRUE(media_channel1_->IsStreamMuted(0)); |
| 1938 EXPECT_TRUE(channel1_->SetAudioSend(0, false, nullptr, nullptr)); |
| 1939 EXPECT_FALSE(media_channel1_->IsStreamMuted(0)); |
| 1940 |
| 1941 // Test that we can not mute an unknown SSRC. |
| 1942 EXPECT_FALSE(channel1_->SetAudioSend(kSsrc1, true, nullptr, nullptr)); |
| 1943 |
| 1944 SendInitiate(); |
| 1945 // After the local session description has been set, we can mute a stream |
| 1946 // with its SSRC. |
| 1947 EXPECT_TRUE(channel1_->SetAudioSend(kSsrc1, true, nullptr, nullptr)); |
| 1948 EXPECT_TRUE(media_channel1_->IsStreamMuted(kSsrc1)); |
| 1949 EXPECT_TRUE(channel1_->SetAudioSend(kSsrc1, false, nullptr, nullptr)); |
| 1950 EXPECT_FALSE(media_channel1_->IsStreamMuted(kSsrc1)); |
1996 } | 1951 } |
1997 | 1952 |
1998 TEST_F(VoiceChannelTest, TestMediaContentDirection) { | 1953 TEST_F(VoiceChannelTest, TestMediaContentDirection) { |
1999 Base::TestMediaContentDirection(); | 1954 Base::TestMediaContentDirection(); |
2000 } | 1955 } |
2001 | 1956 |
2002 TEST_F(VoiceChannelTest, TestCallSetup) { | 1957 TEST_F(VoiceChannelTest, TestCallSetup) { |
2003 Base::TestCallSetup(); | 1958 Base::TestCallSetup(); |
2004 } | 1959 } |
2005 | 1960 |
(...skipping 93 matching lines...) Loading... |
2099 } | 2054 } |
2100 | 2055 |
2101 TEST_F(VoiceChannelTest, SendWithWritabilityLoss) { | 2056 TEST_F(VoiceChannelTest, SendWithWritabilityLoss) { |
2102 Base::SendWithWritabilityLoss(); | 2057 Base::SendWithWritabilityLoss(); |
2103 } | 2058 } |
2104 | 2059 |
2105 TEST_F(VoiceChannelTest, TestMediaMonitor) { | 2060 TEST_F(VoiceChannelTest, TestMediaMonitor) { |
2106 Base::TestMediaMonitor(); | 2061 Base::TestMediaMonitor(); |
2107 } | 2062 } |
2108 | 2063 |
2109 // Test that MuteStream properly forwards to the media channel and does | |
2110 // not signal. | |
2111 TEST_F(VoiceChannelTest, TestVoiceSpecificMuteStream) { | |
2112 CreateChannels(0, 0); | |
2113 EXPECT_FALSE(media_channel1_->IsStreamMuted(0)); | |
2114 EXPECT_TRUE(channel1_->MuteStream(0, true)); | |
2115 EXPECT_TRUE(media_channel1_->IsStreamMuted(0)); | |
2116 EXPECT_TRUE(channel1_->MuteStream(0, false)); | |
2117 EXPECT_FALSE(media_channel1_->IsStreamMuted(0)); | |
2118 } | |
2119 | |
2120 // Test that PressDTMF properly forwards to the media channel. | 2064 // Test that PressDTMF properly forwards to the media channel. |
2121 TEST_F(VoiceChannelTest, TestDtmf) { | 2065 TEST_F(VoiceChannelTest, TestDtmf) { |
2122 CreateChannels(0, 0); | 2066 CreateChannels(0, 0); |
2123 EXPECT_TRUE(SendInitiate()); | 2067 EXPECT_TRUE(SendInitiate()); |
2124 EXPECT_TRUE(SendAccept()); | 2068 EXPECT_TRUE(SendAccept()); |
2125 EXPECT_EQ(0U, media_channel1_->dtmf_info_queue().size()); | 2069 EXPECT_EQ(0U, media_channel1_->dtmf_info_queue().size()); |
2126 | 2070 |
2127 EXPECT_TRUE(channel1_->PressDTMF(1, true)); | 2071 EXPECT_TRUE(channel1_->PressDTMF(1, true)); |
2128 EXPECT_TRUE(channel1_->PressDTMF(8, false)); | 2072 EXPECT_TRUE(channel1_->PressDTMF(8, false)); |
2129 | 2073 |
(...skipping 177 matching lines...) Loading... |
2307 TEST_F(VoiceChannelTest, SendBundleToBundleWithRtcpMux) { | 2251 TEST_F(VoiceChannelTest, SendBundleToBundleWithRtcpMux) { |
2308 Base::SendBundleToBundle( | 2252 Base::SendBundleToBundle( |
2309 kAudioPts, ARRAY_SIZE(kAudioPts), true, false); | 2253 kAudioPts, ARRAY_SIZE(kAudioPts), true, false); |
2310 } | 2254 } |
2311 | 2255 |
2312 TEST_F(VoiceChannelTest, SendBundleToBundleWithRtcpMuxSecure) { | 2256 TEST_F(VoiceChannelTest, SendBundleToBundleWithRtcpMuxSecure) { |
2313 Base::SendBundleToBundle( | 2257 Base::SendBundleToBundle( |
2314 kAudioPts, ARRAY_SIZE(kAudioPts), true, true); | 2258 kAudioPts, ARRAY_SIZE(kAudioPts), true, true); |
2315 } | 2259 } |
2316 | 2260 |
2317 TEST_F(VoiceChannelTest, TestSetChannelOptions) { | |
2318 TestSetChannelOptions(); | |
2319 } | |
2320 | |
2321 // VideoChannelTest | 2261 // VideoChannelTest |
2322 TEST_F(VideoChannelTest, TestInit) { | 2262 TEST_F(VideoChannelTest, TestInit) { |
2323 Base::TestInit(); | 2263 Base::TestInit(); |
2324 } | 2264 } |
2325 | 2265 |
2326 TEST_F(VideoChannelTest, TestSetContents) { | 2266 TEST_F(VideoChannelTest, TestSetContents) { |
2327 Base::TestSetContents(); | 2267 Base::TestSetContents(); |
2328 } | 2268 } |
2329 | 2269 |
2330 TEST_F(VideoChannelTest, TestSetContentsNullOffer) { | 2270 TEST_F(VideoChannelTest, TestSetContentsNullOffer) { |
(...skipping 56 matching lines...) Loading... |
2387 | 2327 |
2388 TEST_F(VideoChannelTest, TestChangeStreamParamsInContent) { | 2328 TEST_F(VideoChannelTest, TestChangeStreamParamsInContent) { |
2389 Base::TestChangeStreamParamsInContent(); | 2329 Base::TestChangeStreamParamsInContent(); |
2390 } | 2330 } |
2391 | 2331 |
2392 TEST_F(VideoChannelTest, TestPlayoutAndSendingStates) { | 2332 TEST_F(VideoChannelTest, TestPlayoutAndSendingStates) { |
2393 Base::TestPlayoutAndSendingStates(); | 2333 Base::TestPlayoutAndSendingStates(); |
2394 } | 2334 } |
2395 | 2335 |
2396 TEST_F(VideoChannelTest, TestMuteStream) { | 2336 TEST_F(VideoChannelTest, TestMuteStream) { |
2397 Base::TestMuteStream(); | 2337 CreateChannels(0, 0); |
| 2338 // Test that we can Mute the default channel even though the sending SSRC |
| 2339 // is unknown. |
| 2340 EXPECT_FALSE(media_channel1_->IsStreamMuted(0)); |
| 2341 EXPECT_TRUE(channel1_->SetVideoSend(0, true, nullptr)); |
| 2342 EXPECT_TRUE(media_channel1_->IsStreamMuted(0)); |
| 2343 EXPECT_TRUE(channel1_->SetVideoSend(0, false, nullptr)); |
| 2344 EXPECT_FALSE(media_channel1_->IsStreamMuted(0)); |
| 2345 // Test that we can not mute an unknown SSRC. |
| 2346 EXPECT_FALSE(channel1_->SetVideoSend(kSsrc1, true, nullptr)); |
| 2347 SendInitiate(); |
| 2348 // After the local session description has been set, we can mute a stream |
| 2349 // with its SSRC. |
| 2350 EXPECT_TRUE(channel1_->SetVideoSend(kSsrc1, true, nullptr)); |
| 2351 EXPECT_TRUE(media_channel1_->IsStreamMuted(kSsrc1)); |
| 2352 EXPECT_TRUE(channel1_->SetVideoSend(kSsrc1, false, nullptr)); |
| 2353 EXPECT_FALSE(media_channel1_->IsStreamMuted(kSsrc1)); |
2398 } | 2354 } |
2399 | 2355 |
2400 TEST_F(VideoChannelTest, TestMediaContentDirection) { | 2356 TEST_F(VideoChannelTest, TestMediaContentDirection) { |
2401 Base::TestMediaContentDirection(); | 2357 Base::TestMediaContentDirection(); |
2402 } | 2358 } |
2403 | 2359 |
2404 TEST_F(VideoChannelTest, TestCallSetup) { | 2360 TEST_F(VideoChannelTest, TestCallSetup) { |
2405 Base::TestCallSetup(); | 2361 Base::TestCallSetup(); |
2406 } | 2362 } |
2407 | 2363 |
(...skipping 209 matching lines...) Loading... |
2617 EXPECT_EQ(cricket::VideoFormat::FpsToInterval(30), send_format.interval); | 2573 EXPECT_EQ(cricket::VideoFormat::FpsToInterval(30), send_format.interval); |
2618 | 2574 |
2619 // stream1: 0x0x0; stream2: 0x0x0 | 2575 // stream1: 0x0x0; stream2: 0x0x0 |
2620 request.static_video_views.clear(); | 2576 request.static_video_views.clear(); |
2621 EXPECT_TRUE(channel1_->ApplyViewRequest(request)); | 2577 EXPECT_TRUE(channel1_->ApplyViewRequest(request)); |
2622 EXPECT_TRUE(media_channel1_->GetSendStreamFormat(kSsrc1, &send_format)); | 2578 EXPECT_TRUE(media_channel1_->GetSendStreamFormat(kSsrc1, &send_format)); |
2623 EXPECT_EQ(0, send_format.width); | 2579 EXPECT_EQ(0, send_format.width); |
2624 EXPECT_EQ(0, send_format.height); | 2580 EXPECT_EQ(0, send_format.height); |
2625 } | 2581 } |
2626 | 2582 |
2627 TEST_F(VideoChannelTest, TestSetChannelOptions) { | |
2628 TestSetChannelOptions(); | |
2629 } | |
2630 | |
2631 | 2583 |
2632 // DataChannelTest | 2584 // DataChannelTest |
2633 | 2585 |
2634 class DataChannelTest | 2586 class DataChannelTest |
2635 : public ChannelTest<DataTraits> { | 2587 : public ChannelTest<DataTraits> { |
2636 public: | 2588 public: |
2637 typedef ChannelTest<DataTraits> | 2589 typedef ChannelTest<DataTraits> |
2638 Base; | 2590 Base; |
2639 DataChannelTest() : Base(kDataPacket, sizeof(kDataPacket), | 2591 DataChannelTest() : Base(kDataPacket, sizeof(kDataPacket), |
2640 kRtcpReport, sizeof(kRtcpReport)) { | 2592 kRtcpReport, sizeof(kRtcpReport)) { |
(...skipping 186 matching lines...) Loading... |
2827 }; | 2779 }; |
2828 rtc::Buffer payload(data, 3); | 2780 rtc::Buffer payload(data, 3); |
2829 cricket::SendDataResult result; | 2781 cricket::SendDataResult result; |
2830 ASSERT_TRUE(media_channel1_->SendData(params, payload, &result)); | 2782 ASSERT_TRUE(media_channel1_->SendData(params, payload, &result)); |
2831 EXPECT_EQ(params.ssrc, | 2783 EXPECT_EQ(params.ssrc, |
2832 media_channel1_->last_sent_data_params().ssrc); | 2784 media_channel1_->last_sent_data_params().ssrc); |
2833 EXPECT_EQ("foo", media_channel1_->last_sent_data()); | 2785 EXPECT_EQ("foo", media_channel1_->last_sent_data()); |
2834 } | 2786 } |
2835 | 2787 |
2836 // TODO(pthatcher): TestSetReceiver? | 2788 // TODO(pthatcher): TestSetReceiver? |
OLD | NEW |