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