OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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 |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 const uint32_t kSenderSsrc = 0x10203; | 190 const uint32_t kSenderSsrc = 0x10203; |
191 const uint32_t kSourceSsrc = 0x123456; | 191 const uint32_t kSourceSsrc = 0x123456; |
192 std::set<uint32_t> ssrcs; | 192 std::set<uint32_t> ssrcs; |
193 ssrcs.insert(kSourceSsrc); | 193 ssrcs.insert(kSourceSsrc); |
194 rtcp_receiver_->SetSsrcs(kSourceSsrc, ssrcs); | 194 rtcp_receiver_->SetSsrcs(kSourceSsrc, ssrcs); |
195 | 195 |
196 rtcp::ReportBlock rb; | 196 rtcp::ReportBlock rb; |
197 rb.To(kSourceSsrc + 1); | 197 rb.To(kSourceSsrc + 1); |
198 rtcp::ReceiverReport rr; | 198 rtcp::ReceiverReport rr; |
199 rr.From(kSenderSsrc); | 199 rr.From(kSenderSsrc); |
200 rr.WithReportBlock(&rb); | 200 rr.WithReportBlock(rb); |
201 rtc::scoped_ptr<rtcp::RawPacket> packet(rr.Build()); | 201 rtc::scoped_ptr<rtcp::RawPacket> packet(rr.Build()); |
202 EXPECT_EQ(0, InjectRtcpPacket(packet->Buffer(), packet->Length())); | 202 EXPECT_EQ(0, InjectRtcpPacket(packet->Buffer(), packet->Length())); |
203 EXPECT_EQ(kSenderSsrc, rtcp_packet_info_.remoteSSRC); | 203 EXPECT_EQ(kSenderSsrc, rtcp_packet_info_.remoteSSRC); |
204 EXPECT_EQ(kRtcpRr, rtcp_packet_info_.rtcpPacketTypeFlags); | 204 EXPECT_EQ(kRtcpRr, rtcp_packet_info_.rtcpPacketTypeFlags); |
205 ASSERT_EQ(0u, rtcp_packet_info_.report_blocks.size()); | 205 ASSERT_EQ(0u, rtcp_packet_info_.report_blocks.size()); |
206 | 206 |
207 std::vector<RTCPReportBlock> received_blocks; | 207 std::vector<RTCPReportBlock> received_blocks; |
208 rtcp_receiver_->StatisticsReceived(&received_blocks); | 208 rtcp_receiver_->StatisticsReceived(&received_blocks); |
209 EXPECT_TRUE(received_blocks.empty()); | 209 EXPECT_TRUE(received_blocks.empty()); |
210 } | 210 } |
211 | 211 |
212 TEST_F(RtcpReceiverTest, InjectRrPacketWithOneReportBlock) { | 212 TEST_F(RtcpReceiverTest, InjectRrPacketWithOneReportBlock) { |
213 const uint32_t kSenderSsrc = 0x10203; | 213 const uint32_t kSenderSsrc = 0x10203; |
214 const uint32_t kSourceSsrc = 0x123456; | 214 const uint32_t kSourceSsrc = 0x123456; |
215 std::set<uint32_t> ssrcs; | 215 std::set<uint32_t> ssrcs; |
216 ssrcs.insert(kSourceSsrc); | 216 ssrcs.insert(kSourceSsrc); |
217 rtcp_receiver_->SetSsrcs(kSourceSsrc, ssrcs); | 217 rtcp_receiver_->SetSsrcs(kSourceSsrc, ssrcs); |
218 | 218 |
219 rtcp::ReportBlock rb; | 219 rtcp::ReportBlock rb; |
220 rb.To(kSourceSsrc); | 220 rb.To(kSourceSsrc); |
221 rtcp::ReceiverReport rr; | 221 rtcp::ReceiverReport rr; |
222 rr.From(kSenderSsrc); | 222 rr.From(kSenderSsrc); |
223 rr.WithReportBlock(&rb); | 223 rr.WithReportBlock(rb); |
224 rtc::scoped_ptr<rtcp::RawPacket> packet(rr.Build()); | 224 rtc::scoped_ptr<rtcp::RawPacket> packet(rr.Build()); |
225 EXPECT_EQ(0, InjectRtcpPacket(packet->Buffer(), packet->Length())); | 225 EXPECT_EQ(0, InjectRtcpPacket(packet->Buffer(), packet->Length())); |
226 EXPECT_EQ(kSenderSsrc, rtcp_packet_info_.remoteSSRC); | 226 EXPECT_EQ(kSenderSsrc, rtcp_packet_info_.remoteSSRC); |
227 EXPECT_EQ(kRtcpRr, rtcp_packet_info_.rtcpPacketTypeFlags); | 227 EXPECT_EQ(kRtcpRr, rtcp_packet_info_.rtcpPacketTypeFlags); |
228 ASSERT_EQ(1u, rtcp_packet_info_.report_blocks.size()); | 228 ASSERT_EQ(1u, rtcp_packet_info_.report_blocks.size()); |
229 | 229 |
230 std::vector<RTCPReportBlock> received_blocks; | 230 std::vector<RTCPReportBlock> received_blocks; |
231 rtcp_receiver_->StatisticsReceived(&received_blocks); | 231 rtcp_receiver_->StatisticsReceived(&received_blocks); |
232 EXPECT_EQ(1u, received_blocks.size()); | 232 EXPECT_EQ(1u, received_blocks.size()); |
233 } | 233 } |
(...skipping 14 matching lines...) Expand all Loading... |
248 rb1.WithExtHighestSeqNum(kSequenceNumbers[0]); | 248 rb1.WithExtHighestSeqNum(kSequenceNumbers[0]); |
249 rb1.WithFractionLost(10); | 249 rb1.WithFractionLost(10); |
250 rb1.WithCumulativeLost(5); | 250 rb1.WithCumulativeLost(5); |
251 | 251 |
252 rtcp::ReportBlock rb2; | 252 rtcp::ReportBlock rb2; |
253 rb2.To(kSourceSsrcs[1]); | 253 rb2.To(kSourceSsrcs[1]); |
254 rb2.WithExtHighestSeqNum(kSequenceNumbers[1]); | 254 rb2.WithExtHighestSeqNum(kSequenceNumbers[1]); |
255 | 255 |
256 rtcp::ReceiverReport rr1; | 256 rtcp::ReceiverReport rr1; |
257 rr1.From(kSenderSsrc); | 257 rr1.From(kSenderSsrc); |
258 rr1.WithReportBlock(&rb1); | 258 rr1.WithReportBlock(rb1); |
259 rr1.WithReportBlock(&rb2); | 259 rr1.WithReportBlock(rb2); |
260 | 260 |
261 rtc::scoped_ptr<rtcp::RawPacket> p1(rr1.Build()); | 261 rtc::scoped_ptr<rtcp::RawPacket> p1(rr1.Build()); |
262 EXPECT_EQ(0, InjectRtcpPacket(p1->Buffer(), p1->Length())); | 262 EXPECT_EQ(0, InjectRtcpPacket(p1->Buffer(), p1->Length())); |
263 ASSERT_EQ(2u, rtcp_packet_info_.report_blocks.size()); | 263 ASSERT_EQ(2u, rtcp_packet_info_.report_blocks.size()); |
264 EXPECT_EQ(10, rtcp_packet_info_.report_blocks.front().fractionLost); | 264 EXPECT_EQ(10, rtcp_packet_info_.report_blocks.front().fractionLost); |
265 EXPECT_EQ(0, rtcp_packet_info_.report_blocks.back().fractionLost); | 265 EXPECT_EQ(0, rtcp_packet_info_.report_blocks.back().fractionLost); |
266 | 266 |
267 rtcp::ReportBlock rb3; | 267 rtcp::ReportBlock rb3; |
268 rb3.To(kSourceSsrcs[0]); | 268 rb3.To(kSourceSsrcs[0]); |
269 rb3.WithExtHighestSeqNum(kSequenceNumbers[0]); | 269 rb3.WithExtHighestSeqNum(kSequenceNumbers[0]); |
270 rb3.WithFractionLost(kFracLost[0]); | 270 rb3.WithFractionLost(kFracLost[0]); |
271 rb3.WithCumulativeLost(kCumLost[0]); | 271 rb3.WithCumulativeLost(kCumLost[0]); |
272 | 272 |
273 rtcp::ReportBlock rb4; | 273 rtcp::ReportBlock rb4; |
274 rb4.To(kSourceSsrcs[1]); | 274 rb4.To(kSourceSsrcs[1]); |
275 rb4.WithExtHighestSeqNum(kSequenceNumbers[1]); | 275 rb4.WithExtHighestSeqNum(kSequenceNumbers[1]); |
276 rb4.WithFractionLost(kFracLost[1]); | 276 rb4.WithFractionLost(kFracLost[1]); |
277 rb4.WithCumulativeLost(kCumLost[1]); | 277 rb4.WithCumulativeLost(kCumLost[1]); |
278 | 278 |
279 rtcp::ReceiverReport rr2; | 279 rtcp::ReceiverReport rr2; |
280 rr2.From(kSenderSsrc); | 280 rr2.From(kSenderSsrc); |
281 rr2.WithReportBlock(&rb3); | 281 rr2.WithReportBlock(rb3); |
282 rr2.WithReportBlock(&rb4); | 282 rr2.WithReportBlock(rb4); |
283 | 283 |
284 rtc::scoped_ptr<rtcp::RawPacket> p2(rr2.Build()); | 284 rtc::scoped_ptr<rtcp::RawPacket> p2(rr2.Build()); |
285 EXPECT_EQ(0, InjectRtcpPacket(p2->Buffer(), p2->Length())); | 285 EXPECT_EQ(0, InjectRtcpPacket(p2->Buffer(), p2->Length())); |
286 ASSERT_EQ(2u, rtcp_packet_info_.report_blocks.size()); | 286 ASSERT_EQ(2u, rtcp_packet_info_.report_blocks.size()); |
287 EXPECT_EQ(kFracLost[0], rtcp_packet_info_.report_blocks.front().fractionLost); | 287 EXPECT_EQ(kFracLost[0], rtcp_packet_info_.report_blocks.front().fractionLost); |
288 EXPECT_EQ(kFracLost[1], rtcp_packet_info_.report_blocks.back().fractionLost); | 288 EXPECT_EQ(kFracLost[1], rtcp_packet_info_.report_blocks.back().fractionLost); |
289 | 289 |
290 std::vector<RTCPReportBlock> received_blocks; | 290 std::vector<RTCPReportBlock> received_blocks; |
291 rtcp_receiver_->StatisticsReceived(&received_blocks); | 291 rtcp_receiver_->StatisticsReceived(&received_blocks); |
292 EXPECT_EQ(2u, received_blocks.size()); | 292 EXPECT_EQ(2u, received_blocks.size()); |
(...skipping 18 matching lines...) Expand all Loading... |
311 std::set<uint32_t> ssrcs(kSourceSsrcs, kSourceSsrcs + kNumSsrcs); | 311 std::set<uint32_t> ssrcs(kSourceSsrcs, kSourceSsrcs + kNumSsrcs); |
312 rtcp_receiver_->SetSsrcs(kSourceSsrcs[0], ssrcs); | 312 rtcp_receiver_->SetSsrcs(kSourceSsrcs[0], ssrcs); |
313 | 313 |
314 rtcp::ReportBlock rb1; | 314 rtcp::ReportBlock rb1; |
315 rb1.To(kSourceSsrcs[0]); | 315 rb1.To(kSourceSsrcs[0]); |
316 rb1.WithExtHighestSeqNum(kSequenceNumbers[0]); | 316 rb1.WithExtHighestSeqNum(kSequenceNumbers[0]); |
317 rb1.WithFractionLost(kFracLost[0]); | 317 rb1.WithFractionLost(kFracLost[0]); |
318 rb1.WithCumulativeLost(kCumLost[0]); | 318 rb1.WithCumulativeLost(kCumLost[0]); |
319 rtcp::ReceiverReport rr1; | 319 rtcp::ReceiverReport rr1; |
320 rr1.From(kSenderSsrc1); | 320 rr1.From(kSenderSsrc1); |
321 rr1.WithReportBlock(&rb1); | 321 rr1.WithReportBlock(rb1); |
322 | 322 |
323 rtc::scoped_ptr<rtcp::RawPacket> p1(rr1.Build()); | 323 rtc::scoped_ptr<rtcp::RawPacket> p1(rr1.Build()); |
324 EXPECT_EQ(0, InjectRtcpPacket(p1->Buffer(), p1->Length())); | 324 EXPECT_EQ(0, InjectRtcpPacket(p1->Buffer(), p1->Length())); |
325 ASSERT_EQ(1u, rtcp_packet_info_.report_blocks.size()); | 325 ASSERT_EQ(1u, rtcp_packet_info_.report_blocks.size()); |
326 EXPECT_EQ(kFracLost[0], rtcp_packet_info_.report_blocks.front().fractionLost); | 326 EXPECT_EQ(kFracLost[0], rtcp_packet_info_.report_blocks.front().fractionLost); |
327 | 327 |
328 std::vector<RTCPReportBlock> received_blocks; | 328 std::vector<RTCPReportBlock> received_blocks; |
329 rtcp_receiver_->StatisticsReceived(&received_blocks); | 329 rtcp_receiver_->StatisticsReceived(&received_blocks); |
330 EXPECT_EQ(1u, received_blocks.size()); | 330 EXPECT_EQ(1u, received_blocks.size()); |
331 EXPECT_EQ(kSenderSsrc1, received_blocks[0].remoteSSRC); | 331 EXPECT_EQ(kSenderSsrc1, received_blocks[0].remoteSSRC); |
332 EXPECT_EQ(kSourceSsrcs[0], received_blocks[0].sourceSSRC); | 332 EXPECT_EQ(kSourceSsrcs[0], received_blocks[0].sourceSSRC); |
333 EXPECT_EQ(kFracLost[0], received_blocks[0].fractionLost); | 333 EXPECT_EQ(kFracLost[0], received_blocks[0].fractionLost); |
334 EXPECT_EQ(kCumLost[0], received_blocks[0].cumulativeLost); | 334 EXPECT_EQ(kCumLost[0], received_blocks[0].cumulativeLost); |
335 EXPECT_EQ(kSequenceNumbers[0], received_blocks[0].extendedHighSeqNum); | 335 EXPECT_EQ(kSequenceNumbers[0], received_blocks[0].extendedHighSeqNum); |
336 | 336 |
337 rtcp::ReportBlock rb2; | 337 rtcp::ReportBlock rb2; |
338 rb2.To(kSourceSsrcs[0]); | 338 rb2.To(kSourceSsrcs[0]); |
339 rb2.WithExtHighestSeqNum(kSequenceNumbers[1]); | 339 rb2.WithExtHighestSeqNum(kSequenceNumbers[1]); |
340 rb2.WithFractionLost(kFracLost[1]); | 340 rb2.WithFractionLost(kFracLost[1]); |
341 rb2.WithCumulativeLost(kCumLost[1]); | 341 rb2.WithCumulativeLost(kCumLost[1]); |
342 rtcp::ReceiverReport rr2; | 342 rtcp::ReceiverReport rr2; |
343 rr2.From(kSenderSsrc2); | 343 rr2.From(kSenderSsrc2); |
344 rr2.WithReportBlock(&rb2); | 344 rr2.WithReportBlock(rb2); |
345 rtc::scoped_ptr<rtcp::RawPacket> p2(rr2.Build()); | 345 rtc::scoped_ptr<rtcp::RawPacket> p2(rr2.Build()); |
346 EXPECT_EQ(0, InjectRtcpPacket(p2->Buffer(), p2->Length())); | 346 EXPECT_EQ(0, InjectRtcpPacket(p2->Buffer(), p2->Length())); |
347 ASSERT_EQ(1u, rtcp_packet_info_.report_blocks.size()); | 347 ASSERT_EQ(1u, rtcp_packet_info_.report_blocks.size()); |
348 EXPECT_EQ(kFracLost[1], rtcp_packet_info_.report_blocks.front().fractionLost); | 348 EXPECT_EQ(kFracLost[1], rtcp_packet_info_.report_blocks.front().fractionLost); |
349 | 349 |
350 received_blocks.clear(); | 350 received_blocks.clear(); |
351 rtcp_receiver_->StatisticsReceived(&received_blocks); | 351 rtcp_receiver_->StatisticsReceived(&received_blocks); |
352 ASSERT_EQ(2u, received_blocks.size()); | 352 ASSERT_EQ(2u, received_blocks.size()); |
353 EXPECT_EQ(kSenderSsrc1, received_blocks[0].remoteSSRC); | 353 EXPECT_EQ(kSenderSsrc1, received_blocks[0].remoteSSRC); |
354 EXPECT_EQ(kSenderSsrc2, received_blocks[1].remoteSSRC); | 354 EXPECT_EQ(kSenderSsrc2, received_blocks[1].remoteSSRC); |
(...skipping 12 matching lines...) Expand all Loading... |
367 ssrcs.insert(kSourceSsrc); | 367 ssrcs.insert(kSourceSsrc); |
368 rtcp_receiver_->SetSsrcs(kSourceSsrc, ssrcs); | 368 rtcp_receiver_->SetSsrcs(kSourceSsrc, ssrcs); |
369 | 369 |
370 // No report block received. | 370 // No report block received. |
371 EXPECT_EQ(-1, rtcp_receiver_->RTT(kSenderSsrc, NULL, NULL, NULL, NULL)); | 371 EXPECT_EQ(-1, rtcp_receiver_->RTT(kSenderSsrc, NULL, NULL, NULL, NULL)); |
372 | 372 |
373 rtcp::ReportBlock rb; | 373 rtcp::ReportBlock rb; |
374 rb.To(kSourceSsrc); | 374 rb.To(kSourceSsrc); |
375 rtcp::ReceiverReport rr; | 375 rtcp::ReceiverReport rr; |
376 rr.From(kSenderSsrc); | 376 rr.From(kSenderSsrc); |
377 rr.WithReportBlock(&rb); | 377 rr.WithReportBlock(rb); |
378 rtc::scoped_ptr<rtcp::RawPacket> packet(rr.Build()); | 378 rtc::scoped_ptr<rtcp::RawPacket> packet(rr.Build()); |
379 EXPECT_EQ(0, InjectRtcpPacket(packet->Buffer(), packet->Length())); | 379 EXPECT_EQ(0, InjectRtcpPacket(packet->Buffer(), packet->Length())); |
380 EXPECT_EQ(kSenderSsrc, rtcp_packet_info_.remoteSSRC); | 380 EXPECT_EQ(kSenderSsrc, rtcp_packet_info_.remoteSSRC); |
381 EXPECT_EQ(kRtcpRr, rtcp_packet_info_.rtcpPacketTypeFlags); | 381 EXPECT_EQ(kRtcpRr, rtcp_packet_info_.rtcpPacketTypeFlags); |
382 EXPECT_EQ(1u, rtcp_packet_info_.report_blocks.size()); | 382 EXPECT_EQ(1u, rtcp_packet_info_.report_blocks.size()); |
383 EXPECT_EQ(0, rtcp_receiver_->RTT(kSenderSsrc, NULL, NULL, NULL, NULL)); | 383 EXPECT_EQ(0, rtcp_receiver_->RTT(kSenderSsrc, NULL, NULL, NULL, NULL)); |
384 | 384 |
385 // Report block not received. | 385 // Report block not received. |
386 EXPECT_EQ(-1, rtcp_receiver_->RTT(kSenderSsrc + 1, NULL, NULL, NULL, NULL)); | 386 EXPECT_EQ(-1, rtcp_receiver_->RTT(kSenderSsrc + 1, NULL, NULL, NULL, NULL)); |
387 } | 387 } |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
477 | 477 |
478 std::set<uint32_t> ssrcs(kSourceSsrcs, kSourceSsrcs + kNumSsrcs); | 478 std::set<uint32_t> ssrcs(kSourceSsrcs, kSourceSsrcs + kNumSsrcs); |
479 rtcp_receiver_->SetSsrcs(kSourceSsrcs[0], ssrcs); | 479 rtcp_receiver_->SetSsrcs(kSourceSsrcs[0], ssrcs); |
480 | 480 |
481 rtcp::ReportBlock rb1; | 481 rtcp::ReportBlock rb1; |
482 rb1.To(kSourceSsrcs[0]); | 482 rb1.To(kSourceSsrcs[0]); |
483 rtcp::ReportBlock rb2; | 483 rtcp::ReportBlock rb2; |
484 rb2.To(kSourceSsrcs[1]); | 484 rb2.To(kSourceSsrcs[1]); |
485 rtcp::ReceiverReport rr; | 485 rtcp::ReceiverReport rr; |
486 rr.From(kSenderSsrc); | 486 rr.From(kSenderSsrc); |
487 rr.WithReportBlock(&rb1); | 487 rr.WithReportBlock(rb1); |
488 rr.WithReportBlock(&rb2); | 488 rr.WithReportBlock(rb2); |
489 | 489 |
490 rtc::scoped_ptr<rtcp::RawPacket> p1(rr.Build()); | 490 rtc::scoped_ptr<rtcp::RawPacket> p1(rr.Build()); |
491 EXPECT_EQ(0, InjectRtcpPacket(p1->Buffer(), p1->Length())); | 491 EXPECT_EQ(0, InjectRtcpPacket(p1->Buffer(), p1->Length())); |
492 ASSERT_EQ(2u, rtcp_packet_info_.report_blocks.size()); | 492 ASSERT_EQ(2u, rtcp_packet_info_.report_blocks.size()); |
493 std::vector<RTCPReportBlock> received_blocks; | 493 std::vector<RTCPReportBlock> received_blocks; |
494 rtcp_receiver_->StatisticsReceived(&received_blocks); | 494 rtcp_receiver_->StatisticsReceived(&received_blocks); |
495 EXPECT_EQ(2u, received_blocks.size()); | 495 EXPECT_EQ(2u, received_blocks.size()); |
496 | 496 |
497 // Verify that BYE removes the report blocks. | 497 // Verify that BYE removes the report blocks. |
498 rtcp::Bye bye; | 498 rtcp::Bye bye; |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
795 // No RR received, shouldn't trigger a timeout. | 795 // No RR received, shouldn't trigger a timeout. |
796 EXPECT_FALSE(rtcp_receiver_->RtcpRrTimeout(kRtcpIntervalMs)); | 796 EXPECT_FALSE(rtcp_receiver_->RtcpRrTimeout(kRtcpIntervalMs)); |
797 EXPECT_FALSE(rtcp_receiver_->RtcpRrSequenceNumberTimeout(kRtcpIntervalMs)); | 797 EXPECT_FALSE(rtcp_receiver_->RtcpRrSequenceNumberTimeout(kRtcpIntervalMs)); |
798 | 798 |
799 // Add a RR and advance the clock just enough to not trigger a timeout. | 799 // Add a RR and advance the clock just enough to not trigger a timeout. |
800 rtcp::ReportBlock rb1; | 800 rtcp::ReportBlock rb1; |
801 rb1.To(kSourceSsrc); | 801 rb1.To(kSourceSsrc); |
802 rb1.WithExtHighestSeqNum(kSequenceNumber); | 802 rb1.WithExtHighestSeqNum(kSequenceNumber); |
803 rtcp::ReceiverReport rr1; | 803 rtcp::ReceiverReport rr1; |
804 rr1.From(kSenderSsrc); | 804 rr1.From(kSenderSsrc); |
805 rr1.WithReportBlock(&rb1); | 805 rr1.WithReportBlock(rb1); |
806 rtc::scoped_ptr<rtcp::RawPacket> p1(rr1.Build()); | 806 rtc::scoped_ptr<rtcp::RawPacket> p1(rr1.Build()); |
807 EXPECT_EQ(0, InjectRtcpPacket(p1->Buffer(), p1->Length())); | 807 EXPECT_EQ(0, InjectRtcpPacket(p1->Buffer(), p1->Length())); |
808 system_clock_.AdvanceTimeMilliseconds(3 * kRtcpIntervalMs - 1); | 808 system_clock_.AdvanceTimeMilliseconds(3 * kRtcpIntervalMs - 1); |
809 EXPECT_FALSE(rtcp_receiver_->RtcpRrTimeout(kRtcpIntervalMs)); | 809 EXPECT_FALSE(rtcp_receiver_->RtcpRrTimeout(kRtcpIntervalMs)); |
810 EXPECT_FALSE(rtcp_receiver_->RtcpRrSequenceNumberTimeout(kRtcpIntervalMs)); | 810 EXPECT_FALSE(rtcp_receiver_->RtcpRrSequenceNumberTimeout(kRtcpIntervalMs)); |
811 | 811 |
812 // Add a RR with the same extended max as the previous RR to trigger a | 812 // Add a RR with the same extended max as the previous RR to trigger a |
813 // sequence number timeout, but not a RR timeout. | 813 // sequence number timeout, but not a RR timeout. |
814 EXPECT_EQ(0, InjectRtcpPacket(p1->Buffer(), p1->Length())); | 814 EXPECT_EQ(0, InjectRtcpPacket(p1->Buffer(), p1->Length())); |
815 system_clock_.AdvanceTimeMilliseconds(2); | 815 system_clock_.AdvanceTimeMilliseconds(2); |
816 EXPECT_FALSE(rtcp_receiver_->RtcpRrTimeout(kRtcpIntervalMs)); | 816 EXPECT_FALSE(rtcp_receiver_->RtcpRrTimeout(kRtcpIntervalMs)); |
817 EXPECT_TRUE(rtcp_receiver_->RtcpRrSequenceNumberTimeout(kRtcpIntervalMs)); | 817 EXPECT_TRUE(rtcp_receiver_->RtcpRrSequenceNumberTimeout(kRtcpIntervalMs)); |
818 | 818 |
819 // Advance clock enough to trigger an RR timeout too. | 819 // Advance clock enough to trigger an RR timeout too. |
820 system_clock_.AdvanceTimeMilliseconds(3 * kRtcpIntervalMs); | 820 system_clock_.AdvanceTimeMilliseconds(3 * kRtcpIntervalMs); |
821 EXPECT_TRUE(rtcp_receiver_->RtcpRrTimeout(kRtcpIntervalMs)); | 821 EXPECT_TRUE(rtcp_receiver_->RtcpRrTimeout(kRtcpIntervalMs)); |
822 | 822 |
823 // We should only get one timeout even though we still haven't received a new | 823 // We should only get one timeout even though we still haven't received a new |
824 // RR. | 824 // RR. |
825 EXPECT_FALSE(rtcp_receiver_->RtcpRrTimeout(kRtcpIntervalMs)); | 825 EXPECT_FALSE(rtcp_receiver_->RtcpRrTimeout(kRtcpIntervalMs)); |
826 EXPECT_FALSE(rtcp_receiver_->RtcpRrSequenceNumberTimeout(kRtcpIntervalMs)); | 826 EXPECT_FALSE(rtcp_receiver_->RtcpRrSequenceNumberTimeout(kRtcpIntervalMs)); |
827 | 827 |
828 // Add a new RR with increase sequence number to reset timers. | 828 // Add a new RR with increase sequence number to reset timers. |
829 rtcp::ReportBlock rb2; | 829 rtcp::ReportBlock rb2; |
830 rb2.To(kSourceSsrc); | 830 rb2.To(kSourceSsrc); |
831 rb2.WithExtHighestSeqNum(kSequenceNumber + 1); | 831 rb2.WithExtHighestSeqNum(kSequenceNumber + 1); |
832 rtcp::ReceiverReport rr2; | 832 rtcp::ReceiverReport rr2; |
833 rr2.From(kSenderSsrc); | 833 rr2.From(kSenderSsrc); |
834 rr2.WithReportBlock(&rb2); | 834 rr2.WithReportBlock(rb2); |
835 rtc::scoped_ptr<rtcp::RawPacket> p2(rr2.Build()); | 835 rtc::scoped_ptr<rtcp::RawPacket> p2(rr2.Build()); |
836 EXPECT_EQ(0, InjectRtcpPacket(p2->Buffer(), p2->Length())); | 836 EXPECT_EQ(0, InjectRtcpPacket(p2->Buffer(), p2->Length())); |
837 EXPECT_FALSE(rtcp_receiver_->RtcpRrTimeout(kRtcpIntervalMs)); | 837 EXPECT_FALSE(rtcp_receiver_->RtcpRrTimeout(kRtcpIntervalMs)); |
838 EXPECT_FALSE(rtcp_receiver_->RtcpRrSequenceNumberTimeout(kRtcpIntervalMs)); | 838 EXPECT_FALSE(rtcp_receiver_->RtcpRrSequenceNumberTimeout(kRtcpIntervalMs)); |
839 | 839 |
840 // Verify we can get a timeout again once we've received new RR. | 840 // Verify we can get a timeout again once we've received new RR. |
841 system_clock_.AdvanceTimeMilliseconds(2 * kRtcpIntervalMs); | 841 system_clock_.AdvanceTimeMilliseconds(2 * kRtcpIntervalMs); |
842 EXPECT_EQ(0, InjectRtcpPacket(p2->Buffer(), p2->Length())); | 842 EXPECT_EQ(0, InjectRtcpPacket(p2->Buffer(), p2->Length())); |
843 system_clock_.AdvanceTimeMilliseconds(kRtcpIntervalMs + 1); | 843 system_clock_.AdvanceTimeMilliseconds(kRtcpIntervalMs + 1); |
844 EXPECT_FALSE(rtcp_receiver_->RtcpRrTimeout(kRtcpIntervalMs)); | 844 EXPECT_FALSE(rtcp_receiver_->RtcpRrTimeout(kRtcpIntervalMs)); |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1001 // First packet, all numbers should just propagate. | 1001 // First packet, all numbers should just propagate. |
1002 rtcp::ReportBlock rb1; | 1002 rtcp::ReportBlock rb1; |
1003 rb1.To(kSourceSsrc); | 1003 rb1.To(kSourceSsrc); |
1004 rb1.WithExtHighestSeqNum(kSequenceNumber); | 1004 rb1.WithExtHighestSeqNum(kSequenceNumber); |
1005 rb1.WithFractionLost(kFractionLoss); | 1005 rb1.WithFractionLost(kFractionLoss); |
1006 rb1.WithCumulativeLost(kCumulativeLoss); | 1006 rb1.WithCumulativeLost(kCumulativeLoss); |
1007 rb1.WithJitter(kJitter); | 1007 rb1.WithJitter(kJitter); |
1008 | 1008 |
1009 rtcp::ReceiverReport rr1; | 1009 rtcp::ReceiverReport rr1; |
1010 rr1.From(kSenderSsrc); | 1010 rr1.From(kSenderSsrc); |
1011 rr1.WithReportBlock(&rb1); | 1011 rr1.WithReportBlock(rb1); |
1012 rtc::scoped_ptr<rtcp::RawPacket> p1(rr1.Build()); | 1012 rtc::scoped_ptr<rtcp::RawPacket> p1(rr1.Build()); |
1013 EXPECT_EQ(0, InjectRtcpPacket(p1->Buffer(), p1->Length())); | 1013 EXPECT_EQ(0, InjectRtcpPacket(p1->Buffer(), p1->Length())); |
1014 EXPECT_TRUE(callback.Matches(kSourceSsrc, kSequenceNumber, kFractionLoss, | 1014 EXPECT_TRUE(callback.Matches(kSourceSsrc, kSequenceNumber, kFractionLoss, |
1015 kCumulativeLoss, kJitter)); | 1015 kCumulativeLoss, kJitter)); |
1016 | 1016 |
1017 rtcp_receiver_->RegisterRtcpStatisticsCallback(NULL); | 1017 rtcp_receiver_->RegisterRtcpStatisticsCallback(NULL); |
1018 | 1018 |
1019 // Add arbitrary numbers, callback should not be called (retain old values). | 1019 // Add arbitrary numbers, callback should not be called (retain old values). |
1020 rtcp::ReportBlock rb2; | 1020 rtcp::ReportBlock rb2; |
1021 rb2.To(kSourceSsrc); | 1021 rb2.To(kSourceSsrc); |
1022 rb2.WithExtHighestSeqNum(kSequenceNumber + 1); | 1022 rb2.WithExtHighestSeqNum(kSequenceNumber + 1); |
1023 rb2.WithFractionLost(42); | 1023 rb2.WithFractionLost(42); |
1024 rb2.WithCumulativeLost(137); | 1024 rb2.WithCumulativeLost(137); |
1025 rb2.WithJitter(4711); | 1025 rb2.WithJitter(4711); |
1026 | 1026 |
1027 rtcp::ReceiverReport rr2; | 1027 rtcp::ReceiverReport rr2; |
1028 rr2.From(kSenderSsrc); | 1028 rr2.From(kSenderSsrc); |
1029 rr2.WithReportBlock(&rb2); | 1029 rr2.WithReportBlock(rb2); |
1030 rtc::scoped_ptr<rtcp::RawPacket> p2(rr2.Build()); | 1030 rtc::scoped_ptr<rtcp::RawPacket> p2(rr2.Build()); |
1031 EXPECT_EQ(0, InjectRtcpPacket(p2->Buffer(), p2->Length())); | 1031 EXPECT_EQ(0, InjectRtcpPacket(p2->Buffer(), p2->Length())); |
1032 EXPECT_TRUE(callback.Matches(kSourceSsrc, kSequenceNumber, kFractionLoss, | 1032 EXPECT_TRUE(callback.Matches(kSourceSsrc, kSequenceNumber, kFractionLoss, |
1033 kCumulativeLoss, kJitter)); | 1033 kCumulativeLoss, kJitter)); |
1034 } | 1034 } |
1035 | 1035 |
1036 } // Anonymous namespace | 1036 } // Anonymous namespace |
1037 | 1037 |
1038 } // namespace webrtc | 1038 } // namespace webrtc |
OLD | NEW |