tor-browser

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

h264_sps_pps_tracker.h (1840B)


      1 /*
      2 *  Copyright (c) 2016 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_H264_SPS_PPS_TRACKER_H_
     12 #define MODULES_VIDEO_CODING_H264_SPS_PPS_TRACKER_H_
     13 
     14 #include <cstddef>
     15 #include <cstdint>
     16 #include <map>
     17 #include <vector>
     18 
     19 #include "api/array_view.h"
     20 #include "modules/rtp_rtcp/source/rtp_video_header.h"
     21 #include "rtc_base/buffer.h"
     22 #include "rtc_base/copy_on_write_buffer.h"
     23 
     24 namespace webrtc {
     25 namespace video_coding {
     26 
     27 class H264SpsPpsTracker {
     28 public:
     29  enum PacketAction { kInsert, kDrop, kRequestKeyframe };
     30  struct FixedBitstream {
     31    PacketAction action;
     32    CopyOnWriteBuffer bitstream;
     33  };
     34 
     35  H264SpsPpsTracker() = default;
     36  H264SpsPpsTracker(const H264SpsPpsTracker& other) = default;
     37  H264SpsPpsTracker& operator=(const H264SpsPpsTracker& other) = default;
     38  ~H264SpsPpsTracker() = default;
     39 
     40  // Returns fixed bitstream and modifies `video_header`.
     41  FixedBitstream CopyAndFixBitstream(ArrayView<const uint8_t> bitstream,
     42                                     RTPVideoHeader* video_header);
     43 
     44  void InsertSpsPpsNalus(const std::vector<uint8_t>& sps,
     45                         const std::vector<uint8_t>& pps);
     46 
     47 private:
     48  struct PpsInfo {
     49    int sps_id = -1;
     50    Buffer data;
     51  };
     52 
     53  struct SpsInfo {
     54    int width = -1;
     55    int height = -1;
     56    Buffer data;
     57  };
     58 
     59  std::map<int, PpsInfo> pps_data_;
     60  std::map<int, SpsInfo> sps_data_;
     61 };
     62 
     63 }  // namespace video_coding
     64 }  // namespace webrtc
     65 
     66 #endif  // MODULES_VIDEO_CODING_H264_SPS_PPS_TRACKER_H_