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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 // New stream buffers have been parsed. | 52 // New stream buffers have been parsed. |
53 // First parameter - A queue of newly parsed audio buffers. | 53 // First parameter - A queue of newly parsed audio buffers. |
54 // Second parameter - A queue of newly parsed video buffers. | 54 // Second parameter - A queue of newly parsed video buffers. |
55 // Return value - True indicates that the buffers are accepted. | 55 // Return value - True indicates that the buffers are accepted. |
56 // False if something was wrong with the buffers and a parsing | 56 // False if something was wrong with the buffers and a parsing |
57 // error should be signalled. | 57 // error should be signalled. |
58 typedef base::Callback<bool(const BufferQueue&, | 58 typedef base::Callback<bool(const BufferQueue&, |
59 const BufferQueue&)> NewBuffersCB; | 59 const BufferQueue&)> NewBuffersCB; |
60 | 60 |
61 // New stream buffers of inband text have been parsed. | 61 // New stream buffers of inband text have been parsed. |
62 // First parameter - The text track to which these cues will be added. | 62 // First parameter - The (number of the) text track to which these cues will |
| 63 // be added. |
63 // Second parameter - A queue of newly parsed buffers. | 64 // Second parameter - A queue of newly parsed buffers. |
64 // Return value - True indicates that the buffers are accepted. | 65 // Return value - True indicates that the buffers are accepted. |
65 // False if something was wrong with the buffers and a parsing | 66 // False if something was wrong with the buffers and a parsing |
66 // error should be signalled. | 67 // error should be signalled. |
67 typedef base::Callback<bool(TextTrack*, const BufferQueue&)> NewTextBuffersCB; | 68 typedef base::Callback<bool(int track_number, |
| 69 const BufferQueue&)> NewTextBuffersCB; |
68 | 70 |
69 // Signals the beginning of a new media segment. | 71 // Signals the beginning of a new media segment. |
70 typedef base::Callback<void()> NewMediaSegmentCB; | 72 typedef base::Callback<void()> NewMediaSegmentCB; |
71 | 73 |
72 // A new potentially encrypted stream has been parsed. | 74 // A new potentially encrypted stream has been parsed. |
73 // First parameter - The type of the initialization data associated with the | 75 // First parameter - The type of the initialization data associated with the |
74 // stream. | 76 // stream. |
75 // Second parameter - The initialization data associated with the stream. | 77 // Second parameter - The initialization data associated with the stream. |
76 typedef base::Callback<void(const std::string&, | 78 typedef base::Callback<void(const std::string&, |
77 const std::vector<uint8>&)> NeedKeyCB; | 79 const std::vector<uint8>&)> NeedKeyCB; |
78 | 80 |
| 81 // New text track has been parsed. |
| 82 // First parameter - The track number (from the Track element). |
| 83 // Second parameter - The track kind (inferred from the CodecID). |
| 84 // Third parameter - The track name sub-element value. |
| 85 // Fourth parameter - The track language sub-element value. |
| 86 typedef base::Callback<void(int track_number, |
| 87 TextKind kind, |
| 88 const std::string& name, |
| 89 const std::string& language)> NewTextTrackCB; |
| 90 |
79 // Initialize the parser with necessary callbacks. Must be called before any | 91 // 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 | 92 // data is passed to Parse(). |init_cb| will be called once enough data has |
81 // been parsed to determine the initial stream configurations, presentation | 93 // been parsed to determine the initial stream configurations, presentation |
82 // start time, and duration. | 94 // start time, and duration. |
83 virtual void Init(const InitCB& init_cb, | 95 virtual void Init(const InitCB& init_cb, |
84 const NewConfigCB& config_cb, | 96 const NewConfigCB& config_cb, |
85 const NewBuffersCB& new_buffers_cb, | 97 const NewBuffersCB& new_buffers_cb, |
86 const NewTextBuffersCB& text_cb, | 98 const NewTextBuffersCB& text_cb, |
87 const NeedKeyCB& need_key_cb, | 99 const NeedKeyCB& need_key_cb, |
88 const AddTextTrackCB& add_text_track_cb, | 100 const NewTextTrackCB& new_text_track_cb, |
89 const NewMediaSegmentCB& new_segment_cb, | 101 const NewMediaSegmentCB& new_segment_cb, |
90 const base::Closure& end_of_segment_cb, | 102 const base::Closure& end_of_segment_cb, |
91 const LogCB& log_cb) = 0; | 103 const LogCB& log_cb) = 0; |
92 | 104 |
93 // Called when a seek occurs. This flushes the current parser state | 105 // Called when a seek occurs. This flushes the current parser state |
94 // and puts the parser in a state where it can receive data for the new seek | 106 // and puts the parser in a state where it can receive data for the new seek |
95 // point. | 107 // point. |
96 virtual void Flush() = 0; | 108 virtual void Flush() = 0; |
97 | 109 |
98 // Called when there is new data to parse. | 110 // Called when there is new data to parse. |
99 // | 111 // |
100 // Returns true if the parse succeeds. | 112 // Returns true if the parse succeeds. |
101 virtual bool Parse(const uint8* buf, int size) = 0; | 113 virtual bool Parse(const uint8* buf, int size) = 0; |
102 | 114 |
103 private: | 115 private: |
104 DISALLOW_COPY_AND_ASSIGN(StreamParser); | 116 DISALLOW_COPY_AND_ASSIGN(StreamParser); |
105 }; | 117 }; |
106 | 118 |
107 } // namespace media | 119 } // namespace media |
108 | 120 |
109 #endif // MEDIA_BASE_STREAM_PARSER_H_ | 121 #endif // MEDIA_BASE_STREAM_PARSER_H_ |
OLD | NEW |