| 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 873 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 884 SendGenericPayload(); | 884 SendGenericPayload(); |
| 885 ASSERT_EQ(2, transport_.packets_sent()); | 885 ASSERT_EQ(2, transport_.packets_sent()); |
| 886 const RtpPacketReceived& media_packet = transport_.sent_packets_[0]; | 886 const RtpPacketReceived& media_packet = transport_.sent_packets_[0]; |
| 887 EXPECT_EQ(kMediaPayloadType, media_packet.PayloadType()); | 887 EXPECT_EQ(kMediaPayloadType, media_packet.PayloadType()); |
| 888 EXPECT_EQ(kMediaSsrc, media_packet.Ssrc()); | 888 EXPECT_EQ(kMediaSsrc, media_packet.Ssrc()); |
| 889 const RtpPacketReceived& flexfec_packet = transport_.sent_packets_[1]; | 889 const RtpPacketReceived& flexfec_packet = transport_.sent_packets_[1]; |
| 890 EXPECT_EQ(kFlexfecPayloadType, flexfec_packet.PayloadType()); | 890 EXPECT_EQ(kFlexfecPayloadType, flexfec_packet.PayloadType()); |
| 891 EXPECT_EQ(kFlexfecSsrc, flexfec_packet.Ssrc()); | 891 EXPECT_EQ(kFlexfecSsrc, flexfec_packet.Ssrc()); |
| 892 } | 892 } |
| 893 | 893 |
| 894 TEST_F(RtpSenderTest, FecOverheadRate) { |
| 895 constexpr int kMediaPayloadType = 127; |
| 896 constexpr int kFlexfecPayloadType = 118; |
| 897 constexpr uint32_t kMediaSsrc = 1234; |
| 898 constexpr uint32_t kFlexfecSsrc = 5678; |
| 899 const std::vector<RtpExtension> kNoRtpExtensions; |
| 900 FlexfecSender flexfec_sender(kFlexfecPayloadType, kFlexfecSsrc, kMediaSsrc, |
| 901 kNoRtpExtensions, &fake_clock_); |
| 902 |
| 903 // Reset |rtp_sender_| to use FlexFEC. |
| 904 rtp_sender_.reset(new RTPSender( |
| 905 false, &fake_clock_, &transport_, &mock_paced_sender_, &flexfec_sender, |
| 906 &seq_num_allocator_, nullptr, nullptr, nullptr, nullptr, |
| 907 &mock_rtc_event_log_, &send_packet_observer_, |
| 908 &retransmission_rate_limiter_, nullptr)); |
| 909 rtp_sender_->SetSSRC(kMediaSsrc); |
| 910 rtp_sender_->SetSequenceNumber(kSeqNum); |
| 911 rtp_sender_->SetSendPayloadType(kMediaPayloadType); |
| 912 |
| 913 // Parameters selected to generate a single FEC packet per media packet. |
| 914 FecProtectionParams params; |
| 915 params.fec_rate = 15; |
| 916 params.max_fec_frames = 1; |
| 917 params.fec_mask_type = kFecMaskRandom; |
| 918 rtp_sender_->SetFecParameters(params, params); |
| 919 |
| 920 constexpr size_t kNumMediaPackets = 10; |
| 921 constexpr size_t kNumFecPackets = kNumMediaPackets; |
| 922 constexpr int64_t kTimeBetweenPacketsMs = 10; |
| 923 EXPECT_CALL(mock_paced_sender_, InsertPacket(_, _, _, _, _, false)) |
| 924 .Times(kNumMediaPackets + kNumFecPackets); |
| 925 for (size_t i = 0; i < kNumMediaPackets; ++i) { |
| 926 SendGenericPayload(); |
| 927 fake_clock_.AdvanceTimeMilliseconds(kTimeBetweenPacketsMs); |
| 928 } |
| 929 constexpr size_t kRtpHeaderLength = 12; |
| 930 constexpr size_t kFlexfecHeaderLength = 20; |
| 931 constexpr size_t kGenericCodecHeaderLength = 1; |
| 932 constexpr size_t kPayloadLength = sizeof(kPayloadData); |
| 933 constexpr size_t kPacketLength = kRtpHeaderLength + kFlexfecHeaderLength + |
| 934 kGenericCodecHeaderLength + kPayloadLength; |
| 935 EXPECT_NEAR(kNumFecPackets * kPacketLength * 8 / |
| 936 (kNumFecPackets * kTimeBetweenPacketsMs / 1000.0f), |
| 937 rtp_sender_->FecOverheadRate(), 500); |
| 938 } |
| 939 |
| 894 TEST_F(RtpSenderTest, FrameCountCallbacks) { | 940 TEST_F(RtpSenderTest, FrameCountCallbacks) { |
| 895 class TestCallback : public FrameCountObserver { | 941 class TestCallback : public FrameCountObserver { |
| 896 public: | 942 public: |
| 897 TestCallback() : FrameCountObserver(), num_calls_(0), ssrc_(0) {} | 943 TestCallback() : FrameCountObserver(), num_calls_(0), ssrc_(0) {} |
| 898 virtual ~TestCallback() {} | 944 virtual ~TestCallback() {} |
| 899 | 945 |
| 900 void FrameCountUpdated(const FrameCounts& frame_counts, | 946 void FrameCountUpdated(const FrameCounts& frame_counts, |
| 901 uint32_t ssrc) override { | 947 uint32_t ssrc) override { |
| 902 ++num_calls_; | 948 ++num_calls_; |
| 903 ssrc_ = ssrc; | 949 ssrc_ = ssrc; |
| (...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1439 kRtpOverheadBytesPerPacket, | 1485 kRtpOverheadBytesPerPacket, |
| 1440 PacketInfo::kNotAProbe)) | 1486 PacketInfo::kNotAProbe)) |
| 1441 .Times(1); | 1487 .Times(1); |
| 1442 EXPECT_CALL(mock_overhead_observer, | 1488 EXPECT_CALL(mock_overhead_observer, |
| 1443 OnOverheadChanged(kRtpOverheadBytesPerPacket)) | 1489 OnOverheadChanged(kRtpOverheadBytesPerPacket)) |
| 1444 .Times(1); | 1490 .Times(1); |
| 1445 SendGenericPayload(); | 1491 SendGenericPayload(); |
| 1446 } | 1492 } |
| 1447 | 1493 |
| 1448 } // namespace webrtc | 1494 } // namespace webrtc |
| OLD | NEW |