diff --git a/media/libstagefright/binding/Box.cpp b/media/libstagefright/binding/Box.cpp index af802919e3b0..500a6d0a9aac 100644 --- a/media/libstagefright/binding/Box.cpp +++ b/media/libstagefright/binding/Box.cpp @@ -90,6 +90,12 @@ Box::Box(BoxContext* aContext, uint64_t aOffset, const Box* aParent) !byteRange->Contains(boxRange)) { return; } + + nsTArray content; + if (!Read(&content, boxRange)) { + return; + } + mRange = boxRange; } @@ -114,10 +120,16 @@ Box::FirstChild() const return Box(mContext, mChildOffset, this); } -void +bool Box::Read(nsTArray* aDest) { - aDest->SetLength(mRange.mEnd - mChildOffset); + return Read(aDest, mRange); +} + +bool +Box::Read(nsTArray* aDest, const MediaByteRange& aRange) +{ + aDest->SetLength(aRange.mEnd - mChildOffset); size_t bytes; if (!mContext->mSource->CachedReadAt(mChildOffset, aDest->Elements(), aDest->Length(), &bytes) || @@ -125,6 +137,8 @@ Box::Read(nsTArray* aDest) // Byte ranges are being reported incorrectly NS_WARNING("Read failed in mp4_demuxer::Box::Read()"); aDest->Clear(); + return false; } + return true; } } diff --git a/media/libstagefright/binding/include/mp4_demuxer/Box.h b/media/libstagefright/binding/include/mp4_demuxer/Box.h index 6f37efc83daa..e94d10ae093d 100644 --- a/media/libstagefright/binding/include/mp4_demuxer/Box.h +++ b/media/libstagefright/binding/include/mp4_demuxer/Box.h @@ -48,7 +48,8 @@ public: Box Next() const; Box FirstChild() const; - void Read(nsTArray* aDest); + bool Read(nsTArray* aDest); + bool Read(nsTArray* aDest, const MediaByteRange& aRange); private: bool Contains(MediaByteRange aRange) const;