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

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

Issue 2397573006: Using AudioOption to enable audio network adaptor. (Closed)
Patch Set: fixing some problems Created 4 years, 1 month 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 ConfigHelper() 61 ConfigHelper()
62 : simulated_clock_(123456), 62 : simulated_clock_(123456),
63 stream_config_(nullptr), 63 stream_config_(nullptr),
64 congestion_controller_(&simulated_clock_, 64 congestion_controller_(&simulated_clock_,
65 &bitrate_observer_, 65 &bitrate_observer_,
66 &remote_bitrate_observer_, 66 &remote_bitrate_observer_,
67 &event_log_), 67 &event_log_),
68 bitrate_allocator_(&limit_observer_), 68 bitrate_allocator_(&limit_observer_),
69 worker_queue_("ConfigHelper_worker_queue") { 69 worker_queue_("ConfigHelper_worker_queue") {
70 using testing::Invoke; 70 using testing::Invoke;
71 using testing::StrEq;
72 71
73 EXPECT_CALL(voice_engine_, 72 EXPECT_CALL(voice_engine_,
74 RegisterVoiceEngineObserver(_)).WillOnce(Return(0)); 73 RegisterVoiceEngineObserver(_)).WillOnce(Return(0));
75 EXPECT_CALL(voice_engine_, 74 EXPECT_CALL(voice_engine_,
76 DeRegisterVoiceEngineObserver()).WillOnce(Return(0)); 75 DeRegisterVoiceEngineObserver()).WillOnce(Return(0));
77 AudioState::Config config; 76 AudioState::Config config;
78 config.voice_engine = &voice_engine_; 77 config.voice_engine = &voice_engine_;
79 audio_state_ = AudioState::Create(config); 78 audio_state_ = AudioState::Create(config);
80 79
80 SetupDefaultChannelProxy();
81
81 EXPECT_CALL(voice_engine_, ChannelProxyFactory(kChannelId)) 82 EXPECT_CALL(voice_engine_, ChannelProxyFactory(kChannelId))
82 .WillOnce(Invoke([this](int channel_id) { 83 .WillOnce(Invoke([this](int channel_id) {
83 EXPECT_FALSE(channel_proxy_);
84 channel_proxy_ = new testing::StrictMock<MockVoEChannelProxy>();
85 EXPECT_CALL(*channel_proxy_, SetRTCPStatus(true)).Times(1);
86 EXPECT_CALL(*channel_proxy_, SetLocalSSRC(kSsrc)).Times(1);
87 EXPECT_CALL(*channel_proxy_, SetRTCP_CNAME(StrEq(kCName))).Times(1);
88 EXPECT_CALL(*channel_proxy_, SetNACKStatus(true, 10)).Times(1);
89 EXPECT_CALL(*channel_proxy_,
90 SetSendAbsoluteSenderTimeStatus(true, kAbsSendTimeId)).Times(1);
91 EXPECT_CALL(*channel_proxy_,
92 SetSendAudioLevelIndicationStatus(true, kAudioLevelId)).Times(1);
93 EXPECT_CALL(*channel_proxy_, EnableSendTransportSequenceNumber(
94 kTransportSequenceNumberId))
95 .Times(1);
96 EXPECT_CALL(*channel_proxy_,
97 RegisterSenderCongestionControlObjects(
98 congestion_controller_.pacer(),
99 congestion_controller_.GetTransportFeedbackObserver(),
100 congestion_controller_.packet_router()))
101 .Times(1);
102 EXPECT_CALL(*channel_proxy_, ResetCongestionControlObjects())
103 .Times(1);
104 EXPECT_CALL(*channel_proxy_, RegisterExternalTransport(nullptr))
105 .Times(1);
106 EXPECT_CALL(*channel_proxy_, DeRegisterExternalTransport())
107 .Times(1);
108 EXPECT_CALL(*channel_proxy_, SetRtcEventLog(testing::NotNull()))
109 .Times(1);
110 EXPECT_CALL(*channel_proxy_, SetRtcEventLog(testing::IsNull()))
111 .Times(1); // Destructor resets the event log
112 return channel_proxy_; 84 return channel_proxy_;
113 })); 85 }));
86
114 SetupMockForSetupSendCodec(); 87 SetupMockForSetupSendCodec();
88
115 stream_config_.voe_channel_id = kChannelId; 89 stream_config_.voe_channel_id = kChannelId;
116 stream_config_.rtp.ssrc = kSsrc; 90 stream_config_.rtp.ssrc = kSsrc;
117 stream_config_.rtp.nack.rtp_history_ms = 200; 91 stream_config_.rtp.nack.rtp_history_ms = 200;
118 stream_config_.rtp.c_name = kCName; 92 stream_config_.rtp.c_name = kCName;
119 stream_config_.rtp.extensions.push_back( 93 stream_config_.rtp.extensions.push_back(
120 RtpExtension(RtpExtension::kAudioLevelUri, kAudioLevelId)); 94 RtpExtension(RtpExtension::kAudioLevelUri, kAudioLevelId));
121 stream_config_.rtp.extensions.push_back( 95 stream_config_.rtp.extensions.push_back(
122 RtpExtension(RtpExtension::kAbsSendTimeUri, kAbsSendTimeId)); 96 RtpExtension(RtpExtension::kAbsSendTimeUri, kAbsSendTimeId));
123 stream_config_.rtp.extensions.push_back(RtpExtension( 97 stream_config_.rtp.extensions.push_back(RtpExtension(
124 RtpExtension::kTransportSequenceNumberUri, kTransportSequenceNumberId)); 98 RtpExtension::kTransportSequenceNumberUri, kTransportSequenceNumberId));
125 // Use ISAC as default codec so as to prevent unnecessary |voice_engine_| 99 // Use ISAC as default codec so as to prevent unnecessary |voice_engine_|
126 // calls from the default ctor behavior. 100 // calls from the default ctor behavior.
127 stream_config_.send_codec_spec.codec_inst = kIsacCodec; 101 stream_config_.send_codec_spec.codec_inst = kIsacCodec;
128 } 102 }
129 103
130 AudioSendStream::Config& config() { return stream_config_; } 104 AudioSendStream::Config& config() { return stream_config_; }
131 rtc::scoped_refptr<AudioState> audio_state() { return audio_state_; } 105 rtc::scoped_refptr<AudioState> audio_state() { return audio_state_; }
132 MockVoEChannelProxy* channel_proxy() { return channel_proxy_; } 106 MockVoEChannelProxy* channel_proxy() { return channel_proxy_; }
133 CongestionController* congestion_controller() { 107 CongestionController* congestion_controller() {
134 return &congestion_controller_; 108 return &congestion_controller_;
135 } 109 }
136 BitrateAllocator* bitrate_allocator() { return &bitrate_allocator_; } 110 BitrateAllocator* bitrate_allocator() { return &bitrate_allocator_; }
137 rtc::TaskQueue* worker_queue() { return &worker_queue_; } 111 rtc::TaskQueue* worker_queue() { return &worker_queue_; }
138 RtcEventLog* event_log() { return &event_log_; } 112 RtcEventLog* event_log() { return &event_log_; }
139 MockVoiceEngine* voice_engine() { return &voice_engine_; } 113 MockVoiceEngine* voice_engine() { return &voice_engine_; }
140 114
115 void SetupDefaultChannelProxy() {
116 using testing::StrEq;
117 channel_proxy_ = new testing::StrictMock<MockVoEChannelProxy>();
118 EXPECT_CALL(*channel_proxy_, SetRTCPStatus(true)).Times(1);
119 EXPECT_CALL(*channel_proxy_, SetLocalSSRC(kSsrc)).Times(1);
120 EXPECT_CALL(*channel_proxy_, SetRTCP_CNAME(StrEq(kCName))).Times(1);
121 EXPECT_CALL(*channel_proxy_, SetNACKStatus(true, 10)).Times(1);
122 EXPECT_CALL(*channel_proxy_,
123 SetSendAbsoluteSenderTimeStatus(true, kAbsSendTimeId))
124 .Times(1);
125 EXPECT_CALL(*channel_proxy_,
126 SetSendAudioLevelIndicationStatus(true, kAudioLevelId))
127 .Times(1);
128 EXPECT_CALL(*channel_proxy_,
129 EnableSendTransportSequenceNumber(kTransportSequenceNumberId))
130 .Times(1);
131 EXPECT_CALL(*channel_proxy_,
132 RegisterSenderCongestionControlObjects(
133 congestion_controller_.pacer(),
134 congestion_controller_.GetTransportFeedbackObserver(),
135 congestion_controller_.packet_router()))
136 .Times(1);
137 EXPECT_CALL(*channel_proxy_, ResetCongestionControlObjects()).Times(1);
138 EXPECT_CALL(*channel_proxy_, RegisterExternalTransport(nullptr)).Times(1);
139 EXPECT_CALL(*channel_proxy_, DeRegisterExternalTransport()).Times(1);
140 EXPECT_CALL(*channel_proxy_, SetRtcEventLog(testing::NotNull())).Times(1);
141 EXPECT_CALL(*channel_proxy_, SetRtcEventLog(testing::IsNull()))
142 .Times(1); // Destructor resets the event log
143 }
144
141 void SetupMockForSetupSendCodec() { 145 void SetupMockForSetupSendCodec() {
142 EXPECT_CALL(voice_engine_, SetVADStatus(kChannelId, false, _, _)) 146 EXPECT_CALL(voice_engine_, SetVADStatus(kChannelId, false, _, _))
143 .WillOnce(Return(0)); 147 .WillOnce(Return(0));
144 EXPECT_CALL(voice_engine_, SetFECStatus(kChannelId, false)) 148 EXPECT_CALL(voice_engine_, SetFECStatus(kChannelId, false))
145 .WillOnce(Return(0)); 149 .WillOnce(Return(0));
146 // Let |GetSendCodec| return -1 for the first time to indicate that no send 150 // Let |GetSendCodec| return -1 for the first time to indicate that no send
147 // codec has been set. 151 // codec has been set.
148 EXPECT_CALL(voice_engine_, GetSendCodec(kChannelId, _)) 152 EXPECT_CALL(voice_engine_, GetSendCodec(kChannelId, _))
149 .WillOnce(Return(-1)); 153 .WillOnce(Return(-1));
150 EXPECT_CALL(voice_engine_, SetSendCodec(kChannelId, _)).WillOnce(Return(0)); 154 EXPECT_CALL(voice_engine_, SetSendCodec(kChannelId, _)).WillOnce(Return(0));
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 TEST(AudioSendStreamTest, SendCodecAppliesConfigParams) { 312 TEST(AudioSendStreamTest, SendCodecAppliesConfigParams) {
309 ConfigHelper helper; 313 ConfigHelper helper;
310 auto stream_config = helper.config(); 314 auto stream_config = helper.config();
311 const CodecInst kOpusCodec = {111, "opus", 48000, 960, 2, 64000}; 315 const CodecInst kOpusCodec = {111, "opus", 48000, 960, 2, 64000};
312 stream_config.send_codec_spec.codec_inst = kOpusCodec; 316 stream_config.send_codec_spec.codec_inst = kOpusCodec;
313 stream_config.send_codec_spec.enable_codec_fec = true; 317 stream_config.send_codec_spec.enable_codec_fec = true;
314 stream_config.send_codec_spec.enable_opus_dtx = true; 318 stream_config.send_codec_spec.enable_opus_dtx = true;
315 stream_config.send_codec_spec.opus_max_playback_rate = 12345; 319 stream_config.send_codec_spec.opus_max_playback_rate = 12345;
316 stream_config.send_codec_spec.cng_plfreq = 16000; 320 stream_config.send_codec_spec.cng_plfreq = 16000;
317 stream_config.send_codec_spec.cng_payload_type = 105; 321 stream_config.send_codec_spec.cng_payload_type = 105;
322 stream_config.send_codec_spec.min_ptime_ms = 10;
323 stream_config.send_codec_spec.max_ptime_ms = 60;
324 stream_config.audio_network_adaptor_config =
325 rtc::Optional<std::string>("abced");
318 EXPECT_CALL(*helper.voice_engine(), SetFECStatus(kChannelId, true)) 326 EXPECT_CALL(*helper.voice_engine(), SetFECStatus(kChannelId, true))
319 .WillOnce(Return(0)); 327 .WillOnce(Return(0));
320 EXPECT_CALL( 328 EXPECT_CALL(
321 *helper.voice_engine(), 329 *helper.voice_engine(),
322 SetOpusDtx(kChannelId, stream_config.send_codec_spec.enable_opus_dtx)) 330 SetOpusDtx(kChannelId, stream_config.send_codec_spec.enable_opus_dtx))
323 .WillOnce(Return(0)); 331 .WillOnce(Return(0));
324 EXPECT_CALL( 332 EXPECT_CALL(
325 *helper.voice_engine(), 333 *helper.voice_engine(),
326 SetOpusMaxPlaybackRate( 334 SetOpusMaxPlaybackRate(
327 kChannelId, stream_config.send_codec_spec.opus_max_playback_rate)) 335 kChannelId, stream_config.send_codec_spec.opus_max_playback_rate))
328 .WillOnce(Return(0)); 336 .WillOnce(Return(0));
329 EXPECT_CALL(*helper.voice_engine(), 337 EXPECT_CALL(*helper.voice_engine(),
330 SetSendCNPayloadType( 338 SetSendCNPayloadType(
331 kChannelId, stream_config.send_codec_spec.cng_payload_type, 339 kChannelId, stream_config.send_codec_spec.cng_payload_type,
332 webrtc::kFreq16000Hz)) 340 webrtc::kFreq16000Hz))
333 .WillOnce(Return(0)); 341 .WillOnce(Return(0));
342 EXPECT_CALL(
343 *helper.channel_proxy(),
344 SetReceiverFrameLengthRange(stream_config.send_codec_spec.min_ptime_ms,
345 stream_config.send_codec_spec.max_ptime_ms));
346 EXPECT_CALL(
347 *helper.channel_proxy(),
348 EnableAudioNetworkAdaptor(*stream_config.audio_network_adaptor_config))
349 .WillOnce(Return(true));
334 internal::AudioSendStream send_stream( 350 internal::AudioSendStream send_stream(
335 stream_config, helper.audio_state(), helper.worker_queue(), 351 stream_config, helper.audio_state(), helper.worker_queue(),
336 helper.congestion_controller(), helper.bitrate_allocator(), 352 helper.congestion_controller(), helper.bitrate_allocator(),
337 helper.event_log()); 353 helper.event_log());
338 } 354 }
339 355
340 // VAD is applied when codec is mono and the CNG frequency matches the codec 356 // VAD is applied when codec is mono and the CNG frequency matches the codec
341 // sample rate. 357 // sample rate.
342 TEST(AudioSendStreamTest, SendCodecCanApplyVad) { 358 TEST(AudioSendStreamTest, SendCodecCanApplyVad) {
343 ConfigHelper helper; 359 ConfigHelper helper;
344 auto stream_config = helper.config(); 360 auto stream_config = helper.config();
345 const CodecInst kG722Codec = {9, "g722", 8000, 160, 1, 16000}; 361 const CodecInst kG722Codec = {9, "g722", 8000, 160, 1, 16000};
346 stream_config.send_codec_spec.codec_inst = kG722Codec; 362 stream_config.send_codec_spec.codec_inst = kG722Codec;
347 stream_config.send_codec_spec.cng_plfreq = 8000; 363 stream_config.send_codec_spec.cng_plfreq = 8000;
348 stream_config.send_codec_spec.cng_payload_type = 105; 364 stream_config.send_codec_spec.cng_payload_type = 105;
349 EXPECT_CALL(*helper.voice_engine(), SetVADStatus(kChannelId, true, _, _)) 365 EXPECT_CALL(*helper.voice_engine(), SetVADStatus(kChannelId, true, _, _))
350 .WillOnce(Return(0)); 366 .WillOnce(Return(0));
351 internal::AudioSendStream send_stream( 367 internal::AudioSendStream send_stream(
352 stream_config, helper.audio_state(), helper.worker_queue(), 368 stream_config, helper.audio_state(), helper.worker_queue(),
353 helper.congestion_controller(), helper.bitrate_allocator(), 369 helper.congestion_controller(), helper.bitrate_allocator(),
354 helper.event_log()); 370 helper.event_log());
355 } 371 }
356 372
357 } // namespace test 373 } // namespace test
358 } // namespace webrtc 374 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698