1 /* 2 * Copyright (c) 2019 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_VIDEO_FEC_GENERATOR_H_ 12 #define MODULES_RTP_RTCP_SOURCE_VIDEO_FEC_GENERATOR_H_ 13 14 #include <memory> 15 #include <vector> 16 17 #include "api/units/data_rate.h" 18 #include "modules/include/module_fec_types.h" 19 #include "modules/rtp_rtcp/source/rtp_packet_to_send.h" 20 21 namespace webrtc { 22 23 class VideoFecGenerator { 24 public: 25 VideoFecGenerator() = default; 26 virtual ~VideoFecGenerator() = default; 27 28 enum class FecType { kFlexFec, kUlpFec }; 29 virtual FecType GetFecType() const = 0; 30 // Returns the SSRC used for FEC packets (i.e. FlexFec SSRC). 31 virtual absl::optional<uint32_t> FecSsrc() = 0; 32 // Returns the overhead, in bytes per packet, for FEC (and possibly RED). 33 virtual size_t MaxPacketOverhead() const = 0; 34 // Current rate of FEC packets generated, including all RTP-level headers. 35 virtual DataRate CurrentFecRate() const = 0; 36 // Set FEC rates, max frames before FEC is sent, and type of FEC masks. 37 virtual void SetProtectionParameters( 38 const FecProtectionParams& delta_params, 39 const FecProtectionParams& key_params) = 0; 40 // Called on new media packet to be protected. The generator may choose 41 // to generate FEC packets at this time, if so they will be stored in an 42 // internal buffer. 43 virtual void AddPacketAndGenerateFec(const RtpPacketToSend& packet) = 0; 44 // Get (and remove) and FEC packets pending in the generator. These packets 45 // will lack sequence numbers, that needs to be set externally. 46 // TODO(bugs.webrtc.org/11340): Actually FlexFec sets seq#, fix that! 47 virtual std::vector<std::unique_ptr<RtpPacketToSend>> GetFecPackets() = 0; 48 // Only called on the VideoSendStream queue, after operation has shut down, 49 // and only populated if there is an RtpState (e.g. FlexFec). 50 virtual absl::optional<RtpState> GetRtpState() = 0; 51 }; 52 53 } // namespace webrtc 54 #endif // MODULES_RTP_RTCP_SOURCE_VIDEO_FEC_GENERATOR_H_ 55