1 /* 2 * Copyright (c) 2012 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_SOURCE_ULPFEC_RECEIVER_IMPL_H_ 12 #define MODULES_RTP_RTCP_SOURCE_ULPFEC_RECEIVER_IMPL_H_ 13 14 #include <stddef.h> 15 #include <stdint.h> 16 17 #include <memory> 18 #include <vector> 19 20 #include "modules/rtp_rtcp/include/rtp_header_extension_map.h" 21 #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" 22 #include "modules/rtp_rtcp/include/ulpfec_receiver.h" 23 #include "modules/rtp_rtcp/source/forward_error_correction.h" 24 #include "modules/rtp_rtcp/source/rtp_packet_received.h" 25 #include "rtc_base/synchronization/mutex.h" 26 27 namespace webrtc { 28 29 class UlpfecReceiverImpl : public UlpfecReceiver { 30 public: 31 explicit UlpfecReceiverImpl(uint32_t ssrc, 32 RecoveredPacketReceiver* callback, 33 rtc::ArrayView<const RtpExtension> extensions); 34 ~UlpfecReceiverImpl() override; 35 36 bool AddReceivedRedPacket(const RtpPacketReceived& rtp_packet, 37 uint8_t ulpfec_payload_type) override; 38 39 int32_t ProcessReceivedFec() override; 40 41 FecPacketCounter GetPacketCounter() const override; 42 43 private: 44 const uint32_t ssrc_; 45 const RtpHeaderExtensionMap extensions_; 46 47 mutable Mutex mutex_; 48 RecoveredPacketReceiver* recovered_packet_callback_; 49 std::unique_ptr<ForwardErrorCorrection> fec_; 50 // TODO(nisse): The AddReceivedRedPacket method adds one or two packets to 51 // this list at a time, after which it is emptied by ProcessReceivedFec. It 52 // will make things simpler to merge AddReceivedRedPacket and 53 // ProcessReceivedFec into a single method, and we can then delete this list. 54 std::vector<std::unique_ptr<ForwardErrorCorrection::ReceivedPacket>> 55 received_packets_; 56 ForwardErrorCorrection::RecoveredPacketList recovered_packets_; 57 FecPacketCounter packet_counter_; 58 }; 59 60 } // namespace webrtc 61 62 #endif // MODULES_RTP_RTCP_SOURCE_ULPFEC_RECEIVER_IMPL_H_ 63