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 <memory>
11 
12 #include "packager/base/macros.h"
13 
14 namespace shaka {
15 namespace media {
16 
22 class ByteQueue {
23  public:
24  ByteQueue();
25  ~ByteQueue();
26 
28  void Reset();
29 
31  void Push(const uint8_t* data, int size);
32 
35  void Peek(const uint8_t** data, int* size) const;
36 
39  void Pop(int count);
40 
41  private:
42  // Returns a pointer to the front of the queue.
43  uint8_t* front() const;
44 
45  std::unique_ptr<uint8_t[]> buffer_;
46 
47  // Size of |buffer_|.
48  size_t size_;
49 
50  // Offset from the start of |buffer_| that marks the front of the queue.
51  size_t offset_;
52 
53  // Number of bytes stored in the queue.
54  int used_;
55 
56  DISALLOW_COPY_AND_ASSIGN(ByteQueue);
57 };
58 
59 } // namespace media
60 } // namespace shaka
61 
62 #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 Pop(int count)
Definition: byte_queue.cc:70
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