5 #ifndef PACKAGER_MEDIA_FORMATS_MP2T_ES_PARSER_H26x_H_
6 #define PACKAGER_MEDIA_FORMATS_MP2T_ES_PARSER_H26x_H_
14 #include <packager/macros/classes.h>
15 #include <packager/media/codecs/nalu_reader.h>
16 #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,
100 virtual int64_t CalculateSampleDuration(
int pps_id) = 0;
103 EmitSampleCB emit_sample_cb_;
106 Nalu::CodecType type_;
109 std::unique_ptr<media::OffsetByteQueue> es_queue_;
110 std::list<std::pair<int64_t, TimingDesc>> timing_desc_list_;
114 uint64_t current_search_position_ = 0;
116 uint64_t current_access_unit_position_ = 0;
119 VideoSliceInfo current_video_slice_info_;
120 bool next_access_unit_position_set_ =
false;
121 uint64_t next_access_unit_position_ = 0;
123 std::unique_ptr<NaluInfo> current_nalu_info_;
125 std::unique_ptr<NaluInfo> next_nalu_info_;
128 std::unique_ptr<H26xByteToUnitStreamConverter> stream_converter_;
131 std::shared_ptr<MediaSample> pending_sample_;
132 int pending_sample_pps_id_ = -1;
133 int64_t pending_sample_duration_ = 0;
136 bool waiting_for_key_frame_ =
true;
All the methods that are virtual are virtual for mocking.