1 /* 2 * Copyright (c) 2025 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef ARK_DRM_CALLBACK_ADAPTER_IMPL_H 17 #define ARK_DRM_CALLBACK_ADAPTER_IMPL_H 18 #pragma once 19 20 #include "drm_adapter.h" 21 #include "ohos_adapter/include/ark_drm_adapter.h" 22 23 namespace OHOS::ArkWeb { 24 25 class ArkDrmCallbackAdapterImpl : public ArkDrmCallbackAdapter { 26 public: 27 ArkDrmCallbackAdapterImpl(std::shared_ptr<OHOS::NWeb::DrmCallbackAdapter>); 28 29 void OnSessionMessage(const ArkWebString& sessionId, int32_t& type, const ArkWebUint8Vector& message) override; 30 31 void OnProvisionRequest(const ArkWebString& defaultUrl, const ArkWebString& requestData) override; 32 33 void OnProvisioningComplete(bool success) override; 34 35 void OnMediaKeySessionReady(void* session) override; 36 37 void OnPromiseRejected(uint32_t promiseId, const ArkWebString& errorMessage) override; 38 39 void OnPromiseResolved(uint32_t promiseId) override; 40 41 void OnPromiseResolvedWithSession(uint32_t promiseId, const ArkWebString& sessionId) override; 42 43 void OnSessionClosed(const ArkWebString& sessionId) override; 44 45 void OnSessionKeysChange(const ArkWebString& sessionId, const ArkWebStringVector& keyIdArray, 46 const ArkWebUint32Vector& statusArray, bool hasAdditionalUsableKey, bool isKeyRelease) override; 47 48 void OnSessionExpirationUpdate(const ArkWebString& sessionId, uint64_t expirationTime) override; 49 50 void OnStorageProvisioned() override; 51 52 void OnStorageSaveInfo(const ArkWebUint8Vector& ketSetId, const ArkWebString& mimeType, 53 const ArkWebString& sessionId, int32_t keyType) override; 54 55 void OnStorageLoadInfo(const ArkWebString& sessionId) override; 56 57 void OnStorageClearInfoForKeyRelease(const ArkWebString& sessionId) override; 58 59 void OnStorageClearInfoForLoadFail(const ArkWebString& sessionId) override; 60 61 void OnMediaLicenseReady(bool success) override; 62 63 private: 64 std::shared_ptr<OHOS::NWeb::DrmCallbackAdapter> real_; 65 66 IMPLEMENT_REFCOUNTING(ArkDrmCallbackAdapterImpl); 67 }; 68 69 } // namespace OHOS::ArkWeb 70 71 #endif // ARK_DRM_CALLBACK_ADAPTER_IMPL_H 72