tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

video_fec_generator.h (2419B)


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