2011-07-07 08:21:25 +00:00
|
|
|
/*
|
2012-02-01 02:40:37 +00:00
|
|
|
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
2011-07-07 08:21:25 +00:00
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
2022-08-09 17:50:45 +02:00
|
|
|
#ifndef MODULES_RTP_RTCP_SOURCE_ULPFEC_RECEIVER_H_
|
|
|
|
|
#define MODULES_RTP_RTCP_SOURCE_ULPFEC_RECEIVER_H_
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2018-10-23 12:03:01 +02:00
|
|
|
#include <stddef.h>
|
|
|
|
|
#include <stdint.h>
|
2019-07-05 19:08:33 +02:00
|
|
|
|
2016-09-21 09:19:34 +02:00
|
|
|
#include <memory>
|
2017-09-18 07:58:59 -07:00
|
|
|
#include <vector>
|
2016-09-21 09:19:34 +02:00
|
|
|
|
2021-02-10 14:31:24 +01:00
|
|
|
#include "api/sequence_checker.h"
|
2019-06-26 14:39:36 +02:00
|
|
|
#include "modules/rtp_rtcp/include/rtp_header_extension_map.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
|
|
|
|
|
#include "modules/rtp_rtcp/source/forward_error_correction.h"
|
2020-03-11 12:59:07 +01:00
|
|
|
#include "modules/rtp_rtcp/source/rtp_packet_received.h"
|
2021-01-19 13:30:23 +01:00
|
|
|
#include "rtc_base/system/no_unique_address.h"
|
2022-08-10 07:45:43 +02:00
|
|
|
#include "system_wrappers/include/clock.h"
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
2013-08-15 23:38:54 +00:00
|
|
|
|
2022-08-09 17:50:45 +02:00
|
|
|
struct FecPacketCounter {
|
|
|
|
|
FecPacketCounter() = default;
|
|
|
|
|
size_t num_packets = 0; // Number of received packets.
|
|
|
|
|
size_t num_bytes = 0;
|
|
|
|
|
size_t num_fec_packets = 0; // Number of received FEC packets.
|
|
|
|
|
size_t num_recovered_packets =
|
|
|
|
|
0; // Number of recovered media packets using FEC.
|
2022-08-10 07:45:43 +02:00
|
|
|
// Time when first packet is received.
|
|
|
|
|
Timestamp first_packet_time = Timestamp::MinusInfinity();
|
2022-08-09 17:50:45 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class UlpfecReceiver {
|
2013-05-16 15:06:28 +00:00
|
|
|
public:
|
2022-08-09 17:50:45 +02:00
|
|
|
UlpfecReceiver(uint32_t ssrc,
|
2022-08-10 07:45:43 +02:00
|
|
|
int ulpfec_payload_type,
|
2022-08-09 17:50:45 +02:00
|
|
|
RecoveredPacketReceiver* callback,
|
2022-08-10 07:45:43 +02:00
|
|
|
rtc::ArrayView<const RtpExtension> extensions,
|
|
|
|
|
Clock* clock);
|
2022-08-09 17:50:45 +02:00
|
|
|
~UlpfecReceiver();
|
2013-05-16 15:06:28 +00:00
|
|
|
|
2022-08-10 07:45:43 +02:00
|
|
|
int ulpfec_payload_type() const { return ulpfec_payload_type_; }
|
|
|
|
|
|
|
|
|
|
bool AddReceivedRedPacket(const RtpPacketReceived& rtp_packet);
|
2013-05-16 15:06:28 +00:00
|
|
|
|
2022-08-09 17:50:45 +02:00
|
|
|
void ProcessReceivedFec();
|
2013-05-16 15:06:28 +00:00
|
|
|
|
2022-08-09 17:50:45 +02:00
|
|
|
FecPacketCounter GetPacketCounter() const;
|
2015-01-15 07:40:20 +00:00
|
|
|
|
2022-08-09 17:50:45 +02:00
|
|
|
void SetRtpExtensions(rtc::ArrayView<const RtpExtension> extensions);
|
2021-09-08 10:44:50 +02:00
|
|
|
|
2013-05-16 15:06:28 +00:00
|
|
|
private:
|
2017-06-29 02:45:35 -07:00
|
|
|
const uint32_t ssrc_;
|
2022-08-10 07:45:43 +02:00
|
|
|
const int ulpfec_payload_type_;
|
|
|
|
|
Clock* const clock_;
|
2021-09-08 10:44:50 +02:00
|
|
|
RtpHeaderExtensionMap extensions_ RTC_GUARDED_BY(&sequence_checker_);
|
2017-06-29 02:45:35 -07:00
|
|
|
|
2021-01-19 13:30:23 +01:00
|
|
|
RTC_NO_UNIQUE_ADDRESS SequenceChecker sequence_checker_;
|
|
|
|
|
RecoveredPacketReceiver* const recovered_packet_callback_;
|
|
|
|
|
const std::unique_ptr<ForwardErrorCorrection> fec_;
|
2017-09-18 07:58:59 -07:00
|
|
|
// TODO(nisse): The AddReceivedRedPacket method adds one or two packets to
|
|
|
|
|
// this list at a time, after which it is emptied by ProcessReceivedFec. It
|
|
|
|
|
// will make things simpler to merge AddReceivedRedPacket and
|
|
|
|
|
// ProcessReceivedFec into a single method, and we can then delete this list.
|
|
|
|
|
std::vector<std::unique_ptr<ForwardErrorCorrection::ReceivedPacket>>
|
2021-01-19 13:30:23 +01:00
|
|
|
received_packets_ RTC_GUARDED_BY(&sequence_checker_);
|
|
|
|
|
ForwardErrorCorrection::RecoveredPacketList recovered_packets_
|
|
|
|
|
RTC_GUARDED_BY(&sequence_checker_);
|
|
|
|
|
FecPacketCounter packet_counter_ RTC_GUARDED_BY(&sequence_checker_);
|
2011-07-07 08:21:25 +00:00
|
|
|
};
|
2016-10-04 00:00:06 -07:00
|
|
|
|
2013-05-16 15:06:28 +00:00
|
|
|
} // namespace webrtc
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2022-08-09 17:50:45 +02:00
|
|
|
#endif // MODULES_RTP_RTCP_SOURCE_ULPFEC_RECEIVER_H_
|