stefan@webrtc.org | e0d6fa4 | 2012-03-20 22:10:56 +0000 | [diff] [blame] | 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 | |
pbos@webrtc.org | a048d7c | 2013-05-29 14:27:38 +0000 | [diff] [blame^] | 16 | #include "webrtc/modules/rtp_rtcp/source/forward_error_correction.h" |
stefan@webrtc.org | e0d6fa4 | 2012-03-20 22:10:56 +0000 | [diff] [blame] | 17 | |
| 18 | namespace webrtc { |
| 19 | |
| 20 | struct RtpPacket; |
| 21 | |
| 22 | class RedPacket { |
| 23 | public: |
| 24 | explicit RedPacket(int length); |
| 25 | ~RedPacket(); |
| 26 | void CreateHeader(const uint8_t* rtp_header, int header_length, |
| 27 | int red_pl_type, int pl_type); |
| 28 | void SetSeqNum(int seq_num); |
| 29 | void AssignPayload(const uint8_t* payload, int length); |
| 30 | void ClearMarkerBit(); |
| 31 | uint8_t* data() const; |
| 32 | int length() const; |
| 33 | |
| 34 | private: |
| 35 | uint8_t* data_; |
| 36 | int length_; |
| 37 | int header_length_; |
| 38 | }; |
| 39 | |
| 40 | class ProducerFec { |
| 41 | public: |
| 42 | explicit ProducerFec(ForwardErrorCorrection* fec); |
| 43 | ~ProducerFec(); |
| 44 | |
| 45 | void SetFecParameters(const FecProtectionParams* params, |
| 46 | int max_fec_frames); |
| 47 | |
| 48 | RedPacket* BuildRedPacket(const uint8_t* data_buffer, |
| 49 | int payload_length, |
| 50 | int rtp_header_length, |
| 51 | int red_pl_type); |
| 52 | |
| 53 | int AddRtpPacketAndGenerateFec(const uint8_t* data_buffer, |
| 54 | int payload_length, |
| 55 | int rtp_header_length); |
| 56 | |
marpan@webrtc.org | 747cd87 | 2012-05-22 16:50:00 +0000 | [diff] [blame] | 57 | bool ExcessOverheadBelowMax(); |
| 58 | |
| 59 | bool MinimumMediaPacketsReached(); |
| 60 | |
stefan@webrtc.org | e0d6fa4 | 2012-03-20 22:10:56 +0000 | [diff] [blame] | 61 | bool FecAvailable() const; |
| 62 | |
marpan@webrtc.org | 8639fd9 | 2012-07-30 18:17:02 +0000 | [diff] [blame] | 63 | RedPacket* GetFecPacket(int red_pl_type, |
| 64 | int fec_pl_type, |
| 65 | uint16_t seq_num, |
| 66 | int rtp_header_length); |
stefan@webrtc.org | e0d6fa4 | 2012-03-20 22:10:56 +0000 | [diff] [blame] | 67 | |
| 68 | private: |
| 69 | void DeletePackets(); |
| 70 | int Overhead() const; |
| 71 | ForwardErrorCorrection* fec_; |
| 72 | std::list<ForwardErrorCorrection::Packet*> media_packets_fec_; |
| 73 | std::list<ForwardErrorCorrection::Packet*> fec_packets_; |
| 74 | int num_frames_; |
| 75 | bool incomplete_frame_; |
| 76 | int num_first_partition_; |
marpan@webrtc.org | 747cd87 | 2012-05-22 16:50:00 +0000 | [diff] [blame] | 77 | int minimum_media_packets_fec_; |
stefan@webrtc.org | e0d6fa4 | 2012-03-20 22:10:56 +0000 | [diff] [blame] | 78 | FecProtectionParams params_; |
stefan@webrtc.org | c35f5ce | 2012-04-11 07:42:25 +0000 | [diff] [blame] | 79 | FecProtectionParams new_params_; |
stefan@webrtc.org | e0d6fa4 | 2012-03-20 22:10:56 +0000 | [diff] [blame] | 80 | }; |
| 81 | |
| 82 | } // namespace webrtc |
| 83 | |
| 84 | #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_PRODUCER_FEC_H_ |