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 DEFERREDPROCESSING_FUZZER_H 17 #define DEFERREDPROCESSING_FUZZER_H 18 #define FUZZ_PROJECT_NAME "deferredprocessing_fuzzer" 19 #include <iostream> 20 #include "deferred_photo_processing_session.h" 21 #include "deferred_photo_processor.h" 22 #include "ideferred_photo_processing_session_callback.h" 23 #include "deferred_photo_processing_session_callback_stub.h" 24 #include "deferred_video_processing_session.h" 25 #include "ideferred_video_processing_session_callback.h" 26 #include "deferred_video_processing_session_callback_stub.h" 27 namespace OHOS { 28 namespace CameraStandard { 29 using namespace OHOS::CameraStandard::DeferredProcessing; 30 void DeferredProcessingFuzzTestGetPermission(); 31 void DeferredProcessingPhotoFuzzTest(uint8_t *rawData, size_t size); 32 void DeferredProcessingVideoFuzzTest(uint8_t *rawData, size_t size); 33 34 class IDeferredPhotoProcessingSessionCallbackFuzz : public DeferredPhotoProcessingSessionCallbackStub { 35 public: 36 explicit IDeferredPhotoProcessingSessionCallbackFuzz() = default; 37 virtual ~IDeferredPhotoProcessingSessionCallbackFuzz() = default; OnProcessImageDone(const std::string & imageId,sptr<IPCFileDescriptor> ipcFd,const long bytes,uint32_t cloudImageEnhanceFlag)38 inline int32_t OnProcessImageDone(const std::string &imageId, 39 sptr<IPCFileDescriptor> ipcFd, const long bytes, uint32_t cloudImageEnhanceFlag) override 40 { 41 return 0; 42 } OnProcessImageDone(const std::string & imageId,std::shared_ptr<PictureIntf> picture,uint32_t cloudImageEnhanceFlag)43 inline int32_t OnProcessImageDone(const std::string &imageId, std::shared_ptr<PictureIntf> picture, 44 uint32_t cloudImageEnhanceFlag) override 45 { 46 return 0; 47 } OnDeliveryLowQualityImage(const std::string & imageId,std::shared_ptr<PictureIntf> picture)48 inline int32_t OnDeliveryLowQualityImage(const std::string &imageId, 49 std::shared_ptr<PictureIntf> picture) override 50 { 51 return 0; 52 } OnError(const std::string & imageId,const ErrorCode errorCode)53 inline int32_t OnError(const std::string &imageId, const ErrorCode errorCode) override 54 { 55 return 0; 56 } OnStateChanged(const StatusCode status)57 inline int32_t OnStateChanged(const StatusCode status) override 58 { 59 return 0; 60 } 61 }; 62 63 class IDeferredVideoProcessingSessionCallbackFuzz : public DeferredVideoProcessingSessionCallbackStub { 64 public: 65 explicit IDeferredVideoProcessingSessionCallbackFuzz() = default; 66 virtual ~IDeferredVideoProcessingSessionCallbackFuzz() = default; OnProcessVideoDone(const std::string & videoId,const sptr<IPCFileDescriptor> & fd)67 inline ErrCode OnProcessVideoDone(const std::string& videoId, const sptr<IPCFileDescriptor>& fd) override 68 { 69 return 0; 70 } OnError(const std::string & videoId,int32_t errorCode)71 inline ErrCode OnError(const std::string& videoId, int32_t errorCode) override 72 { 73 return 0; 74 } OnStateChanged(int32_t status)75 inline ErrCode OnStateChanged(int32_t status) override 76 { 77 return 0; 78 } 79 }; 80 81 void TestBufferInfo(uint8_t *rawData, size_t size); 82 } //CameraStandard 83 } //OHOS 84 #endif //DEFERREDPROCESSING_FUZZER_H 85 86