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

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

Issue 2721003002: Remove usage of VoEVolumeControl from WVoE and Audio[Send|Receive]Stream. (Closed)
Patch Set: rebase+comment 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/audio_receive_stream.h » ('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" 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 MOCK_CONST_METHOD0(AudioLevelFullRange, int16_t());
70 };
71
66 struct ConfigHelper { 72 struct ConfigHelper {
67 explicit ConfigHelper(bool audio_bwe_enabled) 73 explicit ConfigHelper(bool audio_bwe_enabled)
68 : simulated_clock_(123456), 74 : simulated_clock_(123456),
69 stream_config_(nullptr), 75 stream_config_(nullptr),
70 congestion_controller_(&simulated_clock_, 76 congestion_controller_(&simulated_clock_,
71 &bitrate_observer_, 77 &bitrate_observer_,
72 &remote_bitrate_observer_, 78 &remote_bitrate_observer_,
73 &event_log_, 79 &event_log_,
74 &packet_router_), 80 &packet_router_),
75 bitrate_allocator_(&limit_observer_), 81 bitrate_allocator_(&limit_observer_),
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 block.fraction_lost = 0; 212 block.fraction_lost = 0;
207 report_blocks.push_back(block); // Duplicate SSRC, bad fraction_lost. 213 report_blocks.push_back(block); // Duplicate SSRC, bad fraction_lost.
208 214
209 EXPECT_TRUE(channel_proxy_); 215 EXPECT_TRUE(channel_proxy_);
210 EXPECT_CALL(*channel_proxy_, GetRTCPStatistics()) 216 EXPECT_CALL(*channel_proxy_, GetRTCPStatistics())
211 .WillRepeatedly(Return(kCallStats)); 217 .WillRepeatedly(Return(kCallStats));
212 EXPECT_CALL(*channel_proxy_, GetRemoteRTCPReportBlocks()) 218 EXPECT_CALL(*channel_proxy_, GetRemoteRTCPReportBlocks())
213 .WillRepeatedly(Return(report_blocks)); 219 .WillRepeatedly(Return(report_blocks));
214 EXPECT_CALL(*channel_proxy_, GetSendCodec(_)) 220 EXPECT_CALL(*channel_proxy_, GetSendCodec(_))
215 .WillRepeatedly(DoAll(SetArgPointee<0>(kIsacCodec), Return(true))); 221 .WillRepeatedly(DoAll(SetArgPointee<0>(kIsacCodec), Return(true)));
216 EXPECT_CALL(voice_engine_, GetSpeechInputLevelFullRange(_)) 222 EXPECT_CALL(voice_engine_, transmit_mixer())
217 .WillRepeatedly(DoAll(SetArgReferee<0>(kSpeechInputLevel), Return(0))); 223 .WillRepeatedly(Return(&transmit_mixer_));
218 EXPECT_CALL(voice_engine_, audio_processing()) 224 EXPECT_CALL(voice_engine_, audio_processing())
219 .WillRepeatedly(Return(&audio_processing_)); 225 .WillRepeatedly(Return(&audio_processing_));
220 226
227 EXPECT_CALL(transmit_mixer_, AudioLevelFullRange())
228 .WillRepeatedly(Return(kSpeechInputLevel));
229
221 // We have to set the instantaneous value, the average, min and max. We only 230 // 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. 231 // care about the instantaneous value, so we set all to the same value.
223 audio_processing_stats_.echo_return_loss.Set( 232 audio_processing_stats_.echo_return_loss.Set(
224 kEchoReturnLoss, kEchoReturnLoss, kEchoReturnLoss, kEchoReturnLoss); 233 kEchoReturnLoss, kEchoReturnLoss, kEchoReturnLoss, kEchoReturnLoss);
225 audio_processing_stats_.echo_return_loss_enhancement.Set( 234 audio_processing_stats_.echo_return_loss_enhancement.Set(
226 kEchoReturnLossEnhancement, kEchoReturnLossEnhancement, 235 kEchoReturnLossEnhancement, kEchoReturnLossEnhancement,
227 kEchoReturnLossEnhancement, kEchoReturnLossEnhancement); 236 kEchoReturnLossEnhancement, kEchoReturnLossEnhancement);
228 audio_processing_stats_.delay_median = kEchoDelayMedian; 237 audio_processing_stats_.delay_median = kEchoDelayMedian;
229 audio_processing_stats_.delay_standard_deviation = kEchoDelayStdDev; 238 audio_processing_stats_.delay_standard_deviation = kEchoDelayStdDev;
230 239
231 EXPECT_CALL(audio_processing_, GetStatistics()) 240 EXPECT_CALL(audio_processing_, GetStatistics())
232 .WillRepeatedly(Return(audio_processing_stats_)); 241 .WillRepeatedly(Return(audio_processing_stats_));
233 } 242 }
234 243
235 private: 244 private:
236 SimulatedClock simulated_clock_; 245 SimulatedClock simulated_clock_;
237 testing::StrictMock<MockVoiceEngine> voice_engine_; 246 testing::StrictMock<MockVoiceEngine> voice_engine_;
238 rtc::scoped_refptr<AudioState> audio_state_; 247 rtc::scoped_refptr<AudioState> audio_state_;
239 AudioSendStream::Config stream_config_; 248 AudioSendStream::Config stream_config_;
240 testing::StrictMock<MockVoEChannelProxy>* channel_proxy_ = nullptr; 249 testing::StrictMock<MockVoEChannelProxy>* channel_proxy_ = nullptr;
241 testing::NiceMock<MockCongestionObserver> bitrate_observer_; 250 testing::NiceMock<MockCongestionObserver> bitrate_observer_;
242 testing::NiceMock<MockRemoteBitrateObserver> remote_bitrate_observer_; 251 testing::NiceMock<MockRemoteBitrateObserver> remote_bitrate_observer_;
243 MockAudioProcessing audio_processing_; 252 MockAudioProcessing audio_processing_;
253 MockTransmitMixer transmit_mixer_;
244 AudioProcessing::AudioProcessingStatistics audio_processing_stats_; 254 AudioProcessing::AudioProcessingStatistics audio_processing_stats_;
245 PacketRouter packet_router_; 255 PacketRouter packet_router_;
246 CongestionController congestion_controller_; 256 CongestionController congestion_controller_;
247 MockRtcEventLog event_log_; 257 MockRtcEventLog event_log_;
248 MockRtcpRttStats rtcp_rtt_stats_; 258 MockRtcpRttStats rtcp_rtt_stats_;
249 testing::NiceMock<MockLimitObserver> limit_observer_; 259 testing::NiceMock<MockLimitObserver> limit_observer_;
250 BitrateAllocator bitrate_allocator_; 260 BitrateAllocator bitrate_allocator_;
251 // |worker_queue| is defined last to ensure all pending tasks are cancelled 261 // |worker_queue| is defined last to ensure all pending tasks are cancelled
252 // and deleted before any other members. 262 // and deleted before any other members.
253 rtc::TaskQueue worker_queue_; 263 rtc::TaskQueue worker_queue_;
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 internal::AudioSendStream send_stream( 469 internal::AudioSendStream send_stream(
460 helper.config(), helper.audio_state(), helper.worker_queue(), 470 helper.config(), helper.audio_state(), helper.worker_queue(),
461 helper.packet_router(), helper.congestion_controller(), 471 helper.packet_router(), helper.congestion_controller(),
462 helper.bitrate_allocator(), helper.event_log(), helper.rtcp_rtt_stats()); 472 helper.bitrate_allocator(), helper.event_log(), helper.rtcp_rtt_stats());
463 EXPECT_CALL(*helper.channel_proxy(), SetBitrate(_, 5000)); 473 EXPECT_CALL(*helper.channel_proxy(), SetBitrate(_, 5000));
464 send_stream.OnBitrateUpdated(50000, 0.0, 50, 5000); 474 send_stream.OnBitrateUpdated(50000, 0.0, 50, 5000);
465 } 475 }
466 476
467 } // namespace test 477 } // namespace test
468 } // namespace webrtc 478 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/audio/audio_send_stream.cc ('k') | webrtc/call/audio_receive_stream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698