1 /* 2 * Copyright (c) 2021 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 /** 17 * @file idistributed_camera_provider.h 18 * 19 * @brief Transfer interfaces call between distributed camera SA service and distributed camera HDF service, 20 * and provide Hardware Driver Interfaces (HDIs) for the upper layer. 21 * 22 * @since 1.0 23 * @version 1.0 24 */ 25 26 #ifndef HDI_DISTRIBUTED_CAMERA_PROVIDER_H 27 #define HDI_DISTRIBUTED_CAMERA_PROVIDER_H 28 29 #include "idistributed_camera_provider_callback.h" 30 31 namespace OHOS { 32 namespace DistributedHardware { 33 enum { 34 CMD_DISTRIBUTED_CAMERA_PROVIDER_ENABLE_DEVICE = 0, 35 CMD_DISTRIBUTED_CAMERA_PROVIDER_DISABLE_DEVICE, 36 CMD_DISTRIBUTED_CAMERA_PROVIDER_ACQUIRE_BUFFER, 37 CMD_DISTRIBUTED_CAMERA_PROVIDER_SHUTTER_BUFFER, 38 CMD_DISTRIBUTED_CAMERA_PROVIDER_ON_SETTINGS_RESULT, 39 CMD_DISTRIBUTED_CAMERA_PROVIDER_NOTIFY, 40 }; 41 42 class IDCameraProvider : public IRemoteBroker { 43 public: 44 DECLARE_INTERFACE_DESCRIPTOR(u"HDI.DCamera.V1_0.Provider"); ~IDCameraProvider()45 virtual ~IDCameraProvider() {} 46 47 public: 48 /** 49 * @brief Obtains an <b>IDCameraProvider</b> instance. 50 * This function provides the entry to the distributed camera SA service. 51 * You must use this function to obtain an <b>IDCameraProvider</b> instance before performing other operations. 52 * 53 * @return Returns the <b>IDCameraProvider</b> instance if the operation is successful, 54 * returns <b>nullptr</b> otherwise. 55 * 56 * @since 1.0 57 * @version 1.0 58 */ 59 static sptr<IDCameraProvider> Get(); 60 61 /** 62 * @brief Enable distributed camera device and set callback. For details about the callbacks, 63 * see {@link IDCameraProviderCallback}. 64 * 65 * @param dhBase [in] Distributed hardware device base info. 66 * 67 * @param abilityInfo [in] The static capability info of the distributed camera device to be enabled. 68 * 69 * @param callback [in] Indicates the callbacks to set. 70 * 71 * @return Returns <b>NO_ERROR</b> if the operation is successful, 72 * returns an error code defined in {@link DCamRetCode} otherwise. 73 * 74 * @since 1.0 75 * @version 1.0 76 */ 77 virtual DCamRetCode EnableDCameraDevice(const std::shared_ptr<DHBase> &dhBase, 78 const std::string &abilityInfo, const sptr<IDCameraProviderCallback> &callback) = 0; 79 80 /** 81 * @brief Disable distributed camera device. 82 * 83 * @param dhBase [in] Distributed hardware device base info 84 * 85 * @return Returns <b>NO_ERROR</b> if the operation is successful, 86 * returns an error code defined in {@link DCamRetCode} otherwise. 87 * 88 * @since 1.0 89 * @version 1.0 90 */ 91 virtual DCamRetCode DisableDCameraDevice(const std::shared_ptr<DHBase> &dhBase) = 0; 92 93 /** 94 * @brief Acquire a frame buffer from the procedure handle which attached to the streamId. 95 * 96 * @param dhBase [in] Distributed hardware device base info 97 * 98 * @param streamId [in] Indicates the ID of the stream to which the procedure handle is to be attached. 99 * 100 * @param buffer [out] A frame buffer 101 * 102 * @return Returns <b>NO_ERROR</b> if the operation is successful, 103 * returns an error code defined in {@link DCamRetCode} otherwise. 104 * 105 * @since 1.0 106 * @version 1.0 107 */ 108 virtual DCamRetCode AcquireBuffer(const std::shared_ptr<DHBase> &dhBase, int streamId, 109 std::shared_ptr<DCameraBuffer> &buffer) = 0; 110 111 /** 112 * @brief Notify distributed camera HDF service when a frame buffer has been filled. 113 * 114 * @param dhBase [in] Distributed hardware device base info 115 * 116 * @param streamId [in] Indicates the ID of the stream to which the frame buffer is to be attached. 117 * 118 * @param buffer [out] output frame buffer 119 * 120 * @return Returns <b>NO_ERROR</b> if the operation is successful, 121 * returns an error code defined in {@link DCamRetCode} otherwise. 122 * 123 * @since 1.0 124 * @version 1.0 125 */ 126 virtual DCamRetCode ShutterBuffer(const std::shared_ptr<DHBase> &dhBase, int streamId, 127 const std::shared_ptr<DCameraBuffer> &buffer) = 0; 128 129 /** 130 * @brief Called to report metadata related to the distributed camera device. 131 * 132 * @param dhBase [in] Distributed hardware device base info 133 * 134 * @param result Indicates the metadata reported. 135 * 136 * @return Returns <b>NO_ERROR</b> if the operation is successful, 137 * returns an error code defined in {@link DCamRetCode} otherwise. 138 * 139 * @since 1.0 140 * @version 1.0 141 */ 142 virtual DCamRetCode OnSettingsResult(const std::shared_ptr<DHBase> &dhBase, 143 const std::shared_ptr<DCameraSettings> &result) = 0; 144 145 /** 146 * @brief Called to notify some events from distributed camera SA service to distributed camera HDF service. 147 * 148 * @param dhBase [in] Distributed hardware device base info 149 * 150 * @param event [in] Detail event contents 151 * 152 * @return Returns <b>NO_ERROR</b> if the operation is successful, 153 * returns an error code defined in {@link DCamRetCode} otherwise. 154 * 155 * @since 1.0 156 * @version 1.0 157 */ 158 virtual DCamRetCode Notify(const std::shared_ptr<DHBase> &dhBase, 159 const std::shared_ptr<DCameraHDFEvent> &event) = 0; 160 }; 161 } // end namespace DistributedHardware 162 } // end namespace OHOS 163 164 #endif // HDI_DISTRIBUTED_CAMERA_PROVIDER_H