blob: fc7fe387e744a6c9c2779bc1d64a663d529eb3dd [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
andrew@webrtc.org7fe219f2012-02-01 02:40:37 +00002 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
niklase@google.com470e71d2011-07-07 08:21:25 +00003 *
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 Bonadei92ea95e2017-09-15 06:47:31 +020011#ifndef MODULES_RTP_RTCP_SOURCE_ULPFEC_RECEIVER_IMPL_H_
12#define MODULES_RTP_RTCP_SOURCE_ULPFEC_RECEIVER_IMPL_H_
niklase@google.com470e71d2011-07-07 08:21:25 +000013
Yves Gerey988cc082018-10-23 12:03:01 +020014#include <stddef.h>
15#include <stdint.h>
Jonas Olssona4d87372019-07-05 19:08:33 +020016
Rasmus Brandt78db1582016-09-21 09:19:34 +020017#include <memory>
nissea5f043f2017-09-18 07:58:59 -070018#include <vector>
Rasmus Brandt78db1582016-09-21 09:19:34 +020019
Ilya Nikolaevskiy2d821c32019-06-26 14:39:36 +020020#include "modules/rtp_rtcp/include/rtp_header_extension_map.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020021#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 Titov68173942020-03-11 12:59:07 +010024#include "modules/rtp_rtcp/source/rtp_packet_received.h"
Tomas Gunnarsson1e75df22021-01-19 13:30:23 +010025#include "rtc_base/synchronization/sequence_checker.h"
26#include "rtc_base/system/no_unique_address.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000027
28namespace webrtc {
wu@webrtc.org822fbd82013-08-15 23:38:54 +000029
brandtrd55c3f62016-10-31 04:51:33 -070030class UlpfecReceiverImpl : public UlpfecReceiver {
phoglund@webrtc.org9919ad52013-05-16 15:06:28 +000031 public:
Ilya Nikolaevskiy2d821c32019-06-26 14:39:36 +020032 explicit UlpfecReceiverImpl(uint32_t ssrc,
33 RecoveredPacketReceiver* callback,
34 rtc::ArrayView<const RtpExtension> extensions);
Danil Chapovalov2a5ce2b2018-02-07 09:38:31 +010035 ~UlpfecReceiverImpl() override;
niklase@google.com470e71d2011-07-07 08:21:25 +000036
Artem Titov68173942020-03-11 12:59:07 +010037 bool AddReceivedRedPacket(const RtpPacketReceived& rtp_packet,
Danil Chapovalov04fd2152019-09-20 11:40:12 +020038 uint8_t ulpfec_payload_type) override;
niklase@google.com470e71d2011-07-07 08:21:25 +000039
kjellander@webrtc.org14665ff2015-03-04 12:58:35 +000040 int32_t ProcessReceivedFec() override;
niklase@google.com470e71d2011-07-07 08:21:25 +000041
kjellander@webrtc.org14665ff2015-03-04 12:58:35 +000042 FecPacketCounter GetPacketCounter() const override;
asapersson@webrtc.org0800db72015-01-15 07:40:20 +000043
phoglund@webrtc.org9919ad52013-05-16 15:06:28 +000044 private:
brandtrd726a3f2017-06-29 02:45:35 -070045 const uint32_t ssrc_;
Ilya Nikolaevskiy2d821c32019-06-26 14:39:36 +020046 const RtpHeaderExtensionMap extensions_;
brandtrd726a3f2017-06-29 02:45:35 -070047
Tomas Gunnarsson1e75df22021-01-19 13:30:23 +010048 RTC_NO_UNIQUE_ADDRESS SequenceChecker sequence_checker_;
49 RecoveredPacketReceiver* const recovered_packet_callback_;
50 const std::unique_ptr<ForwardErrorCorrection> fec_;
nissea5f043f2017-09-18 07:58:59 -070051 // 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 Gunnarsson1e75df22021-01-19 13:30:23 +010056 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.com470e71d2011-07-07 08:21:25 +000060};
brandtra2ece732016-10-04 00:00:06 -070061
phoglund@webrtc.org9919ad52013-05-16 15:06:28 +000062} // namespace webrtc
niklase@google.com470e71d2011-07-07 08:21:25 +000063
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020064#endif // MODULES_RTP_RTCP_SOURCE_ULPFEC_RECEIVER_IMPL_H_