Shaka Packager SDK
Loading...
Searching...
No Matches
es_parser_h264.h
1// Copyright 2014 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef PACKAGER_MEDIA_FORMATS_MP2T_ES_PARSER_H264_H_
6#define PACKAGER_MEDIA_FORMATS_MP2T_ES_PARSER_H264_H_
7
8#include <cstdint>
9#include <memory>
10
11#include <packager/media/codecs/nalu_reader.h>
12#include <packager/media/formats/mp2t/es_parser.h>
13#include <packager/media/formats/mp2t/es_parser_h26x.h>
14
15namespace shaka {
16namespace media {
17
18class H264Parser;
19
20namespace mp2t {
21
22// Remark:
23// In this h264 parser, frame splitting is based on AUD nals.
24// Mpeg2 TS spec: "2.14 Carriage of Rec. ITU-T H.264 | ISO/IEC 14496-10 video"
25// "Each AVC access unit shall contain an access unit delimiter NAL Unit;"
26//
27class EsParserH264 : public EsParserH26x {
28 public:
29 EsParserH264(uint32_t pid,
30 const NewStreamInfoCB& new_stream_info_cb,
31 const EmitSampleCB& emit_sample_cb);
32 ~EsParserH264() override;
33
34 // EsParserH26x implementation override.
35 void Reset() override;
36
37 private:
38 // Processes a NAL unit found in ParseInternal.
39 bool ProcessNalu(const Nalu& nalu, VideoSliceInfo* video_slice_info) override;
40
41 // Update the video decoder config based on an H264 SPS.
42 // Return true if successful.
43 bool UpdateVideoDecoderConfig(int sps_id) override;
44 // Calculate video sample duration based on SPS data
45 int64_t CalculateSampleDuration(int pps_id) override;
46 // Callback to pass the stream configuration.
47 NewStreamInfoCB new_stream_info_cb_;
48
49 std::shared_ptr<StreamInfo> last_video_decoder_config_;
50 bool decoder_config_check_pending_;
51
52 std::unique_ptr<H264Parser> h264_parser_;
53};
54
55} // namespace mp2t
56} // namespace media
57} // namespace shaka
58
59#endif
All the methods that are virtual are virtual for mocking.