/* * 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 { ErrorCallback, AsyncCallback } from './@ohos.base'; import type Context from './application/BaseContext'; import image from './@ohos.multimedia.image'; /** * @namespace camera * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ declare namespace camera { /** * Creates a CameraManager instance. * * @param { Context } context - Current application context. * @returns { CameraManager } CameraManager instance. * @throws { BusinessError } 7400101 - Parameter missing or parameter type incorrect. * @throws { BusinessError } 7400201 - Camera service fatal error. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ function getCameraManager(context: Context): CameraManager; /** * Enum for camera status. * * @enum { number } * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ enum CameraStatus { /** * Appear status. * * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ CAMERA_STATUS_APPEAR = 0, /** * Disappear status. * * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ CAMERA_STATUS_DISAPPEAR = 1, /** * Available status. * * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ CAMERA_STATUS_AVAILABLE = 2, /** * Unavailable status. * * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ CAMERA_STATUS_UNAVAILABLE = 3 } /** * Profile for camera streams. * * @typedef Profile * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ interface Profile { /** * Camera format. * * @type { CameraFormat } * @readonly * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ readonly format: CameraFormat; /** * Picture size. * * @type { Size } * @readonly * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ readonly size: Size; } /** * Frame rate range. * * @typedef FrameRateRange * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ interface FrameRateRange { /** * Min frame rate. * * @type { number } * @readonly * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ readonly min: number; /** * Max frame rate. * * @type { number } * @readonly * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ readonly max: number; } /** * Video profile. * * @typedef VideoProfile * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ interface VideoProfile extends Profile { /** * Frame rate in unit fps (frames per second). * * @type { FrameRateRange } * @readonly * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ readonly frameRateRange: FrameRateRange; } /** * Camera output capability. * * @typedef CameraOutputCapability * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ interface CameraOutputCapability { /** * Preview profiles. * * @type { Array } * @readonly * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ readonly previewProfiles: Array; /** * Photo profiles. * * @type { Array } * @readonly * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ readonly photoProfiles: Array; /** * Video profiles. * * @type { Array } * @readonly * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ readonly videoProfiles: Array; /** * All the supported metadata Object Types. * * @type { Array } * @readonly * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ readonly supportedMetadataObjectTypes: Array; } /** * Enum for camera error code. * * @enum { number } * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ enum CameraErrorCode { /** * Parameter missing or parameter type incorrect. * * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ INVALID_ARGUMENT = 7400101, /** * Operation not allowed. * * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ OPERATION_NOT_ALLOWED = 7400102, /** * Session not config. * * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ SESSION_NOT_CONFIG = 7400103, /** * Session not running. * * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ SESSION_NOT_RUNNING = 7400104, /** * Session config locked. * * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ SESSION_CONFIG_LOCKED = 7400105, /** * Device setting locked. * * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ DEVICE_SETTING_LOCKED = 7400106, /** * Can not use camera cause of conflict. * * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ CONFLICT_CAMERA = 7400107, /** * Camera disabled cause of security reason. * * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ DEVICE_DISABLED = 7400108, /** * Can not use camera cause of preempted. * * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ DEVICE_PREEMPTED = 7400109, /** * Camera service fatal error. * * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ SERVICE_FATAL_ERROR = 7400201 } /** * Prelaunch config object. * * @typedef PrelaunchConfig * @syscap SystemCapability.Multimedia.Camera.Core * @systemapi * @since 10 */ interface PrelaunchConfig { /** * Camera instance. * * @type { CameraDevice } * @syscap SystemCapability.Multimedia.Camera.Core * @systemapi * @since 10 */ cameraDevice: CameraDevice; } /** * Camera manager object. * * @interface CameraManager * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ interface CameraManager { /** * Gets supported camera descriptions. * * @returns { Array } An array of supported cameras. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ getSupportedCameras(): Array; /** * Gets supported output capability for specific camera. * * @param { CameraDevice } camera - Camera device. * @returns { CameraOutputCapability } The camera output capability. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ getSupportedOutputCapability(camera: CameraDevice): CameraOutputCapability; /** * Determine whether camera is muted. * * @returns { boolean } Is camera muted. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ isCameraMuted(): boolean; /** * Determine whether camera mute is supported. * * @returns { boolean } Is camera mute supported. * @syscap SystemCapability.Multimedia.Camera.Core * @systemapi * @since 10 */ isCameraMuteSupported(): boolean; /** * Mute camera. * * @param { boolean } mute - Mute camera if TRUE, otherwise unmute camera. * @syscap SystemCapability.Multimedia.Camera.Core * @systemapi * @since 10 */ muteCamera(mute: boolean): void; /** * Creates a CameraInput instance by camera. * * @permission ohos.permission.CAMERA * @param { CameraDevice } camera - Camera device used to create the instance. * @returns { CameraInput } The CameraInput instance. * @throws { BusinessError } 7400101 - Parameter missing or parameter type incorrect. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ createCameraInput(camera: CameraDevice): CameraInput; /** * Creates a CameraInput instance by camera position and type. * * @permission ohos.permission.CAMERA * @param { CameraPosition } position - Target camera position. * @param { CameraType } type - Target camera type. * @returns { CameraInput } The CameraInput instance. * @throws { BusinessError } 7400101 - Parameter missing or parameter type incorrect. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ createCameraInput(position: CameraPosition, type: CameraType): CameraInput; /** * Creates a PreviewOutput instance. * * @param { Profile } profile - Preview output profile. * @param { string } surfaceId - Surface object id used in camera photo output. * @returns { PreviewOutput } The PreviewOutput instance. * @throws { BusinessError } 7400101 - Parameter missing or parameter type incorrect. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ createPreviewOutput(profile: Profile, surfaceId: string): PreviewOutput; /** * Creates a PhotoOutput instance. * * @param { Profile } profile - Photo output profile. * @param { string } surfaceId - Surface object id used in camera photo output. * @returns { PhotoOutput } The PhotoOutput instance. * @throws { BusinessError } 7400101 - Parameter missing or parameter type incorrect. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ createPhotoOutput(profile: Profile, surfaceId: string): PhotoOutput; /** * Creates a VideoOutput instance. * * @param { VideoProfile } profile - Video profile. * @param { string } surfaceId - Surface object id used in camera video output. * @returns { VideoOutput } The VideoOutput instance. * @throws { BusinessError } 7400101 - Parameter missing or parameter type incorrect. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ createVideoOutput(profile: VideoProfile, surfaceId: string): VideoOutput; /** * Creates a MetadataOutput instance. * * @param { Array } metadataObjectTypes - Array of MetadataObjectType. * @returns { MetadataOutput } The MetadataOutput instance. * @throws { BusinessError } 7400101 - Parameter missing or parameter type incorrect. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ createMetadataOutput(metadataObjectTypes: Array): MetadataOutput; /** * Gets a CaptureSession instance. * * @returns { CaptureSession } The CaptureSession instance. * @throws { BusinessError } 7400201 - Camera service fatal error. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ createCaptureSession(): CaptureSession; /** * Subscribes camera status change event callback. * * @param { 'cameraStatus' } type - Event type. * @param { AsyncCallback } callback - Callback used to get the camera status change. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ on(type: 'cameraStatus', callback: AsyncCallback): void; /** * Unsubscribes from camera status change event callback. * * @param { 'cameraStatus' } type - Event type. * @param { AsyncCallback } callback - Callback used to get the camera status change. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ off(type: 'cameraStatus', callback?: AsyncCallback): void; /** * Subscribes camera mute change event callback. * * @param { 'cameraMute' } type - Event type. * @param { AsyncCallback } callback - Callback used to get the camera mute change. * @syscap SystemCapability.Multimedia.Camera.Core * @systemapi * @since 10 */ on(type: 'cameraMute', callback: AsyncCallback): void; /** * Unsubscribes from camera mute change event callback. * * @param { 'cameraMute' } type - Event type. * @param { AsyncCallback } callback - Callback used to get the camera mute change. * @syscap SystemCapability.Multimedia.Camera.Core * @systemapi * @since 10 */ off(type: 'cameraMute', callback?: AsyncCallback): void; /** * Determines whether the camera device supports prelaunch. * This function must be called in prior to the setPrelaunchConfig and prelaunch functions. * * @param { CameraDevice } camera - Camera device. * @returns { boolean } Whether prelaunch is supported. * @throws { BusinessError } 7400101 - Parameter missing or parameter type incorrect. * @syscap SystemCapability.Multimedia.Camera.Core * @systemapi * @since 10 */ isPrelaunchSupported(camera: CameraDevice): boolean; /** * Sets the camera prelaunch configuration. * The configuration is sent to the camera service when you exit the camera or change the configuration next time. * * @permission ohos.permission.CAMERA * @param { PrelaunchConfig } prelaunchConfig - Prelaunch configuration info. * @throws { BusinessError } 7400101 - Parameter missing or parameter type incorrect. * @throws { BusinessError } 7400102 - Operation not allowed. * @syscap SystemCapability.Multimedia.Camera.Core * @systemapi * @since 10 */ setPrelaunchConfig(prelaunchConfig: PrelaunchConfig): void; /** * Enable the camera to prelaunch and start. * This function is called when the user clicks the system camera icon to start the camera application. * * @syscap SystemCapability.Multimedia.Camera.Core * @systemapi * @since 10 */ prelaunch(): void; /** * Creates a deferred PreviewOutput instance. * * @param { Profile } profile - Preview output profile. * @returns { PreviewOutput } the PreviewOutput instance. * @throws { BusinessError } 7400101 - Parameter missing or parameter type incorrect. * @syscap SystemCapability.Multimedia.Camera.Core * @systemapi * @since 10 */ createDeferredPreviewOutput(profile: Profile): PreviewOutput; } /** * Camera status info. * * @typedef CameraStatusInfo * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ interface CameraStatusInfo { /** * Camera instance. * * @type { CameraDevice } * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ camera: CameraDevice; /** * Current camera status. * * @type { CameraStatus } * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ status: CameraStatus; } /** * Enum for camera position. * * @enum { number } * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ enum CameraPosition { /** * Unspecified position. * * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ CAMERA_POSITION_UNSPECIFIED = 0, /** * Back position. * * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ CAMERA_POSITION_BACK = 1, /** * Front position. * * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ CAMERA_POSITION_FRONT = 2 } /** * Enum for camera type. * * @enum { number } * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ enum CameraType { /** * Default camera type * * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ CAMERA_TYPE_DEFAULT = 0, /** * Wide camera * * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ CAMERA_TYPE_WIDE_ANGLE = 1, /** * Ultra wide camera * * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ CAMERA_TYPE_ULTRA_WIDE = 2, /** * Telephoto camera * * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ CAMERA_TYPE_TELEPHOTO = 3, /** * True depth camera * * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ CAMERA_TYPE_TRUE_DEPTH = 4 } /** * Enum for camera connection type. * * @enum { number } * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ enum ConnectionType { /** * Built-in camera. * * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ CAMERA_CONNECTION_BUILT_IN = 0, /** * Camera connected using USB * * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ CAMERA_CONNECTION_USB_PLUGIN = 1, /** * Remote camera * * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ CAMERA_CONNECTION_REMOTE = 2 } /** * Enum for remote camera device type. * * @enum { number } * @syscap SystemCapability.Multimedia.Camera.Core * @systemapi * @since 10 */ enum HostDeviceType { /** * Indicates an unknown device camera. * * @syscap SystemCapability.Multimedia.Camera.Core * @systemapi * @since 10 */ UNKNOWN_TYPE = 0, /** * Indicates a smartphone camera. * * @syscap SystemCapability.Multimedia.Camera.Core * @systemapi * @since 10 */ PHONE = 0x0E, /** * Indicates a tablet camera. * * @syscap SystemCapability.Multimedia.Camera.Core * @systemapi * @since 10 */ TABLET = 0x11 } /** * Camera device object. * * @typedef CameraDevice * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ interface CameraDevice { /** * Camera id attribute. * * @type { string } * @readonly * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ readonly cameraId: string; /** * Camera position attribute. * * @type { CameraPosition } * @readonly * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ readonly cameraPosition: CameraPosition; /** * Camera type attribute. * * @type { CameraType } * @readonly * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ readonly cameraType: CameraType; /** * Camera connection type attribute. * * @type { ConnectionType } * @readonly * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ readonly connectionType: ConnectionType; /** * Camera remote camera device name attribute. * * @type { string } * @readonly * @syscap SystemCapability.Multimedia.Camera.Core * @systemapi * @since 10 */ readonly hostDeviceName: string; /** * Camera remote camera device type attribute. * * @type { HostDeviceType } * @readonly * @syscap SystemCapability.Multimedia.Camera.Core * @systemapi * @since 10 */ readonly hostDeviceType: HostDeviceType; } /** * Size parameter. * * @typedef Size * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ interface Size { /** * Height. * * @type { number } * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ height: number; /** * Width. * * @type { number } * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ width: number; } /** * Point parameter. * * @typedef Point * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ interface Point { /** * x co-ordinate * * @type { number } * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ x: number; /** * y co-ordinate * * @type { number } * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ y: number; } /** * Camera input object. * * @interface CameraInput * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ interface CameraInput { /** * Open camera. * * @param { AsyncCallback } callback - Callback used to return the result. * @throws { BusinessError } 7400107 - Can not use camera cause of conflict. * @throws { BusinessError } 7400108 - Camera disabled cause of security reason. * @throws { BusinessError } 7400201 - Camera service fatal error. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ open(callback: AsyncCallback): void; /** * Open camera. * * @returns { Promise } Promise used to return the result. * @throws { BusinessError } 7400107 - Can not use camera cause of conflict. * @throws { BusinessError } 7400108 - Camera disabled cause of security reason. * @throws { BusinessError } 7400201 - Camera service fatal error. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ open(): Promise; /** * Close camera. * * @param { AsyncCallback } callback - Callback used to return the result. * @throws { BusinessError } 7400201 - Camera service fatal error. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ close(callback: AsyncCallback): void; /** * Close camera. * * @returns { Promise } Promise used to return the result. * @throws { BusinessError } 7400201 - Camera service fatal error. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ close(): Promise; /** * Subscribes to error events. * * @param { 'error' } type - Event type. * @param { CameraDevice } camera - Camera device. * @param { ErrorCallback } callback - Callback used to get the camera input errors. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ on(type: 'error', camera: CameraDevice, callback: ErrorCallback): void; /** * Unsubscribes from error events. * * @param { 'error' } type - Event type. * @param { CameraDevice } camera - Camera device. * @param { ErrorCallback } callback - Callback used to get the camera input errors. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ off(type: 'error', camera: CameraDevice, callback?: ErrorCallback): void; } /** * Enum for camera format type. * * @enum { number } * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ enum CameraFormat { /** * RGBA 8888 Format. * * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ CAMERA_FORMAT_RGBA_8888 = 3, /** * YUV 420 Format. * * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ CAMERA_FORMAT_YUV_420_SP = 1003, /** * JPEG Format. * * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ CAMERA_FORMAT_JPEG = 2000 } /** * Enum for flash mode. * * @enum { number } * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ enum FlashMode { /** * Close mode. * * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ FLASH_MODE_CLOSE = 0, /** * Open mode. * * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ FLASH_MODE_OPEN = 1, /** * Auto mode. * * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ FLASH_MODE_AUTO = 2, /** * Always open mode. * * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ FLASH_MODE_ALWAYS_OPEN = 3 } /** * Enum for exposure mode. * * @enum { number } * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ enum ExposureMode { /** * Lock exposure mode. * * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ EXPOSURE_MODE_LOCKED = 0, /** * Auto exposure mode. * * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ EXPOSURE_MODE_AUTO = 1, /** * Continuous automatic exposure. * * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ EXPOSURE_MODE_CONTINUOUS_AUTO = 2 } /** * Enum for focus mode. * * @enum { number } * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ enum FocusMode { /** * Manual mode. * * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ FOCUS_MODE_MANUAL = 0, /** * Continuous auto mode. * * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ FOCUS_MODE_CONTINUOUS_AUTO = 1, /** * Auto mode. * * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ FOCUS_MODE_AUTO = 2, /** * Locked mode. * * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ FOCUS_MODE_LOCKED = 3 } /** * Enum for focus state. * * @enum { number } * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ enum FocusState { /** * Scan state. * * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ FOCUS_STATE_SCAN = 0, /** * Focused state. * * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ FOCUS_STATE_FOCUSED = 1, /** * Unfocused state. * * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ FOCUS_STATE_UNFOCUSED = 2 } /** * Enum for video stabilization mode. * * @enum { number } * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ enum VideoStabilizationMode { /** * Turn off video stablization. * * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ OFF = 0, /** * LOW mode provides basic stabilization effect. * * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ LOW = 1, /** * MIDDLE mode means algorithms can achieve better effects than LOW mode. * * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ MIDDLE = 2, /** * HIGH mode means algorithms can achieve better effects than MIDDLE mode. * * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ HIGH = 3, /** * Camera HDF can select mode automatically. * * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ AUTO = 4 } /** * Enumerates the camera filter types. * * @enum { number } * @syscap SystemCapability.Multimedia.Camera.Core * @systemapi * @since 10 */ enum FilterType { /** * Filter disabled. No filter effect is provided. * * @syscap SystemCapability.Multimedia.Camera.Core * @systemapi * @since 10 */ NONE = 0, /** * Classic filter effect. * * @syscap SystemCapability.Multimedia.Camera.Core * @systemapi * @since 10 */ CLASSIC = 1, /** * Dawn filter effect. * * @syscap SystemCapability.Multimedia.Camera.Core * @systemapi * @since 10 */ DAWN = 2, /** * Pure filter effect. * * @syscap SystemCapability.Multimedia.Camera.Core * @systemapi * @since 10 */ PURE = 3, /** * Grey filter effect. * * @syscap SystemCapability.Multimedia.Camera.Core * @systemapi * @since 10 */ GREY = 4, /** * Natural filter effect. * * @syscap SystemCapability.Multimedia.Camera.Core * @systemapi * @since 10 */ NATURAL = 5, /** * Mori filter effect. * * @syscap SystemCapability.Multimedia.Camera.Core * @systemapi * @since 10 */ MORI = 6, /** * Fair filter effect. * * @syscap SystemCapability.Multimedia.Camera.Core * @systemapi * @since 10 */ FAIR = 7, /** * Pink filter effect. * * @syscap SystemCapability.Multimedia.Camera.Core * @systemapi * @since 10 */ PINK = 8 } /** * Enumerates the camera beauty effect types. * * @enum { number } * @syscap SystemCapability.Multimedia.Camera.Core * @systemapi * @since 10 */ enum BeautyType { /** * Auto beauty type. * * @syscap SystemCapability.Multimedia.Camera.Core * @systemapi * @since 10 */ AUTO = 0, /** * Skin smooth beauty type. * * @syscap SystemCapability.Multimedia.Camera.Core * @systemapi * @since 10 */ SKIN_SMOOTH = 1, /** * Face slender beauty type. * * @syscap SystemCapability.Multimedia.Camera.Core * @systemapi * @since 10 */ FACE_SLENDER = 2, /** * Skin tone beauty type. * * @syscap SystemCapability.Multimedia.Camera.Core * @systemapi * @since 10 */ SKIN_TONE = 3 } /** * Capture session object. * * @interface CaptureSession * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ interface CaptureSession { /** * Begin capture session config. * * @throws { BusinessError } 7400105 - Session config locked. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ beginConfig(): void; /** * Commit capture session config. * * @param { AsyncCallback } callback - Callback used to return the result. * @throws { BusinessError } 7400102 - Operation not allowed. * @throws { BusinessError } 7400201 - Camera service fatal error. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ commitConfig(callback: AsyncCallback): void; /** * Commit capture session config. * * @returns { Promise } Promise used to return the result. * @throws { BusinessError } 7400102 - Operation not allowed. * @throws { BusinessError } 7400201 - Camera service fatal error. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ commitConfig(): Promise; /** * Adds a camera input. * * @param { CameraInput } cameraInput - Target camera input to add. * @throws { BusinessError } 7400101 - Parameter missing or parameter type incorrect. * @throws { BusinessError } 7400102 - Operation not allowed. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ addInput(cameraInput: CameraInput): void; /** * Removes a camera input. * * @param { CameraInput } cameraInput - Target camera input to remove. * @throws { BusinessError } 7400101 - Parameter missing or parameter type incorrect. * @throws { BusinessError } 7400102 - Operation not allowed. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ removeInput(cameraInput: CameraInput): void; /** * Adds a camera output. * * @param { CameraOutput } cameraOutput - Target camera output to add. * @throws { BusinessError } 7400101 - Parameter missing or parameter type incorrect. * @throws { BusinessError } 7400102 - Operation not allowed. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ addOutput(cameraOutput: CameraOutput): void; /** * Removes a camera output. * * @param { CameraOutput } cameraOutput - Target camera output to remove. * @throws { BusinessError } 7400101 - Parameter missing or parameter type incorrect. * @throws { BusinessError } 7400102 - Operation not allowed. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ removeOutput(cameraOutput: CameraOutput): void; /** * Starts capture session. * * @param { AsyncCallback } callback - Callback used to return the result. * @throws { BusinessError } 7400103 - Session not config. * @throws { BusinessError } 7400201 - Camera service fatal error. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ start(callback: AsyncCallback): void; /** * Starts capture session. * * @returns { Promise } Promise used to return the result. * @throws { BusinessError } 7400103 - Session not config. * @throws { BusinessError } 7400201 - Camera service fatal error. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ start(): Promise; /** * Stops capture session. * * @param { AsyncCallback } callback - Callback used to return the result. * @throws { BusinessError } 7400201 - Camera service fatal error. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ stop(callback: AsyncCallback): void; /** * Stops capture session. * * @returns { Promise } Promise used to return the result. * @throws { BusinessError } 7400201 - Camera service fatal error. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ stop(): Promise; /** * Release capture session instance. * * @param { AsyncCallback } callback - Callback used to return the result. * @throws { BusinessError } 7400201 - Camera service fatal error. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ release(callback: AsyncCallback): void; /** * Release capture session instance. * * @returns { Promise } Promise used to return the result. * @throws { BusinessError } 7400201 - Camera service fatal error. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ release(): Promise; /** * Check if device has flash light. * * @returns { boolean } The flash light support status. * @throws { BusinessError } 7400103 - Session not config. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ hasFlash(): boolean; /** * Checks whether a specified flash mode is supported. * * @param { FlashMode } flashMode - Flash mode * @returns { boolean } Is the flash mode supported. * @throws { BusinessError } 7400103 - Session not config. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ isFlashModeSupported(flashMode: FlashMode): boolean; /** * Gets current flash mode. * * @returns { FlashMode } The current flash mode. * @throws { BusinessError } 7400103 - Session not config. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ getFlashMode(): FlashMode; /** * Sets flash mode. * * @param { FlashMode } flashMode - Target flash mode. * @throws { BusinessError } 7400103 - Session not config. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ setFlashMode(flashMode: FlashMode): void; /** * Checks whether a specified exposure mode is supported. * * @param { ExposureMode } aeMode - Exposure mode * @returns { boolean } Is the exposure mode supported. * @throws { BusinessError } 7400103 - Session not config. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ isExposureModeSupported(aeMode: ExposureMode): boolean; /** * Gets current exposure mode. * * @returns { ExposureMode } The current exposure mode. * @throws { BusinessError } 7400103 - Session not config. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ getExposureMode(): ExposureMode; /** * Sets Exposure mode. * * @param { ExposureMode } aeMode - Exposure mode * @throws { BusinessError } 7400103 - Session not config. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ setExposureMode(aeMode: ExposureMode): void; /** * Gets current metering point. * * @returns { Point } The current metering point. * @throws { BusinessError } 7400103 - Session not config. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ getMeteringPoint(): Point; /** * Set the center point of the metering area. * * @param { Point } point - metering point * @throws { BusinessError } 7400103 - Session not config. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ setMeteringPoint(point: Point): void; /** * Query the exposure compensation range. * * @returns { Array } The array of compensation range. * @throws { BusinessError } 7400103 - Session not config. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ getExposureBiasRange(): Array; /** * Set exposure compensation. * * @param { number } exposureBias - Exposure compensation * @throws { BusinessError } 7400103 - Session not config. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ setExposureBias(exposureBias: number): void; /** * Query the exposure value. * * @returns { number } The exposure value. * @throws { BusinessError } 7400103 - Session not config. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ getExposureValue(): number; /** * Checks whether a specified focus mode is supported. * * @param { FocusMode } afMode - Focus mode. * @returns { boolean } Is the focus mode supported. * @throws { BusinessError } 7400103 - Session not config. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ isFocusModeSupported(afMode: FocusMode): boolean; /** * Gets current focus mode. * * @returns { FocusMode } The current focus mode. * @throws { BusinessError } 7400103 - Session not config. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ getFocusMode(): FocusMode; /** * Sets focus mode. * * @param { FocusMode } afMode - Target focus mode. * @throws { BusinessError } 7400103 - Session not config. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ setFocusMode(afMode: FocusMode): void; /** * Sets focus point. * * @param { Point } point - Target focus point. * @throws { BusinessError } 7400103 - Session not config. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ setFocusPoint(point: Point): void; /** * Gets current focus point. * * @returns { Point } The current focus point. * @throws { BusinessError } 7400103 - Session not config. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ getFocusPoint(): Point; /** * Gets current focal length. * * @returns { number } The current focal point. * @throws { BusinessError } 7400103 - Session not config. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ getFocalLength(): number; /** * Gets all supported zoom ratio range. * * @returns { Array } The zoom ratio range. * @throws { BusinessError } 7400103 - Session not config. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ getZoomRatioRange(): Array; /** * Gets zoom ratio. * * @returns { number } The zoom ratio value. * @throws { BusinessError } 7400103 - Session not config. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ getZoomRatio(): number; /** * Sets zoom ratio. * * @param { number } zoomRatio - Target zoom ratio. * @throws { BusinessError } 7400103 - Session not config. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ setZoomRatio(zoomRatio: number): void; /** * Check whether the specified video stabilization mode is supported. * * @param { VideoStabilizationMode } vsMode - Video Stabilization mode. * @returns { boolean } Is flash mode supported. * @throws { BusinessError } 7400103 - Session not config. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ isVideoStabilizationModeSupported(vsMode: VideoStabilizationMode): boolean; /** * Query the video stabilization mode currently in use. * * @returns { VideoStabilizationMode } The current video stabilization mode. * @throws { BusinessError } 7400103 - Session not config. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ getActiveVideoStabilizationMode(): VideoStabilizationMode; /** * Set video stabilization mode. * * @param { VideoStabilizationMode } mode - video stabilization mode to set. * @throws { BusinessError } 7400103 - Session not config. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ setVideoStabilizationMode(mode: VideoStabilizationMode): void; /** * Subscribes focus status change event callback. * * @param { 'focusStateChange' } type - Event type. * @param { AsyncCallback } callback - Callback used to get the focus state change. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ on(type: 'focusStateChange', callback: AsyncCallback): void; /** * Unsubscribes from focus status change event callback. * * @param { 'focusStateChange' } type - Event type. * @param { AsyncCallback } callback - Callback used to get the focus state change. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ off(type: 'focusStateChange', callback?: AsyncCallback): void; /** * Subscribes to error events. * * @param { 'error' } type - Event type. * @param { ErrorCallback } callback - Callback used to get the capture session errors. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ on(type: 'error', callback: ErrorCallback): void; /** * Unsubscribes from error events. * * @param { 'error' } type - Event type. * @param { ErrorCallback } callback - Callback used to get the capture session errors. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ off(type: 'error', callback?: ErrorCallback): void; /** * Gets the supported filter effects. * * @returns { Array } List of filter effects, the list must be a subset of {@link FilterType} * @throws { BusinessError } 7400103 - Session not config. * @syscap SystemCapability.Multimedia.Camera.Core * @systemapi * @since 10 */ getSupportedFilters(): Array; /** * Gets the filter effect in use. * * @returns { number } the filter effect in use, included in {@link FilterType} * @throws { BusinessError } 7400103 - Session not config. * @syscap SystemCapability.Multimedia.Camera.Core * @systemapi * @since 10 */ getFilter(): number; /** * Sets a filter effect for a camera device. * * @param { number } filter - Filter effect to set. The filter must be included in {@link FilterType} * @throws { BusinessError } 7400101 - Parameter missing or parameter type incorrect. * @throws { BusinessError } 7400103 - Session not config. * @syscap SystemCapability.Multimedia.Camera.Core * @systemapi * @since 10 */ setFilter(filter: number): void; /** * Gets supported beauty effect types. * * @returns { Array } List of beauty effect types. * @throws { BusinessError } 7400103 - Session not config. * @syscap SystemCapability.Multimedia.Camera.Core * @systemapi * @since 10 */ getSupportedBeautyTypes(): Array; /** * Gets the specific beauty effect type range. * * @param { BeautyType } type - The type of beauty effect. * @returns { Array } The array of the specific beauty effect range. * @throws { BusinessError } 7400103 - Session not config. * @syscap SystemCapability.Multimedia.Camera.Core * @systemapi * @since 10 */ getSupportedBeautyRange(type: BeautyType): Array; /** * Gets the beauty effect in use. * * @param { BeautyType } type - The type of beauty effect. * @returns { number } the beauty effect in use. * @throws { BusinessError } 7400103 - Session not config. * @syscap SystemCapability.Multimedia.Camera.Core * @systemapi * @since 10 */ getBeauty(type: BeautyType): number; /** * Sets a beauty effect for a camera device. * * @param { BeautyType } type - The type of beauty effect. * @param { number } value The number of beauty effect. * @throws { BusinessError } 7400103 - Session not config. * @syscap SystemCapability.Multimedia.Camera.Core * @systemapi * @since 10 */ setBeauty(type: BeautyType, value: number): void; } /** * Enumerates the camera modes. * * @enum { number } * @syscap SystemCapability.Multimedia.Camera.Core * @systemapi * @since 10 */ enum CameraMode { /** * portrait mode. * * @syscap SystemCapability.Multimedia.Camera.Core * @systemapi * @since 10 */ PORTRAIT = 1 } /** * Creates a ModeManager instance. * * @param { Context } context - Current application context. * @returns { ModeManager } ModeManager instance. * @throws { BusinessError } 7400101 - Parameter missing or parameter type incorrect. * @throws { BusinessError } 7400201 - Camera service fatal error. * @syscap SystemCapability.Multimedia.Camera.Core * @systemapi * @since 10 */ function getModeManager(context: Context): ModeManager; /** * Camera mode manager object. * * @interface ModeManager * @syscap SystemCapability.Multimedia.Camera.Core * @systemapi * @since 10 */ interface ModeManager { /** * Gets the modes supported by the specified camera. * * @param { CameraDevice } device - Camera device. * @returns { Array } List of modes supported by the camera device. * @syscap SystemCapability.Multimedia.Camera.Core * @systemapi * @since 10 */ getSupportedModes(device: CameraDevice): Array; /** * Gets the supported output capability for the specific camera and specific mode. * * @param { CameraDevice } device - Camera device. * @param { CameraMode } mode - Camera mode. * @returns { CameraOutputCapability } The camera output capability. * @syscap SystemCapability.Multimedia.Camera.Core * @systemapi * @since 10 */ getSupportedOutputCapability(device: CameraDevice, mode: CameraMode): CameraOutputCapability; /** * Gets a CaptureSession instance for the specific camera mode. * * @param { CameraMode } mode - Camera mode. * @returns { CaptureSession } The CaptureSession instance for specific camera mode. * @syscap SystemCapability.Multimedia.Camera.Core * @systemapi * @since 10 */ createCaptureSession(mode: CameraMode): CaptureSession; } /** * Enumerates the camera portrait effects. * * @enum { number } * @syscap SystemCapability.Multimedia.Camera.Core * @systemapi * @since 10 */ enum PortraitEffect { /** * portrait effect off. * * @syscap SystemCapability.Multimedia.Camera.Core * @systemapi * @since 10 */ OFF = 0, /** * circular blurring for portrait. * * @syscap SystemCapability.Multimedia.Camera.Core * @systemapi * @since 10 */ CIRCLES = 1 } /** * Portrait session object. * * @interface PortraitSession * @syscap SystemCapability.Multimedia.Camera.Core * @systemapi * @since 10 */ interface PortraitSession extends CaptureSession { /** * Gets supported portrait effect. * * @returns { Array } List of portrait effect. * @throws { BusinessError } 7400103 - Session not config. * @syscap SystemCapability.Multimedia.Camera.Core * @systemapi * @since 10 */ getSupportedPortraitEffects(): Array; /** * Gets the portrait effect in use. * * @returns { PortraitEffect } The portrait effect in use. * @throws { BusinessError } 7400103 - Session not config. * @syscap SystemCapability.Multimedia.Camera.Core * @systemapi * @since 10 */ getPortraitEffect(): PortraitEffect; /** * Sets a portrait effect for a camera device. * * @param { PortraitEffect } effect - Effect Portrait effect to set. * @throws { BusinessError } 7400103 - Session not config. * @syscap SystemCapability.Multimedia.Camera.Core * @systemapi * @since 10 */ setPortraitEffect(effect: PortraitEffect): void; } /** * Camera output object. * * @interface CameraOutput * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ interface CameraOutput { /** * Release output instance. * * @param { AsyncCallback } callback - Callback used to return the result. * @throws { BusinessError } 7400201 - Camera service fatal error. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ release(callback: AsyncCallback): void; /** * Release output instance. * * @returns { Promise } Promise used to return the result. * @throws { BusinessError } 7400201 - Camera service fatal error. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ release(): Promise; } /** * Preview output object. * * @interface PreviewOutput * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ interface PreviewOutput extends CameraOutput { /** * Start output instance. * * @param { AsyncCallback } callback - Callback used to return the result. * @throws { BusinessError } 7400103 - Session not config. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ start(callback: AsyncCallback): void; /** * Start output instance. * * @returns { Promise } Promise used to return the result. * @throws { BusinessError } 7400103 - Session not config. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ start(): Promise; /** * Stop output instance. * * @param { AsyncCallback } callback - Callback used to return the result. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ stop(callback: AsyncCallback): void; /** * Stop output instance. * * @returns { Promise } Promise used to return the result. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ stop(): Promise; /** * Subscribes frame start event callback. * * @param { 'frameStart' } type - Event type. * @param { AsyncCallback } callback - Callback used to return the result. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ on(type: 'frameStart', callback: AsyncCallback): void; /** * Unsubscribes from frame start event callback. * * @param { 'frameStart' } type - Event type. * @param { AsyncCallback } callback - Callback used to return the result. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ off(type: 'frameStart', callback?: AsyncCallback): void; /** * Subscribes frame end event callback. * * @param { 'frameEnd' } type - Event type. * @param { AsyncCallback } callback - Callback used to return the result. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ on(type: 'frameEnd', callback: AsyncCallback): void; /** * Unsubscribes from frame end event callback. * * @param { 'frameEnd' } type - Event type. * @param { AsyncCallback } callback - Callback used to return the result. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ off(type: 'frameEnd', callback?: AsyncCallback): void; /** * Subscribes to error events. * * @param { 'error' } type - Event type. * @param { ErrorCallback } callback - Callback used to get the preview output errors. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ on(type: 'error', callback: ErrorCallback): void; /** * Unsubscribes from error events. * * @param { 'error' } type - Event type. * @param { ErrorCallback } callback - Callback used to get the preview output errors. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ off(type: 'error', callback?: ErrorCallback): void; /** * Adds a deferred surface. * * @param { string } surfaceId - Surface object id used in camera photo output. * @throws { BusinessError } 7400101 - Parameter missing or parameter type incorrect. * @syscap SystemCapability.Multimedia.Camera.Core * @systemapi * @since 10 */ addDeferredSurface(surfaceId: string): void; } /** * Enumerates the image rotation angles. * * @enum { number } * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ enum ImageRotation { /** * The capture image rotates 0 degrees. * * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ ROTATION_0 = 0, /** * The capture image rotates 90 degrees. * * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ ROTATION_90 = 90, /** * The capture image rotates 180 degrees. * * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ ROTATION_180 = 180, /** * The capture image rotates 270 degrees. * * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ ROTATION_270 = 270 } /** * Photo capture location * * @typedef Location * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ interface Location { /** * Latitude. * * @type { number } * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ latitude: number; /** * Longitude. * * @type { number } * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ longitude: number; /** * Altitude. * * @type { number } * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ altitude: number; } /** * Enumerates the image quality levels. * * @enum { number } * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ enum QualityLevel { /** * High image quality. * * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ QUALITY_LEVEL_HIGH = 0, /** * Medium image quality. * * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ QUALITY_LEVEL_MEDIUM = 1, /** * Low image quality. * * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ QUALITY_LEVEL_LOW = 2 } /** * Photo capture options to set. * * @typedef PhotoCaptureSetting * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ interface PhotoCaptureSetting { /** * Photo image quality. * * @type { ?QualityLevel } * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ quality?: QualityLevel; /** * Photo rotation. * * @type { ?ImageRotation } * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ rotation?: ImageRotation; /** * Photo location. * * @type { ?Location } * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ location?: Location; /** * Set the mirror photo function switch, default to false. * * @type { ?boolean } * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ mirror?: boolean; } /** * Photo output object. * * @interface PhotoOutput * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ interface PhotoOutput extends CameraOutput { /** * Start capture output. * * @param { AsyncCallback } callback - Callback used to return the result. * @throws { BusinessError } 7400104 - Session not running. * @throws { BusinessError } 7400201 - Camera service fatal error. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ capture(callback: AsyncCallback): void; /** * Start capture output. * * @returns { Promise } Promise used to return the result. * @throws { BusinessError } 7400104 - Session not running. * @throws { BusinessError } 7400201 - Camera service fatal error. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ capture(): Promise; /** * Start capture output. * * @param { PhotoCaptureSetting } setting - Photo capture settings. * @param { AsyncCallback } callback - Callback used to return the result. * @throws { BusinessError } 7400101 - Parameter missing or parameter type incorrect. * @throws { BusinessError } 7400104 - Session not running. * @throws { BusinessError } 7400201 - Camera service fatal error. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ capture(setting: PhotoCaptureSetting, callback: AsyncCallback): void; /** * Start capture output. * * @param { PhotoCaptureSetting } setting - Photo capture settings. * @returns { Promise } Promise used to return the result. * @throws { BusinessError } 7400101 - Parameter missing or parameter type incorrect. * @throws { BusinessError } 7400104 - Session not running. * @throws { BusinessError } 7400201 - Camera service fatal error. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ capture(setting?: PhotoCaptureSetting): Promise; /** * Check whether to support mirror photo. * * @returns { boolean } Is the mirror supported. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ isMirrorSupported(): boolean; /** * Subscribes capture start event callback. * * @param { 'captureStart' } type - Event type. * @param { AsyncCallback } callback - Callback used to get the capture ID. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ on(type: 'captureStart', callback: AsyncCallback): void; /** * Unsubscribes from capture start event callback. * * @param { 'captureStart' } type - Event type. * @param { AsyncCallback } callback - Callback used to get the capture ID. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ off(type: 'captureStart', callback?: AsyncCallback): void; /** * Subscribes frame shutter event callback. * * @param { 'frameShutter' } type - Event type. * @param { AsyncCallback } callback - Callback used to get the frame shutter information. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ on(type: 'frameShutter', callback: AsyncCallback): void; /** * Unsubscribes from frame shutter event callback. * * @param { 'frameShutter' } type - Event type. * @param { AsyncCallback } callback - Callback used to get the frame shutter information. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ off(type: 'frameShutter', callback?: AsyncCallback): void; /** * Subscribes capture end event callback. * * @param { 'captureEnd' } type - Event type. * @param { AsyncCallback } callback - Callback used to get the capture end information. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ on(type: 'captureEnd', callback: AsyncCallback): void; /** * Unsubscribes from capture end event callback. * * @param { 'captureEnd' } type - Event type. * @param { AsyncCallback } callback - Callback used to get the capture end information. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ off(type: 'captureEnd', callback?: AsyncCallback): void; /** * Subscribes to error events. * * @param { 'error' } type - Event type. * @param { ErrorCallback } callback - Callback used to get the photo output errors. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ on(type: 'error', callback: ErrorCallback): void; /** * Unsubscribes from error events. * * @param { 'error' } type - Event type. * @param { ErrorCallback } callback - Callback used to get the photo output errors. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ off(type: 'error', callback?: ErrorCallback): void; /** * Checks whether PhotoOutput supports quick thumbnail. * This method is valid after CaptureSession.addInput() and CaptureSession.addOutput(photoOutput) are called. * * @returns { boolean } Whether quick thumbnail is supported. * @throws { BusinessError } 7400104 - session is not running. * @syscap SystemCapability.Multimedia.Camera.Core * @systemapi * @since 10 */ isQuickThumbnailSupported(): boolean; /** * Enables or disables quick thumbnail. * The method must be called after CaptureSession.addInput() and CaptureSession.addOutput(photoOutput) are called. * To avoid stream reconfiguration and performance loss, * you are advised to call the method before CaptureSession.commitConfig(). * * @param { boolean } enabled - The value TRUE means to enable quick thumbnail, and FALSE means the opposite. * @throws { BusinessError } 7400104 - session is not running. * @syscap SystemCapability.Multimedia.Camera.Core * @systemapi * @since 10 */ enableQuickThumbnail(enabled: boolean): void; /** * Subscribes to camera thumbnail events. * This method is valid only after enableQuickThumbnail(true) is called. * * @param { 'quickThumbnail' } type - Event type. * @param { AsyncCallback } callback - Callback used to get the quick thumbnail. * @syscap SystemCapability.Multimedia.Camera.Core * @systemapi * @since 10 */ on(type: 'quickThumbnail', callback: AsyncCallback): void; /** * Unsubscribes from camera thumbnail events. * This method is valid only after enableQuickThumbnail(true) is called. * * @param { 'quickThumbnail' } type - Event type. * @param { AsyncCallback } callback - Callback used to get the quick thumbnail. * @syscap SystemCapability.Multimedia.Camera.Core * @systemapi * @since 10 */ off(type: 'quickThumbnail', callback?: AsyncCallback): void; } /** * Frame shutter callback info. * * @typedef FrameShutterInfo * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ interface FrameShutterInfo { /** * Capture id. * * @type { number } * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ captureId: number; /** * Timestamp for frame. * * @type { number } * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ timestamp: number; } /** * Capture end info. * * @typedef CaptureEndInfo * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ interface CaptureEndInfo { /** * Capture id. * * @type { number } * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ captureId: number; /** * Frame count. * * @type { number } * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ frameCount: number; } /** * Video output object. * * @interface VideoOutput * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ interface VideoOutput extends CameraOutput { /** * Start video output. * * @param { AsyncCallback } callback - Callback used to return the result. * @throws { BusinessError } 7400103 - Session not config. * @throws { BusinessError } 7400201 - Camera service fatal error. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ start(callback: AsyncCallback): void; /** * Start video output. * * @returns { Promise } Promise used to return the result. * @throws { BusinessError } 7400103 - Session not config. * @throws { BusinessError } 7400201 - Camera service fatal error. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ start(): Promise; /** * Stop video output. * * @param { AsyncCallback } callback - Callback used to return the result. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ stop(callback: AsyncCallback): void; /** * Stop video output. * * @returns { Promise } Promise used to return the result. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ stop(): Promise; /** * Subscribes frame start event callback. * * @param { 'frameStart' } type - Event type. * @param { AsyncCallback } callback - Callback used to return the result. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ on(type: 'frameStart', callback: AsyncCallback): void; /** * Unsubscribes from frame start event callback. * * @param { 'frameStart' } type - Event type. * @param { AsyncCallback } callback - Callback used to return the result. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ off(type: 'frameStart', callback?: AsyncCallback): void; /** * Subscribes frame end event callback. * * @param { 'frameEnd' } type - Event type. * @param { AsyncCallback } callback - Callback used to return the result. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ on(type: 'frameEnd', callback: AsyncCallback): void; /** * Unsubscribes from frame end event callback. * * @param { 'frameEnd' } type - Event type. * @param { AsyncCallback } callback - Callback used to return the result. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ off(type: 'frameEnd', callback?: AsyncCallback): void; /** * Subscribes to error events. * * @param { 'error' } type - Event type. * @param { ErrorCallback } callback - Callback used to get the video output errors. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ on(type: 'error', callback: ErrorCallback): void; /** * Unsubscribes from error events. * * @param { 'error' } type - Event type. * @param { ErrorCallback } callback - Callback used to get the video output errors. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ off(type: 'error', callback?: ErrorCallback): void; } /** * Metadata object type. * * @enum { number } * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ enum MetadataObjectType { FACE_DETECTION = 0 } /** * Rectangle definition. * * @typedef Rect * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ interface Rect { /** * X coordinator of top left point. * * @type { number } * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ topLeftX: number; /** * Y coordinator of top left point. * * @type { number } * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ topLeftY: number; /** * Width of this rectangle. * * @type { number } * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ width: number; /** * Height of this rectangle. * * @type { number } * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ height: number; } /** * Metadata object basis. * * @typedef MetadataObject * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ interface MetadataObject { /** * Metadata object type. * * @type { MetadataObjectType } * @readonly * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ readonly type: MetadataObjectType; /** * Metadata object timestamp in milliseconds. * * @type { number } * @readonly * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ readonly timestamp: number; /** * The axis-aligned bounding box of detected metadata object. * * @type { Rect } * @readonly * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ readonly boundingBox: Rect; } /** * Metadata Output object * * @interface MetadataOutput * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ interface MetadataOutput extends CameraOutput { /** * Start output metadata * * @param { AsyncCallback } callback - Callback used to return the result. * @throws { BusinessError } 7400103 - Session not config. * @throws { BusinessError } 7400201 - Camera service fatal error. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ start(callback: AsyncCallback): void; /** * Start output metadata * * @returns { Promise } Promise used to return the result. * @throws { BusinessError } 7400103 - Session not config. * @throws { BusinessError } 7400201 - Camera service fatal error. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ start(): Promise; /** * Stop output metadata * * @param { AsyncCallback } callback - Callback used to return the result. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ stop(callback: AsyncCallback): void; /** * Stop output metadata * * @returns { Promise } Promise used to return the result. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ stop(): Promise; /** * Subscribes to metadata objects available event callback. * * @param { 'metadataObjectsAvailable' } type - Event type. * @param { AsyncCallback> } callback - Callback used to get the available metadata objects. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ on(type: 'metadataObjectsAvailable', callback: AsyncCallback>): void; /** * Unsubscribes from metadata objects available event callback. * * @param { 'metadataObjectsAvailable' } type - Event type. * @param { AsyncCallback> } callback - Callback used to get the available metadata objects. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ off(type: 'metadataObjectsAvailable', callback?: AsyncCallback>): void; /** * Subscribes to error events. * * @param { 'error' } type - Event type. * @param { ErrorCallback } callback - Callback used to get the video output errors. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ on(type: 'error', callback: ErrorCallback): void; /** * Unsubscribes from error events. * * @param { 'error' } type - Event type. * @param { ErrorCallback } callback - Callback used to get the video output errors. * @syscap SystemCapability.Multimedia.Camera.Core * @since 10 */ off(type: 'error', callback?: ErrorCallback): void; } } export default camera;