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

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

Issue 2436033002: Replace AudioConferenceMixer with AudioMixer. (Closed)
Patch Set: New ReceiveStream test and no fixture in AudioPath test. 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 123, 456, false, 0, 0, 789, 12, 345, 678, 901, -1, -1, -1, -1, -1, 0}; 65 123, 456, false, 0, 0, 789, 12, 345, 678, 901, -1, -1, -1, -1, -1, 0};
66 const AudioDecodingCallStats kAudioDecodeStats = MakeAudioDecodeStatsForTest(); 66 const AudioDecodingCallStats kAudioDecodeStats = MakeAudioDecodeStatsForTest();
67 67
68 struct ConfigHelper { 68 struct ConfigHelper {
69 ConfigHelper() 69 ConfigHelper()
70 : simulated_clock_(123456), 70 : simulated_clock_(123456),
71 decoder_factory_(new rtc::RefCountedObject<MockAudioDecoderFactory>), 71 decoder_factory_(new rtc::RefCountedObject<MockAudioDecoderFactory>),
72 congestion_controller_(&simulated_clock_, 72 congestion_controller_(&simulated_clock_,
73 &bitrate_observer_, 73 &bitrate_observer_,
74 &remote_bitrate_observer_, 74 &remote_bitrate_observer_,
75 &event_log_) { 75 &event_log_),
76 audio_mixer_(AudioMixerImpl::Create()) {
aleloi 2016/11/17 18:12:26 Changed the helper method to save a pointer to the
76 using testing::Invoke; 77 using testing::Invoke;
77 78
78 EXPECT_CALL(voice_engine_, 79 EXPECT_CALL(voice_engine_,
79 RegisterVoiceEngineObserver(_)).WillOnce(Return(0)); 80 RegisterVoiceEngineObserver(_)).WillOnce(Return(0));
80 EXPECT_CALL(voice_engine_, 81 EXPECT_CALL(voice_engine_,
81 DeRegisterVoiceEngineObserver()).WillOnce(Return(0)); 82 DeRegisterVoiceEngineObserver()).WillOnce(Return(0));
82 EXPECT_CALL(voice_engine_, audio_processing()); 83 EXPECT_CALL(voice_engine_, audio_processing());
83 EXPECT_CALL(voice_engine_, audio_device_module()); 84 EXPECT_CALL(voice_engine_, audio_device_module());
84 EXPECT_CALL(voice_engine_, audio_transport()); 85 EXPECT_CALL(voice_engine_, audio_transport());
85 86
86 AudioState::Config config; 87 AudioState::Config config;
87 config.voice_engine = &voice_engine_; 88 config.voice_engine = &voice_engine_;
88 config.audio_mixer = AudioMixerImpl::Create(); 89 config.audio_mixer = audio_mixer_;
89 audio_state_ = AudioState::Create(config); 90 audio_state_ = AudioState::Create(config);
90 91
91 EXPECT_CALL(voice_engine_, ChannelProxyFactory(kChannelId)) 92 EXPECT_CALL(voice_engine_, ChannelProxyFactory(kChannelId))
92 .WillOnce(Invoke([this](int channel_id) { 93 .WillOnce(Invoke([this](int channel_id) {
93 EXPECT_FALSE(channel_proxy_); 94 EXPECT_FALSE(channel_proxy_);
94 channel_proxy_ = new testing::StrictMock<MockVoEChannelProxy>(); 95 channel_proxy_ = new testing::StrictMock<MockVoEChannelProxy>();
95 EXPECT_CALL(*channel_proxy_, SetLocalSSRC(kLocalSsrc)).Times(1); 96 EXPECT_CALL(*channel_proxy_, SetLocalSSRC(kLocalSsrc)).Times(1);
96 EXPECT_CALL(*channel_proxy_, SetNACKStatus(true, 15)).Times(1); 97 EXPECT_CALL(*channel_proxy_, SetNACKStatus(true, 15)).Times(1);
97 EXPECT_CALL(*channel_proxy_, 98 EXPECT_CALL(*channel_proxy_,
98 SetReceiveAudioLevelIndicationStatus(true, kAudioLevelId)) 99 SetReceiveAudioLevelIndicationStatus(true, kAudioLevelId))
(...skipping 16 matching lines...) Expand all
115 .WillOnce(ReturnRef(decoder_factory_)); 116 .WillOnce(ReturnRef(decoder_factory_));
116 testing::Expectation expect_set = 117 testing::Expectation expect_set =
117 EXPECT_CALL(*channel_proxy_, SetRtcEventLog(&event_log_)) 118 EXPECT_CALL(*channel_proxy_, SetRtcEventLog(&event_log_))
118 .Times(1); 119 .Times(1);
119 EXPECT_CALL(*channel_proxy_, SetRtcEventLog(testing::IsNull())) 120 EXPECT_CALL(*channel_proxy_, SetRtcEventLog(testing::IsNull()))
120 .Times(1) 121 .Times(1)
121 .After(expect_set); 122 .After(expect_set);
122 EXPECT_CALL(*channel_proxy_, DisassociateSendChannel()).Times(1); 123 EXPECT_CALL(*channel_proxy_, DisassociateSendChannel()).Times(1);
123 return channel_proxy_; 124 return channel_proxy_;
124 })); 125 }));
125 EXPECT_CALL(voice_engine_, StopPlayout(kChannelId)).WillOnce(Return(0));
126 stream_config_.voe_channel_id = kChannelId; 126 stream_config_.voe_channel_id = kChannelId;
127 stream_config_.rtp.local_ssrc = kLocalSsrc; 127 stream_config_.rtp.local_ssrc = kLocalSsrc;
128 stream_config_.rtp.remote_ssrc = kRemoteSsrc; 128 stream_config_.rtp.remote_ssrc = kRemoteSsrc;
129 stream_config_.rtp.nack.rtp_history_ms = 300; 129 stream_config_.rtp.nack.rtp_history_ms = 300;
130 stream_config_.rtp.extensions.push_back( 130 stream_config_.rtp.extensions.push_back(
131 RtpExtension(RtpExtension::kAudioLevelUri, kAudioLevelId)); 131 RtpExtension(RtpExtension::kAudioLevelUri, kAudioLevelId));
132 stream_config_.rtp.extensions.push_back(RtpExtension( 132 stream_config_.rtp.extensions.push_back(RtpExtension(
133 RtpExtension::kTransportSequenceNumberUri, kTransportSequenceNumberId)); 133 RtpExtension::kTransportSequenceNumberUri, kTransportSequenceNumberId));
134 stream_config_.decoder_factory = decoder_factory_; 134 stream_config_.decoder_factory = decoder_factory_;
135 } 135 }
136 136
137 MockCongestionController* congestion_controller() { 137 MockCongestionController* congestion_controller() {
138 return &congestion_controller_; 138 return &congestion_controller_;
139 } 139 }
140 MockRemoteBitrateEstimator* remote_bitrate_estimator() { 140 MockRemoteBitrateEstimator* remote_bitrate_estimator() {
141 return &remote_bitrate_estimator_; 141 return &remote_bitrate_estimator_;
142 } 142 }
143 MockRtcEventLog* event_log() { return &event_log_; } 143 MockRtcEventLog* event_log() { return &event_log_; }
144 AudioReceiveStream::Config& config() { return stream_config_; } 144 AudioReceiveStream::Config& config() { return stream_config_; }
145 rtc::scoped_refptr<AudioState> audio_state() { return audio_state_; } 145 rtc::scoped_refptr<AudioState> audio_state() { return audio_state_; }
146 rtc::scoped_refptr<AudioMixerImpl> audio_mixer() { return audio_mixer_; }
146 MockVoiceEngine& voice_engine() { return voice_engine_; } 147 MockVoiceEngine& voice_engine() { return voice_engine_; }
147 MockVoEChannelProxy* channel_proxy() { return channel_proxy_; } 148 MockVoEChannelProxy* channel_proxy() { return channel_proxy_; }
148 149
149 void SetupMockForBweFeedback(bool send_side_bwe) { 150 void SetupMockForBweFeedback(bool send_side_bwe) {
150 EXPECT_CALL(congestion_controller_, 151 EXPECT_CALL(congestion_controller_,
151 GetRemoteBitrateEstimator(send_side_bwe)) 152 GetRemoteBitrateEstimator(send_side_bwe))
152 .WillOnce(Return(&remote_bitrate_estimator_)); 153 .WillOnce(Return(&remote_bitrate_estimator_));
153 EXPECT_CALL(remote_bitrate_estimator_, 154 EXPECT_CALL(remote_bitrate_estimator_,
154 RemoveStream(stream_config_.rtp.remote_ssrc)); 155 RemoveStream(stream_config_.rtp.remote_ssrc));
155 } 156 }
(...skipping 22 matching lines...) Expand all
178 SimulatedClock simulated_clock_; 179 SimulatedClock simulated_clock_;
179 PacketRouter packet_router_; 180 PacketRouter packet_router_;
180 testing::NiceMock<MockCongestionObserver> bitrate_observer_; 181 testing::NiceMock<MockCongestionObserver> bitrate_observer_;
181 testing::NiceMock<MockRemoteBitrateObserver> remote_bitrate_observer_; 182 testing::NiceMock<MockRemoteBitrateObserver> remote_bitrate_observer_;
182 rtc::scoped_refptr<AudioDecoderFactory> decoder_factory_; 183 rtc::scoped_refptr<AudioDecoderFactory> decoder_factory_;
183 MockCongestionController congestion_controller_; 184 MockCongestionController congestion_controller_;
184 MockRemoteBitrateEstimator remote_bitrate_estimator_; 185 MockRemoteBitrateEstimator remote_bitrate_estimator_;
185 MockRtcEventLog event_log_; 186 MockRtcEventLog event_log_;
186 testing::StrictMock<MockVoiceEngine> voice_engine_; 187 testing::StrictMock<MockVoiceEngine> voice_engine_;
187 rtc::scoped_refptr<AudioState> audio_state_; 188 rtc::scoped_refptr<AudioState> audio_state_;
189 rtc::scoped_refptr<AudioMixerImpl> audio_mixer_;
188 AudioReceiveStream::Config stream_config_; 190 AudioReceiveStream::Config stream_config_;
189 testing::StrictMock<MockVoEChannelProxy>* channel_proxy_ = nullptr; 191 testing::StrictMock<MockVoEChannelProxy>* channel_proxy_ = nullptr;
190 }; 192 };
191 193
192 void BuildOneByteExtension(std::vector<uint8_t>::iterator it, 194 void BuildOneByteExtension(std::vector<uint8_t>::iterator it,
193 int id, 195 int id,
194 uint32_t extension_value, 196 uint32_t extension_value,
195 size_t value_length) { 197 size_t value_length) {
196 const uint16_t kRtpOneByteHeaderExtensionId = 0xBEDE; 198 const uint16_t kRtpOneByteHeaderExtensionId = 0xBEDE;
197 ByteWriter<uint16_t>::WriteBigEndian(&(*it), kRtpOneByteHeaderExtensionId); 199 ByteWriter<uint16_t>::WriteBigEndian(&(*it), kRtpOneByteHeaderExtensionId);
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 363
362 TEST(AudioReceiveStreamTest, SetGain) { 364 TEST(AudioReceiveStreamTest, SetGain) {
363 ConfigHelper helper; 365 ConfigHelper helper;
364 internal::AudioReceiveStream recv_stream( 366 internal::AudioReceiveStream recv_stream(
365 helper.congestion_controller(), helper.config(), helper.audio_state(), 367 helper.congestion_controller(), helper.config(), helper.audio_state(),
366 helper.event_log()); 368 helper.event_log());
367 EXPECT_CALL(*helper.channel_proxy(), 369 EXPECT_CALL(*helper.channel_proxy(),
368 SetChannelOutputVolumeScaling(FloatEq(0.765f))); 370 SetChannelOutputVolumeScaling(FloatEq(0.765f)));
369 recv_stream.SetGain(0.765f); 371 recv_stream.SetGain(0.765f);
370 } 372 }
373
374 TEST(AudioReceiveStreamTest, StreamShouldNotBeAddedToMixerWhenVoEReturnsError) {
375 ConfigHelper helper;
376 internal::AudioReceiveStream recv_stream(
377 helper.congestion_controller(), helper.config(), helper.audio_state(),
378 helper.event_log());
379
380 EXPECT_CALL(helper.voice_engine(), StartPlayout(_)).WillOnce(Return(-1));
381
382 recv_stream.Start();
383
384 EXPECT_EQ(helper.audio_mixer()->GetSourcePresenceStatusForTest(&recv_stream),
385 false);
386 }
387
388 TEST(AudioReceiveStreamTest, StreamShouldBeAddedToMixerOnStart) {
389 ConfigHelper helper;
390 internal::AudioReceiveStream recv_stream(
391 helper.congestion_controller(), helper.config(), helper.audio_state(),
392 helper.event_log());
393
394 EXPECT_CALL(helper.voice_engine(), StartPlayout(_)).WillOnce(Return(0));
395 EXPECT_CALL(helper.voice_engine(), StopPlayout(_));
396
397 recv_stream.Start();
398
399 EXPECT_EQ(helper.audio_mixer()->GetSourcePresenceStatusForTest(&recv_stream),
400 true);
401 }
371 } // namespace test 402 } // namespace test
372 } // namespace webrtc 403 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698