OLD | NEW |
---|---|
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 "webrtc/modules/pacing/packet_router.h" | 11 #include "webrtc/modules/pacing/packet_router.h" |
12 #include "webrtc/modules/remote_bitrate_estimator/remote_estimator_proxy.h" | 12 #include "webrtc/modules/remote_bitrate_estimator/remote_estimator_proxy.h" |
13 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h" | 13 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h" |
14 #include "webrtc/system_wrappers/include/clock.h" | 14 #include "webrtc/system_wrappers/include/clock.h" |
15 #include "webrtc/test/gmock.h" | 15 #include "webrtc/test/gmock.h" |
16 #include "webrtc/test/gtest.h" | 16 #include "webrtc/test/gtest.h" |
17 | 17 |
18 using ::testing::_; | 18 using ::testing::_; |
19 using ::testing::InSequence; | 19 using ::testing::ElementsAre; |
20 using ::testing::Invoke; | 20 using ::testing::Invoke; |
21 using ::testing::Return; | 21 using ::testing::Return; |
22 | 22 |
23 namespace webrtc { | 23 namespace webrtc { |
24 namespace { | |
25 | |
26 std::vector<uint16_t> SequenceNumbers(const rtcp::TransportFeedback& packet) { | |
terelius
2017/01/17 16:32:23
It is unclear whether packet refers to the RTCP fe
danilchap
2017/01/17 17:20:14
Done.
| |
27 std::vector<uint16_t> sequence_numbers; | |
28 for (const auto& received_packet : packet.GetReceivedPackets()) { | |
29 sequence_numbers.push_back(received_packet.sequence_number()); | |
30 } | |
31 return sequence_numbers; | |
32 } | |
33 | |
terelius
2017/01/17 16:32:23
feedback_packet?
danilchap
2017/01/17 17:20:14
Done.
| |
34 std::vector<int64_t> TimestampsMs(const rtcp::TransportFeedback& packet) { | |
35 std::vector<int64_t> timestamps; | |
36 int64_t timestamp_us = packet.GetBaseTimeUs(); | |
37 for (const auto& received_packet : packet.GetReceivedPackets()) { | |
38 timestamps.push_back((timestamp_us += received_packet.delta_us()) / 1000); | |
39 } | |
40 return timestamps; | |
41 } | |
24 | 42 |
25 class MockPacketRouter : public PacketRouter { | 43 class MockPacketRouter : public PacketRouter { |
26 public: | 44 public: |
27 MOCK_METHOD1(SendFeedback, bool(rtcp::TransportFeedback* packet)); | 45 MOCK_METHOD1(SendFeedback, bool(rtcp::TransportFeedback* packet)); |
terelius
2017/01/17 16:32:23
feedback_packet?
danilchap
2017/01/17 17:20:14
Done.
| |
28 }; | 46 }; |
29 | 47 |
30 class RemoteEstimatorProxyTest : public ::testing::Test { | 48 class RemoteEstimatorProxyTest : public ::testing::Test { |
31 public: | 49 public: |
32 RemoteEstimatorProxyTest() : clock_(0), proxy_(&clock_, &router_) {} | 50 RemoteEstimatorProxyTest() : clock_(0), proxy_(&clock_, &router_) {} |
33 | 51 |
34 protected: | 52 protected: |
35 void IncomingPacket(uint16_t seq, int64_t time_ms) { | 53 void IncomingPacket(uint16_t seq, int64_t time_ms) { |
36 RTPHeader header; | 54 RTPHeader header; |
37 header.extension.hasTransportSequenceNumber = true; | 55 header.extension.hasTransportSequenceNumber = true; |
(...skipping 17 matching lines...) Expand all Loading... | |
55 const uint16_t kBaseSeq = 10; | 73 const uint16_t kBaseSeq = 10; |
56 const int64_t kBaseTimeMs = 123; | 74 const int64_t kBaseTimeMs = 123; |
57 const int64_t kMaxSmallDeltaMs = | 75 const int64_t kMaxSmallDeltaMs = |
58 (rtcp::TransportFeedback::kDeltaScaleFactor * 0xFF) / 1000; | 76 (rtcp::TransportFeedback::kDeltaScaleFactor * 0xFF) / 1000; |
59 }; | 77 }; |
60 | 78 |
61 TEST_F(RemoteEstimatorProxyTest, SendsSinglePacketFeedback) { | 79 TEST_F(RemoteEstimatorProxyTest, SendsSinglePacketFeedback) { |
62 IncomingPacket(kBaseSeq, kBaseTimeMs); | 80 IncomingPacket(kBaseSeq, kBaseTimeMs); |
63 | 81 |
64 EXPECT_CALL(router_, SendFeedback(_)) | 82 EXPECT_CALL(router_, SendFeedback(_)) |
65 .Times(1) | |
66 .WillOnce(Invoke([this](rtcp::TransportFeedback* packet) { | 83 .WillOnce(Invoke([this](rtcp::TransportFeedback* packet) { |
terelius
2017/01/17 16:32:23
feedback_packet?
danilchap
2017/01/17 17:20:14
Done.
To avoid growing these lines too much notice
| |
67 packet->Build(); | |
68 EXPECT_EQ(kBaseSeq, packet->GetBaseSequence()); | 84 EXPECT_EQ(kBaseSeq, packet->GetBaseSequence()); |
69 EXPECT_EQ(kMediaSsrc, packet->media_ssrc()); | 85 EXPECT_EQ(kMediaSsrc, packet->media_ssrc()); |
70 | 86 |
71 std::vector<rtcp::TransportFeedback::StatusSymbol> status_vec = | 87 EXPECT_THAT(SequenceNumbers(*packet), ElementsAre(kBaseSeq)); |
72 packet->GetStatusVector(); | 88 EXPECT_THAT(TimestampsMs(*packet), ElementsAre(kBaseTimeMs)); |
73 EXPECT_EQ(1u, status_vec.size()); | |
74 EXPECT_EQ(rtcp::TransportFeedback::StatusSymbol::kReceivedSmallDelta, | |
75 status_vec[0]); | |
76 std::vector<int64_t> delta_vec = packet->GetReceiveDeltasUs(); | |
77 EXPECT_EQ(1u, delta_vec.size()); | |
78 EXPECT_EQ(kBaseTimeMs, (packet->GetBaseTimeUs() + delta_vec[0]) / 1000); | |
79 return true; | 89 return true; |
80 })); | 90 })); |
81 | 91 |
82 Process(); | 92 Process(); |
83 } | 93 } |
84 | 94 |
85 TEST_F(RemoteEstimatorProxyTest, DuplicatedPackets) { | 95 TEST_F(RemoteEstimatorProxyTest, DuplicatedPackets) { |
86 IncomingPacket(kBaseSeq, kBaseTimeMs); | 96 IncomingPacket(kBaseSeq, kBaseTimeMs); |
87 IncomingPacket(kBaseSeq, kBaseTimeMs + 1000); | 97 IncomingPacket(kBaseSeq, kBaseTimeMs + 1000); |
88 | 98 |
89 EXPECT_CALL(router_, SendFeedback(_)) | 99 EXPECT_CALL(router_, SendFeedback(_)) |
90 .Times(1) | |
91 .WillOnce(Invoke([this](rtcp::TransportFeedback* packet) { | 100 .WillOnce(Invoke([this](rtcp::TransportFeedback* packet) { |
terelius
2017/01/17 16:32:23
feedback_packet?
danilchap
2017/01/17 17:20:14
Done.
| |
92 packet->Build(); | |
93 EXPECT_EQ(kBaseSeq, packet->GetBaseSequence()); | 101 EXPECT_EQ(kBaseSeq, packet->GetBaseSequence()); |
94 EXPECT_EQ(kMediaSsrc, packet->media_ssrc()); | 102 EXPECT_EQ(kMediaSsrc, packet->media_ssrc()); |
95 | 103 |
96 std::vector<rtcp::TransportFeedback::StatusSymbol> status_vec = | 104 EXPECT_THAT(SequenceNumbers(*packet), ElementsAre(kBaseSeq)); |
97 packet->GetStatusVector(); | 105 EXPECT_THAT(TimestampsMs(*packet), ElementsAre(kBaseTimeMs)); |
98 EXPECT_EQ(1u, status_vec.size()); | |
99 EXPECT_EQ(rtcp::TransportFeedback::StatusSymbol::kReceivedSmallDelta, | |
100 status_vec[0]); | |
101 std::vector<int64_t> delta_vec = packet->GetReceiveDeltasUs(); | |
102 EXPECT_EQ(1u, delta_vec.size()); | |
103 EXPECT_EQ(kBaseTimeMs, (packet->GetBaseTimeUs() + delta_vec[0]) / 1000); | |
104 return true; | 106 return true; |
105 })); | 107 })); |
106 | 108 |
107 Process(); | 109 Process(); |
108 } | 110 } |
109 | 111 |
110 TEST_F(RemoteEstimatorProxyTest, FeedbackWithMissingStart) { | 112 TEST_F(RemoteEstimatorProxyTest, FeedbackWithMissingStart) { |
111 // First feedback. | 113 // First feedback. |
112 IncomingPacket(kBaseSeq, kBaseTimeMs); | 114 IncomingPacket(kBaseSeq, kBaseTimeMs); |
113 IncomingPacket(kBaseSeq + 1, kBaseTimeMs + 1000); | 115 IncomingPacket(kBaseSeq + 1, kBaseTimeMs + 1000); |
114 EXPECT_CALL(router_, SendFeedback(_)).Times(1).WillOnce(Return(true)); | 116 EXPECT_CALL(router_, SendFeedback(_)).WillOnce(Return(true)); |
115 Process(); | 117 Process(); |
116 | 118 |
117 // Second feedback starts with a missing packet (DROP kBaseSeq + 2). | 119 // Second feedback starts with a missing packet (DROP kBaseSeq + 2). |
118 IncomingPacket(kBaseSeq + 3, kBaseTimeMs + 3000); | 120 IncomingPacket(kBaseSeq + 3, kBaseTimeMs + 3000); |
119 | 121 |
120 EXPECT_CALL(router_, SendFeedback(_)) | 122 EXPECT_CALL(router_, SendFeedback(_)) |
121 .Times(1) | |
122 .WillOnce(Invoke([this](rtcp::TransportFeedback* packet) { | 123 .WillOnce(Invoke([this](rtcp::TransportFeedback* packet) { |
terelius
2017/01/17 16:32:23
feedback_packet?
danilchap
2017/01/17 17:20:14
Done.
| |
123 packet->Build(); | |
124 EXPECT_EQ(kBaseSeq + 2, packet->GetBaseSequence()); | 124 EXPECT_EQ(kBaseSeq + 2, packet->GetBaseSequence()); |
125 EXPECT_EQ(kMediaSsrc, packet->media_ssrc()); | 125 EXPECT_EQ(kMediaSsrc, packet->media_ssrc()); |
126 | 126 |
127 std::vector<rtcp::TransportFeedback::StatusSymbol> status_vec = | 127 EXPECT_THAT(SequenceNumbers(*packet), ElementsAre(kBaseSeq + 3)); |
128 packet->GetStatusVector(); | 128 EXPECT_THAT(TimestampsMs(*packet), ElementsAre(kBaseTimeMs + 3000)); |
129 EXPECT_EQ(2u, status_vec.size()); | |
130 EXPECT_EQ(rtcp::TransportFeedback::StatusSymbol::kNotReceived, | |
131 status_vec[0]); | |
132 EXPECT_EQ(rtcp::TransportFeedback::StatusSymbol::kReceivedSmallDelta, | |
133 status_vec[1]); | |
134 std::vector<int64_t> delta_vec = packet->GetReceiveDeltasUs(); | |
135 EXPECT_EQ(1u, delta_vec.size()); | |
136 EXPECT_EQ(kBaseTimeMs + 3000, | |
137 (packet->GetBaseTimeUs() + delta_vec[0]) / 1000); | |
138 return true; | 129 return true; |
139 })); | 130 })); |
140 | 131 |
141 Process(); | 132 Process(); |
142 } | 133 } |
143 | 134 |
144 TEST_F(RemoteEstimatorProxyTest, SendsFeedbackWithVaryingDeltas) { | 135 TEST_F(RemoteEstimatorProxyTest, SendsFeedbackWithVaryingDeltas) { |
145 IncomingPacket(kBaseSeq, kBaseTimeMs); | 136 IncomingPacket(kBaseSeq, kBaseTimeMs); |
146 IncomingPacket(kBaseSeq + 1, kBaseTimeMs + kMaxSmallDeltaMs); | 137 IncomingPacket(kBaseSeq + 1, kBaseTimeMs + kMaxSmallDeltaMs); |
147 IncomingPacket(kBaseSeq + 2, kBaseTimeMs + (2 * kMaxSmallDeltaMs) + 1); | 138 IncomingPacket(kBaseSeq + 2, kBaseTimeMs + (2 * kMaxSmallDeltaMs) + 1); |
148 | 139 |
149 EXPECT_CALL(router_, SendFeedback(_)) | 140 EXPECT_CALL(router_, SendFeedback(_)) |
150 .Times(1) | |
151 .WillOnce(Invoke([this](rtcp::TransportFeedback* packet) { | 141 .WillOnce(Invoke([this](rtcp::TransportFeedback* packet) { |
terelius
2017/01/17 16:32:23
feedback_packet?
danilchap
2017/01/17 17:20:14
Done.
| |
152 packet->Build(); | |
153 EXPECT_EQ(kBaseSeq, packet->GetBaseSequence()); | 142 EXPECT_EQ(kBaseSeq, packet->GetBaseSequence()); |
154 EXPECT_EQ(kMediaSsrc, packet->media_ssrc()); | 143 EXPECT_EQ(kMediaSsrc, packet->media_ssrc()); |
155 | 144 |
156 std::vector<rtcp::TransportFeedback::StatusSymbol> status_vec = | 145 EXPECT_THAT(SequenceNumbers(*packet), |
157 packet->GetStatusVector(); | 146 ElementsAre(kBaseSeq, kBaseSeq + 1, kBaseSeq + 2)); |
158 EXPECT_EQ(3u, status_vec.size()); | 147 EXPECT_THAT(TimestampsMs(*packet), |
159 EXPECT_EQ(rtcp::TransportFeedback::StatusSymbol::kReceivedSmallDelta, | 148 ElementsAre(kBaseTimeMs, kBaseTimeMs + kMaxSmallDeltaMs, |
160 status_vec[0]); | 149 kBaseTimeMs + (2 * kMaxSmallDeltaMs) + 1)); |
161 EXPECT_EQ(rtcp::TransportFeedback::StatusSymbol::kReceivedSmallDelta, | |
162 status_vec[1]); | |
163 EXPECT_EQ(rtcp::TransportFeedback::StatusSymbol::kReceivedLargeDelta, | |
164 status_vec[2]); | |
165 | |
166 std::vector<int64_t> delta_vec = packet->GetReceiveDeltasUs(); | |
167 EXPECT_EQ(3u, delta_vec.size()); | |
168 EXPECT_EQ(kBaseTimeMs, (packet->GetBaseTimeUs() + delta_vec[0]) / 1000); | |
169 EXPECT_EQ(kMaxSmallDeltaMs, delta_vec[1] / 1000); | |
170 EXPECT_EQ(kMaxSmallDeltaMs + 1, delta_vec[2] / 1000); | |
171 return true; | 150 return true; |
172 })); | 151 })); |
173 | 152 |
174 Process(); | 153 Process(); |
175 } | 154 } |
176 | 155 |
177 TEST_F(RemoteEstimatorProxyTest, SendsFragmentedFeedback) { | 156 TEST_F(RemoteEstimatorProxyTest, SendsFragmentedFeedback) { |
178 const int64_t kTooLargeDelta = | 157 const int64_t kTooLargeDelta = |
179 rtcp::TransportFeedback::kDeltaScaleFactor * (1 << 16); | 158 rtcp::TransportFeedback::kDeltaScaleFactor * (1 << 16); |
180 | 159 |
181 IncomingPacket(kBaseSeq, kBaseTimeMs); | 160 IncomingPacket(kBaseSeq, kBaseTimeMs); |
182 IncomingPacket(kBaseSeq + 1, kBaseTimeMs + kTooLargeDelta); | 161 IncomingPacket(kBaseSeq + 1, kBaseTimeMs + kTooLargeDelta); |
183 | 162 |
184 InSequence s; | |
185 EXPECT_CALL(router_, SendFeedback(_)) | 163 EXPECT_CALL(router_, SendFeedback(_)) |
186 .Times(1) | |
187 .WillOnce(Invoke([kTooLargeDelta, this](rtcp::TransportFeedback* packet) { | 164 .WillOnce(Invoke([kTooLargeDelta, this](rtcp::TransportFeedback* packet) { |
terelius
2017/01/17 16:32:23
feedback_packet?
danilchap
2017/01/17 17:20:14
Done.
| |
188 packet->Build(); | |
189 EXPECT_EQ(kBaseSeq, packet->GetBaseSequence()); | 165 EXPECT_EQ(kBaseSeq, packet->GetBaseSequence()); |
190 EXPECT_EQ(kMediaSsrc, packet->media_ssrc()); | 166 EXPECT_EQ(kMediaSsrc, packet->media_ssrc()); |
191 | 167 |
192 std::vector<rtcp::TransportFeedback::StatusSymbol> status_vec = | 168 EXPECT_THAT(SequenceNumbers(*packet), ElementsAre(kBaseSeq)); |
193 packet->GetStatusVector(); | 169 EXPECT_THAT(TimestampsMs(*packet), ElementsAre(kBaseTimeMs)); |
194 EXPECT_EQ(1u, status_vec.size()); | |
195 EXPECT_EQ(rtcp::TransportFeedback::StatusSymbol::kReceivedSmallDelta, | |
196 status_vec[0]); | |
197 std::vector<int64_t> delta_vec = packet->GetReceiveDeltasUs(); | |
198 EXPECT_EQ(1u, delta_vec.size()); | |
199 EXPECT_EQ(kBaseTimeMs, (packet->GetBaseTimeUs() + delta_vec[0]) / 1000); | |
200 return true; | 170 return true; |
201 })) | 171 })) |
202 .RetiresOnSaturation(); | |
203 | |
204 EXPECT_CALL(router_, SendFeedback(_)) | |
205 .Times(1) | |
206 .WillOnce(Invoke([kTooLargeDelta, this](rtcp::TransportFeedback* packet) { | 172 .WillOnce(Invoke([kTooLargeDelta, this](rtcp::TransportFeedback* packet) { |
terelius
2017/01/17 16:32:23
feedback_packet?
danilchap
2017/01/17 17:20:14
Done.
| |
207 packet->Build(); | |
208 EXPECT_EQ(kBaseSeq + 1, packet->GetBaseSequence()); | 173 EXPECT_EQ(kBaseSeq + 1, packet->GetBaseSequence()); |
209 EXPECT_EQ(kMediaSsrc, packet->media_ssrc()); | 174 EXPECT_EQ(kMediaSsrc, packet->media_ssrc()); |
210 | 175 |
211 std::vector<rtcp::TransportFeedback::StatusSymbol> status_vec = | 176 EXPECT_THAT(SequenceNumbers(*packet), ElementsAre(kBaseSeq + 1)); |
212 packet->GetStatusVector(); | 177 EXPECT_THAT(TimestampsMs(*packet), |
213 EXPECT_EQ(1u, status_vec.size()); | 178 ElementsAre(kBaseTimeMs + kTooLargeDelta)); |
214 EXPECT_EQ(rtcp::TransportFeedback::StatusSymbol::kReceivedSmallDelta, | |
215 status_vec[0]); | |
216 std::vector<int64_t> delta_vec = packet->GetReceiveDeltasUs(); | |
217 EXPECT_EQ(1u, delta_vec.size()); | |
218 EXPECT_EQ(kBaseTimeMs + kTooLargeDelta, | |
219 (packet->GetBaseTimeUs() + delta_vec[0]) / 1000); | |
220 return true; | 179 return true; |
221 })) | 180 })); |
222 .RetiresOnSaturation(); | |
223 | 181 |
224 Process(); | 182 Process(); |
225 } | 183 } |
226 | 184 |
227 TEST_F(RemoteEstimatorProxyTest, GracefullyHandlesReorderingAndWrap) { | 185 TEST_F(RemoteEstimatorProxyTest, GracefullyHandlesReorderingAndWrap) { |
terelius
2017/01/17 16:32:23
Based on this test, it looks like "gracefully hand
danilchap
2017/01/17 17:20:14
Yes, currently 'gracefully' mean 'ignore but do no
| |
228 const int64_t kDeltaMs = 1000; | 186 const int64_t kDeltaMs = 1000; |
229 const uint16_t kLargeSeq = 62762; | 187 const uint16_t kLargeSeq = 62762; |
230 IncomingPacket(kBaseSeq, kBaseTimeMs); | 188 IncomingPacket(kBaseSeq, kBaseTimeMs); |
231 IncomingPacket(kLargeSeq, kBaseTimeMs + kDeltaMs); | 189 IncomingPacket(kLargeSeq, kBaseTimeMs + kDeltaMs); |
232 | 190 |
233 EXPECT_CALL(router_, SendFeedback(_)) | 191 EXPECT_CALL(router_, SendFeedback(_)) |
234 .Times(1) | |
235 .WillOnce(Invoke([this](rtcp::TransportFeedback* packet) { | 192 .WillOnce(Invoke([this](rtcp::TransportFeedback* packet) { |
terelius
2017/01/17 16:32:23
feedback_packet?
danilchap
2017/01/17 17:20:14
Done.
| |
236 packet->Build(); | |
237 EXPECT_EQ(kBaseSeq, packet->GetBaseSequence()); | 193 EXPECT_EQ(kBaseSeq, packet->GetBaseSequence()); |
238 EXPECT_EQ(kMediaSsrc, packet->media_ssrc()); | 194 EXPECT_EQ(kMediaSsrc, packet->media_ssrc()); |
239 | 195 |
240 std::vector<int64_t> delta_vec = packet->GetReceiveDeltasUs(); | 196 EXPECT_THAT(TimestampsMs(*packet), ElementsAre(kBaseTimeMs)); |
241 EXPECT_EQ(1u, delta_vec.size()); | |
242 EXPECT_EQ(kBaseTimeMs, (packet->GetBaseTimeUs() + delta_vec[0]) / 1000); | |
243 return true; | 197 return true; |
244 })); | 198 })); |
245 | 199 |
246 Process(); | 200 Process(); |
247 } | 201 } |
248 | 202 |
249 TEST_F(RemoteEstimatorProxyTest, ResendsTimestampsOnReordering) { | 203 TEST_F(RemoteEstimatorProxyTest, ResendsTimestampsOnReordering) { |
250 IncomingPacket(kBaseSeq, kBaseTimeMs); | 204 IncomingPacket(kBaseSeq, kBaseTimeMs); |
251 IncomingPacket(kBaseSeq + 2, kBaseTimeMs + 2); | 205 IncomingPacket(kBaseSeq + 2, kBaseTimeMs + 2); |
252 | 206 |
253 EXPECT_CALL(router_, SendFeedback(_)) | 207 EXPECT_CALL(router_, SendFeedback(_)) |
254 .Times(1) | |
255 .WillOnce(Invoke([this](rtcp::TransportFeedback* packet) { | 208 .WillOnce(Invoke([this](rtcp::TransportFeedback* packet) { |
terelius
2017/01/17 16:32:23
feedback_packet?
danilchap
2017/01/17 17:20:14
Done.
| |
256 packet->Build(); | |
257 EXPECT_EQ(kBaseSeq, packet->GetBaseSequence()); | 209 EXPECT_EQ(kBaseSeq, packet->GetBaseSequence()); |
258 EXPECT_EQ(kMediaSsrc, packet->media_ssrc()); | 210 EXPECT_EQ(kMediaSsrc, packet->media_ssrc()); |
259 | 211 |
260 std::vector<int64_t> delta_vec = packet->GetReceiveDeltasUs(); | 212 EXPECT_THAT(SequenceNumbers(*packet), |
261 EXPECT_EQ(2u, delta_vec.size()); | 213 ElementsAre(kBaseSeq, kBaseSeq + 2)); |
262 EXPECT_EQ(kBaseTimeMs, (packet->GetBaseTimeUs() + delta_vec[0]) / 1000); | 214 EXPECT_THAT(TimestampsMs(*packet), |
263 EXPECT_EQ(2, delta_vec[1] / 1000); | 215 ElementsAre(kBaseTimeMs, kBaseTimeMs + 2)); |
264 return true; | 216 return true; |
265 })); | 217 })); |
266 | 218 |
267 Process(); | 219 Process(); |
268 | 220 |
269 IncomingPacket(kBaseSeq + 1, kBaseTimeMs + 1); | 221 IncomingPacket(kBaseSeq + 1, kBaseTimeMs + 1); |
270 | 222 |
271 EXPECT_CALL(router_, SendFeedback(_)) | 223 EXPECT_CALL(router_, SendFeedback(_)) |
272 .Times(1) | |
273 .WillOnce(Invoke([this](rtcp::TransportFeedback* packet) { | 224 .WillOnce(Invoke([this](rtcp::TransportFeedback* packet) { |
terelius
2017/01/17 16:32:23
feedback_packet?
danilchap
2017/01/17 17:20:14
Done.
| |
274 packet->Build(); | |
275 EXPECT_EQ(kBaseSeq + 1, packet->GetBaseSequence()); | 225 EXPECT_EQ(kBaseSeq + 1, packet->GetBaseSequence()); |
276 EXPECT_EQ(kMediaSsrc, packet->media_ssrc()); | 226 EXPECT_EQ(kMediaSsrc, packet->media_ssrc()); |
277 | 227 |
278 std::vector<int64_t> delta_vec = packet->GetReceiveDeltasUs(); | 228 EXPECT_THAT(SequenceNumbers(*packet), |
279 EXPECT_EQ(2u, delta_vec.size()); | 229 ElementsAre(kBaseSeq + 1, kBaseSeq + 2)); |
280 EXPECT_EQ(kBaseTimeMs + 1, | 230 EXPECT_THAT(TimestampsMs(*packet), |
281 (packet->GetBaseTimeUs() + delta_vec[0]) / 1000); | 231 ElementsAre(kBaseTimeMs + 1, kBaseTimeMs + 2)); |
282 EXPECT_EQ(1, delta_vec[1] / 1000); | |
283 return true; | 232 return true; |
284 })); | 233 })); |
285 | 234 |
286 Process(); | 235 Process(); |
287 } | 236 } |
288 | 237 |
289 TEST_F(RemoteEstimatorProxyTest, RemovesTimestampsOutOfScope) { | 238 TEST_F(RemoteEstimatorProxyTest, RemovesTimestampsOutOfScope) { |
290 const int64_t kTimeoutTimeMs = | 239 const int64_t kTimeoutTimeMs = |
291 kBaseTimeMs + RemoteEstimatorProxy::kBackWindowMs; | 240 kBaseTimeMs + RemoteEstimatorProxy::kBackWindowMs; |
292 | 241 |
293 IncomingPacket(kBaseSeq + 2, kBaseTimeMs); | 242 IncomingPacket(kBaseSeq + 2, kBaseTimeMs); |
294 | 243 |
295 EXPECT_CALL(router_, SendFeedback(_)) | 244 EXPECT_CALL(router_, SendFeedback(_)) |
296 .Times(1) | |
297 .WillOnce(Invoke([kTimeoutTimeMs, this](rtcp::TransportFeedback* packet) { | 245 .WillOnce(Invoke([kTimeoutTimeMs, this](rtcp::TransportFeedback* packet) { |
terelius
2017/01/17 16:32:23
feedback_packet?
danilchap
2017/01/17 17:20:14
Done.
| |
298 packet->Build(); | |
299 EXPECT_EQ(kBaseSeq + 2, packet->GetBaseSequence()); | 246 EXPECT_EQ(kBaseSeq + 2, packet->GetBaseSequence()); |
300 | 247 |
301 std::vector<int64_t> delta_vec = packet->GetReceiveDeltasUs(); | 248 EXPECT_THAT(TimestampsMs(*packet), ElementsAre(kBaseTimeMs)); |
302 EXPECT_EQ(1u, delta_vec.size()); | |
303 EXPECT_EQ(kBaseTimeMs, (packet->GetBaseTimeUs() + delta_vec[0]) / 1000); | |
304 return true; | 249 return true; |
305 })); | 250 })); |
306 | 251 |
307 Process(); | 252 Process(); |
308 | 253 |
309 IncomingPacket(kBaseSeq + 3, kTimeoutTimeMs); // kBaseSeq + 2 times out here. | 254 IncomingPacket(kBaseSeq + 3, kTimeoutTimeMs); // kBaseSeq + 2 times out here. |
310 | 255 |
311 EXPECT_CALL(router_, SendFeedback(_)) | 256 EXPECT_CALL(router_, SendFeedback(_)) |
312 .Times(1) | |
313 .WillOnce(Invoke([kTimeoutTimeMs, this](rtcp::TransportFeedback* packet) { | 257 .WillOnce(Invoke([kTimeoutTimeMs, this](rtcp::TransportFeedback* packet) { |
314 packet->Build(); | |
315 EXPECT_EQ(kBaseSeq + 3, packet->GetBaseSequence()); | 258 EXPECT_EQ(kBaseSeq + 3, packet->GetBaseSequence()); |
316 | 259 |
317 std::vector<int64_t> delta_vec = packet->GetReceiveDeltasUs(); | 260 EXPECT_THAT(TimestampsMs(*packet), ElementsAre(kTimeoutTimeMs)); |
318 EXPECT_EQ(1u, delta_vec.size()); | |
319 EXPECT_EQ(kTimeoutTimeMs, | |
320 (packet->GetBaseTimeUs() + delta_vec[0]) / 1000); | |
321 return true; | 261 return true; |
322 })); | 262 })); |
323 | 263 |
324 Process(); | 264 Process(); |
325 | 265 |
326 // New group, with sequence starting below the first so that they may be | 266 // New group, with sequence starting below the first so that they may be |
327 // retransmitted. | 267 // retransmitted. |
328 IncomingPacket(kBaseSeq, kBaseTimeMs - 1); | 268 IncomingPacket(kBaseSeq, kBaseTimeMs - 1); |
329 IncomingPacket(kBaseSeq + 1, kTimeoutTimeMs - 1); | 269 IncomingPacket(kBaseSeq + 1, kTimeoutTimeMs - 1); |
330 | 270 |
331 EXPECT_CALL(router_, SendFeedback(_)) | 271 EXPECT_CALL(router_, SendFeedback(_)) |
332 .Times(1) | |
333 .WillOnce(Invoke([kTimeoutTimeMs, this](rtcp::TransportFeedback* packet) { | 272 .WillOnce(Invoke([kTimeoutTimeMs, this](rtcp::TransportFeedback* packet) { |
terelius
2017/01/17 16:32:23
feedback_packet?
danilchap
2017/01/17 17:20:14
Done.
| |
334 packet->Build(); | |
335 EXPECT_EQ(kBaseSeq, packet->GetBaseSequence()); | 273 EXPECT_EQ(kBaseSeq, packet->GetBaseSequence()); |
336 | 274 |
337 // Four status entries (kBaseSeq + 3 missing). | 275 EXPECT_THAT(SequenceNumbers(*packet), |
338 EXPECT_EQ(4u, packet->GetStatusVector().size()); | 276 ElementsAre(kBaseSeq, kBaseSeq + 1, kBaseSeq + 3)); |
339 | 277 EXPECT_THAT( |
340 // Only three actual timestamps. | 278 TimestampsMs(*packet), |
341 std::vector<int64_t> delta_vec = packet->GetReceiveDeltasUs(); | 279 ElementsAre(kBaseTimeMs - 1, kTimeoutTimeMs - 1, kTimeoutTimeMs)); |
342 EXPECT_EQ(3u, delta_vec.size()); | |
343 EXPECT_EQ(kBaseTimeMs - 1, | |
344 (packet->GetBaseTimeUs() + delta_vec[0]) / 1000); | |
345 EXPECT_EQ(kTimeoutTimeMs - kBaseTimeMs, delta_vec[1] / 1000); | |
346 EXPECT_EQ(1, delta_vec[2] / 1000); | |
347 return true; | 280 return true; |
348 })); | 281 })); |
349 | 282 |
350 Process(); | 283 Process(); |
351 } | 284 } |
352 | 285 |
353 TEST_F(RemoteEstimatorProxyTest, TimeUntilNextProcessIsZeroBeforeFirstProcess) { | 286 TEST_F(RemoteEstimatorProxyTest, TimeUntilNextProcessIsZeroBeforeFirstProcess) { |
354 EXPECT_EQ(0, proxy_.TimeUntilNextProcess()); | 287 EXPECT_EQ(0, proxy_.TimeUntilNextProcess()); |
355 } | 288 } |
356 | 289 |
(...skipping 27 matching lines...) Expand all Loading... | |
384 proxy_.TimeUntilNextProcess()); | 317 proxy_.TimeUntilNextProcess()); |
385 } | 318 } |
386 | 319 |
387 TEST_F(RemoteEstimatorProxyTest, TwccReportsUse5PercentOfAvailableBandwidth) { | 320 TEST_F(RemoteEstimatorProxyTest, TwccReportsUse5PercentOfAvailableBandwidth) { |
388 Process(); | 321 Process(); |
389 proxy_.OnBitrateChanged(80000); | 322 proxy_.OnBitrateChanged(80000); |
390 // 80kbps * 0.05 = TwccReportSize(68B * 8b/B) * 1000ms / SendInterval(136ms) | 323 // 80kbps * 0.05 = TwccReportSize(68B * 8b/B) * 1000ms / SendInterval(136ms) |
391 EXPECT_EQ(136, proxy_.TimeUntilNextProcess()); | 324 EXPECT_EQ(136, proxy_.TimeUntilNextProcess()); |
392 } | 325 } |
393 | 326 |
327 } // namespace | |
394 } // namespace webrtc | 328 } // namespace webrtc |
OLD | NEW |