• 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_REPEAT_FUZZER_H
17 #define HSTREAM_REPEAT_FUZZER_H
18 
19 #include "stream_capture_stub.h"
20 #include "hstream_repeat.h"
21 #include "hcamera_device.h"
22 #include "stream_repeat_callback_stub.h"
23 #include <fuzzer/FuzzedDataProvider.h>
24 
25 namespace OHOS {
26 namespace CameraStandard {
27 class HStreamRepeatCallbackStubDemo : public StreamRepeatCallbackStub {
28 public:
OnFrameStarted()29     int32_t OnFrameStarted() override
30     {
31         return 0;
32     }
OnFrameEnded(int32_t frameCount)33     int32_t OnFrameEnded(int32_t frameCount) override
34     {
35         return 0;
36     }
OnFrameError(int32_t errorCode)37     int32_t OnFrameError(int32_t errorCode) override
38     {
39         return 0;
40     }
OnSketchStatusChanged(SketchStatus status)41     int32_t OnSketchStatusChanged(SketchStatus status) override
42     {
43         return 0;
44     }
OnDeferredVideoEnhancementInfo(const CaptureEndedInfoExt & captureEndedInfo)45     int32_t OnDeferredVideoEnhancementInfo(const CaptureEndedInfoExt& captureEndedInfo) override
46     {
47         return 0;
48     }
49 };
50 
51 class IStreamOperatorMock : public IStreamOperator {
52 public:
53     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)54     inline int32_t IsStreamsSupported(OHOS::HDI::Camera::V1_0::OperationMode mode,
55         const std::vector<uint8_t>& modeSetting,
56         const std::vector<OHOS::HDI::Camera::V1_0::StreamInfo>& infos,
57         OHOS::HDI::Camera::V1_0::StreamSupportType& type) override
58     {
59         return 0;
60     }
CreateStreams(const std::vector<OHOS::HDI::Camera::V1_0::StreamInfo> & streamInfos)61     inline int32_t CreateStreams(const std::vector<OHOS::HDI::Camera::V1_0::StreamInfo>& streamInfos) override
62     {
63         return 0;
64     }
ReleaseStreams(const std::vector<int32_t> & streamIds)65     inline int32_t ReleaseStreams(const std::vector<int32_t>& streamIds) override
66     {
67         return 0;
68     }
CommitStreams(OHOS::HDI::Camera::V1_0::OperationMode mode,const std::vector<uint8_t> & modeSetting)69     inline int32_t CommitStreams(OHOS::HDI::Camera::V1_0::OperationMode mode,
70         const std::vector<uint8_t>& modeSetting) override
71     {
72         return 0;
73     }
GetStreamAttributes(std::vector<OHOS::HDI::Camera::V1_0::StreamAttribute> & attributes)74     inline int32_t GetStreamAttributes(std::vector<OHOS::HDI::Camera::V1_0::StreamAttribute>& attributes) override
75     {
76         return 0;
77     }
AttachBufferQueue(int32_t streamId,const sptr<OHOS::HDI::Camera::V1_0::BufferProducerSequenceable> & bufferProducer)78     inline int32_t AttachBufferQueue(int32_t streamId,
79         const sptr<OHOS::HDI::Camera::V1_0::BufferProducerSequenceable>& bufferProducer) override
80     {
81         return 0;
82     }
DetachBufferQueue(int32_t streamId)83     inline int32_t DetachBufferQueue(int32_t streamId) override
84     {
85         return 0;
86     }
Capture(int32_t captureId,const OHOS::HDI::Camera::V1_0::CaptureInfo & info,bool isStreaming)87     inline int32_t Capture(int32_t captureId, const OHOS::HDI::Camera::V1_0::CaptureInfo& info,
88         bool isStreaming) override
89     {
90         return 0;
91     }
CancelCapture(int32_t captureId)92     inline int32_t CancelCapture(int32_t captureId) override
93     {
94         return 0;
95     }
ChangeToOfflineStream(const std::vector<int32_t> & streamIds,const sptr<OHOS::HDI::Camera::V1_0::IStreamOperatorCallback> & callbackObj,sptr<OHOS::HDI::Camera::V1_0::IOfflineStreamOperator> & offlineOperator)96     inline int32_t ChangeToOfflineStream(const std::vector<int32_t>& streamIds,
97          const sptr<OHOS::HDI::Camera::V1_0::IStreamOperatorCallback>& callbackObj,
98          sptr<OHOS::HDI::Camera::V1_0::IOfflineStreamOperator>& offlineOperator) override
99     {
100         return 0;
101     }
GetVersion(uint32_t & majorVer,uint32_t & minorVer)102     inline int32_t GetVersion(uint32_t& majorVer, uint32_t& minorVer) override
103     {
104         majorVer = 1;
105         minorVer = 0;
106         return HDF_SUCCESS;
107     }
IsProxy()108     inline bool IsProxy() override
109     {
110         return false;
111     }
GetDesc()112     inline const std::u16string GetDesc() override
113     {
114         return metaDescriptor_;
115     }
116 };
117 
118 class HStreamRepeatFuzzer {
119 public:
120 static bool hasPermission;
121 static std::shared_ptr<HStreamRepeat> fuzz_;
122 static void HStreamRepeatFuzzTest1(FuzzedDataProvider& fdp);
123 static void HStreamRepeatFuzzTest2(FuzzedDataProvider& fdp);
124 static void HStreamRepeatFuzzTest3(FuzzedDataProvider& fdp);
125 };
126 } //CameraStandard
127 } //OHOS
128 #endif //HSTREAM_REPEAT_FUZZER_H