DecoderData.h (1745B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 #ifndef DECODER_DATA_H_ 6 #define DECODER_DATA_H_ 7 8 #include "MediaInfo.h" 9 #include "MediaResult.h" 10 #include "mozilla/Result.h" 11 #include "mp4parse.h" 12 #include "nsString.h" 13 #include "nsTArray.h" 14 15 namespace mozilla { 16 17 class IndiceWrapper; 18 class MP4Demuxer; 19 20 struct PsshInfo { 21 PsshInfo() = default; 22 PsshInfo(const PsshInfo& aOther) = delete; 23 PsshInfo(PsshInfo&& aOther) = default; 24 25 nsTArray<uint8_t> uuid; 26 nsTArray<uint8_t> data; 27 28 bool operator==(const PsshInfo& aOther) const { 29 return uuid == aOther.uuid && data == aOther.data; 30 } 31 }; 32 33 class CryptoFile { 34 public: 35 CryptoFile() : valid(false) {} 36 CryptoFile(const CryptoFile& aCryptoFile) = delete; 37 38 void Update(const uint8_t* aData, size_t aLength) { 39 valid = DoUpdate(aData, aLength).isOk(); 40 } 41 42 bool valid; 43 nsTArray<PsshInfo> pssh; 44 45 private: 46 mozilla::Result<mozilla::Ok, nsresult> DoUpdate(const uint8_t* aData, 47 size_t aLength); 48 }; 49 50 class MP4AudioInfo : public mozilla::AudioInfo { 51 public: 52 MP4AudioInfo() = default; 53 54 MediaResult Update(const Mp4parseTrackInfo* aTrack, 55 const Mp4parseTrackAudioInfo* aAudio, 56 const IndiceWrapper* aIndices); 57 58 virtual bool IsValid() const override; 59 }; 60 61 class MP4VideoInfo : public mozilla::VideoInfo { 62 public: 63 MP4VideoInfo() = default; 64 65 MediaResult Update(const Mp4parseTrackInfo* track, 66 const Mp4parseTrackVideoInfo* video); 67 68 virtual bool IsValid() const override; 69 }; 70 71 } // namespace mozilla 72 73 #endif