niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1 | /* |
andrew@webrtc.org | 7fe219f | 2012-02-01 02:40:37 +0000 | [diff] [blame] | 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 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 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #ifndef MODULES_RTP_RTCP_SOURCE_ULPFEC_RECEIVER_IMPL_H_ |
| 12 | #define MODULES_RTP_RTCP_SOURCE_ULPFEC_RECEIVER_IMPL_H_ |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 13 | |
Yves Gerey | 988cc08 | 2018-10-23 12:03:01 +0200 | [diff] [blame] | 14 | #include <stddef.h> |
| 15 | #include <stdint.h> |
Rasmus Brandt | 78db158 | 2016-09-21 09:19:34 +0200 | [diff] [blame] | 16 | #include <memory> |
nisse | a5f043f | 2017-09-18 07:58:59 -0700 | [diff] [blame] | 17 | #include <vector> |
Rasmus Brandt | 78db158 | 2016-09-21 09:19:34 +0200 | [diff] [blame] | 18 | |
Yves Gerey | 988cc08 | 2018-10-23 12:03:01 +0200 | [diff] [blame] | 19 | #include "api/rtp_headers.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 20 | #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" |
| 21 | #include "modules/rtp_rtcp/include/ulpfec_receiver.h" |
| 22 | #include "modules/rtp_rtcp/source/forward_error_correction.h" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame^] | 23 | #include "rtc_base/critical_section.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 24 | |
| 25 | namespace webrtc { |
wu@webrtc.org | 822fbd8 | 2013-08-15 23:38:54 +0000 | [diff] [blame] | 26 | |
brandtr | d55c3f6 | 2016-10-31 04:51:33 -0700 | [diff] [blame] | 27 | class UlpfecReceiverImpl : public UlpfecReceiver { |
phoglund@webrtc.org | 9919ad5 | 2013-05-16 15:06:28 +0000 | [diff] [blame] | 28 | public: |
brandtr | d726a3f | 2017-06-29 02:45:35 -0700 | [diff] [blame] | 29 | explicit UlpfecReceiverImpl(uint32_t ssrc, RecoveredPacketReceiver* callback); |
Danil Chapovalov | 2a5ce2b | 2018-02-07 09:38:31 +0100 | [diff] [blame] | 30 | ~UlpfecReceiverImpl() override; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 31 | |
kjellander@webrtc.org | 14665ff | 2015-03-04 12:58:35 +0000 | [diff] [blame] | 32 | int32_t AddReceivedRedPacket(const RTPHeader& rtp_header, |
| 33 | const uint8_t* incoming_rtp_packet, |
| 34 | size_t packet_length, |
| 35 | uint8_t ulpfec_payload_type) override; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 36 | |
kjellander@webrtc.org | 14665ff | 2015-03-04 12:58:35 +0000 | [diff] [blame] | 37 | int32_t ProcessReceivedFec() override; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 38 | |
kjellander@webrtc.org | 14665ff | 2015-03-04 12:58:35 +0000 | [diff] [blame] | 39 | FecPacketCounter GetPacketCounter() const override; |
asapersson@webrtc.org | 0800db7 | 2015-01-15 07:40:20 +0000 | [diff] [blame] | 40 | |
phoglund@webrtc.org | 9919ad5 | 2013-05-16 15:06:28 +0000 | [diff] [blame] | 41 | private: |
brandtr | d726a3f | 2017-06-29 02:45:35 -0700 | [diff] [blame] | 42 | const uint32_t ssrc_; |
| 43 | |
danilchap | 7c9426c | 2016-04-14 03:05:31 -0700 | [diff] [blame] | 44 | rtc::CriticalSection crit_sect_; |
nisse | 30e8931 | 2017-05-29 08:16:37 -0700 | [diff] [blame] | 45 | RecoveredPacketReceiver* recovered_packet_callback_; |
Rasmus Brandt | 78db158 | 2016-09-21 09:19:34 +0200 | [diff] [blame] | 46 | std::unique_ptr<ForwardErrorCorrection> fec_; |
nisse | a5f043f | 2017-09-18 07:58:59 -0700 | [diff] [blame] | 47 | // TODO(nisse): The AddReceivedRedPacket method adds one or two packets to |
| 48 | // this list at a time, after which it is emptied by ProcessReceivedFec. It |
| 49 | // will make things simpler to merge AddReceivedRedPacket and |
| 50 | // ProcessReceivedFec into a single method, and we can then delete this list. |
| 51 | std::vector<std::unique_ptr<ForwardErrorCorrection::ReceivedPacket>> |
| 52 | received_packets_; |
brandtr | 74811e5 | 2016-08-10 00:51:50 -0700 | [diff] [blame] | 53 | ForwardErrorCorrection::RecoveredPacketList recovered_packets_; |
asapersson@webrtc.org | 0800db7 | 2015-01-15 07:40:20 +0000 | [diff] [blame] | 54 | FecPacketCounter packet_counter_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 55 | }; |
brandtr | a2ece73 | 2016-10-04 00:00:06 -0700 | [diff] [blame] | 56 | |
phoglund@webrtc.org | 9919ad5 | 2013-05-16 15:06:28 +0000 | [diff] [blame] | 57 | } // namespace webrtc |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 58 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 59 | #endif // MODULES_RTP_RTCP_SOURCE_ULPFEC_RECEIVER_IMPL_H_ |