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 <cstdint>
15 #include <map>
16 #include <memory>
17 #include <vector>
18 
19 #include "modules/include/module_common_types.h"
20 
21 namespace webrtc {
22 
23 class VCMPacket;
24 
25 namespace video_coding {
26 
27 class H264SpsPpsTracker {
28  public:
29   enum PacketAction { kInsert, kDrop, kRequestKeyframe };
30 
31   PacketAction CopyAndFixBitstream(VCMPacket* packet);
32 
33   void InsertSpsPpsNalus(const std::vector<uint8_t>& sps,
34                          const std::vector<uint8_t>& pps);
35 
36  private:
37   struct PpsInfo {
38     int sps_id = -1;
39     size_t size = 0;
40     std::unique_ptr<uint8_t[]> data;
41   };
42 
43   struct SpsInfo {
44     size_t size = 0;
45     int width = -1;
46     int height = -1;
47     std::unique_ptr<uint8_t[]> data;
48   };
49 
50   std::map<uint32_t, PpsInfo> pps_data_;
51   std::map<uint32_t, SpsInfo> sps_data_;
52 };
53 
54 }  // namespace video_coding
55 }  // namespace webrtc
56 
57 #endif  // MODULES_VIDEO_CODING_H264_SPS_PPS_TRACKER_H_
58