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 #ifndef OHOS_DRM_MEDIADECRYPTMODULESERVICE_H 16 #define OHOS_DRM_MEDIADECRYPTMODULESERVICE_H 17 18 #include <iostream> 19 #include <refbase.h> 20 #include "drm_host_manager.h" 21 #include "drm_log.h" 22 #include "drm_dfx.h" 23 #include "drm_dfx_utils.h" 24 #include "media_decrypt_module_service_stub.h" 25 #include "v1_0/media_decrypt_module_proxy.h" 26 27 namespace OHOS { 28 namespace DrmStandard { 29 using namespace OHOS::HDI::Drm::V1_0; 30 using namespace OHOS::HDI; 31 32 class MediaDecryptModuleService : public MediaDecryptModuleServiceStub { 33 public: 34 MediaDecryptModuleService(sptr<OHOS::HDI::Drm::V1_0::IMediaDecryptModule> hdiMediaDecryptModule); 35 MediaDecryptModuleService(sptr<OHOS::HDI::Drm::V1_0::IMediaDecryptModule> hdiMediaDecryptModule, 36 StatisticsInfo statisticsInfo); 37 ~MediaDecryptModuleService(); 38 int32_t Release() override; 39 int32_t DecryptMediaData(bool secureDecodrtState, IMediaDecryptModuleService::CryptInfo &cryptInfo, 40 IMediaDecryptModuleService::DrmBuffer &srcBuffer, IMediaDecryptModuleService::DrmBuffer &dstBuffer) override; 41 std::string GetDumpInfo(); 42 43 private: 44 void SetCryptInfo(OHOS::HDI::Drm::V1_0::CryptoInfo &cryptInfoTmp, 45 IMediaDecryptModuleService::CryptInfo &cryptInfo, uint32_t &bufLen); 46 void SetDrmBufferInfo(OHOS::HDI::Drm::V1_0::DrmBuffer* drmSrcBuffer, OHOS::HDI::Drm::V1_0::DrmBuffer* drmDstBuffer, 47 IMediaDecryptModuleService::DrmBuffer &srcBuffer, IMediaDecryptModuleService::DrmBuffer &dstBuffer, 48 uint32_t bufLen); 49 void UpdateDecryptionStatistics(int32_t decryptionResult, uint32_t bufLen, uint32_t curDuration); 50 const std::string GetTopThreeDecryptionDurations(); 51 52 std::recursive_mutex moduleLock_; 53 sptr<OHOS::HDI::Drm::V1_0::IMediaDecryptModule> hdiMediaDecryptModule_; 54 StatisticsInfo statisticsInfo_; 55 std::recursive_mutex statisticsMutex_; 56 DecryptionStatistics decryptStatistics_; 57 uint64_t instanceId_; 58 }; 59 } // DrmStandard 60 } // OHOS 61 62 #endif // OHOS_DRM_MediaDecryptModuleService_H_