OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_BLINK_MULTIBUFFER_H_ | 5 #ifndef MEDIA_BLINK_MULTIBUFFER_H_ |
6 #define MEDIA_BLINK_MULTIBUFFER_H_ | 6 #define MEDIA_BLINK_MULTIBUFFER_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
107 virtual ~DataProvider() {} | 107 virtual ~DataProvider() {} |
108 | 108 |
109 // Returns the block number that is to be returned | 109 // Returns the block number that is to be returned |
110 // by the next Read() call. | 110 // by the next Read() call. |
111 virtual MultiBufferBlockId Tell() const = 0; | 111 virtual MultiBufferBlockId Tell() const = 0; |
112 | 112 |
113 // Returns true if one (or more) blocks are | 113 // Returns true if one (or more) blocks are |
114 // availble to read. | 114 // availble to read. |
115 virtual bool Available() const = 0; | 115 virtual bool Available() const = 0; |
116 | 116 |
117 // Returns how many bytes are available, note that Available() may still | |
118 // return false even if AvailableBytes() returns true. | |
liberato (no reviews please)
2016/05/13 17:45:54
s/true./greater than zero, if less than a full blo
hubbe
2016/05/13 17:51:36
Done.
| |
119 virtual int64_t AvailableBytes() const = 0; | |
120 | |
117 // Returns the next block. Only valid if Available() | 121 // Returns the next block. Only valid if Available() |
118 // returns true. Last block might be of a smaller size | 122 // returns true. Last block might be of a smaller size |
119 // and after the last block we will get an end-of-stream | 123 // and after the last block we will get an end-of-stream |
120 // DataBuffer. | 124 // DataBuffer. |
121 virtual scoped_refptr<DataBuffer> Read() = 0; | 125 virtual scoped_refptr<DataBuffer> Read() = 0; |
122 | 126 |
123 // Ask the data provider to stop giving us data. | 127 // Ask the data provider to stop giving us data. |
124 // It's ok if the effect is not immediate. | 128 // It's ok if the effect is not immediate. |
125 virtual void SetDeferred(bool deferred) = 0; | 129 virtual void SetDeferred(bool deferred) = 0; |
126 }; | 130 }; |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
242 // Unpin block 4 & 5: PinRange(4, 6, -1); | 246 // Unpin block 4 & 5: PinRange(4, 6, -1); |
243 void PinRange(const BlockId& from, const BlockId& to, int32_t how_much); | 247 void PinRange(const BlockId& from, const BlockId& to, int32_t how_much); |
244 | 248 |
245 // Calls PinRange for each range in |ranges|, convenience | 249 // Calls PinRange for each range in |ranges|, convenience |
246 // function for applying multiple changes to the pinned ranges. | 250 // function for applying multiple changes to the pinned ranges. |
247 void PinRanges(const IntervalMap<BlockId, int32_t>& ranges); | 251 void PinRanges(const IntervalMap<BlockId, int32_t>& ranges); |
248 | 252 |
249 // Increment max cache size by |size| (counted in blocks). | 253 // Increment max cache size by |size| (counted in blocks). |
250 void IncrementMaxSize(int32_t size); | 254 void IncrementMaxSize(int32_t size); |
251 | 255 |
256 // Returns how many bytes have been received by the data providers at position | |
257 // |block|, which have not yet been submitted to the multibuffer cache. | |
258 // The returned number should be less than the size of one block. | |
259 int64_t UncommittedBytesAt(const BlockId& block); | |
260 | |
252 // Caller takes ownership of 'provider', cache will | 261 // Caller takes ownership of 'provider', cache will |
253 // not call it anymore. | 262 // not call it anymore. |
254 std::unique_ptr<DataProvider> RemoveProvider(DataProvider* provider); | 263 std::unique_ptr<DataProvider> RemoveProvider(DataProvider* provider); |
255 | 264 |
256 // Add a writer to this cache. Cache takes ownership, and may | 265 // Add a writer to this cache. Cache takes ownership, and may |
257 // destroy |provider| later. (Not during this call.) | 266 // destroy |provider| later. (Not during this call.) |
258 void AddProvider(std::unique_ptr<DataProvider> provider); | 267 void AddProvider(std::unique_ptr<DataProvider> provider); |
259 | 268 |
260 // Transfer all data from |other| to this. | 269 // Transfer all data from |other| to this. |
261 void MergeFrom(MultiBuffer* other); | 270 void MergeFrom(MultiBuffer* other); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
338 // and 0 for all blocks that are not. Used to quickly figure out | 347 // and 0 for all blocks that are not. Used to quickly figure out |
339 // ranges of available/unavailable blocks without iterating. | 348 // ranges of available/unavailable blocks without iterating. |
340 IntervalMap<BlockId, int32_t> present_; | 349 IntervalMap<BlockId, int32_t> present_; |
341 | 350 |
342 DISALLOW_COPY_AND_ASSIGN(MultiBuffer); | 351 DISALLOW_COPY_AND_ASSIGN(MultiBuffer); |
343 }; | 352 }; |
344 | 353 |
345 } // namespace media | 354 } // namespace media |
346 | 355 |
347 #endif // MEDIA_BLINK_MULTIBUFFER_H_ | 356 #endif // MEDIA_BLINK_MULTIBUFFER_H_ |
OLD | NEW |