1 /* 2 * Copyright (c) 2023-2024 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 OHOS_HDI_DRM_V1_0_MEDIAKEYSYSTEMPROXY_H 17 #define OHOS_HDI_DRM_V1_0_MEDIAKEYSYSTEMPROXY_H 18 19 #include "v1_0/imedia_key_system.h" 20 #include <iproxy_broker.h> 21 22 namespace OHOS { 23 namespace HDI { 24 namespace Drm { 25 namespace V1_0 { 26 class MediaKeySystemProxy : public IProxyBroker<OHOS::HDI::Drm::V1_0::IMediaKeySystem> { 27 public: MediaKeySystemProxy(const sptr<IRemoteObject> & remote)28 explicit MediaKeySystemProxy(const sptr<IRemoteObject> &remote) 29 : IProxyBroker<OHOS::HDI::Drm::V1_0::IMediaKeySystem>(remote) 30 {} 31 32 virtual ~MediaKeySystemProxy() = default; 33 IsProxy()34 inline bool IsProxy() override 35 { 36 return true; 37 } 38 39 int32_t GetConfigurationString(const std::string &name, std::string &value) override; 40 41 int32_t SetConfigurationString(const std::string &name, const std::string &value) override; 42 43 int32_t GetConfigurationByteArray(const std::string &name, std::vector<uint8_t> &value) override; 44 45 int32_t SetConfigurationByteArray(const std::string &name, const std::vector<uint8_t> &value) override; 46 47 int32_t GetStatistics(std::map<std::string, std::string> &statistics) override; 48 49 int32_t GetMaxContentProtectionLevel(OHOS::HDI::Drm::V1_0::ContentProtectionLevel &level) override; 50 51 int32_t GenerateKeySystemRequest(std::string &defaultUrl, std::vector<uint8_t> &request) override; 52 53 int32_t ProcessKeySystemResponse(const std::vector<uint8_t> &response) override; 54 55 int32_t GetOemCertificateStatus(OHOS::HDI::Drm::V1_0::CertificateStatus &status) override; 56 57 int32_t SetCallback(const sptr<OHOS::HDI::Drm::V1_0::IMediaKeySystemCallback> &systemCallback) override; 58 59 int32_t CreateMediaKeySession(OHOS::HDI::Drm::V1_0::ContentProtectionLevel level, 60 sptr<OHOS::HDI::Drm::V1_0::IMediaKeySession> &keySession) override; 61 62 int32_t GetOfflineMediaKeyIds(std::vector<std::vector<uint8_t>> &mediaKeyIds) override; 63 64 int32_t GetOfflineMediaKeyStatus(const std::vector<uint8_t> &mediaKeyId, 65 OHOS::HDI::Drm::V1_0::OfflineMediaKeyStatus &mediaKeyStatus) override; 66 67 int32_t ClearOfflineMediaKeys(const std::vector<uint8_t> &mediaKeyId) override; 68 69 int32_t GetOemCertificate(sptr<OHOS::HDI::Drm::V1_0::IOemCertificate> &oemCert) override; 70 71 int32_t Destroy() override; 72 73 int32_t GetVersion(uint32_t &majorVer, uint32_t &minorVer) override; 74 75 static int32_t GetConfigurationString_(const std::string &name, std::string &value, 76 const sptr<IRemoteObject> remote); 77 78 static int32_t SetConfigurationString_(const std::string &name, const std::string &value, 79 const sptr<IRemoteObject> remote); 80 81 static int32_t GetConfigurationByteArray_(const std::string &name, std::vector<uint8_t> &value, 82 const sptr<IRemoteObject> remote); 83 84 static int32_t SetConfigurationByteArray_(const std::string &name, const std::vector<uint8_t> &value, 85 const sptr<IRemoteObject> remote); 86 87 static int32_t GetStatistics_(std::map<std::string, std::string> &statistics, const sptr<IRemoteObject> remote); 88 89 static int32_t GetMaxContentProtectionLevel_(OHOS::HDI::Drm::V1_0::ContentProtectionLevel &level, 90 const sptr<IRemoteObject> remote); 91 92 static int32_t GenerateKeySystemRequest_(std::string &defaultUrl, std::vector<uint8_t> &request, 93 const sptr<IRemoteObject> remote); 94 95 static int32_t ProcessKeySystemResponse_(const std::vector<uint8_t> &response, const sptr<IRemoteObject> remote); 96 97 static int32_t GetOemCertificateStatus_(OHOS::HDI::Drm::V1_0::CertificateStatus &status, 98 const sptr<IRemoteObject> remote); 99 100 static int32_t SetCallback_(const sptr<OHOS::HDI::Drm::V1_0::IMediaKeySystemCallback> &systemCallback, 101 const sptr<IRemoteObject> remote); 102 103 static int32_t CreateMediaKeySession_(OHOS::HDI::Drm::V1_0::ContentProtectionLevel level, 104 sptr<OHOS::HDI::Drm::V1_0::IMediaKeySession> &keySession, const sptr<IRemoteObject> remote); 105 106 static int32_t GetOfflineMediaKeyIds_(std::vector<std::vector<uint8_t>> &mediaKeyIds, 107 const sptr<IRemoteObject> remote); 108 109 static int32_t GetOfflineMediaKeyStatus_(const std::vector<uint8_t> &mediaKeyId, 110 OHOS::HDI::Drm::V1_0::OfflineMediaKeyStatus &mediaKeyStatus, const sptr<IRemoteObject> remote); 111 112 static int32_t ClearOfflineMediaKeys_(const std::vector<uint8_t> &mediaKeyId, const sptr<IRemoteObject> remote); 113 114 static int32_t GetOemCertificate_(sptr<OHOS::HDI::Drm::V1_0::IOemCertificate> &oemCert, 115 const sptr<IRemoteObject> remote); 116 117 static int32_t Destroy_(const sptr<IRemoteObject> remote); 118 119 static int32_t GetVersion_(uint32_t &majorVer, uint32_t &minorVer, const sptr<IRemoteObject> remote); 120 121 private: 122 static inline BrokerDelegator<OHOS::HDI::Drm::V1_0::MediaKeySystemProxy> delegator_; 123 }; 124 } // V1_0 125 } // Drm 126 } // HDI 127 } // OHOS 128 129 #endif // OHOS_HDI_DRM_V1_0_MEDIAKEYSYSTEMPROXY_H