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

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

Issue 1535963002: Wire-up BWE feedback for audio receive streams. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fix a test I forgot to run. Created 4 years, 11 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
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 12
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 14
15 #include "webrtc/audio/audio_receive_stream.h" 15 #include "webrtc/audio/audio_receive_stream.h"
16 #include "webrtc/audio/conversion.h" 16 #include "webrtc/audio/conversion.h"
17 #include "webrtc/call/mock/mock_congestion_controller.h"
18 #include "webrtc/modules/bitrate_controller/include/mock/mock_bitrate_controller .h"
19 #include "webrtc/modules/pacing/packet_router.h"
17 #include "webrtc/modules/remote_bitrate_estimator/include/mock/mock_remote_bitra te_estimator.h" 20 #include "webrtc/modules/remote_bitrate_estimator/include/mock/mock_remote_bitra te_estimator.h"
18 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" 21 #include "webrtc/modules/rtp_rtcp/source/byte_io.h"
22 #include "webrtc/modules/utility/include/mock/mock_process_thread.h"
23 #include "webrtc/system_wrappers/include/clock.h"
19 #include "webrtc/test/mock_voe_channel_proxy.h" 24 #include "webrtc/test/mock_voe_channel_proxy.h"
20 #include "webrtc/test/mock_voice_engine.h" 25 #include "webrtc/test/mock_voice_engine.h"
26 #include "webrtc/video/call_stats.h"
21 27
22 namespace webrtc { 28 namespace webrtc {
23 namespace test { 29 namespace test {
24 namespace { 30 namespace {
25 31
26 using testing::_; 32 using testing::_;
27 using testing::Return; 33 using testing::Return;
28 34
29 AudioDecodingCallStats MakeAudioDecodeStatsForTest() { 35 AudioDecodingCallStats MakeAudioDecodeStatsForTest() {
30 AudioDecodingCallStats audio_decode_stats; 36 AudioDecodingCallStats audio_decode_stats;
31 audio_decode_stats.calls_to_silence_generator = 234; 37 audio_decode_stats.calls_to_silence_generator = 234;
32 audio_decode_stats.calls_to_neteq = 567; 38 audio_decode_stats.calls_to_neteq = 567;
33 audio_decode_stats.decoded_normal = 890; 39 audio_decode_stats.decoded_normal = 890;
34 audio_decode_stats.decoded_plc = 123; 40 audio_decode_stats.decoded_plc = 123;
35 audio_decode_stats.decoded_cng = 456; 41 audio_decode_stats.decoded_cng = 456;
36 audio_decode_stats.decoded_plc_cng = 789; 42 audio_decode_stats.decoded_plc_cng = 789;
37 return audio_decode_stats; 43 return audio_decode_stats;
38 } 44 }
39 45
40 const int kChannelId = 2; 46 const int kChannelId = 2;
41 const uint32_t kRemoteSsrc = 1234; 47 const uint32_t kRemoteSsrc = 1234;
42 const uint32_t kLocalSsrc = 5678; 48 const uint32_t kLocalSsrc = 5678;
43 const size_t kAbsoluteSendTimeLength = 4; 49 const size_t kOneByteExtensionHeaderLength = 4;
50 const size_t kOneByteExtensionLength = 4;
44 const int kAbsSendTimeId = 2; 51 const int kAbsSendTimeId = 2;
45 const int kAudioLevelId = 3; 52 const int kAudioLevelId = 3;
53 const int kTransportSequenceNumberId = 4;
46 const int kJitterBufferDelay = -7; 54 const int kJitterBufferDelay = -7;
47 const int kPlayoutBufferDelay = 302; 55 const int kPlayoutBufferDelay = 302;
48 const unsigned int kSpeechOutputLevel = 99; 56 const unsigned int kSpeechOutputLevel = 99;
49 const CallStatistics kCallStats = { 57 const CallStatistics kCallStats = {
50 345, 678, 901, 234, -12, 3456, 7890, 567, 890, 123}; 58 345, 678, 901, 234, -12, 3456, 7890, 567, 890, 123};
51 const CodecInst kCodecInst = { 59 const CodecInst kCodecInst = {
52 123, "codec_name_recv", 96000, -187, -198, -103}; 60 123, "codec_name_recv", 96000, -187, -198, -103};
53 const NetworkStatistics kNetworkStats = { 61 const NetworkStatistics kNetworkStats = {
54 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};
55 const AudioDecodingCallStats kAudioDecodeStats = MakeAudioDecodeStatsForTest(); 63 const AudioDecodingCallStats kAudioDecodeStats = MakeAudioDecodeStatsForTest();
56 64
57 struct ConfigHelper { 65 struct ConfigHelper {
58 ConfigHelper() { 66 ConfigHelper()
67 : simulated_clock_(123456),
68 call_stats_(&simulated_clock_),
69 congestion_controller_(&process_thread_,
70 &call_stats_,
71 &bitrate_observer_) {
59 using testing::Invoke; 72 using testing::Invoke;
60 73
61 EXPECT_CALL(voice_engine_, 74 EXPECT_CALL(voice_engine_,
62 RegisterVoiceEngineObserver(_)).WillOnce(Return(0)); 75 RegisterVoiceEngineObserver(_)).WillOnce(Return(0));
63 EXPECT_CALL(voice_engine_, 76 EXPECT_CALL(voice_engine_,
64 DeRegisterVoiceEngineObserver()).WillOnce(Return(0)); 77 DeRegisterVoiceEngineObserver()).WillOnce(Return(0));
65 AudioState::Config config; 78 AudioState::Config config;
66 config.voice_engine = &voice_engine_; 79 config.voice_engine = &voice_engine_;
67 audio_state_ = AudioState::Create(config); 80 audio_state_ = AudioState::Create(config);
81 channel_proxy_ = new testing::StrictMock<MockVoEChannelProxy>();
the sun 2016/01/11 11:47:19 Move back into ChannelProxyFactory() so this test
stefan-webrtc 2016/01/11 17:15:48 Done.
68 82
69 EXPECT_CALL(voice_engine_, ChannelProxyFactory(kChannelId)) 83 EXPECT_CALL(voice_engine_, ChannelProxyFactory(kChannelId))
70 .WillOnce(Invoke([this](int channel_id) { 84 .WillOnce(Invoke([this](int channel_id) {
71 EXPECT_FALSE(channel_proxy_);
72 channel_proxy_ = new testing::StrictMock<MockVoEChannelProxy>();
73 EXPECT_CALL(*channel_proxy_, SetLocalSSRC(kLocalSsrc)).Times(1); 85 EXPECT_CALL(*channel_proxy_, SetLocalSSRC(kLocalSsrc)).Times(1);
74 EXPECT_CALL(*channel_proxy_, 86 EXPECT_CALL(*channel_proxy_,
75 SetReceiveAbsoluteSenderTimeStatus(true, kAbsSendTimeId)) 87 SetReceiveAbsoluteSenderTimeStatus(true, kAbsSendTimeId))
76 .Times(1); 88 .Times(1);
77 EXPECT_CALL(*channel_proxy_, 89 EXPECT_CALL(*channel_proxy_,
78 SetReceiveAudioLevelIndicationStatus(true, kAudioLevelId)) 90 SetReceiveAudioLevelIndicationStatus(true, kAudioLevelId))
79 .Times(1); 91 .Times(1);
92 EXPECT_CALL(*channel_proxy_, SetCongestionControlObjects(
93 nullptr, nullptr, &packet_router_))
94 .Times(1);
80 return channel_proxy_; 95 return channel_proxy_;
81 })); 96 }));
97 EXPECT_CALL(congestion_controller_, packet_router())
98 .WillOnce(Return(&packet_router_));
99 EXPECT_CALL(*channel_proxy_,
100 SetCongestionControlObjects(nullptr, nullptr, nullptr))
101 .Times(1);
82 stream_config_.voe_channel_id = kChannelId; 102 stream_config_.voe_channel_id = kChannelId;
83 stream_config_.rtp.local_ssrc = kLocalSsrc; 103 stream_config_.rtp.local_ssrc = kLocalSsrc;
84 stream_config_.rtp.remote_ssrc = kRemoteSsrc; 104 stream_config_.rtp.remote_ssrc = kRemoteSsrc;
85 stream_config_.rtp.extensions.push_back( 105 stream_config_.rtp.extensions.push_back(
the sun 2016/01/11 11:47:19 Should AST be mutually exclusive with transport se
stefan-webrtc 2016/01/11 17:15:48 I don't think there's any reason to enforce that a
86 RtpExtension(RtpExtension::kAbsSendTime, kAbsSendTimeId)); 106 RtpExtension(RtpExtension::kAbsSendTime, kAbsSendTimeId));
87 stream_config_.rtp.extensions.push_back( 107 stream_config_.rtp.extensions.push_back(
88 RtpExtension(RtpExtension::kAudioLevel, kAudioLevelId)); 108 RtpExtension(RtpExtension::kAudioLevel, kAudioLevelId));
89 } 109 }
90 110
111 MockCongestionController* congestion_controller() {
112 return &congestion_controller_;
113 }
91 MockRemoteBitrateEstimator* remote_bitrate_estimator() { 114 MockRemoteBitrateEstimator* remote_bitrate_estimator() {
92 return &remote_bitrate_estimator_; 115 return &remote_bitrate_estimator_;
93 } 116 }
94 AudioReceiveStream::Config& config() { return stream_config_; } 117 AudioReceiveStream::Config& config() { return stream_config_; }
95 rtc::scoped_refptr<AudioState> audio_state() { return audio_state_; } 118 rtc::scoped_refptr<AudioState> audio_state() { return audio_state_; }
96 MockVoiceEngine& voice_engine() { return voice_engine_; } 119 MockVoiceEngine& voice_engine() { return voice_engine_; }
97 120
121 void SetupMockForBweFeedback() {
122 EXPECT_CALL(congestion_controller_, GetRemoteBitrateEstimator(true))
123 .WillOnce(Return(&remote_bitrate_estimator_));
124 EXPECT_CALL(remote_bitrate_estimator_,
125 RemoveStream(stream_config_.rtp.remote_ssrc));
126 }
127
98 void SetupMockForGetStats() { 128 void SetupMockForGetStats() {
99 using testing::DoAll; 129 using testing::DoAll;
100 using testing::SetArgReferee; 130 using testing::SetArgReferee;
101 131
102 EXPECT_TRUE(channel_proxy_); 132 ASSERT_TRUE(channel_proxy_);
103 EXPECT_CALL(*channel_proxy_, GetRTCPStatistics()) 133 EXPECT_CALL(*channel_proxy_, GetRTCPStatistics())
104 .WillOnce(Return(kCallStats)); 134 .WillOnce(Return(kCallStats));
105 EXPECT_CALL(*channel_proxy_, GetDelayEstimate()) 135 EXPECT_CALL(*channel_proxy_, GetDelayEstimate())
106 .WillOnce(Return(kJitterBufferDelay + kPlayoutBufferDelay)); 136 .WillOnce(Return(kJitterBufferDelay + kPlayoutBufferDelay));
107 EXPECT_CALL(*channel_proxy_, GetSpeechOutputLevelFullRange()) 137 EXPECT_CALL(*channel_proxy_, GetSpeechOutputLevelFullRange())
108 .WillOnce(Return(kSpeechOutputLevel)); 138 .WillOnce(Return(kSpeechOutputLevel));
109 EXPECT_CALL(*channel_proxy_, GetNetworkStatistics()) 139 EXPECT_CALL(*channel_proxy_, GetNetworkStatistics())
110 .WillOnce(Return(kNetworkStats)); 140 .WillOnce(Return(kNetworkStats));
111 EXPECT_CALL(*channel_proxy_, GetDecodingCallStatistics()) 141 EXPECT_CALL(*channel_proxy_, GetDecodingCallStatistics())
112 .WillOnce(Return(kAudioDecodeStats)); 142 .WillOnce(Return(kAudioDecodeStats));
113 143
114 EXPECT_CALL(voice_engine_, GetRecCodec(kChannelId, _)) 144 EXPECT_CALL(voice_engine_, GetRecCodec(kChannelId, _))
115 .WillOnce(DoAll(SetArgReferee<1>(kCodecInst), Return(0))); 145 .WillOnce(DoAll(SetArgReferee<1>(kCodecInst), Return(0)));
116 } 146 }
117 147
118 private: 148 private:
149 SimulatedClock simulated_clock_;
150 CallStats call_stats_;
151 PacketRouter packet_router_;
152 testing::NiceMock<MockBitrateObserver> bitrate_observer_;
153 testing::NiceMock<MockProcessThread> process_thread_;
154 MockCongestionController congestion_controller_;
the sun 2016/01/11 11:47:19 Do you need to NiceMock or StrictMock the CC? Chec
stefan-webrtc 2016/01/11 17:15:48 Nope, not that I can see.
119 MockRemoteBitrateEstimator remote_bitrate_estimator_; 155 MockRemoteBitrateEstimator remote_bitrate_estimator_;
120 testing::StrictMock<MockVoiceEngine> voice_engine_; 156 testing::StrictMock<MockVoiceEngine> voice_engine_;
121 rtc::scoped_refptr<AudioState> audio_state_; 157 rtc::scoped_refptr<AudioState> audio_state_;
122 AudioReceiveStream::Config stream_config_; 158 AudioReceiveStream::Config stream_config_;
123 testing::StrictMock<MockVoEChannelProxy>* channel_proxy_ = nullptr; 159 testing::StrictMock<MockVoEChannelProxy>* channel_proxy_ = nullptr;
124 }; 160 };
125 161
126 void BuildAbsoluteSendTimeExtension(uint8_t* buffer, 162 void BuildOneByteExtension(std::vector<uint8_t>::iterator it,
127 int id, 163 int id,
128 uint32_t abs_send_time) { 164 uint32_t extension_value,
129 const size_t kRtpOneByteHeaderLength = 4; 165 size_t value_length) {
130 const uint16_t kRtpOneByteHeaderExtensionId = 0xBEDE; 166 const uint16_t kRtpOneByteHeaderExtensionId = 0xBEDE;
131 ByteWriter<uint16_t>::WriteBigEndian(buffer, kRtpOneByteHeaderExtensionId); 167 ByteWriter<uint16_t>::WriteBigEndian(&(*it), kRtpOneByteHeaderExtensionId);
168 it += 2;
132 169
133 const uint32_t kPosLength = 2; 170 ByteWriter<uint16_t>::WriteBigEndian(&(*it), kOneByteExtensionLength / 4);
134 ByteWriter<uint16_t>::WriteBigEndian(buffer + kPosLength, 171 it += 2;
135 kAbsoluteSendTimeLength / 4); 172 const size_t kExtensionDataLength = kOneByteExtensionLength - 1;
136 173 uint32_t shifted_value = extension_value
137 const uint8_t kLengthOfData = 3; 174 << (8 * (kExtensionDataLength - value_length));
138 buffer[kRtpOneByteHeaderLength] = (id << 4) + (kLengthOfData - 1); 175 *it = (id << 4) + (value_length - 1);
139 ByteWriter<uint32_t, kLengthOfData>::WriteBigEndian( 176 ++it;
140 buffer + kRtpOneByteHeaderLength + 1, abs_send_time); 177 ByteWriter<uint32_t, kExtensionDataLength>::WriteBigEndian(&(*it),
178 shifted_value);
141 } 179 }
142 180
143 size_t CreateRtpHeaderWithAbsSendTime(uint8_t* header, 181 std::vector<uint8_t> CreateRtpHeaderWithOneByteExtension(
144 int extension_id, 182 int extension_id,
145 uint32_t abs_send_time) { 183 uint32_t extension_value,
184 size_t value_length) {
185 std::vector<uint8_t> header;
186 header.resize(webrtc::kRtpHeaderSize + kOneByteExtensionHeaderLength +
187 kOneByteExtensionLength);
146 header[0] = 0x80; // Version 2. 188 header[0] = 0x80; // Version 2.
147 header[0] |= 0x10; // Set extension bit. 189 header[0] |= 0x10; // Set extension bit.
148 header[1] = 100; // Payload type. 190 header[1] = 100; // Payload type.
149 header[1] |= 0x80; // Marker bit is set. 191 header[1] |= 0x80; // Marker bit is set.
150 ByteWriter<uint16_t>::WriteBigEndian(header + 2, 0x1234); // Sequence number. 192 ByteWriter<uint16_t>::WriteBigEndian(&header[2], 0x1234); // Sequence number.
151 ByteWriter<uint32_t>::WriteBigEndian(header + 4, 0x5678); // Timestamp. 193 ByteWriter<uint32_t>::WriteBigEndian(&header[4], 0x5678); // Timestamp.
152 ByteWriter<uint32_t>::WriteBigEndian(header + 8, 0x4321); // SSRC. 194 ByteWriter<uint32_t>::WriteBigEndian(&header[8], 0x4321); // SSRC.
153 int32_t rtp_header_length = webrtc::kRtpHeaderSize;
154 195
155 BuildAbsoluteSendTimeExtension(header + rtp_header_length, extension_id, 196 BuildOneByteExtension(header.begin() + webrtc::kRtpHeaderSize, extension_id,
156 abs_send_time); 197 extension_value, value_length);
157 rtp_header_length += kAbsoluteSendTimeLength; 198 return header;
158 return rtp_header_length;
159 } 199 }
160 } // namespace 200 } // namespace
161 201
162 TEST(AudioReceiveStreamTest, ConfigToString) { 202 TEST(AudioReceiveStreamTest, ConfigToString) {
163 AudioReceiveStream::Config config; 203 AudioReceiveStream::Config config;
164 config.rtp.remote_ssrc = kRemoteSsrc; 204 config.rtp.remote_ssrc = kRemoteSsrc;
165 config.rtp.local_ssrc = kLocalSsrc; 205 config.rtp.local_ssrc = kLocalSsrc;
166 config.rtp.extensions.push_back( 206 config.rtp.extensions.push_back(
167 RtpExtension(RtpExtension::kAbsSendTime, kAbsSendTimeId)); 207 RtpExtension(RtpExtension::kAbsSendTime, kAbsSendTimeId));
168 config.voe_channel_id = kChannelId; 208 config.voe_channel_id = kChannelId;
169 config.combined_audio_video_bwe = true; 209 config.combined_audio_video_bwe = true;
170 EXPECT_EQ( 210 EXPECT_EQ(
171 "{rtp: {remote_ssrc: 1234, local_ssrc: 5678, extensions: [{name: " 211 "{rtp: {remote_ssrc: 1234, local_ssrc: 5678, extensions: [{name: "
172 "http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time, id: 2}]}, " 212 "http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time, id: 2}]}, "
173 "receive_transport: nullptr, rtcp_send_transport: nullptr, " 213 "receive_transport: nullptr, rtcp_send_transport: nullptr, "
174 "voe_channel_id: 2, combined_audio_video_bwe: true}", 214 "voe_channel_id: 2, combined_audio_video_bwe: true}",
175 config.ToString()); 215 config.ToString());
176 } 216 }
177 217
178 TEST(AudioReceiveStreamTest, ConstructDestruct) { 218 TEST(AudioReceiveStreamTest, ConstructDestruct) {
179 ConfigHelper helper; 219 ConfigHelper helper;
180 internal::AudioReceiveStream recv_stream( 220 internal::AudioReceiveStream recv_stream(
181 helper.remote_bitrate_estimator(), helper.config(), helper.audio_state()); 221 helper.congestion_controller(), helper.config(), helper.audio_state());
222 }
223
224 MATCHER_P(VerifyHeaderExtension, expected_extension, "") {
225 return arg.extension.hasAbsoluteSendTime ==
226 expected_extension.hasAbsoluteSendTime &&
227 arg.extension.absoluteSendTime ==
228 expected_extension.absoluteSendTime &&
229 arg.extension.hasTransportSequenceNumber ==
230 expected_extension.hasTransportSequenceNumber &&
231 arg.extension.transportSequenceNumber ==
232 expected_extension.transportSequenceNumber;
182 } 233 }
183 234
184 TEST(AudioReceiveStreamTest, AudioPacketUpdatesBweWithTimestamp) { 235 TEST(AudioReceiveStreamTest, AudioPacketUpdatesBweWithTimestamp) {
185 ConfigHelper helper; 236 ConfigHelper helper;
186 helper.config().combined_audio_video_bwe = true; 237 helper.config().combined_audio_video_bwe = true;
238 EXPECT_CALL(*helper.congestion_controller(), GetRemoteBitrateEstimator(false))
the sun 2016/01/11 11:47:19 Except for the argument to GetRemoteBitrateEstimat
stefan-webrtc 2016/01/11 17:15:48 Good point.
239 .WillOnce(Return(helper.remote_bitrate_estimator()));
240 EXPECT_CALL(*helper.remote_bitrate_estimator(),
241 RemoveStream(helper.config().rtp.remote_ssrc));
187 internal::AudioReceiveStream recv_stream( 242 internal::AudioReceiveStream recv_stream(
188 helper.remote_bitrate_estimator(), helper.config(), helper.audio_state()); 243 helper.congestion_controller(), helper.config(), helper.audio_state());
189 uint8_t rtp_packet[30];
190 const int kAbsSendTimeValue = 1234; 244 const int kAbsSendTimeValue = 1234;
191 CreateRtpHeaderWithAbsSendTime(rtp_packet, kAbsSendTimeId, kAbsSendTimeValue); 245 std::vector<uint8_t> rtp_packet =
246 CreateRtpHeaderWithOneByteExtension(kAbsSendTimeId, kAbsSendTimeValue, 3);
192 PacketTime packet_time(5678000, 0); 247 PacketTime packet_time(5678000, 0);
193 const size_t kExpectedHeaderLength = 20; 248 const size_t kExpectedHeaderLength = 20;
249 RTPHeaderExtension expected_extension;
250 expected_extension.hasAbsoluteSendTime = true;
251 expected_extension.absoluteSendTime = kAbsSendTimeValue;
194 EXPECT_CALL(*helper.remote_bitrate_estimator(), 252 EXPECT_CALL(*helper.remote_bitrate_estimator(),
195 IncomingPacket(packet_time.timestamp / 1000, 253 IncomingPacket(packet_time.timestamp / 1000,
196 sizeof(rtp_packet) - kExpectedHeaderLength, 254 rtp_packet.size() - kExpectedHeaderLength,
197 testing::_, false)) 255 VerifyHeaderExtension(expected_extension), false))
198 .Times(1); 256 .Times(1);
199 EXPECT_TRUE( 257 EXPECT_TRUE(
200 recv_stream.DeliverRtp(rtp_packet, sizeof(rtp_packet), packet_time)); 258 recv_stream.DeliverRtp(&rtp_packet[0], rtp_packet.size(), packet_time));
259 }
260
261 TEST(AudioReceiveStreamTest, AudioPacketUpdatesBweFeedback) {
262 ConfigHelper helper;
263 helper.config().combined_audio_video_bwe = true;
264 helper.config().rtp.transport_cc = true;
265 helper.config().rtp.extensions.push_back(RtpExtension(
266 RtpExtension::kTransportSequenceNumber, kTransportSequenceNumberId));
267 helper.SetupMockForBweFeedback();
268 internal::AudioReceiveStream recv_stream(
269 helper.congestion_controller(), helper.config(), helper.audio_state());
270 const int kTransportSequenceNumberValue = 1234;
271 std::vector<uint8_t> rtp_packet = CreateRtpHeaderWithOneByteExtension(
272 kTransportSequenceNumberId, kTransportSequenceNumberValue, 2);
273 PacketTime packet_time(5678000, 0);
274 const size_t kExpectedHeaderLength = 20;
275 RTPHeaderExtension expected_extension;
276 expected_extension.hasTransportSequenceNumber = true;
277 expected_extension.transportSequenceNumber = kTransportSequenceNumberValue;
278 EXPECT_CALL(*helper.remote_bitrate_estimator(),
279 IncomingPacket(packet_time.timestamp / 1000,
280 rtp_packet.size() - kExpectedHeaderLength,
281 VerifyHeaderExtension(expected_extension), false))
282 .Times(1);
283 EXPECT_TRUE(
284 recv_stream.DeliverRtp(&rtp_packet[0], rtp_packet.size(), packet_time));
201 } 285 }
202 286
203 TEST(AudioReceiveStreamTest, GetStats) { 287 TEST(AudioReceiveStreamTest, GetStats) {
204 ConfigHelper helper; 288 ConfigHelper helper;
205 internal::AudioReceiveStream recv_stream( 289 internal::AudioReceiveStream recv_stream(
206 helper.remote_bitrate_estimator(), helper.config(), helper.audio_state()); 290 helper.congestion_controller(), helper.config(), helper.audio_state());
207 helper.SetupMockForGetStats(); 291 helper.SetupMockForGetStats();
208 AudioReceiveStream::Stats stats = recv_stream.GetStats(); 292 AudioReceiveStream::Stats stats = recv_stream.GetStats();
209 EXPECT_EQ(kRemoteSsrc, stats.remote_ssrc); 293 EXPECT_EQ(kRemoteSsrc, stats.remote_ssrc);
210 EXPECT_EQ(static_cast<int64_t>(kCallStats.bytesReceived), stats.bytes_rcvd); 294 EXPECT_EQ(static_cast<int64_t>(kCallStats.bytesReceived), stats.bytes_rcvd);
211 EXPECT_EQ(static_cast<uint32_t>(kCallStats.packetsReceived), 295 EXPECT_EQ(static_cast<uint32_t>(kCallStats.packetsReceived),
212 stats.packets_rcvd); 296 stats.packets_rcvd);
213 EXPECT_EQ(kCallStats.cumulativeLost, stats.packets_lost); 297 EXPECT_EQ(kCallStats.cumulativeLost, stats.packets_lost);
214 EXPECT_EQ(Q8ToFloat(kCallStats.fractionLost), stats.fraction_lost); 298 EXPECT_EQ(Q8ToFloat(kCallStats.fractionLost), stats.fraction_lost);
215 EXPECT_EQ(std::string(kCodecInst.plname), stats.codec_name); 299 EXPECT_EQ(std::string(kCodecInst.plname), stats.codec_name);
216 EXPECT_EQ(kCallStats.extendedMax, stats.ext_seqnum); 300 EXPECT_EQ(kCallStats.extendedMax, stats.ext_seqnum);
(...skipping 19 matching lines...) Expand all
236 EXPECT_EQ(kAudioDecodeStats.calls_to_neteq, stats.decoding_calls_to_neteq); 320 EXPECT_EQ(kAudioDecodeStats.calls_to_neteq, stats.decoding_calls_to_neteq);
237 EXPECT_EQ(kAudioDecodeStats.decoded_normal, stats.decoding_normal); 321 EXPECT_EQ(kAudioDecodeStats.decoded_normal, stats.decoding_normal);
238 EXPECT_EQ(kAudioDecodeStats.decoded_plc, stats.decoding_plc); 322 EXPECT_EQ(kAudioDecodeStats.decoded_plc, stats.decoding_plc);
239 EXPECT_EQ(kAudioDecodeStats.decoded_cng, stats.decoding_cng); 323 EXPECT_EQ(kAudioDecodeStats.decoded_cng, stats.decoding_cng);
240 EXPECT_EQ(kAudioDecodeStats.decoded_plc_cng, stats.decoding_plc_cng); 324 EXPECT_EQ(kAudioDecodeStats.decoded_plc_cng, stats.decoding_plc_cng);
241 EXPECT_EQ(kCallStats.capture_start_ntp_time_ms_, 325 EXPECT_EQ(kCallStats.capture_start_ntp_time_ms_,
242 stats.capture_start_ntp_time_ms); 326 stats.capture_start_ntp_time_ms);
243 } 327 }
244 } // namespace test 328 } // namespace test
245 } // namespace webrtc 329 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698