Shaka Packager SDK
Loading...
Searching...
No Matches
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 PACKAGER_MEDIA_BASE_BYTE_QUEUE_H_
6#define PACKAGER_MEDIA_BASE_BYTE_QUEUE_H_
7
8#include <cstddef>
9#include <cstdint>
10#include <memory>
11
12#include <packager/macros/classes.h>
13
14namespace shaka {
15namespace media {
16
22class 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 // PACKAGER_MEDIA_BASE_BYTE_QUEUE_H_
void Pop(int count)
Definition byte_queue.cc:73
void Peek(const uint8_t **data, int *size) const
Definition byte_queue.cc:66
void Reset()
Reset the queue to the empty state.
Definition byte_queue.cc:28
void Push(const uint8_t *data, int size)
Append new bytes to the end of the queue.
Definition byte_queue.cc:33
All the methods that are virtual are virtual for mocking.