• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023-2024 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 
38 private:
39     int32_t DecryptByAesCbc(const std::vector<uint8_t> &key, const std::vector<uint8_t> &iv, uint8_t *src_data,
40         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, uint8_t *srcData,
42         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     sptr<Session> session_;
48 };
49 } // V1_0
50 } // Drm
51 } // HDI
52 } // OHOS
53 
54 #endif // OHOS_HDI_DRM_V1_0_MEDIADECRYPTMODULESERVICE_H
55