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

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

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

Powered by Google App Engine
This is Rietveld 408576698