From 510e47a9249abb26774af27e438472fd3c757a2a Mon Sep 17 00:00:00 2001 From: "Alfredo.Yang" Date: Wed, 25 Oct 2017 15:40:24 +0800 Subject: [PATCH] Bug 1412183 - use BufferReader instead of ByteReader in DecoderData. r=kinetik MozReview-Commit-ID: AgcOuWn7ouo --HG-- extra : rebase_source : e2aa46b47e848a8d51dc6e48a58e46db6f669b68 --- media/libstagefright/binding/DecoderData.cpp | 14 +++++++------- .../binding/include/mp4_demuxer/DecoderData.h | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/media/libstagefright/binding/DecoderData.cpp b/media/libstagefright/binding/DecoderData.cpp index 6687ccdb936c..e147337e5a13 100644 --- a/media/libstagefright/binding/DecoderData.cpp +++ b/media/libstagefright/binding/DecoderData.cpp @@ -4,7 +4,7 @@ #include "mp4_demuxer/Adts.h" #include "mp4_demuxer/AnnexB.h" -#include "mp4_demuxer/ByteReader.h" +#include "mp4_demuxer/BufferReader.h" #include "mp4_demuxer/DecoderData.h" #include #include "media/stagefright/MetaData.h" @@ -87,27 +87,27 @@ FindData(const MetaData* aMetaData, uint32_t aKey, mozilla::MediaByteBuffer* aDe return FindData(aMetaData, aKey, static_cast*>(aDest)); } -bool +Result CryptoFile::DoUpdate(const uint8_t* aData, size_t aLength) { - ByteReader reader(aData, aLength); + BufferReader reader(aData, aLength); while (reader.Remaining()) { PsshInfo psshInfo; if (!reader.ReadArray(psshInfo.uuid, 16)) { - return false; + return Err(NS_ERROR_FAILURE); } if (!reader.CanReadType()) { - return false; + return Err(NS_ERROR_FAILURE); } auto length = reader.ReadType(); if (!reader.ReadArray(psshInfo.data, length)) { - return false; + return Err(NS_ERROR_FAILURE); } pssh.AppendElement(psshInfo); } - return true; + return Ok(); } static void diff --git a/media/libstagefright/binding/include/mp4_demuxer/DecoderData.h b/media/libstagefright/binding/include/mp4_demuxer/DecoderData.h index 3cd4b7c142f4..b2c44fe1c894 100644 --- a/media/libstagefright/binding/include/mp4_demuxer/DecoderData.h +++ b/media/libstagefright/binding/include/mp4_demuxer/DecoderData.h @@ -53,14 +53,14 @@ public: void Update(const uint8_t* aData, size_t aLength) { - valid = DoUpdate(aData, aLength); + valid = DoUpdate(aData, aLength).isOk(); } bool valid; nsTArray pssh; private: - bool DoUpdate(const uint8_t* aData, size_t aLength); + mozilla::Result DoUpdate(const uint8_t* aData, size_t aLength); }; class MP4AudioInfo : public mozilla::AudioInfo