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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 MOCK_METHOD0(AllocateSequenceNumber, uint16_t()); | 119 MOCK_METHOD0(AllocateSequenceNumber, uint16_t()); |
120 }; | 120 }; |
121 | 121 |
122 class MockSendPacketObserver : public SendPacketObserver { | 122 class MockSendPacketObserver : public SendPacketObserver { |
123 public: | 123 public: |
124 MOCK_METHOD3(OnSendPacket, void(uint16_t, int64_t, uint32_t)); | 124 MOCK_METHOD3(OnSendPacket, void(uint16_t, int64_t, uint32_t)); |
125 }; | 125 }; |
126 | 126 |
127 class MockTransportFeedbackObserver : public TransportFeedbackObserver { | 127 class MockTransportFeedbackObserver : public TransportFeedbackObserver { |
128 public: | 128 public: |
129 MOCK_METHOD3(AddPacket, void(uint16_t, size_t, int)); | 129 MOCK_METHOD3(AddPacket, void(uint16_t, size_t, const PacedPacketInfo&)); |
130 MOCK_METHOD1(OnTransportFeedback, void(const rtcp::TransportFeedback&)); | 130 MOCK_METHOD1(OnTransportFeedback, void(const rtcp::TransportFeedback&)); |
131 MOCK_CONST_METHOD0(GetTransportFeedbackVector, std::vector<PacketInfo>()); | 131 MOCK_CONST_METHOD0(GetTransportFeedbackVector, std::vector<PacketInfo>()); |
132 }; | 132 }; |
133 | 133 |
134 class RtpSenderTest : public ::testing::Test { | 134 class RtpSenderTest : public ::testing::Test { |
135 protected: | 135 protected: |
136 RtpSenderTest() | 136 RtpSenderTest() |
137 : fake_clock_(kStartTime), | 137 : fake_clock_(kStartTime), |
138 mock_rtc_event_log_(), | 138 mock_rtc_event_log_(), |
139 mock_paced_sender_(), | 139 mock_paced_sender_(), |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 | 304 |
305 rtp_sender_->SetSendingMediaStatus(false); | 305 rtp_sender_->SetSendingMediaStatus(false); |
306 EXPECT_FALSE(rtp_sender_->AssignSequenceNumber(packet.get())); | 306 EXPECT_FALSE(rtp_sender_->AssignSequenceNumber(packet.get())); |
307 } | 307 } |
308 | 308 |
309 TEST_F(RtpSenderTestWithoutPacer, AssignSequenceNumberMayAllowPadding) { | 309 TEST_F(RtpSenderTestWithoutPacer, AssignSequenceNumberMayAllowPadding) { |
310 constexpr size_t kPaddingSize = 100; | 310 constexpr size_t kPaddingSize = 100; |
311 auto packet = rtp_sender_->AllocatePacket(); | 311 auto packet = rtp_sender_->AllocatePacket(); |
312 ASSERT_TRUE(packet); | 312 ASSERT_TRUE(packet); |
313 | 313 |
314 ASSERT_FALSE(rtp_sender_->TimeToSendPadding(kPaddingSize, -1)); | 314 ASSERT_FALSE(rtp_sender_->TimeToSendPadding(kPaddingSize, PacedPacketInfo())); |
315 packet->SetMarker(false); | 315 packet->SetMarker(false); |
316 ASSERT_TRUE(rtp_sender_->AssignSequenceNumber(packet.get())); | 316 ASSERT_TRUE(rtp_sender_->AssignSequenceNumber(packet.get())); |
317 // Packet without marker bit doesn't allow padding. | 317 // Packet without marker bit doesn't allow padding. |
318 EXPECT_FALSE(rtp_sender_->TimeToSendPadding(kPaddingSize, -1)); | 318 EXPECT_FALSE(rtp_sender_->TimeToSendPadding(kPaddingSize, PacedPacketInfo())); |
319 | 319 |
320 packet->SetMarker(true); | 320 packet->SetMarker(true); |
321 ASSERT_TRUE(rtp_sender_->AssignSequenceNumber(packet.get())); | 321 ASSERT_TRUE(rtp_sender_->AssignSequenceNumber(packet.get())); |
322 // Packet with marker bit allows send padding. | 322 // Packet with marker bit allows send padding. |
323 EXPECT_TRUE(rtp_sender_->TimeToSendPadding(kPaddingSize, -1)); | 323 EXPECT_TRUE(rtp_sender_->TimeToSendPadding(kPaddingSize, PacedPacketInfo())); |
324 } | 324 } |
325 | 325 |
326 TEST_F(RtpSenderTestWithoutPacer, AssignSequenceNumberSetPaddingTimestamps) { | 326 TEST_F(RtpSenderTestWithoutPacer, AssignSequenceNumberSetPaddingTimestamps) { |
327 constexpr size_t kPaddingSize = 100; | 327 constexpr size_t kPaddingSize = 100; |
328 auto packet = rtp_sender_->AllocatePacket(); | 328 auto packet = rtp_sender_->AllocatePacket(); |
329 ASSERT_TRUE(packet); | 329 ASSERT_TRUE(packet); |
330 packet->SetMarker(true); | 330 packet->SetMarker(true); |
331 packet->SetTimestamp(kTimestamp); | 331 packet->SetTimestamp(kTimestamp); |
332 | 332 |
333 ASSERT_TRUE(rtp_sender_->AssignSequenceNumber(packet.get())); | 333 ASSERT_TRUE(rtp_sender_->AssignSequenceNumber(packet.get())); |
334 ASSERT_TRUE(rtp_sender_->TimeToSendPadding(kPaddingSize, -1)); | 334 ASSERT_TRUE(rtp_sender_->TimeToSendPadding(kPaddingSize, PacedPacketInfo())); |
335 | 335 |
336 ASSERT_EQ(1u, transport_.sent_packets_.size()); | 336 ASSERT_EQ(1u, transport_.sent_packets_.size()); |
337 // Verify padding packet timestamp. | 337 // Verify padding packet timestamp. |
338 EXPECT_EQ(kTimestamp, transport_.last_sent_packet().Timestamp()); | 338 EXPECT_EQ(kTimestamp, transport_.last_sent_packet().Timestamp()); |
339 } | 339 } |
340 | 340 |
341 TEST_F(RtpSenderTestWithoutPacer, SendsPacketsWithTransportSequenceNumber) { | 341 TEST_F(RtpSenderTestWithoutPacer, SendsPacketsWithTransportSequenceNumber) { |
342 rtp_sender_.reset(new RTPSender( | 342 rtp_sender_.reset(new RTPSender( |
343 false, &fake_clock_, &transport_, nullptr, nullptr, &seq_num_allocator_, | 343 false, &fake_clock_, &transport_, nullptr, nullptr, &seq_num_allocator_, |
344 &feedback_observer_, nullptr, nullptr, nullptr, &mock_rtc_event_log_, | 344 &feedback_observer_, nullptr, nullptr, nullptr, &mock_rtc_event_log_, |
345 &send_packet_observer_, &retransmission_rate_limiter_, nullptr)); | 345 &send_packet_observer_, &retransmission_rate_limiter_, nullptr)); |
346 rtp_sender_->SetSSRC(kSsrc); | 346 rtp_sender_->SetSSRC(kSsrc); |
347 EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension( | 347 EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension( |
348 kRtpExtensionTransportSequenceNumber, | 348 kRtpExtensionTransportSequenceNumber, |
349 kTransportSequenceNumberExtensionId)); | 349 kTransportSequenceNumberExtensionId)); |
350 | 350 |
351 EXPECT_CALL(seq_num_allocator_, AllocateSequenceNumber()) | 351 EXPECT_CALL(seq_num_allocator_, AllocateSequenceNumber()) |
352 .WillOnce(testing::Return(kTransportSequenceNumber)); | 352 .WillOnce(testing::Return(kTransportSequenceNumber)); |
353 EXPECT_CALL(send_packet_observer_, | 353 EXPECT_CALL(send_packet_observer_, |
354 OnSendPacket(kTransportSequenceNumber, _, _)) | 354 OnSendPacket(kTransportSequenceNumber, _, _)) |
355 .Times(1); | 355 .Times(1); |
356 EXPECT_CALL(feedback_observer_, | 356 EXPECT_CALL( |
357 AddPacket(kTransportSequenceNumber, | 357 feedback_observer_, |
358 sizeof(kPayloadData) + kGenericHeaderLength, | 358 AddPacket(kTransportSequenceNumber, |
359 PacedPacketInfo::kNotAProbe)) | 359 sizeof(kPayloadData) + kGenericHeaderLength, PacedPacketInfo())) |
360 .Times(1); | 360 .Times(1); |
361 | 361 |
362 SendGenericPayload(); | 362 SendGenericPayload(); |
363 | 363 |
364 const auto& packet = transport_.last_sent_packet(); | 364 const auto& packet = transport_.last_sent_packet(); |
365 uint16_t transport_seq_no; | 365 uint16_t transport_seq_no; |
366 ASSERT_TRUE(packet.GetExtension<TransportSequenceNumber>(&transport_seq_no)); | 366 ASSERT_TRUE(packet.GetExtension<TransportSequenceNumber>(&transport_seq_no)); |
367 EXPECT_EQ(kTransportSequenceNumber, transport_seq_no); | 367 EXPECT_EQ(kTransportSequenceNumber, transport_seq_no); |
368 EXPECT_EQ(transport_.last_packet_id_, transport_seq_no); | 368 EXPECT_EQ(transport_.last_packet_id_, transport_seq_no); |
369 } | 369 } |
(...skipping 27 matching lines...) Expand all Loading... |
397 EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension( | 397 EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension( |
398 kRtpExtensionTransportSequenceNumber, | 398 kRtpExtensionTransportSequenceNumber, |
399 kTransportSequenceNumberExtensionId)); | 399 kTransportSequenceNumberExtensionId)); |
400 | 400 |
401 EXPECT_CALL(mock_paced_sender_, InsertPacket(_, kSsrc, kSeqNum, _, _, _)); | 401 EXPECT_CALL(mock_paced_sender_, InsertPacket(_, kSsrc, kSeqNum, _, _, _)); |
402 EXPECT_CALL(seq_num_allocator_, AllocateSequenceNumber()) | 402 EXPECT_CALL(seq_num_allocator_, AllocateSequenceNumber()) |
403 .WillOnce(testing::Return(kTransportSequenceNumber)); | 403 .WillOnce(testing::Return(kTransportSequenceNumber)); |
404 EXPECT_CALL(send_packet_observer_, | 404 EXPECT_CALL(send_packet_observer_, |
405 OnSendPacket(kTransportSequenceNumber, _, _)) | 405 OnSendPacket(kTransportSequenceNumber, _, _)) |
406 .Times(1); | 406 .Times(1); |
407 const int kProbeClusterId = 1; | |
408 EXPECT_CALL( | 407 EXPECT_CALL( |
409 feedback_observer_, | 408 feedback_observer_, |
410 AddPacket(kTransportSequenceNumber, | 409 AddPacket(kTransportSequenceNumber, |
411 sizeof(kPayloadData) + kGenericHeaderLength, kProbeClusterId)) | 410 sizeof(kPayloadData) + kGenericHeaderLength, PacedPacketInfo())) |
412 .Times(1); | 411 .Times(1); |
413 | 412 |
414 SendGenericPayload(); | 413 SendGenericPayload(); |
415 rtp_sender_->TimeToSendPacket( | 414 rtp_sender_->TimeToSendPacket(kSsrc, kSeqNum, |
416 kSsrc, kSeqNum, fake_clock_.TimeInMilliseconds(), false, kProbeClusterId); | 415 fake_clock_.TimeInMilliseconds(), false, |
| 416 PacedPacketInfo()); |
417 | 417 |
418 const auto& packet = transport_.last_sent_packet(); | 418 const auto& packet = transport_.last_sent_packet(); |
419 uint16_t transport_seq_no; | 419 uint16_t transport_seq_no; |
420 EXPECT_TRUE(packet.GetExtension<TransportSequenceNumber>(&transport_seq_no)); | 420 EXPECT_TRUE(packet.GetExtension<TransportSequenceNumber>(&transport_seq_no)); |
421 EXPECT_EQ(kTransportSequenceNumber, transport_seq_no); | 421 EXPECT_EQ(kTransportSequenceNumber, transport_seq_no); |
422 EXPECT_EQ(transport_.last_packet_id_, transport_seq_no); | 422 EXPECT_EQ(transport_.last_packet_id_, transport_seq_no); |
423 } | 423 } |
424 | 424 |
425 TEST_F(RtpSenderTest, TrafficSmoothingWithExtensions) { | 425 TEST_F(RtpSenderTest, TrafficSmoothingWithExtensions) { |
426 EXPECT_CALL(mock_paced_sender_, InsertPacket(RtpPacketSender::kNormalPriority, | 426 EXPECT_CALL(mock_paced_sender_, InsertPacket(RtpPacketSender::kNormalPriority, |
(...skipping 17 matching lines...) Expand all Loading... |
444 EXPECT_TRUE(rtp_sender_->SendToNetwork(std::move(packet), | 444 EXPECT_TRUE(rtp_sender_->SendToNetwork(std::move(packet), |
445 kAllowRetransmission, | 445 kAllowRetransmission, |
446 RtpPacketSender::kNormalPriority)); | 446 RtpPacketSender::kNormalPriority)); |
447 | 447 |
448 EXPECT_EQ(0, transport_.packets_sent()); | 448 EXPECT_EQ(0, transport_.packets_sent()); |
449 | 449 |
450 const int kStoredTimeInMs = 100; | 450 const int kStoredTimeInMs = 100; |
451 fake_clock_.AdvanceTimeMilliseconds(kStoredTimeInMs); | 451 fake_clock_.AdvanceTimeMilliseconds(kStoredTimeInMs); |
452 | 452 |
453 rtp_sender_->TimeToSendPacket(kSsrc, kSeqNum, capture_time_ms, false, | 453 rtp_sender_->TimeToSendPacket(kSsrc, kSeqNum, capture_time_ms, false, |
454 PacedPacketInfo::kNotAProbe); | 454 PacedPacketInfo()); |
455 | 455 |
456 // Process send bucket. Packet should now be sent. | 456 // Process send bucket. Packet should now be sent. |
457 EXPECT_EQ(1, transport_.packets_sent()); | 457 EXPECT_EQ(1, transport_.packets_sent()); |
458 EXPECT_EQ(packet_size, transport_.last_sent_packet().size()); | 458 EXPECT_EQ(packet_size, transport_.last_sent_packet().size()); |
459 | 459 |
460 webrtc::RTPHeader rtp_header; | 460 webrtc::RTPHeader rtp_header; |
461 transport_.last_sent_packet().GetHeader(&rtp_header); | 461 transport_.last_sent_packet().GetHeader(&rtp_header); |
462 | 462 |
463 // Verify transmission time offset. | 463 // Verify transmission time offset. |
464 EXPECT_EQ(kStoredTimeInMs * 90, rtp_header.extension.transmissionTimeOffset); | 464 EXPECT_EQ(kStoredTimeInMs * 90, rtp_header.extension.transmissionTimeOffset); |
(...skipping 30 matching lines...) Expand all Loading... |
495 EXPECT_CALL(mock_paced_sender_, InsertPacket(RtpPacketSender::kNormalPriority, | 495 EXPECT_CALL(mock_paced_sender_, InsertPacket(RtpPacketSender::kNormalPriority, |
496 kSsrc, kSeqNum, _, _, _)); | 496 kSsrc, kSeqNum, _, _, _)); |
497 | 497 |
498 const int kStoredTimeInMs = 100; | 498 const int kStoredTimeInMs = 100; |
499 fake_clock_.AdvanceTimeMilliseconds(kStoredTimeInMs); | 499 fake_clock_.AdvanceTimeMilliseconds(kStoredTimeInMs); |
500 | 500 |
501 EXPECT_EQ(static_cast<int>(packet_size), rtp_sender_->ReSendPacket(kSeqNum)); | 501 EXPECT_EQ(static_cast<int>(packet_size), rtp_sender_->ReSendPacket(kSeqNum)); |
502 EXPECT_EQ(0, transport_.packets_sent()); | 502 EXPECT_EQ(0, transport_.packets_sent()); |
503 | 503 |
504 rtp_sender_->TimeToSendPacket(kSsrc, kSeqNum, capture_time_ms, false, | 504 rtp_sender_->TimeToSendPacket(kSsrc, kSeqNum, capture_time_ms, false, |
505 PacedPacketInfo::kNotAProbe); | 505 PacedPacketInfo()); |
506 | 506 |
507 // Process send bucket. Packet should now be sent. | 507 // Process send bucket. Packet should now be sent. |
508 EXPECT_EQ(1, transport_.packets_sent()); | 508 EXPECT_EQ(1, transport_.packets_sent()); |
509 EXPECT_EQ(packet_size, transport_.last_sent_packet().size()); | 509 EXPECT_EQ(packet_size, transport_.last_sent_packet().size()); |
510 | 510 |
511 webrtc::RTPHeader rtp_header; | 511 webrtc::RTPHeader rtp_header; |
512 transport_.last_sent_packet().GetHeader(&rtp_header); | 512 transport_.last_sent_packet().GetHeader(&rtp_header); |
513 | 513 |
514 // Verify transmission time offset. | 514 // Verify transmission time offset. |
515 EXPECT_EQ(kStoredTimeInMs * 90, rtp_header.extension.transmissionTimeOffset); | 515 EXPECT_EQ(kStoredTimeInMs * 90, rtp_header.extension.transmissionTimeOffset); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
554 EXPECT_TRUE(rtp_sender_->SendToNetwork(std::move(packet), | 554 EXPECT_TRUE(rtp_sender_->SendToNetwork(std::move(packet), |
555 kAllowRetransmission, | 555 kAllowRetransmission, |
556 RtpPacketSender::kNormalPriority)); | 556 RtpPacketSender::kNormalPriority)); |
557 | 557 |
558 int total_packets_sent = 0; | 558 int total_packets_sent = 0; |
559 EXPECT_EQ(total_packets_sent, transport_.packets_sent()); | 559 EXPECT_EQ(total_packets_sent, transport_.packets_sent()); |
560 | 560 |
561 const int kStoredTimeInMs = 100; | 561 const int kStoredTimeInMs = 100; |
562 fake_clock_.AdvanceTimeMilliseconds(kStoredTimeInMs); | 562 fake_clock_.AdvanceTimeMilliseconds(kStoredTimeInMs); |
563 rtp_sender_->TimeToSendPacket(kSsrc, seq_num++, capture_time_ms, false, | 563 rtp_sender_->TimeToSendPacket(kSsrc, seq_num++, capture_time_ms, false, |
564 PacedPacketInfo::kNotAProbe); | 564 PacedPacketInfo()); |
565 // Packet should now be sent. This test doesn't verify the regular video | 565 // Packet should now be sent. This test doesn't verify the regular video |
566 // packet, since it is tested in another test. | 566 // packet, since it is tested in another test. |
567 EXPECT_EQ(++total_packets_sent, transport_.packets_sent()); | 567 EXPECT_EQ(++total_packets_sent, transport_.packets_sent()); |
568 timestamp += 90 * kStoredTimeInMs; | 568 timestamp += 90 * kStoredTimeInMs; |
569 | 569 |
570 // Send padding 4 times, waiting 50 ms between each. | 570 // Send padding 4 times, waiting 50 ms between each. |
571 for (int i = 0; i < 4; ++i) { | 571 for (int i = 0; i < 4; ++i) { |
572 const int kPaddingPeriodMs = 50; | 572 const int kPaddingPeriodMs = 50; |
573 const size_t kPaddingBytes = 100; | 573 const size_t kPaddingBytes = 100; |
574 const size_t kMaxPaddingLength = 224; // Value taken from rtp_sender.cc. | 574 const size_t kMaxPaddingLength = 224; // Value taken from rtp_sender.cc. |
575 // Padding will be forced to full packets. | 575 // Padding will be forced to full packets. |
576 EXPECT_EQ(kMaxPaddingLength, | 576 EXPECT_EQ(kMaxPaddingLength, |
577 rtp_sender_->TimeToSendPadding(kPaddingBytes, | 577 rtp_sender_->TimeToSendPadding(kPaddingBytes, PacedPacketInfo())); |
578 PacedPacketInfo::kNotAProbe)); | |
579 | 578 |
580 // Process send bucket. Padding should now be sent. | 579 // Process send bucket. Padding should now be sent. |
581 EXPECT_EQ(++total_packets_sent, transport_.packets_sent()); | 580 EXPECT_EQ(++total_packets_sent, transport_.packets_sent()); |
582 EXPECT_EQ(kMaxPaddingLength + rtp_header_len, | 581 EXPECT_EQ(kMaxPaddingLength + rtp_header_len, |
583 transport_.last_sent_packet().size()); | 582 transport_.last_sent_packet().size()); |
584 | 583 |
585 transport_.last_sent_packet().GetHeader(&rtp_header); | 584 transport_.last_sent_packet().GetHeader(&rtp_header); |
586 EXPECT_EQ(kMaxPaddingLength, rtp_header.paddingLength); | 585 EXPECT_EQ(kMaxPaddingLength, rtp_header.paddingLength); |
587 | 586 |
588 // Verify sequence number and timestamp. The timestamp should be the same | 587 // Verify sequence number and timestamp. The timestamp should be the same |
(...skipping 17 matching lines...) Expand all Loading... |
606 | 605 |
607 EXPECT_CALL(mock_paced_sender_, InsertPacket(RtpPacketSender::kNormalPriority, | 606 EXPECT_CALL(mock_paced_sender_, InsertPacket(RtpPacketSender::kNormalPriority, |
608 kSsrc, seq_num, _, _, _)); | 607 kSsrc, seq_num, _, _, _)); |
609 | 608 |
610 // Packet should be stored in a send bucket. | 609 // Packet should be stored in a send bucket. |
611 EXPECT_TRUE(rtp_sender_->SendToNetwork(std::move(packet), | 610 EXPECT_TRUE(rtp_sender_->SendToNetwork(std::move(packet), |
612 kAllowRetransmission, | 611 kAllowRetransmission, |
613 RtpPacketSender::kNormalPriority)); | 612 RtpPacketSender::kNormalPriority)); |
614 | 613 |
615 rtp_sender_->TimeToSendPacket(kSsrc, seq_num, capture_time_ms, false, | 614 rtp_sender_->TimeToSendPacket(kSsrc, seq_num, capture_time_ms, false, |
616 PacedPacketInfo::kNotAProbe); | 615 PacedPacketInfo()); |
617 // Process send bucket. | 616 // Process send bucket. |
618 EXPECT_EQ(++total_packets_sent, transport_.packets_sent()); | 617 EXPECT_EQ(++total_packets_sent, transport_.packets_sent()); |
619 EXPECT_EQ(packet_size, transport_.last_sent_packet().size()); | 618 EXPECT_EQ(packet_size, transport_.last_sent_packet().size()); |
620 transport_.last_sent_packet().GetHeader(&rtp_header); | 619 transport_.last_sent_packet().GetHeader(&rtp_header); |
621 | 620 |
622 // Verify sequence number and timestamp. | 621 // Verify sequence number and timestamp. |
623 EXPECT_EQ(seq_num, rtp_header.sequenceNumber); | 622 EXPECT_EQ(seq_num, rtp_header.sequenceNumber); |
624 EXPECT_EQ(timestamp, rtp_header.timestamp); | 623 EXPECT_EQ(timestamp, rtp_header.timestamp); |
625 // Verify transmission time offset. This packet is sent without delay. | 624 // Verify transmission time offset. This packet is sent without delay. |
626 EXPECT_EQ(0, rtp_header.extension.transmissionTimeOffset); | 625 EXPECT_EQ(0, rtp_header.extension.transmissionTimeOffset); |
(...skipping 13 matching lines...) Expand all Loading... |
640 .Times(1); | 639 .Times(1); |
641 EXPECT_CALL(seq_num_allocator_, AllocateSequenceNumber()) | 640 EXPECT_CALL(seq_num_allocator_, AllocateSequenceNumber()) |
642 .WillOnce(testing::Return(kTransportSequenceNumber)); | 641 .WillOnce(testing::Return(kTransportSequenceNumber)); |
643 EXPECT_CALL(mock_paced_sender_, InsertPacket(_, kSsrc, kSeqNum, _, _, _)) | 642 EXPECT_CALL(mock_paced_sender_, InsertPacket(_, kSsrc, kSeqNum, _, _, _)) |
644 .Times(1); | 643 .Times(1); |
645 | 644 |
646 SendGenericPayload(); // Packet passed to pacer. | 645 SendGenericPayload(); // Packet passed to pacer. |
647 const bool kIsRetransmit = false; | 646 const bool kIsRetransmit = false; |
648 rtp_sender_->TimeToSendPacket(kSsrc, kSeqNum, | 647 rtp_sender_->TimeToSendPacket(kSsrc, kSeqNum, |
649 fake_clock_.TimeInMilliseconds(), kIsRetransmit, | 648 fake_clock_.TimeInMilliseconds(), kIsRetransmit, |
650 PacedPacketInfo::kNotAProbe); | 649 PacedPacketInfo()); |
651 EXPECT_EQ(1, transport_.packets_sent()); | 650 EXPECT_EQ(1, transport_.packets_sent()); |
652 } | 651 } |
653 | 652 |
654 TEST_F(RtpSenderTest, OnSendPacketNotUpdatedForRetransmits) { | 653 TEST_F(RtpSenderTest, OnSendPacketNotUpdatedForRetransmits) { |
655 EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension( | 654 EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension( |
656 kRtpExtensionTransportSequenceNumber, | 655 kRtpExtensionTransportSequenceNumber, |
657 kTransportSequenceNumberExtensionId)); | 656 kTransportSequenceNumberExtensionId)); |
658 rtp_sender_->SetStorePacketsStatus(true, 10); | 657 rtp_sender_->SetStorePacketsStatus(true, 10); |
659 | 658 |
660 EXPECT_CALL(send_packet_observer_, OnSendPacket(_, _, _)).Times(0); | 659 EXPECT_CALL(send_packet_observer_, OnSendPacket(_, _, _)).Times(0); |
661 EXPECT_CALL(seq_num_allocator_, AllocateSequenceNumber()) | 660 EXPECT_CALL(seq_num_allocator_, AllocateSequenceNumber()) |
662 .WillOnce(testing::Return(kTransportSequenceNumber)); | 661 .WillOnce(testing::Return(kTransportSequenceNumber)); |
663 EXPECT_CALL(mock_paced_sender_, InsertPacket(_, kSsrc, kSeqNum, _, _, _)) | 662 EXPECT_CALL(mock_paced_sender_, InsertPacket(_, kSsrc, kSeqNum, _, _, _)) |
664 .Times(1); | 663 .Times(1); |
665 | 664 |
666 SendGenericPayload(); // Packet passed to pacer. | 665 SendGenericPayload(); // Packet passed to pacer. |
667 const bool kIsRetransmit = true; | 666 const bool kIsRetransmit = true; |
668 rtp_sender_->TimeToSendPacket(kSsrc, kSeqNum, | 667 rtp_sender_->TimeToSendPacket(kSsrc, kSeqNum, |
669 fake_clock_.TimeInMilliseconds(), kIsRetransmit, | 668 fake_clock_.TimeInMilliseconds(), kIsRetransmit, |
670 PacedPacketInfo::kNotAProbe); | 669 PacedPacketInfo()); |
671 EXPECT_EQ(1, transport_.packets_sent()); | 670 EXPECT_EQ(1, transport_.packets_sent()); |
672 } | 671 } |
673 | 672 |
674 TEST_F(RtpSenderTest, OnSendPacketNotUpdatedWithoutSeqNumAllocator) { | 673 TEST_F(RtpSenderTest, OnSendPacketNotUpdatedWithoutSeqNumAllocator) { |
675 rtp_sender_.reset(new RTPSender( | 674 rtp_sender_.reset(new RTPSender( |
676 false, &fake_clock_, &transport_, &mock_paced_sender_, nullptr, | 675 false, &fake_clock_, &transport_, &mock_paced_sender_, nullptr, |
677 nullptr /* TransportSequenceNumberAllocator */, nullptr, nullptr, nullptr, | 676 nullptr /* TransportSequenceNumberAllocator */, nullptr, nullptr, nullptr, |
678 nullptr, nullptr, &send_packet_observer_, &retransmission_rate_limiter_, | 677 nullptr, nullptr, &send_packet_observer_, &retransmission_rate_limiter_, |
679 nullptr)); | 678 nullptr)); |
680 rtp_sender_->SetSequenceNumber(kSeqNum); | 679 rtp_sender_->SetSequenceNumber(kSeqNum); |
681 rtp_sender_->SetSSRC(kSsrc); | 680 rtp_sender_->SetSSRC(kSsrc); |
682 EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension( | 681 EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension( |
683 kRtpExtensionTransportSequenceNumber, | 682 kRtpExtensionTransportSequenceNumber, |
684 kTransportSequenceNumberExtensionId)); | 683 kTransportSequenceNumberExtensionId)); |
685 rtp_sender_->SetSequenceNumber(kSeqNum); | 684 rtp_sender_->SetSequenceNumber(kSeqNum); |
686 rtp_sender_->SetStorePacketsStatus(true, 10); | 685 rtp_sender_->SetStorePacketsStatus(true, 10); |
687 | 686 |
688 EXPECT_CALL(send_packet_observer_, OnSendPacket(_, _, _)).Times(0); | 687 EXPECT_CALL(send_packet_observer_, OnSendPacket(_, _, _)).Times(0); |
689 EXPECT_CALL(mock_paced_sender_, InsertPacket(_, kSsrc, kSeqNum, _, _, _)) | 688 EXPECT_CALL(mock_paced_sender_, InsertPacket(_, kSsrc, kSeqNum, _, _, _)) |
690 .Times(1); | 689 .Times(1); |
691 | 690 |
692 SendGenericPayload(); // Packet passed to pacer. | 691 SendGenericPayload(); // Packet passed to pacer. |
693 const bool kIsRetransmit = false; | 692 const bool kIsRetransmit = false; |
694 rtp_sender_->TimeToSendPacket(kSsrc, kSeqNum, | 693 rtp_sender_->TimeToSendPacket(kSsrc, kSeqNum, |
695 fake_clock_.TimeInMilliseconds(), kIsRetransmit, | 694 fake_clock_.TimeInMilliseconds(), kIsRetransmit, |
696 PacedPacketInfo::kNotAProbe); | 695 PacedPacketInfo()); |
697 EXPECT_EQ(1, transport_.packets_sent()); | 696 EXPECT_EQ(1, transport_.packets_sent()); |
698 } | 697 } |
699 | 698 |
700 TEST_F(RtpSenderTest, SendRedundantPayloads) { | 699 TEST_F(RtpSenderTest, SendRedundantPayloads) { |
701 MockTransport transport; | 700 MockTransport transport; |
702 rtp_sender_.reset(new RTPSender( | 701 rtp_sender_.reset(new RTPSender( |
703 false, &fake_clock_, &transport, &mock_paced_sender_, nullptr, nullptr, | 702 false, &fake_clock_, &transport, &mock_paced_sender_, nullptr, nullptr, |
704 nullptr, nullptr, nullptr, nullptr, &mock_rtc_event_log_, nullptr, | 703 nullptr, nullptr, nullptr, nullptr, &mock_rtc_event_log_, nullptr, |
705 &retransmission_rate_limiter_, nullptr)); | 704 &retransmission_rate_limiter_, nullptr)); |
706 rtp_sender_->SetSequenceNumber(kSeqNum); | 705 rtp_sender_->SetSequenceNumber(kSeqNum); |
(...skipping 22 matching lines...) Expand all Loading... |
729 EXPECT_CALL(mock_rtc_event_log_, | 728 EXPECT_CALL(mock_rtc_event_log_, |
730 LogRtpHeader(PacketDirection::kOutgoingPacket, _, _, _)) | 729 LogRtpHeader(PacketDirection::kOutgoingPacket, _, _, _)) |
731 .Times(kNumPayloadSizes); | 730 .Times(kNumPayloadSizes); |
732 | 731 |
733 // Send 10 packets of increasing size. | 732 // Send 10 packets of increasing size. |
734 for (size_t i = 0; i < kNumPayloadSizes; ++i) { | 733 for (size_t i = 0; i < kNumPayloadSizes; ++i) { |
735 int64_t capture_time_ms = fake_clock_.TimeInMilliseconds(); | 734 int64_t capture_time_ms = fake_clock_.TimeInMilliseconds(); |
736 EXPECT_CALL(transport, SendRtp(_, _, _)).WillOnce(testing::Return(true)); | 735 EXPECT_CALL(transport, SendRtp(_, _, _)).WillOnce(testing::Return(true)); |
737 SendPacket(capture_time_ms, kPayloadSizes[i]); | 736 SendPacket(capture_time_ms, kPayloadSizes[i]); |
738 rtp_sender_->TimeToSendPacket(kSsrc, seq_num++, capture_time_ms, false, | 737 rtp_sender_->TimeToSendPacket(kSsrc, seq_num++, capture_time_ms, false, |
739 PacedPacketInfo::kNotAProbe); | 738 PacedPacketInfo()); |
740 fake_clock_.AdvanceTimeMilliseconds(33); | 739 fake_clock_.AdvanceTimeMilliseconds(33); |
741 } | 740 } |
742 | 741 |
743 EXPECT_CALL(mock_rtc_event_log_, | 742 EXPECT_CALL(mock_rtc_event_log_, |
744 LogRtpHeader(PacketDirection::kOutgoingPacket, _, _, _)) | 743 LogRtpHeader(PacketDirection::kOutgoingPacket, _, _, _)) |
745 .Times(::testing::AtLeast(4)); | 744 .Times(::testing::AtLeast(4)); |
746 | 745 |
747 // The amount of padding to send it too small to send a payload packet. | 746 // The amount of padding to send it too small to send a payload packet. |
748 EXPECT_CALL(transport, SendRtp(_, kMaxPaddingSize + rtp_header_len, _)) | 747 EXPECT_CALL(transport, SendRtp(_, kMaxPaddingSize + rtp_header_len, _)) |
749 .WillOnce(testing::Return(true)); | 748 .WillOnce(testing::Return(true)); |
750 EXPECT_EQ(kMaxPaddingSize, | 749 EXPECT_EQ(kMaxPaddingSize, |
751 rtp_sender_->TimeToSendPadding(49, PacedPacketInfo::kNotAProbe)); | 750 rtp_sender_->TimeToSendPadding(49, PacedPacketInfo())); |
752 | 751 |
753 EXPECT_CALL(transport, | 752 EXPECT_CALL(transport, |
754 SendRtp(_, kPayloadSizes[0] + rtp_header_len + kRtxHeaderSize, _)) | 753 SendRtp(_, kPayloadSizes[0] + rtp_header_len + kRtxHeaderSize, _)) |
755 .WillOnce(testing::Return(true)); | 754 .WillOnce(testing::Return(true)); |
756 EXPECT_EQ(kPayloadSizes[0], | 755 EXPECT_EQ(kPayloadSizes[0], |
757 rtp_sender_->TimeToSendPadding(500, PacedPacketInfo::kNotAProbe)); | 756 rtp_sender_->TimeToSendPadding(500, PacedPacketInfo())); |
758 | 757 |
759 EXPECT_CALL(transport, SendRtp(_, kPayloadSizes[kNumPayloadSizes - 1] + | 758 EXPECT_CALL(transport, SendRtp(_, kPayloadSizes[kNumPayloadSizes - 1] + |
760 rtp_header_len + kRtxHeaderSize, | 759 rtp_header_len + kRtxHeaderSize, |
761 _)) | 760 _)) |
762 .WillOnce(testing::Return(true)); | 761 .WillOnce(testing::Return(true)); |
763 EXPECT_CALL(transport, SendRtp(_, kMaxPaddingSize + rtp_header_len, _)) | 762 EXPECT_CALL(transport, SendRtp(_, kMaxPaddingSize + rtp_header_len, _)) |
764 .WillOnce(testing::Return(true)); | 763 .WillOnce(testing::Return(true)); |
765 EXPECT_EQ(kPayloadSizes[kNumPayloadSizes - 1] + kMaxPaddingSize, | 764 EXPECT_EQ(kPayloadSizes[kNumPayloadSizes - 1] + kMaxPaddingSize, |
766 rtp_sender_->TimeToSendPadding(999, PacedPacketInfo::kNotAProbe)); | 765 rtp_sender_->TimeToSendPadding(999, PacedPacketInfo())); |
767 } | 766 } |
768 | 767 |
769 TEST_F(RtpSenderTestWithoutPacer, SendGenericVideo) { | 768 TEST_F(RtpSenderTestWithoutPacer, SendGenericVideo) { |
770 char payload_name[RTP_PAYLOAD_NAME_SIZE] = "GENERIC"; | 769 char payload_name[RTP_PAYLOAD_NAME_SIZE] = "GENERIC"; |
771 const uint8_t payload_type = 127; | 770 const uint8_t payload_type = 127; |
772 ASSERT_EQ(0, rtp_sender_->RegisterPayload(payload_name, payload_type, 90000, | 771 ASSERT_EQ(0, rtp_sender_->RegisterPayload(payload_name, payload_type, 90000, |
773 0, 1500)); | 772 0, 1500)); |
774 uint8_t payload[] = {47, 11, 32, 93, 89}; | 773 uint8_t payload[] = {47, 11, 32, 93, 89}; |
775 | 774 |
776 // Send keyframe | 775 // Send keyframe |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
831 InsertPacket(RtpPacketSender::kLowPriority, kMediaSsrc, kSeqNum, | 830 InsertPacket(RtpPacketSender::kLowPriority, kMediaSsrc, kSeqNum, |
832 _, _, false)); | 831 _, _, false)); |
833 uint16_t flexfec_seq_num; | 832 uint16_t flexfec_seq_num; |
834 EXPECT_CALL(mock_paced_sender_, InsertPacket(RtpPacketSender::kLowPriority, | 833 EXPECT_CALL(mock_paced_sender_, InsertPacket(RtpPacketSender::kLowPriority, |
835 kFlexfecSsrc, _, _, _, false)) | 834 kFlexfecSsrc, _, _, _, false)) |
836 .WillOnce(testing::SaveArg<2>(&flexfec_seq_num)); | 835 .WillOnce(testing::SaveArg<2>(&flexfec_seq_num)); |
837 SendGenericPayload(); | 836 SendGenericPayload(); |
838 EXPECT_CALL(mock_rtc_event_log_, | 837 EXPECT_CALL(mock_rtc_event_log_, |
839 LogRtpHeader(PacketDirection::kOutgoingPacket, _, _, _)) | 838 LogRtpHeader(PacketDirection::kOutgoingPacket, _, _, _)) |
840 .Times(2); | 839 .Times(2); |
841 EXPECT_TRUE(rtp_sender_->TimeToSendPacket( | 840 EXPECT_TRUE(rtp_sender_->TimeToSendPacket(kMediaSsrc, kSeqNum, |
842 kMediaSsrc, kSeqNum, fake_clock_.TimeInMilliseconds(), false, 0)); | 841 fake_clock_.TimeInMilliseconds(), |
| 842 false, PacedPacketInfo())); |
843 EXPECT_TRUE(rtp_sender_->TimeToSendPacket(kFlexfecSsrc, flexfec_seq_num, | 843 EXPECT_TRUE(rtp_sender_->TimeToSendPacket(kFlexfecSsrc, flexfec_seq_num, |
844 fake_clock_.TimeInMilliseconds(), | 844 fake_clock_.TimeInMilliseconds(), |
845 false, 0)); | 845 false, PacedPacketInfo())); |
846 ASSERT_EQ(2, transport_.packets_sent()); | 846 ASSERT_EQ(2, transport_.packets_sent()); |
847 const RtpPacketReceived& media_packet = transport_.sent_packets_[0]; | 847 const RtpPacketReceived& media_packet = transport_.sent_packets_[0]; |
848 EXPECT_EQ(kMediaPayloadType, media_packet.PayloadType()); | 848 EXPECT_EQ(kMediaPayloadType, media_packet.PayloadType()); |
849 EXPECT_EQ(kSeqNum, media_packet.SequenceNumber()); | 849 EXPECT_EQ(kSeqNum, media_packet.SequenceNumber()); |
850 EXPECT_EQ(kMediaSsrc, media_packet.Ssrc()); | 850 EXPECT_EQ(kMediaSsrc, media_packet.Ssrc()); |
851 const RtpPacketReceived& flexfec_packet = transport_.sent_packets_[1]; | 851 const RtpPacketReceived& flexfec_packet = transport_.sent_packets_[1]; |
852 EXPECT_EQ(kFlexfecPayloadType, flexfec_packet.PayloadType()); | 852 EXPECT_EQ(kFlexfecPayloadType, flexfec_packet.PayloadType()); |
853 EXPECT_EQ(flexfec_seq_num, flexfec_packet.SequenceNumber()); | 853 EXPECT_EQ(flexfec_seq_num, flexfec_packet.SequenceNumber()); |
854 EXPECT_EQ(kFlexfecSsrc, flexfec_packet.Ssrc()); | 854 EXPECT_EQ(kFlexfecSsrc, flexfec_packet.Ssrc()); |
855 } | 855 } |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1152 expected.transmitted.payload_bytes = 12; | 1152 expected.transmitted.payload_bytes = 12; |
1153 expected.transmitted.header_bytes = 24; | 1153 expected.transmitted.header_bytes = 24; |
1154 expected.transmitted.packets = 2; | 1154 expected.transmitted.packets = 2; |
1155 expected.retransmitted.payload_bytes = 6; | 1155 expected.retransmitted.payload_bytes = 6; |
1156 expected.retransmitted.header_bytes = 12; | 1156 expected.retransmitted.header_bytes = 12; |
1157 expected.retransmitted.padding_bytes = 0; | 1157 expected.retransmitted.padding_bytes = 0; |
1158 expected.retransmitted.packets = 1; | 1158 expected.retransmitted.packets = 1; |
1159 callback.Matches(ssrc, expected); | 1159 callback.Matches(ssrc, expected); |
1160 | 1160 |
1161 // Send padding. | 1161 // Send padding. |
1162 rtp_sender_->TimeToSendPadding(kMaxPaddingSize, PacedPacketInfo::kNotAProbe); | 1162 rtp_sender_->TimeToSendPadding(kMaxPaddingSize, PacedPacketInfo()); |
1163 expected.transmitted.payload_bytes = 12; | 1163 expected.transmitted.payload_bytes = 12; |
1164 expected.transmitted.header_bytes = 36; | 1164 expected.transmitted.header_bytes = 36; |
1165 expected.transmitted.padding_bytes = kMaxPaddingSize; | 1165 expected.transmitted.padding_bytes = kMaxPaddingSize; |
1166 expected.transmitted.packets = 3; | 1166 expected.transmitted.packets = 3; |
1167 callback.Matches(ssrc, expected); | 1167 callback.Matches(ssrc, expected); |
1168 | 1168 |
1169 // Send ULPFEC. | 1169 // Send ULPFEC. |
1170 rtp_sender_->SetUlpfecConfig(kRedPayloadType, kUlpfecPayloadType); | 1170 rtp_sender_->SetUlpfecConfig(kRedPayloadType, kUlpfecPayloadType); |
1171 FecProtectionParams fec_params; | 1171 FecProtectionParams fec_params; |
1172 fec_params.fec_mask_type = kFecMaskRandom; | 1172 fec_params.fec_mask_type = kFecMaskRandom; |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1280 | 1280 |
1281 ASSERT_EQ(0, rtp_sender_->RegisterPayload(kPayloadName, kPayloadType, 90000, | 1281 ASSERT_EQ(0, rtp_sender_->RegisterPayload(kPayloadName, kPayloadType, 90000, |
1282 0, 1500)); | 1282 0, 1500)); |
1283 uint8_t payload[] = {47, 11, 32, 93, 89}; | 1283 uint8_t payload[] = {47, 11, 32, 93, 89}; |
1284 | 1284 |
1285 ASSERT_TRUE(rtp_sender_->SendOutgoingData( | 1285 ASSERT_TRUE(rtp_sender_->SendOutgoingData( |
1286 kVideoFrameKey, kPayloadType, 1234, 4321, payload, | 1286 kVideoFrameKey, kPayloadType, 1234, 4321, payload, |
1287 sizeof(payload), nullptr, nullptr, nullptr)); | 1287 sizeof(payload), nullptr, nullptr, nullptr)); |
1288 | 1288 |
1289 // Will send 2 full-size padding packets. | 1289 // Will send 2 full-size padding packets. |
1290 rtp_sender_->TimeToSendPadding(1, PacedPacketInfo::kNotAProbe); | 1290 rtp_sender_->TimeToSendPadding(1, PacedPacketInfo()); |
1291 rtp_sender_->TimeToSendPadding(1, PacedPacketInfo::kNotAProbe); | 1291 rtp_sender_->TimeToSendPadding(1, PacedPacketInfo()); |
1292 | 1292 |
1293 StreamDataCounters rtp_stats; | 1293 StreamDataCounters rtp_stats; |
1294 StreamDataCounters rtx_stats; | 1294 StreamDataCounters rtx_stats; |
1295 rtp_sender_->GetDataCounters(&rtp_stats, &rtx_stats); | 1295 rtp_sender_->GetDataCounters(&rtp_stats, &rtx_stats); |
1296 | 1296 |
1297 // Payload + 1-byte generic header. | 1297 // Payload + 1-byte generic header. |
1298 EXPECT_GT(rtp_stats.first_packet_time_ms, -1); | 1298 EXPECT_GT(rtp_stats.first_packet_time_ms, -1); |
1299 EXPECT_EQ(rtp_stats.transmitted.payload_bytes, sizeof(payload) + 1); | 1299 EXPECT_EQ(rtp_stats.transmitted.payload_bytes, sizeof(payload) + 1); |
1300 EXPECT_EQ(rtp_stats.transmitted.header_bytes, 12u); | 1300 EXPECT_EQ(rtp_stats.transmitted.header_bytes, 12u); |
1301 EXPECT_EQ(rtp_stats.transmitted.padding_bytes, 0u); | 1301 EXPECT_EQ(rtp_stats.transmitted.padding_bytes, 0u); |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1483 rtp_sender_->SetSSRC(kSsrc); | 1483 rtp_sender_->SetSSRC(kSsrc); |
1484 EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension( | 1484 EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension( |
1485 kRtpExtensionTransportSequenceNumber, | 1485 kRtpExtensionTransportSequenceNumber, |
1486 kTransportSequenceNumberExtensionId)); | 1486 kTransportSequenceNumberExtensionId)); |
1487 EXPECT_CALL(seq_num_allocator_, AllocateSequenceNumber()) | 1487 EXPECT_CALL(seq_num_allocator_, AllocateSequenceNumber()) |
1488 .WillOnce(testing::Return(kTransportSequenceNumber)); | 1488 .WillOnce(testing::Return(kTransportSequenceNumber)); |
1489 EXPECT_CALL(feedback_observer_, | 1489 EXPECT_CALL(feedback_observer_, |
1490 AddPacket(kTransportSequenceNumber, | 1490 AddPacket(kTransportSequenceNumber, |
1491 sizeof(kPayloadData) + kGenericHeaderLength + | 1491 sizeof(kPayloadData) + kGenericHeaderLength + |
1492 kRtpOverheadBytesPerPacket, | 1492 kRtpOverheadBytesPerPacket, |
1493 PacedPacketInfo::kNotAProbe)) | 1493 PacedPacketInfo())) |
1494 .Times(1); | 1494 .Times(1); |
1495 EXPECT_CALL(mock_overhead_observer, | 1495 EXPECT_CALL(mock_overhead_observer, |
1496 OnOverheadChanged(kRtpOverheadBytesPerPacket)) | 1496 OnOverheadChanged(kRtpOverheadBytesPerPacket)) |
1497 .Times(1); | 1497 .Times(1); |
1498 SendGenericPayload(); | 1498 SendGenericPayload(); |
1499 } | 1499 } |
1500 | 1500 |
1501 TEST_F(RtpSenderTest, SendAudioPadding) { | 1501 TEST_F(RtpSenderTest, SendAudioPadding) { |
1502 MockTransport transport; | 1502 MockTransport transport; |
1503 const bool kEnableAudio = true; | 1503 const bool kEnableAudio = true; |
1504 rtp_sender_.reset(new RTPSender( | 1504 rtp_sender_.reset(new RTPSender( |
1505 kEnableAudio, &fake_clock_, &transport, &mock_paced_sender_, nullptr, | 1505 kEnableAudio, &fake_clock_, &transport, &mock_paced_sender_, nullptr, |
1506 nullptr, nullptr, nullptr, nullptr, nullptr, &mock_rtc_event_log_, | 1506 nullptr, nullptr, nullptr, nullptr, nullptr, &mock_rtc_event_log_, |
1507 nullptr, &retransmission_rate_limiter_, nullptr)); | 1507 nullptr, &retransmission_rate_limiter_, nullptr)); |
1508 rtp_sender_->SetSendPayloadType(kPayload); | 1508 rtp_sender_->SetSendPayloadType(kPayload); |
1509 rtp_sender_->SetSequenceNumber(kSeqNum); | 1509 rtp_sender_->SetSequenceNumber(kSeqNum); |
1510 rtp_sender_->SetTimestampOffset(0); | 1510 rtp_sender_->SetTimestampOffset(0); |
1511 rtp_sender_->SetSSRC(kSsrc); | 1511 rtp_sender_->SetSSRC(kSsrc); |
1512 | 1512 |
1513 const size_t kPaddingSize = 59; | 1513 const size_t kPaddingSize = 59; |
1514 EXPECT_CALL(transport, SendRtp(_, kPaddingSize + kRtpHeaderSize, _)) | 1514 EXPECT_CALL(transport, SendRtp(_, kPaddingSize + kRtpHeaderSize, _)) |
1515 .WillOnce(testing::Return(true)); | 1515 .WillOnce(testing::Return(true)); |
1516 EXPECT_EQ(kPaddingSize, | 1516 EXPECT_EQ(kPaddingSize, |
1517 rtp_sender_->TimeToSendPadding(kPaddingSize, | 1517 rtp_sender_->TimeToSendPadding(kPaddingSize, PacedPacketInfo())); |
1518 PacedPacketInfo::kNotAProbe)); | |
1519 | 1518 |
1520 // Requested padding size is too small, will send a larger one. | 1519 // Requested padding size is too small, will send a larger one. |
1521 const size_t kMinPaddingSize = 50; | 1520 const size_t kMinPaddingSize = 50; |
1522 EXPECT_CALL(transport, SendRtp(_, kMinPaddingSize + kRtpHeaderSize, _)) | 1521 EXPECT_CALL(transport, SendRtp(_, kMinPaddingSize + kRtpHeaderSize, _)) |
1523 .WillOnce(testing::Return(true)); | 1522 .WillOnce(testing::Return(true)); |
1524 EXPECT_EQ(kMinPaddingSize, | 1523 EXPECT_EQ( |
1525 rtp_sender_->TimeToSendPadding(kMinPaddingSize - 5, | 1524 kMinPaddingSize, |
1526 PacedPacketInfo::kNotAProbe)); | 1525 rtp_sender_->TimeToSendPadding(kMinPaddingSize - 5, PacedPacketInfo())); |
1527 } | 1526 } |
1528 } // namespace webrtc | 1527 } // namespace webrtc |
OLD | NEW |