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 ARK_CAMERA_MANAGER_ADAPTER_H 17 #define ARK_CAMERA_MANAGER_ADAPTER_H 18 #pragma once 19 20 #include "ohos_adapter/include/ark_format_adapter_vector.h" 21 #include "ohos_adapter/include/ark_video_device_descriptor_adapter_vector.h" 22 23 #include "base/include/ark_web_base_ref_counted.h" 24 #include "base/include/ark_web_types.h" 25 26 namespace OHOS::ArkWeb { 27 28 /*--ark web(source=webview)--*/ 29 class ArkVideoControlSupportAdapter : public virtual ArkWebBaseRefCounted { 30 public: 31 /*--ark web()--*/ 32 virtual bool GetPan() = 0; 33 34 /*--ark web()--*/ 35 virtual bool GetTilt() = 0; 36 37 /*--ark web()--*/ 38 virtual bool GetZoom() = 0; 39 }; 40 41 /*--ark web(source=webview)--*/ 42 class ArkFormatAdapter : public virtual ArkWebBaseRefCounted { 43 public: 44 /*--ark web()--*/ 45 virtual uint32_t GetWidth() = 0; 46 47 /*--ark web()--*/ 48 virtual uint32_t GetHeight() = 0; 49 50 /*--ark web()--*/ 51 virtual float GetFrameRate() = 0; 52 53 /*--ark web()--*/ 54 virtual int32_t GetPixelFormat() = 0; 55 }; 56 57 /*--ark web(source=webview)--*/ 58 class ArkVideoDeviceDescriptorAdapter : public virtual ArkWebBaseRefCounted { 59 public: 60 /*--ark web()--*/ 61 virtual ArkWebString GetDisplayName() = 0; 62 63 /*--ark web()--*/ 64 virtual ArkWebString GetDeviceId() = 0; 65 66 /*--ark web()--*/ 67 virtual ArkWebString GetModelId() = 0; 68 69 /*--ark web()--*/ 70 virtual ArkWebRefPtr<ArkVideoControlSupportAdapter> GetControlSupport() = 0; 71 72 /*--ark web()--*/ 73 virtual int32_t GetTransportType() = 0; 74 75 /*--ark web()--*/ 76 virtual int32_t GetFacingMode() = 0; 77 78 /*--ark web()--*/ 79 virtual ArkFormatAdapterVector GetSupportCaptureFormats() = 0; 80 }; 81 82 /*--ark web(source=webcore)--*/ 83 class ArkVideoCaptureParamsAdapter : public virtual ArkWebBaseRefCounted { 84 public: 85 /*--ark web()--*/ 86 virtual uint32_t GetWidth() = 0; 87 88 /*--ark web()--*/ 89 virtual uint32_t GetHeight() = 0; 90 91 /*--ark web()--*/ 92 virtual float GetFrameRate() = 0; 93 94 /*--ark web()--*/ 95 virtual int32_t GetPixelFormat() = 0; 96 97 /*--ark web()--*/ 98 virtual bool GetEnableFaceDetection() = 0; 99 }; 100 101 /*--ark web(source=webview)--*/ 102 class ArkVideoCaptureRangeAdapter : public virtual ArkWebBaseRefCounted { 103 public: 104 /*--ark web()--*/ 105 virtual double GetMin() = 0; 106 107 /*--ark web()--*/ 108 virtual double GetMax() = 0; 109 110 /*--ark web()--*/ 111 virtual double GetStep() = 0; 112 113 /*--ark web()--*/ 114 virtual double GetCurrent() = 0; 115 }; 116 117 /*--ark web(source=webview)--*/ 118 class ArkCameraRotationInfoAdapter : public virtual ArkWebBaseRefCounted { 119 public: 120 /*--ark web()--*/ 121 virtual int32_t GetRotation() = 0; 122 123 /*--ark web()--*/ 124 virtual bool GetIsFlipX() = 0; 125 126 /*--ark web()--*/ 127 virtual bool GetIsFlipY() = 0; 128 }; 129 130 /*--ark web(source=webview)--*/ 131 class ArkCameraSurfaceBufferAdapter : public virtual ArkWebBaseRefCounted { 132 public: 133 /*--ark web()--*/ 134 virtual int32_t GetFileDescriptor() = 0; 135 136 /*--ark web()--*/ 137 virtual int32_t GetWidth() = 0; 138 139 /*--ark web()--*/ 140 virtual int32_t GetHeight() = 0; 141 142 /*--ark web()--*/ 143 virtual int32_t GetStride() = 0; 144 145 /*--ark web()--*/ 146 virtual int32_t GetFormat() = 0; 147 148 /*--ark web()--*/ 149 virtual uint32_t GetSize() = 0; 150 151 /*--ark web()--*/ 152 virtual uint8_t* GetBufferAddr() = 0; 153 }; 154 155 /*--ark web(source=webview)--*/ 156 class ArkCameraSurfaceAdapter : public virtual ArkWebBaseRefCounted { 157 public: 158 /*--ark web()--*/ 159 virtual int32_t ReleaseBuffer(ArkWebRefPtr<ArkCameraSurfaceBufferAdapter> buffer, int32_t fence) = 0; 160 }; 161 162 /*--ark web(source=webcore)--*/ 163 class ArkCameraBufferListenerAdapter : public virtual ArkWebBaseRefCounted { 164 public: 165 /*--ark web()--*/ 166 virtual void OnBufferAvailable(ArkWebRefPtr<ArkCameraSurfaceAdapter> surface, 167 ArkWebRefPtr<ArkCameraSurfaceBufferAdapter> buffer, 168 ArkWebRefPtr<ArkCameraRotationInfoAdapter> rotationInfo) = 0; 169 }; 170 171 /*--ark web(source=webcore)--*/ 172 class ArkCameraStatusCallbackAdapter : public virtual ArkWebBaseRefCounted { 173 public: 174 /*--ark web()--*/ 175 virtual void OnCameraStatusChanged(int32_t cameraStatusAdapter, const ArkWebString callBackDeviceId) = 0; 176 }; 177 178 /*--ark web(source=webview)--*/ 179 class ArkCameraManagerAdapter : public virtual ArkWebBaseRefCounted { 180 public: 181 /*--ark web()--*/ 182 virtual int32_t Create(ArkWebRefPtr<ArkCameraStatusCallbackAdapter> cameraStatusCallback) = 0; 183 184 /*--ark web()--*/ 185 virtual ArkVideoDeviceDescriptorAdapterVector GetDevicesInfo() = 0; 186 187 /*--ark web()--*/ 188 virtual int32_t ReleaseCameraManger() = 0; 189 190 /*--ark web()--*/ 191 virtual int32_t GetExposureModes(ArkWebInt32Vector& exposureModesAdapter) = 0; 192 193 /*--ark web()--*/ 194 virtual int32_t GetCurrentExposureMode(int32_t& exposureModeAdapter) = 0; 195 196 /*--ark web()--*/ 197 virtual ArkWebRefPtr<ArkVideoCaptureRangeAdapter> GetCaptionRangeById(int32_t rangeId) = 0; 198 199 /*--ark web()--*/ 200 virtual bool IsFocusModeSupported(int32_t focusMode) = 0; 201 202 /*--ark web()--*/ 203 virtual int32_t GetCurrentFocusMode() = 0; 204 205 /*--ark web()--*/ 206 virtual bool IsFlashModeSupported(int32_t flashMode) = 0; 207 208 /*--ark web()--*/ 209 virtual int32_t RestartSession() = 0; 210 211 /*--ark web()--*/ 212 virtual int32_t StopSession(int32_t stopType) = 0; 213 214 /*--ark web()--*/ 215 virtual int32_t GetCameraStatus() = 0; 216 217 /*--ark web()--*/ 218 virtual bool IsExistCaptureTask() = 0; 219 220 /*--ark web()--*/ 221 virtual int32_t StartStream(const ArkWebString& deviceId, 222 const ArkWebRefPtr<ArkVideoCaptureParamsAdapter> captureParams, 223 ArkWebRefPtr<ArkCameraBufferListenerAdapter> listener) = 0; 224 225 /*--ark web()--*/ 226 virtual void SetForegroundFlag(bool isForeground) = 0; 227 228 /*--ark web()--*/ 229 virtual void SetCameraStatus(int32_t status) = 0; 230 231 /*--ark web()--*/ 232 virtual ArkWebString GetCurrentDeviceId() = 0; 233 }; 234 235 } // namespace OHOS::ArkWeb 236 237 #endif // ARK_CAMERA_MANAGER_ADAPTER_H 238