5 #include "packager/media/base/offset_byte_queue.h"
9 #include "packager/base/logging.h"
14 OffsetByteQueue::OffsetByteQueue() : buf_(NULL), size_(0), head_(0) {}
15 OffsetByteQueue::~OffsetByteQueue() {}
17 void OffsetByteQueue::Reset() {
24 void OffsetByteQueue::Push(
const uint8_t* buf,
int size) {
25 queue_.
Push(buf, size);
27 DVLOG(4) <<
"Buffer pushed. head=" <<
head() <<
" tail=" <<
tail();
30 void OffsetByteQueue::Peek(
const uint8_t** buf,
int* size) {
31 *buf = size_ > 0 ? buf_ : NULL;
35 void OffsetByteQueue::Pop(
int count) {
42 if (offset <
head() || offset >=
tail()) {
47 *buf = &buf_[offset -
head()];
48 *size =
tail() - offset;
52 if (max_offset < head_)
return true;
53 if (max_offset >
tail()) {
57 Pop(max_offset - head_);
61 void OffsetByteQueue::Sync() {
62 queue_.
Peek(&buf_, &size_);