7 #ifndef MEDIA_CODECS_NALU_READER_H_
8 #define MEDIA_CODECS_NALU_READER_H_
13 #include "packager/base/compiler_specific.h"
14 #include "packager/base/macros.h"
15 #include "packager/media/base/decrypt_config.h"
23 const uint8_t kIsAnnexbByteStream = 0;
39 H264_SPSExtension = 13,
40 H264_PrefixNALUnit = 14,
42 H264_DepthParameterSet = 16,
45 H264_CodedSliceExtension = 20,
57 H265_RSV_VCL_N10 = 10,
58 H265_RSV_VCL_R15 = 15,
65 H265_RSV_IRAP_VCL22 = 22,
66 H265_RSV_IRAP_VCL23 = 23,
92 bool Initialize(CodecType
type,
94 uint64_t size) WARN_UNUSED_RESULT;
97 const uint8_t*
data()
const {
return data_; }
105 int ref_idc()
const {
return ref_idc_; }
108 int nuh_layer_id()
const {
return nuh_layer_id_; }
109 int nuh_temporal_id()
const {
return nuh_temporal_id_; }
113 int type()
const {
return type_; }
114 bool is_aud()
const {
return is_aud_; }
115 bool is_vcl()
const {
return is_vcl_; }
118 bool can_start_access_unit()
const {
return can_start_access_unit_; }
121 bool InitializeFromH264(
const uint8_t* data, uint64_t size);
122 bool InitializeFromH265(
const uint8_t* data, uint64_t size);
126 const uint8_t* data_ =
nullptr;
129 uint64_t header_size_ = 0;
131 uint64_t payload_size_ = 0;
134 int nuh_layer_id_ = 0;
135 int nuh_temporal_id_ = 0;
137 bool is_aud_ =
false;
138 bool is_vcl_ =
false;
139 bool is_video_slice_ =
false;
140 bool can_start_access_unit_ =
false;
161 uint8_t nal_length_size,
162 const uint8_t* stream,
163 uint64_t stream_size);
176 uint8_t nal_length_size,
177 const uint8_t* stream,
178 uint64_t stream_size,
179 const std::vector<SubsampleEntry>& subsamples);
191 static bool FindStartCode(
const uint8_t* data,
194 uint8_t* start_code_size);
208 uint8_t* start_code_size,
209 const std::vector<SubsampleEntry>& subsamples);
223 kAnnexbByteStreamFormat,
234 bool LocateNaluByStartCode(uint64_t* nalu_size, uint8_t* start_code_size);
237 const uint8_t* stream_;
239 uint64_t stream_size_;
241 Nalu::CodecType nalu_type_;
244 uint8_t nalu_length_size_;
249 std::vector<SubsampleEntry> subsamples_;
257 #endif // MEDIA_CODECS_NALU_READER_H_