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

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

Issue 2516983004: Move ownership of PacketRouter from CongestionController to Call. (Closed)
Patch Set: Add back packet_router method and 4-argument constructor. Created 4 years 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
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 uint32_t max_padding_bitrate_bps)); 60 uint32_t max_padding_bitrate_bps));
61 }; 61 };
62 62
63 struct ConfigHelper { 63 struct ConfigHelper {
64 ConfigHelper() 64 ConfigHelper()
65 : simulated_clock_(123456), 65 : simulated_clock_(123456),
66 stream_config_(nullptr), 66 stream_config_(nullptr),
67 congestion_controller_(&simulated_clock_, 67 congestion_controller_(&simulated_clock_,
68 &bitrate_observer_, 68 &bitrate_observer_,
69 &remote_bitrate_observer_, 69 &remote_bitrate_observer_,
70 &event_log_), 70 &event_log_,
71 &packet_router_),
71 bitrate_allocator_(&limit_observer_), 72 bitrate_allocator_(&limit_observer_),
72 worker_queue_("ConfigHelper_worker_queue") { 73 worker_queue_("ConfigHelper_worker_queue") {
73 using testing::Invoke; 74 using testing::Invoke;
74 75
75 EXPECT_CALL(voice_engine_, 76 EXPECT_CALL(voice_engine_,
76 RegisterVoiceEngineObserver(_)).WillOnce(Return(0)); 77 RegisterVoiceEngineObserver(_)).WillOnce(Return(0));
77 EXPECT_CALL(voice_engine_, 78 EXPECT_CALL(voice_engine_,
78 DeRegisterVoiceEngineObserver()).WillOnce(Return(0)); 79 DeRegisterVoiceEngineObserver()).WillOnce(Return(0));
79 EXPECT_CALL(voice_engine_, audio_device_module()); 80 EXPECT_CALL(voice_engine_, audio_device_module());
80 EXPECT_CALL(voice_engine_, audio_processing()); 81 EXPECT_CALL(voice_engine_, audio_processing());
(...skipping 22 matching lines...) Expand all
103 stream_config_.rtp.extensions.push_back(RtpExtension( 104 stream_config_.rtp.extensions.push_back(RtpExtension(
104 RtpExtension::kTransportSequenceNumberUri, kTransportSequenceNumberId)); 105 RtpExtension::kTransportSequenceNumberUri, kTransportSequenceNumberId));
105 // Use ISAC as default codec so as to prevent unnecessary |voice_engine_| 106 // Use ISAC as default codec so as to prevent unnecessary |voice_engine_|
106 // calls from the default ctor behavior. 107 // calls from the default ctor behavior.
107 stream_config_.send_codec_spec.codec_inst = kIsacCodec; 108 stream_config_.send_codec_spec.codec_inst = kIsacCodec;
108 } 109 }
109 110
110 AudioSendStream::Config& config() { return stream_config_; } 111 AudioSendStream::Config& config() { return stream_config_; }
111 rtc::scoped_refptr<AudioState> audio_state() { return audio_state_; } 112 rtc::scoped_refptr<AudioState> audio_state() { return audio_state_; }
112 MockVoEChannelProxy* channel_proxy() { return channel_proxy_; } 113 MockVoEChannelProxy* channel_proxy() { return channel_proxy_; }
114 PacketRouter* packet_router() { return &packet_router_; }
113 CongestionController* congestion_controller() { 115 CongestionController* congestion_controller() {
114 return &congestion_controller_; 116 return &congestion_controller_;
115 } 117 }
116 BitrateAllocator* bitrate_allocator() { return &bitrate_allocator_; } 118 BitrateAllocator* bitrate_allocator() { return &bitrate_allocator_; }
117 rtc::TaskQueue* worker_queue() { return &worker_queue_; } 119 rtc::TaskQueue* worker_queue() { return &worker_queue_; }
118 RtcEventLog* event_log() { return &event_log_; } 120 RtcEventLog* event_log() { return &event_log_; }
119 MockVoiceEngine* voice_engine() { return &voice_engine_; } 121 MockVoiceEngine* voice_engine() { return &voice_engine_; }
120 122
121 void SetupDefaultChannelProxy() { 123 void SetupDefaultChannelProxy() {
122 using testing::StrEq; 124 using testing::StrEq;
123 channel_proxy_ = new testing::StrictMock<MockVoEChannelProxy>(); 125 channel_proxy_ = new testing::StrictMock<MockVoEChannelProxy>();
124 EXPECT_CALL(*channel_proxy_, SetRTCPStatus(true)).Times(1); 126 EXPECT_CALL(*channel_proxy_, SetRTCPStatus(true)).Times(1);
125 EXPECT_CALL(*channel_proxy_, SetLocalSSRC(kSsrc)).Times(1); 127 EXPECT_CALL(*channel_proxy_, SetLocalSSRC(kSsrc)).Times(1);
126 EXPECT_CALL(*channel_proxy_, SetRTCP_CNAME(StrEq(kCName))).Times(1); 128 EXPECT_CALL(*channel_proxy_, SetRTCP_CNAME(StrEq(kCName))).Times(1);
127 EXPECT_CALL(*channel_proxy_, SetNACKStatus(true, 10)).Times(1); 129 EXPECT_CALL(*channel_proxy_, SetNACKStatus(true, 10)).Times(1);
128 EXPECT_CALL(*channel_proxy_, 130 EXPECT_CALL(*channel_proxy_,
129 SetSendAudioLevelIndicationStatus(true, kAudioLevelId)) 131 SetSendAudioLevelIndicationStatus(true, kAudioLevelId))
130 .Times(1); 132 .Times(1);
131 EXPECT_CALL(*channel_proxy_, 133 EXPECT_CALL(*channel_proxy_,
132 EnableSendTransportSequenceNumber(kTransportSequenceNumberId)) 134 EnableSendTransportSequenceNumber(kTransportSequenceNumberId))
133 .Times(1); 135 .Times(1);
134 EXPECT_CALL(*channel_proxy_, 136 EXPECT_CALL(*channel_proxy_,
135 RegisterSenderCongestionControlObjects( 137 RegisterSenderCongestionControlObjects(
136 congestion_controller_.pacer(), 138 congestion_controller_.pacer(),
137 congestion_controller_.GetTransportFeedbackObserver(), 139 congestion_controller_.GetTransportFeedbackObserver(),
138 congestion_controller_.packet_router())) 140 packet_router()))
139 .Times(1); 141 .Times(1);
140 EXPECT_CALL(*channel_proxy_, ResetCongestionControlObjects()).Times(1); 142 EXPECT_CALL(*channel_proxy_, ResetCongestionControlObjects()).Times(1);
141 EXPECT_CALL(*channel_proxy_, RegisterExternalTransport(nullptr)).Times(1); 143 EXPECT_CALL(*channel_proxy_, RegisterExternalTransport(nullptr)).Times(1);
142 EXPECT_CALL(*channel_proxy_, DeRegisterExternalTransport()).Times(1); 144 EXPECT_CALL(*channel_proxy_, DeRegisterExternalTransport()).Times(1);
143 EXPECT_CALL(*channel_proxy_, SetRtcEventLog(testing::NotNull())).Times(1); 145 EXPECT_CALL(*channel_proxy_, SetRtcEventLog(testing::NotNull())).Times(1);
144 EXPECT_CALL(*channel_proxy_, SetRtcEventLog(testing::IsNull())) 146 EXPECT_CALL(*channel_proxy_, SetRtcEventLog(testing::IsNull()))
145 .Times(1); // Destructor resets the event log 147 .Times(1); // Destructor resets the event log
146 } 148 }
147 149
148 void SetupMockForSetupSendCodec() { 150 void SetupMockForSetupSendCodec() {
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 private: 213 private:
212 SimulatedClock simulated_clock_; 214 SimulatedClock simulated_clock_;
213 testing::StrictMock<MockVoiceEngine> voice_engine_; 215 testing::StrictMock<MockVoiceEngine> voice_engine_;
214 rtc::scoped_refptr<AudioState> audio_state_; 216 rtc::scoped_refptr<AudioState> audio_state_;
215 AudioSendStream::Config stream_config_; 217 AudioSendStream::Config stream_config_;
216 testing::StrictMock<MockVoEChannelProxy>* channel_proxy_ = nullptr; 218 testing::StrictMock<MockVoEChannelProxy>* channel_proxy_ = nullptr;
217 testing::NiceMock<MockCongestionObserver> bitrate_observer_; 219 testing::NiceMock<MockCongestionObserver> bitrate_observer_;
218 testing::NiceMock<MockRemoteBitrateObserver> remote_bitrate_observer_; 220 testing::NiceMock<MockRemoteBitrateObserver> remote_bitrate_observer_;
219 MockAudioProcessing audio_processing_; 221 MockAudioProcessing audio_processing_;
220 AudioProcessing::AudioProcessingStatistics audio_processing_stats_; 222 AudioProcessing::AudioProcessingStatistics audio_processing_stats_;
223 PacketRouter packet_router_;
221 CongestionController congestion_controller_; 224 CongestionController congestion_controller_;
222 MockRtcEventLog event_log_; 225 MockRtcEventLog event_log_;
223 testing::NiceMock<MockLimitObserver> limit_observer_; 226 testing::NiceMock<MockLimitObserver> limit_observer_;
224 BitrateAllocator bitrate_allocator_; 227 BitrateAllocator bitrate_allocator_;
225 // |worker_queue| is defined last to ensure all pending tasks are cancelled 228 // |worker_queue| is defined last to ensure all pending tasks are cancelled
226 // and deleted before any other members. 229 // and deleted before any other members.
227 rtc::TaskQueue worker_queue_; 230 rtc::TaskQueue worker_queue_;
228 }; 231 };
229 } // namespace 232 } // namespace
230 233
(...skipping 26 matching lines...) Expand all
257 "32000, cng_payload_type: 42, cng_plfreq: 56, min_ptime: 20, max_ptime: " 260 "32000, cng_payload_type: 42, cng_plfreq: 56, min_ptime: 20, max_ptime: "
258 "60, codec_inst: {pltype: 103, plname: \"isac\", plfreq: 16000, pacsize: " 261 "60, codec_inst: {pltype: 103, plname: \"isac\", plfreq: 16000, pacsize: "
259 "320, channels: 1, rate: 32000}}}", 262 "320, channels: 1, rate: 32000}}}",
260 config.ToString()); 263 config.ToString());
261 } 264 }
262 265
263 TEST(AudioSendStreamTest, ConstructDestruct) { 266 TEST(AudioSendStreamTest, ConstructDestruct) {
264 ConfigHelper helper; 267 ConfigHelper helper;
265 internal::AudioSendStream send_stream( 268 internal::AudioSendStream send_stream(
266 helper.config(), helper.audio_state(), helper.worker_queue(), 269 helper.config(), helper.audio_state(), helper.worker_queue(),
267 helper.congestion_controller(), helper.bitrate_allocator(), 270 helper.packet_router(), helper.congestion_controller(),
268 helper.event_log()); 271 helper.bitrate_allocator(), helper.event_log());
269 } 272 }
270 273
271 TEST(AudioSendStreamTest, SendTelephoneEvent) { 274 TEST(AudioSendStreamTest, SendTelephoneEvent) {
272 ConfigHelper helper; 275 ConfigHelper helper;
273 internal::AudioSendStream send_stream( 276 internal::AudioSendStream send_stream(
274 helper.config(), helper.audio_state(), helper.worker_queue(), 277 helper.config(), helper.audio_state(), helper.worker_queue(),
275 helper.congestion_controller(), helper.bitrate_allocator(), 278 helper.packet_router(), helper.congestion_controller(),
276 helper.event_log()); 279 helper.bitrate_allocator(), helper.event_log());
277 helper.SetupMockForSendTelephoneEvent(); 280 helper.SetupMockForSendTelephoneEvent();
278 EXPECT_TRUE(send_stream.SendTelephoneEvent(kTelephoneEventPayloadType, 281 EXPECT_TRUE(send_stream.SendTelephoneEvent(kTelephoneEventPayloadType,
279 kTelephoneEventPayloadFrequency, kTelephoneEventCode, 282 kTelephoneEventPayloadFrequency, kTelephoneEventCode,
280 kTelephoneEventDuration)); 283 kTelephoneEventDuration));
281 } 284 }
282 285
283 TEST(AudioSendStreamTest, SetMuted) { 286 TEST(AudioSendStreamTest, SetMuted) {
284 ConfigHelper helper; 287 ConfigHelper helper;
285 internal::AudioSendStream send_stream( 288 internal::AudioSendStream send_stream(
286 helper.config(), helper.audio_state(), helper.worker_queue(), 289 helper.config(), helper.audio_state(), helper.worker_queue(),
287 helper.congestion_controller(), helper.bitrate_allocator(), 290 helper.packet_router(), helper.congestion_controller(),
288 helper.event_log()); 291 helper.bitrate_allocator(), helper.event_log());
289 EXPECT_CALL(*helper.channel_proxy(), SetInputMute(true)); 292 EXPECT_CALL(*helper.channel_proxy(), SetInputMute(true));
290 send_stream.SetMuted(true); 293 send_stream.SetMuted(true);
291 } 294 }
292 295
293 TEST(AudioSendStreamTest, GetStats) { 296 TEST(AudioSendStreamTest, GetStats) {
294 ConfigHelper helper; 297 ConfigHelper helper;
295 internal::AudioSendStream send_stream( 298 internal::AudioSendStream send_stream(
296 helper.config(), helper.audio_state(), helper.worker_queue(), 299 helper.config(), helper.audio_state(), helper.worker_queue(),
297 helper.congestion_controller(), helper.bitrate_allocator(), 300 helper.packet_router(), helper.congestion_controller(),
298 helper.event_log()); 301 helper.bitrate_allocator(), helper.event_log());
299 helper.SetupMockForGetStats(); 302 helper.SetupMockForGetStats();
300 AudioSendStream::Stats stats = send_stream.GetStats(); 303 AudioSendStream::Stats stats = send_stream.GetStats();
301 EXPECT_EQ(kSsrc, stats.local_ssrc); 304 EXPECT_EQ(kSsrc, stats.local_ssrc);
302 EXPECT_EQ(static_cast<int64_t>(kCallStats.bytesSent), stats.bytes_sent); 305 EXPECT_EQ(static_cast<int64_t>(kCallStats.bytesSent), stats.bytes_sent);
303 EXPECT_EQ(kCallStats.packetsSent, stats.packets_sent); 306 EXPECT_EQ(kCallStats.packetsSent, stats.packets_sent);
304 EXPECT_EQ(static_cast<int32_t>(kReportBlock.cumulative_num_packets_lost), 307 EXPECT_EQ(static_cast<int32_t>(kReportBlock.cumulative_num_packets_lost),
305 stats.packets_lost); 308 stats.packets_lost);
306 EXPECT_EQ(Q8ToFloat(kReportBlock.fraction_lost), stats.fraction_lost); 309 EXPECT_EQ(Q8ToFloat(kReportBlock.fraction_lost), stats.fraction_lost);
307 EXPECT_EQ(std::string(kIsacCodec.plname), stats.codec_name); 310 EXPECT_EQ(std::string(kIsacCodec.plname), stats.codec_name);
308 EXPECT_EQ(static_cast<int32_t>(kReportBlock.extended_highest_sequence_number), 311 EXPECT_EQ(static_cast<int32_t>(kReportBlock.extended_highest_sequence_number),
309 stats.ext_seqnum); 312 stats.ext_seqnum);
310 EXPECT_EQ(static_cast<int32_t>(kReportBlock.interarrival_jitter / 313 EXPECT_EQ(static_cast<int32_t>(kReportBlock.interarrival_jitter /
311 (kIsacCodec.plfreq / 1000)), 314 (kIsacCodec.plfreq / 1000)),
312 stats.jitter_ms); 315 stats.jitter_ms);
313 EXPECT_EQ(kCallStats.rttMs, stats.rtt_ms); 316 EXPECT_EQ(kCallStats.rttMs, stats.rtt_ms);
314 EXPECT_EQ(static_cast<int32_t>(kSpeechInputLevel), stats.audio_level); 317 EXPECT_EQ(static_cast<int32_t>(kSpeechInputLevel), stats.audio_level);
315 EXPECT_EQ(-1, stats.aec_quality_min); 318 EXPECT_EQ(-1, stats.aec_quality_min);
316 EXPECT_EQ(kEchoDelayMedian, stats.echo_delay_median_ms); 319 EXPECT_EQ(kEchoDelayMedian, stats.echo_delay_median_ms);
317 EXPECT_EQ(kEchoDelayStdDev, stats.echo_delay_std_ms); 320 EXPECT_EQ(kEchoDelayStdDev, stats.echo_delay_std_ms);
318 EXPECT_EQ(kEchoReturnLoss, stats.echo_return_loss); 321 EXPECT_EQ(kEchoReturnLoss, stats.echo_return_loss);
319 EXPECT_EQ(kEchoReturnLossEnhancement, stats.echo_return_loss_enhancement); 322 EXPECT_EQ(kEchoReturnLossEnhancement, stats.echo_return_loss_enhancement);
320 EXPECT_EQ(kResidualEchoLikelihood, stats.residual_echo_likelihood); 323 EXPECT_EQ(kResidualEchoLikelihood, stats.residual_echo_likelihood);
321 EXPECT_FALSE(stats.typing_noise_detected); 324 EXPECT_FALSE(stats.typing_noise_detected);
322 } 325 }
323 326
324 TEST(AudioSendStreamTest, GetStatsTypingNoiseDetected) { 327 TEST(AudioSendStreamTest, GetStatsTypingNoiseDetected) {
325 ConfigHelper helper; 328 ConfigHelper helper;
326 internal::AudioSendStream send_stream( 329 internal::AudioSendStream send_stream(
327 helper.config(), helper.audio_state(), helper.worker_queue(), 330 helper.config(), helper.audio_state(), helper.worker_queue(),
328 helper.congestion_controller(), helper.bitrate_allocator(), 331 helper.packet_router(), helper.congestion_controller(),
329 helper.event_log()); 332 helper.bitrate_allocator(), helper.event_log());
330 helper.SetupMockForGetStats(); 333 helper.SetupMockForGetStats();
331 EXPECT_FALSE(send_stream.GetStats().typing_noise_detected); 334 EXPECT_FALSE(send_stream.GetStats().typing_noise_detected);
332 335
333 internal::AudioState* internal_audio_state = 336 internal::AudioState* internal_audio_state =
334 static_cast<internal::AudioState*>(helper.audio_state().get()); 337 static_cast<internal::AudioState*>(helper.audio_state().get());
335 VoiceEngineObserver* voe_observer = 338 VoiceEngineObserver* voe_observer =
336 static_cast<VoiceEngineObserver*>(internal_audio_state); 339 static_cast<VoiceEngineObserver*>(internal_audio_state);
337 voe_observer->CallbackOnError(-1, VE_TYPING_NOISE_WARNING); 340 voe_observer->CallbackOnError(-1, VE_TYPING_NOISE_WARNING);
338 EXPECT_TRUE(send_stream.GetStats().typing_noise_detected); 341 EXPECT_TRUE(send_stream.GetStats().typing_noise_detected);
339 voe_observer->CallbackOnError(-1, VE_TYPING_NOISE_OFF_WARNING); 342 voe_observer->CallbackOnError(-1, VE_TYPING_NOISE_OFF_WARNING);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 .WillOnce(Return(0)); 375 .WillOnce(Return(0));
373 EXPECT_CALL( 376 EXPECT_CALL(
374 *helper.channel_proxy(), 377 *helper.channel_proxy(),
375 SetReceiverFrameLengthRange(stream_config.send_codec_spec.min_ptime_ms, 378 SetReceiverFrameLengthRange(stream_config.send_codec_spec.min_ptime_ms,
376 stream_config.send_codec_spec.max_ptime_ms)); 379 stream_config.send_codec_spec.max_ptime_ms));
377 EXPECT_CALL( 380 EXPECT_CALL(
378 *helper.channel_proxy(), 381 *helper.channel_proxy(),
379 EnableAudioNetworkAdaptor(*stream_config.audio_network_adaptor_config)); 382 EnableAudioNetworkAdaptor(*stream_config.audio_network_adaptor_config));
380 internal::AudioSendStream send_stream( 383 internal::AudioSendStream send_stream(
381 stream_config, helper.audio_state(), helper.worker_queue(), 384 stream_config, helper.audio_state(), helper.worker_queue(),
382 helper.congestion_controller(), helper.bitrate_allocator(), 385 helper.packet_router(), helper.congestion_controller(),
383 helper.event_log()); 386 helper.bitrate_allocator(), helper.event_log());
384 } 387 }
385 388
386 // VAD is applied when codec is mono and the CNG frequency matches the codec 389 // VAD is applied when codec is mono and the CNG frequency matches the codec
387 // sample rate. 390 // sample rate.
388 TEST(AudioSendStreamTest, SendCodecCanApplyVad) { 391 TEST(AudioSendStreamTest, SendCodecCanApplyVad) {
389 ConfigHelper helper; 392 ConfigHelper helper;
390 auto stream_config = helper.config(); 393 auto stream_config = helper.config();
391 const CodecInst kG722Codec = {9, "g722", 8000, 160, 1, 16000}; 394 const CodecInst kG722Codec = {9, "g722", 8000, 160, 1, 16000};
392 stream_config.send_codec_spec.codec_inst = kG722Codec; 395 stream_config.send_codec_spec.codec_inst = kG722Codec;
393 stream_config.send_codec_spec.cng_plfreq = 8000; 396 stream_config.send_codec_spec.cng_plfreq = 8000;
394 stream_config.send_codec_spec.cng_payload_type = 105; 397 stream_config.send_codec_spec.cng_payload_type = 105;
395 EXPECT_CALL(*helper.voice_engine(), SetVADStatus(kChannelId, true, _, _)) 398 EXPECT_CALL(*helper.voice_engine(), SetVADStatus(kChannelId, true, _, _))
396 .WillOnce(Return(0)); 399 .WillOnce(Return(0));
397 internal::AudioSendStream send_stream( 400 internal::AudioSendStream send_stream(
398 stream_config, helper.audio_state(), helper.worker_queue(), 401 stream_config, helper.audio_state(), helper.worker_queue(),
399 helper.congestion_controller(), helper.bitrate_allocator(), 402 helper.packet_router(), helper.congestion_controller(),
400 helper.event_log()); 403 helper.bitrate_allocator(), helper.event_log());
401 } 404 }
402 405
403 } // namespace test 406 } // namespace test
404 } // namespace webrtc 407 } // 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