Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef MEDIA_MP4_OFFSET_BYTE_QUEUE_H_ | |
| 6 #define MEDIA_MP4_OFFSET_BYTE_QUEUE_H_ | |
| 7 | |
| 8 #include "base/basictypes.h" | |
| 9 #include "media/base/byte_queue.h" | |
| 10 | |
| 11 namespace media { | |
| 12 | |
| 13 // A wrapper around a ByteQueue which maintains a notion of a | |
| 14 // monotonically-increasing offset. All buffer access is done by passing these | |
| 15 // offsets into this class, going some way towards preventing the proliferation | |
| 16 // of many different meanings of "offset", "head", etc. | |
| 17 class OffsetByteQueue { | |
| 18 public: | |
| 19 OffsetByteQueue(); | |
| 20 ~OffsetByteQueue(); | |
| 21 | |
| 22 // These work like their underlying ByteQueue counterparts. | |
| 23 void Reset(); | |
| 24 void Push(const uint8* buf, size_t size); | |
| 25 void Peek(const uint8** buf, size_t* size); | |
| 26 void Pop(size_t count); | |
| 27 | |
| 28 // Sets |buf| to point at the first buffered byte corresponding to |offset|, | |
| 29 // and |size| to the number of bytes available starting from that offset. | |
| 30 // | |
| 31 // It is an error if the offset is before the current head. It's not an error | |
| 32 // if the current offset is beyond tail(), but you will of course get back | |
| 33 // a null |buf| and a |size| of zero. | |
| 34 void PeekAt(size_t offset, const uint8** buf, size_t* size); | |
| 35 | |
| 36 // Marks the bytes up to (but not including) |max_offset| as ready for | |
| 37 // deletion. This is relatively inexpensive, but will not necessarily reduce | |
| 38 // the resident buffer size right away (or ever). | |
| 39 // | |
| 40 // Returns true if the full range of bytes were successfully trimmed, | |
| 41 // including the case where |max_offset| is less than the current head. | |
| 42 // Returns false if |max_offset| > tail() (although all bytes currently | |
| 43 // buffered are still cleared). | |
| 44 bool Trim(size_t max_offset); | |
| 45 | |
| 46 // The head and tail positions, in terms of the file's absolute offsets. | |
| 47 // tail() is an exclusive bound. | |
| 48 size_t head() { return head_; } | |
|
acolwell GONE FROM CHROMIUM
2012/06/07 19:44:02
Is there any reason these and other values in here
strobe_
2012/06/07 22:04:22
Done.
| |
| 49 size_t tail() { return head_ + size_; } | |
| 50 | |
| 51 private: | |
| 52 // Synchronize |buf_| and |size_| with |queue_|. | |
| 53 void Sync(); | |
| 54 | |
| 55 ByteQueue queue_; | |
| 56 const uint8* buf_; | |
| 57 size_t size_; | |
| 58 size_t head_; | |
| 59 | |
| 60 DISALLOW_COPY_AND_ASSIGN(OffsetByteQueue); | |
| 61 }; | |
| 62 | |
| 63 } // namespace media | |
| 64 | |
| 65 #endif // MEDIA_MP4_MP4_STREAM_PARSER_H_ | |
| OLD | NEW |