2016-10-10 16:44:57 -07:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* 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.
|
|
|
|
|
*/
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#ifndef MODULES_RTP_RTCP_INCLUDE_FLEXFEC_RECEIVER_H_
|
|
|
|
|
#define MODULES_RTP_RTCP_INCLUDE_FLEXFEC_RECEIVER_H_
|
2016-10-10 16:44:57 -07:00
|
|
|
|
2018-10-23 12:03:01 +02:00
|
|
|
#include <stdint.h>
|
2019-07-05 19:08:33 +02:00
|
|
|
|
2016-10-10 16:44:57 -07:00
|
|
|
#include <memory>
|
|
|
|
|
|
2021-02-10 14:31:24 +01:00
|
|
|
#include "api/sequence_checker.h"
|
2018-10-23 12:03:01 +02:00
|
|
|
#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "modules/rtp_rtcp/source/forward_error_correction.h"
|
|
|
|
|
#include "modules/rtp_rtcp/source/rtp_packet_received.h"
|
2022-08-09 17:50:45 +02:00
|
|
|
#include "modules/rtp_rtcp/source/ulpfec_receiver.h"
|
2020-11-23 11:07:42 +01:00
|
|
|
#include "rtc_base/system/no_unique_address.h"
|
2018-10-23 12:03:01 +02:00
|
|
|
#include "rtc_base/thread_annotations.h"
|
2016-10-10 16:44:57 -07:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
2018-10-23 12:03:01 +02:00
|
|
|
class Clock;
|
|
|
|
|
|
2016-10-10 16:44:57 -07:00
|
|
|
class FlexfecReceiver {
|
|
|
|
|
public:
|
2016-11-03 08:18:27 -07:00
|
|
|
FlexfecReceiver(uint32_t ssrc,
|
|
|
|
|
uint32_t protected_media_ssrc,
|
2016-12-21 06:37:18 -08:00
|
|
|
RecoveredPacketReceiver* recovered_packet_receiver);
|
2019-03-04 19:39:01 +01:00
|
|
|
FlexfecReceiver(Clock* clock,
|
|
|
|
|
uint32_t ssrc,
|
|
|
|
|
uint32_t protected_media_ssrc,
|
|
|
|
|
RecoveredPacketReceiver* recovered_packet_receiver);
|
2016-11-03 08:18:27 -07:00
|
|
|
~FlexfecReceiver();
|
2016-10-10 16:44:57 -07:00
|
|
|
|
|
|
|
|
// Inserts a received packet (can be either media or FlexFEC) into the
|
|
|
|
|
// internal buffer, and sends the received packets to the erasure code.
|
|
|
|
|
// All newly recovered packets are sent back through the callback.
|
2017-02-16 06:52:32 -08:00
|
|
|
void OnRtpPacket(const RtpPacketReceived& packet);
|
2016-10-10 16:44:57 -07:00
|
|
|
|
|
|
|
|
// Returns a counter describing the added and recovered packets.
|
2016-11-03 08:18:27 -07:00
|
|
|
FecPacketCounter GetPacketCounter() const;
|
|
|
|
|
|
2017-02-16 06:52:32 -08:00
|
|
|
// Protected to aid testing.
|
|
|
|
|
protected:
|
2017-09-18 07:58:59 -07:00
|
|
|
std::unique_ptr<ForwardErrorCorrection::ReceivedPacket> AddReceivedPacket(
|
|
|
|
|
const RtpPacketReceived& packet);
|
|
|
|
|
void ProcessReceivedPacket(
|
|
|
|
|
const ForwardErrorCorrection::ReceivedPacket& received_packet);
|
2016-11-03 08:18:27 -07:00
|
|
|
|
2017-02-16 06:52:32 -08:00
|
|
|
private:
|
2016-11-03 08:18:27 -07:00
|
|
|
// Config.
|
|
|
|
|
const uint32_t ssrc_;
|
|
|
|
|
const uint32_t protected_media_ssrc_;
|
|
|
|
|
|
|
|
|
|
// Erasure code interfacing and callback.
|
2016-12-19 10:02:30 -08:00
|
|
|
std::unique_ptr<ForwardErrorCorrection> erasure_code_
|
2017-09-07 07:53:45 -07:00
|
|
|
RTC_GUARDED_BY(sequence_checker_);
|
2016-12-19 10:02:30 -08:00
|
|
|
ForwardErrorCorrection::RecoveredPacketList recovered_packets_
|
2017-09-07 07:53:45 -07:00
|
|
|
RTC_GUARDED_BY(sequence_checker_);
|
2016-12-21 06:37:18 -08:00
|
|
|
RecoveredPacketReceiver* const recovered_packet_receiver_;
|
2016-11-03 08:18:27 -07:00
|
|
|
|
|
|
|
|
// Logging and stats.
|
|
|
|
|
Clock* const clock_;
|
2017-09-07 07:53:45 -07:00
|
|
|
int64_t last_recovered_packet_ms_ RTC_GUARDED_BY(sequence_checker_);
|
|
|
|
|
FecPacketCounter packet_counter_ RTC_GUARDED_BY(sequence_checker_);
|
2016-11-03 08:18:27 -07:00
|
|
|
|
2020-11-23 11:07:42 +01:00
|
|
|
RTC_NO_UNIQUE_ADDRESS SequenceChecker sequence_checker_;
|
2016-10-10 16:44:57 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace webrtc
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#endif // MODULES_RTP_RTCP_INCLUDE_FLEXFEC_RECEIVER_H_
|