/work/obj-fuzz/dist/include/mozilla/CDMCaps.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 | | /* vim: set ts=8 sts=2 et sw=2 tw=80: */ |
3 | | /* This Source Code Form is subject to the terms of the Mozilla Public |
4 | | * License, v. 2.0. If a copy of the MPL was not distributed with this file, |
5 | | * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
6 | | |
7 | | #ifndef CDMCaps_h_ |
8 | | #define CDMCaps_h_ |
9 | | |
10 | | #include "nsIThread.h" |
11 | | #include "nsTArray.h" |
12 | | #include "nsString.h" |
13 | | #include "SamplesWaitingForKey.h" |
14 | | |
15 | | #include "mozilla/Monitor.h" |
16 | | #include "mozilla/Attributes.h" |
17 | | #include "mozilla/dom/MediaKeyStatusMapBinding.h" // For MediaKeyStatus |
18 | | #include "mozilla/dom/BindingDeclarations.h" // For Optional |
19 | | |
20 | | namespace mozilla { |
21 | | |
22 | | // CDM capabilities; what keys a CDMProxy can use. |
23 | | // Must be locked to access state. |
24 | | class CDMCaps { |
25 | | public: |
26 | | CDMCaps(); |
27 | | ~CDMCaps(); |
28 | | |
29 | | struct KeyStatus { |
30 | | KeyStatus(const CencKeyId& aId, |
31 | | const nsString& aSessionId, |
32 | | dom::MediaKeyStatus aStatus) |
33 | | : mId(aId) |
34 | | , mSessionId(aSessionId) |
35 | | , mStatus(aStatus) |
36 | 0 | {} |
37 | | KeyStatus(const KeyStatus& aOther) |
38 | | : mId(aOther.mId) |
39 | | , mSessionId(aOther.mSessionId) |
40 | | , mStatus(aOther.mStatus) |
41 | 0 | {} |
42 | 0 | bool operator==(const KeyStatus& aOther) const { |
43 | 0 | return mId == aOther.mId && |
44 | 0 | mSessionId == aOther.mSessionId; |
45 | 0 | }; |
46 | | |
47 | | CencKeyId mId; |
48 | | nsString mSessionId; |
49 | | dom::MediaKeyStatus mStatus; |
50 | | }; |
51 | | |
52 | | bool IsKeyUsable(const CencKeyId& aKeyId); |
53 | | |
54 | | // Returns true if key status changed, |
55 | | // i.e. the key status changed from usable to expired. |
56 | | bool SetKeyStatus(const CencKeyId& aKeyId, |
57 | | const nsString& aSessionId, |
58 | | const dom::Optional<dom::MediaKeyStatus>& aStatus); |
59 | | |
60 | | void GetKeyStatusesForSession(const nsAString& aSessionId, |
61 | | nsTArray<KeyStatus>& aOutKeyStatuses); |
62 | | |
63 | | // Ensures all keys for a session are marked as 'unknown', i.e. removed. |
64 | | // Returns true if a key status was changed. |
65 | | bool RemoveKeysForSession(const nsString& aSessionId); |
66 | | |
67 | | // Notifies the SamplesWaitingForKey when key become usable. |
68 | | void NotifyWhenKeyIdUsable(const CencKeyId& aKey, |
69 | | SamplesWaitingForKey* aSamplesWaiting); |
70 | | |
71 | | private: |
72 | | |
73 | | struct WaitForKeys { |
74 | | WaitForKeys(const CencKeyId& aKeyId, |
75 | | SamplesWaitingForKey* aListener) |
76 | | : mKeyId(aKeyId) |
77 | | , mListener(aListener) |
78 | 0 | {} |
79 | | CencKeyId mKeyId; |
80 | | RefPtr<SamplesWaitingForKey> mListener; |
81 | | }; |
82 | | |
83 | | nsTArray<KeyStatus> mKeyStatuses; |
84 | | |
85 | | nsTArray<WaitForKeys> mWaitForKeys; |
86 | | |
87 | | // It is not safe to copy this object. |
88 | | CDMCaps(const CDMCaps&) = delete; |
89 | | CDMCaps& operator=(const CDMCaps&) = delete; |
90 | | }; |
91 | | |
92 | | } // namespace mozilla |
93 | | |
94 | | #endif |