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: Fix for failing tests. Created 4 years, 8 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/bitrate_controller/include/mock/mock_bitrate_controller .h" 19 #include "webrtc/modules/bitrate_controller/include/mock/mock_bitrate_controller .h"
19 #include "webrtc/modules/congestion_controller/include/mock/mock_congestion_cont roller.h" 20 #include "webrtc/modules/congestion_controller/include/mock/mock_congestion_cont roller.h"
20 #include "webrtc/modules/pacing/packet_router.h" 21 #include "webrtc/modules/pacing/packet_router.h"
21 #include "webrtc/modules/remote_bitrate_estimator/include/mock/mock_remote_bitra te_estimator.h" 22 #include "webrtc/modules/remote_bitrate_estimator/include/mock/mock_remote_bitra te_estimator.h"
22 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" 23 #include "webrtc/modules/rtp_rtcp/source/byte_io.h"
23 #include "webrtc/system_wrappers/include/clock.h" 24 #include "webrtc/system_wrappers/include/clock.h"
24 #include "webrtc/test/mock_voe_channel_proxy.h" 25 #include "webrtc/test/mock_voe_channel_proxy.h"
25 #include "webrtc/test/mock_voice_engine.h" 26 #include "webrtc/test/mock_voice_engine.h"
26 27
27 namespace webrtc { 28 namespace webrtc {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 123, "codec_name_recv", 96000, -187, 0, -103}; 60 123, "codec_name_recv", 96000, -187, 0, -103};
60 const NetworkStatistics kNetworkStats = { 61 const NetworkStatistics kNetworkStats = {
61 123, 456, false, 0, 0, 789, 12, 345, 678, 901, -1, -1, -1, -1, -1, 0}; 62 123, 456, false, 0, 0, 789, 12, 345, 678, 901, -1, -1, -1, -1, -1, 0};
62 const AudioDecodingCallStats kAudioDecodeStats = MakeAudioDecodeStatsForTest(); 63 const AudioDecodingCallStats kAudioDecodeStats = MakeAudioDecodeStatsForTest();
63 64
64 struct ConfigHelper { 65 struct ConfigHelper {
65 ConfigHelper() 66 ConfigHelper()
66 : simulated_clock_(123456), 67 : simulated_clock_(123456),
67 congestion_controller_(&simulated_clock_, 68 congestion_controller_(&simulated_clock_,
68 &bitrate_observer_, 69 &bitrate_observer_,
69 &remote_bitrate_observer_) { 70 &remote_bitrate_observer_,
71 &event_log_) {
70 using testing::Invoke; 72 using testing::Invoke;
71 73
72 EXPECT_CALL(voice_engine_, 74 EXPECT_CALL(voice_engine_,
73 RegisterVoiceEngineObserver(_)).WillOnce(Return(0)); 75 RegisterVoiceEngineObserver(_)).WillOnce(Return(0));
74 EXPECT_CALL(voice_engine_, 76 EXPECT_CALL(voice_engine_,
75 DeRegisterVoiceEngineObserver()).WillOnce(Return(0)); 77 DeRegisterVoiceEngineObserver()).WillOnce(Return(0));
76 AudioState::Config config; 78 AudioState::Config config;
77 config.voice_engine = &voice_engine_; 79 config.voice_engine = &voice_engine_;
78 audio_state_ = AudioState::Create(config); 80 audio_state_ = AudioState::Create(config);
79 81
(...skipping 11 matching lines...) Expand all
91 EXPECT_CALL(*channel_proxy_, EnableReceiveTransportSequenceNumber( 93 EXPECT_CALL(*channel_proxy_, EnableReceiveTransportSequenceNumber(
92 kTransportSequenceNumberId)) 94 kTransportSequenceNumberId))
93 .Times(1); 95 .Times(1);
94 EXPECT_CALL(*channel_proxy_, 96 EXPECT_CALL(*channel_proxy_,
95 RegisterReceiverCongestionControlObjects(&packet_router_)) 97 RegisterReceiverCongestionControlObjects(&packet_router_))
96 .Times(1); 98 .Times(1);
97 EXPECT_CALL(congestion_controller_, packet_router()) 99 EXPECT_CALL(congestion_controller_, packet_router())
98 .WillOnce(Return(&packet_router_)); 100 .WillOnce(Return(&packet_router_));
99 EXPECT_CALL(*channel_proxy_, ResetCongestionControlObjects()) 101 EXPECT_CALL(*channel_proxy_, ResetCongestionControlObjects())
100 .Times(1); 102 .Times(1);
103 testing::Expectation expect_set =
104 EXPECT_CALL(*channel_proxy_, SetRtcEventLog(testing::NotNull()))
the sun 2016/03/30 15:20:38 Could check for argument to be &event_log_ ?
ivoc 2016/03/31 09:06:56 Good idea, done.
105 .Times(1);
106 EXPECT_CALL(*channel_proxy_, SetRtcEventLog(testing::IsNull()))
107 .Times(1)
108 .After(expect_set);
101 return channel_proxy_; 109 return channel_proxy_;
102 })); 110 }));
103 stream_config_.voe_channel_id = kChannelId; 111 stream_config_.voe_channel_id = kChannelId;
104 stream_config_.rtp.local_ssrc = kLocalSsrc; 112 stream_config_.rtp.local_ssrc = kLocalSsrc;
105 stream_config_.rtp.remote_ssrc = kRemoteSsrc; 113 stream_config_.rtp.remote_ssrc = kRemoteSsrc;
106 stream_config_.rtp.extensions.push_back( 114 stream_config_.rtp.extensions.push_back(
107 RtpExtension(RtpExtension::kAbsSendTime, kAbsSendTimeId)); 115 RtpExtension(RtpExtension::kAbsSendTime, kAbsSendTimeId));
108 stream_config_.rtp.extensions.push_back( 116 stream_config_.rtp.extensions.push_back(
109 RtpExtension(RtpExtension::kAudioLevel, kAudioLevelId)); 117 RtpExtension(RtpExtension::kAudioLevel, kAudioLevelId));
110 stream_config_.rtp.extensions.push_back(RtpExtension( 118 stream_config_.rtp.extensions.push_back(RtpExtension(
111 RtpExtension::kTransportSequenceNumber, kTransportSequenceNumberId)); 119 RtpExtension::kTransportSequenceNumber, kTransportSequenceNumberId));
112 } 120 }
113 121
114 MockCongestionController* congestion_controller() { 122 MockCongestionController* congestion_controller() {
115 return &congestion_controller_; 123 return &congestion_controller_;
116 } 124 }
117 MockRemoteBitrateEstimator* remote_bitrate_estimator() { 125 MockRemoteBitrateEstimator* remote_bitrate_estimator() {
118 return &remote_bitrate_estimator_; 126 return &remote_bitrate_estimator_;
119 } 127 }
128 MockRtcEventLog* event_log() { return &event_log_; }
120 AudioReceiveStream::Config& config() { return stream_config_; } 129 AudioReceiveStream::Config& config() { return stream_config_; }
121 rtc::scoped_refptr<AudioState> audio_state() { return audio_state_; } 130 rtc::scoped_refptr<AudioState> audio_state() { return audio_state_; }
122 MockVoiceEngine& voice_engine() { return voice_engine_; } 131 MockVoiceEngine& voice_engine() { return voice_engine_; }
123 132
124 void SetupMockForBweFeedback(bool send_side_bwe) { 133 void SetupMockForBweFeedback(bool send_side_bwe) {
125 EXPECT_CALL(congestion_controller_, 134 EXPECT_CALL(congestion_controller_,
126 GetRemoteBitrateEstimator(send_side_bwe)) 135 GetRemoteBitrateEstimator(send_side_bwe))
127 .WillOnce(Return(&remote_bitrate_estimator_)); 136 .WillOnce(Return(&remote_bitrate_estimator_));
128 EXPECT_CALL(remote_bitrate_estimator_, 137 EXPECT_CALL(remote_bitrate_estimator_,
129 RemoveStream(stream_config_.rtp.remote_ssrc)); 138 RemoveStream(stream_config_.rtp.remote_ssrc));
(...skipping 19 matching lines...) Expand all
149 .WillOnce(DoAll(SetArgReferee<1>(kCodecInst), Return(0))); 158 .WillOnce(DoAll(SetArgReferee<1>(kCodecInst), Return(0)));
150 } 159 }
151 160
152 private: 161 private:
153 SimulatedClock simulated_clock_; 162 SimulatedClock simulated_clock_;
154 PacketRouter packet_router_; 163 PacketRouter packet_router_;
155 testing::NiceMock<MockBitrateObserver> bitrate_observer_; 164 testing::NiceMock<MockBitrateObserver> bitrate_observer_;
156 testing::NiceMock<MockRemoteBitrateObserver> remote_bitrate_observer_; 165 testing::NiceMock<MockRemoteBitrateObserver> remote_bitrate_observer_;
157 MockCongestionController congestion_controller_; 166 MockCongestionController congestion_controller_;
158 MockRemoteBitrateEstimator remote_bitrate_estimator_; 167 MockRemoteBitrateEstimator remote_bitrate_estimator_;
168 MockRtcEventLog event_log_;
159 testing::StrictMock<MockVoiceEngine> voice_engine_; 169 testing::StrictMock<MockVoiceEngine> voice_engine_;
160 rtc::scoped_refptr<AudioState> audio_state_; 170 rtc::scoped_refptr<AudioState> audio_state_;
161 AudioReceiveStream::Config stream_config_; 171 AudioReceiveStream::Config stream_config_;
162 testing::StrictMock<MockVoEChannelProxy>* channel_proxy_ = nullptr; 172 testing::StrictMock<MockVoEChannelProxy>* channel_proxy_ = nullptr;
163 }; 173 };
164 174
165 void BuildOneByteExtension(std::vector<uint8_t>::iterator it, 175 void BuildOneByteExtension(std::vector<uint8_t>::iterator it,
166 int id, 176 int id,
167 uint32_t extension_value, 177 uint32_t extension_value,
168 size_t value_length) { 178 size_t value_length) {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 "http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time, id: 2}], " 224 "http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time, id: 2}], "
215 "transport_cc: off}, " 225 "transport_cc: off}, "
216 "receive_transport: nullptr, rtcp_send_transport: nullptr, " 226 "receive_transport: nullptr, rtcp_send_transport: nullptr, "
217 "voe_channel_id: 2}", 227 "voe_channel_id: 2}",
218 config.ToString()); 228 config.ToString());
219 } 229 }
220 230
221 TEST(AudioReceiveStreamTest, ConstructDestruct) { 231 TEST(AudioReceiveStreamTest, ConstructDestruct) {
222 ConfigHelper helper; 232 ConfigHelper helper;
223 internal::AudioReceiveStream recv_stream( 233 internal::AudioReceiveStream recv_stream(
224 helper.congestion_controller(), helper.config(), helper.audio_state()); 234 helper.congestion_controller(), helper.config(), helper.audio_state(),
235 helper.event_log());
225 } 236 }
226 237
227 MATCHER_P(VerifyHeaderExtension, expected_extension, "") { 238 MATCHER_P(VerifyHeaderExtension, expected_extension, "") {
228 return arg.extension.hasAbsoluteSendTime == 239 return arg.extension.hasAbsoluteSendTime ==
229 expected_extension.hasAbsoluteSendTime && 240 expected_extension.hasAbsoluteSendTime &&
230 arg.extension.absoluteSendTime == 241 arg.extension.absoluteSendTime ==
231 expected_extension.absoluteSendTime && 242 expected_extension.absoluteSendTime &&
232 arg.extension.hasTransportSequenceNumber == 243 arg.extension.hasTransportSequenceNumber ==
233 expected_extension.hasTransportSequenceNumber && 244 expected_extension.hasTransportSequenceNumber &&
234 arg.extension.transportSequenceNumber == 245 arg.extension.transportSequenceNumber ==
235 expected_extension.transportSequenceNumber; 246 expected_extension.transportSequenceNumber;
236 } 247 }
237 248
238 TEST(AudioReceiveStreamTest, AudioPacketUpdatesBweFeedback) { 249 TEST(AudioReceiveStreamTest, AudioPacketUpdatesBweFeedback) {
239 ConfigHelper helper; 250 ConfigHelper helper;
240 helper.config().rtp.transport_cc = true; 251 helper.config().rtp.transport_cc = true;
241 helper.SetupMockForBweFeedback(true); 252 helper.SetupMockForBweFeedback(true);
242 internal::AudioReceiveStream recv_stream( 253 internal::AudioReceiveStream recv_stream(
243 helper.congestion_controller(), helper.config(), helper.audio_state()); 254 helper.congestion_controller(), helper.config(), helper.audio_state(),
255 helper.event_log());
244 const int kTransportSequenceNumberValue = 1234; 256 const int kTransportSequenceNumberValue = 1234;
245 std::vector<uint8_t> rtp_packet = CreateRtpHeaderWithOneByteExtension( 257 std::vector<uint8_t> rtp_packet = CreateRtpHeaderWithOneByteExtension(
246 kTransportSequenceNumberId, kTransportSequenceNumberValue, 2); 258 kTransportSequenceNumberId, kTransportSequenceNumberValue, 2);
247 PacketTime packet_time(5678000, 0); 259 PacketTime packet_time(5678000, 0);
248 const size_t kExpectedHeaderLength = 20; 260 const size_t kExpectedHeaderLength = 20;
249 RTPHeaderExtension expected_extension; 261 RTPHeaderExtension expected_extension;
250 expected_extension.hasTransportSequenceNumber = true; 262 expected_extension.hasTransportSequenceNumber = true;
251 expected_extension.transportSequenceNumber = kTransportSequenceNumberValue; 263 expected_extension.transportSequenceNumber = kTransportSequenceNumberValue;
252 EXPECT_CALL(*helper.remote_bitrate_estimator(), 264 EXPECT_CALL(*helper.remote_bitrate_estimator(),
253 IncomingPacket(packet_time.timestamp / 1000, 265 IncomingPacket(packet_time.timestamp / 1000,
254 rtp_packet.size() - kExpectedHeaderLength, 266 rtp_packet.size() - kExpectedHeaderLength,
255 VerifyHeaderExtension(expected_extension), false)) 267 VerifyHeaderExtension(expected_extension), false))
256 .Times(1); 268 .Times(1);
257 EXPECT_TRUE( 269 EXPECT_TRUE(
258 recv_stream.DeliverRtp(&rtp_packet[0], rtp_packet.size(), packet_time)); 270 recv_stream.DeliverRtp(&rtp_packet[0], rtp_packet.size(), packet_time));
259 } 271 }
260 272
261 TEST(AudioReceiveStreamTest, GetStats) { 273 TEST(AudioReceiveStreamTest, GetStats) {
262 ConfigHelper helper; 274 ConfigHelper helper;
263 internal::AudioReceiveStream recv_stream( 275 internal::AudioReceiveStream recv_stream(
264 helper.congestion_controller(), helper.config(), helper.audio_state()); 276 helper.congestion_controller(), helper.config(), helper.audio_state(),
277 helper.event_log());
265 helper.SetupMockForGetStats(); 278 helper.SetupMockForGetStats();
266 AudioReceiveStream::Stats stats = recv_stream.GetStats(); 279 AudioReceiveStream::Stats stats = recv_stream.GetStats();
267 EXPECT_EQ(kRemoteSsrc, stats.remote_ssrc); 280 EXPECT_EQ(kRemoteSsrc, stats.remote_ssrc);
268 EXPECT_EQ(static_cast<int64_t>(kCallStats.bytesReceived), stats.bytes_rcvd); 281 EXPECT_EQ(static_cast<int64_t>(kCallStats.bytesReceived), stats.bytes_rcvd);
269 EXPECT_EQ(static_cast<uint32_t>(kCallStats.packetsReceived), 282 EXPECT_EQ(static_cast<uint32_t>(kCallStats.packetsReceived),
270 stats.packets_rcvd); 283 stats.packets_rcvd);
271 EXPECT_EQ(kCallStats.cumulativeLost, stats.packets_lost); 284 EXPECT_EQ(kCallStats.cumulativeLost, stats.packets_lost);
272 EXPECT_EQ(Q8ToFloat(kCallStats.fractionLost), stats.fraction_lost); 285 EXPECT_EQ(Q8ToFloat(kCallStats.fractionLost), stats.fraction_lost);
273 EXPECT_EQ(std::string(kCodecInst.plname), stats.codec_name); 286 EXPECT_EQ(std::string(kCodecInst.plname), stats.codec_name);
274 EXPECT_EQ(kCallStats.extendedMax, stats.ext_seqnum); 287 EXPECT_EQ(kCallStats.extendedMax, stats.ext_seqnum);
(...skipping 19 matching lines...) Expand all
294 EXPECT_EQ(kAudioDecodeStats.calls_to_neteq, stats.decoding_calls_to_neteq); 307 EXPECT_EQ(kAudioDecodeStats.calls_to_neteq, stats.decoding_calls_to_neteq);
295 EXPECT_EQ(kAudioDecodeStats.decoded_normal, stats.decoding_normal); 308 EXPECT_EQ(kAudioDecodeStats.decoded_normal, stats.decoding_normal);
296 EXPECT_EQ(kAudioDecodeStats.decoded_plc, stats.decoding_plc); 309 EXPECT_EQ(kAudioDecodeStats.decoded_plc, stats.decoding_plc);
297 EXPECT_EQ(kAudioDecodeStats.decoded_cng, stats.decoding_cng); 310 EXPECT_EQ(kAudioDecodeStats.decoded_cng, stats.decoding_cng);
298 EXPECT_EQ(kAudioDecodeStats.decoded_plc_cng, stats.decoding_plc_cng); 311 EXPECT_EQ(kAudioDecodeStats.decoded_plc_cng, stats.decoding_plc_cng);
299 EXPECT_EQ(kCallStats.capture_start_ntp_time_ms_, 312 EXPECT_EQ(kCallStats.capture_start_ntp_time_ms_,
300 stats.capture_start_ntp_time_ms); 313 stats.capture_start_ntp_time_ms);
301 } 314 }
302 } // namespace test 315 } // namespace test
303 } // namespace webrtc 316 } // 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