| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_BASE_STREAM_PARSER_H_ | 5 #ifndef MEDIA_BASE_STREAM_PARSER_H_ |
| 6 #define MEDIA_BASE_STREAM_PARSER_H_ | 6 #define MEDIA_BASE_STREAM_PARSER_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 // Return value - True indicates that the buffers are accepted. | 99 // Return value - True indicates that the buffers are accepted. |
| 100 // False if something was wrong with the buffers and a parsing | 100 // False if something was wrong with the buffers and a parsing |
| 101 // error should be signalled. | 101 // error should be signalled. |
| 102 typedef base::Callback<bool(const BufferQueue&, | 102 typedef base::Callback<bool(const BufferQueue&, |
| 103 const BufferQueue&, | 103 const BufferQueue&, |
| 104 const TextBufferQueueMap&)> NewBuffersCB; | 104 const TextBufferQueueMap&)> NewBuffersCB; |
| 105 | 105 |
| 106 // Signals the beginning of a new media segment. | 106 // Signals the beginning of a new media segment. |
| 107 typedef base::Callback<void()> NewMediaSegmentCB; | 107 typedef base::Callback<void()> NewMediaSegmentCB; |
| 108 | 108 |
| 109 // Signals the end of a media segment. Returns true if the signal is accepted. |
| 110 // Returns false if something was wrong with segment ending and a parsing |
| 111 // error should be signalled. |
| 112 typedef base::Callback<bool()> EndMediaSegmentCB; |
| 113 |
| 109 // A new potentially encrypted stream has been parsed. | 114 // A new potentially encrypted stream has been parsed. |
| 110 // First parameter - The type of the initialization data associated with the | 115 // First parameter - The type of the initialization data associated with the |
| 111 // stream. | 116 // stream. |
| 112 // Second parameter - The initialization data associated with the stream. | 117 // Second parameter - The initialization data associated with the stream. |
| 113 typedef base::Callback<void(EmeInitDataType, const std::vector<uint8_t>&)> | 118 typedef base::Callback<void(EmeInitDataType, const std::vector<uint8_t>&)> |
| 114 EncryptedMediaInitDataCB; | 119 EncryptedMediaInitDataCB; |
| 115 | 120 |
| 116 StreamParser(); | 121 StreamParser(); |
| 117 virtual ~StreamParser(); | 122 virtual ~StreamParser(); |
| 118 | 123 |
| 119 // Initializes the parser with necessary callbacks. Must be called before any | 124 // Initializes the parser with necessary callbacks. Must be called before any |
| 120 // data is passed to Parse(). |init_cb| will be called once enough data has | 125 // data is passed to Parse(). |init_cb| will be called once enough data has |
| 121 // been parsed to determine the initial stream configurations, presentation | 126 // been parsed to determine the initial stream configurations, presentation |
| 122 // start time, and duration. If |ignore_text_track| is true, then no text | 127 // start time, and duration. If |ignore_text_track| is true, then no text |
| 123 // buffers should be passed later by the parser to |new_buffers_cb|. | 128 // buffers should be passed later by the parser to |new_buffers_cb|. |
| 124 virtual void Init( | 129 virtual void Init( |
| 125 const InitCB& init_cb, | 130 const InitCB& init_cb, |
| 126 const NewConfigCB& config_cb, | 131 const NewConfigCB& config_cb, |
| 127 const NewBuffersCB& new_buffers_cb, | 132 const NewBuffersCB& new_buffers_cb, |
| 128 bool ignore_text_track, | 133 bool ignore_text_track, |
| 129 const EncryptedMediaInitDataCB& encrypted_media_init_data_cb, | 134 const EncryptedMediaInitDataCB& encrypted_media_init_data_cb, |
| 130 const NewMediaSegmentCB& new_segment_cb, | 135 const NewMediaSegmentCB& new_segment_cb, |
| 131 const base::Closure& end_of_segment_cb, | 136 const EndMediaSegmentCB& end_of_segment_cb, |
| 132 const scoped_refptr<MediaLog>& media_log) = 0; | 137 const scoped_refptr<MediaLog>& media_log) = 0; |
| 133 | 138 |
| 134 // Called when a seek occurs. This flushes the current parser state | 139 // Called during the reset parser state algorithm. This flushes the current |
| 135 // and puts the parser in a state where it can receive data for the new seek | 140 // parser and puts the parser in a state where it can receive data. This |
| 136 // point. | 141 // method does not need to invoke the EndMediaSegmentCB since the parser reset |
| 142 // algorithm already resets the segment parsing state. |
| 137 virtual void Flush() = 0; | 143 virtual void Flush() = 0; |
| 138 | 144 |
| 139 // Called when there is new data to parse. | 145 // Called when there is new data to parse. |
| 140 // | 146 // |
| 141 // Returns true if the parse succeeds. | 147 // Returns true if the parse succeeds. |
| 142 virtual bool Parse(const uint8_t* buf, int size) = 0; | 148 virtual bool Parse(const uint8_t* buf, int size) = 0; |
| 143 | 149 |
| 144 private: | 150 private: |
| 145 DISALLOW_COPY_AND_ASSIGN(StreamParser); | 151 DISALLOW_COPY_AND_ASSIGN(StreamParser); |
| 146 }; | 152 }; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 158 // subtle issues with tie-breaking. See http://crbug.com/338484. | 164 // subtle issues with tie-breaking. See http://crbug.com/338484. |
| 159 MEDIA_EXPORT bool MergeBufferQueues( | 165 MEDIA_EXPORT bool MergeBufferQueues( |
| 160 const StreamParser::BufferQueue& audio_buffers, | 166 const StreamParser::BufferQueue& audio_buffers, |
| 161 const StreamParser::BufferQueue& video_buffers, | 167 const StreamParser::BufferQueue& video_buffers, |
| 162 const StreamParser::TextBufferQueueMap& text_buffers, | 168 const StreamParser::TextBufferQueueMap& text_buffers, |
| 163 StreamParser::BufferQueue* merged_buffers); | 169 StreamParser::BufferQueue* merged_buffers); |
| 164 | 170 |
| 165 } // namespace media | 171 } // namespace media |
| 166 | 172 |
| 167 #endif // MEDIA_BASE_STREAM_PARSER_H_ | 173 #endif // MEDIA_BASE_STREAM_PARSER_H_ |
| OLD | NEW |