2014-04-01 01:34:59 +00:00
|
|
|
// Copyright 2014 The Chromium Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2017-12-20 00:56:36 +00:00
|
|
|
#ifndef PACKAGER_MEDIA_FORMATS_MP2T_ES_PARSER_H264_H_
|
|
|
|
#define PACKAGER_MEDIA_FORMATS_MP2T_ES_PARSER_H264_H_
|
2014-04-01 01:34:59 +00:00
|
|
|
|
2023-10-11 08:49:50 +00:00
|
|
|
#include <cstdint>
|
2023-08-31 23:59:46 +00:00
|
|
|
#include <functional>
|
2016-08-17 17:41:40 +00:00
|
|
|
#include <memory>
|
2014-04-01 01:34:59 +00:00
|
|
|
|
2023-10-11 08:49:50 +00:00
|
|
|
#include <packager/media/formats/mp2t/es_parser_h26x.h>
|
|
|
|
|
2016-05-20 21:19:33 +00:00
|
|
|
namespace shaka {
|
2014-04-01 01:34:59 +00:00
|
|
|
namespace media {
|
2014-04-08 00:39:14 +00:00
|
|
|
|
2014-04-01 01:34:59 +00:00
|
|
|
class H264Parser;
|
2014-04-16 23:22:31 +00:00
|
|
|
|
2014-04-01 01:34:59 +00:00
|
|
|
namespace mp2t {
|
|
|
|
|
|
|
|
// Remark:
|
|
|
|
// In this h264 parser, frame splitting is based on AUD nals.
|
|
|
|
// Mpeg2 TS spec: "2.14 Carriage of Rec. ITU-T H.264 | ISO/IEC 14496-10 video"
|
|
|
|
// "Each AVC access unit shall contain an access unit delimiter NAL Unit;"
|
|
|
|
//
|
2016-03-31 19:48:16 +00:00
|
|
|
class EsParserH264 : public EsParserH26x {
|
2014-04-01 01:34:59 +00:00
|
|
|
public:
|
2014-09-30 21:52:21 +00:00
|
|
|
EsParserH264(uint32_t pid,
|
2014-04-10 19:57:10 +00:00
|
|
|
const NewStreamInfoCB& new_stream_info_cb,
|
2014-04-08 00:39:14 +00:00
|
|
|
const EmitSampleCB& emit_sample_cb);
|
2015-07-22 23:40:45 +00:00
|
|
|
~EsParserH264() override;
|
2014-04-01 01:34:59 +00:00
|
|
|
|
2016-03-31 19:48:16 +00:00
|
|
|
// EsParserH26x implementation override.
|
2015-07-22 23:40:45 +00:00
|
|
|
void Reset() override;
|
2014-04-01 01:34:59 +00:00
|
|
|
|
|
|
|
private:
|
2016-08-25 22:44:25 +00:00
|
|
|
// Processes a NAL unit found in ParseInternal.
|
|
|
|
bool ProcessNalu(const Nalu& nalu, VideoSliceInfo* video_slice_info) override;
|
2014-04-01 01:34:59 +00:00
|
|
|
|
|
|
|
// Update the video decoder config based on an H264 SPS.
|
|
|
|
// Return true if successful.
|
2016-03-31 19:48:16 +00:00
|
|
|
bool UpdateVideoDecoderConfig(int sps_id) override;
|
2022-10-28 03:22:17 +00:00
|
|
|
// Calculate video sample duration based on SPS data
|
|
|
|
int64_t CalculateSampleDuration(int pps_id) override;
|
2016-03-31 19:48:16 +00:00
|
|
|
// Callback to pass the stream configuration.
|
2014-04-10 19:57:10 +00:00
|
|
|
NewStreamInfoCB new_stream_info_cb_;
|
2014-04-01 01:34:59 +00:00
|
|
|
|
2017-01-24 00:55:02 +00:00
|
|
|
std::shared_ptr<StreamInfo> last_video_decoder_config_;
|
2014-04-18 01:57:31 +00:00
|
|
|
bool decoder_config_check_pending_;
|
|
|
|
|
2016-08-17 17:41:40 +00:00
|
|
|
std::unique_ptr<H264Parser> h264_parser_;
|
2014-04-01 01:34:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mp2t
|
|
|
|
} // namespace media
|
2016-05-20 21:19:33 +00:00
|
|
|
} // namespace shaka
|
2014-04-01 01:34:59 +00:00
|
|
|
|
|
|
|
#endif
|