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/. */
12 #include "SamplesWaitingForKey.h"
14 #include "mozilla/Monitor.h"
15 #include "mozilla/Attributes.h"
16 #include "mozilla/dom/MediaKeyStatusMapBinding.h" // For MediaKeyStatus
17 #include "mozilla/dom/BindingDeclarations.h" // For Optional
21 // CDM capabilities; what keys a CDMProxy can use.
22 // Must be locked to access state.
29 KeyStatus(const CencKeyId
& aId
, const nsString
& aSessionId
,
30 dom::MediaKeyStatus aStatus
)
31 : mId(aId
.Clone()), mSessionId(aSessionId
), mStatus(aStatus
) {}
32 KeyStatus(const KeyStatus
& aOther
)
33 : mId(aOther
.mId
.Clone()),
34 mSessionId(aOther
.mSessionId
),
35 mStatus(aOther
.mStatus
) {}
36 bool operator==(const KeyStatus
& aOther
) const {
37 return mId
== aOther
.mId
&& mSessionId
== aOther
.mSessionId
;
42 dom::MediaKeyStatus mStatus
;
45 bool IsKeyUsable(const CencKeyId
& aKeyId
);
47 // Returns true if key status changed,
48 // i.e. the key status changed from usable to expired.
49 bool SetKeyStatus(const CencKeyId
& aKeyId
, const nsString
& aSessionId
,
50 const dom::Optional
<dom::MediaKeyStatus
>& aStatus
);
52 void GetKeyStatusesForSession(const nsAString
& aSessionId
,
53 nsTArray
<KeyStatus
>& aOutKeyStatuses
);
55 // Ensures all keys for a session are marked as 'unknown', i.e. removed.
56 // Returns true if a key status was changed.
57 bool RemoveKeysForSession(const nsString
& aSessionId
);
59 // Notifies the SamplesWaitingForKey when key become usable.
60 void NotifyWhenKeyIdUsable(const CencKeyId
& aKey
,
61 SamplesWaitingForKey
* aSamplesWaiting
);
65 WaitForKeys(const CencKeyId
& aKeyId
, SamplesWaitingForKey
* aListener
)
66 : mKeyId(aKeyId
.Clone()), mListener(aListener
) {}
68 RefPtr
<SamplesWaitingForKey
> mListener
;
71 nsTArray
<KeyStatus
> mKeyStatuses
;
73 nsTArray
<WaitForKeys
> mWaitForKeys
;
75 // It is not safe to copy this object.
76 CDMCaps(const CDMCaps
&) = delete;
77 CDMCaps
& operator=(const CDMCaps
&) = delete;
80 } // namespace mozilla