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. |
| 110 typedef base::Callback<void()> EndMediaSegmentCB; |
| 111 |
109 // A new potentially encrypted stream has been parsed. | 112 // A new potentially encrypted stream has been parsed. |
110 // First parameter - The type of the initialization data associated with the | 113 // First parameter - The type of the initialization data associated with the |
111 // stream. | 114 // stream. |
112 // Second parameter - The initialization data associated with the stream. | 115 // Second parameter - The initialization data associated with the stream. |
113 typedef base::Callback<void(EmeInitDataType, const std::vector<uint8_t>&)> | 116 typedef base::Callback<void(EmeInitDataType, const std::vector<uint8_t>&)> |
114 EncryptedMediaInitDataCB; | 117 EncryptedMediaInitDataCB; |
115 | 118 |
116 StreamParser(); | 119 StreamParser(); |
117 virtual ~StreamParser(); | 120 virtual ~StreamParser(); |
118 | 121 |
119 // Initializes the parser with necessary callbacks. Must be called before any | 122 // 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 | 123 // data is passed to Parse(). |init_cb| will be called once enough data has |
121 // been parsed to determine the initial stream configurations, presentation | 124 // been parsed to determine the initial stream configurations, presentation |
122 // start time, and duration. If |ignore_text_track| is true, then no text | 125 // 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|. | 126 // buffers should be passed later by the parser to |new_buffers_cb|. |
124 virtual void Init( | 127 virtual void Init( |
125 const InitCB& init_cb, | 128 const InitCB& init_cb, |
126 const NewConfigCB& config_cb, | 129 const NewConfigCB& config_cb, |
127 const NewBuffersCB& new_buffers_cb, | 130 const NewBuffersCB& new_buffers_cb, |
128 bool ignore_text_track, | 131 bool ignore_text_track, |
129 const EncryptedMediaInitDataCB& encrypted_media_init_data_cb, | 132 const EncryptedMediaInitDataCB& encrypted_media_init_data_cb, |
130 const NewMediaSegmentCB& new_segment_cb, | 133 const NewMediaSegmentCB& new_segment_cb, |
131 const base::Closure& end_of_segment_cb, | 134 const EndMediaSegmentCB& end_of_segment_cb, |
132 const scoped_refptr<MediaLog>& media_log) = 0; | 135 const scoped_refptr<MediaLog>& media_log) = 0; |
133 | 136 |
134 // Called when a seek occurs. This flushes the current parser state | 137 // 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 | 138 // parser and puts the parser in a state where it can receive data. This |
136 // point. | 139 // method does not need to invoke the EndMediaSegmentCB since the parser reset |
| 140 // algorithm already resets the segment parsing state. |
137 virtual void Flush() = 0; | 141 virtual void Flush() = 0; |
138 | 142 |
139 // Called when there is new data to parse. | 143 // Called when there is new data to parse. |
140 // | 144 // |
141 // Returns true if the parse succeeds. | 145 // Returns true if the parse succeeds. |
142 virtual bool Parse(const uint8_t* buf, int size) = 0; | 146 virtual bool Parse(const uint8_t* buf, int size) = 0; |
143 | 147 |
144 private: | 148 private: |
145 DISALLOW_COPY_AND_ASSIGN(StreamParser); | 149 DISALLOW_COPY_AND_ASSIGN(StreamParser); |
146 }; | 150 }; |
(...skipping 11 matching lines...) Expand all Loading... |
158 // subtle issues with tie-breaking. See http://crbug.com/338484. | 162 // subtle issues with tie-breaking. See http://crbug.com/338484. |
159 MEDIA_EXPORT bool MergeBufferQueues( | 163 MEDIA_EXPORT bool MergeBufferQueues( |
160 const StreamParser::BufferQueue& audio_buffers, | 164 const StreamParser::BufferQueue& audio_buffers, |
161 const StreamParser::BufferQueue& video_buffers, | 165 const StreamParser::BufferQueue& video_buffers, |
162 const StreamParser::TextBufferQueueMap& text_buffers, | 166 const StreamParser::TextBufferQueueMap& text_buffers, |
163 StreamParser::BufferQueue* merged_buffers); | 167 StreamParser::BufferQueue* merged_buffers); |
164 | 168 |
165 } // namespace media | 169 } // namespace media |
166 | 170 |
167 #endif // MEDIA_BASE_STREAM_PARSER_H_ | 171 #endif // MEDIA_BASE_STREAM_PARSER_H_ |
OLD | NEW |