| 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 <set> | 8 #include <set> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 ~MPEGAudioStreamParserBase() override; | 31 ~MPEGAudioStreamParserBase() override; |
| 32 | 32 |
| 33 // StreamParser implementation. | 33 // StreamParser implementation. |
| 34 void Init(const InitCB& init_cb, | 34 void Init(const InitCB& init_cb, |
| 35 const NewConfigCB& config_cb, | 35 const NewConfigCB& config_cb, |
| 36 const NewBuffersCB& new_buffers_cb, | 36 const NewBuffersCB& new_buffers_cb, |
| 37 bool ignore_text_tracks, | 37 bool ignore_text_tracks, |
| 38 const EncryptedMediaInitDataCB& encrypted_media_init_data_cb, | 38 const EncryptedMediaInitDataCB& encrypted_media_init_data_cb, |
| 39 const NewMediaSegmentCB& new_segment_cb, | 39 const NewMediaSegmentCB& new_segment_cb, |
| 40 const base::Closure& end_of_segment_cb, | 40 const base::Closure& end_of_segment_cb, |
| 41 const LogCB& log_cb) override; | 41 const scoped_refptr<MediaLog>& media_log) override; |
| 42 void Flush() override; | 42 void Flush() override; |
| 43 bool Parse(const uint8* buf, int size) override; | 43 bool Parse(const uint8* buf, int size) override; |
| 44 | 44 |
| 45 protected: | 45 protected: |
| 46 // Subclasses implement this method to parse format specific frame headers. | 46 // Subclasses implement this method to parse format specific frame headers. |
| 47 // |data| & |size| describe the data available for parsing. | 47 // |data| & |size| describe the data available for parsing. |
| 48 // | 48 // |
| 49 // Implementations are expected to consume an entire frame header. It should | 49 // Implementations are expected to consume an entire frame header. It should |
| 50 // only return a value greater than 0 when |data| has enough bytes to | 50 // only return a value greater than 0 when |data| has enough bytes to |
| 51 // successfully parse & consume the entire frame header. | 51 // successfully parse & consume the entire frame header. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 74 // 0 : If more data is needed to parse the entire frame header. | 74 // 0 : If more data is needed to parse the entire frame header. |
| 75 // < 0 : An error was encountered during parsing. | 75 // < 0 : An error was encountered during parsing. |
| 76 virtual int ParseFrameHeader(const uint8* data, | 76 virtual int ParseFrameHeader(const uint8* data, |
| 77 int size, | 77 int size, |
| 78 int* frame_size, | 78 int* frame_size, |
| 79 int* sample_rate, | 79 int* sample_rate, |
| 80 ChannelLayout* channel_layout, | 80 ChannelLayout* channel_layout, |
| 81 int* sample_count, | 81 int* sample_count, |
| 82 bool* metadata_frame) const = 0; | 82 bool* metadata_frame) const = 0; |
| 83 | 83 |
| 84 const LogCB& log_cb() const { return log_cb_; } | 84 const scoped_refptr<MediaLog>& media_log() const { return media_log_; } |
| 85 | 85 |
| 86 private: | 86 private: |
| 87 enum State { | 87 enum State { |
| 88 UNINITIALIZED, | 88 UNINITIALIZED, |
| 89 INITIALIZED, | 89 INITIALIZED, |
| 90 PARSE_ERROR | 90 PARSE_ERROR |
| 91 }; | 91 }; |
| 92 | 92 |
| 93 void ChangeState(State state); | 93 void ChangeState(State state); |
| 94 | 94 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 // Returns true if the buffers are sent successfully. | 130 // Returns true if the buffers are sent successfully. |
| 131 bool SendBuffers(BufferQueue* buffers, bool end_of_segment); | 131 bool SendBuffers(BufferQueue* buffers, bool end_of_segment); |
| 132 | 132 |
| 133 State state_; | 133 State state_; |
| 134 | 134 |
| 135 InitCB init_cb_; | 135 InitCB init_cb_; |
| 136 NewConfigCB config_cb_; | 136 NewConfigCB config_cb_; |
| 137 NewBuffersCB new_buffers_cb_; | 137 NewBuffersCB new_buffers_cb_; |
| 138 NewMediaSegmentCB new_segment_cb_; | 138 NewMediaSegmentCB new_segment_cb_; |
| 139 base::Closure end_of_segment_cb_; | 139 base::Closure end_of_segment_cb_; |
| 140 LogCB log_cb_; | 140 scoped_refptr<MediaLog> media_log_; |
| 141 | 141 |
| 142 ByteQueue queue_; | 142 ByteQueue queue_; |
| 143 | 143 |
| 144 AudioDecoderConfig config_; | 144 AudioDecoderConfig config_; |
| 145 scoped_ptr<AudioTimestampHelper> timestamp_helper_; | 145 scoped_ptr<AudioTimestampHelper> timestamp_helper_; |
| 146 bool in_media_segment_; | 146 bool in_media_segment_; |
| 147 const uint32 start_code_mask_; | 147 const uint32 start_code_mask_; |
| 148 const AudioCodec audio_codec_; | 148 const AudioCodec audio_codec_; |
| 149 const int codec_delay_; | 149 const int codec_delay_; |
| 150 | 150 |
| 151 DISALLOW_COPY_AND_ASSIGN(MPEGAudioStreamParserBase); | 151 DISALLOW_COPY_AND_ASSIGN(MPEGAudioStreamParserBase); |
| 152 }; | 152 }; |
| 153 | 153 |
| 154 } // namespace media | 154 } // namespace media |
| 155 | 155 |
| 156 #endif // MEDIA_FORMATS_MPEG_MPEG_AUDIO_STREAM_PARSER_BASE_H_ | 156 #endif // MEDIA_FORMATS_MPEG_MPEG_AUDIO_STREAM_PARSER_BASE_H_ |
| OLD | NEW |