Line data Source code
1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* This Source Code Form is subject to the terms of the Mozilla Public
3 : * License, v. 2.0. If a copy of the MPL was not distributed with this
4 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 :
6 : #ifndef GMPEncryptedBufferDataImpl_h_
7 : #define GMPEncryptedBufferDataImpl_h_
8 :
9 : #include "gmp-decryption.h"
10 : #include "nsAutoPtr.h"
11 : #include "nsTArray.h"
12 : #include "mozilla/gmp/GMPTypes.h"
13 :
14 : namespace mozilla {
15 : class CryptoSample;
16 :
17 : namespace gmp {
18 :
19 0 : class GMPStringListImpl : public GMPStringList
20 : {
21 : public:
22 : explicit GMPStringListImpl(const nsTArray<nsCString>& aStrings);
23 : uint32_t Size() const override;
24 : void StringAt(uint32_t aIndex,
25 : const char** aOutString, uint32_t *aOutLength) const override;
26 : virtual ~GMPStringListImpl() override;
27 : void RelinquishData(nsTArray<nsCString>& aStrings);
28 :
29 : private:
30 : nsTArray<nsCString> mStrings;
31 : };
32 :
33 0 : class GMPEncryptedBufferDataImpl : public GMPEncryptedBufferMetadata {
34 : public:
35 : explicit GMPEncryptedBufferDataImpl(const CryptoSample& aCrypto);
36 : explicit GMPEncryptedBufferDataImpl(const GMPDecryptionData& aData);
37 : virtual ~GMPEncryptedBufferDataImpl();
38 :
39 : void RelinquishData(GMPDecryptionData& aData);
40 :
41 : const uint8_t* KeyId() const override;
42 : uint32_t KeyIdSize() const override;
43 : const uint8_t* IV() const override;
44 : uint32_t IVSize() const override;
45 : uint32_t NumSubsamples() const override;
46 : const uint16_t* ClearBytes() const override;
47 : const uint32_t* CipherBytes() const override;
48 : const GMPStringList* SessionIds() const override;
49 :
50 : private:
51 : nsTArray<uint8_t> mKeyId;
52 : nsTArray<uint8_t> mIV;
53 : nsTArray<uint16_t> mClearBytes;
54 : nsTArray<uint32_t> mCipherBytes;
55 :
56 : GMPStringListImpl mSessionIdList;
57 : };
58 :
59 0 : class GMPBufferImpl : public GMPBuffer {
60 : public:
61 0 : GMPBufferImpl(uint32_t aId, const nsTArray<uint8_t>& aData)
62 0 : : mId(aId)
63 0 : , mData(aData)
64 : {
65 0 : }
66 0 : uint32_t Id() const override {
67 0 : return mId;
68 : }
69 0 : uint8_t* Data() override {
70 0 : return mData.Elements();
71 : }
72 0 : uint32_t Size() const override {
73 0 : return mData.Length();
74 : }
75 0 : void Resize(uint32_t aSize) override {
76 0 : mData.SetLength(aSize);
77 0 : }
78 :
79 : // Set metadata object to be freed when this buffer is destroyed.
80 0 : void SetMetadata(GMPEncryptedBufferDataImpl* aMetadata) {
81 0 : mMetadata = aMetadata;
82 0 : }
83 :
84 : uint32_t mId;
85 : nsTArray<uint8_t> mData;
86 : nsAutoPtr<GMPEncryptedBufferDataImpl> mMetadata;
87 : };
88 :
89 : } // namespace gmp
90 : } // namespace mozilla
91 :
92 : #endif // GMPEncryptedBufferDataImpl_h_
|