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