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