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