Cleanup Ulpfec receiver: remove 2 blocks RED packets support
WebRTC impelementation never sent more than a single block in RED packets Bug: none Change-Id: Ia39cf803e3c165bf03c09ce734154c04d548c921 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/144024 Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> Reviewed-by: Rasmus Brandt <brandtr@webrtc.org> Commit-Queue: Ilya Nikolaevskiy <ilnik@webrtc.org> Cr-Commit-Position: refs/heads/master@{#28399}
This commit is contained in:

committed by
Commit Bot

parent
a36c591c09
commit
36c8ef625e
@ -113,82 +113,19 @@ int32_t UlpfecReceiverImpl::AddReceivedRedPacket(
|
||||
received_packet->ssrc = header.ssrc;
|
||||
received_packet->seq_num = header.sequenceNumber;
|
||||
|
||||
uint16_t block_length = 0;
|
||||
if (incoming_rtp_packet[header.headerLength] & 0x80) {
|
||||
// f bit set in RED header, i.e. there are more than one RED header blocks.
|
||||
red_header_length = 4;
|
||||
if (payload_data_length < red_header_length + 1u) {
|
||||
RTC_LOG(LS_WARNING) << "Corrupt/truncated FEC packet.";
|
||||
return -1;
|
||||
}
|
||||
|
||||
uint16_t timestamp_offset = incoming_rtp_packet[header.headerLength + 1]
|
||||
<< 8;
|
||||
timestamp_offset += incoming_rtp_packet[header.headerLength + 2];
|
||||
timestamp_offset = timestamp_offset >> 2;
|
||||
if (timestamp_offset != 0) {
|
||||
RTC_LOG(LS_WARNING) << "Corrupt payload found.";
|
||||
return -1;
|
||||
}
|
||||
|
||||
block_length = (0x3 & incoming_rtp_packet[header.headerLength + 2]) << 8;
|
||||
block_length += incoming_rtp_packet[header.headerLength + 3];
|
||||
|
||||
// Check next RED header block.
|
||||
if (incoming_rtp_packet[header.headerLength + 4] & 0x80) {
|
||||
RTC_LOG(LS_WARNING) << "More than 2 blocks in packet not supported.";
|
||||
return -1;
|
||||
}
|
||||
// Check that the packet is long enough to contain data in the following
|
||||
// block.
|
||||
if (block_length > payload_data_length - (red_header_length + 1)) {
|
||||
RTC_LOG(LS_WARNING) << "Block length longer than packet.";
|
||||
return -1;
|
||||
}
|
||||
// WebRTC never generates multiple blocks in a RED packet for FEC.
|
||||
RTC_LOG(LS_WARNING) << "More than 1 block in RED packet is not supported.";
|
||||
return -1;
|
||||
}
|
||||
|
||||
++packet_counter_.num_packets;
|
||||
if (packet_counter_.first_packet_time_ms == -1) {
|
||||
packet_counter_.first_packet_time_ms = rtc::TimeMillis();
|
||||
}
|
||||
|
||||
std::unique_ptr<ForwardErrorCorrection::ReceivedPacket>
|
||||
second_received_packet;
|
||||
if (block_length > 0) {
|
||||
// Handle block length, split into two packets.
|
||||
red_header_length = 5;
|
||||
|
||||
// Copy RTP header.
|
||||
memcpy(received_packet->pkt->data, incoming_rtp_packet,
|
||||
header.headerLength);
|
||||
|
||||
// Set payload type.
|
||||
received_packet->pkt->data[1] &= 0x80; // Reset RED payload type.
|
||||
received_packet->pkt->data[1] += payload_type; // Set media payload type.
|
||||
|
||||
// Copy payload data.
|
||||
memcpy(received_packet->pkt->data + header.headerLength,
|
||||
incoming_rtp_packet + header.headerLength + red_header_length,
|
||||
block_length);
|
||||
received_packet->pkt->length = block_length;
|
||||
|
||||
second_received_packet.reset(new ForwardErrorCorrection::ReceivedPacket);
|
||||
second_received_packet->pkt = new ForwardErrorCorrection::Packet;
|
||||
|
||||
second_received_packet->is_fec = true;
|
||||
second_received_packet->ssrc = header.ssrc;
|
||||
second_received_packet->seq_num = header.sequenceNumber;
|
||||
++packet_counter_.num_fec_packets;
|
||||
|
||||
// Copy FEC payload data.
|
||||
memcpy(second_received_packet->pkt->data,
|
||||
incoming_rtp_packet + header.headerLength + red_header_length +
|
||||
block_length,
|
||||
payload_data_length - red_header_length - block_length);
|
||||
|
||||
second_received_packet->pkt->length =
|
||||
payload_data_length - red_header_length - block_length;
|
||||
|
||||
} else if (received_packet->is_fec) {
|
||||
if (received_packet->is_fec) {
|
||||
++packet_counter_.num_fec_packets;
|
||||
|
||||
// everything behind the RED header
|
||||
@ -221,9 +158,6 @@ int32_t UlpfecReceiverImpl::AddReceivedRedPacket(
|
||||
}
|
||||
|
||||
received_packets_.push_back(std::move(received_packet));
|
||||
if (second_received_packet) {
|
||||
received_packets_.push_back(std::move(second_received_packet));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user