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> |
Jonas Olsson | a4d8737 | 2019-07-05 19:08:33 +0200 | [diff] [blame] | 16 | |
Rasmus Brandt | 78db158 | 2016-09-21 09:19:34 +0200 | [diff] [blame] | 17 | #include <memory> |
nisse | a5f043f | 2017-09-18 07:58:59 -0700 | [diff] [blame] | 18 | #include <vector> |
Rasmus Brandt | 78db158 | 2016-09-21 09:19:34 +0200 | [diff] [blame] | 19 | |
Ilya Nikolaevskiy | 2d821c3 | 2019-06-26 14:39:36 +0200 | [diff] [blame] | 20 | #include "modules/rtp_rtcp/include/rtp_header_extension_map.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 21 | #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" |
| 22 | #include "modules/rtp_rtcp/include/ulpfec_receiver.h" |
| 23 | #include "modules/rtp_rtcp/source/forward_error_correction.h" |
Artem Titov | 6817394 | 2020-03-11 12:59:07 +0100 | [diff] [blame] | 24 | #include "modules/rtp_rtcp/source/rtp_packet_received.h" |
Tomas Gunnarsson | 1e75df2 | 2021-01-19 13:30:23 +0100 | [diff] [blame] | 25 | #include "rtc_base/synchronization/sequence_checker.h" |
| 26 | #include "rtc_base/system/no_unique_address.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 27 | |
| 28 | namespace webrtc { |
wu@webrtc.org | 822fbd8 | 2013-08-15 23:38:54 +0000 | [diff] [blame] | 29 | |
brandtr | d55c3f6 | 2016-10-31 04:51:33 -0700 | [diff] [blame] | 30 | class UlpfecReceiverImpl : public UlpfecReceiver { |
phoglund@webrtc.org | 9919ad5 | 2013-05-16 15:06:28 +0000 | [diff] [blame] | 31 | public: |
Ilya Nikolaevskiy | 2d821c3 | 2019-06-26 14:39:36 +0200 | [diff] [blame] | 32 | explicit UlpfecReceiverImpl(uint32_t ssrc, |
| 33 | RecoveredPacketReceiver* callback, |
| 34 | rtc::ArrayView<const RtpExtension> extensions); |
Danil Chapovalov | 2a5ce2b | 2018-02-07 09:38:31 +0100 | [diff] [blame] | 35 | ~UlpfecReceiverImpl() override; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 36 | |
Artem Titov | 6817394 | 2020-03-11 12:59:07 +0100 | [diff] [blame] | 37 | bool AddReceivedRedPacket(const RtpPacketReceived& rtp_packet, |
Danil Chapovalov | 04fd215 | 2019-09-20 11:40:12 +0200 | [diff] [blame] | 38 | uint8_t ulpfec_payload_type) override; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 39 | |
kjellander@webrtc.org | 14665ff | 2015-03-04 12:58:35 +0000 | [diff] [blame] | 40 | int32_t ProcessReceivedFec() override; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 41 | |
kjellander@webrtc.org | 14665ff | 2015-03-04 12:58:35 +0000 | [diff] [blame] | 42 | FecPacketCounter GetPacketCounter() const override; |
asapersson@webrtc.org | 0800db7 | 2015-01-15 07:40:20 +0000 | [diff] [blame] | 43 | |
phoglund@webrtc.org | 9919ad5 | 2013-05-16 15:06:28 +0000 | [diff] [blame] | 44 | private: |
brandtr | d726a3f | 2017-06-29 02:45:35 -0700 | [diff] [blame] | 45 | const uint32_t ssrc_; |
Ilya Nikolaevskiy | 2d821c3 | 2019-06-26 14:39:36 +0200 | [diff] [blame] | 46 | const RtpHeaderExtensionMap extensions_; |
brandtr | d726a3f | 2017-06-29 02:45:35 -0700 | [diff] [blame] | 47 | |
Tomas Gunnarsson | 1e75df2 | 2021-01-19 13:30:23 +0100 | [diff] [blame] | 48 | RTC_NO_UNIQUE_ADDRESS SequenceChecker sequence_checker_; |
| 49 | RecoveredPacketReceiver* const recovered_packet_callback_; |
| 50 | const std::unique_ptr<ForwardErrorCorrection> fec_; |
nisse | a5f043f | 2017-09-18 07:58:59 -0700 | [diff] [blame] | 51 | // TODO(nisse): The AddReceivedRedPacket method adds one or two packets to |
| 52 | // this list at a time, after which it is emptied by ProcessReceivedFec. It |
| 53 | // will make things simpler to merge AddReceivedRedPacket and |
| 54 | // ProcessReceivedFec into a single method, and we can then delete this list. |
| 55 | std::vector<std::unique_ptr<ForwardErrorCorrection::ReceivedPacket>> |
Tomas Gunnarsson | 1e75df2 | 2021-01-19 13:30:23 +0100 | [diff] [blame] | 56 | received_packets_ RTC_GUARDED_BY(&sequence_checker_); |
| 57 | ForwardErrorCorrection::RecoveredPacketList recovered_packets_ |
| 58 | RTC_GUARDED_BY(&sequence_checker_); |
| 59 | FecPacketCounter packet_counter_ RTC_GUARDED_BY(&sequence_checker_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 60 | }; |
brandtr | a2ece73 | 2016-10-04 00:00:06 -0700 | [diff] [blame] | 61 | |
phoglund@webrtc.org | 9919ad5 | 2013-05-16 15:06:28 +0000 | [diff] [blame] | 62 | } // namespace webrtc |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 63 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 64 | #endif // MODULES_RTP_RTCP_SOURCE_ULPFEC_RECEIVER_IMPL_H_ |