OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef MEDIA_FORMATS_MP2T_ES_PARSER_H264_H_ | 5 #ifndef MEDIA_FORMATS_MP2T_ES_PARSER_H264_H_ |
6 #define MEDIA_FORMATS_MP2T_ES_PARSER_H264_H_ | 6 #define MEDIA_FORMATS_MP2T_ES_PARSER_H264_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/time/time.h" | 15 #include "base/time/time.h" |
16 #include "media/base/media_export.h" | 16 #include "media/base/media_export.h" |
17 #include "media/base/video_decoder_config.h" | 17 #include "media/base/video_decoder_config.h" |
18 #include "media/formats/mp2t/es_parser.h" | 18 #include "media/formats/mp2t/es_parser.h" |
19 | 19 |
20 namespace media { | 20 namespace media { |
21 class H264Parser; | 21 class H264Parser; |
22 struct H264SPS; | 22 struct H264SPS; |
23 class OffsetByteQueue; | 23 class OffsetByteQueue; |
24 } | 24 } |
25 | 25 |
26 namespace media { | 26 namespace media { |
27 namespace mp2t { | 27 namespace mp2t { |
28 | 28 |
29 class EsAdapterVideo; | |
30 | |
29 // Remark: | 31 // Remark: |
30 // In this h264 parser, frame splitting is based on AUD nals. | 32 // In this h264 parser, frame splitting is based on AUD nals. |
31 // Mpeg2 TS spec: "2.14 Carriage of Rec. ITU-T H.264 | ISO/IEC 14496-10 video" | 33 // Mpeg2 TS spec: "2.14 Carriage of Rec. ITU-T H.264 | ISO/IEC 14496-10 video" |
32 // "Each AVC access unit shall contain an access unit delimiter NAL Unit;" | 34 // "Each AVC access unit shall contain an access unit delimiter NAL Unit;" |
33 // | 35 // |
34 class MEDIA_EXPORT EsParserH264 : NON_EXPORTED_BASE(public EsParser) { | 36 class MEDIA_EXPORT EsParserH264 : NON_EXPORTED_BASE(public EsParser) { |
35 public: | 37 public: |
36 typedef base::Callback<void(const VideoDecoderConfig&)> NewVideoConfigCB; | 38 typedef base::Callback<void(const VideoDecoderConfig&)> NewVideoConfigCB; |
37 | 39 |
38 EsParserH264(const NewVideoConfigCB& new_video_config_cb, | 40 EsParserH264(const NewVideoConfigCB& new_video_config_cb, |
(...skipping 26 matching lines...) Expand all Loading... | |
65 | 67 |
66 // Emit a frame whose position in the ES queue starts at |access_unit_pos|. | 68 // Emit a frame whose position in the ES queue starts at |access_unit_pos|. |
67 // Returns true if successful, false if no PTS is available for the frame. | 69 // Returns true if successful, false if no PTS is available for the frame. |
68 bool EmitFrame(int64 access_unit_pos, int access_unit_size, | 70 bool EmitFrame(int64 access_unit_pos, int access_unit_size, |
69 bool is_key_frame, int pps_id); | 71 bool is_key_frame, int pps_id); |
70 | 72 |
71 // Update the video decoder config based on an H264 SPS. | 73 // Update the video decoder config based on an H264 SPS. |
72 // Return true if successful. | 74 // Return true if successful. |
73 bool UpdateVideoDecoderConfig(const H264SPS* sps); | 75 bool UpdateVideoDecoderConfig(const H264SPS* sps); |
74 | 76 |
75 // Callbacks to pass the stream configuration and the frames. | 77 scoped_ptr<EsAdapterVideo> es_adapter_; |
scherkus (not reviewing)
2014/07/10 20:45:34
any reason why this needs to be a scoped_ptr<>?
i
damienv1
2014/07/10 22:53:42
I used to have a reset before, then changed it bas
| |
76 NewVideoConfigCB new_video_config_cb_; | |
77 EmitBufferCB emit_buffer_cb_; | |
78 | 78 |
79 // Bytes of the ES stream that have not been emitted yet. | 79 // Bytes of the ES stream that have not been emitted yet. |
80 scoped_ptr<media::OffsetByteQueue> es_queue_; | 80 scoped_ptr<media::OffsetByteQueue> es_queue_; |
81 std::list<std::pair<int64, TimingDesc> > timing_desc_list_; | 81 std::list<std::pair<int64, TimingDesc> > timing_desc_list_; |
82 | 82 |
83 // H264 parser state. | 83 // H264 parser state. |
84 // - |current_access_unit_pos_| is pointing to an annexB syncword | 84 // - |current_access_unit_pos_| is pointing to an annexB syncword |
85 // representing the first NALU of an H264 access unit. | 85 // representing the first NALU of an H264 access unit. |
86 scoped_ptr<H264Parser> h264_parser_; | 86 scoped_ptr<H264Parser> h264_parser_; |
87 int64 current_access_unit_pos_; | 87 int64 current_access_unit_pos_; |
88 int64 next_access_unit_pos_; | 88 int64 next_access_unit_pos_; |
89 | 89 |
90 // Last video decoder config. | 90 // Last video decoder config. |
91 VideoDecoderConfig last_video_decoder_config_; | 91 VideoDecoderConfig last_video_decoder_config_; |
92 | |
93 DISALLOW_COPY_AND_ASSIGN(EsParserH264); | |
92 }; | 94 }; |
93 | 95 |
94 } // namespace mp2t | 96 } // namespace mp2t |
95 } // namespace media | 97 } // namespace media |
96 | 98 |
97 #endif | 99 #endif |
98 | 100 |
OLD | NEW |