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

Unified Diff: webrtc/modules/rtp_rtcp/source/producer_fec.h

Issue 2110763002: Style updates to ProducerFec/FecReceiver. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Initial. Created 4 years, 5 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/producer_fec.h
diff --git a/webrtc/modules/rtp_rtcp/source/producer_fec.h b/webrtc/modules/rtp_rtcp/source/producer_fec.h
index e4b5ce5fbf79c460c90e6ab4b19eaf062ee59649..0b04fd95ebee957102126feb5ec5b55afad40c90 100644
--- a/webrtc/modules/rtp_rtcp/source/producer_fec.h
+++ b/webrtc/modules/rtp_rtcp/source/producer_fec.h
@@ -22,7 +22,7 @@ class RedPacket {
explicit RedPacket(size_t length);
~RedPacket();
void CreateHeader(const uint8_t* rtp_header, size_t header_length,
- int red_pl_type, int pl_type);
+ int red_payload_type, int payload_type);
void SetSeqNum(int seq_num);
void AssignPayload(const uint8_t* payload, size_t length);
void ClearMarkerBit();
@@ -30,7 +30,7 @@ class RedPacket {
size_t length() const;
private:
- uint8_t* data_;
+ std::unique_ptr<uint8_t[]> data_;
size_t length_;
size_t header_length_;
};
@@ -40,42 +40,55 @@ class ProducerFec {
explicit ProducerFec(ForwardErrorCorrection* fec);
~ProducerFec();
- void SetFecParameters(const FecProtectionParams* params,
- int max_fec_frames);
+ static std::unique_ptr<RedPacket> BuildRedPacket(const uint8_t* data_buffer,
+ size_t payload_length,
+ size_t rtp_header_length,
+ int red_payload_type);
- // The caller is expected to delete the memory when done.
- RedPacket* BuildRedPacket(const uint8_t* data_buffer,
- size_t payload_length,
- size_t rtp_header_length,
- int red_pl_type);
+ void SetFecParameters(const FecProtectionParams* params,
+ int num_first_partition);
+ // Adds a media packet to the internal buffer. When enough media packets
+ // have been added, the FEC packets are generated and stored internally.
+ // These FEC packets are then obtained by calling GetFecPacketsAsRed().
int AddRtpPacketAndGenerateFec(const uint8_t* data_buffer,
size_t payload_length,
size_t rtp_header_length);
- bool ExcessOverheadBelowMax();
-
+ // Returns true if the excess overhead (actual - target) for the FEC is below
+ // the amount |kMaxExcessOverhead|. This effects the lower protection level
+ // cases and low number of media packets/frame. The target overhead is given
+ // by |params_.fec_rate|, and is only achievable in the limit of large number
+ // of media packets.
+ bool ExcessOverheadBelowMax() const;
+
+ // Returns true if the number of added media packets is at least
+ // |minimum_num_media_packets_|. This condition tries to capture the effect
+ // that, for the same amount of protection/overhead, longer codes
+ // (e.g. (2k,2m) vs (k,m)) are generally more effective at recovering losses.
bool MinimumMediaPacketsReached();
+ // Returns true if there are generated FEC packets available.
bool FecAvailable() const;
+
size_t NumAvailableFecPackets() const;
- // GetFecPackets allocates memory and creates FEC packets, but the caller is
- // assumed to delete the memory when done with the packets.
- std::vector<RedPacket*> GetFecPackets(int red_pl_type,
- int fec_pl_type,
- uint16_t first_seq_num,
- size_t rtp_header_length);
+ // Returns generated FEC packets with RED headers added.
+ std::vector<std::unique_ptr<RedPacket>> GetFecPacketsAsRed(
+ int red_payload_type,
+ int ulpfec_payload_type,
+ uint16_t first_seq_num,
+ size_t rtp_header_length);
private:
- void DeletePackets();
+ void DeleteMediaPackets();
int Overhead() const;
ForwardErrorCorrection* fec_;
- ForwardErrorCorrection::PacketList media_packets_fec_;
- std::list<ForwardErrorCorrection::Packet*> fec_packets_;
- int num_frames_;
- int num_first_partition_;
- int minimum_media_packets_fec_;
+ ForwardErrorCorrection::PacketList media_packets_;
+ std::list<ForwardErrorCorrection::Packet*> generated_fec_packets_;
+ int num_frames_protected_;
philipel 2016/07/04 15:35:04 num_protected_frames_
brandtr 2016/07/05 11:46:05 Done.
+ int num_important_packets_;
+ int minimum_num_media_packets_;
philipel 2016/07/04 15:35:04 min_num_media_packets_
brandtr 2016/07/05 11:46:05 Done.
FecProtectionParams params_;
FecProtectionParams new_params_;
};

Powered by Google App Engine
This is Rietveld 408576698