Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1824)

Unified Diff: webrtc/modules/rtp_rtcp/source/fec_receiver_impl.cc

Issue 2110763002: Style updates to ProducerFec/FecReceiver. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rebase + 'git cl format'. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/rtp_rtcp/source/fec_receiver_impl.cc
diff --git a/webrtc/modules/rtp_rtcp/source/fec_receiver_impl.cc b/webrtc/modules/rtp_rtcp/source/fec_receiver_impl.cc
index 9a1d218cda44c08a097e32b0226a79428115130e..a4a6d2943b1cbbc5f9cea843d46ff95825953c1d 100644
--- a/webrtc/modules/rtp_rtcp/source/fec_receiver_impl.cc
+++ b/webrtc/modules/rtp_rtcp/source/fec_receiver_impl.cc
@@ -18,7 +18,6 @@
#include "webrtc/modules/rtp_rtcp/source/byte_io.h"
#include "webrtc/modules/rtp_rtcp/source/rtp_receiver_video.h"
-// RFC 5109
namespace webrtc {
FecReceiver* FecReceiver::Create(RtpData* callback) {
@@ -26,15 +25,11 @@ FecReceiver* FecReceiver::Create(RtpData* callback) {
}
FecReceiverImpl::FecReceiverImpl(RtpData* callback)
- : recovered_packet_callback_(callback),
- fec_(new ForwardErrorCorrection()) {}
+ : recovered_packet_callback_(callback) {}
FecReceiverImpl::~FecReceiverImpl() {
- received_packet_list_.clear();
- if (fec_ != NULL) {
- fec_->ResetState(&recovered_packet_list_);
- delete fec_;
- }
+ received_packets_.clear();
+ fec_.ResetState(&recovered_packets_);
}
FecPacketCounter FecReceiverImpl::GetPacketCounter() const {
@@ -74,7 +69,8 @@ int32_t FecReceiverImpl::AddReceivedRedPacket(
const RTPHeader& header, const uint8_t* incoming_rtp_packet,
size_t packet_length, uint8_t ulpfec_payload_type) {
rtc::CritScope cs(&crit_sect_);
- uint8_t REDHeaderLength = 1;
+
+ uint8_t red_header_length = 1;
size_t payload_data_length = packet_length - header.headerLength;
if (payload_data_length == 0) {
@@ -82,31 +78,27 @@ int32_t FecReceiverImpl::AddReceivedRedPacket(
return -1;
}
- // Add to list without RED header, aka a virtual RTP packet
- // we remove the RED header
-
+ // Remove RED header of incoming packet and store as a virtual RTP packet.
std::unique_ptr<ForwardErrorCorrection::ReceivedPacket> received_packet(
new ForwardErrorCorrection::ReceivedPacket());
received_packet->pkt = new ForwardErrorCorrection::Packet();
- // get payload type from RED header
- uint8_t payload_type =
- incoming_rtp_packet[header.headerLength] & 0x7f;
-
+ // Get payload type from RED header and sequence number from RTP header.
+ uint8_t payload_type = incoming_rtp_packet[header.headerLength] & 0x7f;
received_packet->is_fec = payload_type == ulpfec_payload_type;
received_packet->seq_num = header.sequenceNumber;
- uint16_t blockLength = 0;
+ uint16_t block_length = 0;
if (incoming_rtp_packet[header.headerLength] & 0x80) {
- // f bit set in RED header
- REDHeaderLength = 4;
- if (payload_data_length < REDHeaderLength + 1u) {
+ // 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) {
LOG(LS_WARNING) << "Corrupt/truncated FEC packet.";
return -1;
}
- uint16_t timestamp_offset =
- (incoming_rtp_packet[header.headerLength + 1]) << 8;
+ uint16_t timestamp_offset = incoming_rtp_packet[header.headerLength + 1]
+ << 8;
timestamp_offset +=
incoming_rtp_packet[header.headerLength + 2];
timestamp_offset = timestamp_offset >> 2;
@@ -115,18 +107,17 @@ int32_t FecReceiverImpl::AddReceivedRedPacket(
return -1;
}
- blockLength =
- (0x03 & incoming_rtp_packet[header.headerLength + 2]) << 8;
- blockLength += (incoming_rtp_packet[header.headerLength + 3]);
+ block_length = (0x3 & incoming_rtp_packet[header.headerLength + 2]) << 8;
+ block_length += incoming_rtp_packet[header.headerLength + 3];
- // check next RED header
+ // Check next RED header block.
if (incoming_rtp_packet[header.headerLength + 4] & 0x80) {
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 (blockLength > payload_data_length - (REDHeaderLength + 1)) {
+ if (block_length > payload_data_length - (red_header_length + 1)) {
LOG(LS_WARNING) << "Block length longer than packet.";
return -1;
}
@@ -135,92 +126,84 @@ int32_t FecReceiverImpl::AddReceivedRedPacket(
std::unique_ptr<ForwardErrorCorrection::ReceivedPacket>
second_received_packet;
- if (blockLength > 0) {
- // handle block length, split into 2 packets
- REDHeaderLength = 5;
+ if (block_length > 0) {
+ // Handle block length, split into two packets.
+ red_header_length = 5;
- // copy the RTP header
+ // Copy RTP header.
memcpy(received_packet->pkt->data, incoming_rtp_packet,
header.headerLength);
- // replace the RED payload type
- received_packet->pkt->data[1] &= 0x80; // reset the payload
- received_packet->pkt->data[1] +=
- payload_type; // set the media payload type
-
- // copy the payload data
- memcpy(
- received_packet->pkt->data + header.headerLength,
- incoming_rtp_packet + header.headerLength + REDHeaderLength,
- blockLength);
+ // Set payload type.
+ received_packet->pkt->data[1] &= 0x80; // Reset RED payload type.
+ received_packet->pkt->data[1] += payload_type; // Set media payload type.
- received_packet->pkt->length = blockLength;
+ // 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.reset(new ForwardErrorCorrection::ReceivedPacket);
+ second_received_packet->pkt = new ForwardErrorCorrection::Packet;
second_received_packet->is_fec = true;
second_received_packet->seq_num = header.sequenceNumber;
++packet_counter_.num_fec_packets;
- // copy the FEC payload data
+ // Copy FEC payload data.
memcpy(second_received_packet->pkt->data,
- incoming_rtp_packet + header.headerLength +
- REDHeaderLength + blockLength,
- payload_data_length - REDHeaderLength - blockLength);
+ 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 - REDHeaderLength - blockLength;
+ payload_data_length - red_header_length - block_length;
} else if (received_packet->is_fec) {
++packet_counter_.num_fec_packets;
// everything behind the RED header
- memcpy(
- received_packet->pkt->data,
- incoming_rtp_packet + header.headerLength + REDHeaderLength,
- payload_data_length - REDHeaderLength);
- received_packet->pkt->length = payload_data_length - REDHeaderLength;
+ memcpy(received_packet->pkt->data,
+ incoming_rtp_packet + header.headerLength + red_header_length,
+ payload_data_length - red_header_length);
+ received_packet->pkt->length = payload_data_length - red_header_length;
received_packet->ssrc =
ByteReader<uint32_t>::ReadBigEndian(&incoming_rtp_packet[8]);
} else {
- // copy the RTP header
+ // Copy RTP header.
memcpy(received_packet->pkt->data, incoming_rtp_packet,
header.headerLength);
- // replace the RED payload type
- received_packet->pkt->data[1] &= 0x80; // reset the payload
- received_packet->pkt->data[1] +=
- payload_type; // set the media payload type
-
- // copy the media payload data
- memcpy(
- received_packet->pkt->data + header.headerLength,
- incoming_rtp_packet + header.headerLength + REDHeaderLength,
- payload_data_length - REDHeaderLength);
+ // 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,
+ payload_data_length - red_header_length);
received_packet->pkt->length =
- header.headerLength + payload_data_length - REDHeaderLength;
+ header.headerLength + payload_data_length - red_header_length;
}
if (received_packet->pkt->length == 0) {
return 0;
}
- received_packet_list_.push_back(std::move(received_packet));
+ received_packets_.push_back(std::move(received_packet));
if (second_received_packet) {
- received_packet_list_.push_back(std::move(second_received_packet));
+ received_packets_.push_back(std::move(second_received_packet));
}
return 0;
}
int32_t FecReceiverImpl::ProcessReceivedFec() {
crit_sect_.Enter();
- if (!received_packet_list_.empty()) {
+ if (!received_packets_.empty()) {
// Send received media packet to VCM.
- if (!received_packet_list_.front()->is_fec) {
- ForwardErrorCorrection::Packet* packet =
- received_packet_list_.front()->pkt;
+ if (!received_packets_.front()->is_fec) {
+ ForwardErrorCorrection::Packet* packet = received_packets_.front()->pkt;
crit_sect_.Leave();
if (!recovered_packet_callback_->OnRecoveredPacket(packet->data,
packet->length)) {
@@ -228,14 +211,14 @@ int32_t FecReceiverImpl::ProcessReceivedFec() {
}
crit_sect_.Enter();
}
- if (fec_->DecodeFec(&received_packet_list_, &recovered_packet_list_) != 0) {
+ if (fec_.DecodeFec(&received_packets_, &recovered_packets_) != 0) {
crit_sect_.Leave();
return -1;
}
- RTC_DCHECK(received_packet_list_.empty());
+ RTC_DCHECK(received_packets_.empty());
}
// Send any recovered media packets to VCM.
- for (const auto& recovered_packet : recovered_packet_list_) {
+ for (const auto& recovered_packet : recovered_packets_) {
if (recovered_packet->returned) {
// Already sent to the VCM and the jitter buffer.
continue;
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/fec_receiver_impl.h ('k') | webrtc/modules/rtp_rtcp/source/fec_receiver_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698