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

Side by Side Diff: webrtc/modules/rtp_rtcp/source/producer_fec.h

Issue 2305793003: Simplify public interface of ProducerFec. (Closed)
Patch Set: Fix fuzzer. Created 4 years, 2 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
« no previous file with comments | « no previous file | webrtc/modules/rtp_rtcp/source/producer_fec.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 void SetFecParameters(const FecProtectionParams* params, 52 void SetFecParameters(const FecProtectionParams* params,
53 int num_first_partition); 53 int num_first_partition);
54 54
55 // Adds a media packet to the internal buffer. When enough media packets 55 // Adds a media packet to the internal buffer. When enough media packets
56 // have been added, the FEC packets are generated and stored internally. 56 // have been added, the FEC packets are generated and stored internally.
57 // These FEC packets are then obtained by calling GetFecPacketsAsRed(). 57 // These FEC packets are then obtained by calling GetFecPacketsAsRed().
58 int AddRtpPacketAndGenerateFec(const uint8_t* data_buffer, 58 int AddRtpPacketAndGenerateFec(const uint8_t* data_buffer,
59 size_t payload_length, 59 size_t payload_length,
60 size_t rtp_header_length); 60 size_t rtp_header_length);
61 61
62 // Returns true if there are generated FEC packets available.
63 bool FecAvailable() const;
64
65 size_t NumAvailableFecPackets() const;
66
67 // Returns the overhead, per packet, for FEC (and possibly RED).
68 size_t MaxPacketOverhead() const;
69
70 // Returns generated FEC packets with RED headers added.
71 std::vector<std::unique_ptr<RedPacket>> GetUlpfecPacketsAsRed(
72 int red_payload_type,
73 int ulpfec_payload_type,
74 uint16_t first_seq_num,
75 size_t rtp_header_length);
76
77 private:
78 // Overhead is defined as relative to the number of media packets, and not
79 // relative to total number of packets. This definition is inherited from the
80 // protection factor produced by video_coding module and how the FEC
81 // generation is implemented.
82 int Overhead() const;
83
62 // Returns true if the excess overhead (actual - target) for the FEC is below 84 // Returns true if the excess overhead (actual - target) for the FEC is below
63 // the amount |kMaxExcessOverhead|. This effects the lower protection level 85 // the amount |kMaxExcessOverhead|. This effects the lower protection level
64 // cases and low number of media packets/frame. The target overhead is given 86 // cases and low number of media packets/frame. The target overhead is given
65 // by |params_.fec_rate|, and is only achievable in the limit of large number 87 // by |params_.fec_rate|, and is only achievable in the limit of large number
66 // of media packets. 88 // of media packets.
67 bool ExcessOverheadBelowMax() const; 89 bool ExcessOverheadBelowMax() const;
68 90
69 // Returns true if the number of added media packets is at least 91 // Returns true if the number of added media packets is at least
70 // |min_num_media_packets_|. This condition tries to capture the effect 92 // |min_num_media_packets_|. This condition tries to capture the effect
71 // that, for the same amount of protection/overhead, longer codes 93 // that, for the same amount of protection/overhead, longer codes
72 // (e.g. (2k,2m) vs (k,m)) are generally more effective at recovering losses. 94 // (e.g. (2k,2m) vs (k,m)) are generally more effective at recovering losses.
73 bool MinimumMediaPacketsReached() const; 95 bool MinimumMediaPacketsReached() const;
74 96
75 // Returns true if there are generated FEC packets available. 97 void ResetState();
76 bool FecAvailable() const;
77 98
78 size_t NumAvailableFecPackets() const;
79
80 size_t MaxPacketOverhead() const;
81
82 // Returns generated FEC packets with RED headers added.
83 std::vector<std::unique_ptr<RedPacket>> GetFecPacketsAsRed(
84 int red_payload_type,
85 int ulpfec_payload_type,
86 uint16_t first_seq_num,
87 size_t rtp_header_length);
88
89 private:
90 void DeleteMediaPackets();
91 int Overhead() const;
92 std::unique_ptr<ForwardErrorCorrection> fec_; 99 std::unique_ptr<ForwardErrorCorrection> fec_;
93 ForwardErrorCorrection::PacketList media_packets_; 100 ForwardErrorCorrection::PacketList media_packets_;
94 std::list<ForwardErrorCorrection::Packet*> generated_fec_packets_; 101 std::list<ForwardErrorCorrection::Packet*> generated_fec_packets_;
95 int num_protected_frames_; 102 int num_protected_frames_;
96 int num_important_packets_; 103 int num_important_packets_;
97 int min_num_media_packets_; 104 int min_num_media_packets_;
98 FecProtectionParams params_; 105 FecProtectionParams params_;
99 FecProtectionParams new_params_; 106 FecProtectionParams new_params_;
100 }; 107 };
101 108
102 } // namespace webrtc 109 } // namespace webrtc
103 110
104 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_PRODUCER_FEC_H_ 111 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_PRODUCER_FEC_H_
OLDNEW
« no previous file with comments | « no previous file | webrtc/modules/rtp_rtcp/source/producer_fec.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698