Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(810)

Side by Side Diff: webrtc/audio/audio_send_stream_unittest.cc

Issue 2948763002: Allow an external audio processing module to be used in WebRTC (Closed)
Patch Set: tracking linux32_rel issue Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 .WillByDefault(Invoke([](int payload_type, const SdpAudioFormat& format, 121 .WillByDefault(Invoke([](int payload_type, const SdpAudioFormat& format,
122 std::unique_ptr<AudioEncoder>* return_value) { 122 std::unique_ptr<AudioEncoder>* return_value) {
123 *return_value = SetupAudioEncoderMock(payload_type, format); 123 *return_value = SetupAudioEncoderMock(payload_type, format);
124 })); 124 }));
125 return factory; 125 return factory;
126 } 126 }
127 127
128 struct ConfigHelper { 128 struct ConfigHelper {
129 ConfigHelper(bool audio_bwe_enabled, bool expect_set_encoder_call) 129 ConfigHelper(bool audio_bwe_enabled, bool expect_set_encoder_call)
130 : stream_config_(nullptr), 130 : stream_config_(nullptr),
131 audio_processing_(new rtc::RefCountedObject<MockAudioProcessing>()),
131 simulated_clock_(123456), 132 simulated_clock_(123456),
132 send_side_cc_(rtc::MakeUnique<SendSideCongestionController>( 133 send_side_cc_(rtc::MakeUnique<SendSideCongestionController>(
133 &simulated_clock_, 134 &simulated_clock_,
134 nullptr /* observer */, 135 nullptr /* observer */,
135 &event_log_, 136 &event_log_,
136 &packet_router_)), 137 &packet_router_)),
137 fake_transport_(&packet_router_, send_side_cc_.get()), 138 fake_transport_(&packet_router_, send_side_cc_.get()),
138 bitrate_allocator_(&limit_observer_), 139 bitrate_allocator_(&limit_observer_),
139 worker_queue_("ConfigHelper_worker_queue") { 140 worker_queue_("ConfigHelper_worker_queue") {
140 using testing::Invoke; 141 using testing::Invoke;
141 142
142 EXPECT_CALL(voice_engine_, 143 EXPECT_CALL(voice_engine_,
143 RegisterVoiceEngineObserver(_)).WillOnce(Return(0)); 144 RegisterVoiceEngineObserver(_)).WillOnce(Return(0));
144 EXPECT_CALL(voice_engine_, 145 EXPECT_CALL(voice_engine_,
145 DeRegisterVoiceEngineObserver()).WillOnce(Return(0)); 146 DeRegisterVoiceEngineObserver()).WillOnce(Return(0));
146 EXPECT_CALL(voice_engine_, audio_device_module()); 147 EXPECT_CALL(voice_engine_, audio_device_module());
147 EXPECT_CALL(voice_engine_, audio_processing());
148 EXPECT_CALL(voice_engine_, audio_transport()); 148 EXPECT_CALL(voice_engine_, audio_transport());
149 149
150 AudioState::Config config; 150 AudioState::Config config;
151 config.voice_engine = &voice_engine_; 151 config.voice_engine = &voice_engine_;
152 config.audio_mixer = AudioMixerImpl::Create(); 152 config.audio_mixer = AudioMixerImpl::Create();
153 config.audio_processing = audio_processing_;
153 audio_state_ = AudioState::Create(config); 154 audio_state_ = AudioState::Create(config);
154 155
155 SetupDefaultChannelProxy(audio_bwe_enabled); 156 SetupDefaultChannelProxy(audio_bwe_enabled);
156 157
157 EXPECT_CALL(voice_engine_, ChannelProxyFactory(kChannelId)) 158 EXPECT_CALL(voice_engine_, ChannelProxyFactory(kChannelId))
158 .WillOnce(Invoke([this](int channel_id) { 159 .WillOnce(Invoke([this](int channel_id) {
159 return channel_proxy_; 160 return channel_proxy_;
160 })); 161 }));
161 162
162 SetupMockForSetupSendCodec(expect_set_encoder_call); 163 SetupMockForSetupSendCodec(expect_set_encoder_call);
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 block.fraction_lost = 0; 272 block.fraction_lost = 0;
272 report_blocks.push_back(block); // Duplicate SSRC, bad fraction_lost. 273 report_blocks.push_back(block); // Duplicate SSRC, bad fraction_lost.
273 274
274 EXPECT_TRUE(channel_proxy_); 275 EXPECT_TRUE(channel_proxy_);
275 EXPECT_CALL(*channel_proxy_, GetRTCPStatistics()) 276 EXPECT_CALL(*channel_proxy_, GetRTCPStatistics())
276 .WillRepeatedly(Return(kCallStats)); 277 .WillRepeatedly(Return(kCallStats));
277 EXPECT_CALL(*channel_proxy_, GetRemoteRTCPReportBlocks()) 278 EXPECT_CALL(*channel_proxy_, GetRemoteRTCPReportBlocks())
278 .WillRepeatedly(Return(report_blocks)); 279 .WillRepeatedly(Return(report_blocks));
279 EXPECT_CALL(voice_engine_, transmit_mixer()) 280 EXPECT_CALL(voice_engine_, transmit_mixer())
280 .WillRepeatedly(Return(&transmit_mixer_)); 281 .WillRepeatedly(Return(&transmit_mixer_));
281 EXPECT_CALL(voice_engine_, audio_processing())
282 .WillRepeatedly(Return(&audio_processing_));
283 282
284 EXPECT_CALL(transmit_mixer_, AudioLevelFullRange()) 283 EXPECT_CALL(transmit_mixer_, AudioLevelFullRange())
285 .WillRepeatedly(Return(kSpeechInputLevel)); 284 .WillRepeatedly(Return(kSpeechInputLevel));
286 285
287 // We have to set the instantaneous value, the average, min and max. We only 286 // We have to set the instantaneous value, the average, min and max. We only
288 // care about the instantaneous value, so we set all to the same value. 287 // care about the instantaneous value, so we set all to the same value.
289 audio_processing_stats_.echo_return_loss.Set( 288 audio_processing_stats_.echo_return_loss.Set(
290 kEchoReturnLoss, kEchoReturnLoss, kEchoReturnLoss, kEchoReturnLoss); 289 kEchoReturnLoss, kEchoReturnLoss, kEchoReturnLoss, kEchoReturnLoss);
291 audio_processing_stats_.echo_return_loss_enhancement.Set( 290 audio_processing_stats_.echo_return_loss_enhancement.Set(
292 kEchoReturnLossEnhancement, kEchoReturnLossEnhancement, 291 kEchoReturnLossEnhancement, kEchoReturnLossEnhancement,
293 kEchoReturnLossEnhancement, kEchoReturnLossEnhancement); 292 kEchoReturnLossEnhancement, kEchoReturnLossEnhancement);
294 audio_processing_stats_.delay_median = kEchoDelayMedian; 293 audio_processing_stats_.delay_median = kEchoDelayMedian;
295 audio_processing_stats_.delay_standard_deviation = kEchoDelayStdDev; 294 audio_processing_stats_.delay_standard_deviation = kEchoDelayStdDev;
296 295
297 EXPECT_CALL(audio_processing_, GetStatistics()) 296 EXPECT_CALL(*audio_processing_, GetStatistics())
298 .WillRepeatedly(Return(audio_processing_stats_)); 297 .WillRepeatedly(Return(audio_processing_stats_));
299 } 298 }
300 299
301 private: 300 private:
302 testing::StrictMock<MockVoiceEngine> voice_engine_; 301 testing::StrictMock<MockVoiceEngine> voice_engine_;
303 rtc::scoped_refptr<AudioState> audio_state_; 302 rtc::scoped_refptr<AudioState> audio_state_;
304 AudioSendStream::Config stream_config_; 303 AudioSendStream::Config stream_config_;
305 testing::StrictMock<MockVoEChannelProxy>* channel_proxy_ = nullptr; 304 testing::StrictMock<MockVoEChannelProxy>* channel_proxy_ = nullptr;
306 MockAudioProcessing audio_processing_; 305 rtc::scoped_refptr<MockAudioProcessing> audio_processing_;
307 MockTransmitMixer transmit_mixer_; 306 MockTransmitMixer transmit_mixer_;
308 AudioProcessing::AudioProcessingStatistics audio_processing_stats_; 307 AudioProcessing::AudioProcessingStatistics audio_processing_stats_;
309 SimulatedClock simulated_clock_; 308 SimulatedClock simulated_clock_;
310 PacketRouter packet_router_; 309 PacketRouter packet_router_;
311 std::unique_ptr<SendSideCongestionController> send_side_cc_; 310 std::unique_ptr<SendSideCongestionController> send_side_cc_;
312 FakeRtpTransportControllerSend fake_transport_; 311 FakeRtpTransportControllerSend fake_transport_;
313 MockRtcEventLog event_log_; 312 MockRtcEventLog event_log_;
314 MockRtpRtcp rtp_rtcp_; 313 MockRtpRtcp rtp_rtcp_;
315 MockRtcpRttStats rtcp_rtt_stats_; 314 MockRtcpRttStats rtcp_rtt_stats_;
316 testing::NiceMock<MockLimitObserver> limit_observer_; 315 testing::NiceMock<MockLimitObserver> limit_observer_;
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 stream_config.send_codec_spec->cng_payload_type = rtc::Optional<int>(105); 536 stream_config.send_codec_spec->cng_payload_type = rtc::Optional<int>(105);
538 internal::AudioSendStream send_stream( 537 internal::AudioSendStream send_stream(
539 stream_config, helper.audio_state(), helper.worker_queue(), 538 stream_config, helper.audio_state(), helper.worker_queue(),
540 helper.transport(), helper.bitrate_allocator(), helper.event_log(), 539 helper.transport(), helper.bitrate_allocator(), helper.event_log(),
541 helper.rtcp_rtt_stats(), rtc::Optional<RtpState>()); 540 helper.rtcp_rtt_stats(), rtc::Optional<RtpState>());
542 send_stream.Reconfigure(stream_config); 541 send_stream.Reconfigure(stream_config);
543 } 542 }
544 543
545 } // namespace test 544 } // namespace test
546 } // namespace webrtc 545 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698