Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "media/mp4/offset_byte_queue.h" | 5 #include "media/mp4/offset_byte_queue.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 | 9 |
| 10 namespace media { | 10 namespace media { |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 30 *size = size_; | 30 *size = size_; |
| 31 } | 31 } |
| 32 | 32 |
| 33 void OffsetByteQueue::Pop(int count) { | 33 void OffsetByteQueue::Pop(int count) { |
| 34 queue_.Pop(count); | 34 queue_.Pop(count); |
| 35 head_ += count; | 35 head_ += count; |
| 36 Sync(); | 36 Sync(); |
| 37 } | 37 } |
| 38 | 38 |
| 39 void OffsetByteQueue::PeekAt(int64 offset, const uint8** buf, int* size) { | 39 void OffsetByteQueue::PeekAt(int64 offset, const uint8** buf, int* size) { |
| 40 DCHECK(offset >= head()); | |
|
acolwell GONE FROM CHROMIUM
2012/07/30 20:49:04
Is this a result of a coding error, or can unexpec
strobe_
2012/07/31 18:34:38
As of now, it can only be the result of a programm
| |
| 40 if (offset < head() || offset >= tail()) { | 41 if (offset < head() || offset >= tail()) { |
| 41 *buf = NULL; | 42 *buf = NULL; |
| 42 *size = 0; | 43 *size = 0; |
| 43 return; | 44 return; |
| 44 } | 45 } |
| 45 *buf = &buf_[offset - head()]; | 46 *buf = &buf_[offset - head()]; |
| 46 *size = tail() - offset; | 47 *size = tail() - offset; |
| 47 } | 48 } |
| 48 | 49 |
| 49 bool OffsetByteQueue::Trim(int64 max_offset) { | 50 bool OffsetByteQueue::Trim(int64 max_offset) { |
| 50 if (max_offset < head_) return true; | 51 if (max_offset < head_) return true; |
| 51 if (max_offset > tail()) { | 52 if (max_offset > tail()) { |
| 52 Pop(size_); | 53 Pop(size_); |
| 53 return false; | 54 return false; |
| 54 } | 55 } |
| 55 Pop(max_offset - head_); | 56 Pop(max_offset - head_); |
| 56 return true; | 57 return true; |
| 57 } | 58 } |
| 58 | 59 |
| 59 void OffsetByteQueue::Sync() { | 60 void OffsetByteQueue::Sync() { |
| 60 queue_.Peek(&buf_, &size_); | 61 queue_.Peek(&buf_, &size_); |
| 61 } | 62 } |
| 62 | 63 |
| 63 } // namespace media | 64 } // namespace media |
| OLD | NEW |