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

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

Issue 2441613002: Add FlexfecSender. (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
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_ULPFEC_GENERATOR_H_ 11 #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_ULPFEC_GENERATOR_H_
12 #define WEBRTC_MODULES_RTP_RTCP_SOURCE_ULPFEC_GENERATOR_H_ 12 #define WEBRTC_MODULES_RTP_RTCP_SOURCE_ULPFEC_GENERATOR_H_
13 13
14 #include <list> 14 #include <list>
15 #include <memory> 15 #include <memory>
16 #include <vector> 16 #include <vector>
17 17
18 #include "webrtc/modules/rtp_rtcp/source/forward_error_correction.h" 18 #include "webrtc/modules/rtp_rtcp/source/forward_error_correction.h"
19 19
20 namespace webrtc { 20 namespace webrtc {
21 21
22 class FlexfecSenderImpl;
23
22 class RedPacket { 24 class RedPacket {
23 public: 25 public:
24 explicit RedPacket(size_t length); 26 explicit RedPacket(size_t length);
25 27
26 void CreateHeader(const uint8_t* rtp_header, 28 void CreateHeader(const uint8_t* rtp_header,
27 size_t header_length, 29 size_t header_length,
28 int red_payload_type, 30 int red_payload_type,
29 int payload_type); 31 int payload_type);
30 void SetSeqNum(int seq_num); 32 void SetSeqNum(int seq_num);
31 void AssignPayload(const uint8_t* payload, size_t length); 33 void AssignPayload(const uint8_t* payload, size_t length);
32 void ClearMarkerBit(); 34 void ClearMarkerBit();
33 uint8_t* data() const; 35 uint8_t* data() const;
34 size_t length() const; 36 size_t length() const;
35 37
36 private: 38 private:
37 std::unique_ptr<uint8_t[]> data_; 39 std::unique_ptr<uint8_t[]> data_;
38 size_t length_; 40 size_t length_;
39 size_t header_length_; 41 size_t header_length_;
40 }; 42 };
41 43
42 class UlpfecGenerator { 44 class UlpfecGenerator {
45 friend class FlexfecSender;
46
43 public: 47 public:
44 UlpfecGenerator(); 48 UlpfecGenerator();
45 ~UlpfecGenerator(); 49 ~UlpfecGenerator();
46 50
47 static std::unique_ptr<RedPacket> BuildRedPacket(const uint8_t* data_buffer, 51 static std::unique_ptr<RedPacket> BuildRedPacket(const uint8_t* data_buffer,
48 size_t payload_length, 52 size_t payload_length,
49 size_t rtp_header_length, 53 size_t rtp_header_length,
50 int red_payload_type); 54 int red_payload_type);
51 55
52 void SetFecParameters(const FecProtectionParams* params); 56 void SetFecParameters(const FecProtectionParams* params);
(...skipping 14 matching lines...) Expand all
67 size_t MaxPacketOverhead() const; 71 size_t MaxPacketOverhead() const;
68 72
69 // Returns generated FEC packets with RED headers added. 73 // Returns generated FEC packets with RED headers added.
70 std::vector<std::unique_ptr<RedPacket>> GetUlpfecPacketsAsRed( 74 std::vector<std::unique_ptr<RedPacket>> GetUlpfecPacketsAsRed(
71 int red_payload_type, 75 int red_payload_type,
72 int ulpfec_payload_type, 76 int ulpfec_payload_type,
73 uint16_t first_seq_num, 77 uint16_t first_seq_num,
74 size_t rtp_header_length); 78 size_t rtp_header_length);
75 79
76 private: 80 private:
81 explicit UlpfecGenerator(std::unique_ptr<ForwardErrorCorrection> fec);
82
77 // Overhead is defined as relative to the number of media packets, and not 83 // 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 84 // relative to total number of packets. This definition is inherited from the
79 // protection factor produced by video_coding module and how the FEC 85 // protection factor produced by video_coding module and how the FEC
80 // generation is implemented. 86 // generation is implemented.
81 int Overhead() const; 87 int Overhead() const;
82 88
83 // Returns true if the excess overhead (actual - target) for the FEC is below 89 // Returns true if the excess overhead (actual - target) for the FEC is below
84 // the amount |kMaxExcessOverhead|. This effects the lower protection level 90 // the amount |kMaxExcessOverhead|. This effects the lower protection level
85 // cases and low number of media packets/frame. The target overhead is given 91 // 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 92 // by |params_.fec_rate|, and is only achievable in the limit of large number
(...skipping 13 matching lines...) Expand all
100 std::list<ForwardErrorCorrection::Packet*> generated_fec_packets_; 106 std::list<ForwardErrorCorrection::Packet*> generated_fec_packets_;
101 int num_protected_frames_; 107 int num_protected_frames_;
102 int min_num_media_packets_; 108 int min_num_media_packets_;
103 FecProtectionParams params_; 109 FecProtectionParams params_;
104 FecProtectionParams new_params_; 110 FecProtectionParams new_params_;
105 }; 111 };
106 112
107 } // namespace webrtc 113 } // namespace webrtc
108 114
109 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_ULPFEC_GENERATOR_H_ 115 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_ULPFEC_GENERATOR_H_
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/flexfec_sender_unittest.cc ('k') | webrtc/modules/rtp_rtcp/source/ulpfec_generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698