tor-browser

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

session_info.h (4408B)


      1 /*
      2 *  Copyright (c) 2011 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_VIDEO_CODING_DEPRECATED_SESSION_INFO_H_
     12 #define MODULES_VIDEO_CODING_DEPRECATED_SESSION_INFO_H_
     13 
     14 #include <stddef.h>
     15 #include <stdint.h>
     16 
     17 #include <list>
     18 #include <vector>
     19 
     20 #include "api/video/video_frame_type.h"
     21 #include "modules/video_coding/codecs/h264/include/h264_globals.h"
     22 #include "modules/video_coding/codecs/vp9/include/vp9_globals.h"
     23 #include "modules/video_coding/deprecated/packet.h"
     24 
     25 namespace webrtc {
     26 // Used to pass data from jitter buffer to session info.
     27 // This data is then used in determining whether a frame is decodable.
     28 struct FrameData {
     29  int64_t rtt_ms;
     30  float rolling_average_packets_per_frame;
     31 };
     32 
     33 class VCMSessionInfo {
     34 public:
     35  VCMSessionInfo();
     36  ~VCMSessionInfo();
     37 
     38  void UpdateDataPointers(const uint8_t* old_base_ptr,
     39                          const uint8_t* new_base_ptr);
     40  void Reset();
     41  int InsertPacket(const VCMPacket& packet,
     42                   uint8_t* frame_buffer,
     43                   const FrameData& frame_data);
     44  bool complete() const;
     45 
     46  // Makes the frame decodable. I.e., only contain decodable NALUs. All
     47  // non-decodable NALUs will be deleted and packets will be moved to in
     48  // memory to remove any empty space.
     49  // Returns the number of bytes deleted from the session.
     50  size_t MakeDecodable();
     51 
     52  size_t SessionLength() const;
     53  int NumPackets() const;
     54  bool HaveFirstPacket() const;
     55  bool HaveLastPacket() const;
     56  VideoFrameType FrameType() const { return frame_type_; }
     57  int LowSequenceNumber() const;
     58 
     59  // Returns highest sequence number, media or empty.
     60  int HighSequenceNumber() const;
     61  int PictureId() const;
     62  int TemporalId() const;
     63  bool LayerSync() const;
     64  int Tl0PicId() const;
     65 
     66  std::vector<NaluInfo> GetNaluInfos() const;
     67 
     68  void SetGofInfo(const GofInfoVP9& gof_info, size_t idx);
     69 
     70 private:
     71  enum { kMaxVP8Partitions = 9 };
     72 
     73  typedef std::list<VCMPacket> PacketList;
     74  typedef PacketList::iterator PacketIterator;
     75  typedef PacketList::const_iterator PacketIteratorConst;
     76  typedef PacketList::reverse_iterator ReversePacketIterator;
     77 
     78  void InformOfEmptyPacket(uint16_t seq_num);
     79 
     80  // Finds the packet of the beginning of the next VP8 partition. If
     81  // none is found the returned iterator points to `packets_.end()`.
     82  // `it` is expected to point to the last packet of the previous partition,
     83  // or to the first packet of the frame. `packets_skipped` is incremented
     84  // for each packet found which doesn't have the beginning bit set.
     85  PacketIterator FindNextPartitionBeginning(PacketIterator it) const;
     86 
     87  // Returns an iterator pointing to the last packet of the partition pointed to
     88  // by `it`.
     89  PacketIterator FindPartitionEnd(PacketIterator it) const;
     90  static bool InSequence(const PacketIterator& it,
     91                         const PacketIterator& prev_it);
     92  size_t InsertBuffer(uint8_t* frame_buffer, PacketIterator packetIterator);
     93  size_t Insert(const uint8_t* buffer,
     94                size_t length,
     95                bool insert_start_code,
     96                uint8_t* frame_buffer);
     97  void ShiftSubsequentPackets(PacketIterator it, int steps_to_shift);
     98  PacketIterator FindNaluEnd(PacketIterator packet_iter) const;
     99  // Deletes the data of all packets between `start` and `end`, inclusively.
    100  // Note that this function doesn't delete the actual packets.
    101  size_t DeletePacketData(PacketIterator start, PacketIterator end);
    102  void UpdateCompleteSession();
    103 
    104  bool complete_;
    105  VideoFrameType frame_type_;
    106  // Packets in this frame.
    107  PacketList packets_;
    108  int empty_seq_num_low_;
    109  int empty_seq_num_high_;
    110 
    111  // The following two variables correspond to the first and last media packets
    112  // in a session defined by the first packet flag and the marker bit.
    113  // They are not necessarily equal to the front and back packets, as packets
    114  // may enter out of order.
    115  // TODO(mikhal): Refactor the list to use a map.
    116  int first_packet_seq_num_;
    117  int last_packet_seq_num_;
    118 };
    119 
    120 }  // namespace webrtc
    121 
    122 #endif  // MODULES_VIDEO_CODING_DEPRECATED_SESSION_INFO_H_