| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 MOCK_METHOD2(OnAllocationLimitsChanged, | 80 MOCK_METHOD2(OnAllocationLimitsChanged, |
| 81 void(uint32_t min_send_bitrate_bps, | 81 void(uint32_t min_send_bitrate_bps, |
| 82 uint32_t max_padding_bitrate_bps)); | 82 uint32_t max_padding_bitrate_bps)); |
| 83 }; | 83 }; |
| 84 | 84 |
| 85 class MockTransmitMixer : public voe::TransmitMixer { | 85 class MockTransmitMixer : public voe::TransmitMixer { |
| 86 public: | 86 public: |
| 87 MOCK_CONST_METHOD0(AudioLevelFullRange, int16_t()); | 87 MOCK_CONST_METHOD0(AudioLevelFullRange, int16_t()); |
| 88 MOCK_CONST_METHOD0(GetTotalInputEnergy, double()); | 88 MOCK_CONST_METHOD0(GetTotalInputEnergy, double()); |
| 89 MOCK_CONST_METHOD0(GetTotalInputDuration, double()); | 89 MOCK_CONST_METHOD0(GetTotalInputDuration, double()); |
| 90 MOCK_CONST_METHOD0(typing_noise_detected, bool()); |
| 90 }; | 91 }; |
| 91 | 92 |
| 92 std::unique_ptr<MockAudioEncoder> SetupAudioEncoderMock( | 93 std::unique_ptr<MockAudioEncoder> SetupAudioEncoderMock( |
| 93 int payload_type, | 94 int payload_type, |
| 94 const SdpAudioFormat& format) { | 95 const SdpAudioFormat& format) { |
| 95 for (const auto& spec : kCodecSpecs) { | 96 for (const auto& spec : kCodecSpecs) { |
| 96 if (format == spec.format) { | 97 if (format == spec.format) { |
| 97 std::unique_ptr<MockAudioEncoder> encoder(new MockAudioEncoder); | 98 std::unique_ptr<MockAudioEncoder> encoder(new MockAudioEncoder); |
| 98 ON_CALL(*encoder.get(), SampleRateHz()) | 99 ON_CALL(*encoder.get(), SampleRateHz()) |
| 99 .WillByDefault(Return(spec.info.sample_rate_hz)); | 100 .WillByDefault(Return(spec.info.sample_rate_hz)); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 &simulated_clock_, | 140 &simulated_clock_, |
| 140 nullptr /* observer */, | 141 nullptr /* observer */, |
| 141 &event_log_, | 142 &event_log_, |
| 142 &pacer_)), | 143 &pacer_)), |
| 143 fake_transport_(&packet_router_, &pacer_, send_side_cc_.get()), | 144 fake_transport_(&packet_router_, &pacer_, send_side_cc_.get()), |
| 144 bitrate_allocator_(&limit_observer_), | 145 bitrate_allocator_(&limit_observer_), |
| 145 worker_queue_("ConfigHelper_worker_queue"), | 146 worker_queue_("ConfigHelper_worker_queue"), |
| 146 audio_encoder_(nullptr) { | 147 audio_encoder_(nullptr) { |
| 147 using testing::Invoke; | 148 using testing::Invoke; |
| 148 | 149 |
| 149 EXPECT_CALL(voice_engine_, | |
| 150 RegisterVoiceEngineObserver(_)).WillOnce(Return(0)); | |
| 151 EXPECT_CALL(voice_engine_, | |
| 152 DeRegisterVoiceEngineObserver()).WillOnce(Return(0)); | |
| 153 EXPECT_CALL(voice_engine_, audio_device_module()); | 150 EXPECT_CALL(voice_engine_, audio_device_module()); |
| 154 EXPECT_CALL(voice_engine_, audio_transport()); | 151 EXPECT_CALL(voice_engine_, audio_transport()); |
| 155 | 152 |
| 156 AudioState::Config config; | 153 AudioState::Config config; |
| 157 config.voice_engine = &voice_engine_; | 154 config.voice_engine = &voice_engine_; |
| 158 config.audio_mixer = AudioMixerImpl::Create(); | 155 config.audio_mixer = AudioMixerImpl::Create(); |
| 159 config.audio_processing = audio_processing_; | 156 config.audio_processing = audio_processing_; |
| 160 audio_state_ = AudioState::Create(config); | 157 audio_state_ = AudioState::Create(config); |
| 161 | 158 |
| 162 SetupDefaultChannelProxy(audio_bwe_enabled); | 159 SetupDefaultChannelProxy(audio_bwe_enabled); |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 .WillRepeatedly(Return(ANAStats())); | 302 .WillRepeatedly(Return(ANAStats())); |
| 306 EXPECT_CALL(voice_engine_, transmit_mixer()) | 303 EXPECT_CALL(voice_engine_, transmit_mixer()) |
| 307 .WillRepeatedly(Return(&transmit_mixer_)); | 304 .WillRepeatedly(Return(&transmit_mixer_)); |
| 308 | 305 |
| 309 EXPECT_CALL(transmit_mixer_, AudioLevelFullRange()) | 306 EXPECT_CALL(transmit_mixer_, AudioLevelFullRange()) |
| 310 .WillRepeatedly(Return(kSpeechInputLevel)); | 307 .WillRepeatedly(Return(kSpeechInputLevel)); |
| 311 EXPECT_CALL(transmit_mixer_, GetTotalInputEnergy()) | 308 EXPECT_CALL(transmit_mixer_, GetTotalInputEnergy()) |
| 312 .WillRepeatedly(Return(kTotalInputEnergy)); | 309 .WillRepeatedly(Return(kTotalInputEnergy)); |
| 313 EXPECT_CALL(transmit_mixer_, GetTotalInputDuration()) | 310 EXPECT_CALL(transmit_mixer_, GetTotalInputDuration()) |
| 314 .WillRepeatedly(Return(kTotalInputDuration)); | 311 .WillRepeatedly(Return(kTotalInputDuration)); |
| 312 EXPECT_CALL(transmit_mixer_, typing_noise_detected()) |
| 313 .WillRepeatedly(Return(true)); |
| 315 | 314 |
| 316 // We have to set the instantaneous value, the average, min and max. We only | 315 // We have to set the instantaneous value, the average, min and max. We only |
| 317 // care about the instantaneous value, so we set all to the same value. | 316 // care about the instantaneous value, so we set all to the same value. |
| 318 audio_processing_stats_.echo_return_loss.Set( | 317 audio_processing_stats_.echo_return_loss.Set( |
| 319 kEchoReturnLoss, kEchoReturnLoss, kEchoReturnLoss, kEchoReturnLoss); | 318 kEchoReturnLoss, kEchoReturnLoss, kEchoReturnLoss, kEchoReturnLoss); |
| 320 audio_processing_stats_.echo_return_loss_enhancement.Set( | 319 audio_processing_stats_.echo_return_loss_enhancement.Set( |
| 321 kEchoReturnLossEnhancement, kEchoReturnLossEnhancement, | 320 kEchoReturnLossEnhancement, kEchoReturnLossEnhancement, |
| 322 kEchoReturnLossEnhancement, kEchoReturnLossEnhancement); | 321 kEchoReturnLossEnhancement, kEchoReturnLossEnhancement); |
| 323 audio_processing_stats_.delay_median = kEchoDelayMedian; | 322 audio_processing_stats_.delay_median = kEchoDelayMedian; |
| 324 audio_processing_stats_.delay_standard_deviation = kEchoDelayStdDev; | 323 audio_processing_stats_.delay_standard_deviation = kEchoDelayStdDev; |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 EXPECT_EQ(kCallStats.rttMs, stats.rtt_ms); | 448 EXPECT_EQ(kCallStats.rttMs, stats.rtt_ms); |
| 450 EXPECT_EQ(static_cast<int32_t>(kSpeechInputLevel), stats.audio_level); | 449 EXPECT_EQ(static_cast<int32_t>(kSpeechInputLevel), stats.audio_level); |
| 451 EXPECT_EQ(kTotalInputEnergy, stats.total_input_energy); | 450 EXPECT_EQ(kTotalInputEnergy, stats.total_input_energy); |
| 452 EXPECT_EQ(kTotalInputDuration, stats.total_input_duration); | 451 EXPECT_EQ(kTotalInputDuration, stats.total_input_duration); |
| 453 EXPECT_EQ(-1, stats.aec_quality_min); | 452 EXPECT_EQ(-1, stats.aec_quality_min); |
| 454 EXPECT_EQ(kEchoDelayMedian, stats.echo_delay_median_ms); | 453 EXPECT_EQ(kEchoDelayMedian, stats.echo_delay_median_ms); |
| 455 EXPECT_EQ(kEchoDelayStdDev, stats.echo_delay_std_ms); | 454 EXPECT_EQ(kEchoDelayStdDev, stats.echo_delay_std_ms); |
| 456 EXPECT_EQ(kEchoReturnLoss, stats.echo_return_loss); | 455 EXPECT_EQ(kEchoReturnLoss, stats.echo_return_loss); |
| 457 EXPECT_EQ(kEchoReturnLossEnhancement, stats.echo_return_loss_enhancement); | 456 EXPECT_EQ(kEchoReturnLossEnhancement, stats.echo_return_loss_enhancement); |
| 458 EXPECT_EQ(kResidualEchoLikelihood, stats.residual_echo_likelihood); | 457 EXPECT_EQ(kResidualEchoLikelihood, stats.residual_echo_likelihood); |
| 459 EXPECT_FALSE(stats.typing_noise_detected); | 458 EXPECT_TRUE(stats.typing_noise_detected); |
| 460 } | |
| 461 | |
| 462 TEST(AudioSendStreamTest, GetStatsTypingNoiseDetected) { | |
| 463 ConfigHelper helper(false, true); | |
| 464 internal::AudioSendStream send_stream( | |
| 465 helper.config(), helper.audio_state(), helper.worker_queue(), | |
| 466 helper.transport(), helper.bitrate_allocator(), helper.event_log(), | |
| 467 helper.rtcp_rtt_stats(), rtc::Optional<RtpState>()); | |
| 468 helper.SetupMockForGetStats(); | |
| 469 EXPECT_FALSE(send_stream.GetStats().typing_noise_detected); | |
| 470 | |
| 471 internal::AudioState* internal_audio_state = | |
| 472 static_cast<internal::AudioState*>(helper.audio_state().get()); | |
| 473 VoiceEngineObserver* voe_observer = | |
| 474 static_cast<VoiceEngineObserver*>(internal_audio_state); | |
| 475 voe_observer->CallbackOnError(-1, VE_TYPING_NOISE_WARNING); | |
| 476 EXPECT_TRUE(send_stream.GetStats().typing_noise_detected); | |
| 477 voe_observer->CallbackOnError(-1, VE_TYPING_NOISE_OFF_WARNING); | |
| 478 EXPECT_FALSE(send_stream.GetStats().typing_noise_detected); | |
| 479 } | 459 } |
| 480 | 460 |
| 481 TEST(AudioSendStreamTest, SendCodecAppliesAudioNetworkAdaptor) { | 461 TEST(AudioSendStreamTest, SendCodecAppliesAudioNetworkAdaptor) { |
| 482 ConfigHelper helper(false, true); | 462 ConfigHelper helper(false, true); |
| 483 auto stream_config = helper.config(); | 463 auto stream_config = helper.config(); |
| 484 stream_config.send_codec_spec = | 464 stream_config.send_codec_spec = |
| 485 rtc::Optional<AudioSendStream::Config::SendCodecSpec>({0, kOpusFormat}); | 465 rtc::Optional<AudioSendStream::Config::SendCodecSpec>({0, kOpusFormat}); |
| 486 const std::string kAnaConfigString = "abcde"; | 466 const std::string kAnaConfigString = "abcde"; |
| 487 const std::string kAnaReconfigString = "12345"; | 467 const std::string kAnaReconfigString = "12345"; |
| 488 | 468 |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 607 EXPECT_CALL(*helper.channel_proxy(), RegisterSenderCongestionControlObjects( | 587 EXPECT_CALL(*helper.channel_proxy(), RegisterSenderCongestionControlObjects( |
| 608 helper.transport(), Ne(nullptr))) | 588 helper.transport(), Ne(nullptr))) |
| 609 .Times(1); | 589 .Times(1); |
| 610 } | 590 } |
| 611 send_stream.Reconfigure(new_config); | 591 send_stream.Reconfigure(new_config); |
| 612 } | 592 } |
| 613 | 593 |
| 614 | 594 |
| 615 } // namespace test | 595 } // namespace test |
| 616 } // namespace webrtc | 596 } // namespace webrtc |
| OLD | NEW |