Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(325)

Side by Side Diff: media/mp4/offset_byte_queue.h

Issue 10536014: Implement ISO BMFF support in Media Source. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: A thorough sign-ification Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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, int size);
25 void Peek(const uint8** buf, int* size);
26 void Pop(int 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(int64 offset, const uint8** buf, int* 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(int64 max_offset);
45
46 // The head and tail positions, in terms of the file's absolute offsets.
47 // tail() is an exclusive bound.
48 int64 head() { return head_; }
49 int64 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 int size_;
58 int64 head_;
59
60 DISALLOW_COPY_AND_ASSIGN(OffsetByteQueue);
61 };
62
63 } // namespace media
64
65 #endif // MEDIA_MP4_MP4_STREAM_PARSER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698