DASH Media Packaging SDK
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator
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 MEDIA_FORMATS_MP2T_ES_PARSER_H264_H_
6 #define MEDIA_FORMATS_MP2T_ES_PARSER_H264_H_
7 
8 #include <stdint.h>
9 #include <memory>
10 #include "packager/base/callback.h"
11 #include "packager/media/formats/mp2t/es_parser_h26x.h"
12 
13 namespace shaka {
14 namespace media {
15 
16 class H264Parser;
17 
18 namespace mp2t {
19 
20 // Remark:
21 // In this h264 parser, frame splitting is based on AUD nals.
22 // Mpeg2 TS spec: "2.14 Carriage of Rec. ITU-T H.264 | ISO/IEC 14496-10 video"
23 // "Each AVC access unit shall contain an access unit delimiter NAL Unit;"
24 //
25 class EsParserH264 : public EsParserH26x {
26  public:
27  EsParserH264(uint32_t pid,
28  const NewStreamInfoCB& new_stream_info_cb,
29  const EmitSampleCB& emit_sample_cb);
30  ~EsParserH264() override;
31 
32  // EsParserH26x implementation override.
33  void Reset() override;
34 
35  private:
36  // Processes a NAL unit found in ParseInternal. The @a pps_id_for_access_unit
37  // value will be passed to UpdateVideoDecoderConfig.
38  bool ProcessNalu(const Nalu& nalu,
39  bool* is_key_frame,
40  int* pps_id_for_access_unit) override;
41 
42  // Update the video decoder config based on an H264 SPS.
43  // Return true if successful.
44  bool UpdateVideoDecoderConfig(int sps_id) override;
45 
46  // Callback to pass the stream configuration.
47  NewStreamInfoCB new_stream_info_cb_;
48 
49  scoped_refptr<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