DASH Media Packaging SDK
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator
byte_queue.h
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_BASE_BYTE_QUEUE_H_
6 #define MEDIA_BASE_BYTE_QUEUE_H_
7 
8 #include <stdint.h>
9 
10 #include "packager/base/memory/scoped_ptr.h"
11 
12 namespace edash_packager {
13 namespace media {
14 
20 class ByteQueue {
21  public:
22  ByteQueue();
23  ~ByteQueue();
24 
26  void Reset();
27 
29  void Push(const uint8_t* data, int size);
30 
33  void Peek(const uint8_t** data, int* size) const;
34 
37  void Pop(int count);
38 
39  private:
40  // Returns a pointer to the front of the queue.
41  uint8_t* front() const;
42 
43  scoped_ptr<uint8_t[]> buffer_;
44 
45  // Size of |buffer_|.
46  size_t size_;
47 
48  // Offset from the start of |buffer_| that marks the front of the queue.
49  size_t offset_;
50 
51  // Number of bytes stored in the queue.
52  int used_;
53 
54  DISALLOW_COPY_AND_ASSIGN(ByteQueue);
55 };
56 
57 } // namespace media
58 } // namespace edash_packager
59 
60 #endif // MEDIA_BASE_BYTE_QUEUE_H_
void Push(const uint8_t *data, int size)
Append new bytes to the end of the queue.
Definition: byte_queue.cc:29
void Reset()
Reset the queue to the empty state.
Definition: byte_queue.cc:24
void Peek(const uint8_t **data, int *size) const
Definition: byte_queue.cc:63