Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(120)

Side by Side Diff: media/mp4/offset_byte_queue.cc

Issue 10536014: Implement ISO BMFF support in Media Source. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: A thorough sign-ification Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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 #include "media/mp4/offset_byte_queue.h"
6
7 #include "base/basictypes.h"
8 #include "base/logging.h"
9
10 namespace media {
11
12 OffsetByteQueue::OffsetByteQueue() : buf_(NULL), size_(0), head_(0) {}
13 OffsetByteQueue::~OffsetByteQueue() {};
acolwell GONE FROM CHROMIUM 2012/06/08 16:10:38 lint nit: remove ;
strobe_ 2012/06/11 18:44:21 Done.
14
15 void OffsetByteQueue::Reset() {
16 queue_.Reset();
17 buf_ = NULL;
18 size_ = 0;
19 head_ = 0;
20 }
21
22 void OffsetByteQueue::Push(const uint8* buf, int size) {
23 queue_.Push(buf, size);
24 Sync();
25 DVLOG(4) << "Buffer pushed. head=" << head() << " tail=" << tail();
26 }
27
28 void OffsetByteQueue::Peek(const uint8** buf, int* size) {
29 *buf = size_ > 0 ? buf_ : NULL;
30 *size = size_;
31 }
32
33 void OffsetByteQueue::Pop(int count) {
34 queue_.Pop(count);
35 head_ += count;
36 Sync();
37 }
38
39 void OffsetByteQueue::PeekAt(int64 offset, const uint8** buf, int* size) {
40 if (offset < head() || offset >= tail()) {
41 *buf = NULL;
42 *size = 0;
43 return;
44 }
45 *buf = &buf_[offset - head()];
46 *size = tail() - offset;
47 }
48
49 bool OffsetByteQueue::Trim(int64 max_offset) {
50 if (max_offset < head_) return true;
51 if (max_offset > tail()) {
52 Pop(size_);
53 return false;
54 }
55 Pop(max_offset - head_);
56 return true;
57 }
58
59 void OffsetByteQueue::Sync() {
60 queue_.Peek(&buf_, &size_);
61 }
62
63 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698