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

Unified Diff: media/formats/mp4/box_reader.h

Issue 1149023002: Combine 'pssh' parsing routines. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: size_t Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/formats/mp4/box_definitions.cc ('k') | media/formats/mp4/box_reader.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..92e85fc44fade4ce118914b1f47d1d363decf549 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,9 @@ 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);
+ // Create a BoxReader from |buf|. |is_EOS| should be true if |buf| is
+ // complete stream (i.e. no additional data is expected to be appended).
+ BoxReader(const uint8* buf, const int size, const LogCB& log_cb, bool is_EOS);
// 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 +180,9 @@ class MEDIA_EXPORT BoxReader : public BufferReader {
// valid if scanned_ is true.
ChildMap children_;
bool scanned_;
+
+ // True if the buffer provided to the reader is the complete stream.
+ const bool is_EOS_;
};
// Template definitions
@@ -207,8 +220,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));
« no previous file with comments | « media/formats/mp4/box_definitions.cc ('k') | media/formats/mp4/box_reader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698