OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2008 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2008 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 |
11 #include "webrtc/api/fakemediacontroller.h" | 11 #include "webrtc/api/fakemediacontroller.h" |
12 #include "webrtc/base/gunit.h" | 12 #include "webrtc/base/gunit.h" |
13 #include "webrtc/base/logging.h" | 13 #include "webrtc/base/logging.h" |
14 #include "webrtc/base/thread.h" | 14 #include "webrtc/base/thread.h" |
15 #include "webrtc/logging/rtc_event_log/rtc_event_log.h" | 15 #include "webrtc/logging/rtc_event_log/rtc_event_log.h" |
16 #include "webrtc/media/base/fakemediaengine.h" | 16 #include "webrtc/media/base/fakemediaengine.h" |
17 #include "webrtc/media/base/fakevideocapturer.h" | 17 #include "webrtc/media/base/fakevideocapturer.h" |
18 #include "webrtc/media/base/testutils.h" | 18 #include "webrtc/media/base/testutils.h" |
19 #include "webrtc/media/engine/fakewebrtccall.h" | 19 #include "webrtc/media/engine/fakewebrtccall.h" |
20 #include "webrtc/p2p/base/faketransportcontroller.h" | 20 #include "webrtc/p2p/base/faketransportcontroller.h" |
21 #include "webrtc/pc/channelmanager.h" | 21 #include "webrtc/pc/channelmanager.h" |
22 | 22 |
23 namespace cricket { | 23 namespace cricket { |
| 24 const bool kDefaultRtcpEnabled = false; |
| 25 const bool kDefaultSrtpRequired = true; |
| 26 } |
| 27 |
| 28 namespace cricket { |
24 | 29 |
25 static const AudioCodec kAudioCodecs[] = { | 30 static const AudioCodec kAudioCodecs[] = { |
26 AudioCodec(97, "voice", 1, 2, 3), AudioCodec(111, "OPUS", 48000, 32000, 2), | 31 AudioCodec(97, "voice", 1, 2, 3), AudioCodec(111, "OPUS", 48000, 32000, 2), |
27 }; | 32 }; |
28 | 33 |
29 static const VideoCodec kVideoCodecs[] = { | 34 static const VideoCodec kVideoCodecs[] = { |
30 VideoCodec(99, "H264"), VideoCodec(100, "VP8"), VideoCodec(96, "rtx"), | 35 VideoCodec(99, "H264"), VideoCodec(100, "VP8"), VideoCodec(96, "rtx"), |
31 }; | 36 }; |
32 | 37 |
33 class ChannelManagerTest : public testing::Test { | 38 class ChannelManagerTest : public testing::Test { |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 EXPECT_FALSE(cm_->set_network_thread(rtc::Thread::Current())); | 96 EXPECT_FALSE(cm_->set_network_thread(rtc::Thread::Current())); |
92 EXPECT_FALSE(cm_->set_worker_thread(rtc::Thread::Current())); | 97 EXPECT_FALSE(cm_->set_worker_thread(rtc::Thread::Current())); |
93 cm_->Terminate(); | 98 cm_->Terminate(); |
94 EXPECT_FALSE(cm_->initialized()); | 99 EXPECT_FALSE(cm_->initialized()); |
95 } | 100 } |
96 | 101 |
97 // Test that we can create and destroy a voice and video channel. | 102 // Test that we can create and destroy a voice and video channel. |
98 TEST_F(ChannelManagerTest, CreateDestroyChannels) { | 103 TEST_F(ChannelManagerTest, CreateDestroyChannels) { |
99 EXPECT_TRUE(cm_->Init()); | 104 EXPECT_TRUE(cm_->Init()); |
100 cricket::VoiceChannel* voice_channel = cm_->CreateVoiceChannel( | 105 cricket::VoiceChannel* voice_channel = cm_->CreateVoiceChannel( |
101 &fake_mc_, transport_controller_, cricket::CN_AUDIO, nullptr, false, | 106 &fake_mc_, transport_controller_, cricket::CN_AUDIO, nullptr, |
102 AudioOptions()); | 107 kDefaultRtcpEnabled, kDefaultSrtpRequired, AudioOptions()); |
103 EXPECT_TRUE(voice_channel != nullptr); | 108 EXPECT_TRUE(voice_channel != nullptr); |
104 cricket::VideoChannel* video_channel = cm_->CreateVideoChannel( | 109 cricket::VideoChannel* video_channel = cm_->CreateVideoChannel( |
105 &fake_mc_, transport_controller_, cricket::CN_VIDEO, nullptr, false, | 110 &fake_mc_, transport_controller_, cricket::CN_VIDEO, nullptr, |
106 VideoOptions()); | 111 kDefaultRtcpEnabled, kDefaultSrtpRequired, VideoOptions()); |
107 EXPECT_TRUE(video_channel != nullptr); | 112 EXPECT_TRUE(video_channel != nullptr); |
108 cricket::DataChannel* data_channel = | 113 cricket::DataChannel* data_channel = cm_->CreateDataChannel( |
109 cm_->CreateDataChannel(transport_controller_, cricket::CN_DATA, nullptr, | 114 &fake_mc_, transport_controller_, cricket::CN_DATA, nullptr, |
110 false, cricket::DCT_RTP); | 115 kDefaultRtcpEnabled, kDefaultSrtpRequired, cricket::DCT_RTP); |
111 EXPECT_TRUE(data_channel != nullptr); | 116 EXPECT_TRUE(data_channel != nullptr); |
112 cm_->DestroyVideoChannel(video_channel); | 117 cm_->DestroyVideoChannel(video_channel); |
113 cm_->DestroyVoiceChannel(voice_channel); | 118 cm_->DestroyVoiceChannel(voice_channel); |
114 cm_->DestroyDataChannel(data_channel); | 119 cm_->DestroyDataChannel(data_channel); |
115 cm_->Terminate(); | 120 cm_->Terminate(); |
116 } | 121 } |
117 | 122 |
118 // Test that we can create and destroy a voice and video channel with a worker. | 123 // Test that we can create and destroy a voice and video channel with a worker. |
119 TEST_F(ChannelManagerTest, CreateDestroyChannelsOnThread) { | 124 TEST_F(ChannelManagerTest, CreateDestroyChannelsOnThread) { |
120 network_.Start(); | 125 network_.Start(); |
121 worker_.Start(); | 126 worker_.Start(); |
122 EXPECT_TRUE(cm_->set_worker_thread(&worker_)); | 127 EXPECT_TRUE(cm_->set_worker_thread(&worker_)); |
123 EXPECT_TRUE(cm_->set_network_thread(&network_)); | 128 EXPECT_TRUE(cm_->set_network_thread(&network_)); |
124 EXPECT_TRUE(cm_->Init()); | 129 EXPECT_TRUE(cm_->Init()); |
125 delete transport_controller_; | 130 delete transport_controller_; |
126 transport_controller_ = | 131 transport_controller_ = |
127 new cricket::FakeTransportController(&network_, ICEROLE_CONTROLLING); | 132 new cricket::FakeTransportController(&network_, ICEROLE_CONTROLLING); |
128 cricket::VoiceChannel* voice_channel = cm_->CreateVoiceChannel( | 133 cricket::VoiceChannel* voice_channel = cm_->CreateVoiceChannel( |
129 &fake_mc_, transport_controller_, cricket::CN_AUDIO, nullptr, false, | 134 &fake_mc_, transport_controller_, cricket::CN_AUDIO, nullptr, |
130 AudioOptions()); | 135 kDefaultRtcpEnabled, kDefaultSrtpRequired, AudioOptions()); |
131 EXPECT_TRUE(voice_channel != nullptr); | 136 EXPECT_TRUE(voice_channel != nullptr); |
132 cricket::VideoChannel* video_channel = cm_->CreateVideoChannel( | 137 cricket::VideoChannel* video_channel = cm_->CreateVideoChannel( |
133 &fake_mc_, transport_controller_, cricket::CN_VIDEO, nullptr, false, | 138 &fake_mc_, transport_controller_, cricket::CN_VIDEO, nullptr, |
134 VideoOptions()); | 139 kDefaultRtcpEnabled, kDefaultSrtpRequired, VideoOptions()); |
135 EXPECT_TRUE(video_channel != nullptr); | 140 EXPECT_TRUE(video_channel != nullptr); |
136 cricket::DataChannel* data_channel = | 141 cricket::DataChannel* data_channel = cm_->CreateDataChannel( |
137 cm_->CreateDataChannel(transport_controller_, cricket::CN_DATA, nullptr, | 142 &fake_mc_, transport_controller_, cricket::CN_DATA, nullptr, |
138 false, cricket::DCT_RTP); | 143 kDefaultRtcpEnabled, kDefaultSrtpRequired, cricket::DCT_RTP); |
139 EXPECT_TRUE(data_channel != nullptr); | 144 EXPECT_TRUE(data_channel != nullptr); |
140 cm_->DestroyVideoChannel(video_channel); | 145 cm_->DestroyVideoChannel(video_channel); |
141 cm_->DestroyVoiceChannel(voice_channel); | 146 cm_->DestroyVoiceChannel(voice_channel); |
142 cm_->DestroyDataChannel(data_channel); | 147 cm_->DestroyDataChannel(data_channel); |
143 cm_->Terminate(); | 148 cm_->Terminate(); |
144 } | 149 } |
145 | 150 |
146 TEST_F(ChannelManagerTest, SetVideoRtxEnabled) { | 151 TEST_F(ChannelManagerTest, SetVideoRtxEnabled) { |
147 std::vector<VideoCodec> codecs; | 152 std::vector<VideoCodec> codecs; |
148 const VideoCodec rtx_codec(96, "rtx"); | 153 const VideoCodec rtx_codec(96, "rtx"); |
(...skipping 18 matching lines...) Expand all Loading... |
167 EXPECT_FALSE(cm_->SetVideoRtxEnabled(false)); | 172 EXPECT_FALSE(cm_->SetVideoRtxEnabled(false)); |
168 | 173 |
169 // Can set again after terminate. | 174 // Can set again after terminate. |
170 cm_->Terminate(); | 175 cm_->Terminate(); |
171 EXPECT_TRUE(cm_->SetVideoRtxEnabled(true)); | 176 EXPECT_TRUE(cm_->SetVideoRtxEnabled(true)); |
172 cm_->GetSupportedVideoCodecs(&codecs); | 177 cm_->GetSupportedVideoCodecs(&codecs); |
173 EXPECT_TRUE(ContainsMatchingCodec(codecs, rtx_codec)); | 178 EXPECT_TRUE(ContainsMatchingCodec(codecs, rtx_codec)); |
174 } | 179 } |
175 | 180 |
176 } // namespace cricket | 181 } // namespace cricket |
OLD | NEW |