| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2008 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 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 <memory> | 11 #include <memory> |
| 12 | 12 |
| 13 #include "webrtc/api/audio_codecs/builtin_audio_decoder_factory.h" | 13 #include "webrtc/api/audio_codecs/builtin_audio_decoder_factory.h" |
| 14 #include "webrtc/api/audio_codecs/builtin_audio_encoder_factory.h" |
| 14 #include "webrtc/base/arraysize.h" | 15 #include "webrtc/base/arraysize.h" |
| 15 #include "webrtc/base/byteorder.h" | 16 #include "webrtc/base/byteorder.h" |
| 16 #include "webrtc/base/safe_conversions.h" | 17 #include "webrtc/base/safe_conversions.h" |
| 17 #include "webrtc/call/call.h" | 18 #include "webrtc/call/call.h" |
| 18 #include "webrtc/logging/rtc_event_log/rtc_event_log.h" | 19 #include "webrtc/logging/rtc_event_log/rtc_event_log.h" |
| 19 #include "webrtc/media/base/fakemediaengine.h" | 20 #include "webrtc/media/base/fakemediaengine.h" |
| 20 #include "webrtc/media/base/fakenetworkinterface.h" | 21 #include "webrtc/media/base/fakenetworkinterface.h" |
| 21 #include "webrtc/media/base/fakertp.h" | 22 #include "webrtc/media/base/fakertp.h" |
| 22 #include "webrtc/media/base/mediaconstants.h" | 23 #include "webrtc/media/base/mediaconstants.h" |
| 23 #include "webrtc/media/engine/fakewebrtccall.h" | 24 #include "webrtc/media/engine/fakewebrtccall.h" |
| 24 #include "webrtc/media/engine/fakewebrtcvoiceengine.h" | 25 #include "webrtc/media/engine/fakewebrtcvoiceengine.h" |
| 25 #include "webrtc/media/engine/webrtcvoiceengine.h" | 26 #include "webrtc/media/engine/webrtcvoiceengine.h" |
| 26 #include "webrtc/modules/audio_device/include/mock_audio_device.h" | 27 #include "webrtc/modules/audio_device/include/mock_audio_device.h" |
| 27 #include "webrtc/modules/audio_processing/include/mock_audio_processing.h" | 28 #include "webrtc/modules/audio_processing/include/mock_audio_processing.h" |
| 28 #include "webrtc/pc/channel.h" | 29 #include "webrtc/pc/channel.h" |
| 29 #include "webrtc/test/field_trial.h" | 30 #include "webrtc/test/field_trial.h" |
| 30 #include "webrtc/test/gtest.h" | 31 #include "webrtc/test/gtest.h" |
| 31 #include "webrtc/test/mock_audio_decoder_factory.h" | 32 #include "webrtc/test/mock_audio_decoder_factory.h" |
| 33 #include "webrtc/test/mock_audio_encoder_factory.h" |
| 32 #include "webrtc/voice_engine/transmit_mixer.h" | 34 #include "webrtc/voice_engine/transmit_mixer.h" |
| 33 | 35 |
| 34 using testing::ContainerEq; | 36 using testing::ContainerEq; |
| 35 using testing::Return; | 37 using testing::Return; |
| 36 using testing::StrictMock; | 38 using testing::StrictMock; |
| 37 | 39 |
| 38 namespace { | 40 namespace { |
| 39 | 41 |
| 40 constexpr uint32_t kMaxUnsignaledRecvStreams = 1; | 42 constexpr uint32_t kMaxUnsignaledRecvStreams = 1; |
| 41 | 43 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 StrictMock<webrtc::test::MockAudioProcessing> apm; | 124 StrictMock<webrtc::test::MockAudioProcessing> apm; |
| 123 EXPECT_CALL(apm, ApplyConfig(testing::_)); | 125 EXPECT_CALL(apm, ApplyConfig(testing::_)); |
| 124 EXPECT_CALL(apm, SetExtraOptions(testing::_)); | 126 EXPECT_CALL(apm, SetExtraOptions(testing::_)); |
| 125 EXPECT_CALL(apm, Initialize()).WillOnce(Return(0)); | 127 EXPECT_CALL(apm, Initialize()).WillOnce(Return(0)); |
| 126 StrictMock<MockTransmitMixer> transmit_mixer; | 128 StrictMock<MockTransmitMixer> transmit_mixer; |
| 127 EXPECT_CALL(transmit_mixer, EnableStereoChannelSwapping(false)); | 129 EXPECT_CALL(transmit_mixer, EnableStereoChannelSwapping(false)); |
| 128 cricket::FakeWebRtcVoiceEngine voe(&apm, &transmit_mixer); | 130 cricket::FakeWebRtcVoiceEngine voe(&apm, &transmit_mixer); |
| 129 EXPECT_FALSE(voe.IsInited()); | 131 EXPECT_FALSE(voe.IsInited()); |
| 130 { | 132 { |
| 131 cricket::WebRtcVoiceEngine engine( | 133 cricket::WebRtcVoiceEngine engine( |
| 132 &adm, webrtc::MockAudioDecoderFactory::CreateUnusedFactory(), nullptr, | 134 &adm, webrtc::MockAudioEncoderFactory::CreateUnusedFactory(), |
| 135 webrtc::MockAudioDecoderFactory::CreateUnusedFactory(), nullptr, |
| 133 new FakeVoEWrapper(&voe)); | 136 new FakeVoEWrapper(&voe)); |
| 134 EXPECT_TRUE(voe.IsInited()); | 137 EXPECT_TRUE(voe.IsInited()); |
| 135 } | 138 } |
| 136 EXPECT_FALSE(voe.IsInited()); | 139 EXPECT_FALSE(voe.IsInited()); |
| 137 } | 140 } |
| 138 | 141 |
| 139 class FakeAudioSink : public webrtc::AudioSinkInterface { | 142 class FakeAudioSink : public webrtc::AudioSinkInterface { |
| 140 public: | 143 public: |
| 141 void OnData(const Data& audio) override {} | 144 void OnData(const Data& audio) override {} |
| 142 }; | 145 }; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 167 EXPECT_CALL(apm_ns_, Enable(true)).WillOnce(Return(0)); | 170 EXPECT_CALL(apm_ns_, Enable(true)).WillOnce(Return(0)); |
| 168 EXPECT_CALL(apm_vd_, Enable(true)).WillOnce(Return(0)); | 171 EXPECT_CALL(apm_vd_, Enable(true)).WillOnce(Return(0)); |
| 169 EXPECT_CALL(transmit_mixer_, EnableStereoChannelSwapping(false)); | 172 EXPECT_CALL(transmit_mixer_, EnableStereoChannelSwapping(false)); |
| 170 // Init does not overwrite default AGC config. | 173 // Init does not overwrite default AGC config. |
| 171 EXPECT_CALL(apm_gc_, target_level_dbfs()).WillOnce(Return(1)); | 174 EXPECT_CALL(apm_gc_, target_level_dbfs()).WillOnce(Return(1)); |
| 172 EXPECT_CALL(apm_gc_, compression_gain_db()).WillRepeatedly(Return(5)); | 175 EXPECT_CALL(apm_gc_, compression_gain_db()).WillRepeatedly(Return(5)); |
| 173 EXPECT_CALL(apm_gc_, is_limiter_enabled()).WillRepeatedly(Return(true)); | 176 EXPECT_CALL(apm_gc_, is_limiter_enabled()).WillRepeatedly(Return(true)); |
| 174 EXPECT_CALL(apm_gc_, set_target_level_dbfs(1)).WillOnce(Return(0)); | 177 EXPECT_CALL(apm_gc_, set_target_level_dbfs(1)).WillOnce(Return(0)); |
| 175 EXPECT_CALL(apm_gc_, set_compression_gain_db(5)).WillRepeatedly(Return(0)); | 178 EXPECT_CALL(apm_gc_, set_compression_gain_db(5)).WillRepeatedly(Return(0)); |
| 176 EXPECT_CALL(apm_gc_, enable_limiter(true)).WillRepeatedly(Return(0)); | 179 EXPECT_CALL(apm_gc_, enable_limiter(true)).WillRepeatedly(Return(0)); |
| 177 // TODO(kwiberg): We should use a mock AudioDecoderFactory, but a bunch of | 180 // TODO(kwiberg): We should use mock factories here, but a bunch of |
| 178 // the tests here probe the specific set of codecs provided by the builtin | 181 // the tests here probe the specific set of codecs provided by the builtin |
| 179 // factory. Those tests should probably be moved elsewhere. | 182 // factories. Those tests should probably be moved elsewhere. |
| 180 engine_.reset(new cricket::WebRtcVoiceEngine( | 183 auto encoder_factory = webrtc::CreateBuiltinAudioEncoderFactory(); |
| 181 &adm_, webrtc::CreateBuiltinAudioDecoderFactory(), nullptr, | 184 auto decoder_factory = webrtc::CreateBuiltinAudioDecoderFactory(); |
| 182 new FakeVoEWrapper(&voe_))); | 185 engine_.reset(new cricket::WebRtcVoiceEngine(&adm_, encoder_factory, |
| 186 decoder_factory, nullptr, |
| 187 new FakeVoEWrapper(&voe_))); |
| 183 send_parameters_.codecs.push_back(kPcmuCodec); | 188 send_parameters_.codecs.push_back(kPcmuCodec); |
| 184 recv_parameters_.codecs.push_back(kPcmuCodec); | 189 recv_parameters_.codecs.push_back(kPcmuCodec); |
| 185 // Default Options. | 190 // Default Options. |
| 186 EXPECT_TRUE(IsHighPassFilterEnabled()); | 191 EXPECT_TRUE(IsHighPassFilterEnabled()); |
| 187 } | 192 } |
| 188 | 193 |
| 189 bool SetupChannel() { | 194 bool SetupChannel() { |
| 190 EXPECT_CALL(apm_, ApplyConfig(testing::_)); | 195 EXPECT_CALL(apm_, ApplyConfig(testing::_)); |
| 191 EXPECT_CALL(apm_, SetExtraOptions(testing::_)); | 196 EXPECT_CALL(apm_, SetExtraOptions(testing::_)); |
| 192 channel_ = engine_->CreateChannel(&call_, cricket::MediaConfig(), | 197 channel_ = engine_->CreateChannel(&call_, cricket::MediaConfig(), |
| (...skipping 3054 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3247 channel_->SetRecvParameters(parameters); | 3252 channel_->SetRecvParameters(parameters); |
| 3248 | 3253 |
| 3249 EXPECT_TRUE(GetRecvStream(kSsrcX).started()); | 3254 EXPECT_TRUE(GetRecvStream(kSsrcX).started()); |
| 3250 } | 3255 } |
| 3251 | 3256 |
| 3252 // Tests that the library initializes and shuts down properly. | 3257 // Tests that the library initializes and shuts down properly. |
| 3253 TEST(WebRtcVoiceEngineTest, StartupShutdown) { | 3258 TEST(WebRtcVoiceEngineTest, StartupShutdown) { |
| 3254 // If the VoiceEngine wants to gather available codecs early, that's fine but | 3259 // If the VoiceEngine wants to gather available codecs early, that's fine but |
| 3255 // we never want it to create a decoder at this stage. | 3260 // we never want it to create a decoder at this stage. |
| 3256 cricket::WebRtcVoiceEngine engine( | 3261 cricket::WebRtcVoiceEngine engine( |
| 3257 nullptr, webrtc::MockAudioDecoderFactory::CreateUnusedFactory(), nullptr); | 3262 nullptr, webrtc::MockAudioEncoderFactory::CreateUnusedFactory(), |
| 3263 webrtc::MockAudioDecoderFactory::CreateUnusedFactory(), nullptr); |
| 3258 webrtc::RtcEventLogNullImpl event_log; | 3264 webrtc::RtcEventLogNullImpl event_log; |
| 3259 std::unique_ptr<webrtc::Call> call( | 3265 std::unique_ptr<webrtc::Call> call( |
| 3260 webrtc::Call::Create(webrtc::Call::Config(&event_log))); | 3266 webrtc::Call::Create(webrtc::Call::Config(&event_log))); |
| 3261 cricket::VoiceMediaChannel* channel = engine.CreateChannel( | 3267 cricket::VoiceMediaChannel* channel = engine.CreateChannel( |
| 3262 call.get(), cricket::MediaConfig(), cricket::AudioOptions()); | 3268 call.get(), cricket::MediaConfig(), cricket::AudioOptions()); |
| 3263 EXPECT_TRUE(channel != nullptr); | 3269 EXPECT_TRUE(channel != nullptr); |
| 3264 delete channel; | 3270 delete channel; |
| 3265 } | 3271 } |
| 3266 | 3272 |
| 3267 // Tests that reference counting on the external ADM is correct. | 3273 // Tests that reference counting on the external ADM is correct. |
| 3268 TEST(WebRtcVoiceEngineTest, StartupShutdownWithExternalADM) { | 3274 TEST(WebRtcVoiceEngineTest, StartupShutdownWithExternalADM) { |
| 3269 testing::NiceMock<webrtc::test::MockAudioDeviceModule> adm; | 3275 testing::NiceMock<webrtc::test::MockAudioDeviceModule> adm; |
| 3270 EXPECT_CALL(adm, AddRef()).Times(3).WillRepeatedly(Return(0)); | 3276 EXPECT_CALL(adm, AddRef()).Times(3).WillRepeatedly(Return(0)); |
| 3271 EXPECT_CALL(adm, Release()).Times(3).WillRepeatedly(Return(0)); | 3277 EXPECT_CALL(adm, Release()).Times(3).WillRepeatedly(Return(0)); |
| 3272 // Return 100ms just in case this function gets called. If we don't, | 3278 // Return 100ms just in case this function gets called. If we don't, |
| 3273 // we could enter a tight loop since the mock would return 0. | 3279 // we could enter a tight loop since the mock would return 0. |
| 3274 EXPECT_CALL(adm, TimeUntilNextProcess()).WillRepeatedly(Return(100)); | 3280 EXPECT_CALL(adm, TimeUntilNextProcess()).WillRepeatedly(Return(100)); |
| 3275 { | 3281 { |
| 3276 cricket::WebRtcVoiceEngine engine( | 3282 cricket::WebRtcVoiceEngine engine( |
| 3277 &adm, webrtc::MockAudioDecoderFactory::CreateUnusedFactory(), nullptr); | 3283 &adm, webrtc::MockAudioEncoderFactory::CreateUnusedFactory(), |
| 3284 webrtc::MockAudioDecoderFactory::CreateUnusedFactory(), nullptr); |
| 3278 webrtc::RtcEventLogNullImpl event_log; | 3285 webrtc::RtcEventLogNullImpl event_log; |
| 3279 std::unique_ptr<webrtc::Call> call( | 3286 std::unique_ptr<webrtc::Call> call( |
| 3280 webrtc::Call::Create(webrtc::Call::Config(&event_log))); | 3287 webrtc::Call::Create(webrtc::Call::Config(&event_log))); |
| 3281 cricket::VoiceMediaChannel* channel = engine.CreateChannel( | 3288 cricket::VoiceMediaChannel* channel = engine.CreateChannel( |
| 3282 call.get(), cricket::MediaConfig(), cricket::AudioOptions()); | 3289 call.get(), cricket::MediaConfig(), cricket::AudioOptions()); |
| 3283 EXPECT_TRUE(channel != nullptr); | 3290 EXPECT_TRUE(channel != nullptr); |
| 3284 delete channel; | 3291 delete channel; |
| 3285 } | 3292 } |
| 3286 } | 3293 } |
| 3287 | 3294 |
| 3288 // Verify the payload id of common audio codecs, including CN, ISAC, and G722. | 3295 // Verify the payload id of common audio codecs, including CN, ISAC, and G722. |
| 3289 TEST(WebRtcVoiceEngineTest, HasCorrectPayloadTypeMapping) { | 3296 TEST(WebRtcVoiceEngineTest, HasCorrectPayloadTypeMapping) { |
| 3290 // TODO(ossu): Why are the payload types of codecs with non-static payload | 3297 // TODO(ossu): Why are the payload types of codecs with non-static payload |
| 3291 // type assignments checked here? It shouldn't really matter. | 3298 // type assignments checked here? It shouldn't really matter. |
| 3292 cricket::WebRtcVoiceEngine engine( | 3299 cricket::WebRtcVoiceEngine engine( |
| 3293 nullptr, webrtc::MockAudioDecoderFactory::CreateUnusedFactory(), nullptr); | 3300 nullptr, webrtc::MockAudioEncoderFactory::CreateUnusedFactory(), |
| 3301 webrtc::MockAudioDecoderFactory::CreateUnusedFactory(), nullptr); |
| 3294 for (const cricket::AudioCodec& codec : engine.send_codecs()) { | 3302 for (const cricket::AudioCodec& codec : engine.send_codecs()) { |
| 3295 auto is_codec = [&codec](const char* name, int clockrate = 0) { | 3303 auto is_codec = [&codec](const char* name, int clockrate = 0) { |
| 3296 return STR_CASE_CMP(codec.name.c_str(), name) == 0 && | 3304 return STR_CASE_CMP(codec.name.c_str(), name) == 0 && |
| 3297 (clockrate == 0 || codec.clockrate == clockrate); | 3305 (clockrate == 0 || codec.clockrate == clockrate); |
| 3298 }; | 3306 }; |
| 3299 if (is_codec("CN", 16000)) { | 3307 if (is_codec("CN", 16000)) { |
| 3300 EXPECT_EQ(105, codec.id); | 3308 EXPECT_EQ(105, codec.id); |
| 3301 } else if (is_codec("CN", 32000)) { | 3309 } else if (is_codec("CN", 32000)) { |
| 3302 EXPECT_EQ(106, codec.id); | 3310 EXPECT_EQ(106, codec.id); |
| 3303 } else if (is_codec("ISAC", 16000)) { | 3311 } else if (is_codec("ISAC", 16000)) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 3323 EXPECT_EQ("10", codec.params.find("minptime")->second); | 3331 EXPECT_EQ("10", codec.params.find("minptime")->second); |
| 3324 ASSERT_TRUE(codec.params.find("useinbandfec") != codec.params.end()); | 3332 ASSERT_TRUE(codec.params.find("useinbandfec") != codec.params.end()); |
| 3325 EXPECT_EQ("1", codec.params.find("useinbandfec")->second); | 3333 EXPECT_EQ("1", codec.params.find("useinbandfec")->second); |
| 3326 } | 3334 } |
| 3327 } | 3335 } |
| 3328 } | 3336 } |
| 3329 | 3337 |
| 3330 // Tests that VoE supports at least 32 channels | 3338 // Tests that VoE supports at least 32 channels |
| 3331 TEST(WebRtcVoiceEngineTest, Has32Channels) { | 3339 TEST(WebRtcVoiceEngineTest, Has32Channels) { |
| 3332 cricket::WebRtcVoiceEngine engine( | 3340 cricket::WebRtcVoiceEngine engine( |
| 3333 nullptr, webrtc::MockAudioDecoderFactory::CreateUnusedFactory(), nullptr); | 3341 nullptr, webrtc::MockAudioEncoderFactory::CreateUnusedFactory(), |
| 3342 webrtc::MockAudioDecoderFactory::CreateUnusedFactory(), nullptr); |
| 3334 webrtc::RtcEventLogNullImpl event_log; | 3343 webrtc::RtcEventLogNullImpl event_log; |
| 3335 std::unique_ptr<webrtc::Call> call( | 3344 std::unique_ptr<webrtc::Call> call( |
| 3336 webrtc::Call::Create(webrtc::Call::Config(&event_log))); | 3345 webrtc::Call::Create(webrtc::Call::Config(&event_log))); |
| 3337 | 3346 |
| 3338 cricket::VoiceMediaChannel* channels[32]; | 3347 cricket::VoiceMediaChannel* channels[32]; |
| 3339 int num_channels = 0; | 3348 int num_channels = 0; |
| 3340 while (num_channels < arraysize(channels)) { | 3349 while (num_channels < arraysize(channels)) { |
| 3341 cricket::VoiceMediaChannel* channel = engine.CreateChannel( | 3350 cricket::VoiceMediaChannel* channel = engine.CreateChannel( |
| 3342 call.get(), cricket::MediaConfig(), cricket::AudioOptions()); | 3351 call.get(), cricket::MediaConfig(), cricket::AudioOptions()); |
| 3343 if (!channel) | 3352 if (!channel) |
| (...skipping 12 matching lines...) Expand all Loading... |
| 3356 // Test that we set our preferred codecs properly. | 3365 // Test that we set our preferred codecs properly. |
| 3357 TEST(WebRtcVoiceEngineTest, SetRecvCodecs) { | 3366 TEST(WebRtcVoiceEngineTest, SetRecvCodecs) { |
| 3358 // TODO(ossu): I'm not sure of the intent of this test. It's either: | 3367 // TODO(ossu): I'm not sure of the intent of this test. It's either: |
| 3359 // - Check that our builtin codecs are usable by Channel. | 3368 // - Check that our builtin codecs are usable by Channel. |
| 3360 // - The codecs provided by the engine is usable by Channel. | 3369 // - The codecs provided by the engine is usable by Channel. |
| 3361 // It does not check that the codecs in the RecvParameters are actually | 3370 // It does not check that the codecs in the RecvParameters are actually |
| 3362 // what we sent in - though it's probably reasonable to expect so, if | 3371 // what we sent in - though it's probably reasonable to expect so, if |
| 3363 // SetRecvParameters returns true. | 3372 // SetRecvParameters returns true. |
| 3364 // I think it will become clear once audio decoder injection is completed. | 3373 // I think it will become clear once audio decoder injection is completed. |
| 3365 cricket::WebRtcVoiceEngine engine( | 3374 cricket::WebRtcVoiceEngine engine( |
| 3366 nullptr, webrtc::CreateBuiltinAudioDecoderFactory(), nullptr); | 3375 nullptr, webrtc::MockAudioEncoderFactory::CreateUnusedFactory(), |
| 3376 webrtc::CreateBuiltinAudioDecoderFactory(), nullptr); |
| 3367 webrtc::RtcEventLogNullImpl event_log; | 3377 webrtc::RtcEventLogNullImpl event_log; |
| 3368 std::unique_ptr<webrtc::Call> call( | 3378 std::unique_ptr<webrtc::Call> call( |
| 3369 webrtc::Call::Create(webrtc::Call::Config(&event_log))); | 3379 webrtc::Call::Create(webrtc::Call::Config(&event_log))); |
| 3370 cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::MediaConfig(), | 3380 cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::MediaConfig(), |
| 3371 cricket::AudioOptions(), call.get()); | 3381 cricket::AudioOptions(), call.get()); |
| 3372 cricket::AudioRecvParameters parameters; | 3382 cricket::AudioRecvParameters parameters; |
| 3373 parameters.codecs = engine.recv_codecs(); | 3383 parameters.codecs = engine.recv_codecs(); |
| 3374 EXPECT_TRUE(channel.SetRecvParameters(parameters)); | 3384 EXPECT_TRUE(channel.SetRecvParameters(parameters)); |
| 3375 } | 3385 } |
| 3376 | 3386 |
| 3377 TEST(WebRtcVoiceEngineTest, CollectRecvCodecs) { | 3387 TEST(WebRtcVoiceEngineTest, CollectRecvCodecs) { |
| 3378 std::vector<webrtc::AudioCodecSpec> specs; | 3388 std::vector<webrtc::AudioCodecSpec> specs; |
| 3379 webrtc::AudioCodecSpec spec1{{"codec1", 48000, 2, {{"param1", "value1"}}}, | 3389 webrtc::AudioCodecSpec spec1{{"codec1", 48000, 2, {{"param1", "value1"}}}, |
| 3380 {48000, 2, 16000, 10000, 20000}}; | 3390 {48000, 2, 16000, 10000, 20000}}; |
| 3381 spec1.info.allow_comfort_noise = false; | 3391 spec1.info.allow_comfort_noise = false; |
| 3382 spec1.info.supports_network_adaption = true; | 3392 spec1.info.supports_network_adaption = true; |
| 3383 specs.push_back(spec1); | 3393 specs.push_back(spec1); |
| 3384 webrtc::AudioCodecSpec spec2{{"codec2", 32000, 1}, {32000, 1, 32000}}; | 3394 webrtc::AudioCodecSpec spec2{{"codec2", 32000, 1}, {32000, 1, 32000}}; |
| 3385 spec2.info.allow_comfort_noise = false; | 3395 spec2.info.allow_comfort_noise = false; |
| 3386 specs.push_back(spec2); | 3396 specs.push_back(spec2); |
| 3387 specs.push_back(webrtc::AudioCodecSpec{ | 3397 specs.push_back(webrtc::AudioCodecSpec{ |
| 3388 {"codec3", 16000, 1, {{"param1", "value1b"}, {"param2", "value2"}}}, | 3398 {"codec3", 16000, 1, {{"param1", "value1b"}, {"param2", "value2"}}}, |
| 3389 {16000, 1, 13300}}); | 3399 {16000, 1, 13300}}); |
| 3390 specs.push_back( | 3400 specs.push_back( |
| 3391 webrtc::AudioCodecSpec{{"codec4", 8000, 1}, {8000, 1, 64000}}); | 3401 webrtc::AudioCodecSpec{{"codec4", 8000, 1}, {8000, 1, 64000}}); |
| 3392 specs.push_back( | 3402 specs.push_back( |
| 3393 webrtc::AudioCodecSpec{{"codec5", 8000, 2}, {8000, 1, 64000}}); | 3403 webrtc::AudioCodecSpec{{"codec5", 8000, 2}, {8000, 1, 64000}}); |
| 3394 | 3404 |
| 3395 rtc::scoped_refptr<webrtc::MockAudioDecoderFactory> mock_factory = | 3405 rtc::scoped_refptr<webrtc::MockAudioEncoderFactory> unused_encoder_factory = |
| 3406 webrtc::MockAudioEncoderFactory::CreateUnusedFactory(); |
| 3407 rtc::scoped_refptr<webrtc::MockAudioDecoderFactory> mock_decoder_factory = |
| 3396 new rtc::RefCountedObject<webrtc::MockAudioDecoderFactory>; | 3408 new rtc::RefCountedObject<webrtc::MockAudioDecoderFactory>; |
| 3397 EXPECT_CALL(*mock_factory.get(), GetSupportedDecoders()) | 3409 EXPECT_CALL(*mock_decoder_factory.get(), GetSupportedDecoders()) |
| 3398 .WillOnce(Return(specs)); | 3410 .WillOnce(Return(specs)); |
| 3399 | 3411 |
| 3400 cricket::WebRtcVoiceEngine engine(nullptr, mock_factory, nullptr); | 3412 cricket::WebRtcVoiceEngine engine(nullptr, unused_encoder_factory, |
| 3413 mock_decoder_factory, nullptr); |
| 3401 auto codecs = engine.recv_codecs(); | 3414 auto codecs = engine.recv_codecs(); |
| 3402 EXPECT_EQ(11, codecs.size()); | 3415 EXPECT_EQ(11, codecs.size()); |
| 3403 | 3416 |
| 3404 // Rather than just ASSERTing that there are enough codecs, ensure that we can | 3417 // Rather than just ASSERTing that there are enough codecs, ensure that we can |
| 3405 // check the actual values safely, to provide better test results. | 3418 // check the actual values safely, to provide better test results. |
| 3406 auto get_codec = | 3419 auto get_codec = |
| 3407 [&codecs](size_t index) -> const cricket::AudioCodec& { | 3420 [&codecs](size_t index) -> const cricket::AudioCodec& { |
| 3408 static const cricket::AudioCodec missing_codec(0, "<missing>", 0, 0, 0); | 3421 static const cricket::AudioCodec missing_codec(0, "<missing>", 0, 0, 0); |
| 3409 if (codecs.size() > index) | 3422 if (codecs.size() > index) |
| 3410 return codecs[index]; | 3423 return codecs[index]; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 3439 // Without this cast, the comparison turned unsigned and, thus, failed for -1. | 3452 // Without this cast, the comparison turned unsigned and, thus, failed for -1. |
| 3440 const int num_specs = static_cast<int>(specs.size()); | 3453 const int num_specs = static_cast<int>(specs.size()); |
| 3441 EXPECT_GE(find_codec({"cn", 8000, 1}), num_specs); | 3454 EXPECT_GE(find_codec({"cn", 8000, 1}), num_specs); |
| 3442 EXPECT_GE(find_codec({"cn", 16000, 1}), num_specs); | 3455 EXPECT_GE(find_codec({"cn", 16000, 1}), num_specs); |
| 3443 EXPECT_EQ(find_codec({"cn", 32000, 1}), -1); | 3456 EXPECT_EQ(find_codec({"cn", 32000, 1}), -1); |
| 3444 EXPECT_GE(find_codec({"telephone-event", 8000, 1}), num_specs); | 3457 EXPECT_GE(find_codec({"telephone-event", 8000, 1}), num_specs); |
| 3445 EXPECT_GE(find_codec({"telephone-event", 16000, 1}), num_specs); | 3458 EXPECT_GE(find_codec({"telephone-event", 16000, 1}), num_specs); |
| 3446 EXPECT_GE(find_codec({"telephone-event", 32000, 1}), num_specs); | 3459 EXPECT_GE(find_codec({"telephone-event", 32000, 1}), num_specs); |
| 3447 EXPECT_GE(find_codec({"telephone-event", 48000, 1}), num_specs); | 3460 EXPECT_GE(find_codec({"telephone-event", 48000, 1}), num_specs); |
| 3448 } | 3461 } |
| OLD | NEW |