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_FILTERS_SOURCE_BUFFER_STREAM_H_ | 5 #ifndef MEDIA_FILTERS_SOURCE_BUFFER_STREAM_H_ |
6 #define MEDIA_FILTERS_SOURCE_BUFFER_STREAM_H_ | 6 #define MEDIA_FILTERS_SOURCE_BUFFER_STREAM_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 #include <list> | 9 #include <list> |
10 #include <utility> | 10 #include <utility> |
11 | 11 |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "media/base/audio_decoder_config.h" | 13 #include "media/base/audio_decoder_config.h" |
14 #include "media/base/media_export.h" | 14 #include "media/base/media_export.h" |
| 15 #include "media/base/ranges.h" |
15 #include "media/base/stream_parser_buffer.h" | 16 #include "media/base/stream_parser_buffer.h" |
16 #include "media/base/video_decoder_config.h" | 17 #include "media/base/video_decoder_config.h" |
17 | 18 |
18 namespace media { | 19 namespace media { |
19 | 20 |
20 class SourceBufferRange; | 21 class SourceBufferRange; |
21 | 22 |
22 // SourceBufferStream is a data structure that stores media Buffers in ranges. | 23 // SourceBufferStream is a data structure that stores media Buffers in ranges. |
23 // Buffers can be appended out of presentation order. Buffers are retrieved by | 24 // Buffers can be appended out of presentation order. Buffers are retrieved by |
24 // seeking to the desired start point and calling GetNextBuffer(). Buffers are | 25 // seeking to the desired start point and calling GetNextBuffer(). Buffers are |
25 // returned in sequential presentation order. | 26 // returned in sequential presentation order. |
26 class MEDIA_EXPORT SourceBufferStream { | 27 class MEDIA_EXPORT SourceBufferStream { |
27 public: | 28 public: |
28 typedef std::deque<scoped_refptr<StreamParserBuffer> > BufferQueue; | 29 typedef std::deque<scoped_refptr<StreamParserBuffer> > BufferQueue; |
29 typedef std::pair<base::TimeDelta, base::TimeDelta> Timespan; | |
30 typedef std::deque<Timespan> TimespanList; | |
31 | 30 |
32 SourceBufferStream(); | 31 SourceBufferStream(); |
33 explicit SourceBufferStream(const AudioDecoderConfig& audio_config); | 32 explicit SourceBufferStream(const AudioDecoderConfig& audio_config); |
34 explicit SourceBufferStream(const VideoDecoderConfig& video_config); | 33 explicit SourceBufferStream(const VideoDecoderConfig& video_config); |
35 | 34 |
36 ~SourceBufferStream(); | 35 ~SourceBufferStream(); |
37 | 36 |
38 // Add the |buffers| to the SourceBufferStream. Buffers within the queue are | 37 // Add the |buffers| to the SourceBufferStream. Buffers within the queue are |
39 // expected to be in order, but multiple calls to Append() may add buffers out | 38 // expected to be in order, but multiple calls to Append() may add buffers out |
40 // of order or overlapping. Assumes all buffers within |buffers| are in | 39 // of order or overlapping. Assumes all buffers within |buffers| are in |
(...skipping 16 matching lines...) Expand all Loading... |
57 // Fills |out_buffer| with a new buffer. Buffers are presented in order from | 56 // Fills |out_buffer| with a new buffer. Buffers are presented in order from |
58 // the last call to Seek(), or starting with the first buffer appended if | 57 // the last call to Seek(), or starting with the first buffer appended if |
59 // Seek() has not been called yet. | 58 // Seek() has not been called yet. |
60 // |out_buffer|'s timestamp may be earlier than the |timestamp| passed to | 59 // |out_buffer|'s timestamp may be earlier than the |timestamp| passed to |
61 // the last Seek() call. | 60 // the last Seek() call. |
62 // Returns true if |out_buffer| is filled with a valid buffer, false if | 61 // Returns true if |out_buffer| is filled with a valid buffer, false if |
63 // there is not enough data buffered to fulfill the request. | 62 // there is not enough data buffered to fulfill the request. |
64 bool GetNextBuffer(scoped_refptr<StreamParserBuffer>* out_buffer); | 63 bool GetNextBuffer(scoped_refptr<StreamParserBuffer>* out_buffer); |
65 | 64 |
66 // Returns a list of the buffered time ranges. | 65 // Returns a list of the buffered time ranges. |
67 TimespanList GetBufferedTime() const; | 66 Ranges<base::TimeDelta> GetBufferedTime() const; |
68 | 67 |
69 // Notifies this SourceBufferStream that EndOfStream has been called and that | 68 // Notifies this SourceBufferStream that EndOfStream has been called and that |
70 // GetNextBuffer() should return EOS buffers after all other buffered data. | 69 // GetNextBuffer() should return EOS buffers after all other buffered data. |
71 // Returns false if called when there is a gap between the current position | 70 // Returns false if called when there is a gap between the current position |
72 // and the end of the buffered data. | 71 // and the end of the buffered data. |
73 void EndOfStream(); | 72 void EndOfStream(); |
74 | 73 |
75 // Returns true if this SourceBufferStream can successfully call EndOfStream() | 74 // Returns true if this SourceBufferStream can successfully call EndOfStream() |
76 // (if there are no gaps between the current position and the remaining data). | 75 // (if there are no gaps between the current position and the remaining data). |
77 bool CanEndOfStream() const; | 76 bool CanEndOfStream() const; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 // True when EndOfStream() has been called and GetNextBuffer() should return | 142 // True when EndOfStream() has been called and GetNextBuffer() should return |
144 // EOS buffers for read requests beyond the buffered data. False initially. | 143 // EOS buffers for read requests beyond the buffered data. False initially. |
145 bool end_of_stream_; | 144 bool end_of_stream_; |
146 | 145 |
147 DISALLOW_COPY_AND_ASSIGN(SourceBufferStream); | 146 DISALLOW_COPY_AND_ASSIGN(SourceBufferStream); |
148 }; | 147 }; |
149 | 148 |
150 } // namespace media | 149 } // namespace media |
151 | 150 |
152 #endif // MEDIA_FILTERS_SOURCE_BUFFER_STREAM_H_ | 151 #endif // MEDIA_FILTERS_SOURCE_BUFFER_STREAM_H_ |
OLD | NEW |