• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_ADAPTER_WRAPPER_H
17 #define ARK_DRM_ADAPTER_WRAPPER_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 ArkDrmAdapterWrapper : public OHOS::NWeb::DrmAdapter {
26 public:
27     explicit ArkDrmAdapterWrapper(ArkWebRefPtr<ArkDrmAdapter>);
28 
29     bool IsSupported(const std::string& name) override;
30 
31     bool IsSupported2(const std::string& name, const std::string& mimeType) override;
32 
33     bool IsSupported3(const std::string& name, const std::string& mimeType, int32_t level) override;
34 
35     std::vector<uint8_t> GetUUID(const std::string& name) override;
36 
37     void StorageProvisionedResult(bool result) override;
38 
39     void StorageSaveInfoResult(bool result, int32_t type) override;
40 
41     void StorageLoadInfoResult(const std::string& sessionId, const std::vector<uint8_t>& keySetId,
42         const std::string& mimeType, uint32_t keyType) override;
43 
44     void StorageClearInfoResult(bool result, int32_t type) override;
45 
46     int32_t CreateKeySystem(const std::string& name, const std::string& origin, int32_t securityLevel) override;
47 
48     int32_t ReleaseMediaKeySystem() override;
49 
50     int32_t ReleaseMediaKeySession() override;
51 
52     int32_t SetConfigurationString(const std::string& configName, const std::string& value) override;
53 
54     int32_t GetConfigurationString(const std::string& configName, char* value, int32_t valueLen) override;
55 
56     int32_t SetConfigurationByteArray(const std::string& configName, const uint8_t* value, int32_t valueLen) override;
57 
58     int32_t GetConfigurationByteArray(const std::string& configName, uint8_t* value, int32_t* valueLen) override;
59 
60     int32_t GetMaxContentProtectionLevel(int32_t& level) override;
61 
62     int32_t ProcessKeySystemResponse(const std::string& response, bool isResponseReceived) override;
63 
64     int32_t GetCertificateStatus(int32_t& certStatus) override;
65 
66     int32_t RegistDrmCallback(std::shared_ptr<NWeb::DrmCallbackAdapter> callbackAdapter) override;
67 
68     int32_t UpdateSession(uint32_t promiseId, const std::string& sessionId, std::vector<uint8_t> response) override;
69 
70     int32_t CloseSession(uint32_t promiseId, const std::string& sessionId) override;
71 
72     int32_t RemoveSession(uint32_t promiseId, const std::string& sessionId) override;
73 
74     int32_t LoadSession(uint32_t promiseId, const std::string& sessionId) override;
75 
76     int32_t ClearMediaKeys() override;
77 
78     int32_t GetSecurityLevel() override;
79 
80     int32_t RequireSecureDecoderModule(const std::string& mimeType, bool& status) override;
81 
82     int32_t GenerateMediaKeyRequest(const std::string& sessionId, int32_t type, int32_t initDataLen,
83         const std::vector<uint8_t>& initData, const std::string& mimeType, uint32_t promiseId) override;
84 
85 private:
86     ArkWebRefPtr<ArkDrmAdapter> ctocpp_;
87 };
88 
89 } // namespace OHOS::ArkWeb
90 
91 #endif // ARK_DRM_ADAPTER_WRAPPER_H
92