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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 EXPECT_CALL(*channel_proxy_, DeRegisterExternalTransport()).Times(1); | 147 EXPECT_CALL(*channel_proxy_, DeRegisterExternalTransport()).Times(1); |
148 EXPECT_CALL(*channel_proxy_, SetRtcEventLog(testing::NotNull())).Times(1); | 148 EXPECT_CALL(*channel_proxy_, SetRtcEventLog(testing::NotNull())).Times(1); |
149 EXPECT_CALL(*channel_proxy_, SetRtcEventLog(testing::IsNull())) | 149 EXPECT_CALL(*channel_proxy_, SetRtcEventLog(testing::IsNull())) |
150 .Times(1); // Destructor resets the event log | 150 .Times(1); // Destructor resets the event log |
151 EXPECT_CALL(*channel_proxy_, SetRtcpRttStats(&rtcp_rtt_stats_)).Times(1); | 151 EXPECT_CALL(*channel_proxy_, SetRtcpRttStats(&rtcp_rtt_stats_)).Times(1); |
152 EXPECT_CALL(*channel_proxy_, SetRtcpRttStats(testing::IsNull())) | 152 EXPECT_CALL(*channel_proxy_, SetRtcpRttStats(testing::IsNull())) |
153 .Times(1); // Destructor resets the rtt stats. | 153 .Times(1); // Destructor resets the rtt stats. |
154 } | 154 } |
155 | 155 |
156 void SetupMockForSetupSendCodec() { | 156 void SetupMockForSetupSendCodec() { |
157 EXPECT_CALL(voice_engine_, SetVADStatus(kChannelId, false, _, _)) | 157 EXPECT_CALL(*channel_proxy_, SetVADStatus(false)) |
158 .WillOnce(Return(0)); | 158 .WillOnce(Return(true)); |
159 EXPECT_CALL(voice_engine_, SetFECStatus(kChannelId, false)) | 159 EXPECT_CALL(*channel_proxy_, SetCodecFECStatus(false)) |
160 .WillOnce(Return(0)); | 160 .WillOnce(Return(true)); |
161 EXPECT_CALL(*channel_proxy_, DisableAudioNetworkAdaptor()); | 161 EXPECT_CALL(*channel_proxy_, DisableAudioNetworkAdaptor()); |
162 // Let |GetSendCodec| return -1 for the first time to indicate that no send | 162 // Let |GetSendCodec| return false for the first time to indicate that no |
163 // codec has been set. | 163 // send codec has been set. |
164 EXPECT_CALL(voice_engine_, GetSendCodec(kChannelId, _)) | 164 EXPECT_CALL(*channel_proxy_, GetSendCodec(_)).WillOnce(Return(false)); |
165 .WillOnce(Return(-1)); | 165 EXPECT_CALL(*channel_proxy_, SetSendCodec(_)).WillOnce(Return(true)); |
166 EXPECT_CALL(voice_engine_, SetSendCodec(kChannelId, _)).WillOnce(Return(0)); | |
167 } | 166 } |
168 RtcpRttStats* rtcp_rtt_stats() { return &rtcp_rtt_stats_; } | 167 RtcpRttStats* rtcp_rtt_stats() { return &rtcp_rtt_stats_; } |
169 | 168 |
170 void SetupMockForSendTelephoneEvent() { | 169 void SetupMockForSendTelephoneEvent() { |
171 EXPECT_TRUE(channel_proxy_); | 170 EXPECT_TRUE(channel_proxy_); |
172 EXPECT_CALL(*channel_proxy_, | 171 EXPECT_CALL(*channel_proxy_, |
173 SetSendTelephoneEventPayloadType(kTelephoneEventPayloadType, | 172 SetSendTelephoneEventPayloadType(kTelephoneEventPayloadType, |
174 kTelephoneEventPayloadFrequency)) | 173 kTelephoneEventPayloadFrequency)) |
175 .WillOnce(Return(true)); | 174 .WillOnce(Return(true)); |
176 EXPECT_CALL(*channel_proxy_, | 175 EXPECT_CALL(*channel_proxy_, |
177 SendTelephoneEventOutband(kTelephoneEventCode, kTelephoneEventDuration)) | 176 SendTelephoneEventOutband(kTelephoneEventCode, kTelephoneEventDuration)) |
178 .WillOnce(Return(true)); | 177 .WillOnce(Return(true)); |
179 } | 178 } |
180 | 179 |
181 void SetupMockForGetStats() { | 180 void SetupMockForGetStats() { |
182 using testing::DoAll; | 181 using testing::DoAll; |
| 182 using testing::SetArgPointee; |
183 using testing::SetArgReferee; | 183 using testing::SetArgReferee; |
184 | 184 |
185 std::vector<ReportBlock> report_blocks; | 185 std::vector<ReportBlock> report_blocks; |
186 webrtc::ReportBlock block = kReportBlock; | 186 webrtc::ReportBlock block = kReportBlock; |
187 report_blocks.push_back(block); // Has wrong SSRC. | 187 report_blocks.push_back(block); // Has wrong SSRC. |
188 block.source_SSRC = kSsrc; | 188 block.source_SSRC = kSsrc; |
189 report_blocks.push_back(block); // Correct block. | 189 report_blocks.push_back(block); // Correct block. |
190 block.fraction_lost = 0; | 190 block.fraction_lost = 0; |
191 report_blocks.push_back(block); // Duplicate SSRC, bad fraction_lost. | 191 report_blocks.push_back(block); // Duplicate SSRC, bad fraction_lost. |
192 | 192 |
193 EXPECT_TRUE(channel_proxy_); | 193 EXPECT_TRUE(channel_proxy_); |
194 EXPECT_CALL(*channel_proxy_, GetRTCPStatistics()) | 194 EXPECT_CALL(*channel_proxy_, GetRTCPStatistics()) |
195 .WillRepeatedly(Return(kCallStats)); | 195 .WillRepeatedly(Return(kCallStats)); |
196 EXPECT_CALL(*channel_proxy_, GetRemoteRTCPReportBlocks()) | 196 EXPECT_CALL(*channel_proxy_, GetRemoteRTCPReportBlocks()) |
197 .WillRepeatedly(Return(report_blocks)); | 197 .WillRepeatedly(Return(report_blocks)); |
198 | 198 EXPECT_CALL(*channel_proxy_, GetSendCodec(_)) |
199 EXPECT_CALL(voice_engine_, GetSendCodec(kChannelId, _)) | 199 .WillRepeatedly(DoAll(SetArgPointee<0>(kIsacCodec), Return(true))); |
200 .WillRepeatedly(DoAll(SetArgReferee<1>(kIsacCodec), Return(0))); | |
201 EXPECT_CALL(voice_engine_, GetSpeechInputLevelFullRange(_)) | 200 EXPECT_CALL(voice_engine_, GetSpeechInputLevelFullRange(_)) |
202 .WillRepeatedly(DoAll(SetArgReferee<0>(kSpeechInputLevel), Return(0))); | 201 .WillRepeatedly(DoAll(SetArgReferee<0>(kSpeechInputLevel), Return(0))); |
203 EXPECT_CALL(voice_engine_, audio_processing()) | 202 EXPECT_CALL(voice_engine_, audio_processing()) |
204 .WillRepeatedly(Return(&audio_processing_)); | 203 .WillRepeatedly(Return(&audio_processing_)); |
205 | 204 |
206 // We have to set the instantaneous value, the average, min and max. We only | 205 // We have to set the instantaneous value, the average, min and max. We only |
207 // care about the instantaneous value, so we set all to the same value. | 206 // care about the instantaneous value, so we set all to the same value. |
208 audio_processing_stats_.echo_return_loss.Set( | 207 audio_processing_stats_.echo_return_loss.Set( |
209 kEchoReturnLoss, kEchoReturnLoss, kEchoReturnLoss, kEchoReturnLoss); | 208 kEchoReturnLoss, kEchoReturnLoss, kEchoReturnLoss, kEchoReturnLoss); |
210 audio_processing_stats_.echo_return_loss_enhancement.Set( | 209 audio_processing_stats_.echo_return_loss_enhancement.Set( |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 stream_config.send_codec_spec.codec_inst = kOpusCodec; | 357 stream_config.send_codec_spec.codec_inst = kOpusCodec; |
359 stream_config.send_codec_spec.enable_codec_fec = true; | 358 stream_config.send_codec_spec.enable_codec_fec = true; |
360 stream_config.send_codec_spec.enable_opus_dtx = true; | 359 stream_config.send_codec_spec.enable_opus_dtx = true; |
361 stream_config.send_codec_spec.opus_max_playback_rate = 12345; | 360 stream_config.send_codec_spec.opus_max_playback_rate = 12345; |
362 stream_config.send_codec_spec.cng_plfreq = 16000; | 361 stream_config.send_codec_spec.cng_plfreq = 16000; |
363 stream_config.send_codec_spec.cng_payload_type = 105; | 362 stream_config.send_codec_spec.cng_payload_type = 105; |
364 stream_config.send_codec_spec.min_ptime_ms = 10; | 363 stream_config.send_codec_spec.min_ptime_ms = 10; |
365 stream_config.send_codec_spec.max_ptime_ms = 60; | 364 stream_config.send_codec_spec.max_ptime_ms = 60; |
366 stream_config.audio_network_adaptor_config = | 365 stream_config.audio_network_adaptor_config = |
367 rtc::Optional<std::string>("abced"); | 366 rtc::Optional<std::string>("abced"); |
368 EXPECT_CALL(*helper.voice_engine(), SetFECStatus(kChannelId, true)) | 367 EXPECT_CALL(*helper.channel_proxy(), SetCodecFECStatus(true)) |
369 .WillOnce(Return(0)); | 368 .WillOnce(Return(true)); |
370 EXPECT_CALL( | 369 EXPECT_CALL( |
371 *helper.voice_engine(), | 370 *helper.channel_proxy(), |
372 SetOpusDtx(kChannelId, stream_config.send_codec_spec.enable_opus_dtx)) | 371 SetOpusDtx(stream_config.send_codec_spec.enable_opus_dtx)) |
373 .WillOnce(Return(0)); | 372 .WillOnce(Return(true)); |
374 EXPECT_CALL( | 373 EXPECT_CALL( |
375 *helper.voice_engine(), | 374 *helper.channel_proxy(), |
376 SetOpusMaxPlaybackRate( | 375 SetOpusMaxPlaybackRate( |
377 kChannelId, stream_config.send_codec_spec.opus_max_playback_rate)) | 376 stream_config.send_codec_spec.opus_max_playback_rate)) |
378 .WillOnce(Return(0)); | 377 .WillOnce(Return(true)); |
379 EXPECT_CALL(*helper.voice_engine(), | 378 EXPECT_CALL(*helper.channel_proxy(), |
380 SetSendCNPayloadType( | 379 SetSendCNPayloadType( |
381 kChannelId, stream_config.send_codec_spec.cng_payload_type, | 380 stream_config.send_codec_spec.cng_payload_type, |
382 webrtc::kFreq16000Hz)) | 381 webrtc::kFreq16000Hz)) |
383 .WillOnce(Return(0)); | 382 .WillOnce(Return(true)); |
384 EXPECT_CALL( | 383 EXPECT_CALL( |
385 *helper.channel_proxy(), | 384 *helper.channel_proxy(), |
386 SetReceiverFrameLengthRange(stream_config.send_codec_spec.min_ptime_ms, | 385 SetReceiverFrameLengthRange(stream_config.send_codec_spec.min_ptime_ms, |
387 stream_config.send_codec_spec.max_ptime_ms)); | 386 stream_config.send_codec_spec.max_ptime_ms)); |
388 EXPECT_CALL( | 387 EXPECT_CALL( |
389 *helper.channel_proxy(), | 388 *helper.channel_proxy(), |
390 EnableAudioNetworkAdaptor(*stream_config.audio_network_adaptor_config)); | 389 EnableAudioNetworkAdaptor(*stream_config.audio_network_adaptor_config)); |
391 internal::AudioSendStream send_stream( | 390 internal::AudioSendStream send_stream( |
392 stream_config, helper.audio_state(), helper.worker_queue(), | 391 stream_config, helper.audio_state(), helper.worker_queue(), |
393 helper.packet_router(), helper.congestion_controller(), | 392 helper.packet_router(), helper.congestion_controller(), |
394 helper.bitrate_allocator(), helper.event_log(), helper.rtcp_rtt_stats()); | 393 helper.bitrate_allocator(), helper.event_log(), helper.rtcp_rtt_stats()); |
395 } | 394 } |
396 | 395 |
397 // VAD is applied when codec is mono and the CNG frequency matches the codec | 396 // VAD is applied when codec is mono and the CNG frequency matches the codec |
398 // sample rate. | 397 // sample rate. |
399 TEST(AudioSendStreamTest, SendCodecCanApplyVad) { | 398 TEST(AudioSendStreamTest, SendCodecCanApplyVad) { |
400 ConfigHelper helper; | 399 ConfigHelper helper; |
401 auto stream_config = helper.config(); | 400 auto stream_config = helper.config(); |
402 const CodecInst kG722Codec = {9, "g722", 8000, 160, 1, 16000}; | 401 const CodecInst kG722Codec = {9, "g722", 8000, 160, 1, 16000}; |
403 stream_config.send_codec_spec.codec_inst = kG722Codec; | 402 stream_config.send_codec_spec.codec_inst = kG722Codec; |
404 stream_config.send_codec_spec.cng_plfreq = 8000; | 403 stream_config.send_codec_spec.cng_plfreq = 8000; |
405 stream_config.send_codec_spec.cng_payload_type = 105; | 404 stream_config.send_codec_spec.cng_payload_type = 105; |
406 EXPECT_CALL(*helper.voice_engine(), SetVADStatus(kChannelId, true, _, _)) | 405 EXPECT_CALL(*helper.channel_proxy(), SetVADStatus(true)) |
407 .WillOnce(Return(0)); | 406 .WillOnce(Return(true)); |
408 internal::AudioSendStream send_stream( | 407 internal::AudioSendStream send_stream( |
409 stream_config, helper.audio_state(), helper.worker_queue(), | 408 stream_config, helper.audio_state(), helper.worker_queue(), |
410 helper.packet_router(), helper.congestion_controller(), | 409 helper.packet_router(), helper.congestion_controller(), |
411 helper.bitrate_allocator(), helper.event_log(), helper.rtcp_rtt_stats()); | 410 helper.bitrate_allocator(), helper.event_log(), helper.rtcp_rtt_stats()); |
412 } | 411 } |
413 | 412 |
414 TEST(AudioSendStreamTest, DoesNotPassHigherBitrateThanMaxBitrate) { | 413 TEST(AudioSendStreamTest, DoesNotPassHigherBitrateThanMaxBitrate) { |
415 ConfigHelper helper; | 414 ConfigHelper helper; |
416 internal::AudioSendStream send_stream( | 415 internal::AudioSendStream send_stream( |
417 helper.config(), helper.audio_state(), helper.worker_queue(), | 416 helper.config(), helper.audio_state(), helper.worker_queue(), |
(...skipping 10 matching lines...) Expand all Loading... |
428 internal::AudioSendStream send_stream( | 427 internal::AudioSendStream send_stream( |
429 helper.config(), helper.audio_state(), helper.worker_queue(), | 428 helper.config(), helper.audio_state(), helper.worker_queue(), |
430 helper.packet_router(), helper.congestion_controller(), | 429 helper.packet_router(), helper.congestion_controller(), |
431 helper.bitrate_allocator(), helper.event_log(), helper.rtcp_rtt_stats()); | 430 helper.bitrate_allocator(), helper.event_log(), helper.rtcp_rtt_stats()); |
432 EXPECT_CALL(*helper.channel_proxy(), SetBitrate(_, 5000)); | 431 EXPECT_CALL(*helper.channel_proxy(), SetBitrate(_, 5000)); |
433 send_stream.OnBitrateUpdated(50000, 0.0, 50, 5000); | 432 send_stream.OnBitrateUpdated(50000, 0.0, 50, 5000); |
434 } | 433 } |
435 | 434 |
436 } // namespace test | 435 } // namespace test |
437 } // namespace webrtc | 436 } // namespace webrtc |
OLD | NEW |