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/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" | 21 #include "webrtc/modules/congestion_controller/include/congestion_controller.h" |
22 #include "webrtc/modules/congestion_controller/include/mock/mock_congestion_cont roller.h" | 22 #include "webrtc/modules/congestion_controller/include/mock/mock_congestion_cont roller.h" |
23 #include "webrtc/modules/pacing/paced_sender.h" | 23 #include "webrtc/modules/pacing/paced_sender.h" |
24 #include "webrtc/modules/remote_bitrate_estimator/include/mock/mock_remote_bitra te_estimator.h" | 24 #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" | 25 #include "webrtc/modules/rtp_rtcp/mocks/mock_rtcp_rtt_stats.h" |
26 #include "webrtc/test/gtest.h" | 26 #include "webrtc/test/gtest.h" |
27 #include "webrtc/test/mock_voe_channel_proxy.h" | 27 #include "webrtc/test/mock_voe_channel_proxy.h" |
28 #include "webrtc/test/mock_voice_engine.h" | 28 #include "webrtc/test/mock_voice_engine.h" |
29 #include "webrtc/voice_engine/transmit_mixer.h" | |
29 | 30 |
30 namespace webrtc { | 31 namespace webrtc { |
31 namespace test { | 32 namespace test { |
32 namespace { | 33 namespace { |
33 | 34 |
34 using testing::_; | 35 using testing::_; |
35 using testing::Eq; | 36 using testing::Eq; |
36 using testing::Ne; | 37 using testing::Ne; |
37 using testing::Return; | 38 using testing::Return; |
38 | 39 |
39 const int kChannelId = 1; | 40 const int kChannelId = 1; |
40 const uint32_t kSsrc = 1234; | 41 const uint32_t kSsrc = 1234; |
41 const char* kCName = "foo_name"; | 42 const char* kCName = "foo_name"; |
42 const int kAudioLevelId = 2; | 43 const int kAudioLevelId = 2; |
43 const int kTransportSequenceNumberId = 4; | 44 const int kTransportSequenceNumberId = 4; |
44 const int kEchoDelayMedian = 254; | 45 const int kEchoDelayMedian = 254; |
45 const int kEchoDelayStdDev = -3; | 46 const int kEchoDelayStdDev = -3; |
46 const int kEchoReturnLoss = -65; | 47 const int kEchoReturnLoss = -65; |
47 const int kEchoReturnLossEnhancement = 101; | 48 const int kEchoReturnLossEnhancement = 101; |
48 const float kResidualEchoLikelihood = -1.0f; | 49 const float kResidualEchoLikelihood = -1.0f; |
49 const unsigned int kSpeechInputLevel = 96; | 50 const int32_t kSpeechInputLevel = 96; |
50 const CallStatistics kCallStats = { | 51 const CallStatistics kCallStats = { |
51 1345, 1678, 1901, 1234, 112, 13456, 17890, 1567, -1890, -1123}; | 52 1345, 1678, 1901, 1234, 112, 13456, 17890, 1567, -1890, -1123}; |
52 const ReportBlock kReportBlock = {456, 780, 123, 567, 890, 132, 143, 13354}; | 53 const ReportBlock kReportBlock = {456, 780, 123, 567, 890, 132, 143, 13354}; |
53 const int kTelephoneEventPayloadType = 123; | 54 const int kTelephoneEventPayloadType = 123; |
54 const int kTelephoneEventPayloadFrequency = 65432; | 55 const int kTelephoneEventPayloadFrequency = 65432; |
55 const int kTelephoneEventCode = 45; | 56 const int kTelephoneEventCode = 45; |
56 const int kTelephoneEventDuration = 6789; | 57 const int kTelephoneEventDuration = 6789; |
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 |
67 class MockTransmitMixer : public voe::TransmitMixer { | |
68 public: | |
69 MockTransmitMixer() = default; | |
70 virtual ~MockTransmitMixer() = default; | |
kwiberg-webrtc
2017/02/28 13:59:18
Do you need these two lines?
the sun
2017/03/02 00:36:25
Nope.
I'm tempted to make it a struct to remove o
| |
71 | |
72 MOCK_CONST_METHOD0(AudioLevelFullRange, int16_t()); | |
73 }; | |
74 | |
66 struct ConfigHelper { | 75 struct ConfigHelper { |
67 explicit ConfigHelper(bool audio_bwe_enabled) | 76 explicit ConfigHelper(bool audio_bwe_enabled) |
68 : simulated_clock_(123456), | 77 : simulated_clock_(123456), |
69 stream_config_(nullptr), | 78 stream_config_(nullptr), |
70 congestion_controller_(&simulated_clock_, | 79 congestion_controller_(&simulated_clock_, |
71 &bitrate_observer_, | 80 &bitrate_observer_, |
72 &remote_bitrate_observer_, | 81 &remote_bitrate_observer_, |
73 &event_log_, | 82 &event_log_, |
74 &packet_router_), | 83 &packet_router_), |
75 bitrate_allocator_(&limit_observer_), | 84 bitrate_allocator_(&limit_observer_), |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
206 block.fraction_lost = 0; | 215 block.fraction_lost = 0; |
207 report_blocks.push_back(block); // Duplicate SSRC, bad fraction_lost. | 216 report_blocks.push_back(block); // Duplicate SSRC, bad fraction_lost. |
208 | 217 |
209 EXPECT_TRUE(channel_proxy_); | 218 EXPECT_TRUE(channel_proxy_); |
210 EXPECT_CALL(*channel_proxy_, GetRTCPStatistics()) | 219 EXPECT_CALL(*channel_proxy_, GetRTCPStatistics()) |
211 .WillRepeatedly(Return(kCallStats)); | 220 .WillRepeatedly(Return(kCallStats)); |
212 EXPECT_CALL(*channel_proxy_, GetRemoteRTCPReportBlocks()) | 221 EXPECT_CALL(*channel_proxy_, GetRemoteRTCPReportBlocks()) |
213 .WillRepeatedly(Return(report_blocks)); | 222 .WillRepeatedly(Return(report_blocks)); |
214 EXPECT_CALL(*channel_proxy_, GetSendCodec(_)) | 223 EXPECT_CALL(*channel_proxy_, GetSendCodec(_)) |
215 .WillRepeatedly(DoAll(SetArgPointee<0>(kIsacCodec), Return(true))); | 224 .WillRepeatedly(DoAll(SetArgPointee<0>(kIsacCodec), Return(true))); |
216 EXPECT_CALL(voice_engine_, GetSpeechInputLevelFullRange(_)) | 225 EXPECT_CALL(voice_engine_, transmit_mixer()) |
217 .WillRepeatedly(DoAll(SetArgReferee<0>(kSpeechInputLevel), Return(0))); | 226 .WillRepeatedly(Return(&transmit_mixer_)); |
218 EXPECT_CALL(voice_engine_, audio_processing()) | 227 EXPECT_CALL(voice_engine_, audio_processing()) |
219 .WillRepeatedly(Return(&audio_processing_)); | 228 .WillRepeatedly(Return(&audio_processing_)); |
220 | 229 |
230 EXPECT_CALL(transmit_mixer_, AudioLevelFullRange()) | |
231 .WillRepeatedly(Return(kSpeechInputLevel)); | |
232 | |
221 // We have to set the instantaneous value, the average, min and max. We only | 233 // We have to set the instantaneous value, the average, min and max. We only |
222 // care about the instantaneous value, so we set all to the same value. | 234 // care about the instantaneous value, so we set all to the same value. |
223 audio_processing_stats_.echo_return_loss.Set( | 235 audio_processing_stats_.echo_return_loss.Set( |
224 kEchoReturnLoss, kEchoReturnLoss, kEchoReturnLoss, kEchoReturnLoss); | 236 kEchoReturnLoss, kEchoReturnLoss, kEchoReturnLoss, kEchoReturnLoss); |
225 audio_processing_stats_.echo_return_loss_enhancement.Set( | 237 audio_processing_stats_.echo_return_loss_enhancement.Set( |
226 kEchoReturnLossEnhancement, kEchoReturnLossEnhancement, | 238 kEchoReturnLossEnhancement, kEchoReturnLossEnhancement, |
227 kEchoReturnLossEnhancement, kEchoReturnLossEnhancement); | 239 kEchoReturnLossEnhancement, kEchoReturnLossEnhancement); |
228 audio_processing_stats_.delay_median = kEchoDelayMedian; | 240 audio_processing_stats_.delay_median = kEchoDelayMedian; |
229 audio_processing_stats_.delay_standard_deviation = kEchoDelayStdDev; | 241 audio_processing_stats_.delay_standard_deviation = kEchoDelayStdDev; |
230 | 242 |
231 EXPECT_CALL(audio_processing_, GetStatistics()) | 243 EXPECT_CALL(audio_processing_, GetStatistics()) |
232 .WillRepeatedly(Return(audio_processing_stats_)); | 244 .WillRepeatedly(Return(audio_processing_stats_)); |
233 } | 245 } |
234 | 246 |
235 private: | 247 private: |
236 SimulatedClock simulated_clock_; | 248 SimulatedClock simulated_clock_; |
237 testing::StrictMock<MockVoiceEngine> voice_engine_; | 249 testing::StrictMock<MockVoiceEngine> voice_engine_; |
238 rtc::scoped_refptr<AudioState> audio_state_; | 250 rtc::scoped_refptr<AudioState> audio_state_; |
239 AudioSendStream::Config stream_config_; | 251 AudioSendStream::Config stream_config_; |
240 testing::StrictMock<MockVoEChannelProxy>* channel_proxy_ = nullptr; | 252 testing::StrictMock<MockVoEChannelProxy>* channel_proxy_ = nullptr; |
241 testing::NiceMock<MockCongestionObserver> bitrate_observer_; | 253 testing::NiceMock<MockCongestionObserver> bitrate_observer_; |
242 testing::NiceMock<MockRemoteBitrateObserver> remote_bitrate_observer_; | 254 testing::NiceMock<MockRemoteBitrateObserver> remote_bitrate_observer_; |
243 MockAudioProcessing audio_processing_; | 255 MockAudioProcessing audio_processing_; |
256 MockTransmitMixer transmit_mixer_; | |
244 AudioProcessing::AudioProcessingStatistics audio_processing_stats_; | 257 AudioProcessing::AudioProcessingStatistics audio_processing_stats_; |
245 PacketRouter packet_router_; | 258 PacketRouter packet_router_; |
246 CongestionController congestion_controller_; | 259 CongestionController congestion_controller_; |
247 MockRtcEventLog event_log_; | 260 MockRtcEventLog event_log_; |
248 MockRtcpRttStats rtcp_rtt_stats_; | 261 MockRtcpRttStats rtcp_rtt_stats_; |
249 testing::NiceMock<MockLimitObserver> limit_observer_; | 262 testing::NiceMock<MockLimitObserver> limit_observer_; |
250 BitrateAllocator bitrate_allocator_; | 263 BitrateAllocator bitrate_allocator_; |
251 // |worker_queue| is defined last to ensure all pending tasks are cancelled | 264 // |worker_queue| is defined last to ensure all pending tasks are cancelled |
252 // and deleted before any other members. | 265 // and deleted before any other members. |
253 rtc::TaskQueue worker_queue_; | 266 rtc::TaskQueue worker_queue_; |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
459 internal::AudioSendStream send_stream( | 472 internal::AudioSendStream send_stream( |
460 helper.config(), helper.audio_state(), helper.worker_queue(), | 473 helper.config(), helper.audio_state(), helper.worker_queue(), |
461 helper.packet_router(), helper.congestion_controller(), | 474 helper.packet_router(), helper.congestion_controller(), |
462 helper.bitrate_allocator(), helper.event_log(), helper.rtcp_rtt_stats()); | 475 helper.bitrate_allocator(), helper.event_log(), helper.rtcp_rtt_stats()); |
463 EXPECT_CALL(*helper.channel_proxy(), SetBitrate(_, 5000)); | 476 EXPECT_CALL(*helper.channel_proxy(), SetBitrate(_, 5000)); |
464 send_stream.OnBitrateUpdated(50000, 0.0, 50, 5000); | 477 send_stream.OnBitrateUpdated(50000, 0.0, 50, 5000); |
465 } | 478 } |
466 | 479 |
467 } // namespace test | 480 } // namespace test |
468 } // namespace webrtc | 481 } // namespace webrtc |
OLD | NEW |