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

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

Powered by Google App Engine
This is Rietveld 408576698