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) {
41 void OffsetByteQueue::PeekAt(int64_t offset,
const uint8_t** buf,
int* size) {
42 if (offset < head() || offset >= tail()) {
47 *buf = &buf_[offset - head()];
48 *size = tail() - offset;
51 bool OffsetByteQueue::Trim(int64_t max_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_);
All the methods that are virtual are virtual for mocking.