From d8e03d04608799e51db8315646c539965ae8c70d Mon Sep 17 00:00:00 2001 From: Wes Kocher Date: Thu, 17 Jul 2014 20:03:18 -0700 Subject: [PATCH] Backed out changeset daa82439f77f (bug 1022434) for build bustage --- media/libstagefright/binding/Adts.cpp | 8 -- media/libstagefright/binding/DecoderData.cpp | 114 +++--------------- .../binding/include/mp4_demuxer/ByteReader.h | 28 +---- .../binding/include/mp4_demuxer/DecoderData.h | 50 -------- .../binding/include/mp4_demuxer/mp4_demuxer.h | 2 - media/libstagefright/binding/mp4_demuxer.cpp | 2 - .../media/libstagefright/MPEG4Extractor.cpp | 9 +- 7 files changed, 20 insertions(+), 193 deletions(-) diff --git a/media/libstagefright/binding/Adts.cpp b/media/libstagefright/binding/Adts.cpp index 33a1f4c341db..eb0d94dc1b7e 100644 --- a/media/libstagefright/binding/Adts.cpp +++ b/media/libstagefright/binding/Adts.cpp @@ -56,14 +56,6 @@ Adts::ConvertEsdsToAdts(uint16_t aChannelCount, int8_t aFrequencyIndex, header[6] = 0xfc; aSample->Prepend(&header[0], ArrayLength(header)); - if (aSample->crypto.valid) { - if (aSample->crypto.plain_sizes.Length() == 0) { - aSample->crypto.plain_sizes.AppendElement(kADTSHeaderSize); - aSample->crypto.encrypted_sizes.AppendElement(aSample->size - kADTSHeaderSize); - } else { - aSample->crypto.plain_sizes[0] += kADTSHeaderSize; - } - } return true; } diff --git a/media/libstagefright/binding/DecoderData.cpp b/media/libstagefright/binding/DecoderData.cpp index 16a1860d540b..152683bdcae0 100644 --- a/media/libstagefright/binding/DecoderData.cpp +++ b/media/libstagefright/binding/DecoderData.cpp @@ -34,94 +34,6 @@ FindInt64(sp& mMetaData, uint32_t mKey) return value; } -template -static bool -FindData(sp& aMetaData, uint32_t aKey, mozilla::Vector* aDest) -{ - const void* data; - size_t size; - uint32_t type; - - aDest->clear(); - // There's no point in checking that the type matches anything because it - // isn't set consistently in the MPEG4Extractor. - if (!aMetaData->findData(aKey, &type, &data, &size) || size % sizeof(T)) { - return false; - } - - aDest->append(reinterpret_cast(data), size / sizeof(T)); - return true; -} - -template -static bool -FindData(sp& aMetaData, uint32_t aKey, nsTArray* aDest) -{ - const void* data; - size_t size; - uint32_t type; - - aDest->Clear(); - // There's no point in checking that the type matches anything because it - // isn't set consistently in the MPEG4Extractor. - if (!aMetaData->findData(aKey, &type, &data, &size) || size % sizeof(T)) { - return false; - } - - aDest->AppendElements(reinterpret_cast(data), size / sizeof(T)); - return true; -} - -bool -CryptoFile::DoUpdate(sp& aMetaData) -{ - const void* data; - size_t size; - uint32_t type; - - // There's no point in checking that the type matches anything because it - // isn't set consistently in the MPEG4Extractor. - if (!aMetaData->findData(kKeyPssh, &type, &data, &size)) { - return false; - } - - ByteReader reader(reinterpret_cast(data), size); - while (reader.Remaining()) { - PsshInfo psshInfo; - if (!reader.ReadArray(psshInfo.uuid, 16)) { - return false; - } - - if (!reader.CanReadType()) { - return false; - } - auto length = reader.ReadType(); - - if (!reader.ReadArray(psshInfo.data, length)) { - return false; - } - pssh.AppendElement(psshInfo); - } - return true; -} - -void -CryptoTrack::Update(sp& aMetaData) -{ - valid = aMetaData->findInt32(kKeyCryptoMode, &mode) && - aMetaData->findInt32(kKeyCryptoDefaultIVSize, &iv_size) && - FindData(aMetaData, kKeyCryptoKey, &key); -} - -void -CryptoSample::Update(sp& aMetaData) -{ - CryptoTrack::Update(aMetaData); - valid = valid && FindData(aMetaData, kKeyPlainSizes, &plain_sizes) && - FindData(aMetaData, kKeyEncryptedSizes, &encrypted_sizes) && - FindData(aMetaData, kKeyCryptoIV, &iv); -} - void AudioDecoderConfig::Update(sp& aMetaData, const char* aMimeType) { @@ -134,18 +46,20 @@ AudioDecoderConfig::Update(sp& aMetaData, const char* aMimeType) frequency_index = Adts::GetFrequencyIndex(samples_per_second); aac_profile = FindInt32(aMetaData, kKeyAACProfile); - if (FindData(aMetaData, kKeyESDS, &extra_data)) { - ESDS esds(&extra_data[0], extra_data.length()); + const void* data; + size_t size; + uint32_t type; - const void* data; - size_t size; + if (aMetaData->findData(kKeyESDS, &type, &data, &size)) { + extra_data.clear(); + extra_data.append(reinterpret_cast(data), size); + + ESDS esds(&extra_data[0], extra_data.length()); if (esds.getCodecSpecificInfo(&data, &size) == OK) { audio_specific_config.append(reinterpret_cast(data), size); } } - - crypto.Update(aMetaData); } bool @@ -164,14 +78,18 @@ VideoDecoderConfig::Update(sp& aMetaData, const char* aMimeType) display_width = FindInt32(aMetaData, kKeyDisplayWidth); display_height = FindInt32(aMetaData, kKeyDisplayHeight); - if (FindData(aMetaData, kKeyAVCC, &extra_data) && extra_data.length() >= 7) { + const void* data; + size_t size; + uint32_t type; + + if (aMetaData->findData(kKeyAVCC, &type, &data, &size) && size >= 7) { + extra_data.clear(); + extra_data.append(reinterpret_cast(data), size); // Set size of the NAL length to 4. The demuxer formats its output with // this NAL length size. extra_data[4] |= 3; annex_b = AnnexB::ConvertExtraDataToAnnexB(extra_data); } - - crypto.Update(aMetaData); } bool @@ -208,8 +126,6 @@ MP4Sample::Update() is_sync_point = FindInt32(m, kKeyIsSyncFrame); data = reinterpret_cast(mMediaBuffer->data()); size = mMediaBuffer->range_length(); - - crypto.Update(m); } void diff --git a/media/libstagefright/binding/include/mp4_demuxer/ByteReader.h b/media/libstagefright/binding/include/mp4_demuxer/ByteReader.h index 6f5dd6b6ad2a..be8082938511 100644 --- a/media/libstagefright/binding/include/mp4_demuxer/ByteReader.h +++ b/media/libstagefright/binding/include/mp4_demuxer/ByteReader.h @@ -6,7 +6,6 @@ #define BYTE_READER_H_ #include "mozilla/Vector.h" -#include "nsTArray.h" namespace mp4_demuxer { @@ -14,7 +13,7 @@ namespace mp4_demuxer class ByteReader { public: - ByteReader(const mozilla::Vector& aData) + ByteReader(mozilla::Vector& aData) : mPtr(&aData[0]), mRemaining(aData.length()) { } @@ -73,31 +72,6 @@ public: return result; } - template bool CanReadType() { return mRemaining >= sizeof(T); } - - template T ReadType() - { - auto ptr = Read(sizeof(T)); - if (!ptr) { - MOZ_ASSERT(false); - return 0; - } - return *reinterpret_cast(ptr); - } - - template - bool ReadArray(nsTArray& aDest, size_t aLength) - { - auto ptr = Read(aLength * sizeof(T)); - if (!ptr) { - return false; - } - - aDest.Clear(); - aDest.AppendElements(reinterpret_cast(ptr), aLength); - return true; - } - private: const uint8_t* mPtr; size_t mRemaining; diff --git a/media/libstagefright/binding/include/mp4_demuxer/DecoderData.h b/media/libstagefright/binding/include/mp4_demuxer/DecoderData.h index 288cb9376b4f..a3160bc3ff52 100644 --- a/media/libstagefright/binding/include/mp4_demuxer/DecoderData.h +++ b/media/libstagefright/binding/include/mp4_demuxer/DecoderData.h @@ -7,7 +7,6 @@ #include "mozilla/Types.h" #include "mozilla/Vector.h" -#include "nsTArray.h" #include "nsAutoPtr.h" namespace stagefright @@ -22,51 +21,6 @@ namespace mp4_demuxer class MP4Demuxer; -struct PsshInfo -{ - PsshInfo() {} - PsshInfo(const PsshInfo& aOther) : uuid(aOther.uuid), data(aOther.data) {} - nsTArray uuid; - nsTArray data; -}; - -class CryptoFile -{ -public: - void Update(stagefright::sp& aMetaData) - { - valid = DoUpdate(aMetaData); - } - - bool valid; - nsTArray pssh; - -private: - bool DoUpdate(stagefright::sp& aMetaData); -}; - -class CryptoTrack -{ -public: - CryptoTrack() : valid(false) {} - void Update(stagefright::sp& aMetaData); - - bool valid; - int32_t mode; - int32_t iv_size; - nsTArray key; -}; - -class CryptoSample : public CryptoTrack -{ -public: - void Update(stagefright::sp& aMetaData); - - nsTArray plain_sizes; - nsTArray encrypted_sizes; - nsTArray iv; -}; - class AudioDecoderConfig { public: @@ -88,7 +42,6 @@ public: int8_t frequency_index; mozilla::Vector extra_data; mozilla::Vector audio_specific_config; - CryptoTrack crypto; void Update(stagefright::sp& aMetaData, const char* aMimeType); bool IsValid(); @@ -116,7 +69,6 @@ public: mozilla::Vector extra_data; // Unparsed AVCDecoderConfig payload. mozilla::Vector annex_b; // Parsed version for sample prepend. - CryptoTrack crypto; void Update(stagefright::sp& aMetaData, const char* aMimeType); bool IsValid(); @@ -142,8 +94,6 @@ public: uint8_t* data; size_t size; - CryptoSample crypto; - void Prepend(const uint8_t* aData, size_t aSize); private: diff --git a/media/libstagefright/binding/include/mp4_demuxer/mp4_demuxer.h b/media/libstagefright/binding/include/mp4_demuxer/mp4_demuxer.h index f0e8ae1bfaab..05adfb6c0265 100644 --- a/media/libstagefright/binding/include/mp4_demuxer/mp4_demuxer.h +++ b/media/libstagefright/binding/include/mp4_demuxer/mp4_demuxer.h @@ -52,7 +52,6 @@ public: MP4Sample* DemuxAudioSample(); MP4Sample* DemuxVideoSample(); - const CryptoFile& Crypto() { return mCrypto; } const AudioDecoderConfig& AudioConfig() { return mAudioConfig; } const VideoDecoderConfig& VideoConfig() { return mVideoConfig; } @@ -63,7 +62,6 @@ public: private: AudioDecoderConfig mAudioConfig; VideoDecoderConfig mVideoConfig; - CryptoFile mCrypto; nsAutoPtr mPrivate; }; diff --git a/media/libstagefright/binding/mp4_demuxer.cpp b/media/libstagefright/binding/mp4_demuxer.cpp index a3078ef27bfb..735c9f386aab 100644 --- a/media/libstagefright/binding/mp4_demuxer.cpp +++ b/media/libstagefright/binding/mp4_demuxer.cpp @@ -111,8 +111,6 @@ MP4Demuxer::Init() mPrivate->mVideoIndex.Init(index); } } - sp metaData = e->getMetaData(); - mCrypto.Update(metaData); return mPrivate->mAudio.get() || mPrivate->mVideo.get(); } diff --git a/media/libstagefright/frameworks/av/media/libstagefright/MPEG4Extractor.cpp b/media/libstagefright/frameworks/av/media/libstagefright/MPEG4Extractor.cpp index 0e524523ccad..59542af1374c 100644 --- a/media/libstagefright/frameworks/av/media/libstagefright/MPEG4Extractor.cpp +++ b/media/libstagefright/frameworks/av/media/libstagefright/MPEG4Extractor.cpp @@ -137,12 +137,12 @@ private: struct Sample { off64_t offset; - uint32_t size; + size_t size; uint32_t duration; uint32_t ctsOffset; uint8_t iv[16]; - Vector clearsizes; - Vector encryptedsizes; + Vector clearsizes; + Vector encryptedsizes; }; Vector mCurrentSamples; @@ -1522,8 +1522,7 @@ status_t MPEG4Extractor::parseChunk(off64_t *offset, int depth) { kKeyESDS, kTypeESDS, &buffer[4], chunk_data_size - 4); if (mPath.size() >= 2 - && (mPath[mPath.size() - 2] == FOURCC('m', 'p', '4', 'a') || - (mPath[mPath.size() - 2] == FOURCC('e', 'n', 'c', 'a')))) { + && mPath[mPath.size() - 2] == FOURCC('m', 'p', '4', 'a')) { // Information from the ESDS must be relied on for proper // setup of sample rate and channel count for MPEG4 Audio. // The generic header appears to only contain generic