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_DRM_I_MEDIA_DECRYPT_MODULE_SERVICE_H 17 #define OHOS_DRM_I_MEDIA_DECRYPT_MODULE_SERVICE_H 18 19 #include "ipc_types.h" 20 #include "iremote_broker.h" 21 #include "iremote_proxy.h" 22 #include "iremote_stub.h" 23 24 namespace OHOS { 25 namespace DrmStandard { 26 class IMediaDecryptModuleService : public IRemoteBroker { 27 public: 28 struct SubSample { 29 uint32_t clearHeaderLen; 30 uint32_t payLoadLen; 31 }; 32 33 struct Pattern { 34 uint32_t encryptBlocks; 35 uint32_t skipBlocks; 36 }; 37 38 enum CryptAlgorithmType { 39 ALGTYPE_UNENCRYPTED = 0, 40 ALGTYPE_AES_CTR, 41 ALGTYPE_AES_WV, 42 ALGTYPE_AES_CBC, 43 ALGTYPE_SM4_CBC, 44 ALGTYPE_SM4_CTR, 45 }; 46 47 struct CryptInfo { 48 CryptAlgorithmType type; 49 std::vector<uint8_t> keyId; 50 std::vector<uint8_t> iv; 51 Pattern pattern; 52 std::vector<SubSample> subSample; 53 }; 54 55 struct DrmBuffer { 56 uint32_t bufferType; 57 int fd; 58 uint32_t bufferLen; 59 uint32_t allocLen; 60 uint32_t filledLen; 61 uint32_t offset; 62 uint32_t sharedMemType; 63 }; 64 65 virtual ~IMediaDecryptModuleService() = default; 66 virtual int32_t Release() = 0; 67 virtual int32_t DecryptMediaData(bool secureDecodrtState, IMediaDecryptModuleService::CryptInfo &cryptInfo, 68 DrmBuffer &srcBuffer, DrmBuffer &dstBuffer) = 0; 69 DECLARE_INTERFACE_DESCRIPTOR(u"IMediaDecryptModuleService"); 70 }; 71 } // DrmStandard 72 } // OHOS 73 #endif // OHOS_DRM_I_MEDIA_DECRYPT_MODULE_SERVICE_H