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

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: Response to feedback. 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
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
42 static std::unique_ptr<RedPacket> BuildRedPacket(const uint8_t* data_buffer,
43 size_t payload_length,
44 size_t rtp_header_length,
45 int red_payload_type);
42 46
43 void SetFecParameters(const FecProtectionParams* params, 47 void SetFecParameters(const FecProtectionParams* params,
44 int max_fec_frames); 48 int num_first_partition);
45 49
46 // The caller is expected to delete the memory when done. 50 // Adds a media packet to the internal buffer. When enough media packets
47 RedPacket* BuildRedPacket(const uint8_t* data_buffer, 51 // have been added, the FEC packets are generated and stored internally.
48 size_t payload_length, 52 // 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, 53 int AddRtpPacketAndGenerateFec(const uint8_t* data_buffer,
53 size_t payload_length, 54 size_t payload_length,
54 size_t rtp_header_length); 55 size_t rtp_header_length);
55 56
56 bool ExcessOverheadBelowMax(); 57 // Returns true if the excess overhead (actual - target) for the FEC is below
58 // the amount |kMaxExcessOverhead|. This effects the lower protection level
59 // cases and low number of media packets/frame. The target overhead is given
60 // by |params_.fec_rate|, and is only achievable in the limit of large number
61 // of media packets.
62 bool ExcessOverheadBelowMax() const;
57 63
64 // Returns true if the number of added media packets is at least
65 // |min_num_media_packets_|. This condition tries to capture the effect
66 // that, for the same amount of protection/overhead, longer codes
67 // (e.g. (2k,2m) vs (k,m)) are generally more effective at recovering losses.
58 bool MinimumMediaPacketsReached(); 68 bool MinimumMediaPacketsReached();
philipel 2016/07/05 13:05:51 bool MinimumMediaPacketsReached() const;
brandtr 2016/07/07 15:00:00 Done.
59 69
70 // Returns true if there are generated FEC packets available.
60 bool FecAvailable() const; 71 bool FecAvailable() const;
72
61 size_t NumAvailableFecPackets() const; 73 size_t NumAvailableFecPackets() const;
62 74
63 // GetFecPackets allocates memory and creates FEC packets, but the caller is 75 // Returns generated FEC packets with RED headers added.
64 // assumed to delete the memory when done with the packets. 76 std::vector<std::unique_ptr<RedPacket>> GetFecPacketsAsRed(
65 std::vector<RedPacket*> GetFecPackets(int red_pl_type, 77 int red_payload_type,
66 int fec_pl_type, 78 int ulpfec_payload_type,
67 uint16_t first_seq_num, 79 uint16_t first_seq_num,
68 size_t rtp_header_length); 80 size_t rtp_header_length);
69 81
70 private: 82 private:
71 void DeletePackets(); 83 void DeleteMediaPackets();
72 int Overhead() const; 84 int Overhead() const;
73 ForwardErrorCorrection* fec_; 85 ForwardErrorCorrection* fec_;
74 ForwardErrorCorrection::PacketList media_packets_fec_; 86 ForwardErrorCorrection::PacketList media_packets_;
75 std::list<ForwardErrorCorrection::Packet*> fec_packets_; 87 std::list<ForwardErrorCorrection::Packet*> generated_fec_packets_;
76 int num_frames_; 88 int num_protected_frames_;
77 int num_first_partition_; 89 int num_important_packets_;
78 int minimum_media_packets_fec_; 90 int min_num_media_packets_;
79 FecProtectionParams params_; 91 FecProtectionParams params_;
80 FecProtectionParams new_params_; 92 FecProtectionParams new_params_;
81 }; 93 };
82 94
83 } // namespace webrtc 95 } // namespace webrtc
84 96
85 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_PRODUCER_FEC_H_ 97 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_PRODUCER_FEC_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698