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