OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_BYTE_QUEUE_H_ | 5 #ifndef MEDIA_BASE_BYTE_QUEUE_H_ |
6 #define MEDIA_BASE_BYTE_QUEUE_H_ | 6 #define MEDIA_BASE_BYTE_QUEUE_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 | 10 |
11 namespace media { | 11 namespace media { |
12 | 12 |
13 // Represents a queue of bytes. | 13 // Represents a queue of bytes. |
14 // Data is added to the end of the queue via an Push() call and removed via | 14 // Data is added to the end of the queue via an Push() call and removed via |
15 // Pop(). The contents of the queue can be observed via the Peek() method. | 15 // Pop(). The contents of the queue can be observed via the Peek() method. |
16 // This class manages the underlying storage of the queue and tries to minimize | 16 // This class manages the underlying storage of the queue and tries to minimize |
17 // the number of buffer copies when data is appended and removed. | 17 // the number of buffer copies when data is appended and removed. |
18 class ByteQueue { | 18 class ByteQueue { |
19 public: | 19 public: |
20 ByteQueue(); | 20 ByteQueue(); |
21 ~ByteQueue(); | 21 ~ByteQueue(); |
22 | 22 |
| 23 // Reset the queue to the empty state. |
| 24 void Reset(); |
| 25 |
23 // Appends new bytes onto the end of the queue. | 26 // Appends new bytes onto the end of the queue. |
24 void Push(const uint8* data, int size); | 27 void Push(const uint8* data, int size); |
25 | 28 |
26 // Get a pointer to the front of the queue and the queue size. | 29 // Get a pointer to the front of the queue and the queue size. |
27 // These values are only valid until the next Push() or | 30 // These values are only valid until the next Push() or |
28 // Pop() call. | 31 // Pop() call. |
29 void Peek(const uint8** data, int* size) const; | 32 void Peek(const uint8** data, int* size) const; |
30 | 33 |
31 // Remove |count| bytes from the front of the queue. | 34 // Remove |count| bytes from the front of the queue. |
32 void Pop(int count); | 35 void Pop(int count); |
(...skipping 12 matching lines...) Expand all Loading... |
45 | 48 |
46 // Number of bytes stored in the queue. | 49 // Number of bytes stored in the queue. |
47 int used_; | 50 int used_; |
48 | 51 |
49 DISALLOW_COPY_AND_ASSIGN(ByteQueue); | 52 DISALLOW_COPY_AND_ASSIGN(ByteQueue); |
50 }; | 53 }; |
51 | 54 |
52 } // namespace media | 55 } // namespace media |
53 | 56 |
54 #endif // MEDIA_BASE_BYTE_QUEUE_H_ | 57 #endif // MEDIA_BASE_BYTE_QUEUE_H_ |
OLD | NEW |