philipel | 34852cf | 2016-11-03 04:03:01 -0700 | [diff] [blame] | 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 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #ifndef MODULES_VIDEO_CODING_H264_SPS_PPS_TRACKER_H_ |
| 12 | #define MODULES_VIDEO_CODING_H264_SPS_PPS_TRACKER_H_ |
philipel | 34852cf | 2016-11-03 04:03:01 -0700 | [diff] [blame] | 13 | |
| 14 | #include <cstdint> |
| 15 | #include <map> |
| 16 | #include <memory> |
philipel | 022b54e | 2016-12-20 04:15:59 -0800 | [diff] [blame] | 17 | #include <vector> |
philipel | 34852cf | 2016-11-03 04:03:01 -0700 | [diff] [blame] | 18 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 19 | #include "modules/include/module_common_types.h" |
philipel | 34852cf | 2016-11-03 04:03:01 -0700 | [diff] [blame] | 20 | |
| 21 | namespace webrtc { |
| 22 | |
| 23 | class VCMPacket; |
| 24 | |
| 25 | namespace video_coding { |
| 26 | |
| 27 | class H264SpsPpsTracker { |
| 28 | public: |
philipel | a75d12d | 2016-11-07 05:11:28 -0800 | [diff] [blame] | 29 | enum PacketAction { kInsert, kDrop, kRequestKeyframe }; |
| 30 | |
Mirko Bonadei | 8fdcac3 | 2018-08-28 16:30:18 +0200 | [diff] [blame^] | 31 | H264SpsPpsTracker(); |
| 32 | ~H264SpsPpsTracker(); |
| 33 | |
philipel | a75d12d | 2016-11-07 05:11:28 -0800 | [diff] [blame] | 34 | PacketAction CopyAndFixBitstream(VCMPacket* packet); |
johan | d2b092f | 2017-01-24 02:38:17 -0800 | [diff] [blame] | 35 | |
| 36 | void InsertSpsPpsNalus(const std::vector<uint8_t>& sps, |
| 37 | const std::vector<uint8_t>& pps); |
philipel | 34852cf | 2016-11-03 04:03:01 -0700 | [diff] [blame] | 38 | |
| 39 | private: |
| 40 | struct PpsInfo { |
Mirko Bonadei | 8fdcac3 | 2018-08-28 16:30:18 +0200 | [diff] [blame^] | 41 | PpsInfo(); |
| 42 | PpsInfo(PpsInfo&& rhs); |
| 43 | PpsInfo& operator=(PpsInfo&& rhs); |
| 44 | ~PpsInfo(); |
| 45 | |
philipel | 34852cf | 2016-11-03 04:03:01 -0700 | [diff] [blame] | 46 | int sps_id = -1; |
| 47 | size_t size = 0; |
| 48 | std::unique_ptr<uint8_t[]> data; |
| 49 | }; |
| 50 | |
| 51 | struct SpsInfo { |
Mirko Bonadei | 8fdcac3 | 2018-08-28 16:30:18 +0200 | [diff] [blame^] | 52 | SpsInfo(); |
| 53 | SpsInfo(SpsInfo&& rhs); |
| 54 | SpsInfo& operator=(SpsInfo&& rhs); |
| 55 | ~SpsInfo(); |
| 56 | |
philipel | 34852cf | 2016-11-03 04:03:01 -0700 | [diff] [blame] | 57 | size_t size = 0; |
philipel | 6585f70 | 2017-03-17 06:12:33 -0700 | [diff] [blame] | 58 | int width = -1; |
| 59 | int height = -1; |
philipel | 34852cf | 2016-11-03 04:03:01 -0700 | [diff] [blame] | 60 | 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 Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 70 | #endif // MODULES_VIDEO_CODING_H264_SPS_PPS_TRACKER_H_ |