| 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 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 // | 34 // |
| 35 class MEDIA_EXPORT EsParserH264 : public EsParser { | 35 class MEDIA_EXPORT EsParserH264 : public EsParser { |
| 36 public: | 36 public: |
| 37 typedef base::Callback<void(const VideoDecoderConfig&)> NewVideoConfigCB; | 37 typedef base::Callback<void(const VideoDecoderConfig&)> NewVideoConfigCB; |
| 38 | 38 |
| 39 EsParserH264(const NewVideoConfigCB& new_video_config_cb, | 39 EsParserH264(const NewVideoConfigCB& new_video_config_cb, |
| 40 const EmitBufferCB& emit_buffer_cb); | 40 const EmitBufferCB& emit_buffer_cb); |
| 41 virtual ~EsParserH264(); | 41 virtual ~EsParserH264(); |
| 42 | 42 |
| 43 // EsParser implementation. | 43 // EsParser implementation. |
| 44 virtual bool Parse(const uint8* buf, int size, | |
| 45 base::TimeDelta pts, | |
| 46 DecodeTimestamp dts) OVERRIDE; | |
| 47 virtual void Flush() OVERRIDE; | 44 virtual void Flush() OVERRIDE; |
| 48 virtual void Reset() OVERRIDE; | 45 virtual void Reset() OVERRIDE; |
| 49 | 46 |
| 50 private: | 47 private: |
| 51 struct TimingDesc { | 48 // EsParser implementation. |
| 52 DecodeTimestamp dts; | 49 virtual bool ParseFromEsQueue() OVERRIDE; |
| 53 base::TimeDelta pts; | |
| 54 }; | |
| 55 | 50 |
| 56 // Find the AUD located at or after |*stream_pos|. | 51 // Find the AUD located at or after |*stream_pos|. |
| 57 // Return true if an AUD is found. | 52 // Return true if an AUD is found. |
| 58 // If found, |*stream_pos| corresponds to the position of the AUD start code | 53 // If found, |*stream_pos| corresponds to the position of the AUD start code |
| 59 // in the stream. Otherwise, |*stream_pos| corresponds to the last position | 54 // in the stream. Otherwise, |*stream_pos| corresponds to the last position |
| 60 // of the start code parser. | 55 // of the start code parser. |
| 61 bool FindAUD(int64* stream_pos); | 56 bool FindAUD(int64* stream_pos); |
| 62 | 57 |
| 63 // Resumes the H264 ES parsing. | |
| 64 // Return true if successful. | |
| 65 bool ParseInternal(); | |
| 66 | |
| 67 // Emit a frame whose position in the ES queue starts at |access_unit_pos|. | 58 // Emit a frame whose position in the ES queue starts at |access_unit_pos|. |
| 68 // Returns true if successful, false if no PTS is available for the frame. | 59 // Returns true if successful, false if no PTS is available for the frame. |
| 69 bool EmitFrame(int64 access_unit_pos, int access_unit_size, | 60 bool EmitFrame(int64 access_unit_pos, int access_unit_size, |
| 70 bool is_key_frame, int pps_id); | 61 bool is_key_frame, int pps_id); |
| 71 | 62 |
| 72 // Update the video decoder config based on an H264 SPS. | 63 // Update the video decoder config based on an H264 SPS. |
| 73 // Return true if successful. | 64 // Return true if successful. |
| 74 bool UpdateVideoDecoderConfig(const H264SPS* sps); | 65 bool UpdateVideoDecoderConfig(const H264SPS* sps); |
| 75 | 66 |
| 76 EsAdapterVideo es_adapter_; | 67 EsAdapterVideo es_adapter_; |
| 77 | 68 |
| 78 // Bytes of the ES stream that have not been emitted yet. | |
| 79 scoped_ptr<media::OffsetByteQueue> es_queue_; | |
| 80 std::list<std::pair<int64, TimingDesc> > timing_desc_list_; | |
| 81 | |
| 82 // H264 parser state. | 69 // H264 parser state. |
| 83 // - |current_access_unit_pos_| is pointing to an annexB syncword | 70 // - |current_access_unit_pos_| is pointing to an annexB syncword |
| 84 // representing the first NALU of an H264 access unit. | 71 // representing the first NALU of an H264 access unit. |
| 85 scoped_ptr<H264Parser> h264_parser_; | 72 scoped_ptr<H264Parser> h264_parser_; |
| 86 int64 current_access_unit_pos_; | 73 int64 current_access_unit_pos_; |
| 87 int64 next_access_unit_pos_; | 74 int64 next_access_unit_pos_; |
| 88 | 75 |
| 89 // Last video decoder config. | 76 // Last video decoder config. |
| 90 VideoDecoderConfig last_video_decoder_config_; | 77 VideoDecoderConfig last_video_decoder_config_; |
| 91 | 78 |
| 92 DISALLOW_COPY_AND_ASSIGN(EsParserH264); | 79 DISALLOW_COPY_AND_ASSIGN(EsParserH264); |
| 93 }; | 80 }; |
| 94 | 81 |
| 95 } // namespace mp2t | 82 } // namespace mp2t |
| 96 } // namespace media | 83 } // namespace media |
| 97 | 84 |
| 98 #endif | 85 #endif |
| OLD | NEW |