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/. */
5 #ifndef DOM_MEDIA_PLATFORM_WMF_CLEARKEY_WMFDECRYPTEDBLOCK_H
6 #define DOM_MEDIA_PLATFORM_WMF_CLEARKEY_WMFDECRYPTEDBLOCK_H
10 #include "WMFClearKeyUtils.h"
11 #include "content_decryption_module.h"
15 // This class is used to store the decrypted data. It will be allocated by
16 // `SessionManagerWrapper::Allocate`.
17 class WMFDecryptedBuffer
: public cdm::Buffer
{
19 explicit WMFDecryptedBuffer(size_t aSize
) {
21 LOG("WMFDecryptedBuffer ctor %p, sz=%u", this, Size());
23 ~WMFDecryptedBuffer() override
{
24 LOG("WMFDecryptedBuffer dtor %p, sz=%u", this, Size());
26 WMFDecryptedBuffer(const WMFDecryptedBuffer
&) = delete;
27 WMFDecryptedBuffer
& operator=(const WMFDecryptedBuffer
&) = delete;
29 // This is not good, but that is how cdm::buffer works.
30 void Destroy() override
{ delete this; }
31 uint32_t Capacity() const override
{ return mBuffer
.size(); }
32 uint8_t* Data() override
{ return mBuffer
.data(); }
33 void SetSize(uint32_t aSize
) override
{ return mBuffer
.resize(aSize
); }
34 uint32_t Size() const override
{ return mBuffer
.size(); }
37 std::vector
<uint8_t> mBuffer
;
40 class WMFDecryptedBlock
: public cdm::DecryptedBlock
{
42 WMFDecryptedBlock() : mBuffer(nullptr), mTimestamp(0) {
43 LOG("WMFDecryptedBlock ctor %p", this);
45 ~WMFDecryptedBlock() override
{
46 LOG("WMFDecryptedBlock dtor %p", this);
52 void SetDecryptedBuffer(cdm::Buffer
* aBuffer
) override
{
53 LOG("WMFDecryptedBlock(%p)::SetDecryptedBuffer, buffer=%p", this, aBuffer
);
56 cdm::Buffer
* DecryptedBuffer() override
{ return mBuffer
; }
57 void SetTimestamp(int64_t aTimestamp
) override
{ mTimestamp
= aTimestamp
; }
58 int64_t Timestamp() const override
{ return mTimestamp
; }
65 } // namespace mozilla
67 #endif // DOM_MEDIA_PLATFORM_WMF_CLEARKEY_WMFDECRYPTEDBLOCK_H