tor-browser

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

nack.h (1775B)


      1 /*
      2 *  Copyright (c) 2015 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_RTCP_PACKET_NACK_H_
     12 #define MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_NACK_H_
     13 
     14 #include <cstddef>
     15 #include <cstdint>
     16 #include <vector>
     17 
     18 #include "modules/rtp_rtcp/source/rtcp_packet/rtpfb.h"
     19 
     20 namespace webrtc {
     21 namespace rtcp {
     22 class CommonHeader;
     23 
     24 class Nack : public Rtpfb {
     25 public:
     26  static constexpr uint8_t kFeedbackMessageType = 1;
     27  Nack();
     28  Nack(const Nack&);
     29  ~Nack() override;
     30 
     31  // Parse assumes header is already parsed and validated.
     32  bool Parse(const CommonHeader& packet);
     33 
     34  void SetPacketIds(const uint16_t* nack_list, size_t length);
     35  void SetPacketIds(std::vector<uint16_t> nack_list);
     36  const std::vector<uint16_t>& packet_ids() const { return packet_ids_; }
     37 
     38  size_t BlockLength() const override;
     39 
     40  bool Create(uint8_t* packet,
     41              size_t* index,
     42              size_t max_length,
     43              PacketReadyCallback callback) const override;
     44 
     45 private:
     46  static constexpr size_t kNackItemLength = 4;
     47  struct PackedNack {
     48    uint16_t first_pid;
     49    uint16_t bitmask;
     50  };
     51 
     52  void Pack();    // Fills packed_ using packed_ids_. (used in SetPacketIds).
     53  void Unpack();  // Fills packet_ids_ using packed_. (used in Parse).
     54 
     55  std::vector<PackedNack> packed_;
     56  std::vector<uint16_t> packet_ids_;
     57 };
     58 
     59 }  // namespace rtcp
     60 }  // namespace webrtc
     61 #endif  // MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_NACK_H_