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