Do not send 48 empty FEC packets when there is a large media packet seq. num. gap.
BUG=webrtc:8617 Change-Id: I9c542f5cfd504511165df8f823dd936b4f01f45a Reviewed-on: https://webrtc-review.googlesource.com/30263 Commit-Queue: Rasmus Brandt <brandtr@webrtc.org> Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> Cr-Commit-Position: refs/heads/master@{#21137}
This commit is contained in:
parent
5c3cc41cef
commit
d73ba12a93
@ -165,6 +165,9 @@ int ForwardErrorCorrection::EncodeFec(const PacketList& media_packets,
|
||||
// Adapt packet masks to missing media packets.
|
||||
int num_mask_bits = InsertZerosInPacketMasks(media_packets, num_fec_packets);
|
||||
if (num_mask_bits < 0) {
|
||||
RTC_LOG(LS_INFO) << "Due to sequence number gaps, cannot protect media "
|
||||
"packets with a single block of FEC packets.";
|
||||
fec_packets->clear();
|
||||
return -1;
|
||||
}
|
||||
packet_mask_size_ = internal::PacketMaskSize(num_mask_bits);
|
||||
|
||||
@ -31,6 +31,8 @@ constexpr size_t kTransportOverhead = 28;
|
||||
constexpr uint32_t kMediaSsrc = 83542;
|
||||
constexpr uint32_t kFlexfecSsrc = 43245;
|
||||
|
||||
constexpr size_t kMaxMediaPackets = 48;
|
||||
|
||||
// Deep copies |src| to |dst|, but only keeps every Nth packet.
|
||||
void DeepCopyEveryNthPacket(const ForwardErrorCorrection::PacketList& src,
|
||||
int n,
|
||||
@ -217,6 +219,51 @@ using FecTypes =
|
||||
Types<FlexfecForwardErrorCorrection, UlpfecForwardErrorCorrection>;
|
||||
TYPED_TEST_CASE(RtpFecTest, FecTypes);
|
||||
|
||||
TYPED_TEST(RtpFecTest, WillProtectMediaPacketsWithLargeSequenceNumberGap) {
|
||||
constexpr int kNumImportantPackets = 0;
|
||||
constexpr bool kUseUnequalProtection = false;
|
||||
constexpr int kNumMediaPackets = 2;
|
||||
constexpr uint8_t kProtectionFactor = 127;
|
||||
|
||||
this->media_packets_ =
|
||||
this->media_packet_generator_.ConstructMediaPackets(kNumMediaPackets);
|
||||
|
||||
// Create |kMaxMediaPackets - 1| sequence number difference.
|
||||
ByteWriter<uint16_t>::WriteBigEndian(&this->media_packets_.front()->data[2],
|
||||
1);
|
||||
ByteWriter<uint16_t>::WriteBigEndian(&this->media_packets_.back()->data[2],
|
||||
kMaxMediaPackets);
|
||||
|
||||
EXPECT_EQ(
|
||||
0, this->fec_.EncodeFec(this->media_packets_, kProtectionFactor,
|
||||
kNumImportantPackets, kUseUnequalProtection,
|
||||
kFecMaskBursty, &this->generated_fec_packets_));
|
||||
EXPECT_EQ(1u, this->generated_fec_packets_.size());
|
||||
}
|
||||
|
||||
TYPED_TEST(RtpFecTest,
|
||||
WillNotProtectMediaPacketsWithTooLargeSequenceNumberGap) {
|
||||
constexpr int kNumImportantPackets = 0;
|
||||
constexpr bool kUseUnequalProtection = false;
|
||||
constexpr int kNumMediaPackets = 2;
|
||||
constexpr uint8_t kProtectionFactor = 127;
|
||||
|
||||
this->media_packets_ =
|
||||
this->media_packet_generator_.ConstructMediaPackets(kNumMediaPackets);
|
||||
|
||||
// Create |kMaxMediaPackets| sequence number difference.
|
||||
ByteWriter<uint16_t>::WriteBigEndian(&this->media_packets_.front()->data[2],
|
||||
1);
|
||||
ByteWriter<uint16_t>::WriteBigEndian(&this->media_packets_.back()->data[2],
|
||||
kMaxMediaPackets + 1);
|
||||
|
||||
EXPECT_EQ(
|
||||
-1, this->fec_.EncodeFec(this->media_packets_, kProtectionFactor,
|
||||
kNumImportantPackets, kUseUnequalProtection,
|
||||
kFecMaskBursty, &this->generated_fec_packets_));
|
||||
EXPECT_TRUE(this->generated_fec_packets_.empty());
|
||||
}
|
||||
|
||||
TYPED_TEST(RtpFecTest, FecRecoveryNoLoss) {
|
||||
constexpr int kNumImportantPackets = 0;
|
||||
constexpr bool kUseUnequalProtection = false;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user