| 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 <deque> | 8 #include <deque> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 // then it means that there isn't an audio stream. | 43 // then it means that there isn't an audio stream. |
| 44 // Second parameter - The new video configuration. If the config is not valid | 44 // Second parameter - The new video configuration. If the config is not valid |
| 45 // then it means that there isn't an audio stream. | 45 // then it means that there isn't an audio stream. |
| 46 // Return value - True if the new configurations are accepted. | 46 // Return value - True if the new configurations are accepted. |
| 47 // False if the new configurations are not supported | 47 // False if the new configurations are not supported |
| 48 // and indicates that a parsing error should be signalled. | 48 // and indicates that a parsing error should be signalled. |
| 49 typedef base::Callback<bool(const AudioDecoderConfig&, | 49 typedef base::Callback<bool(const AudioDecoderConfig&, |
| 50 const VideoDecoderConfig&)> NewConfigCB; | 50 const VideoDecoderConfig&)> NewConfigCB; |
| 51 | 51 |
| 52 // New stream buffers have been parsed. | 52 // New stream buffers have been parsed. |
| 53 // First parameter - A queue of newly parsed buffers. | 53 // First parameter - A queue of newly parsed audio buffers. |
| 54 // Second parameter - A queue of newly parsed video buffers. |
| 54 // Return value - True indicates that the buffers are accepted. | 55 // Return value - True indicates that the buffers are accepted. |
| 55 // False if something was wrong with the buffers and a parsing | 56 // False if something was wrong with the buffers and a parsing |
| 56 // error should be signalled. | 57 // error should be signalled. |
| 57 typedef base::Callback<bool(const BufferQueue&)> NewBuffersCB; | 58 typedef base::Callback<bool(const BufferQueue&, |
| 59 const BufferQueue&)> NewBuffersCB; |
| 58 | 60 |
| 59 // New stream buffers of inband text have been parsed. | 61 // New stream buffers of inband text have been parsed. |
| 60 // First parameter - The text track to which these cues will be added. | 62 // First parameter - The text track to which these cues will be added. |
| 61 // Second parameter - A queue of newly parsed buffers. | 63 // Second parameter - A queue of newly parsed buffers. |
| 62 // Return value - True indicates that the buffers are accepted. | 64 // Return value - True indicates that the buffers are accepted. |
| 63 // False if something was wrong with the buffers and a parsing | 65 // False if something was wrong with the buffers and a parsing |
| 64 // error should be signalled. | 66 // error should be signalled. |
| 65 typedef base::Callback<bool(TextTrack*, const BufferQueue&)> NewTextBuffersCB; | 67 typedef base::Callback<bool(TextTrack*, const BufferQueue&)> NewTextBuffersCB; |
| 66 | 68 |
| 67 // Signals the beginning of a new media segment. | 69 // Signals the beginning of a new media segment. |
| 68 // First parameter - The earliest timestamp of all the streams in the segment. | 70 // First parameter - The earliest timestamp of all the streams in the segment. |
| 69 typedef base::Callback<void(base::TimeDelta)> NewMediaSegmentCB; | 71 typedef base::Callback<void(base::TimeDelta)> NewMediaSegmentCB; |
| 70 | 72 |
| 71 // A new potentially encrypted stream has been parsed. | 73 // A new potentially encrypted stream has been parsed. |
| 72 // First parameter - The type of the initialization data associated with the | 74 // First parameter - The type of the initialization data associated with the |
| 73 // stream. | 75 // stream. |
| 74 // Second parameter - The initialization data associated with the stream. | 76 // Second parameter - The initialization data associated with the stream. |
| 75 // Third parameter - Number of bytes of the initialization data. | 77 // Third parameter - Number of bytes of the initialization data. |
| 76 typedef base::Callback<void(const std::string&, | 78 typedef base::Callback<void(const std::string&, |
| 77 scoped_ptr<uint8[]>, int)> NeedKeyCB; | 79 scoped_ptr<uint8[]>, int)> NeedKeyCB; |
| 78 | 80 |
| 79 // Initialize the parser with necessary callbacks. Must be called before any | 81 // Initialize the parser with necessary callbacks. Must be called before any |
| 80 // data is passed to Parse(). |init_cb| will be called once enough data has | 82 // data is passed to Parse(). |init_cb| will be called once enough data has |
| 81 // been parsed to determine the initial stream configurations, presentation | 83 // been parsed to determine the initial stream configurations, presentation |
| 82 // start time, and duration. | 84 // start time, and duration. |
| 83 virtual void Init(const InitCB& init_cb, | 85 virtual void Init(const InitCB& init_cb, |
| 84 const NewConfigCB& config_cb, | 86 const NewConfigCB& config_cb, |
| 85 const NewBuffersCB& audio_cb, | 87 const NewBuffersCB& new_buffers_cb, |
| 86 const NewBuffersCB& video_cb, | |
| 87 const NewTextBuffersCB& text_cb, | 88 const NewTextBuffersCB& text_cb, |
| 88 const NeedKeyCB& need_key_cb, | 89 const NeedKeyCB& need_key_cb, |
| 89 const AddTextTrackCB& add_text_track_cb, | 90 const AddTextTrackCB& add_text_track_cb, |
| 90 const NewMediaSegmentCB& new_segment_cb, | 91 const NewMediaSegmentCB& new_segment_cb, |
| 91 const base::Closure& end_of_segment_cb, | 92 const base::Closure& end_of_segment_cb, |
| 92 const LogCB& log_cb) = 0; | 93 const LogCB& log_cb) = 0; |
| 93 | 94 |
| 94 // Called when a seek occurs. This flushes the current parser state | 95 // Called when a seek occurs. This flushes the current parser state |
| 95 // and puts the parser in a state where it can receive data for the new seek | 96 // and puts the parser in a state where it can receive data for the new seek |
| 96 // point. | 97 // point. |
| 97 virtual void Flush() = 0; | 98 virtual void Flush() = 0; |
| 98 | 99 |
| 99 // Called when there is new data to parse. | 100 // Called when there is new data to parse. |
| 100 // | 101 // |
| 101 // Returns true if the parse succeeds. | 102 // Returns true if the parse succeeds. |
| 102 virtual bool Parse(const uint8* buf, int size) = 0; | 103 virtual bool Parse(const uint8* buf, int size) = 0; |
| 103 | 104 |
| 104 private: | 105 private: |
| 105 DISALLOW_COPY_AND_ASSIGN(StreamParser); | 106 DISALLOW_COPY_AND_ASSIGN(StreamParser); |
| 106 }; | 107 }; |
| 107 | 108 |
| 108 } // namespace media | 109 } // namespace media |
| 109 | 110 |
| 110 #endif // MEDIA_BASE_STREAM_PARSER_H_ | 111 #endif // MEDIA_BASE_STREAM_PARSER_H_ |
| OLD | NEW |