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

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

Issue 2553863003: Parse FlexFEC RTP headers in Call and add integration with BWE. (Closed)
Patch Set: Work in progress. Created 4 years 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/flexfec_receiver.cc
diff --git a/webrtc/modules/rtp_rtcp/source/flexfec_receiver.cc b/webrtc/modules/rtp_rtcp/source/flexfec_receiver.cc
index 2c974754915cad4a28188b823bb9f1f949e96d95..5ffba016f68add034bba39105294766832b5698e 100644
--- a/webrtc/modules/rtp_rtcp/source/flexfec_receiver.cc
+++ b/webrtc/modules/rtp_rtcp/source/flexfec_receiver.cc
@@ -14,6 +14,8 @@
#include "webrtc/base/logging.h"
#include "webrtc/base/scoped_ref_ptr.h"
+#include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h"
+#include "webrtc/modules/rtp_rtcp/source/rtp_header_extensions.h"
#include "webrtc/modules/rtp_rtcp/source/rtp_packet_received.h"
namespace webrtc {
@@ -29,15 +31,29 @@ constexpr size_t kMinFlexfecHeaderSize = 20;
// How often to log the recovered packets to the text log.
constexpr int kPacketLogIntervalMs = 10000;
+bool HasBweExtension(const RtpPacketReceived& packet) {
+ if (packet.HasExtension<TransportSequenceNumber>()) {
danilchap 2016/12/06 15:04:30 may be return packet.HasExtension<TransportSequenc
brandtr 2016/12/12 13:51:08 Done.
+ return true;
+ } else if (packet.HasExtension<AbsoluteSendTime>()) {
+ return true;
+ } else if (packet.HasExtension<TransmissionOffset>()) {
+ return true;
+ }
+ return false;
+}
+
} // namespace
-FlexfecReceiver::FlexfecReceiver(uint32_t ssrc,
- uint32_t protected_media_ssrc,
- RecoveredPacketReceiver* callback)
+FlexfecReceiver::FlexfecReceiver(
+ uint32_t ssrc,
+ uint32_t protected_media_ssrc,
+ RecoveredPacketReceiver* recovered_packet_receiver,
+ RemoteBitrateEstimator* remote_bitrate_estimator)
: ssrc_(ssrc),
protected_media_ssrc_(protected_media_ssrc),
erasure_code_(ForwardErrorCorrection::CreateFlexfec()),
- callback_(callback),
+ recovered_packet_receiver_(recovered_packet_receiver),
+ remote_bitrate_estimator_(remote_bitrate_estimator),
clock_(Clock::GetRealTimeClock()),
last_recovered_packet_ms_(-1) {
// It's OK to create this object on a different thread/task queue than
@@ -47,11 +63,10 @@ FlexfecReceiver::FlexfecReceiver(uint32_t ssrc,
FlexfecReceiver::~FlexfecReceiver() = default;
-bool FlexfecReceiver::AddAndProcessReceivedPacket(const uint8_t* packet,
- size_t packet_length) {
+bool FlexfecReceiver::AddAndProcessReceivedPacket(RtpPacketReceived packet) {
RTC_DCHECK(sequence_checker_.CalledSequentially());
- if (!AddReceivedPacket(packet, packet_length)) {
+ if (!AddReceivedPacket(std::move(packet))) {
return false;
}
return ProcessReceivedPackets();
@@ -62,42 +77,43 @@ FecPacketCounter FlexfecReceiver::GetPacketCounter() const {
return packet_counter_;
}
-bool FlexfecReceiver::AddReceivedPacket(const uint8_t* packet,
- size_t packet_length) {
+bool FlexfecReceiver::AddReceivedPacket(RtpPacketReceived packet) {
RTC_DCHECK(sequence_checker_.CalledSequentially());
// RTP packets with a full base header (12 bytes), but without payload,
// could conceivably be useful in the decoding. Therefore we check
// with a strict inequality here.
- if (packet_length < kRtpHeaderSize) {
+ if (packet.size() < kRtpHeaderSize) {
danilchap 2016/12/06 15:04:30 feel free to DCHECK now instead: RtpPacket should
brandtr 2016/12/12 13:51:07 Done.
LOG(LS_WARNING) << "Truncated packet, discarding.";
return false;
}
- // TODO(brandtr): Consider how to handle received FlexFEC packets and
- // the bandwidth estimator.
- RtpPacketReceived parsed_packet;
- if (!parsed_packet.Parse(packet, packet_length)) {
- return false;
- }
-
// Demultiplex based on SSRC, and insert into erasure code decoder.
std::unique_ptr<ReceivedPacket> received_packet(new ReceivedPacket());
- received_packet->seq_num = parsed_packet.SequenceNumber();
- received_packet->ssrc = parsed_packet.Ssrc();
+ received_packet->seq_num = packet.SequenceNumber();
+ received_packet->ssrc = packet.Ssrc();
if (received_packet->ssrc == ssrc_) {
- // This is a FEC packet belonging to this FlexFEC stream.
- if (parsed_packet.payload_size() < kMinFlexfecHeaderSize) {
+ // This is a FlexFEC packet.
+ if (packet.payload_size() < kMinFlexfecHeaderSize) {
LOG(LS_WARNING) << "Truncated FlexFEC packet, discarding.";
return false;
}
received_packet->is_fec = true;
++packet_counter_.num_fec_packets;
+
+ // Notify BWE.
+ if (HasBweExtension(packet)) {
+ RTPHeader header;
+ packet.GetHeader(&header);
+ remote_bitrate_estimator_->IncomingPacket(packet.arrival_time_ms(),
+ packet.payload_size(), header);
+ }
+
// Insert packet payload into erasure code.
// TODO(brandtr): Remove this memcpy when the FEC packet classes
// are using COW buffers internally.
received_packet->pkt = rtc::scoped_refptr<Packet>(new Packet());
- auto payload = parsed_packet.payload();
+ auto payload = packet.payload();
memcpy(received_packet->pkt->data, payload.data(), payload.size());
received_packet->pkt->length = payload.size();
} else {
@@ -107,13 +123,14 @@ bool FlexfecReceiver::AddReceivedPacket(const uint8_t* packet,
return false;
}
received_packet->is_fec = false;
+
// Insert entire packet into erasure code.
// TODO(brandtr): Remove this memcpy too.
received_packet->pkt = rtc::scoped_refptr<Packet>(new Packet());
- memcpy(received_packet->pkt->data, parsed_packet.data(),
- parsed_packet.size());
- received_packet->pkt->length = parsed_packet.size();
+ memcpy(received_packet->pkt->data, packet.data(), packet.size());
+ received_packet->pkt->length = packet.size();
}
+
received_packets_.push_back(std::move(received_packet));
++packet_counter_.num_packets;
@@ -145,8 +162,8 @@ bool FlexfecReceiver::ProcessReceivedPackets() {
continue;
}
++packet_counter_.num_recovered_packets;
- if (!callback_->OnRecoveredPacket(recovered_packet->pkt->data,
- recovered_packet->pkt->length)) {
+ if (!recovered_packet_receiver_->OnRecoveredPacket(
+ recovered_packet->pkt->data, recovered_packet->pkt->length)) {
return false;
}
recovered_packet->returned = true;

Powered by Google App Engine
This is Rietveld 408576698