Chromium Code Reviews| Index: media/formats/mp4/box_reader.h |
| diff --git a/media/formats/mp4/box_reader.h b/media/formats/mp4/box_reader.h |
| index 6b59361612459d84e29448c3b19b43595ab98cce..4a86cc009dae2e002520af3777ce8a8d9a4e36f5 100644 |
| --- a/media/formats/mp4/box_reader.h |
| +++ b/media/formats/mp4/box_reader.h |
| @@ -101,6 +101,14 @@ class MEDIA_EXPORT BoxReader : public BufferReader { |
| int* box_size, |
| bool* err) WARN_UNUSED_RESULT; |
| + // Create a BoxReader from a buffer. |buf| must be the complete buffer, as |
| + // errors are returned when sufficient data is not available. |buf| can start |
| + // with any type of box -- it does not have to be IsValidTopLevelBox(). |
| + // |
| + // |buf| is retained but not owned, and must outlive the BoxReader instance. |
| + static BoxReader* ReadConcatentatedBoxes(const uint8* buf, |
| + const int buf_size); |
| + |
| // Returns true if |type| is recognized to be a top-level box, false |
| // otherwise. This returns true for some boxes which we do not parse. |
| // Helpful in debugging misaligned appends. |
| @@ -148,7 +156,7 @@ class MEDIA_EXPORT BoxReader : public BufferReader { |
| const LogCB& log_cb() const { return log_cb_; } |
| private: |
| - BoxReader(const uint8* buf, const int size, const LogCB& log_cb); |
| + BoxReader(const uint8* buf, const int size, const LogCB& log_cb, bool is_EOS); |
|
ddorwin
2015/06/04 18:08:45
Should probably explain is_EOS here.
jrummell
2015/06/04 21:47:10
Done.
|
| // Must be called immediately after init. If the return is false, this |
| // indicates that the box header and its contents were not available in the |
| @@ -170,6 +178,9 @@ class MEDIA_EXPORT BoxReader : public BufferReader { |
| // valid if scanned_ is true. |
| ChildMap children_; |
| bool scanned_; |
| + |
| + // Set to true if the buffer provided to the reader is the complete stream. |
|
ddorwin
2015/06/04 18:08:45
Drop "Set to " since we don't intend for it to be
jrummell
2015/06/04 21:47:11
Done.
|
| + bool is_EOS_; |
|
ddorwin
2015/06/04 18:08:45
const?
jrummell
2015/06/04 21:47:10
Done.
|
| }; |
| // Template definitions |
| @@ -207,8 +218,8 @@ bool BoxReader::ReadAllChildren(std::vector<T>* children) { |
| scanned_ = true; |
| bool err = false; |
| - while (pos() < size()) { |
| - BoxReader child_reader(&buf_[pos_], size_ - pos_, log_cb_); |
| + while (pos_ < size_) { |
| + BoxReader child_reader(&buf_[pos_], size_ - pos_, log_cb_, is_EOS_); |
| if (!child_reader.ReadHeader(&err)) break; |
| T child; |
| RCHECK(child.Parse(&child_reader)); |