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

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

Issue 2449783002: Rename ProducerFec to UlpfecGenerator. (Closed)
Patch Set: Rebase. Created 4 years, 1 month 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 | « webrtc/modules/rtp_rtcp/rtp_rtcp.gypi ('k') | 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
(Empty)
1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_PRODUCER_FEC_H_
12 #define WEBRTC_MODULES_RTP_RTCP_SOURCE_PRODUCER_FEC_H_
13
14 #include <list>
15 #include <memory>
16 #include <vector>
17
18 #include "webrtc/modules/rtp_rtcp/source/forward_error_correction.h"
19
20 namespace webrtc {
21
22 class RedPacket {
23 public:
24 explicit RedPacket(size_t length);
25
26 void CreateHeader(const uint8_t* rtp_header,
27 size_t header_length,
28 int red_payload_type,
29 int payload_type);
30 void SetSeqNum(int seq_num);
31 void AssignPayload(const uint8_t* payload, size_t length);
32 void ClearMarkerBit();
33 uint8_t* data() const;
34 size_t length() const;
35
36 private:
37 std::unique_ptr<uint8_t[]> data_;
38 size_t length_;
39 size_t header_length_;
40 };
41
42 class ProducerFec {
43 public:
44 ProducerFec();
45 ~ProducerFec();
46
47 static std::unique_ptr<RedPacket> BuildRedPacket(const uint8_t* data_buffer,
48 size_t payload_length,
49 size_t rtp_header_length,
50 int red_payload_type);
51
52 void SetFecParameters(const FecProtectionParams* params);
53
54 // Adds a media packet to the internal buffer. When enough media packets
55 // have been added, the FEC packets are generated and stored internally.
56 // These FEC packets are then obtained by calling GetFecPacketsAsRed().
57 int AddRtpPacketAndGenerateFec(const uint8_t* data_buffer,
58 size_t payload_length,
59 size_t rtp_header_length);
60
61 // Returns true if there are generated FEC packets available.
62 bool FecAvailable() const;
63
64 size_t NumAvailableFecPackets() const;
65
66 // Returns the overhead, per packet, for FEC (and possibly RED).
67 size_t MaxPacketOverhead() const;
68
69 // Returns generated FEC packets with RED headers added.
70 std::vector<std::unique_ptr<RedPacket>> GetUlpfecPacketsAsRed(
71 int red_payload_type,
72 int ulpfec_payload_type,
73 uint16_t first_seq_num,
74 size_t rtp_header_length);
75
76 private:
77 // Overhead is defined as relative to the number of media packets, and not
78 // relative to total number of packets. This definition is inherited from the
79 // protection factor produced by video_coding module and how the FEC
80 // generation is implemented.
81 int Overhead() const;
82
83 // Returns true if the excess overhead (actual - target) for the FEC is below
84 // the amount |kMaxExcessOverhead|. This effects the lower protection level
85 // cases and low number of media packets/frame. The target overhead is given
86 // by |params_.fec_rate|, and is only achievable in the limit of large number
87 // of media packets.
88 bool ExcessOverheadBelowMax() const;
89
90 // Returns true if the number of added media packets is at least
91 // |min_num_media_packets_|. This condition tries to capture the effect
92 // that, for the same amount of protection/overhead, longer codes
93 // (e.g. (2k,2m) vs (k,m)) are generally more effective at recovering losses.
94 bool MinimumMediaPacketsReached() const;
95
96 void ResetState();
97
98 std::unique_ptr<ForwardErrorCorrection> fec_;
99 ForwardErrorCorrection::PacketList media_packets_;
100 std::list<ForwardErrorCorrection::Packet*> generated_fec_packets_;
101 int num_protected_frames_;
102 int min_num_media_packets_;
103 FecProtectionParams params_;
104 FecProtectionParams new_params_;
105 };
106
107 } // namespace webrtc
108
109 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_PRODUCER_FEC_H_
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/rtp_rtcp.gypi ('k') | webrtc/modules/rtp_rtcp/source/producer_fec.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698