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_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 <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
| 11 #include <memory> |
| 12 |
11 #include "base/macros.h" | 13 #include "base/macros.h" |
12 #include "base/memory/scoped_ptr.h" | |
13 #include "media/base/media_export.h" | 14 #include "media/base/media_export.h" |
14 | 15 |
15 namespace media { | 16 namespace media { |
16 | 17 |
17 // Represents a queue of bytes. | 18 // Represents a queue of bytes. |
18 // Data is added to the end of the queue via an Push() call and removed via | 19 // Data is added to the end of the queue via an Push() call and removed via |
19 // Pop(). The contents of the queue can be observed via the Peek() method. | 20 // Pop(). The contents of the queue can be observed via the Peek() method. |
20 // This class manages the underlying storage of the queue and tries to minimize | 21 // This class manages the underlying storage of the queue and tries to minimize |
21 // the number of buffer copies when data is appended and removed. | 22 // the number of buffer copies when data is appended and removed. |
22 class MEDIA_EXPORT ByteQueue { | 23 class MEDIA_EXPORT ByteQueue { |
(...skipping 12 matching lines...) Expand all Loading... |
35 // Pop() call. | 36 // Pop() call. |
36 void Peek(const uint8_t** data, int* size) const; | 37 void Peek(const uint8_t** data, int* size) const; |
37 | 38 |
38 // Remove |count| bytes from the front of the queue. | 39 // Remove |count| bytes from the front of the queue. |
39 void Pop(int count); | 40 void Pop(int count); |
40 | 41 |
41 private: | 42 private: |
42 // Returns a pointer to the front of the queue. | 43 // Returns a pointer to the front of the queue. |
43 uint8_t* front() const; | 44 uint8_t* front() const; |
44 | 45 |
45 scoped_ptr<uint8_t[]> buffer_; | 46 std::unique_ptr<uint8_t[]> buffer_; |
46 | 47 |
47 // Size of |buffer_|. | 48 // Size of |buffer_|. |
48 size_t size_; | 49 size_t size_; |
49 | 50 |
50 // Offset from the start of |buffer_| that marks the front of the queue. | 51 // Offset from the start of |buffer_| that marks the front of the queue. |
51 size_t offset_; | 52 size_t offset_; |
52 | 53 |
53 // Number of bytes stored in the queue. | 54 // Number of bytes stored in the queue. |
54 int used_; | 55 int used_; |
55 | 56 |
56 DISALLOW_COPY_AND_ASSIGN(ByteQueue); | 57 DISALLOW_COPY_AND_ASSIGN(ByteQueue); |
57 }; | 58 }; |
58 | 59 |
59 } // namespace media | 60 } // namespace media |
60 | 61 |
61 #endif // MEDIA_BASE_BYTE_QUEUE_H_ | 62 #endif // MEDIA_BASE_BYTE_QUEUE_H_ |
OLD | NEW |