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_MEDIADECRYPTMODULESERVICE_H 17 #define OHOS_HDI_DRM_V1_0_MEDIADECRYPTMODULESERVICE_H 18 19 #include "v1_0/imedia_decrypt_module.h" 20 #include "session.h" 21 22 namespace OHOS { 23 namespace HDI { 24 namespace Drm { 25 namespace V1_0 { 26 class MediaDecryptModuleService : public OHOS::HDI::Drm::V1_0::IMediaDecryptModule { 27 public: 28 MediaDecryptModuleService(sptr<Session>& session); 29 virtual ~MediaDecryptModuleService() = default; 30 31 int32_t DecryptMediaData(bool secure, const CryptoInfo& cryptoInfo, const DrmBuffer& srcBuffer, 32 const DrmBuffer& destBuffer) override; 33 34 int32_t Release() override; 35 int32_t GetDecryptNumber(); 36 int32_t GetErrorDecryptNumber(); 37 int32_t GetDecryptTimes(std::vector<double> ×); 38 private: 39 int32_t DecryptByAesCbc(const std::vector<uint8_t>& key, const std::vector<uint8_t>& iv, 40 uint8_t* src_data, uint8_t* dest_data, const std::vector<SubSample>& subSamples); 41 int32_t DecryptBySM4Cbc(const std::vector<uint8_t> &key, const std::vector<uint8_t> &iv, 42 uint8_t *srcData, uint8_t *destData, const std::vector<SubSample> &subSamples); 43 44 int32_t CopyBuffer(uint8_t* srcBuffer, uint8_t* dstBuffer, const std::vector<SubSample>& subSamples); 45 int32_t decryptNumber = 0; 46 int32_t errorDecryptNumber = 0; 47 std::vector<double> decryptTimes; 48 sptr<Session> session_; 49 }; 50 } // V1_0 51 } // Drm 52 } // HDI 53 } // OHOS 54 55 #endif // OHOS_HDI_DRM_V1_0_MEDIADECRYPTMODULESERVICE_H 56