From 95ebf07f8958dfe4031850649435811b914e2e49 Mon Sep 17 00:00:00 2001 From: cold_yixiu Date: Wed, 28 Sep 2022 19:06:54 +0800 Subject: [PATCH 1/2] camera interface change Signed-off-by: cold_yixiu --- api/@ohos.multimedia.camera.d.ts | 1263 ++++++++++++++++++------------ 1 file changed, 782 insertions(+), 481 deletions(-) diff --git a/api/@ohos.multimedia.camera.d.ts b/api/@ohos.multimedia.camera.d.ts index 18c9ad1114..a4cf42c590 100644 --- a/api/@ohos.multimedia.camera.d.ts +++ b/api/@ohos.multimedia.camera.d.ts @@ -15,6 +15,7 @@ import {ErrorCallback, AsyncCallback} from './basic'; import { Context } from './app/context'; +import { BusinessError } from './interface_sdk-js_cameraErrorCode/api/basic'; /** * @name camera @@ -27,20 +28,12 @@ declare namespace camera { /** * Creates a CameraManager instance. * @param context Current application context. - * @param callback Callback used to return the CameraManager instance. + * @return CameraManager instance. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. */ - function getCameraManager(context: Context, callback: AsyncCallback): void; - - /** - * Creates a CameraManager instance. - * @param context Current application context. - * @return Promise used to return the CameraManager instance. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - function getCameraManager(context: Context): Promise; + function getCameraManager(context: Context): CameraManager; /** * Enum for camera status. @@ -59,19 +52,158 @@ declare namespace camera { * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - CAMERA_STATUS_DISAPPEAR, + CAMERA_STATUS_DISAPPEAR = 1, /** * Available status. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - CAMERA_STATUS_AVAILABLE, + CAMERA_STATUS_AVAILABLE = 2, /** * Unavailable status. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - CAMERA_STATUS_UNAVAILABLE + CAMERA_STATUS_UNAVAILABLE = 3 + } + + /** + * Profile for camera streams. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + interface Profile { + /** + * Camera format. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + readonly format: CameraFormat; + /** + * Picture size. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + readonly size: Size; + } + + /** + * Frame rate range. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + interface FrameRateRange { + /** + * Min frame rate. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + readonly min: number; + /** + * Max frame rate. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + readonly max: number; + } + + /** + * Video profile. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + interface VideoProfile extends Profile { + /** + * Frame rate in unit fps (frames per second). + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + readonly frameRateRange: FrameRateRange; + } + + /** + * Camera output capability. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + interface CameraOutputCapability { + /** + * Preview profiles. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + readonly previewProfiles: Array; + /** + * Photo profiles. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + readonly photoProfiles: Array; + /** + * Video profiles. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + readonly videoProfiles: Array; + /** + * All the supported metadata Object Types. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + readonly supportedMetadataObjectTypes: Array; + } + + /** + * Enum for camera error code. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + enum CameraErrorCode { + /** + * Invaild argument. + * @since 9 + */ + INVALID_ARGUMENT = 7400101, + /** + * Operation not allow. + * @since 9 + */ + OPERATION_NOT_ALLOWED = 7400102, + /** + * Session not config. + * @since 9 + */ + SESSION_NOT_CONFIG = 7400103, + /** + * Session not running. + * @since 9 + */ + SESSION_NOT_RUNNING = 7400104, + /** + * Session config locked. + * @since 9 + */ + SESSION_CONFIG_LOCKED = 7400105, + /** + * Device setting locked. + * @since 9 + */ + DEVICE_SETTING_LOCKED = 7400106, + /** + * Confilict camera. + * @since 9 + */ + CONFILICT_CAMERA = 7400107, + /** + * Driver disabled. + * @since 9 + */ + DEVICE_DISABLED = 7400108, + /** + * Service fatal error. + * @since 9 + */ + SERVICE_FATAL_ERROR = 7400201 } /** @@ -81,62 +213,122 @@ declare namespace camera { */ interface CameraManager { /** - * Gets all camera descriptions. - * @param callback Callback used to return the array of supported cameras. + * Gets supported camera descriptions. + * @return An array of supported cameras. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - getCameras(callback: AsyncCallback>): void; + getSupportedCameras(): Array; /** - * Gets all camera descriptions. - * @return Promise used to return an array of supported cameras. + * Gets supported output capability for specific camera. + * @param camera Camera device. + * @return The camera output capability. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - getCameras(): Promise>; + getSupportedOutputCapability(camera: CameraDevice): CameraOutputCapability; /** - * Creates a CameraInput instance by camera id. - * @param cameraId Camera ID used to create the instance. - * @param callback Callback used to return the CameraInput instance. + * Determine wether camera is muted. + * @return Is camera muted. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core - * @permission ohos.permission.CAMERA */ - createCameraInput(cameraId: string, callback: AsyncCallback): void; + isCameraMuted(): boolean; /** - * Creates a CameraInput instance by camera id. - * @param cameraId Camera ID used to create the instance. - * @return Promise used to return the CameraInput instance. + * Determine wether camera mute is supported. + * @return Is camera mute supported. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core - * @permission ohos.permission.CAMERA + * @systemapi */ - createCameraInput(cameraId: string): Promise; + isCameraMuteSupported(): boolean; /** - * Creates a CameraInput instance by camera position and type. - * @param position Target camera position. - * @param type Target camera type. - * @param callback Callback used to return the CameraInput instance. + * Mute camera. + * @param mute Mute camera if TRUE, otherwise unmute camera. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + * @systemapi + */ + muteCamera(mute: boolean): void; + + /** + * Creates a CameraInput instance by camera. + * @param camera Camera device used to create the instance. + * @return The CameraInput instance. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. * @permission ohos.permission.CAMERA */ - createCameraInput(position: CameraPosition, type: CameraType, callback: AsyncCallback): void; + createCameraInput(camera: CameraDevice): CameraInput; /** * Creates a CameraInput instance by camera position and type. * @param position Target camera position. * @param type Target camera type. - * @return Promise used to return the CameraInput instance. + * @return The CameraInput instance. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. * @permission ohos.permission.CAMERA */ - createCameraInput(position: CameraPosition, type: CameraType): Promise; + createCameraInput(position: CameraPosition, type: CameraType): CameraInput; + + /** + * Creates a PreviewOutput instance. + * @param profile Preview output profile. + * @param surfaceId Surface object id used in camera photo output. + * @return The PreviewOutput instance. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. + */ + createPreviewOutput(profile: Profile, surfaceId: string): PreviewOutput; + + /** + * Creates a PhotoOutput instance. + * @param profile Photo output profile. + * @param surfaceId Surface object id used in camera photo output. + * @return The PhotoOutput instance. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. + */ + createPhotoOutput(profile: Profile, surfaceId: string): PhotoOutput; + + /** + * Creates a VideoOutput instance. + * @param profile Video profile. + * @param surfaceId Surface object id used in camera video output. + * @return The VideoOutput instance. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. + */ + createVideoOutput(profile: VideoProfile, surfaceId: string): VideoOutput; + + /** + * Creates a MetadataOutput instance. + * @param metadataObjectTypes Array of MetadataObjectType. + * @return The MetadataOutput instance. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. + */ + createMetadataOutput(metadataObjectTypes: Array): MetadataOutput; + + /** + * Gets a CaptureSession instance. + * @return The CaptureSession instance. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. + */ + createCaptureSession(): CaptureSession; /** * Subscribes camera status change event callback. @@ -146,6 +338,16 @@ declare namespace camera { * @syscap SystemCapability.Multimedia.Camera.Core */ on(type: 'cameraStatus', callback: AsyncCallback): void; + + /** + * Subscribes camera mute change event callback. + * @param type Event type. + * @param callback Callback used to get the camera mute change. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + * @systemapi + */ + on(type: 'cameraMute', callback: AsyncCallback): void; } /** @@ -159,7 +361,7 @@ declare namespace camera { * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - camera: Camera; + camera: CameraDevice; /** * Current camera status. * @since 9 @@ -185,13 +387,13 @@ declare namespace camera { * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - CAMERA_POSITION_BACK, + CAMERA_POSITION_BACK = 1, /** * Front position. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - CAMERA_POSITION_FRONT + CAMERA_POSITION_FRONT = 2 } /** @@ -201,39 +403,39 @@ declare namespace camera { */ enum CameraType { /** - * Unspecified camera type + * Default camera type * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - CAMERA_TYPE_UNSPECIFIED = 0, + CAMERA_TYPE_DEFAULT = 0, /** * Wide camera * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - CAMERA_TYPE_WIDE_ANGLE, + CAMERA_TYPE_WIDE_ANGLE = 1, /** * Ultra wide camera * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - CAMERA_TYPE_ULTRA_WIDE, + CAMERA_TYPE_ULTRA_WIDE = 2, /** * Telephoto camera * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - CAMERA_TYPE_TELEPHOTO, + CAMERA_TYPE_TELEPHOTO = 3, /** * True depth camera * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - CAMERA_TYPE_TRUE_DEPTH + CAMERA_TYPE_TRUE_DEPTH = 4 } /** @@ -254,22 +456,22 @@ declare namespace camera { * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - CAMERA_CONNECTION_USB_PLUGIN, + CAMERA_CONNECTION_USB_PLUGIN = 1, /** * Remote camera * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - CAMERA_CONNECTION_REMOTE + CAMERA_CONNECTION_REMOTE = 2 } /** - * Camera object. + * Camera device object. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - interface Camera { + interface CameraDevice { /** * Camera id attribute. * @since 9 @@ -303,605 +505,620 @@ declare namespace camera { */ interface Size { /** - * Height. + * Width. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - height: number; + width: number; /** - * Width. + * Height. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - width: number; + height: number; } /** - * Camera input object. + * Point parameter. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - interface CameraInput { + interface Point { /** - * Gets camera id. - * @param callback Callback used to return the camera ID. + * x co-ordinate * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - getCameraId(callback: AsyncCallback): void; - + x: number; /** - * Gets camera id. - * @return Promise used to return the camera ID. + * y co-ordinate * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - getCameraId(): Promise; + y: number; + } + /** + * Camera input object. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + interface CameraInput { /** - * Check if device has flash light. - * @param callback Callback used to return the flash light support status. + * Open camera. + * @param callback Callback used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. */ - hasFlash(callback: AsyncCallback): void; + open(callback: AsyncCallback): void; /** - * Check if device has flash light. - * @return Promise used to return the flash light support status. + * Open camera. + * @return Promise used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. */ - hasFlash(): Promise; + open(): Promise; /** - * Checks whether a specified flash mode is supported. - * @param flashMode Flash mode. - * @param callback Callback used to return the flash light support status. + * Close camera. + * @param callback Callback used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. */ - isFlashModeSupported(flashMode: FlashMode, callback: AsyncCallback): void; + close(callback: AsyncCallback): void; /** - * Checks whether a specified flash mode is supported. - * @param flashMode Flash mode - * @return Promise used to return flash mode support status. + * Close camera. + * @return Promise used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. */ - isFlashModeSupported(flashMode: FlashMode): Promise; + close(): Promise; /** - * Gets current flash mode. - * @param callback Callback used to return the current flash mode. + * Subscribes error event callback. + * @param type Event type. + * @param camera Camera device. + * @param callback Callback used to get the camera input errors. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - getFlashMode(callback: AsyncCallback): void; + on(type: 'error', camera: CameraDevice, callback: ErrorCallback): void; + } + /** + * Enum for camera format type. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + enum CameraFormat { /** - * Gets current flash mode. - * @return Promise used to return the flash mode. + * RGBA 8888 Format. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - getFlashMode(): Promise; + CAMERA_FORMAT_RGBA_8888 = 3, /** - * Sets flash mode. - * @param flashMode Target flash mode. - * @param callback Callback used to return the result. + * YUV 420 Format. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - setFlashMode(flashMode: FlashMode, callback: AsyncCallback): void; + CAMERA_FORMAT_YUV_420_SP = 1003, /** - * Sets flash mode. - * @param flashMode Target flash mode. - * @return Promise used to return the result. + * JPEG Format. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - setFlashMode(flashMode: FlashMode): Promise; + CAMERA_FORMAT_JPEG = 2000 + } + /** + * Enum for flash mode. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + enum FlashMode { /** - * Checks whether a specified focus mode is supported. - * @param afMode Focus mode. - * @param callback Callback used to return the device focus support status. + * Close mode. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - isFocusModeSupported(afMode: FocusMode, callback: AsyncCallback): void; - + FLASH_MODE_CLOSE = 0, /** - * Checks whether a specified focus mode is supported. - * @param afMode Focus mode. - * @return Promise used to return the focus mode support status. + * Open mode. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - isFocusModeSupported(afMode: FocusMode): Promise; - + FLASH_MODE_OPEN = 1, /** - * Gets current focus mode. - * @param callback Callback used to return the current focus mode. + * Auto mode. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - getFocusMode(callback: AsyncCallback): void; - + FLASH_MODE_AUTO = 2, /** - * Gets current focus mode. - * @return Promise used to return the focus mode. + * Always open mode. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - getFocusMode(): Promise; + FLASH_MODE_ALWAYS_OPEN = 3 + } + /** + * Enum for exposure mode. + * @since 9 + */ + enum ExposureMode { /** - * Sets focus mode. - * @param afMode Target focus mode. - * @param callback Callback used to return the result. + * Lock exposure mode. + * @since 9 + */ + EXPOSURE_MODE_LOCKED = 0, + /** + * Auto exposure mode. * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core */ - setFocusMode(afMode: FocusMode, callback: AsyncCallback): void; + EXPOSURE_MODE_AUTO = 1, + /** + * Continuous automatic exposure. + * @since 9 + */ + EXPOSURE_MODE_CONTINUOUS_AUTO = 2 + } + /** + * Enum for focus mode. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + enum FocusMode { /** - * Sets focus mode. - * @param afMode Target focus mode. - * @return Promise used to return the result. + * Manual mode. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - setFocusMode(afMode: FocusMode): Promise; - + FOCUS_MODE_MANUAL = 0, /** - * Gets all supported zoom ratio range. - * @param callback Callback used to return the zoom ratio range. + * Continuous auto mode. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - getZoomRatioRange(callback: AsyncCallback>): void; - + FOCUS_MODE_CONTINUOUS_AUTO = 1, /** - * Gets all supported zoom ratio range. - * @return Promise used to return the zoom ratio range. + * Auto mode. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - getZoomRatioRange(): Promise>; - + FOCUS_MODE_AUTO = 2, /** - * Gets zoom ratio. - * @param callback Callback used to return the current zoom ratio value. + * Locked mode. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - getZoomRatio(callback: AsyncCallback): void; + FOCUS_MODE_LOCKED = 3 + } + /** + * Enum for focus state. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + enum FocusState { /** - * Gets zoom ratio. - * @return Promise used to return the zoom ratio value. + * Scan state. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - getZoomRatio(): Promise; - + FOCUS_STATE_SCAN = 0, /** - * Sets zoom ratio. - * @param zoomRatio Target zoom ratio. - * @param callback Callback used to return the result. + * Focused state. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - setZoomRatio(zoomRatio: number, callback: AsyncCallback): void; - + FOCUS_STATE_FOCUSED = 1, /** - * Sets zoom ratio. - * @param zoomRatio Target zoom ratio. - * @return Promise used to return the result. + * Unfocused state. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - setZoomRatio(zoomRatio: number): Promise; + FOCUS_STATE_UNFOCUSED = 2 + } + /** + * Enum for video stabilization mode. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + enum VideoStabilizationMode { /** - * Releases instance. - * @param callback Callback used to return the result. + * Turn off video stablization. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - release(callback: AsyncCallback): void; - + OFF = 0, /** - * Releases instance. - * @return Promise used to return the result. + * LOW mode provides basic stabilization effect. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - release(): Promise; - + LOW = 1, /** - * Subscribes focus status change event callback. - * @param type Event type. - * @param callback Callback used to get the focus state change. + * MIDDLE mode means algorithms can achieve better effects than LOW mode. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - on(type: 'focusStateChange', callback: AsyncCallback): void; - + MIDDLE = 2, /** - * Subscribes error event callback. - * @param type Event type. - * @param callback Callback used to get the camera input errors. + * HIGH mode means algorithms can achieve better effects than MIDDLE mode. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - on(type: 'error', callback: ErrorCallback): void; - } - - /** - * Enum for CameraInput error code. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - enum CameraInputErrorCode { + HIGH = 3, /** - * Unknown error. + * Camera HDF can select mode automatically. * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core */ - ERROR_UNKNOWN = -1 - } - - /** - * Camera input error object. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - interface CameraInputError extends Error { - code: CameraInputErrorCode; + AUTO = 4 } /** - * Enum for flash mode. + * Capture session object. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - enum FlashMode { + interface CaptureSession { /** - * Close mode. + * Begin capture session config. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. */ - FLASH_MODE_CLOSE = 0, + beginConfig(): void; + /** - * Open mode. + * Commit capture session config. + * @param callback Callback used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. */ - FLASH_MODE_OPEN, + commitConfig(callback: AsyncCallback): void; + /** - * Auto mode. + * Commit capture session config. + * @return Promise used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. */ - FLASH_MODE_AUTO, + commitConfig(): Promise; + /** - * Always open mode. + * Adds a camera input. + * @param cameraInput Target camera input to add. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. */ - FLASH_MODE_ALWAYS_OPEN - } + addInput(cameraInput: CameraInput): void; - /** - * Enum for focus mode. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - enum FocusMode { /** - * Manual mode. + * Removes a camera input. + * @param cameraInput Target camera input to remove. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. */ - FOCUS_MODE_MANUAL = 0, + removeInput(cameraInput: CameraInput): void; + /** - * Continuous auto mode. + * Adds a camera output. + * @param cameraOutput Target camera output to add. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. */ - FOCUS_MODE_CONTINUOUS_AUTO, + addOutput(cameraOutput: CameraOutput): void; + /** - * Auto mode. + * Removes a camera output. + * @param previewOutput Target camera output to remove. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. */ - FOCUS_MODE_AUTO, + removeOutput(cameraOutput: CameraOutput): void; + /** - * Locked mode. + * Starts capture session. + * @param callback Callback used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. */ - FOCUS_MODE_LOCKED - } + start(callback: AsyncCallback): void; - /** - * Enum for focus state. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - enum FocusState { /** - * Scan state. + * Starts capture session. + * @return Promise used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. */ - FOCUS_STATE_SCAN = 0, + start(): Promise; + /** - * Focused state. + * Stops capture session. + * @param callback Callback used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. */ - FOCUS_STATE_FOCUSED, + stop(callback: AsyncCallback): void; + /** - * Unfocused state. + * Stops capture session. + * @return Promise used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. */ - FOCUS_STATE_UNFOCUSED - } - - /** - * Gets a CaptureSession instance. - * @param context Current application context. - * @param callback Callback used to return the CaptureSession instance. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - function createCaptureSession(context: Context, callback: AsyncCallback): void; - - /** - * Gets a CaptureSession instance. - * @param context Current application context. - * @return Promise used to return the CaptureSession instance. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - function createCaptureSession(context: Context): Promise; + stop(): Promise; - /** - * Capture session object. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - interface CaptureSession { /** - * Begin capture session config. + * Release capture session instance. * @param callback Callback used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. */ - beginConfig(callback: AsyncCallback): void; + release(callback: AsyncCallback): void; /** - * Begin capture session config. + * Release capture session instance. * @return Promise used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. */ - beginConfig(): Promise; + release(): Promise; /** - * Commit capture session config. - * @param callback Callback used to return the result. + * Check if device has flash light. + * @return The flash light support status. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. */ - commitConfig(callback: AsyncCallback): void; + hasFlash(): boolean; /** - * Commit capture session config. - * @return Promise used to return the result. + * Checks whether a specified flash mode is supported. + * @param flashMode Flash mode + * @return Is the flash mode supported. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. */ - commitConfig(): Promise; + isFlashModeSupported(flashMode: FlashMode): boolean; /** - * Adds a camera input. - * @param cameraInput Target camera input to add. - * @param callback Callback used to return the result. + * Gets current flash mode. + * @return The current flash mode. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. */ - addInput(cameraInput: CameraInput, callback: AsyncCallback): void; + getFlashMode(): FlashMode; /** - * Adds a camera input. - * @param cameraInput Target camera input to add. - * @return Promise used to return the result. + * Sets flash mode. + * @param flashMode Target flash mode. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. */ - addInput(cameraInput: CameraInput): Promise; + setFlashMode(flashMode: FlashMode): void; /** - * Adds a camera preview output. - * @param previewOutput Target camera preview output to add. - * @param callback Callback used to return the result. + * Checks whether a specified exposure mode is supported. + * @param aeMode Exposure mode + * @return Is the exposure mode supported. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. */ - addOutput(previewOutput: PreviewOutput, callback: AsyncCallback): void; - + isExposureModeSupported(aeMode: ExposureMode): boolean; + /** - * Adds a camera preview output. - * @param previewOutput Target camera preview output to add. - * @return Promise used to return the result. + * Gets current exposure mode. + * @return The current exposure mode. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. */ - addOutput(previewOutput: PreviewOutput): Promise; + getExposureMode(): ExposureMode; + + /** + * Sets Exposure mode. + * @param aeMode Exposure mode + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. + */ + setExposureMode(aeMode: ExposureMode): void; /** - * Adds a camera photo output. - * @param photoOutput Target camera photo output to add. - * @param callback Callback used to return the result. + * Gets current metering point. + * @return The current metering point. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. */ - addOutput(photoOutput: PhotoOutput, callback: AsyncCallback): void; + getMeteringPoint(): Point; /** - * Adds a camera photo output. - * @param photoOutput Target camera photo output to add. - * @return Promise used to return the result. + * Set the center point of the metering area. + * @param point metering point * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. */ - addOutput(photoOutput: PhotoOutput): Promise; + setMeteringPoint(point: Point): void; /** - * Adds a camera video output. - * @param videoOutput Target camera video output to add. - * @param callback Callback used to return the result. + * Query the exposure compensation range. + * @return The array of compenstation range. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. */ - addOutput(videoOutput: VideoOutput, callback: AsyncCallback): void; + getExposureBiasRange(): Array; /** - * Adds a camera video output. - * @param videoOutput Target camera video output to add. - * @return Promise used to return the result. + * Set exposure compensation. + * @param exposureBias Exposure compensation * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. */ - addOutput(videoOutput: VideoOutput): Promise; + setExposureBias(exposureBias: number): void; /** - * Removes a camera input. - * @param cameraInput Target camera input to remove. - * @param callback Callback used to return the result. + * Query the exposure value. + * @return The exposure value. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. */ - removeInput(cameraInput: CameraInput, callback: AsyncCallback): void; + getExposureValue(): number; /** - * Removes a camera input. - * @param cameraInput Target camera input to remove. - * @return Promise used to return the result. + * Checks whether a specified focus mode is supported. + * @param afMode Focus mode. + * @return Is the focus mode supported. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. */ - removeInput(cameraInput: CameraInput): Promise; + isFocusModeSupported(afMode: FocusMode): boolean; /** - * Removes a camera preview output. - * @param previewOutput Target camera preview output to remove. - * @param callback Callback used to return the result. + * Gets current focus mode. + * @return The current focus mode. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. */ - removeOutput(previewOutput: PreviewOutput, callback: AsyncCallback): void; + getFocusMode(): FocusMode; /** - * Removes a camera preview output. - * @param previewOutput Target camera preview output to remove. - * @return Promise used to return the result. + * Sets focus mode. + * @param afMode Target focus mode. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. */ - removeOutput(previewOutput: PreviewOutput): Promise; + setFocusMode(afMode: FocusMode): void; /** - * Removes a camera photo output. - * @param photoOutput Target camera photo output to remove. - * @param callback Callback used to return the result. + * Sets focus point. + * @param afMode Target focus point. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. */ - removeOutput(photoOutput: PhotoOutput, callback: AsyncCallback): void; + setFocusPoint(point: Point): void; /** - * Removes a camera photo output. - * @param photoOutput Target camera photo output to remove. - * @return Promise used to return the result. + * Gets current focus point. + * @return The current focus point. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. */ - removeOutput(photoOutput: PhotoOutput): Promise; + getFocusPoint(): Point; /** - * Removes a camera video output. - * @param videoOutput Target camera video output to remove. - * @param callback Callback used to return the result. + * Gets current focal length. + * @return The current focal point. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. */ - removeOutput(videoOutput: VideoOutput, callback: AsyncCallback): void; + getFocalLength(): number; /** - * Removes a camera video output. - * @param videoOutput Target camera video output to remove. - * @return Promise used to return the result. + * Gets all supported zoom ratio range. + * @return The zoom ratio range. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. */ - removeOutput(videoOutput: VideoOutput): Promise; + getZoomRatioRange(): Array; /** - * Starts capture session. - * @param callback Callback used to return the result. + * Gets zoom ratio. + * @return The zoom ratio value. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. */ - start(callback: AsyncCallback): void; + getZoomRatio(): number; /** - * Starts capture session. - * @return Promise used to return the result. + * Sets zoom ratio. + * @param zoomRatio Target zoom ratio. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. */ - start(): Promise; + setZoomRatio(zoomRatio: number): void; /** - * Stops capture session. - * @param callback Callback used to return the result. + * Check whether the specified video stabilization mode is supported. + * @param callback Callback used to return if video stablization mode is supported. + * @return Is flash mode supported. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. */ - stop(callback: AsyncCallback): void; + isVideoStablizationModeSupported(vsMode: VideoStabilizationMode): boolean; /** - * Stops capture session. - * @return Promise used to return the result. + * Query the video stabilization mode currently in use. + * @return The current video stabilization mode. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. */ - stop(): Promise; + getActiveVideoStabilizationMode(): VideoStabilizationMode; /** - * Release capture session instance. - * @param callback Callback used to return the result. + * Set video stabilization mode. + * @param mode video stabilization mode to set. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. */ - release(callback: AsyncCallback): void; + setVideoStabilizationMode(mode: VideoStabilizationMode): void; /** - * Release capture session instance. - * @return Promise used to return the result. + * Subscribes focus status change event callback. + * @param type Event type. + * @param callback Callback used to get the focus state change. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - release(): Promise; + on(type: 'focusStateChange', callback: AsyncCallback): void; /** * Subscribes error event callback. @@ -910,66 +1127,75 @@ declare namespace camera { * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - on(type: 'error', callback: ErrorCallback): void; + on(type: 'error', callback: ErrorCallback): void; } /** - * Enum for CaptureSession error code. + * Camera output object. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - enum CaptureSessionErrorCode { - ERROR_UNKNOWN = -1 - } + interface CameraOutput { + /** + * Release output instance. + * @param callback Callback used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. + */ + release(callback: AsyncCallback): void; - /** - * Capture session error object. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - interface CaptureSessionError extends Error { - code: CaptureSessionErrorCode; + /** + * Release output instance. + * @return Promise used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. + */ + release(): Promise; } /** - * Creates a PreviewOutput instance. - * @param surfaceId Surface object id used in camera preview output. - * @param callback Callback used to return the PreviewOutput instance. + * Preview output object. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - function createPreviewOutput(surfaceId: string, callback: AsyncCallback): void; + interface PreviewOutput extends CameraOutput { + /** + * Start output instance. + * @param callback Callback used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. + */ + start(callback: AsyncCallback): void; - /** - * Creates a PreviewOutput instance. - * @param surfaceId Surface object id used in camera preview output. - * @return Promise used to return the PreviewOutput instance. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - function createPreviewOutput(surfaceId: string): Promise; + /** + * Start output instance. + * @return Promise used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. + */ + start(): Promise; - /** - * Preview output object. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - interface PreviewOutput { /** - * Release output instance. + * Stop output instance. * @param callback Callback used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. */ - release(callback: AsyncCallback): void; + stop(callback: AsyncCallback): void; /** - * Release output instance. + * Stop output instance. * @return Promise used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. */ - release(): Promise; + stop(): Promise; /** * Subscribes frame start event callback. @@ -996,45 +1222,9 @@ declare namespace camera { * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - on(type: 'error', callback: ErrorCallback): void; - } - - /** - * Enum for preview output error code. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - enum PreviewOutputErrorCode { - ERROR_UNKNOWN = -1 - } - - /** - * Preview output error object. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - interface PreviewOutputError extends Error { - code: PreviewOutputErrorCode; + on(type: 'error', callback: ErrorCallback): void; } - /** - * Creates a PhotoOutput instance. - * @param surfaceId Surface object id used in camera photo output. - * @param callback Callback used to return the PhotoOutput instance. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - function createPhotoOutput(surfaceId: string, callback: AsyncCallback): void; - - /** - * Creates a PhotoOutput instance. - * @param surfaceId Surface object id used in camera photo output. - * @return Promise used to return the PhotoOutput instance. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - function createPhotoOutput(surfaceId: string): Promise; - /** * Enumerates the image rotation angles. * @since 9 @@ -1070,6 +1260,26 @@ declare namespace camera { ROTATION_270 = 270 } + interface Location { + /** + * Latitude. + * @since 9 + */ + latitude: number; + + /** + * Longitude. + * @since 9 + */ + longitude: number; + + /** + * Altitude. + * @since 9 + */ + altitude: number; + } + /** * Enumerates the image quality levels. * @since 9 @@ -1088,14 +1298,14 @@ declare namespace camera { * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - QUALITY_LEVEL_MEDIUM, + QUALITY_LEVEL_MEDIUM = 1, /** * Low image quality. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - QUALITY_LEVEL_LOW + QUALITY_LEVEL_LOW = 2 } /** @@ -1109,12 +1319,27 @@ declare namespace camera { * @syscap SystemCapability.Multimedia.Camera.Core */ quality?: QualityLevel; + /** * Photo rotation. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ rotation?: ImageRotation; + + /** + * Photo location. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + location?: Location; + + /** + * Set the mirror photo function switch, default to false. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + mirror?: boolean; } /** @@ -1122,48 +1347,60 @@ declare namespace camera { * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - interface PhotoOutput { + interface PhotoOutput extends CameraOutput { /** - * Start capture output. - * @param callback Callback used to return the result. + * Get default capture setting. + * @return The default capture setting. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - capture(callback: AsyncCallback): void; + getDefaultCaptureSetting(): PhotoCaptureSetting; /** * Start capture output. - * @param setting Photo capture settings. * @param callback Callback used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. */ - capture(setting: PhotoCaptureSetting, callback: AsyncCallback): void; + capture(callback: AsyncCallback): void; /** * Start capture output. - * @param setting Photo capture settings. * @return Promise used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. */ - capture(setting?: PhotoCaptureSetting): Promise; + capture(): Promise; /** - * Release output instance. + * Start capture output. + * @param setting Photo capture settings. * @param callback Callback used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. */ - release(callback: AsyncCallback): void; + capture(setting: PhotoCaptureSetting, callback: AsyncCallback): void; /** - * Release output instance. + * Start capture output. + * @param setting Photo capture settings. * @return Promise used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. */ - release(): Promise; + capture(setting?: PhotoCaptureSetting): Promise; + + /** + * Check whether to support mirror photo. + * @return Is the mirror supported. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + isMirrorSupported(): boolean; /** * Subscribes capture start event callback. @@ -1199,7 +1436,7 @@ declare namespace camera { * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - on(type: 'error', callback: ErrorCallback): void; + on(type: 'error', callback: ErrorCallback): void; } /** @@ -1242,61 +1479,27 @@ declare namespace camera { frameCount: number; } - /** - * Enum for photo output error code. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - enum PhotoOutputErrorCode { - ERROR_UNKNOWN = -1 - } - - /** - * Photo output error object. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - interface PhotoOutputError extends Error { - code: PhotoOutputErrorCode; - } - - /** - * Creates a VideoOutput instance. - * @param surfaceId Surface object id used in camera video output. - * @param callback Callback used to return the VideoOutput instance. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - function createVideoOutput(surfaceId: string, callback: AsyncCallback): void; - - /** - * Creates a VideoOutput instance. - * @param surfaceId Surface object id used in camera video output. - * @return Promise used to return the VideoOutput instance. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - function createVideoOutput(surfaceId: string): Promise; - /** * Video output object. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - interface VideoOutput { + interface VideoOutput extends CameraOutput { /** * Start video output. * @param callback Callback used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. */ start(callback: AsyncCallback): void; - /** + /** * Start video output. * @return Promise used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. */ start(): Promise; @@ -1305,6 +1508,7 @@ declare namespace camera { * @param callback Callback used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. */ stop(callback: AsyncCallback): void; @@ -1313,25 +1517,10 @@ declare namespace camera { * @return Promise used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. */ stop(): Promise; - /** - * Release output instance. - * @param callback Callback used to return the result. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - release(callback: AsyncCallback): void; - - /** - * Release output instance. - * @return Promise used to return the result. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - release(): Promise; - /** * Subscribes frame start event callback. * @param type Event type. @@ -1357,25 +1546,137 @@ declare namespace camera { * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - on(type: 'error', callback: ErrorCallback): void; + on(type: 'error', callback: ErrorCallback): void; + } + + /** + * Metadata object type. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + enum MetadataObjectType { + FACE_DETECTION = 0 + } + + /** + * Rectangle definition. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + interface Rect { + /** + * X coordinator of top left point. + * @param Promise used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + topLeftX: number; + /** + * Y coordinator of top left point. + * @param Promise used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + topLeftY: number; + /** + * Width of this rectangle. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + width: number; + /** + * Height of this rectangle. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + height: number; } /** - * Enum for video output error code. + * Metadata object basis. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - enum VideoOutputErrorCode { - ERROR_UNKNOWN = -1 + interface MetadataObject { + /** + * Metadata object type. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + readonly type: MetadataObjectType; + /** + * Metadata object timestamp in milliseconds. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + readonly timestamp: number; + /** + * The axis-aligned bounding box of detected metadata object. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + readonly boundingBox: Rect; } /** - * Video output error object. + * Metadata Output object * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - interface VideoOutputError extends Error { - code: VideoOutputErrorCode; + interface MetadataOutput extends CameraOutput { + /** + * Start output metadata + * @param callback Callback used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. + */ + start(callback: AsyncCallback): void; + + /** + * Start output metadata + * @return Promise used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. + */ + start(): Promise; + + /** + * Stop output metadata + * @param callback Callback used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. + */ + stop(callback: AsyncCallback): void; + + /** + * Stop output metadata + * @return Promise used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. + */ + stop(): Promise; + + /** + * Subscribes to metadata objects available event callback. + * @param type Event type. + * @param callback Callback used to get the available metadata objects. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + on(type: 'metadataObjectsAvailable', callback: AsyncCallback>): void; + + /** + * Subscribes error event callback. + * @param type Event type. + * @param callback Callback used to get the video output errors. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + on(type: 'error', callback: ErrorCallback): void; } } -- Gitee From fa386b3a592841dd7ebaaf2ac15d07dd3f124a52 Mon Sep 17 00:00:00 2001 From: supeng Date: Mon, 17 Oct 2022 16:33:32 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E5=BC=82=E5=B8=B8=E6=9C=BA=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: supeng --- api/@ohos.multimedia.camera.d.ts | 38 +++++++------------------------- 1 file changed, 8 insertions(+), 30 deletions(-) diff --git a/api/@ohos.multimedia.camera.d.ts b/api/@ohos.multimedia.camera.d.ts index a4cf42c590..f5b5e6404b 100644 --- a/api/@ohos.multimedia.camera.d.ts +++ b/api/@ohos.multimedia.camera.d.ts @@ -28,10 +28,9 @@ declare namespace camera { /** * Creates a CameraManager instance. * @param context Current application context. - * @return CameraManager instance. + * @return CameraManager instance, or nullptr if error. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core - * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. */ function getCameraManager(context: Context): CameraManager; @@ -258,10 +257,9 @@ declare namespace camera { /** * Creates a CameraInput instance by camera. * @param camera Camera device used to create the instance. - * @return The CameraInput instance. + * @return The CameraInput instance, or nullptr if error. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core - * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. * @permission ohos.permission.CAMERA */ createCameraInput(camera: CameraDevice): CameraInput; @@ -270,10 +268,9 @@ declare namespace camera { * Creates a CameraInput instance by camera position and type. * @param position Target camera position. * @param type Target camera type. - * @return The CameraInput instance. + * @return The CameraInput instance, or nullptr if error. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core - * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. * @permission ohos.permission.CAMERA */ createCameraInput(position: CameraPosition, type: CameraType): CameraInput; @@ -282,10 +279,9 @@ declare namespace camera { * Creates a PreviewOutput instance. * @param profile Preview output profile. * @param surfaceId Surface object id used in camera photo output. - * @return The PreviewOutput instance. + * @return The PreviewOutput instance, or nullptr if error. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core - * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. */ createPreviewOutput(profile: Profile, surfaceId: string): PreviewOutput; @@ -293,10 +289,9 @@ declare namespace camera { * Creates a PhotoOutput instance. * @param profile Photo output profile. * @param surfaceId Surface object id used in camera photo output. - * @return The PhotoOutput instance. + * @return The PhotoOutput instance, or nullptr if error. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core - * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. */ createPhotoOutput(profile: Profile, surfaceId: string): PhotoOutput; @@ -304,29 +299,26 @@ declare namespace camera { * Creates a VideoOutput instance. * @param profile Video profile. * @param surfaceId Surface object id used in camera video output. - * @return The VideoOutput instance. + * @return The VideoOutput instance, or nullptr if error. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core - * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. */ createVideoOutput(profile: VideoProfile, surfaceId: string): VideoOutput; /** * Creates a MetadataOutput instance. * @param metadataObjectTypes Array of MetadataObjectType. - * @return The MetadataOutput instance. + * @return The MetadataOutput instance, or nullptr if error. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core - * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. */ createMetadataOutput(metadataObjectTypes: Array): MetadataOutput; /** * Gets a CaptureSession instance. - * @return The CaptureSession instance. + * @return The CaptureSession instance, or nullptr if error. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core - * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. */ createCaptureSession(): CaptureSession; @@ -567,7 +559,6 @@ declare namespace camera { * @param callback Callback used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core - * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. */ close(callback: AsyncCallback): void; @@ -576,7 +567,6 @@ declare namespace camera { * @return Promise used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core - * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. */ close(): Promise; @@ -860,7 +850,6 @@ declare namespace camera { * @param callback Callback used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core - * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. */ stop(callback: AsyncCallback): void; @@ -869,7 +858,6 @@ declare namespace camera { * @return Promise used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core - * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. */ stop(): Promise; @@ -878,7 +866,6 @@ declare namespace camera { * @param callback Callback used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core - * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. */ release(callback: AsyncCallback): void; @@ -887,7 +874,6 @@ declare namespace camera { * @return Promise used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core - * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. */ release(): Promise; @@ -1141,7 +1127,6 @@ declare namespace camera { * @param callback Callback used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core - * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. */ release(callback: AsyncCallback): void; @@ -1150,7 +1135,6 @@ declare namespace camera { * @return Promise used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core - * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. */ release(): Promise; } @@ -1184,7 +1168,6 @@ declare namespace camera { * @param callback Callback used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core - * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. */ stop(callback: AsyncCallback): void; @@ -1193,7 +1176,6 @@ declare namespace camera { * @return Promise used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core - * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. */ stop(): Promise; @@ -1508,7 +1490,6 @@ declare namespace camera { * @param callback Callback used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core - * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. */ stop(callback: AsyncCallback): void; @@ -1517,7 +1498,6 @@ declare namespace camera { * @return Promise used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core - * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. */ stop(): Promise; @@ -1647,7 +1627,6 @@ declare namespace camera { * @param callback Callback used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core - * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. */ stop(callback: AsyncCallback): void; @@ -1656,7 +1635,6 @@ declare namespace camera { * @return Promise used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core - * @throws Throws this exception if any of the following errors occurs:{@link CameraErrorCode}. */ stop(): Promise; -- Gitee