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.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef WEBRTC_MODULES_RTP_RTCP_INCLUDE_FLEXFEC_RECEIVER_H_
|
|
|
|
|
#define WEBRTC_MODULES_RTP_RTCP_INCLUDE_FLEXFEC_RECEIVER_H_
|
|
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
|
|
#include "webrtc/base/basictypes.h"
|
2016-11-03 08:18:27 -07:00
|
|
|
#include "webrtc/base/sequenced_task_checker.h"
|
2016-10-31 04:51:33 -07:00
|
|
|
#include "webrtc/modules/rtp_rtcp/include/ulpfec_receiver.h"
|
2016-11-03 08:18:27 -07:00
|
|
|
#include "webrtc/modules/rtp_rtcp/source/forward_error_correction.h"
|
2016-12-21 06:37:18 -08:00
|
|
|
#include "webrtc/modules/rtp_rtcp/source/rtp_packet_received.h"
|
2016-11-03 08:18:27 -07:00
|
|
|
#include "webrtc/system_wrappers/include/clock.h"
|
2016-10-10 16:44:57 -07:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
|
|
|
|
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);
|
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-01-17 01:33:54 -08:00
|
|
|
bool AddReceivedPacket(const RtpPacketReceived& packet);
|
2016-11-03 08:18:27 -07:00
|
|
|
bool ProcessReceivedPackets();
|
|
|
|
|
|
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_
|
|
|
|
|
GUARDED_BY(sequence_checker_);
|
|
|
|
|
ForwardErrorCorrection::ReceivedPacketList received_packets_
|
|
|
|
|
GUARDED_BY(sequence_checker_);
|
|
|
|
|
ForwardErrorCorrection::RecoveredPacketList recovered_packets_
|
|
|
|
|
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_;
|
2016-12-19 10:02:30 -08:00
|
|
|
int64_t last_recovered_packet_ms_ GUARDED_BY(sequence_checker_);
|
|
|
|
|
FecPacketCounter packet_counter_ GUARDED_BY(sequence_checker_);
|
2016-11-03 08:18:27 -07:00
|
|
|
|
|
|
|
|
rtc::SequencedTaskChecker sequence_checker_;
|
2016-10-10 16:44:57 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace webrtc
|
|
|
|
|
|
|
|
|
|
#endif // WEBRTC_MODULES_RTP_RTCP_INCLUDE_FLEXFEC_RECEIVER_H_
|