blob: 45720e6b70c45d8c70b2c9b7c269693db71dc183 [file] [log] [blame]
philipel34852cf2016-11-03 04:03:01 -07001/*
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
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020011#ifndef MODULES_VIDEO_CODING_H264_SPS_PPS_TRACKER_H_
12#define MODULES_VIDEO_CODING_H264_SPS_PPS_TRACKER_H_
philipel34852cf2016-11-03 04:03:01 -070013
14#include <cstdint>
15#include <map>
16#include <memory>
philipel022b54e2016-12-20 04:15:59 -080017#include <vector>
philipel34852cf2016-11-03 04:03:01 -070018
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020019#include "modules/include/module_common_types.h"
philipel34852cf2016-11-03 04:03:01 -070020
21namespace webrtc {
22
23class VCMPacket;
24
25namespace video_coding {
26
27class H264SpsPpsTracker {
28 public:
philipela75d12d2016-11-07 05:11:28 -080029 enum PacketAction { kInsert, kDrop, kRequestKeyframe };
30
Mirko Bonadei8fdcac32018-08-28 16:30:18 +020031 H264SpsPpsTracker();
32 ~H264SpsPpsTracker();
33
philipela75d12d2016-11-07 05:11:28 -080034 PacketAction CopyAndFixBitstream(VCMPacket* packet);
johand2b092f2017-01-24 02:38:17 -080035
36 void InsertSpsPpsNalus(const std::vector<uint8_t>& sps,
37 const std::vector<uint8_t>& pps);
philipel34852cf2016-11-03 04:03:01 -070038
39 private:
40 struct PpsInfo {
Mirko Bonadei8fdcac32018-08-28 16:30:18 +020041 PpsInfo();
42 PpsInfo(PpsInfo&& rhs);
43 PpsInfo& operator=(PpsInfo&& rhs);
44 ~PpsInfo();
45
philipel34852cf2016-11-03 04:03:01 -070046 int sps_id = -1;
47 size_t size = 0;
48 std::unique_ptr<uint8_t[]> data;
49 };
50
51 struct SpsInfo {
Mirko Bonadei8fdcac32018-08-28 16:30:18 +020052 SpsInfo();
53 SpsInfo(SpsInfo&& rhs);
54 SpsInfo& operator=(SpsInfo&& rhs);
55 ~SpsInfo();
56
philipel34852cf2016-11-03 04:03:01 -070057 size_t size = 0;
philipel6585f702017-03-17 06:12:33 -070058 int width = -1;
59 int height = -1;
philipel34852cf2016-11-03 04:03:01 -070060 std::unique_ptr<uint8_t[]> data;
61 };
62
63 std::map<uint32_t, PpsInfo> pps_data_;
64 std::map<uint32_t, SpsInfo> sps_data_;
65};
66
67} // namespace video_coding
68} // namespace webrtc
69
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020070#endif // MODULES_VIDEO_CODING_H264_SPS_PPS_TRACKER_H_