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/media/base/fakemediaengine.h" | 15 #include "webrtc/media/base/fakemediaengine.h" |
16 #include "webrtc/media/base/fakevideocapturer.h" | 16 #include "webrtc/media/base/fakevideocapturer.h" |
17 #include "webrtc/media/base/testutils.h" | 17 #include "webrtc/media/base/testutils.h" |
18 #include "webrtc/media/engine/fakewebrtccall.h" | 18 #include "webrtc/media/engine/fakewebrtccall.h" |
19 #include "webrtc/p2p/base/faketransportcontroller.h" | 19 #include "webrtc/p2p/base/faketransportcontroller.h" |
20 #include "webrtc/pc/channelmanager.h" | 20 #include "webrtc/pc/channelmanager.h" |
21 | 21 |
22 namespace cricket { | 22 namespace cricket { |
23 | 23 |
24 static const AudioCodec kAudioCodecs[] = { | 24 static const AudioCodec kAudioCodecs[] = { |
25 AudioCodec(97, "voice", 1, 2, 3, 0), | 25 AudioCodec(97, "voice", 1, 2, 3), AudioCodec(111, "OPUS", 48000, 32000, 2), |
26 AudioCodec(111, "OPUS", 48000, 32000, 2, 0), | |
27 }; | 26 }; |
28 | 27 |
29 static const VideoCodec kVideoCodecs[] = { | 28 static const VideoCodec kVideoCodecs[] = { |
30 VideoCodec(99, "H264", 100, 200, 300, 0), | 29 VideoCodec(99, "H264", 100, 200, 300), |
31 VideoCodec(100, "VP8", 100, 200, 300, 0), | 30 VideoCodec(100, "VP8", 100, 200, 300), VideoCodec(96, "rtx", 100, 200, 300), |
32 VideoCodec(96, "rtx", 100, 200, 300, 0), | |
33 }; | 31 }; |
34 | 32 |
35 class ChannelManagerTest : public testing::Test { | 33 class ChannelManagerTest : public testing::Test { |
36 protected: | 34 protected: |
37 ChannelManagerTest() | 35 ChannelManagerTest() |
38 : fme_(new cricket::FakeMediaEngine()), | 36 : fme_(new cricket::FakeMediaEngine()), |
39 fdme_(new cricket::FakeDataEngine()), | 37 fdme_(new cricket::FakeDataEngine()), |
40 cm_(new cricket::ChannelManager(fme_, | 38 cm_(new cricket::ChannelManager(fme_, |
41 fdme_, | 39 fdme_, |
42 rtc::Thread::Current())), | 40 rtc::Thread::Current())), |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 | 189 |
192 EXPECT_FALSE(cm_->SetOutputVolume(-1)); // Invalid volume. | 190 EXPECT_FALSE(cm_->SetOutputVolume(-1)); // Invalid volume. |
193 EXPECT_TRUE(cm_->SetOutputVolume(60)); | 191 EXPECT_TRUE(cm_->SetOutputVolume(60)); |
194 EXPECT_EQ(60, fme_->output_volume()); | 192 EXPECT_EQ(60, fme_->output_volume()); |
195 EXPECT_TRUE(cm_->GetOutputVolume(&level)); | 193 EXPECT_TRUE(cm_->GetOutputVolume(&level)); |
196 EXPECT_EQ(60, level); | 194 EXPECT_EQ(60, level); |
197 } | 195 } |
198 | 196 |
199 TEST_F(ChannelManagerTest, SetVideoRtxEnabled) { | 197 TEST_F(ChannelManagerTest, SetVideoRtxEnabled) { |
200 std::vector<VideoCodec> codecs; | 198 std::vector<VideoCodec> codecs; |
201 const VideoCodec rtx_codec(96, "rtx", 0, 0, 0, 0); | 199 const VideoCodec rtx_codec(96, "rtx", 0, 0, 0); |
202 | 200 |
203 // By default RTX is disabled. | 201 // By default RTX is disabled. |
204 cm_->GetSupportedVideoCodecs(&codecs); | 202 cm_->GetSupportedVideoCodecs(&codecs); |
205 EXPECT_FALSE(ContainsMatchingCodec(codecs, rtx_codec)); | 203 EXPECT_FALSE(ContainsMatchingCodec(codecs, rtx_codec)); |
206 | 204 |
207 // Enable and check. | 205 // Enable and check. |
208 EXPECT_TRUE(cm_->SetVideoRtxEnabled(true)); | 206 EXPECT_TRUE(cm_->SetVideoRtxEnabled(true)); |
209 cm_->GetSupportedVideoCodecs(&codecs); | 207 cm_->GetSupportedVideoCodecs(&codecs); |
210 EXPECT_TRUE(ContainsMatchingCodec(codecs, rtx_codec)); | 208 EXPECT_TRUE(ContainsMatchingCodec(codecs, rtx_codec)); |
211 | 209 |
212 // Disable and check. | 210 // Disable and check. |
213 EXPECT_TRUE(cm_->SetVideoRtxEnabled(false)); | 211 EXPECT_TRUE(cm_->SetVideoRtxEnabled(false)); |
214 cm_->GetSupportedVideoCodecs(&codecs); | 212 cm_->GetSupportedVideoCodecs(&codecs); |
215 EXPECT_FALSE(ContainsMatchingCodec(codecs, rtx_codec)); | 213 EXPECT_FALSE(ContainsMatchingCodec(codecs, rtx_codec)); |
216 | 214 |
217 // Cannot toggle rtx after initialization. | 215 // Cannot toggle rtx after initialization. |
218 EXPECT_TRUE(cm_->Init()); | 216 EXPECT_TRUE(cm_->Init()); |
219 EXPECT_FALSE(cm_->SetVideoRtxEnabled(true)); | 217 EXPECT_FALSE(cm_->SetVideoRtxEnabled(true)); |
220 EXPECT_FALSE(cm_->SetVideoRtxEnabled(false)); | 218 EXPECT_FALSE(cm_->SetVideoRtxEnabled(false)); |
221 | 219 |
222 // Can set again after terminate. | 220 // Can set again after terminate. |
223 cm_->Terminate(); | 221 cm_->Terminate(); |
224 EXPECT_TRUE(cm_->SetVideoRtxEnabled(true)); | 222 EXPECT_TRUE(cm_->SetVideoRtxEnabled(true)); |
225 cm_->GetSupportedVideoCodecs(&codecs); | 223 cm_->GetSupportedVideoCodecs(&codecs); |
226 EXPECT_TRUE(ContainsMatchingCodec(codecs, rtx_codec)); | 224 EXPECT_TRUE(ContainsMatchingCodec(codecs, rtx_codec)); |
227 } | 225 } |
228 | 226 |
229 } // namespace cricket | 227 } // namespace cricket |
OLD | NEW |