• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1  /*
2  * Copyright (c) 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 HSTREAM_CAPTURE_FUZZER_H
17 #define HSTREAM_CAPTURE_FUZZER_H
18 
19 #include "stream_capture_stub.h"
20 #include "hstream_capture.h"
21 #include "hcamera_device.h"
22 #include <fuzzer/FuzzedDataProvider.h>
23 
24 namespace OHOS {
25 namespace CameraStandard {
26 
27 class IStreamOperatorMock : public IStreamOperator {
28 public:
29     explicit IStreamOperatorMock() = default;
IsStreamsSupported(OHOS::HDI::Camera::V1_0::OperationMode mode,const std::vector<uint8_t> & modeSetting,const std::vector<OHOS::HDI::Camera::V1_0::StreamInfo> & infos,OHOS::HDI::Camera::V1_0::StreamSupportType & type)30     inline int32_t IsStreamsSupported(OHOS::HDI::Camera::V1_0::OperationMode mode,
31         const std::vector<uint8_t>& modeSetting,
32         const std::vector<OHOS::HDI::Camera::V1_0::StreamInfo>& infos,
33         OHOS::HDI::Camera::V1_0::StreamSupportType& type) override
34     {
35         return 0;
36     }
CreateStreams(const std::vector<OHOS::HDI::Camera::V1_0::StreamInfo> & streamInfos)37     inline int32_t CreateStreams(const std::vector<OHOS::HDI::Camera::V1_0::StreamInfo>& streamInfos) override
38     {
39         return 0;
40     }
ReleaseStreams(const std::vector<int32_t> & streamIds)41     inline int32_t ReleaseStreams(const std::vector<int32_t>& streamIds) override
42     {
43         return 0;
44     }
CommitStreams(OHOS::HDI::Camera::V1_0::OperationMode mode,const std::vector<uint8_t> & modeSetting)45     inline int32_t CommitStreams(OHOS::HDI::Camera::V1_0::OperationMode mode,
46         const std::vector<uint8_t>& modeSetting) override
47     {
48         return 0;
49     }
GetStreamAttributes(std::vector<OHOS::HDI::Camera::V1_0::StreamAttribute> & attributes)50     inline int32_t GetStreamAttributes(std::vector<OHOS::HDI::Camera::V1_0::StreamAttribute>& attributes) override
51     {
52         return 0;
53     }
AttachBufferQueue(int32_t streamId,const sptr<OHOS::HDI::Camera::V1_0::BufferProducerSequenceable> & bufferProducer)54     inline int32_t AttachBufferQueue(int32_t streamId,
55         const sptr<OHOS::HDI::Camera::V1_0::BufferProducerSequenceable>& bufferProducer) override
56     {
57         return 0;
58     }
DetachBufferQueue(int32_t streamId)59     inline int32_t DetachBufferQueue(int32_t streamId) override
60     {
61         return 0;
62     }
Capture(int32_t captureId,const OHOS::HDI::Camera::V1_0::CaptureInfo & info,bool isStreaming)63     inline int32_t Capture(int32_t captureId, const OHOS::HDI::Camera::V1_0::CaptureInfo& info,
64         bool isStreaming) override
65     {
66         return 0;
67     }
CancelCapture(int32_t captureId)68     inline int32_t CancelCapture(int32_t captureId) override
69     {
70         return 0;
71     }
ChangeToOfflineStream(const std::vector<int32_t> & streamIds,const sptr<OHOS::HDI::Camera::V1_0::IStreamOperatorCallback> & callbackObj,sptr<OHOS::HDI::Camera::V1_0::IOfflineStreamOperator> & offlineOperator)72     inline int32_t ChangeToOfflineStream(const std::vector<int32_t>& streamIds,
73          const sptr<OHOS::HDI::Camera::V1_0::IStreamOperatorCallback>& callbackObj,
74          sptr<OHOS::HDI::Camera::V1_0::IOfflineStreamOperator>& offlineOperator) override
75     {
76         return 0;
77     }
GetVersion(uint32_t & majorVer,uint32_t & minorVer)78     inline int32_t GetVersion(uint32_t& majorVer, uint32_t& minorVer) override
79     {
80         majorVer = 1;
81         minorVer = 0;
82         return HDF_SUCCESS;
83     }
IsProxy()84     inline bool IsProxy() override
85     {
86         return false;
87     }
GetDesc()88     inline const std::u16string GetDesc() override
89     {
90         return metaDescriptor_;
91     }
92 };
93 
94 class HStreamCaptureFuzzer {
95 public:
96 static bool hasPermission;
97 static std::shared_ptr<HStreamCapture> fuzz_;
98 static void HStreamCaptureFuzzTest1(FuzzedDataProvider& fdp);
99 static void HStreamCaptureFuzzTest2(FuzzedDataProvider& fdp);
100 };
101 } //CameraStandard
102 } //OHOS
103 #endif //HSTREAM_CAPTURE_FUZZER_H