diff --git a/distributed_camera/bundle.json b/distributed_camera/bundle.json new file mode 100644 index 0000000000000000000000000000000000000000..e322db12d20bd3def56b0258d3da78bcf3a5cbc0 --- /dev/null +++ b/distributed_camera/bundle.json @@ -0,0 +1,42 @@ +{ + "name": "distributed_camera_device_driver_interface", + "description": "distributed camera device driver interface", + "version": "3.2", + "license": "Apache License 2.0", + "component": { + "name": "distributed_camera_device_driver_interface", + "subsystem": "hdf", + "syscap": [""], + "adapter_system_type": ["standard"], + "rom": "675KB", + "ram": "1024KB", + "deps": { + "components": [ + "ipc", + "device_driver_framework", + "hiviewdfx_hilog_native", + "utils_base" + ], + "third_part": [ + "bounds_checking_function" + ] + }, + "build": { + "sub_component": [ + "//drivers/interface/distributed_camera/v1_0:libdistributed_camera_provider_proxy_1.0" + ], + "test": [ + ], + "inner_kits": [ + { + "name": "//drivers/interface/distributed_camera/v1_0:libdistributed_camera_provider_proxy_1.0", + "header": { + "header_files": [ + ], + "header_base": "//drivers/interface/distributed_camera" + } + } + ] + } + } + } \ No newline at end of file diff --git a/distributed_camera/v1_0/BUILD.gn b/distributed_camera/v1_0/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..f425b3433f31b56999872c6071e45d0f7ff7795a --- /dev/null +++ b/distributed_camera/v1_0/BUILD.gn @@ -0,0 +1,28 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//drivers/adapter/uhdf2/hdi.gni") +hdi("distributed_camera_provider") { + module_name = "distributed_camera_provider_service" + sources = [ + "DCameraTypes.idl", + "IDCameraProvider.idl", + "IDCameraProviderCallback.idl", + ] + + sequenceable = [ "//drivers/adapter/uhdf2/model/display/sequenceable/buffer_handle:libbuffer_handle_sequenceable_1.0" ] + + language = "cpp" + subsystem_name = "hdf" + part_name = "distributed_camera_device_driver" +} diff --git a/distributed_camera/v1_0/DCameraTypes.idl b/distributed_camera/v1_0/DCameraTypes.idl new file mode 100644 index 0000000000000000000000000000000000000000..f54bda14594e8e9fde0fc864bb6a52a0edf2d1fc --- /dev/null +++ b/distributed_camera/v1_0/DCameraTypes.idl @@ -0,0 +1,286 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file DCameraTypes.idl + * + * @brief Declares data types. + * used by the Hardware Driver Interfaces (HDIs) of this module. + * + * @since 1.0 + * @version 1.0 + */ + +package ohos.hdi.distributed_camera.v1_0; + +sequenceable ohos.hdi.sequenceable.v1_0.BufferHandleSequenceable; + +/** + * @brief Enumerates distributed camera metadata updating types. + */ +enum DCSettingsType { + /** + * Set the whole package metadata. + */ + UPDATE_METADATA = 0, + /** + * Enable metadata configuration. + */ + ENABLE_METADATA = 1, + /** + * Disable metadata configuration. + */ + DISABLE_METADATA = 2, + /** + * Return metadata result from distributed camera. + */ + METADATA_RESULT = 3, + /** + * Set flash light to distribtued camera. + */ + SET_FLASH_LIGHT = 4, + /** + * Set fps range to distributed camera. + */ + FPS_RANGE = 5, + /** + * Set the frame metadata to distributed camera. + */ + UPDATE_FRAME_METADATA = 6, +}; + +/** + * @brief Enumerates return values of the HDIs. + */ +enum DCamRetCode { + /** + * Successful call. + */ + SUCCESS = 0, + /** + * The camera device is busy. + */ + CAMERA_BUSY = 1, + /** + * Invalid parameters. + */ + INVALID_ARGUMENT = 2, + /** + * Unsupported function. + */ + METHOD_NOT_SUPPORTED = 3, + /** + * The camera device is offlined. + */ + CAMERA_OFFLINE = 4, + /** + * The number of distributed camera devices enabled exceeds the limit. + */ + EXCEED_MAX_NUMBER = 5, + /** + * The device is not initialized. + */ + DEVICE_NOT_INIT = 6, + /** + * Failed call. + */ + FAILED = 7, +}; + +/** + * @brief Enumerates encoding types of stream data. + */ +enum DCEncodeType { + /** + * Unspecified encode type. + */ + ENCODE_TYPE_NULL = 0, + /** + * H.264 encode type. + */ + ENCODE_TYPE_H264 = 1, + /** + * H.265 encode type + */ + ENCODE_TYPE_H265 = 2, + /** + * JPEG encode type + */ + ENCODE_TYPE_JPEG = 3, +}; + +/** + * @brief Enumerates distributed camera inner stream types. + */ +enum DCStreamType { + /** + * Continuous capture stream. For example preview streams, video streams. + */ + CONTINUOUS_FRAME = 0, + /** + * Single capture stream. For example photographing streams. + */ + SNAPSHOT_FRAME = 1, +}; + +/** + * @brief Distributed hardware device base info. + */ +struct DHBase { + /** + * The device id, here is networkId. + */ + String deviceId_; + /** + * The distributed hardware id. + */ + String dhId_; +}; + +/** + * @brief The control settings of the distributed camera device. + */ +struct DCameraSettings { + /** + * Settings type, see {@link DCSettingsType}. + */ + enum DCSettingsType type_; + /** + * Settings value. Serialized from bool, array, structure, etc. + */ + String value_; +}; + +/** + * @brief Defines the inner stream information of the distributed camera, + * which is used to pass configuration parameters during stream creation. + */ +struct DCStreamInfo { + /** + * Stream ID, which uniquely identifies a stream on a camera device. + */ + int streamId_; + /** + * Image width. + */ + int width_; + /** + * Image height. + */ + int height_; + /** + * Image stride. + */ + int stride_; + /** + * Image format. + */ + int format_; + /** + * Image color space. + */ + int dataspace_; + /** + * Encoding type, see {@link DCEncodeType}. + */ + enum DCEncodeType encodeType_; + /** + * Stream type, see {@link DCStreamType}. + */ + enum DCStreamType type_; +}; + +/** + * @brief Defines the information about a inner capture request of the distributed camera. + */ +struct DCCaptureInfo { + /** + * IDs of captured streams. + */ + int[] streamIds_; + /** + * Image width. + */ + int width_; + /** + * Image height. + */ + int height_; + /** + * Image stride. + */ + int stride_; + /** + * Image format. + */ + int format_; + /** + * Image color space. + */ + int dataspace_; + /** + * Is trigger sink capture. + */ + boolean isCapture_; + /** + * Encoding type, see {@link DCEncodeType}. + */ + enum DCEncodeType encodeType_; + /** + * Stream type, see {@link DCStreamType}. + */ + enum DCStreamType type_; + /** + * Stream settings, see {@link DCameraSettings}. + */ + struct DCameraSettings[] captureSettings_; +}; + +/** + * @brief Defines the inner buffer of the distributed camera, + * which is used to acquire buffer during processing capture requests. + */ +struct DCameraBuffer { + /** + * Buffer index. + */ + int index_; + /** + * Buffer size. + */ + unsigned int size_; + /** + * Buffer handle sequenceable, see {@link BufferHandleSequenceable}. + */ + BufferHandleSequenceable bufferHandle_; +}; + +/** + * @brief Notification event of the distributed camera. + */ +struct DCameraHDFEvent { + /** + * Event type. + */ + int type_; + /** + * Event result. + */ + int result_; + /** + * Extended content (optional). + */ + String content_; +}; diff --git a/distributed_camera/v1_0/IDCameraProvider.idl b/distributed_camera/v1_0/IDCameraProvider.idl new file mode 100644 index 0000000000000000000000000000000000000000..a795f34229eba34658823133076356d3b1a94fe4 --- /dev/null +++ b/distributed_camera/v1_0/IDCameraProvider.idl @@ -0,0 +1,126 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file IDCameraProvider.idl + * + * @brief Transfer interfaces call between distributed camera SA service and distributed camera HDF service, + * and provide Hardware Driver Interfaces (HDIs) for the upper layer. + * + * @since 1.0 + * @version 1.0 + */ + +package ohos.hdi.distributed_camera.v1_0; + +import ohos.hdi.distributed_camera.v1_0.DCameraTypes; +import ohos.hdi.distributed_camera.v1_0.IDCameraProviderCallback; + +interface IDCameraProvider { + /** + * @brief Enable distributed camera device and set callback. For details about the callbacks, + * see {@link IDCameraProviderCallback}. + * + * @param dhBase [in] Distributed hardware device base info. + * + * @param abilityInfo [in] The static capability info of the distributed camera device to be enabled. + * + * @param callbackObj [in] Indicates the callbacks to set. + * + * @return Returns NO_ERROR if the operation is successful, + * returns an error code defined in {@link DCamRetCode} otherwise. + * + * @since 1.0 + * @version 1.0 + */ + EnableDCameraDevice([in] struct DHBase dhBase,[in] String abilityInfo,[in] IDCameraProviderCallback callbackObj); + + /** + * @brief Disable distributed camera device. + * + * @param dhBase [in] Distributed hardware device base info + * + * @return Returns NO_ERROR if the operation is successful, + * returns an error code defined in {@link DCamRetCode} otherwise. + * + * @since 1.0 + * @version 1.0 + */ + DisableDCameraDevice([in] struct DHBase dhBase); + + /** + * @brief Acquire a frame buffer from the procedure handle which attached to the streamId. + * + * @param dhBase [in] Distributed hardware device base info + * + * @param streamId [in] Indicates the ID of the stream to which the procedure handle is to be attached. + * + * @param buffer [out] A frame buffer + * + * @return Returns NO_ERROR if the operation is successful, + * returns an error code defined in {@link DCamRetCode} otherwise. + * + * @since 1.0 + * @version 1.0 + */ + AcquireBuffer([in] struct DHBase dhBase,[in] int streamId,[out] struct DCameraBuffer buffer); + + /** + * @brief Notify distributed camera HDF service when a frame buffer has been filled. + * + * @param dhBase [in] Distributed hardware device base info + * + * @param streamId [in] Indicates the ID of the stream to which the frame buffer is to be attached. + * + * @param buffer [out] output frame buffer + * + * @return Returns NO_ERROR if the operation is successful, + * returns an error code defined in {@link DCamRetCode} otherwise. + * + * @since 1.0 + * @version 1.0 + */ + ShutterBuffer([in] struct DHBase dhBase,[in] int streamId,[in] struct DCameraBuffer buffer); + + /** + * @brief Called to report metadata related to the distributed camera device. + * + * @param dhBase [in] Distributed hardware device base info + * + * @param result Indicates the metadata reported. + * + * @return Returns NO_ERROR if the operation is successful, + * returns an error code defined in {@link DCamRetCode} otherwise. + * + * @since 1.0 + * @version 1.0 + */ + OnSettingsResult([in] struct DHBase dhBase,[in] struct DCameraSettings result); + + /** + * @brief Called to notify some events from distributed camera SA service to distributed camera HDF service. + * + * @param dhBase [in] Distributed hardware device base info + * + * @param event [in] Detail event contents + * + * @return Returns NO_ERROR if the operation is successful, + * returns an error code defined in {@link DCamRetCode} otherwise. + * + * @since 1.0 + * @version 1.0 + */ + Notify([in] struct DHBase dhBase,[in] struct DCameraHDFEvent event); +} diff --git a/distributed_camera/v1_0/IDCameraProviderCallback.idl b/distributed_camera/v1_0/IDCameraProviderCallback.idl new file mode 100644 index 0000000000000000000000000000000000000000..8b9c68ffb775cc0ff893cb520ac38964d9fc5472 --- /dev/null +++ b/distributed_camera/v1_0/IDCameraProviderCallback.idl @@ -0,0 +1,134 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file IDCameraProviderCallback.idl + * + * @brief Declares callbacks for distributed camera SA service. The caller needs to implement the callbacks. + * + * @since 1.0 + * @version 1.0 + */ + +package ohos.hdi.distributed_camera.v1_0; + +import ohos.hdi.distributed_camera.v1_0.DCameraTypes; + +[callback] interface IDCameraProviderCallback { + /** + * @brief Create the transmission channel between the source device and the sink device. + * Open and initialize the distributed camera session. + * + * @param dhBase [in] Distributed hardware device base info + * + * @return Returns NO_ERROR if the operation is successful, + * returns an error code defined in {@link DCamRetCode} otherwise. + * + * @since 1.0 + * @version 1.0 + */ + OpenSession([in] struct DHBase dhBase); + + /** + * @brief Close the distributed camera session, and destroy the transmission channel between + * the source device and the sink device. + * + * @param dhBase [in] Distributed hardware device base info + * + * @return Returns NO_ERROR if the operation is successful, + * returns an error code defined in {@link DCamRetCode} otherwise. + * + * @since 1.0 + * @version 1.0 + */ + CloseSession([in] struct DHBase dhBase); + + /** + * @brief Configures streams. + * + * @param dhBase [in] Distributed hardware device base info + * + * @param streamInfos [in] Indicates the list of stream information, which is defined by {@link DCStreamInfo}. + * + * @return Returns NO_ERROR if the operation is successful, + * returns an error code defined in {@link DCamRetCode} otherwise. + * + * @since 1.0 + * @version 1.0 + */ + ConfigureStreams([in] struct DHBase dhBase,[in] struct DCStreamInfo[] streamInfos); + + /** + * @brief Releases streams. + * + * @param dhBase [in] Distributed hardware device base info + * + * @param streamIds [IN] Indicates the IDs of the streams to release. + * + * @return Returns NO_ERROR if the operation is successful, + * returns an error code defined in {@link DCamRetCode} otherwise. + * + * @since 1.0 + * @version 1.0 + */ + ReleaseStreams([in] struct DHBase dhBase,[in] int[] streamIds); + + /** + * @brief Start capture images. + * This function must be called after {@link ConfigStreams}. + * There are two image capture modes: continuous capture and single capture. + * + * @param dhBase [in] Distributed hardware device base info + * + * @param captureInfos [in] Indicates the capture request configuration information. + * For details, see {@link DCCaptureInfo}. + * + * @return Returns NO_ERROR if the operation is successful, + * returns an error code defined in {@link DCamRetCode} otherwise. + * + * @since 1.0 + * @version 1.0 + */ + StartCapture([in] struct DHBase dhBase,[in] struct DCCaptureInfo[] captureInfos); + + /** + * @brief Stop capture images. + * + * @param dhBase [in] Distributed hardware device base info + * + * @return Returns NO_ERROR if the operation is successful, + * returns an error code defined in {@link DCamRetCode} otherwise. + * + * @since 1.0 + * @version 1.0 + */ + StopCapture([in] struct DHBase dhBase,[in] int[] streamIds); + + /** + * @brief Updates distributed camera device control parameters. + * + * @param dhBase [in] Distributed hardware device base info + * + * @param settings [in] Indicates the camera parameters, including the sensor frame rate and 3A parameters. + * For details about the settings, see {@link DCameraSettings}. + * + * @return Returns NO_ERROR if the operation is successful, + * returns an error code defined in {@link DCamRetCode} otherwise. + * + * @since 1.0 + * @version 1.0 + */ + UpdateSettings([in] struct DHBase dhBase,[in] struct DCameraSettings[] settings); +}