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