1 /* 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 3 * 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 11 #ifndef MODULES_RTP_RTCP_INCLUDE_ULPFEC_RECEIVER_H_ 12 #define MODULES_RTP_RTCP_INCLUDE_ULPFEC_RECEIVER_H_ 13 14 #include <memory> 15 16 #include "api/array_view.h" 17 #include "api/rtp_parameters.h" 18 #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" 19 #include "modules/rtp_rtcp/source/rtp_packet_received.h" 20 21 namespace webrtc { 22 23 struct FecPacketCounter { 24 FecPacketCounter() = default; 25 size_t num_packets = 0; // Number of received packets. 26 size_t num_bytes = 0; 27 size_t num_fec_packets = 0; // Number of received FEC packets. 28 size_t num_recovered_packets = 29 0; // Number of recovered media packets using FEC. 30 int64_t first_packet_time_ms = -1; // Time when first packet is received. 31 }; 32 33 class UlpfecReceiver { 34 public: 35 static std::unique_ptr<UlpfecReceiver> Create( 36 uint32_t ssrc, 37 RecoveredPacketReceiver* callback, 38 rtc::ArrayView<const RtpExtension> extensions); 39 ~UlpfecReceiver()40 virtual ~UlpfecReceiver() {} 41 42 // Takes a RED packet, strips the RED header, and adds the resulting 43 // "virtual" RTP packet(s) into the internal buffer. 44 // 45 // TODO(brandtr): Set |ulpfec_payload_type| during constructor call, 46 // rather than as a parameter here. 47 virtual bool AddReceivedRedPacket(const RtpPacketReceived& rtp_packet, 48 uint8_t ulpfec_payload_type) = 0; 49 50 // Sends the received packets to the FEC and returns all packets 51 // (both original media and recovered) through the callback. 52 virtual int32_t ProcessReceivedFec() = 0; 53 54 // Returns a counter describing the added and recovered packets. 55 virtual FecPacketCounter GetPacketCounter() const = 0; 56 }; 57 } // namespace webrtc 58 #endif // MODULES_RTP_RTCP_INCLUDE_ULPFEC_RECEIVER_H_ 59