5 #ifndef PACKAGER_MEDIA_FORMATS_MP2T_ES_PARSER_H26x_H_
6 #define PACKAGER_MEDIA_FORMATS_MP2T_ES_PARSER_H26x_H_
14 #include "packager/base/callback.h"
15 #include "packager/base/compiler_specific.h"
16 #include "packager/media/codecs/nalu_reader.h"
17 #include "packager/media/formats/mp2t/es_parser.h"
22 class H26xByteToUnitStreamConverter;
23 class OffsetByteQueue;
31 std::unique_ptr<H26xByteToUnitStreamConverter> stream_converter,
33 const EmitSampleCB& emit_sample_cb);
37 bool Parse(
const uint8_t* buf,
int size, int64_t pts, int64_t dts)
override;
38 bool Flush()
override;
39 void Reset()
override;
44 bool is_key_frame =
false;
52 return stream_converter_.get();
66 uint64_t position = 0;
67 uint8_t start_code_size = 0;
74 virtual bool ProcessNalu(
const Nalu& nalu,
75 VideoSliceInfo* video_slice_info) = 0;
79 virtual bool UpdateVideoDecoderConfig(
int pps_id) = 0;
84 bool SearchForNalu(uint64_t* position, Nalu* nalu);
91 bool EmitCurrentAccessUnit();
95 bool EmitFrame(int64_t access_unit_pos,
101 EmitSampleCB emit_sample_cb_;
104 Nalu::CodecType type_;
107 std::unique_ptr<media::OffsetByteQueue> es_queue_;
108 std::list<std::pair<int64_t, TimingDesc>> timing_desc_list_;
112 uint64_t current_search_position_ = 0;
114 uint64_t current_access_unit_position_ = 0;
117 VideoSliceInfo current_video_slice_info_;
118 bool next_access_unit_position_set_ =
false;
119 uint64_t next_access_unit_position_ = 0;
121 std::unique_ptr<NaluInfo> current_nalu_info_;
123 std::unique_ptr<NaluInfo> next_nalu_info_;
126 std::unique_ptr<H26xByteToUnitStreamConverter> stream_converter_;
129 std::shared_ptr<MediaSample> pending_sample_;
130 uint64_t pending_sample_duration_ = 0;
133 bool waiting_for_key_frame_ =
true;
All the methods that are virtual are virtual for mocking.