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.
5 #ifndef MEDIA_BASE_BYTE_QUEUE_H_
6 #define MEDIA_BASE_BYTE_QUEUE_H_
8 #include "base/basictypes.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "media/base/media_export.h"
14 // Represents a queue of bytes.
15 // Data is added to the end of the queue via an Push() call and removed via
16 // Pop(). The contents of the queue can be observed via the Peek() method.
17 // This class manages the underlying storage of the queue and tries to minimize
18 // the number of buffer copies when data is appended and removed.
19 class MEDIA_EXPORT ByteQueue
{
24 // Reset the queue to the empty state.
27 // Appends new bytes onto the end of the queue.
28 void Push(const uint8
* data
, int size
);
30 // Get a pointer to the front of the queue and the queue size.
31 // These values are only valid until the next Push() or
33 void Peek(const uint8
** data
, int* size
) const;
35 // Remove |count| bytes from the front of the queue.
39 // Returns a pointer to the front of the queue.
42 scoped_ptr
<uint8
[]> buffer_
;
47 // Offset from the start of |buffer_| that marks the front of the queue.
50 // Number of bytes stored in the queue.
53 DISALLOW_COPY_AND_ASSIGN(ByteQueue
);
58 #endif // MEDIA_BASE_BYTE_QUEUE_H_