• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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 AUDIO_AVCENC_INFO_ADAPTER_IMPL_H
17 #define AUDIO_AVCENC_INFO_ADAPTER_IMPL_H
18 
19 #include "audio_cenc_info_adapter.h"
20 
21 #include <vector>
22 #include <cstdint>
23 
24 #include "nweb_log.h"
25 
26 namespace OHOS::NWeb {
27 
28 class AudioCencInfoAdapterImpl : public AudioCencInfoAdapter {
29 public:
30     AudioCencInfoAdapterImpl() = default;
31 
32     ~AudioCencInfoAdapterImpl() override;
33 
34     uint8_t* GetKeyId() override;
35 
36     uint32_t GetKeyIdLen() override;
37 
38     uint8_t* GetIv() override;
39 
40     uint32_t GetIvLen() override;
41 
42     uint32_t GetAlgo() override;
43 
44     uint32_t GetEncryptedBlockCount() override;
45 
46     uint32_t GetSkippedBlockCount() override;
47 
48     uint32_t GetFirstEncryptedOffset() override;
49 
50     std::vector<uint32_t> GetClearHeaderLens() override;
51 
52     std::vector<uint32_t> GetPayLoadLens() override;
53 
54     uint32_t GetMode() override;
55 
56     void SetKeyId(uint8_t* keyId) override;
57 
58     void SetKeyIdLen(uint32_t keyIdLen) override;
59 
60     void SetIv(uint8_t* iv) override;
61 
62     void SetIvLen(uint32_t ivLen) override;
63 
64     void SetAlgo(uint32_t algo) override;
65 
66     void SetEncryptedBlockCount(uint32_t count) override;
67 
68     void SetSkippedBlockCount(uint32_t count) override;
69 
70     void SetFirstEncryptedOffset(uint32_t offset) override;
71 
72     void SetClearHeaderLens(const std::vector<uint32_t>& lens) override;
73 
74     void SetPayLoadLens(const std::vector<uint32_t>& lens) override;
75 
76     void SetMode(uint32_t mode) override;
77 
PrintCencInfoData(std::shared_ptr<AudioCencInfoAdapter> cencInfo)78     static void PrintCencInfoData(std::shared_ptr<AudioCencInfoAdapter> cencInfo)
79     {
80         if (cencInfo) {
81             WVLOG_I("AudioCodecDecoder PrintFormatData:algo[%{public}u], encryptedBlockCount[%{public}u],"
82                     "skippedBlockCount[%{public}u], firstEncryptedOffset[%{public}u], mode[%{public}u],",
83                     cencInfo->GetAlgo(), cencInfo->GetEncryptedBlockCount(), cencInfo->GetSkippedBlockCount(),
84                     cencInfo->GetFirstEncryptedOffset(), cencInfo->GetMode());
85         }
86     }
87 private:
88     uint8_t* keyId_;
89     uint32_t keyIdLen_;
90     uint8_t* iv_;
91     uint32_t ivLen_;
92     uint32_t algo_;
93     uint32_t encryptedBlockCount_;
94     uint32_t skippedBlockCount_;
95     uint32_t firstEncryptedOffset_;
96     std::vector<uint32_t> clearHeaderLens_;
97     std::vector<uint32_t> payLoadLens_;
98     uint32_t mode_;
99 };
100 
101 } // namespace OHOS::NWeb
102 
103 #endif // AUDIO_AVCENC_INFO_ADAPTER_IMPL_H