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 CODECCOMMON_FUZZER_H 17 #define CODECCOMMON_FUZZER_H 18 19 #include <hdf_log.h> 20 #include "codec_omx_ext.h" 21 #include "v1_0/codec_types.h" 22 #include "v1_0/icodec_component.h" 23 #include "v1_0/icodec_component_manager.h" 24 #include "codeccallback_fuzzer.h" 25 26 using OHOS::HDI::Codec::V1_0::OmxCodecBuffer; 27 namespace OHOS { 28 namespace Codec { 29 inline OHOS::sptr<OHOS::HDI::Codec::V1_0::ICodecComponent> g_component; 30 inline OHOS::sptr<OHOS::HDI::Codec::V1_0::ICodecCallback> g_callback; 31 inline OHOS::sptr<OHOS::HDI::Codec::V1_0::ICodecComponentManager> g_manager; 32 extern uint32_t g_componentId; 33 34 void FillDataOmxCodecBuffer(struct OmxCodecBuffer *dataFuzz); 35 bool Preconditions(); 36 bool Destroy(); 37 void Release(); 38 39 template <typename T> ObjectToVector(T & params,std::vector<int8_t> & vec)40 void ObjectToVector(T ¶ms, std::vector<int8_t> &vec) 41 { 42 int8_t *paramPointer = (int8_t *)¶ms; 43 vec.insert(vec.end(), paramPointer, paramPointer + sizeof(params)); 44 } 45 46 } // namespace codec 47 } // namespace OHOS 48 #endif // CODECCOMMON_FUZZER_H 49