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 |
11 #include <string> | 11 #include <string> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "webrtc/audio/audio_send_stream.h" | 14 #include "webrtc/audio/audio_send_stream.h" |
15 #include "webrtc/audio/audio_state.h" | 15 #include "webrtc/audio/audio_state.h" |
16 #include "webrtc/audio/conversion.h" | 16 #include "webrtc/audio/conversion.h" |
17 #include "webrtc/base/task_queue.h" | 17 #include "webrtc/base/task_queue.h" |
| 18 #include "webrtc/call/rtp_transport_controller.h" |
18 #include "webrtc/logging/rtc_event_log/mock/mock_rtc_event_log.h" | 19 #include "webrtc/logging/rtc_event_log/mock/mock_rtc_event_log.h" |
19 #include "webrtc/modules/audio_mixer/audio_mixer_impl.h" | 20 #include "webrtc/modules/audio_mixer/audio_mixer_impl.h" |
20 #include "webrtc/modules/audio_processing/include/mock_audio_processing.h" | 21 #include "webrtc/modules/audio_processing/include/mock_audio_processing.h" |
21 #include "webrtc/modules/congestion_controller/include/congestion_controller.h" | 22 #include "webrtc/modules/congestion_controller/include/congestion_controller.h" |
22 #include "webrtc/modules/congestion_controller/include/mock/mock_congestion_cont
roller.h" | 23 #include "webrtc/modules/congestion_controller/include/mock/mock_congestion_cont
roller.h" |
23 #include "webrtc/modules/pacing/paced_sender.h" | 24 #include "webrtc/modules/pacing/paced_sender.h" |
24 #include "webrtc/modules/remote_bitrate_estimator/include/mock/mock_remote_bitra
te_estimator.h" | 25 #include "webrtc/modules/remote_bitrate_estimator/include/mock/mock_remote_bitra
te_estimator.h" |
25 #include "webrtc/modules/rtp_rtcp/mocks/mock_rtcp_rtt_stats.h" | 26 #include "webrtc/modules/rtp_rtcp/mocks/mock_rtcp_rtt_stats.h" |
26 #include "webrtc/test/gtest.h" | 27 #include "webrtc/test/gtest.h" |
27 #include "webrtc/test/mock_voe_channel_proxy.h" | 28 #include "webrtc/test/mock_voe_channel_proxy.h" |
(...skipping 29 matching lines...) Expand all Loading... |
57 const CodecInst kIsacCodec = {103, "isac", 16000, 320, 1, 32000}; | 58 const CodecInst kIsacCodec = {103, "isac", 16000, 320, 1, 32000}; |
58 | 59 |
59 class MockLimitObserver : public BitrateAllocator::LimitObserver { | 60 class MockLimitObserver : public BitrateAllocator::LimitObserver { |
60 public: | 61 public: |
61 MOCK_METHOD2(OnAllocationLimitsChanged, | 62 MOCK_METHOD2(OnAllocationLimitsChanged, |
62 void(uint32_t min_send_bitrate_bps, | 63 void(uint32_t min_send_bitrate_bps, |
63 uint32_t max_padding_bitrate_bps)); | 64 uint32_t max_padding_bitrate_bps)); |
64 }; | 65 }; |
65 | 66 |
66 struct ConfigHelper { | 67 struct ConfigHelper { |
| 68 class FakeRtpTransportController |
| 69 : public RtpTransportControllerSendInterface { |
| 70 public: |
| 71 explicit FakeRtpTransportController(RtcEventLog* event_log) |
| 72 : simulated_clock_(123456), |
| 73 congestion_controller_(&simulated_clock_, |
| 74 &bitrate_observer_, |
| 75 &remote_bitrate_observer_, |
| 76 event_log, |
| 77 &packet_router_) {} |
| 78 CongestionController* congestion_controller() override { |
| 79 return &congestion_controller_; |
| 80 } |
| 81 VieRemb* remb() override { return nullptr; } |
| 82 PacketRouter* packet_router() override { return &packet_router_; } |
| 83 |
| 84 private: |
| 85 SimulatedClock simulated_clock_; |
| 86 testing::NiceMock<MockCongestionObserver> bitrate_observer_; |
| 87 testing::NiceMock<MockRemoteBitrateObserver> remote_bitrate_observer_; |
| 88 PacketRouter packet_router_; |
| 89 CongestionController congestion_controller_; |
| 90 }; |
| 91 |
67 explicit ConfigHelper(bool audio_bwe_enabled) | 92 explicit ConfigHelper(bool audio_bwe_enabled) |
68 : simulated_clock_(123456), | 93 : stream_config_(nullptr), |
69 stream_config_(nullptr), | 94 fake_transport_(&event_log_), |
70 congestion_controller_(&simulated_clock_, | |
71 &bitrate_observer_, | |
72 &remote_bitrate_observer_, | |
73 &event_log_, | |
74 &packet_router_), | |
75 bitrate_allocator_(&limit_observer_), | 95 bitrate_allocator_(&limit_observer_), |
76 worker_queue_("ConfigHelper_worker_queue") { | 96 worker_queue_("ConfigHelper_worker_queue") { |
77 using testing::Invoke; | 97 using testing::Invoke; |
78 | 98 |
79 EXPECT_CALL(voice_engine_, | 99 EXPECT_CALL(voice_engine_, |
80 RegisterVoiceEngineObserver(_)).WillOnce(Return(0)); | 100 RegisterVoiceEngineObserver(_)).WillOnce(Return(0)); |
81 EXPECT_CALL(voice_engine_, | 101 EXPECT_CALL(voice_engine_, |
82 DeRegisterVoiceEngineObserver()).WillOnce(Return(0)); | 102 DeRegisterVoiceEngineObserver()).WillOnce(Return(0)); |
83 EXPECT_CALL(voice_engine_, audio_device_module()); | 103 EXPECT_CALL(voice_engine_, audio_device_module()); |
84 EXPECT_CALL(voice_engine_, audio_processing()); | 104 EXPECT_CALL(voice_engine_, audio_processing()); |
(...skipping 28 matching lines...) Expand all Loading... |
113 // Use ISAC as default codec so as to prevent unnecessary |voice_engine_| | 133 // Use ISAC as default codec so as to prevent unnecessary |voice_engine_| |
114 // calls from the default ctor behavior. | 134 // calls from the default ctor behavior. |
115 stream_config_.send_codec_spec.codec_inst = kIsacCodec; | 135 stream_config_.send_codec_spec.codec_inst = kIsacCodec; |
116 stream_config_.min_bitrate_bps = 10000; | 136 stream_config_.min_bitrate_bps = 10000; |
117 stream_config_.max_bitrate_bps = 65000; | 137 stream_config_.max_bitrate_bps = 65000; |
118 } | 138 } |
119 | 139 |
120 AudioSendStream::Config& config() { return stream_config_; } | 140 AudioSendStream::Config& config() { return stream_config_; } |
121 rtc::scoped_refptr<AudioState> audio_state() { return audio_state_; } | 141 rtc::scoped_refptr<AudioState> audio_state() { return audio_state_; } |
122 MockVoEChannelProxy* channel_proxy() { return channel_proxy_; } | 142 MockVoEChannelProxy* channel_proxy() { return channel_proxy_; } |
123 PacketRouter* packet_router() { return &packet_router_; } | 143 RtpTransportControllerSendInterface* transport() { return &fake_transport_; } |
124 CongestionController* congestion_controller() { | |
125 return &congestion_controller_; | |
126 } | |
127 BitrateAllocator* bitrate_allocator() { return &bitrate_allocator_; } | 144 BitrateAllocator* bitrate_allocator() { return &bitrate_allocator_; } |
128 rtc::TaskQueue* worker_queue() { return &worker_queue_; } | 145 rtc::TaskQueue* worker_queue() { return &worker_queue_; } |
129 RtcEventLog* event_log() { return &event_log_; } | 146 RtcEventLog* event_log() { return &event_log_; } |
130 MockVoiceEngine* voice_engine() { return &voice_engine_; } | 147 MockVoiceEngine* voice_engine() { return &voice_engine_; } |
131 | 148 |
132 void SetupDefaultChannelProxy(bool audio_bwe_enabled) { | 149 void SetupDefaultChannelProxy(bool audio_bwe_enabled) { |
133 using testing::StrEq; | 150 using testing::StrEq; |
134 channel_proxy_ = new testing::StrictMock<MockVoEChannelProxy>(); | 151 channel_proxy_ = new testing::StrictMock<MockVoEChannelProxy>(); |
135 EXPECT_CALL(*channel_proxy_, SetRTCPStatus(true)).Times(1); | 152 EXPECT_CALL(*channel_proxy_, SetRTCPStatus(true)).Times(1); |
136 EXPECT_CALL(*channel_proxy_, SetLocalSSRC(kSsrc)).Times(1); | 153 EXPECT_CALL(*channel_proxy_, SetLocalSSRC(kSsrc)).Times(1); |
137 EXPECT_CALL(*channel_proxy_, SetRTCP_CNAME(StrEq(kCName))).Times(1); | 154 EXPECT_CALL(*channel_proxy_, SetRTCP_CNAME(StrEq(kCName))).Times(1); |
138 EXPECT_CALL(*channel_proxy_, SetNACKStatus(true, 10)).Times(1); | 155 EXPECT_CALL(*channel_proxy_, SetNACKStatus(true, 10)).Times(1); |
139 EXPECT_CALL(*channel_proxy_, | 156 EXPECT_CALL(*channel_proxy_, |
140 SetSendAudioLevelIndicationStatus(true, kAudioLevelId)) | 157 SetSendAudioLevelIndicationStatus(true, kAudioLevelId)) |
141 .Times(1); | 158 .Times(1); |
142 | |
143 if (audio_bwe_enabled) { | 159 if (audio_bwe_enabled) { |
144 EXPECT_CALL(*channel_proxy_, | 160 EXPECT_CALL(*channel_proxy_, |
145 EnableSendTransportSequenceNumber(kTransportSequenceNumberId)) | 161 EnableSendTransportSequenceNumber(kTransportSequenceNumberId)) |
146 .Times(1); | 162 .Times(1); |
147 EXPECT_CALL(*channel_proxy_, | 163 EXPECT_CALL(*channel_proxy_, RegisterSenderCongestionControlObjects( |
148 RegisterSenderCongestionControlObjects( | 164 &fake_transport_, Ne(nullptr))) |
149 congestion_controller_.pacer(), | |
150 congestion_controller_.GetTransportFeedbackObserver(), | |
151 packet_router(), Ne(nullptr))) | |
152 .Times(1); | 165 .Times(1); |
153 } else { | 166 } else { |
154 EXPECT_CALL(*channel_proxy_, | 167 EXPECT_CALL(*channel_proxy_, RegisterSenderCongestionControlObjects( |
155 RegisterSenderCongestionControlObjects( | 168 &fake_transport_, Eq(nullptr))) |
156 congestion_controller_.pacer(), | |
157 congestion_controller_.GetTransportFeedbackObserver(), | |
158 packet_router(), Eq(nullptr))) | |
159 .Times(1); | 169 .Times(1); |
160 } | 170 } |
161 EXPECT_CALL(*channel_proxy_, ResetCongestionControlObjects()).Times(1); | 171 EXPECT_CALL(*channel_proxy_, ResetCongestionControlObjects()).Times(1); |
162 EXPECT_CALL(*channel_proxy_, RegisterExternalTransport(nullptr)).Times(1); | 172 EXPECT_CALL(*channel_proxy_, RegisterExternalTransport(nullptr)).Times(1); |
163 EXPECT_CALL(*channel_proxy_, DeRegisterExternalTransport()).Times(1); | 173 EXPECT_CALL(*channel_proxy_, DeRegisterExternalTransport()).Times(1); |
164 EXPECT_CALL(*channel_proxy_, SetRtcEventLog(testing::NotNull())).Times(1); | 174 EXPECT_CALL(*channel_proxy_, SetRtcEventLog(testing::NotNull())).Times(1); |
165 EXPECT_CALL(*channel_proxy_, SetRtcEventLog(testing::IsNull())) | 175 EXPECT_CALL(*channel_proxy_, SetRtcEventLog(testing::IsNull())) |
166 .Times(1); // Destructor resets the event log | 176 .Times(1); // Destructor resets the event log |
167 EXPECT_CALL(*channel_proxy_, SetRtcpRttStats(&rtcp_rtt_stats_)).Times(1); | 177 EXPECT_CALL(*channel_proxy_, SetRtcpRttStats(&rtcp_rtt_stats_)).Times(1); |
168 EXPECT_CALL(*channel_proxy_, SetRtcpRttStats(testing::IsNull())) | 178 EXPECT_CALL(*channel_proxy_, SetRtcpRttStats(testing::IsNull())) |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 kEchoReturnLossEnhancement, kEchoReturnLossEnhancement, | 236 kEchoReturnLossEnhancement, kEchoReturnLossEnhancement, |
227 kEchoReturnLossEnhancement, kEchoReturnLossEnhancement); | 237 kEchoReturnLossEnhancement, kEchoReturnLossEnhancement); |
228 audio_processing_stats_.delay_median = kEchoDelayMedian; | 238 audio_processing_stats_.delay_median = kEchoDelayMedian; |
229 audio_processing_stats_.delay_standard_deviation = kEchoDelayStdDev; | 239 audio_processing_stats_.delay_standard_deviation = kEchoDelayStdDev; |
230 | 240 |
231 EXPECT_CALL(audio_processing_, GetStatistics()) | 241 EXPECT_CALL(audio_processing_, GetStatistics()) |
232 .WillRepeatedly(Return(audio_processing_stats_)); | 242 .WillRepeatedly(Return(audio_processing_stats_)); |
233 } | 243 } |
234 | 244 |
235 private: | 245 private: |
236 SimulatedClock simulated_clock_; | |
237 testing::StrictMock<MockVoiceEngine> voice_engine_; | 246 testing::StrictMock<MockVoiceEngine> voice_engine_; |
238 rtc::scoped_refptr<AudioState> audio_state_; | 247 rtc::scoped_refptr<AudioState> audio_state_; |
239 AudioSendStream::Config stream_config_; | 248 AudioSendStream::Config stream_config_; |
240 testing::StrictMock<MockVoEChannelProxy>* channel_proxy_ = nullptr; | 249 testing::StrictMock<MockVoEChannelProxy>* channel_proxy_ = nullptr; |
241 testing::NiceMock<MockCongestionObserver> bitrate_observer_; | |
242 testing::NiceMock<MockRemoteBitrateObserver> remote_bitrate_observer_; | |
243 MockAudioProcessing audio_processing_; | 250 MockAudioProcessing audio_processing_; |
244 AudioProcessing::AudioProcessingStatistics audio_processing_stats_; | 251 AudioProcessing::AudioProcessingStatistics audio_processing_stats_; |
245 PacketRouter packet_router_; | 252 FakeRtpTransportController fake_transport_; |
246 CongestionController congestion_controller_; | |
247 MockRtcEventLog event_log_; | 253 MockRtcEventLog event_log_; |
248 MockRtcpRttStats rtcp_rtt_stats_; | 254 MockRtcpRttStats rtcp_rtt_stats_; |
249 testing::NiceMock<MockLimitObserver> limit_observer_; | 255 testing::NiceMock<MockLimitObserver> limit_observer_; |
250 BitrateAllocator bitrate_allocator_; | 256 BitrateAllocator bitrate_allocator_; |
251 // |worker_queue| is defined last to ensure all pending tasks are cancelled | 257 // |worker_queue| is defined last to ensure all pending tasks are cancelled |
252 // and deleted before any other members. | 258 // and deleted before any other members. |
253 rtc::TaskQueue worker_queue_; | 259 rtc::TaskQueue worker_queue_; |
254 }; | 260 }; |
255 } // namespace | 261 } // namespace |
256 | 262 |
(...skipping 26 matching lines...) Expand all Loading... |
283 "32000, cng_payload_type: 42, cng_plfreq: 56, min_ptime: 20, max_ptime: " | 289 "32000, cng_payload_type: 42, cng_plfreq: 56, min_ptime: 20, max_ptime: " |
284 "60, codec_inst: {pltype: 103, plname: \"isac\", plfreq: 16000, pacsize: " | 290 "60, codec_inst: {pltype: 103, plname: \"isac\", plfreq: 16000, pacsize: " |
285 "320, channels: 1, rate: 32000}}}", | 291 "320, channels: 1, rate: 32000}}}", |
286 config.ToString()); | 292 config.ToString()); |
287 } | 293 } |
288 | 294 |
289 TEST(AudioSendStreamTest, ConstructDestruct) { | 295 TEST(AudioSendStreamTest, ConstructDestruct) { |
290 ConfigHelper helper(false); | 296 ConfigHelper helper(false); |
291 internal::AudioSendStream send_stream( | 297 internal::AudioSendStream send_stream( |
292 helper.config(), helper.audio_state(), helper.worker_queue(), | 298 helper.config(), helper.audio_state(), helper.worker_queue(), |
293 helper.packet_router(), helper.congestion_controller(), | 299 helper.transport(), helper.bitrate_allocator(), helper.event_log(), |
294 helper.bitrate_allocator(), helper.event_log(), helper.rtcp_rtt_stats()); | 300 helper.rtcp_rtt_stats()); |
295 } | 301 } |
296 | 302 |
297 TEST(AudioSendStreamTest, SendTelephoneEvent) { | 303 TEST(AudioSendStreamTest, SendTelephoneEvent) { |
298 ConfigHelper helper(false); | 304 ConfigHelper helper(false); |
299 internal::AudioSendStream send_stream( | 305 internal::AudioSendStream send_stream( |
300 helper.config(), helper.audio_state(), helper.worker_queue(), | 306 helper.config(), helper.audio_state(), helper.worker_queue(), |
301 helper.packet_router(), helper.congestion_controller(), | 307 helper.transport(), helper.bitrate_allocator(), helper.event_log(), |
302 helper.bitrate_allocator(), helper.event_log(), helper.rtcp_rtt_stats()); | 308 helper.rtcp_rtt_stats()); |
303 helper.SetupMockForSendTelephoneEvent(); | 309 helper.SetupMockForSendTelephoneEvent(); |
304 EXPECT_TRUE(send_stream.SendTelephoneEvent(kTelephoneEventPayloadType, | 310 EXPECT_TRUE(send_stream.SendTelephoneEvent(kTelephoneEventPayloadType, |
305 kTelephoneEventPayloadFrequency, kTelephoneEventCode, | 311 kTelephoneEventPayloadFrequency, kTelephoneEventCode, |
306 kTelephoneEventDuration)); | 312 kTelephoneEventDuration)); |
307 } | 313 } |
308 | 314 |
309 TEST(AudioSendStreamTest, SetMuted) { | 315 TEST(AudioSendStreamTest, SetMuted) { |
310 ConfigHelper helper(false); | 316 ConfigHelper helper(false); |
311 internal::AudioSendStream send_stream( | 317 internal::AudioSendStream send_stream( |
312 helper.config(), helper.audio_state(), helper.worker_queue(), | 318 helper.config(), helper.audio_state(), helper.worker_queue(), |
313 helper.packet_router(), helper.congestion_controller(), | 319 helper.transport(), helper.bitrate_allocator(), helper.event_log(), |
314 helper.bitrate_allocator(), helper.event_log(), helper.rtcp_rtt_stats()); | 320 helper.rtcp_rtt_stats()); |
315 EXPECT_CALL(*helper.channel_proxy(), SetInputMute(true)); | 321 EXPECT_CALL(*helper.channel_proxy(), SetInputMute(true)); |
316 send_stream.SetMuted(true); | 322 send_stream.SetMuted(true); |
317 } | 323 } |
318 | 324 |
319 TEST(AudioSendStreamTest, AudioBweCorrectObjectsOnChannelProxy) { | 325 TEST(AudioSendStreamTest, AudioBweCorrectObjectsOnChannelProxy) { |
320 ConfigHelper helper(true); | 326 ConfigHelper helper(true); |
321 internal::AudioSendStream send_stream( | 327 internal::AudioSendStream send_stream( |
322 helper.config(), helper.audio_state(), helper.worker_queue(), | 328 helper.config(), helper.audio_state(), helper.worker_queue(), |
323 helper.packet_router(), helper.congestion_controller(), | 329 helper.transport(), helper.bitrate_allocator(), helper.event_log(), |
324 helper.bitrate_allocator(), helper.event_log(), helper.rtcp_rtt_stats()); | 330 helper.rtcp_rtt_stats()); |
325 } | 331 } |
326 | 332 |
327 TEST(AudioSendStreamTest, NoAudioBweCorrectObjectsOnChannelProxy) { | 333 TEST(AudioSendStreamTest, NoAudioBweCorrectObjectsOnChannelProxy) { |
328 ConfigHelper helper(false); | 334 ConfigHelper helper(false); |
329 internal::AudioSendStream send_stream( | 335 internal::AudioSendStream send_stream( |
330 helper.config(), helper.audio_state(), helper.worker_queue(), | 336 helper.config(), helper.audio_state(), helper.worker_queue(), |
331 helper.packet_router(), helper.congestion_controller(), | 337 helper.transport(), helper.bitrate_allocator(), helper.event_log(), |
332 helper.bitrate_allocator(), helper.event_log(), helper.rtcp_rtt_stats()); | 338 helper.rtcp_rtt_stats()); |
333 } | 339 } |
334 | 340 |
335 TEST(AudioSendStreamTest, GetStats) { | 341 TEST(AudioSendStreamTest, GetStats) { |
336 ConfigHelper helper(false); | 342 ConfigHelper helper(false); |
337 internal::AudioSendStream send_stream( | 343 internal::AudioSendStream send_stream( |
338 helper.config(), helper.audio_state(), helper.worker_queue(), | 344 helper.config(), helper.audio_state(), helper.worker_queue(), |
339 helper.packet_router(), helper.congestion_controller(), | 345 helper.transport(), helper.bitrate_allocator(), helper.event_log(), |
340 helper.bitrate_allocator(), helper.event_log(), helper.rtcp_rtt_stats()); | 346 helper.rtcp_rtt_stats()); |
341 helper.SetupMockForGetStats(); | 347 helper.SetupMockForGetStats(); |
342 AudioSendStream::Stats stats = send_stream.GetStats(); | 348 AudioSendStream::Stats stats = send_stream.GetStats(); |
343 EXPECT_EQ(kSsrc, stats.local_ssrc); | 349 EXPECT_EQ(kSsrc, stats.local_ssrc); |
344 EXPECT_EQ(static_cast<int64_t>(kCallStats.bytesSent), stats.bytes_sent); | 350 EXPECT_EQ(static_cast<int64_t>(kCallStats.bytesSent), stats.bytes_sent); |
345 EXPECT_EQ(kCallStats.packetsSent, stats.packets_sent); | 351 EXPECT_EQ(kCallStats.packetsSent, stats.packets_sent); |
346 EXPECT_EQ(static_cast<int32_t>(kReportBlock.cumulative_num_packets_lost), | 352 EXPECT_EQ(static_cast<int32_t>(kReportBlock.cumulative_num_packets_lost), |
347 stats.packets_lost); | 353 stats.packets_lost); |
348 EXPECT_EQ(Q8ToFloat(kReportBlock.fraction_lost), stats.fraction_lost); | 354 EXPECT_EQ(Q8ToFloat(kReportBlock.fraction_lost), stats.fraction_lost); |
349 EXPECT_EQ(std::string(kIsacCodec.plname), stats.codec_name); | 355 EXPECT_EQ(std::string(kIsacCodec.plname), stats.codec_name); |
350 EXPECT_EQ(static_cast<int32_t>(kReportBlock.extended_highest_sequence_number), | 356 EXPECT_EQ(static_cast<int32_t>(kReportBlock.extended_highest_sequence_number), |
351 stats.ext_seqnum); | 357 stats.ext_seqnum); |
352 EXPECT_EQ(static_cast<int32_t>(kReportBlock.interarrival_jitter / | 358 EXPECT_EQ(static_cast<int32_t>(kReportBlock.interarrival_jitter / |
353 (kIsacCodec.plfreq / 1000)), | 359 (kIsacCodec.plfreq / 1000)), |
354 stats.jitter_ms); | 360 stats.jitter_ms); |
355 EXPECT_EQ(kCallStats.rttMs, stats.rtt_ms); | 361 EXPECT_EQ(kCallStats.rttMs, stats.rtt_ms); |
356 EXPECT_EQ(static_cast<int32_t>(kSpeechInputLevel), stats.audio_level); | 362 EXPECT_EQ(static_cast<int32_t>(kSpeechInputLevel), stats.audio_level); |
357 EXPECT_EQ(-1, stats.aec_quality_min); | 363 EXPECT_EQ(-1, stats.aec_quality_min); |
358 EXPECT_EQ(kEchoDelayMedian, stats.echo_delay_median_ms); | 364 EXPECT_EQ(kEchoDelayMedian, stats.echo_delay_median_ms); |
359 EXPECT_EQ(kEchoDelayStdDev, stats.echo_delay_std_ms); | 365 EXPECT_EQ(kEchoDelayStdDev, stats.echo_delay_std_ms); |
360 EXPECT_EQ(kEchoReturnLoss, stats.echo_return_loss); | 366 EXPECT_EQ(kEchoReturnLoss, stats.echo_return_loss); |
361 EXPECT_EQ(kEchoReturnLossEnhancement, stats.echo_return_loss_enhancement); | 367 EXPECT_EQ(kEchoReturnLossEnhancement, stats.echo_return_loss_enhancement); |
362 EXPECT_EQ(kResidualEchoLikelihood, stats.residual_echo_likelihood); | 368 EXPECT_EQ(kResidualEchoLikelihood, stats.residual_echo_likelihood); |
363 EXPECT_FALSE(stats.typing_noise_detected); | 369 EXPECT_FALSE(stats.typing_noise_detected); |
364 } | 370 } |
365 | 371 |
366 TEST(AudioSendStreamTest, GetStatsTypingNoiseDetected) { | 372 TEST(AudioSendStreamTest, GetStatsTypingNoiseDetected) { |
367 ConfigHelper helper(false); | 373 ConfigHelper helper(false); |
368 internal::AudioSendStream send_stream( | 374 internal::AudioSendStream send_stream( |
369 helper.config(), helper.audio_state(), helper.worker_queue(), | 375 helper.config(), helper.audio_state(), helper.worker_queue(), |
370 helper.packet_router(), helper.congestion_controller(), | 376 helper.transport(), helper.bitrate_allocator(), helper.event_log(), |
371 helper.bitrate_allocator(), helper.event_log(), helper.rtcp_rtt_stats()); | 377 helper.rtcp_rtt_stats()); |
372 helper.SetupMockForGetStats(); | 378 helper.SetupMockForGetStats(); |
373 EXPECT_FALSE(send_stream.GetStats().typing_noise_detected); | 379 EXPECT_FALSE(send_stream.GetStats().typing_noise_detected); |
374 | 380 |
375 internal::AudioState* internal_audio_state = | 381 internal::AudioState* internal_audio_state = |
376 static_cast<internal::AudioState*>(helper.audio_state().get()); | 382 static_cast<internal::AudioState*>(helper.audio_state().get()); |
377 VoiceEngineObserver* voe_observer = | 383 VoiceEngineObserver* voe_observer = |
378 static_cast<VoiceEngineObserver*>(internal_audio_state); | 384 static_cast<VoiceEngineObserver*>(internal_audio_state); |
379 voe_observer->CallbackOnError(-1, VE_TYPING_NOISE_WARNING); | 385 voe_observer->CallbackOnError(-1, VE_TYPING_NOISE_WARNING); |
380 EXPECT_TRUE(send_stream.GetStats().typing_noise_detected); | 386 EXPECT_TRUE(send_stream.GetStats().typing_noise_detected); |
381 voe_observer->CallbackOnError(-1, VE_TYPING_NOISE_OFF_WARNING); | 387 voe_observer->CallbackOnError(-1, VE_TYPING_NOISE_OFF_WARNING); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
414 .WillOnce(Return(true)); | 420 .WillOnce(Return(true)); |
415 EXPECT_CALL( | 421 EXPECT_CALL( |
416 *helper.channel_proxy(), | 422 *helper.channel_proxy(), |
417 SetReceiverFrameLengthRange(stream_config.send_codec_spec.min_ptime_ms, | 423 SetReceiverFrameLengthRange(stream_config.send_codec_spec.min_ptime_ms, |
418 stream_config.send_codec_spec.max_ptime_ms)); | 424 stream_config.send_codec_spec.max_ptime_ms)); |
419 EXPECT_CALL( | 425 EXPECT_CALL( |
420 *helper.channel_proxy(), | 426 *helper.channel_proxy(), |
421 EnableAudioNetworkAdaptor(*stream_config.audio_network_adaptor_config)); | 427 EnableAudioNetworkAdaptor(*stream_config.audio_network_adaptor_config)); |
422 internal::AudioSendStream send_stream( | 428 internal::AudioSendStream send_stream( |
423 stream_config, helper.audio_state(), helper.worker_queue(), | 429 stream_config, helper.audio_state(), helper.worker_queue(), |
424 helper.packet_router(), helper.congestion_controller(), | 430 helper.transport(), helper.bitrate_allocator(), helper.event_log(), |
425 helper.bitrate_allocator(), helper.event_log(), helper.rtcp_rtt_stats()); | 431 helper.rtcp_rtt_stats()); |
426 } | 432 } |
427 | 433 |
428 // VAD is applied when codec is mono and the CNG frequency matches the codec | 434 // VAD is applied when codec is mono and the CNG frequency matches the codec |
429 // sample rate. | 435 // sample rate. |
430 TEST(AudioSendStreamTest, SendCodecCanApplyVad) { | 436 TEST(AudioSendStreamTest, SendCodecCanApplyVad) { |
431 ConfigHelper helper(false); | 437 ConfigHelper helper(false); |
432 auto stream_config = helper.config(); | 438 auto stream_config = helper.config(); |
433 const CodecInst kG722Codec = {9, "g722", 8000, 160, 1, 16000}; | 439 const CodecInst kG722Codec = {9, "g722", 8000, 160, 1, 16000}; |
434 stream_config.send_codec_spec.codec_inst = kG722Codec; | 440 stream_config.send_codec_spec.codec_inst = kG722Codec; |
435 stream_config.send_codec_spec.cng_plfreq = 8000; | 441 stream_config.send_codec_spec.cng_plfreq = 8000; |
436 stream_config.send_codec_spec.cng_payload_type = 105; | 442 stream_config.send_codec_spec.cng_payload_type = 105; |
437 EXPECT_CALL(*helper.channel_proxy(), SetVADStatus(true)) | 443 EXPECT_CALL(*helper.channel_proxy(), SetVADStatus(true)) |
438 .WillOnce(Return(true)); | 444 .WillOnce(Return(true)); |
439 internal::AudioSendStream send_stream( | 445 internal::AudioSendStream send_stream( |
440 stream_config, helper.audio_state(), helper.worker_queue(), | 446 stream_config, helper.audio_state(), helper.worker_queue(), |
441 helper.packet_router(), helper.congestion_controller(), | 447 helper.transport(), helper.bitrate_allocator(), helper.event_log(), |
442 helper.bitrate_allocator(), helper.event_log(), helper.rtcp_rtt_stats()); | 448 helper.rtcp_rtt_stats()); |
443 } | 449 } |
444 | 450 |
445 TEST(AudioSendStreamTest, DoesNotPassHigherBitrateThanMaxBitrate) { | 451 TEST(AudioSendStreamTest, DoesNotPassHigherBitrateThanMaxBitrate) { |
446 ConfigHelper helper(false); | 452 ConfigHelper helper(false); |
447 internal::AudioSendStream send_stream( | 453 internal::AudioSendStream send_stream( |
448 helper.config(), helper.audio_state(), helper.worker_queue(), | 454 helper.config(), helper.audio_state(), helper.worker_queue(), |
449 helper.packet_router(), helper.congestion_controller(), | 455 helper.transport(), helper.bitrate_allocator(), helper.event_log(), |
450 helper.bitrate_allocator(), helper.event_log(), helper.rtcp_rtt_stats()); | 456 helper.rtcp_rtt_stats()); |
451 EXPECT_CALL(*helper.channel_proxy(), | 457 EXPECT_CALL(*helper.channel_proxy(), |
452 SetBitrate(helper.config().max_bitrate_bps, _)); | 458 SetBitrate(helper.config().max_bitrate_bps, _)); |
453 send_stream.OnBitrateUpdated(helper.config().max_bitrate_bps + 5000, 0.0, 50, | 459 send_stream.OnBitrateUpdated(helper.config().max_bitrate_bps + 5000, 0.0, 50, |
454 6000); | 460 6000); |
455 } | 461 } |
456 | 462 |
457 TEST(AudioSendStreamTest, ProbingIntervalOnBitrateUpdated) { | 463 TEST(AudioSendStreamTest, ProbingIntervalOnBitrateUpdated) { |
458 ConfigHelper helper(false); | 464 ConfigHelper helper(false); |
459 internal::AudioSendStream send_stream( | 465 internal::AudioSendStream send_stream( |
460 helper.config(), helper.audio_state(), helper.worker_queue(), | 466 helper.config(), helper.audio_state(), helper.worker_queue(), |
461 helper.packet_router(), helper.congestion_controller(), | 467 helper.transport(), helper.bitrate_allocator(), helper.event_log(), |
462 helper.bitrate_allocator(), helper.event_log(), helper.rtcp_rtt_stats()); | 468 helper.rtcp_rtt_stats()); |
463 EXPECT_CALL(*helper.channel_proxy(), SetBitrate(_, 5000)); | 469 EXPECT_CALL(*helper.channel_proxy(), SetBitrate(_, 5000)); |
464 send_stream.OnBitrateUpdated(50000, 0.0, 50, 5000); | 470 send_stream.OnBitrateUpdated(50000, 0.0, 50, 5000); |
465 } | 471 } |
466 | 472 |
467 } // namespace test | 473 } // namespace test |
468 } // namespace webrtc | 474 } // namespace webrtc |
OLD | NEW |