SinfParser.h (1329B)
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 SINF_PARSER_H_ 6 #define SINF_PARSER_H_ 7 8 #include "Atom.h" 9 #include "AtomType.h" 10 #include "nsTArray.h" 11 12 namespace mozilla { 13 14 class Box; 15 16 class Sinf : public Atom { 17 public: 18 Sinf() 19 : mDefaultIVSize(0), 20 21 mDefaultCryptByteBlock(0), 22 mDefaultSkipByteBlock(0) {} 23 explicit Sinf(const Box& aBox); 24 25 bool IsValid() const override { 26 return !!mDefaultEncryptionType && // Should have an encryption scheme 27 (mDefaultIVSize > 0 || // and either a default IV size 28 mDefaultConstantIV.Length() > 0); // or a constant IV. 29 } 30 31 uint8_t mDefaultIVSize; 32 AtomType mDefaultEncryptionType; 33 uint8_t mDefaultKeyID[16]; 34 uint8_t mDefaultCryptByteBlock; 35 uint8_t mDefaultSkipByteBlock; 36 CopyableTArray<uint8_t> mDefaultConstantIV; 37 }; 38 39 class SinfParser { 40 public: 41 explicit SinfParser(const Box& aBox); 42 43 Sinf& GetSinf() { return mSinf; } 44 45 private: 46 Result<Ok, nsresult> ParseSchm(const Box& aBox); 47 Result<Ok, nsresult> ParseSchi(const Box& aBox); 48 Result<Ok, nsresult> ParseTenc(const Box& aBox); 49 50 Sinf mSinf; 51 }; 52 53 } // namespace mozilla 54 55 #endif // SINF_PARSER_H_