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_CENC_INFO_ADAPTER_H 17 #define AUDIO_CENC_INFO_ADAPTER_H 18 19 #include <vector> 20 #include <cstdint> 21 22 namespace OHOS::NWeb { 23 24 // 和native_cencinfo.h中DrmCencAlgorithm保持一致 25 enum class DrmCencAlgorithmAdapter { 26 /** 27 * Unencrypted. 28 */ 29 DRM_ALG_CENC_UNENCRYPTED = 0x0, 30 /** 31 * Aes ctr. 32 */ 33 DRM_ALG_CENC_AES_CTR = 0x1, 34 /** 35 * Aes wv. 36 */ 37 DRM_ALG_CENC_AES_WV = 0x2, 38 /** 39 * Aes cbc. 40 */ 41 DRM_ALG_CENC_AES_CBC = 0x3, 42 /** 43 * Sm4 cbc. 44 */ 45 DRM_ALG_CENC_SM4_CBC = 0x4, 46 /** 47 * Sm4 ctr. 48 */ 49 DRM_ALG_CENC_SM4_CTR = 0x5 50 }; 51 52 // 和native_cencinfo.h中DrmCencInfoMode保持一致 53 enum class DrmCencInfoModeAdapter { 54 /* key/iv/subsample set. */ 55 DRM_CENC_INFO_KEY_IV_SUBSAMPLES_SET = 0x0, 56 /* key/iv/subsample not set. */ 57 DRM_CENC_INFO_KEY_IV_SUBSAMPLES_NOT_SET = 0x1 58 }; 59 60 class AudioCencInfoAdapter { 61 public: 62 AudioCencInfoAdapter() = default; 63 64 virtual ~AudioCencInfoAdapter() = default; 65 66 virtual uint8_t* GetKeyId() = 0; 67 68 virtual uint32_t GetKeyIdLen() = 0; 69 70 virtual uint8_t* GetIv() = 0; 71 72 virtual uint32_t GetIvLen() = 0; 73 74 virtual uint32_t GetEncryptedBlockCount() = 0; 75 76 virtual uint32_t GetAlgo() = 0; 77 78 virtual uint32_t GetSkippedBlockCount() = 0; 79 80 virtual uint32_t GetFirstEncryptedOffset() = 0; 81 82 virtual std::vector<uint32_t> GetClearHeaderLens() = 0; 83 84 virtual std::vector<uint32_t> GetPayLoadLens() = 0; 85 86 virtual uint32_t GetMode() = 0; 87 88 virtual void SetKeyId(uint8_t* keyId) = 0; 89 90 virtual void SetKeyIdLen(uint32_t keyIdLen) = 0; 91 92 virtual void SetIv(uint8_t* iv) = 0; 93 94 virtual void SetIvLen(uint32_t ivLen) = 0; 95 96 virtual void SetAlgo(uint32_t algo) = 0; 97 98 virtual void SetEncryptedBlockCount(uint32_t encryptedBlockCount) = 0; 99 100 virtual void SetSkippedBlockCount(uint32_t skippedBlockCount) = 0; 101 102 virtual void SetFirstEncryptedOffset(uint32_t firstEncryptedOffset) = 0; 103 104 virtual void SetClearHeaderLens(const std::vector<uint32_t>& clearHeaderLens) = 0; 105 106 virtual void SetPayLoadLens(const std::vector<uint32_t>& payLoadLens) = 0; 107 108 virtual void SetMode(uint32_t mode) = 0; 109 }; 110 111 } // namespace OHOS::NWeb 112 113 #endif // AUDIO_CODEC_DECODER_ADAPTER_H