2015-11-04 08:31:52 +01:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2013 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_ULPFEC_RECEIVER_H_
|
|
|
|
|
#define MODULES_RTP_RTCP_INCLUDE_ULPFEC_RECEIVER_H_
|
2015-11-04 08:31:52 +01:00
|
|
|
|
2019-06-26 14:39:36 +02:00
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
|
|
#include "api/array_view.h"
|
|
|
|
|
#include "api/rtp_parameters.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
|
2020-03-11 12:59:07 +01:00
|
|
|
#include "modules/rtp_rtcp/source/rtp_packet_received.h"
|
2015-11-04 08:31:52 +01:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
|
|
|
|
struct FecPacketCounter {
|
2019-08-27 09:19:49 +02:00
|
|
|
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.
|
|
|
|
|
int64_t first_packet_time_ms = -1; // Time when first packet is received.
|
2015-11-04 08:31:52 +01:00
|
|
|
};
|
|
|
|
|
|
2016-10-31 04:51:33 -07:00
|
|
|
class UlpfecReceiver {
|
2015-11-04 08:31:52 +01:00
|
|
|
public:
|
2019-06-26 14:39:36 +02:00
|
|
|
static std::unique_ptr<UlpfecReceiver> Create(
|
|
|
|
|
uint32_t ssrc,
|
|
|
|
|
RecoveredPacketReceiver* callback,
|
|
|
|
|
rtc::ArrayView<const RtpExtension> extensions);
|
2015-11-04 08:31:52 +01:00
|
|
|
|
2016-10-31 04:51:33 -07:00
|
|
|
virtual ~UlpfecReceiver() {}
|
2015-11-04 08:31:52 +01:00
|
|
|
|
2016-08-10 00:51:50 -07:00
|
|
|
// Takes a RED packet, strips the RED header, and adds the resulting
|
|
|
|
|
// "virtual" RTP packet(s) into the internal buffer.
|
2016-10-04 00:00:06 -07:00
|
|
|
//
|
2021-07-28 23:57:33 +02:00
|
|
|
// TODO(brandtr): Set `ulpfec_payload_type` during constructor call,
|
2016-10-04 00:00:06 -07:00
|
|
|
// rather than as a parameter here.
|
2020-03-11 12:59:07 +01:00
|
|
|
virtual bool AddReceivedRedPacket(const RtpPacketReceived& rtp_packet,
|
2019-09-20 11:40:12 +02:00
|
|
|
uint8_t ulpfec_payload_type) = 0;
|
2015-11-04 08:31:52 +01:00
|
|
|
|
2016-08-10 00:51:50 -07:00
|
|
|
// Sends the received packets to the FEC and returns all packets
|
|
|
|
|
// (both original media and recovered) through the callback.
|
2015-11-04 08:31:52 +01:00
|
|
|
virtual int32_t ProcessReceivedFec() = 0;
|
|
|
|
|
|
2016-08-10 00:51:50 -07:00
|
|
|
// Returns a counter describing the added and recovered packets.
|
2015-11-04 08:31:52 +01:00
|
|
|
virtual FecPacketCounter GetPacketCounter() const = 0;
|
2021-09-08 10:44:50 +02:00
|
|
|
|
|
|
|
|
virtual void SetRtpExtensions(
|
|
|
|
|
rtc::ArrayView<const RtpExtension> extensions) = 0;
|
2015-11-04 08:31:52 +01:00
|
|
|
};
|
|
|
|
|
} // namespace webrtc
|
2017-09-15 06:47:31 +02:00
|
|
|
#endif // MODULES_RTP_RTCP_INCLUDE_ULPFEC_RECEIVER_H_
|