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

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

Issue 1748403002: Move RtcEventLog object from inside VoiceEngine to Call. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Another rebase and accompanying changes. Created 4 years, 5 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_receive_stream.cc ('k') | webrtc/audio/audio_send_stream_unittest.cc » ('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 "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
15 15
16 #include "webrtc/audio/audio_receive_stream.h" 16 #include "webrtc/audio/audio_receive_stream.h"
17 #include "webrtc/audio/conversion.h" 17 #include "webrtc/audio/conversion.h"
18 #include "webrtc/call/mock/mock_rtc_event_log.h"
18 #include "webrtc/modules/audio_coding/codecs/mock/mock_audio_decoder_factory.h" 19 #include "webrtc/modules/audio_coding/codecs/mock/mock_audio_decoder_factory.h"
19 #include "webrtc/modules/bitrate_controller/include/mock/mock_bitrate_controller .h" 20 #include "webrtc/modules/bitrate_controller/include/mock/mock_bitrate_controller .h"
20 #include "webrtc/modules/congestion_controller/include/mock/mock_congestion_cont roller.h" 21 #include "webrtc/modules/congestion_controller/include/mock/mock_congestion_cont roller.h"
21 #include "webrtc/modules/pacing/packet_router.h" 22 #include "webrtc/modules/pacing/packet_router.h"
22 #include "webrtc/modules/remote_bitrate_estimator/include/mock/mock_remote_bitra te_estimator.h" 23 #include "webrtc/modules/remote_bitrate_estimator/include/mock/mock_remote_bitra te_estimator.h"
23 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" 24 #include "webrtc/modules/rtp_rtcp/source/byte_io.h"
24 #include "webrtc/system_wrappers/include/clock.h" 25 #include "webrtc/system_wrappers/include/clock.h"
25 #include "webrtc/test/mock_voe_channel_proxy.h" 26 #include "webrtc/test/mock_voe_channel_proxy.h"
26 #include "webrtc/test/mock_voice_engine.h" 27 #include "webrtc/test/mock_voice_engine.h"
27 28
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 const NetworkStatistics kNetworkStats = { 64 const NetworkStatistics kNetworkStats = {
64 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};
65 const AudioDecodingCallStats kAudioDecodeStats = MakeAudioDecodeStatsForTest(); 66 const AudioDecodingCallStats kAudioDecodeStats = MakeAudioDecodeStatsForTest();
66 67
67 struct ConfigHelper { 68 struct ConfigHelper {
68 ConfigHelper() 69 ConfigHelper()
69 : simulated_clock_(123456), 70 : simulated_clock_(123456),
70 decoder_factory_(new rtc::RefCountedObject<MockAudioDecoderFactory>), 71 decoder_factory_(new rtc::RefCountedObject<MockAudioDecoderFactory>),
71 congestion_controller_(&simulated_clock_, 72 congestion_controller_(&simulated_clock_,
72 &bitrate_observer_, 73 &bitrate_observer_,
73 &remote_bitrate_observer_) { 74 &remote_bitrate_observer_,
75 &event_log_) {
74 using testing::Invoke; 76 using testing::Invoke;
75 77
76 EXPECT_CALL(voice_engine_, 78 EXPECT_CALL(voice_engine_,
77 RegisterVoiceEngineObserver(_)).WillOnce(Return(0)); 79 RegisterVoiceEngineObserver(_)).WillOnce(Return(0));
78 EXPECT_CALL(voice_engine_, 80 EXPECT_CALL(voice_engine_,
79 DeRegisterVoiceEngineObserver()).WillOnce(Return(0)); 81 DeRegisterVoiceEngineObserver()).WillOnce(Return(0));
80 AudioState::Config config; 82 AudioState::Config config;
81 config.voice_engine = &voice_engine_; 83 config.voice_engine = &voice_engine_;
82 audio_state_ = AudioState::Create(config); 84 audio_state_ = AudioState::Create(config);
83 85
(...skipping 18 matching lines...) Expand all
102 EXPECT_CALL(congestion_controller_, packet_router()) 104 EXPECT_CALL(congestion_controller_, packet_router())
103 .WillOnce(Return(&packet_router_)); 105 .WillOnce(Return(&packet_router_));
104 EXPECT_CALL(*channel_proxy_, ResetCongestionControlObjects()) 106 EXPECT_CALL(*channel_proxy_, ResetCongestionControlObjects())
105 .Times(1); 107 .Times(1);
106 EXPECT_CALL(*channel_proxy_, RegisterExternalTransport(nullptr)) 108 EXPECT_CALL(*channel_proxy_, RegisterExternalTransport(nullptr))
107 .Times(1); 109 .Times(1);
108 EXPECT_CALL(*channel_proxy_, DeRegisterExternalTransport()) 110 EXPECT_CALL(*channel_proxy_, DeRegisterExternalTransport())
109 .Times(1); 111 .Times(1);
110 EXPECT_CALL(*channel_proxy_, GetAudioDecoderFactory()) 112 EXPECT_CALL(*channel_proxy_, GetAudioDecoderFactory())
111 .WillOnce(ReturnRef(decoder_factory_)); 113 .WillOnce(ReturnRef(decoder_factory_));
114 testing::Expectation expect_set =
115 EXPECT_CALL(*channel_proxy_, SetRtcEventLog(&event_log_))
116 .Times(1);
117 EXPECT_CALL(*channel_proxy_, SetRtcEventLog(testing::IsNull()))
118 .Times(1)
119 .After(expect_set);
112 return channel_proxy_; 120 return channel_proxy_;
113 })); 121 }));
114 stream_config_.voe_channel_id = kChannelId; 122 stream_config_.voe_channel_id = kChannelId;
115 stream_config_.rtp.local_ssrc = kLocalSsrc; 123 stream_config_.rtp.local_ssrc = kLocalSsrc;
116 stream_config_.rtp.remote_ssrc = kRemoteSsrc; 124 stream_config_.rtp.remote_ssrc = kRemoteSsrc;
117 stream_config_.rtp.nack.rtp_history_ms = 300; 125 stream_config_.rtp.nack.rtp_history_ms = 300;
118 stream_config_.rtp.extensions.push_back( 126 stream_config_.rtp.extensions.push_back(
119 RtpExtension(RtpExtension::kAbsSendTimeUri, kAbsSendTimeId)); 127 RtpExtension(RtpExtension::kAbsSendTimeUri, kAbsSendTimeId));
120 stream_config_.rtp.extensions.push_back( 128 stream_config_.rtp.extensions.push_back(
121 RtpExtension(RtpExtension::kAudioLevelUri, kAudioLevelId)); 129 RtpExtension(RtpExtension::kAudioLevelUri, kAudioLevelId));
122 stream_config_.rtp.extensions.push_back(RtpExtension( 130 stream_config_.rtp.extensions.push_back(RtpExtension(
123 RtpExtension::kTransportSequenceNumberUri, kTransportSequenceNumberId)); 131 RtpExtension::kTransportSequenceNumberUri, kTransportSequenceNumberId));
124 stream_config_.decoder_factory = decoder_factory_; 132 stream_config_.decoder_factory = decoder_factory_;
125 } 133 }
126 134
127 MockCongestionController* congestion_controller() { 135 MockCongestionController* congestion_controller() {
128 return &congestion_controller_; 136 return &congestion_controller_;
129 } 137 }
130 MockRemoteBitrateEstimator* remote_bitrate_estimator() { 138 MockRemoteBitrateEstimator* remote_bitrate_estimator() {
131 return &remote_bitrate_estimator_; 139 return &remote_bitrate_estimator_;
132 } 140 }
141 MockRtcEventLog* event_log() { return &event_log_; }
133 AudioReceiveStream::Config& config() { return stream_config_; } 142 AudioReceiveStream::Config& config() { return stream_config_; }
134 rtc::scoped_refptr<AudioState> audio_state() { return audio_state_; } 143 rtc::scoped_refptr<AudioState> audio_state() { return audio_state_; }
135 MockVoiceEngine& voice_engine() { return voice_engine_; } 144 MockVoiceEngine& voice_engine() { return voice_engine_; }
136 MockVoEChannelProxy* channel_proxy() { return channel_proxy_; } 145 MockVoEChannelProxy* channel_proxy() { return channel_proxy_; }
137 146
138 void SetupMockForBweFeedback(bool send_side_bwe) { 147 void SetupMockForBweFeedback(bool send_side_bwe) {
139 EXPECT_CALL(congestion_controller_, 148 EXPECT_CALL(congestion_controller_,
140 GetRemoteBitrateEstimator(send_side_bwe)) 149 GetRemoteBitrateEstimator(send_side_bwe))
141 .WillOnce(Return(&remote_bitrate_estimator_)); 150 .WillOnce(Return(&remote_bitrate_estimator_));
142 EXPECT_CALL(remote_bitrate_estimator_, 151 EXPECT_CALL(remote_bitrate_estimator_,
(...skipping 21 matching lines...) Expand all
164 } 173 }
165 174
166 private: 175 private:
167 SimulatedClock simulated_clock_; 176 SimulatedClock simulated_clock_;
168 PacketRouter packet_router_; 177 PacketRouter packet_router_;
169 testing::NiceMock<MockCongestionObserver> bitrate_observer_; 178 testing::NiceMock<MockCongestionObserver> bitrate_observer_;
170 testing::NiceMock<MockRemoteBitrateObserver> remote_bitrate_observer_; 179 testing::NiceMock<MockRemoteBitrateObserver> remote_bitrate_observer_;
171 rtc::scoped_refptr<AudioDecoderFactory> decoder_factory_; 180 rtc::scoped_refptr<AudioDecoderFactory> decoder_factory_;
172 MockCongestionController congestion_controller_; 181 MockCongestionController congestion_controller_;
173 MockRemoteBitrateEstimator remote_bitrate_estimator_; 182 MockRemoteBitrateEstimator remote_bitrate_estimator_;
183 MockRtcEventLog event_log_;
174 testing::StrictMock<MockVoiceEngine> voice_engine_; 184 testing::StrictMock<MockVoiceEngine> voice_engine_;
175 rtc::scoped_refptr<AudioState> audio_state_; 185 rtc::scoped_refptr<AudioState> audio_state_;
176 AudioReceiveStream::Config stream_config_; 186 AudioReceiveStream::Config stream_config_;
177 testing::StrictMock<MockVoEChannelProxy>* channel_proxy_ = nullptr; 187 testing::StrictMock<MockVoEChannelProxy>* channel_proxy_ = nullptr;
178 }; 188 };
179 189
180 void BuildOneByteExtension(std::vector<uint8_t>::iterator it, 190 void BuildOneByteExtension(std::vector<uint8_t>::iterator it,
181 int id, 191 int id,
182 uint32_t extension_value, 192 uint32_t extension_value,
183 size_t value_length) { 193 size_t value_length) {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 "nack: {rtp_history_ms: 0}, extensions: [{uri: " 251 "nack: {rtp_history_ms: 0}, extensions: [{uri: "
242 "http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time, id: 2}]}, " 252 "http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time, id: 2}]}, "
243 "rtcp_send_transport: nullptr, " 253 "rtcp_send_transport: nullptr, "
244 "voe_channel_id: 2}", 254 "voe_channel_id: 2}",
245 config.ToString()); 255 config.ToString());
246 } 256 }
247 257
248 TEST(AudioReceiveStreamTest, ConstructDestruct) { 258 TEST(AudioReceiveStreamTest, ConstructDestruct) {
249 ConfigHelper helper; 259 ConfigHelper helper;
250 internal::AudioReceiveStream recv_stream( 260 internal::AudioReceiveStream recv_stream(
251 helper.congestion_controller(), helper.config(), helper.audio_state()); 261 helper.congestion_controller(), helper.config(), helper.audio_state(),
262 helper.event_log());
252 } 263 }
253 264
254 MATCHER_P(VerifyHeaderExtension, expected_extension, "") { 265 MATCHER_P(VerifyHeaderExtension, expected_extension, "") {
255 return arg.extension.hasAbsoluteSendTime == 266 return arg.extension.hasAbsoluteSendTime ==
256 expected_extension.hasAbsoluteSendTime && 267 expected_extension.hasAbsoluteSendTime &&
257 arg.extension.absoluteSendTime == 268 arg.extension.absoluteSendTime ==
258 expected_extension.absoluteSendTime && 269 expected_extension.absoluteSendTime &&
259 arg.extension.hasTransportSequenceNumber == 270 arg.extension.hasTransportSequenceNumber ==
260 expected_extension.hasTransportSequenceNumber && 271 expected_extension.hasTransportSequenceNumber &&
261 arg.extension.transportSequenceNumber == 272 arg.extension.transportSequenceNumber ==
262 expected_extension.transportSequenceNumber; 273 expected_extension.transportSequenceNumber;
263 } 274 }
264 275
265 TEST(AudioReceiveStreamTest, ReceiveRtpPacket) { 276 TEST(AudioReceiveStreamTest, ReceiveRtpPacket) {
266 ConfigHelper helper; 277 ConfigHelper helper;
267 helper.config().rtp.transport_cc = true; 278 helper.config().rtp.transport_cc = true;
268 helper.SetupMockForBweFeedback(true); 279 helper.SetupMockForBweFeedback(true);
269 internal::AudioReceiveStream recv_stream( 280 internal::AudioReceiveStream recv_stream(
270 helper.congestion_controller(), helper.config(), helper.audio_state()); 281 helper.congestion_controller(), helper.config(), helper.audio_state(),
282 helper.event_log());
271 const int kTransportSequenceNumberValue = 1234; 283 const int kTransportSequenceNumberValue = 1234;
272 std::vector<uint8_t> rtp_packet = CreateRtpHeaderWithOneByteExtension( 284 std::vector<uint8_t> rtp_packet = CreateRtpHeaderWithOneByteExtension(
273 kTransportSequenceNumberId, kTransportSequenceNumberValue, 2); 285 kTransportSequenceNumberId, kTransportSequenceNumberValue, 2);
274 PacketTime packet_time(5678000, 0); 286 PacketTime packet_time(5678000, 0);
275 const size_t kExpectedHeaderLength = 20; 287 const size_t kExpectedHeaderLength = 20;
276 RTPHeaderExtension expected_extension; 288 RTPHeaderExtension expected_extension;
277 expected_extension.hasTransportSequenceNumber = true; 289 expected_extension.hasTransportSequenceNumber = true;
278 expected_extension.transportSequenceNumber = kTransportSequenceNumberValue; 290 expected_extension.transportSequenceNumber = kTransportSequenceNumberValue;
279 EXPECT_CALL(*helper.remote_bitrate_estimator(), 291 EXPECT_CALL(*helper.remote_bitrate_estimator(),
280 IncomingPacket(packet_time.timestamp / 1000, 292 IncomingPacket(packet_time.timestamp / 1000,
281 rtp_packet.size() - kExpectedHeaderLength, 293 rtp_packet.size() - kExpectedHeaderLength,
282 VerifyHeaderExtension(expected_extension))) 294 VerifyHeaderExtension(expected_extension)))
283 .Times(1); 295 .Times(1);
284 EXPECT_CALL(*helper.channel_proxy(), 296 EXPECT_CALL(*helper.channel_proxy(),
285 ReceivedRTPPacket(&rtp_packet[0], 297 ReceivedRTPPacket(&rtp_packet[0],
286 rtp_packet.size(), 298 rtp_packet.size(),
287 _)) 299 _))
288 .WillOnce(Return(true)); 300 .WillOnce(Return(true));
289 EXPECT_TRUE( 301 EXPECT_TRUE(
290 recv_stream.DeliverRtp(&rtp_packet[0], rtp_packet.size(), packet_time)); 302 recv_stream.DeliverRtp(&rtp_packet[0], rtp_packet.size(), packet_time));
291 } 303 }
292 304
293 TEST(AudioReceiveStreamTest, ReceiveRtcpPacket) { 305 TEST(AudioReceiveStreamTest, ReceiveRtcpPacket) {
294 ConfigHelper helper; 306 ConfigHelper helper;
295 helper.config().rtp.transport_cc = true; 307 helper.config().rtp.transport_cc = true;
296 helper.SetupMockForBweFeedback(true); 308 helper.SetupMockForBweFeedback(true);
297 internal::AudioReceiveStream recv_stream( 309 internal::AudioReceiveStream recv_stream(
298 helper.congestion_controller(), helper.config(), helper.audio_state()); 310 helper.congestion_controller(), helper.config(), helper.audio_state(),
311 helper.event_log());
299 312
300 std::vector<uint8_t> rtcp_packet = CreateRtcpSenderReport(); 313 std::vector<uint8_t> rtcp_packet = CreateRtcpSenderReport();
301 EXPECT_CALL(*helper.channel_proxy(), 314 EXPECT_CALL(*helper.channel_proxy(),
302 ReceivedRTCPPacket(&rtcp_packet[0], rtcp_packet.size())) 315 ReceivedRTCPPacket(&rtcp_packet[0], rtcp_packet.size()))
303 .WillOnce(Return(true)); 316 .WillOnce(Return(true));
304 EXPECT_TRUE(recv_stream.DeliverRtcp(&rtcp_packet[0], rtcp_packet.size())); 317 EXPECT_TRUE(recv_stream.DeliverRtcp(&rtcp_packet[0], rtcp_packet.size()));
305 } 318 }
306 319
307 TEST(AudioReceiveStreamTest, GetStats) { 320 TEST(AudioReceiveStreamTest, GetStats) {
308 ConfigHelper helper; 321 ConfigHelper helper;
309 internal::AudioReceiveStream recv_stream( 322 internal::AudioReceiveStream recv_stream(
310 helper.congestion_controller(), helper.config(), helper.audio_state()); 323 helper.congestion_controller(), helper.config(), helper.audio_state(),
324 helper.event_log());
311 helper.SetupMockForGetStats(); 325 helper.SetupMockForGetStats();
312 AudioReceiveStream::Stats stats = recv_stream.GetStats(); 326 AudioReceiveStream::Stats stats = recv_stream.GetStats();
313 EXPECT_EQ(kRemoteSsrc, stats.remote_ssrc); 327 EXPECT_EQ(kRemoteSsrc, stats.remote_ssrc);
314 EXPECT_EQ(static_cast<int64_t>(kCallStats.bytesReceived), stats.bytes_rcvd); 328 EXPECT_EQ(static_cast<int64_t>(kCallStats.bytesReceived), stats.bytes_rcvd);
315 EXPECT_EQ(static_cast<uint32_t>(kCallStats.packetsReceived), 329 EXPECT_EQ(static_cast<uint32_t>(kCallStats.packetsReceived),
316 stats.packets_rcvd); 330 stats.packets_rcvd);
317 EXPECT_EQ(kCallStats.cumulativeLost, stats.packets_lost); 331 EXPECT_EQ(kCallStats.cumulativeLost, stats.packets_lost);
318 EXPECT_EQ(Q8ToFloat(kCallStats.fractionLost), stats.fraction_lost); 332 EXPECT_EQ(Q8ToFloat(kCallStats.fractionLost), stats.fraction_lost);
319 EXPECT_EQ(std::string(kCodecInst.plname), stats.codec_name); 333 EXPECT_EQ(std::string(kCodecInst.plname), stats.codec_name);
320 EXPECT_EQ(kCallStats.extendedMax, stats.ext_seqnum); 334 EXPECT_EQ(kCallStats.extendedMax, stats.ext_seqnum);
(...skipping 21 matching lines...) Expand all
342 EXPECT_EQ(kAudioDecodeStats.decoded_plc, stats.decoding_plc); 356 EXPECT_EQ(kAudioDecodeStats.decoded_plc, stats.decoding_plc);
343 EXPECT_EQ(kAudioDecodeStats.decoded_cng, stats.decoding_cng); 357 EXPECT_EQ(kAudioDecodeStats.decoded_cng, stats.decoding_cng);
344 EXPECT_EQ(kAudioDecodeStats.decoded_plc_cng, stats.decoding_plc_cng); 358 EXPECT_EQ(kAudioDecodeStats.decoded_plc_cng, stats.decoding_plc_cng);
345 EXPECT_EQ(kCallStats.capture_start_ntp_time_ms_, 359 EXPECT_EQ(kCallStats.capture_start_ntp_time_ms_,
346 stats.capture_start_ntp_time_ms); 360 stats.capture_start_ntp_time_ms);
347 } 361 }
348 362
349 TEST(AudioReceiveStreamTest, SetGain) { 363 TEST(AudioReceiveStreamTest, SetGain) {
350 ConfigHelper helper; 364 ConfigHelper helper;
351 internal::AudioReceiveStream recv_stream( 365 internal::AudioReceiveStream recv_stream(
352 helper.congestion_controller(), helper.config(), helper.audio_state()); 366 helper.congestion_controller(), helper.config(), helper.audio_state(),
367 helper.event_log());
353 EXPECT_CALL(*helper.channel_proxy(), 368 EXPECT_CALL(*helper.channel_proxy(),
354 SetChannelOutputVolumeScaling(FloatEq(0.765f))); 369 SetChannelOutputVolumeScaling(FloatEq(0.765f)));
355 recv_stream.SetGain(0.765f); 370 recv_stream.SetGain(0.765f);
356 } 371 }
357 } // namespace test 372 } // namespace test
358 } // namespace webrtc 373 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/audio/audio_receive_stream.cc ('k') | webrtc/audio/audio_send_stream_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698