| 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_MPEG_MPEG_AUDIO_STREAM_PARSER_BASE_H_ | 5 #ifndef MEDIA_FORMATS_MPEG_MPEG_AUDIO_STREAM_PARSER_BASE_H_ |
| 6 #define MEDIA_FORMATS_MPEG_MPEG_AUDIO_STREAM_PARSER_BASE_H_ | 6 #define MEDIA_FORMATS_MPEG_MPEG_AUDIO_STREAM_PARSER_BASE_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <set> | 10 #include <set> |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 int codec_delay); | 32 int codec_delay); |
| 33 ~MPEGAudioStreamParserBase() override; | 33 ~MPEGAudioStreamParserBase() override; |
| 34 | 34 |
| 35 // StreamParser implementation. | 35 // StreamParser implementation. |
| 36 void Init(const InitCB& init_cb, | 36 void Init(const InitCB& init_cb, |
| 37 const NewConfigCB& config_cb, | 37 const NewConfigCB& config_cb, |
| 38 const NewBuffersCB& new_buffers_cb, | 38 const NewBuffersCB& new_buffers_cb, |
| 39 bool ignore_text_tracks, | 39 bool ignore_text_tracks, |
| 40 const EncryptedMediaInitDataCB& encrypted_media_init_data_cb, | 40 const EncryptedMediaInitDataCB& encrypted_media_init_data_cb, |
| 41 const NewMediaSegmentCB& new_segment_cb, | 41 const NewMediaSegmentCB& new_segment_cb, |
| 42 const base::Closure& end_of_segment_cb, | 42 const EndMediaSegmentCB& end_of_segment_cb, |
| 43 const scoped_refptr<MediaLog>& media_log) override; | 43 const scoped_refptr<MediaLog>& media_log) override; |
| 44 void Flush() override; | 44 void Flush() override; |
| 45 bool Parse(const uint8_t* buf, int size) override; | 45 bool Parse(const uint8_t* buf, int size) override; |
| 46 | 46 |
| 47 protected: | 47 protected: |
| 48 // Subclasses implement this method to parse format specific frame headers. | 48 // Subclasses implement this method to parse format specific frame headers. |
| 49 // |data| & |size| describe the data available for parsing. | 49 // |data| & |size| describe the data available for parsing. |
| 50 // | 50 // |
| 51 // Implementations are expected to consume an entire frame header. It should | 51 // Implementations are expected to consume an entire frame header. It should |
| 52 // only return a value greater than 0 when |data| has enough bytes to | 52 // only return a value greater than 0 when |data| has enough bytes to |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 // next start code.. | 122 // next start code.. |
| 123 // 0 : If a valid start code was not found and more data is needed. | 123 // 0 : If a valid start code was not found and more data is needed. |
| 124 // < 0 : An error was encountered during parsing. | 124 // < 0 : An error was encountered during parsing. |
| 125 int FindNextValidStartCode(const uint8_t* data, int size) const; | 125 int FindNextValidStartCode(const uint8_t* data, int size) const; |
| 126 | 126 |
| 127 // Sends the buffers in |buffers| to |new_buffers_cb_| and then clears | 127 // Sends the buffers in |buffers| to |new_buffers_cb_| and then clears |
| 128 // |buffers|. | 128 // |buffers|. |
| 129 // If |end_of_segment| is set to true, then |end_of_segment_cb_| is called | 129 // If |end_of_segment| is set to true, then |end_of_segment_cb_| is called |
| 130 // after |new_buffers_cb_| to signal that these buffers represent the end of a | 130 // after |new_buffers_cb_| to signal that these buffers represent the end of a |
| 131 // media segment. | 131 // media segment. |
| 132 // Returns true if the buffers are sent successfully. | 132 // Returns true if the buffers (and the optional end of segment signal) are |
| 133 // sent successfully. |
| 133 bool SendBuffers(BufferQueue* buffers, bool end_of_segment); | 134 bool SendBuffers(BufferQueue* buffers, bool end_of_segment); |
| 134 | 135 |
| 135 State state_; | 136 State state_; |
| 136 | 137 |
| 137 InitCB init_cb_; | 138 InitCB init_cb_; |
| 138 NewConfigCB config_cb_; | 139 NewConfigCB config_cb_; |
| 139 NewBuffersCB new_buffers_cb_; | 140 NewBuffersCB new_buffers_cb_; |
| 140 NewMediaSegmentCB new_segment_cb_; | 141 NewMediaSegmentCB new_segment_cb_; |
| 141 base::Closure end_of_segment_cb_; | 142 EndMediaSegmentCB end_of_segment_cb_; |
| 142 scoped_refptr<MediaLog> media_log_; | 143 scoped_refptr<MediaLog> media_log_; |
| 143 | 144 |
| 144 ByteQueue queue_; | 145 ByteQueue queue_; |
| 145 | 146 |
| 146 AudioDecoderConfig config_; | 147 AudioDecoderConfig config_; |
| 147 scoped_ptr<AudioTimestampHelper> timestamp_helper_; | 148 scoped_ptr<AudioTimestampHelper> timestamp_helper_; |
| 148 bool in_media_segment_; | 149 bool in_media_segment_; |
| 149 const uint32_t start_code_mask_; | 150 const uint32_t start_code_mask_; |
| 150 const AudioCodec audio_codec_; | 151 const AudioCodec audio_codec_; |
| 151 const int codec_delay_; | 152 const int codec_delay_; |
| 152 | 153 |
| 153 DISALLOW_COPY_AND_ASSIGN(MPEGAudioStreamParserBase); | 154 DISALLOW_COPY_AND_ASSIGN(MPEGAudioStreamParserBase); |
| 154 }; | 155 }; |
| 155 | 156 |
| 156 } // namespace media | 157 } // namespace media |
| 157 | 158 |
| 158 #endif // MEDIA_FORMATS_MPEG_MPEG_AUDIO_STREAM_PARSER_BASE_H_ | 159 #endif // MEDIA_FORMATS_MPEG_MPEG_AUDIO_STREAM_PARSER_BASE_H_ |
| OLD | NEW |