5 #include <packager/media/base/offset_byte_queue.h>
9 #include <absl/log/log.h>
11 #include <packager/macros/logging.h>
16 OffsetByteQueue::OffsetByteQueue() : buf_(NULL), size_(0), head_(0) {}
17 OffsetByteQueue::~OffsetByteQueue() {}
19 void OffsetByteQueue::Reset() {
26 void OffsetByteQueue::Push(
const uint8_t* buf,
int size) {
27 queue_.Push(buf, size);
29 DVLOG(4) <<
"Buffer pushed. head=" << head() <<
" tail=" << tail();
32 void OffsetByteQueue::Peek(
const uint8_t** buf,
int* size) {
33 *buf = size_ > 0 ? buf_ : NULL;
37 void OffsetByteQueue::Pop(
int count) {
43 void OffsetByteQueue::PeekAt(int64_t offset,
const uint8_t** buf,
int* size) {
44 if (offset < head() || offset >= tail()) {
49 *buf = &buf_[offset - head()];
50 *size = tail() - offset;
53 bool OffsetByteQueue::Trim(int64_t max_offset) {
54 if (max_offset < head_)
return true;
55 if (max_offset > tail()) {
59 Pop(max_offset - head_);
63 void OffsetByteQueue::Sync() {
64 queue_.Peek(&buf_, &size_);
All the methods that are virtual are virtual for mocking.