mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
45 lines
1.3 KiB
C++
45 lines
1.3 KiB
C++
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
#include "ClearKeySession.h"
|
|
#include "ClearKeyUtils.h"
|
|
|
|
#include "gmp-api/gmp-decryption.h"
|
|
#include "mozilla/Endian.h"
|
|
#include "pk11pub.h"
|
|
|
|
using namespace mozilla;
|
|
|
|
ClearKeySession::ClearKeySession(const std::string& aSessionId,
|
|
GMPDecryptorHost* aHost,
|
|
GMPDecryptorCallback* aCallback)
|
|
: mSessionId(aSessionId)
|
|
, mHost(aHost)
|
|
, mCallback(aCallback)
|
|
{
|
|
CK_LOGD("ClearKeySession ctor %p", this);
|
|
}
|
|
|
|
ClearKeySession::~ClearKeySession()
|
|
{
|
|
CK_LOGD("ClearKeySession dtor %p", this);
|
|
}
|
|
|
|
void
|
|
ClearKeySession::Init(uint32_t aPromiseId,
|
|
const uint8_t* aInitData, uint32_t aInitDataSize)
|
|
{
|
|
CK_LOGD("ClearKeySession::Init");
|
|
|
|
ClearKeyUtils::ParseInitData(aInitData, aInitDataSize, mKeyIds);
|
|
if (!mKeyIds.size()) {
|
|
const char message[] = "Couldn't parse cenc key init data";
|
|
mCallback->RejectPromise(aPromiseId, kGMPAbortError, message, strlen(message));
|
|
return;
|
|
}
|
|
|
|
mCallback->ResolveNewSessionPromise(aPromiseId,
|
|
mSessionId.data(), mSessionId.length());
|
|
}
|