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

Side by Side 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_PRODUCER_FEC_H_ 11 #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_PRODUCER_FEC_H_
12 #define WEBRTC_MODULES_RTP_RTCP_SOURCE_PRODUCER_FEC_H_ 12 #define WEBRTC_MODULES_RTP_RTCP_SOURCE_PRODUCER_FEC_H_
13 13
14 #include <vector> 14 #include <vector>
15 15
16 #include "webrtc/modules/rtp_rtcp/source/forward_error_correction.h" 16 #include "webrtc/modules/rtp_rtcp/source/forward_error_correction.h"
17 17
18 namespace webrtc { 18 namespace webrtc {
19 19
20 class RedPacket { 20 class RedPacket {
21 public: 21 public:
22 explicit RedPacket(size_t length); 22 explicit RedPacket(size_t length);
23 ~RedPacket(); 23 ~RedPacket();
24 void CreateHeader(const uint8_t* rtp_header, size_t header_length, 24 void CreateHeader(const uint8_t* rtp_header, size_t header_length,
25 int red_pl_type, int pl_type); 25 int red_payload_type, int payload_type);
26 void SetSeqNum(int seq_num); 26 void SetSeqNum(int seq_num);
27 void AssignPayload(const uint8_t* payload, size_t length); 27 void AssignPayload(const uint8_t* payload, size_t length);
28 void ClearMarkerBit(); 28 void ClearMarkerBit();
29 uint8_t* data() const; 29 uint8_t* data() const;
30 size_t length() const; 30 size_t length() const;
31 31
32 private: 32 private:
33 uint8_t* data_; 33 std::unique_ptr<uint8_t[]> data_;
34 size_t length_; 34 size_t length_;
35 size_t header_length_; 35 size_t header_length_;
36 }; 36 };
37 37
38 class ProducerFec { 38 class ProducerFec {
39 public: 39 public:
40 explicit ProducerFec(ForwardErrorCorrection* fec); 40 explicit ProducerFec(ForwardErrorCorrection* fec);
41 ~ProducerFec(); 41 ~ProducerFec();
42 42
43 static std::unique_ptr<RedPacket> BuildRedPacket(const uint8_t* data_buffer,
44 size_t payload_length,
45 size_t rtp_header_length,
46 int red_payload_type);
47
43 void SetFecParameters(const FecProtectionParams* params, 48 void SetFecParameters(const FecProtectionParams* params,
44 int max_fec_frames); 49 int num_first_partition);
45 50
46 // The caller is expected to delete the memory when done. 51 // Adds a media packet to the internal buffer. When enough media packets
47 RedPacket* BuildRedPacket(const uint8_t* data_buffer, 52 // have been added, the FEC packets are generated and stored internally.
48 size_t payload_length, 53 // These FEC packets are then obtained by calling GetFecPacketsAsRed().
49 size_t rtp_header_length,
50 int red_pl_type);
51
52 int AddRtpPacketAndGenerateFec(const uint8_t* data_buffer, 54 int AddRtpPacketAndGenerateFec(const uint8_t* data_buffer,
53 size_t payload_length, 55 size_t payload_length,
54 size_t rtp_header_length); 56 size_t rtp_header_length);
55 57
56 bool ExcessOverheadBelowMax(); 58 // Returns true if the excess overhead (actual - target) for the FEC is below
59 // the amount |kMaxExcessOverhead|. This effects the lower protection level
60 // cases and low number of media packets/frame. The target overhead is given
61 // by |params_.fec_rate|, and is only achievable in the limit of large number
62 // of media packets.
63 bool ExcessOverheadBelowMax() const;
57 64
65 // Returns true if the number of added media packets is at least
66 // |minimum_num_media_packets_|. This condition tries to capture the effect
67 // that, for the same amount of protection/overhead, longer codes
68 // (e.g. (2k,2m) vs (k,m)) are generally more effective at recovering losses.
58 bool MinimumMediaPacketsReached(); 69 bool MinimumMediaPacketsReached();
59 70
71 // Returns true if there are generated FEC packets available.
60 bool FecAvailable() const; 72 bool FecAvailable() const;
73
61 size_t NumAvailableFecPackets() const; 74 size_t NumAvailableFecPackets() const;
62 75
63 // GetFecPackets allocates memory and creates FEC packets, but the caller is 76 // Returns generated FEC packets with RED headers added.
64 // assumed to delete the memory when done with the packets. 77 std::vector<std::unique_ptr<RedPacket>> GetFecPacketsAsRed(
65 std::vector<RedPacket*> GetFecPackets(int red_pl_type, 78 int red_payload_type,
66 int fec_pl_type, 79 int ulpfec_payload_type,
67 uint16_t first_seq_num, 80 uint16_t first_seq_num,
68 size_t rtp_header_length); 81 size_t rtp_header_length);
69 82
70 private: 83 private:
71 void DeletePackets(); 84 void DeleteMediaPackets();
72 int Overhead() const; 85 int Overhead() const;
73 ForwardErrorCorrection* fec_; 86 ForwardErrorCorrection* fec_;
74 ForwardErrorCorrection::PacketList media_packets_fec_; 87 ForwardErrorCorrection::PacketList media_packets_;
75 std::list<ForwardErrorCorrection::Packet*> fec_packets_; 88 std::list<ForwardErrorCorrection::Packet*> generated_fec_packets_;
76 int num_frames_; 89 int num_frames_protected_;
philipel 2016/07/04 15:35:04 num_protected_frames_
brandtr 2016/07/05 11:46:05 Done.
77 int num_first_partition_; 90 int num_important_packets_;
78 int minimum_media_packets_fec_; 91 int minimum_num_media_packets_;
philipel 2016/07/04 15:35:04 min_num_media_packets_
brandtr 2016/07/05 11:46:05 Done.
79 FecProtectionParams params_; 92 FecProtectionParams params_;
80 FecProtectionParams new_params_; 93 FecProtectionParams new_params_;
81 }; 94 };
82 95
83 } // namespace webrtc 96 } // namespace webrtc
84 97
85 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_PRODUCER_FEC_H_ 98 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_PRODUCER_FEC_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698