1# @ohos.multimedia.camera (Camera Management)
2
3The camera module provides a set of camera service APIs for you to easily develop a camera application. The application can access and operate the camera hardware to implement basic operations, such as preview, taking photos, and recording videos. It can also perform more operations, for example, controlling the flash and exposure time, and focusing or adjusting the focus.
4
5> **NOTE**
6>
7> The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version.
8
9## Modules to Import
10
11```ts
12import { camera } from '@kit.CameraKit';
13```
14
15## camera.getCameraManager
16
17getCameraManager(context: Context): CameraManager
18
19Obtains a **CameraManager** instance. This API returns the result synchronously.
20
21**System capability**: SystemCapability.Multimedia.Camera.Core
22
23**Parameters**
24
25| Name    | Type                                            | Mandatory| Description                          |
26| -------- | ----------------------------------------------- | ---- | ---------------------------- |
27| context  | [Context](../apis-ability-kit/js-apis-inner-application-baseContext.md)      | Yes  | Application context.                  |
28
29**Return value**
30
31| Type                                            | Description                          |
32| ----------------------------------------------- | ---------------------------- |
33| [CameraManager](#cameramanager)           | **CameraManager** instance obtained.                  |
34
35**Error codes**
36
37For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
38
39| ID        | Error Message       |
40| --------------- | --------------- |
41| 7400101                |  Parameter missing or parameter type incorrect.               |
42| 7400201                |  Camera service fatal error.                                  |
43
44**Example**
45
46```ts
47import { common } from '@kit.AbilityKit';
48import { BusinessError } from '@kit.BasicServicesKit';
49
50function getCameraManager(context: common.BaseContext): camera.CameraManager | undefined {
51  let cameraManager: camera.CameraManager | undefined = undefined;
52  try {
53    cameraManager = camera.getCameraManager(context);
54  } catch (error) {
55    let err = error as BusinessError;
56    console.error(`The getCameraManager call failed. error code: ${err.code}`);
57  }
58  return cameraManager;
59}
60```
61
62## CameraDevice
63
64Defines the camera device information.
65
66**System capability**: SystemCapability.Multimedia.Camera.Core
67
68| Name          | Type                              | Read-only| Optional| Description       |
69| -------------- | --------------------------------- | ---- | ---- |---------- |
70| cameraId       | string                            | Yes  | No  | Camera ID.|
71| cameraPosition | [CameraPosition](#cameraposition) | Yes  | No  | Camera position.   |
72| cameraType     | [CameraType](#cameratype)         | Yes  | No  | Camera type.   |
73| connectionType | [ConnectionType](#connectiontype) | Yes  | No  | Camera connection type.|
74| cameraOrientation<sup>12+</sup> | number | Yes  | No  | Installation angle of the lens, which does not change as the screen rotates. The value ranges from 0° to 360°.|
75
76## CameraPosition
77
78Enumerates the camera positions.
79
80**Atomic service API**: This API can be used in atomic services since API version 12.
81
82**System capability**: SystemCapability.Multimedia.Camera.Core
83
84| Name                        | Value  | Description                                                             |
85| --------------------------- | ---- |-----------------------------------------------------------------|
86| CAMERA_POSITION_UNSPECIFIED | 0    | Unspecified position.                                                       |
87| CAMERA_POSITION_BACK        | 1    | Rear camera.                                                          |
88| CAMERA_POSITION_FRONT       | 2    | Front camera.                                                          |
89| CAMERA_POSITION_FOLD_INNER<sup>(deprecated)</sup>  | 3    | Folded camera.<br>This API is supported since API version 11 and deprecated since API version 12.|
90
91## CameraType
92
93Enumerates the camera types.
94
95**System capability**: SystemCapability.Multimedia.Camera.Core
96
97| Name                    | Value  | Description           |
98| ----------------------- | ---- | -------------- |
99| CAMERA_TYPE_DEFAULT     | 0    | Unspecified camera type. |
100| CAMERA_TYPE_WIDE_ANGLE  | 1    | Wide camera.      |
101| CAMERA_TYPE_ULTRA_WIDE  | 2    | Ultra wide camera.    |
102| CAMERA_TYPE_TELEPHOTO   | 3    | Telephoto camera.      |
103| CAMERA_TYPE_TRUE_DEPTH  | 4    | Camera with depth of field information.|
104
105## ConnectionType
106
107Enumerates the camera connection types.
108
109**System capability**: SystemCapability.Multimedia.Camera.Core
110
111| Name                         | Value  | Description          |
112| ---------------------------- | ---- | ------------- |
113| CAMERA_CONNECTION_BUILT_IN   | 0    | Built-in camera.     |
114| CAMERA_CONNECTION_USB_PLUGIN | 1    | Camera connected using USB.|
115| CAMERA_CONNECTION_REMOTE     | 2    | Remote camera.|
116
117## CameraStatus
118
119Enumerates the camera statuses.
120
121**System capability**: SystemCapability.Multimedia.Camera.Core
122
123| Name                      | Value  | Description           |
124| ------------------------- | ---- | ------------    |
125| CAMERA_STATUS_APPEAR      | 0    | A camera appears.  |
126| CAMERA_STATUS_DISAPPEAR   | 1    | The camera disappears.    |
127| CAMERA_STATUS_AVAILABLE   | 2    | The camera is available.      |
128| CAMERA_STATUS_UNAVAILABLE | 3    | The camera is unavailable.    |
129
130## FoldStatus<sup>12+</sup>
131
132Enumerates the folding statuses available for a fordable device.
133
134**System capability**: SystemCapability.Multimedia.Camera.Core
135
136| Name                      | Value  | Description           |
137| ------------------------- | ---- | ------------    |
138| NON_FOLDABLE      | 0    | The device is not foldable.  |
139| EXPANDED   | 1    | The device is fully unfolded.|
140| FOLDED   | 2    | The device is folded.      |
141
142## CameraStatusInfo
143
144Defines the camera status information.
145
146**System capability**: SystemCapability.Multimedia.Camera.Core
147
148| Name  | Type                          |    Read-only  |     Optional    | Description      |
149| ------ | ----------------------------- | --------- |------------ | ---------- |
150| camera | [CameraDevice](#cameradevice) |     No   |       No    | Camera device.|
151| status | [CameraStatus](#camerastatus) |     No   |       No    | Camera status.|
152
153## FoldStatusInfo<sup>12+</sup>
154
155Describes the folding status information about a foldable device.
156
157**System capability**: SystemCapability.Multimedia.Camera.Core
158
159| Name  | Type                          |    Read-only  |     Optional    | Description      |
160| ------ | ----------------------------- | --------- |------------ | ---------- |
161| supportedCameras | [Array<CameraDevice\>](#cameradevice) |     No   |       No    | List of cameras supported in the current folding status.|
162| foldStatus | [FoldStatus](#foldstatus12) |     No   |       No    | Folding status.|
163
164## Profile
165
166Defines the camera profile.
167
168**System capability**: SystemCapability.Multimedia.Camera.Core
169
170| Name     | Type                         | Read-only| Optional| Description        |
171| -------- | ----------------------------- |---- | ---- | ------------- |
172| format   | [CameraFormat](#cameraformat) | Yes |  No | Output format.     |
173| size     | [Size](#size)                 | Yes |  No | Resolution.<br>The width and height of the camera resolution is set, not the actual width and height of an output image. |
174
175## FrameRateRange
176
177Defines the frame rate range.
178
179**System capability**: SystemCapability.Multimedia.Camera.Core
180
181| Name     | Type                         | Read-only| Optional| Description           |
182| -------- | ----------------------------- |----- |---| -------------- |
183| min      | number                        |  Yes | No| Minimum frame rate.     |
184| max      | number                        |  Yes | No| Maximum frame rate.     |
185
186## VideoProfile
187
188Defines the video configuration information. It inherits from [Profile](#profile).
189
190**System capability**: SystemCapability.Multimedia.Camera.Core
191
192| Name                      | Type                                     | Read-only| Optional| Description       |
193| ------------------------- | ----------------------------------------- | --- | ---- |----------- |
194| frameRateRange            | [FrameRateRange](#frameraterange)         | Yes |  No | Frame rate range, in units of frames per second (FPS).|
195
196## CameraOutputCapability
197
198Defines the camera output capability.
199
200**System capability**: SystemCapability.Multimedia.Camera.Core
201
202| Name                          | Type                                               | Read-only| Optional| Description               |
203| ----------------------------- | --------------------------------------------------- | ---- | ---- |-------------------|
204| previewProfiles               | Array\<[Profile](#profile)\>                        |  Yes | No| Supported preview profiles.     |
205| photoProfiles                 | Array\<[Profile](#profile)\>                        |  Yes | No| Supported photo profiles.       |
206| videoProfiles                 | Array\<[VideoProfile](#videoprofile)\>              |  Yes | No| Supported video profiles.       |
207| supportedMetadataObjectTypes  | Array\<[MetadataObjectType](#metadataobjecttype)\>  |  Yes | No| Supported metadata object types.|
208
209## SceneMode<sup>11+</sup>
210
211Enumerates the camera scene modes.
212
213**System capability**: SystemCapability.Multimedia.Camera.Core
214
215| Name                        | Value      | Description                                         |
216|----------------------------|---------|---------------------------------------------|
217| NORMAL_PHOTO               | 1       | Normal photo mode. For details, see [PhotoSession](#photosession11).  |
218| NORMAL_VIDEO               | 2       | Normal record mode. For details, see [VideoSession](#videosession11).  |
219| SECURE_PHOTO<sup>12+</sup> | 12      | Secure mode. For details, see [SecureSession](#securesession12).|
220
221## CameraErrorCode
222
223Enumerates the camera error codes,
224
225which are returned when an API call is incorrect or the **on()** API is used to listen for the error status.
226
227**System capability**: SystemCapability.Multimedia.Camera.Core
228
229| Name                      | Value         | Description           |
230| -------------------------  | ----       | ------------    |
231| INVALID_ARGUMENT           | 7400101    | A parameter is missing or the parameter type is incorrect.  |
232| OPERATION_NOT_ALLOWED      | 7400102    | The operation is not allowed.    |
233| SESSION_NOT_CONFIG         | 7400103    | The session is not configured.      |
234| SESSION_NOT_RUNNING        | 7400104    | The session is not running.   |
235| SESSION_CONFIG_LOCKED      | 7400105    | The session configuration is locked.    |
236| DEVICE_SETTING_LOCKED      | 7400106    | The device setting is locked.    |
237| CONFLICT_CAMERA            | 7400107    | The device is already started.    |
238| DEVICE_DISABLED            | 7400108    | The camera is disabled for security reasons.    |
239| DEVICE_PREEMPTED           | 7400109    | The camera is preempted.    |
240| UNRESOLVED_CONFLICTS_WITH_CURRENT_CONFIGURATIONS<sup>12+</sup> | 7400110   | The configuration conflicts with the current configuration.    |
241| SERVICE_FATAL_ERROR        | 7400201    | An error occurs in the camera service.    |
242
243## CameraManager
244
245Implements camera management. Before calling any API in **CameraManager**, you must use [getCameraManager](#cameragetcameramanager) to obtain a **CameraManager** instance.
246
247### getSupportedCameras
248
249getSupportedCameras(): Array\<CameraDevice\>
250
251Obtains the supported camera devices. This API returns the result synchronously.
252
253**System capability**: SystemCapability.Multimedia.Camera.Core
254
255**Return value**
256
257| Type                                            | Description                          |
258| ----------------------------------------------- | ---------------------------- |
259|  Array\<[CameraDevice](#cameradevice)>            | Array of camera devices supported.                  |
260
261**Example**
262
263```ts
264import { BusinessError } from '@kit.BasicServicesKit';
265
266function getSupportedCameras(cameraManager: camera.CameraManager): Array<camera.CameraDevice> {
267  let cameras: Array<camera.CameraDevice> = [];
268  try {
269    cameras = cameraManager.getSupportedCameras();
270  } catch (error) {
271    let err = error as BusinessError;
272    console.error(`The getSupportedCameras call failed. error code: ${err.code}`);
273  }
274  return cameras;
275}
276```
277
278### getSupportedSceneModes<sup>11+</sup>
279
280getSupportedSceneModes(camera: CameraDevice): Array\<SceneMode\>
281
282Obtains the scene modes supported by a camera device. This API returns the result synchronously.
283
284**System capability**: SystemCapability.Multimedia.Camera.Core
285
286**Parameters**
287
288| Name        | Type                                                           | Mandatory| Description                     |
289| ------------ |--------------------------------------------------------------- | -- | -------------------------- |
290| camera | [CameraDevice](#cameradevice)                              | Yes| **CameraDevice** instance, which is obtained through [getSupportedCameras](#getsupportedcameras). An error code is returned if the input parameter is invalid.      |
291
292**Return value**
293
294| Type                                            | Description                          |
295| ----------------------------------------------- | ---------------------------- |
296|  Array\<[SceneMode](#scenemode11)>            | Array of scene modes supported.                  |
297
298**Example**
299
300```ts
301import { BusinessError } from '@kit.BasicServicesKit';
302
303function getSupportedSceneModes(cameraManager: camera.CameraManager, camera: camera.CameraDevice): Array<camera.SceneMode> {
304  let modes: Array<camera.SceneMode> = [];
305  try {
306    modes = cameraManager.getSupportedSceneModes(camera);
307  } catch (error) {
308    let err = error as BusinessError;
309    console.error(`The getSupportedSceneModes call failed. error code: ${err.code}`);
310  }
311  return modes;
312}
313```
314
315### getSupportedOutputCapability<sup>(deprecated)</sup>
316
317getSupportedOutputCapability(camera: CameraDevice): CameraOutputCapability
318
319Obtains the output capability supported by a camera device. This API returns the result synchronously.
320
321> **NOTE**
322>
323> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [getSupportedOutputCapability](#getsupportedoutputcapability11) instead.
324
325**System capability**: SystemCapability.Multimedia.Camera.Core
326
327**Parameters**
328
329| Name        | Type                                                           | Mandatory| Description                     |
330| ------------ |--------------------------------------------------------------- | -- | -------------------------- |
331| camera | [CameraDevice](#cameradevice)                              | Yes| **CameraDevice** instance, which is obtained through [getSupportedCameras](#getsupportedcameras). An error code is returned if the input parameter is invalid.     |
332
333**Return value**
334
335| Type                                            | Description                          |
336| ----------------------------------------------- | ---------------------------- |
337| [CameraOutputCapability](#cameraoutputcapability)            | Camera output capability obtained.                  |
338
339**Example**
340
341```ts
342function getSupportedOutputCapability(camera: camera.CameraDevice, cameraManager: camera.CameraManager): camera.CameraOutputCapability {
343  let cameraOutputCapability: camera.CameraOutputCapability = cameraManager.getSupportedOutputCapability(camera);
344  return cameraOutputCapability;
345}
346```
347
348### getSupportedOutputCapability<sup>11+</sup>
349
350getSupportedOutputCapability(camera: CameraDevice, mode: SceneMode): CameraOutputCapability
351
352Obtains the output capability supported by a camera device in a given scene mode. This API returns the result synchronously.
353
354**System capability**: SystemCapability.Multimedia.Camera.Core
355
356**Parameters**
357
358| Name        | Type                                                           | Mandatory| Description                     |
359| ------------ |--------------------------------------------------------------- | -- | -------------------------- |
360| camera | [CameraDevice](#cameradevice)                              | Yes| **CameraDevice** instance, which is obtained through [getSupportedCameras](#getsupportedcameras).      |
361| mode | [SceneMode](#scenemode11)                              | Yes| Scene mode, which is obtained through [getSupportedSceneModes](#getsupportedscenemodes11).      |
362
363**Return value**
364
365| Type                                            | Description                          |
366| ----------------------------------------------- | ---------------------------- |
367| [CameraOutputCapability](#cameraoutputcapability)            | Camera output capability obtained.                  |
368
369**Example**
370
371```ts
372function getSupportedOutputCapability(camera: camera.CameraDevice, cameraManager: camera.CameraManager, sceneMode: camera.SceneMode): camera.CameraOutputCapability {
373  let cameraOutputCapability: camera.CameraOutputCapability = cameraManager.getSupportedOutputCapability(camera, sceneMode);
374  return cameraOutputCapability;
375}
376```
377
378### isCameraMuted
379
380isCameraMuted(): boolean
381
382Checks whether the camera device is muted.
383
384**System capability**: SystemCapability.Multimedia.Camera.Core
385
386**Return value**
387
388| Type       | Description                                        |
389| ---------- | -------------------------------------------- |
390| boolean    | **true**: The camera device is muted.<br>**false**: The camera device is not muted.|
391
392**Example**
393
394```ts
395function isCameraMuted(cameraManager: camera.CameraManager): boolean {
396  let isMuted: boolean = cameraManager.isCameraMuted();
397  return isMuted;
398}
399```
400
401### createCameraInput
402
403createCameraInput(camera: CameraDevice): CameraInput
404
405Creates a **CameraInput** instance with the specified **CameraDevice** instance. This API returns the result synchronously.
406
407**Required permissions**: ohos.permission.CAMERA
408
409**System capability**: SystemCapability.Multimedia.Camera.Core
410
411**Parameters**
412
413| Name    | Type                                        | Mandatory| Description                                              |
414| -------- | ------------------------------------------- | ---- |--------------------------------------------------|
415| camera  | [CameraDevice](#cameradevice)         | Yes  | **CameraDevice** instance, which is obtained through [getSupportedCameras](#getsupportedcameras).|
416
417**Return value**
418
419| Type       | Description                         |
420| ---------- | ----------------------------- |
421| [CameraInput](#camerainput)    | **CameraInput** instance created. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
422
423**Error codes**
424
425For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
426
427| ID        | Error Message       |
428| --------------- | --------------- |
429| 7400101                |  Parameter missing or parameter type incorrect.               |
430| 7400102                |  Operation not allowed.               |
431| 7400201                |  Camera service fatal error.               |
432
433**Example**
434
435```ts
436import { BusinessError } from '@kit.BasicServicesKit';
437
438function createCameraInput(camera: camera.CameraDevice, cameraManager: camera.CameraManager): camera.CameraInput | undefined {
439  let cameraInput: camera.CameraInput | undefined = undefined;
440  try {
441    cameraInput = cameraManager.createCameraInput(camera);
442  } catch (error) {
443    // If the operation fails, error.code is returned and processed.
444    let err = error as BusinessError;
445    console.error(`The createCameraInput call failed. error code: ${err.code}`);
446  }
447  return cameraInput;
448}
449```
450
451### createCameraInput
452
453createCameraInput(position: CameraPosition, type: CameraType): CameraInput
454
455Creates a **CameraInput** instance with the specified camera position and type. This API returns the result synchronously.
456
457**Required permissions**: ohos.permission.CAMERA
458
459**System capability**: SystemCapability.Multimedia.Camera.Core
460
461**Parameters**
462
463| Name    | Type                                       | Mandatory| Description                               |
464| -------- | ------------------------------------------- | ---- | --------------------------------- |
465| position | [CameraPosition](#cameraposition)           | Yes  | Camera position. You can call [getSupportedCameras](#getsupportedcameras) to obtain a **CameraDevice** instance, which contains the camera position information. |
466| type     | [CameraType](#cameratype)                   | Yes  | Camera type. You can call [getSupportedCameras](#getsupportedcameras) to obtain a **CameraDevice** instance, which contains the camera type information.|
467
468**Return value**
469
470| Type       | Description                         |
471| ---------- | ----------------------------- |
472| [CameraInput](#camerainput)    | **CameraInput** instance created. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
473
474**Error codes**
475
476For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
477
478| ID        | Error Message       |
479| --------------- | --------------- |
480| 7400101                |  Parameter missing or parameter type incorrect.               |
481| 7400102                |  Operation not allowed.               |
482| 7400201                |  Camera service fatal error.               |
483
484**Example**
485
486```ts
487import { BusinessError } from '@kit.BasicServicesKit';
488
489function createCameraInput(camera: camera.CameraDevice, cameraManager: camera.CameraManager): camera.CameraInput | undefined {
490  let position: camera.CameraPosition = camera.cameraPosition;
491  let type: camera.CameraType = camera.cameraType;
492  let cameraInput: camera.CameraInput | undefined = undefined;
493  try {
494    cameraInput = cameraManager.createCameraInput(position, type);
495  } catch (error) {
496    // If the operation fails, error.code is returned and processed.
497    let err = error as BusinessError;
498    console.error(`The createCameraInput call failed. error code: ${err.code}`);
499  }
500  return cameraInput;
501}
502```
503
504### createPreviewOutput
505
506createPreviewOutput(profile: Profile, surfaceId: string): PreviewOutput
507
508Creates a **PreviewOutput** instance. This API returns the result synchronously.
509
510**System capability**: SystemCapability.Multimedia.Camera.Core
511
512**Parameters**
513
514| Name    | Type                                            | Mandatory| Description                             |
515| -------- | ----------------------------------------------- | ---- | ------------------------------- |
516| profile  | [Profile](#profile)                             | Yes  | Supported preview profile, which is obtained through [getSupportedOutputCapability](#getsupportedoutputcapability11).|
517| surfaceId| string | Yes  | Surface ID, which is obtained from [XComponent](../apis-arkui/arkui-ts/ts-basic-components-xcomponent.md) or [ImageReceiver](../apis-image-kit/js-apis-image.md#imagereceiver9).|
518
519**Return value**
520
521| Type       | Description                         |
522| ---------- | ----------------------------- |
523| [PreviewOutput](#previewoutput)    | **PreviewOutput** instance created. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
524
525**Error codes**
526
527For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
528
529| ID        | Error Message       |
530| --------------- | --------------- |
531| 7400101                |  Parameter missing or parameter type incorrect.               |
532| 7400201                |  Camera service fatal error.               |
533
534**Example**
535
536```ts
537import { BusinessError } from '@kit.BasicServicesKit';
538
539function createPreviewOutput(cameraOutputCapability: camera.CameraOutputCapability, cameraManager: camera.CameraManager, surfaceId: string): camera.PreviewOutput | undefined {
540  let profile: camera.Profile = cameraOutputCapability.previewProfiles[0];
541  let previewOutput: camera.PreviewOutput | undefined = undefined;
542  try {
543    previewOutput = cameraManager.createPreviewOutput(profile, surfaceId);
544  } catch (error) {
545    // If the operation fails, error.code is returned and processed.
546    let err = error as BusinessError;
547    console.error(`The createPreviewOutput call failed. error code: ${err.code}`);
548  }
549  return previewOutput;
550}
551```
552
553### createPreviewOutput<sup>12+</sup>
554
555createPreviewOutput(surfaceId: string): PreviewOutput
556
557Creates a **PreviewOutput** instance without configuration. This API returns the result synchronously. It must be used together with [preconfig](#preconfig12).
558
559**System capability**: SystemCapability.Multimedia.Camera.Core
560
561**Parameters**
562
563| Name    | Type                                            | Mandatory| Description                             |
564| -------- | ----------------------------------------------- | ---- | ------------------------------- |
565| surfaceId| string | Yes  | Surface ID, which is obtained from [XComponent](../apis-arkui/arkui-ts/ts-basic-components-xcomponent.md) or [ImageReceiver](../apis-image-kit/js-apis-image.md#imagereceiver9).|
566
567**Return value**
568
569| Type       | Description                         |
570| ---------- | ----------------------------- |
571| [PreviewOutput](#previewoutput)    | **PreviewOutput** instance created. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
572
573**Error codes**
574
575For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
576
577| ID  | Error Message                                          |
578|---------|------------------------------------------------|
579| 7400101 | Parameter missing or parameter type incorrect. |
580| 7400201 | Camera service fatal error.                    |
581
582**Example**
583
584```ts
585import { BusinessError } from '@kit.BasicServicesKit';
586
587function createPreviewOutput(cameraManager: camera.CameraManager, surfaceId: string): camera.PreviewOutput | undefined {
588  let previewOutput: camera.PreviewOutput | undefined = undefined;
589  try {
590    previewOutput = cameraManager.createPreviewOutput(surfaceId);
591  } catch (error) {
592    // If the operation fails, error.code is returned and processed.
593    let err = error as BusinessError;
594    console.error(`The createPreviewOutput call failed. error code: ${err.code}`);
595  }
596  return previewOutput;
597}
598```
599
600### createPhotoOutput<sup>(deprecated)</sup>
601
602createPhotoOutput(profile: Profile, surfaceId: string): PhotoOutput
603
604Creates a **PhotoOutput** instance. This API returns the result synchronously.
605
606> **NOTE**
607>
608> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [createPhotoOutput](#createphotooutput11) instead.
609
610**System capability**: SystemCapability.Multimedia.Camera.Core
611
612**Parameters**
613
614| Name    | Type                                        | Mandatory| Description                                 |
615| -------- | ------------------------------------------- | ---- | ----------------------------------- |
616| profile  | [Profile](#profile)                         | Yes  | Supported photo profile, which is obtained through [getSupportedOutputCapability](#getsupportedoutputcapability11).|
617| surfaceId| string            | Yes  | Surface ID, which is obtained from [ImageReceiver](../apis-image-kit/js-apis-image.md#imagereceiver9).|
618
619**Return value**
620
621| Type       | Description                         |
622| ---------- | ----------------------------- |
623| [PhotoOutput](#photooutput)   | **PhotoOutput** instance created. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
624
625**Error codes**
626
627For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
628
629| ID        | Error Message       |
630| --------------- | --------------- |
631| 7400101                |  Parameter missing or parameter type incorrect.               |
632
633```ts
634import { BusinessError } from '@kit.BasicServicesKit';
635
636function createPhotoOutput(cameraOutputCapability: camera.CameraOutputCapability, cameraManager: camera.CameraManager, surfaceId: string): camera.PhotoOutput | undefined {
637  let profile: camera.Profile = cameraOutputCapability.photoProfiles[0];
638  let photoOutput: camera.PhotoOutput | undefined = undefined;
639  try {
640    photoOutput = cameraManager.createPhotoOutput(profile, surfaceId);
641  } catch (error) {
642    // If the operation fails, error.code is returned and processed.
643    let err = error as BusinessError;
644    console.error(`The createPhotoOutput call failed. error code: ${err.code}`);
645  }
646  return photoOutput;
647}
648```
649
650### createPhotoOutput<sup>11+</sup>
651
652createPhotoOutput(profile?: Profile): PhotoOutput
653
654Creates a **PhotoOutput** instance. This API returns the result synchronously.
655
656**System capability**: SystemCapability.Multimedia.Camera.Core
657
658**Parameters**
659
660| Name    | Type                                        | Mandatory| Description                                 |
661| -------- | ------------------------------------------- |----| ----------------------------------- |
662| profile  | [Profile](#profile)                         | No | Supported photo profile, which is obtained through [getSupportedOutputCapability](#getsupportedoutputcapability11).<br>In API version 11, this parameter is mandatory. Since API version 12, it will overwrite the preconfigured parameters passed in through **preconfig**.|
663
664**Return value**
665
666| Type       | Description                         |
667| ---------- | ----------------------------- |
668| [PhotoOutput](#photooutput)   | **PhotoOutput** instance created. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
669
670**Error codes**
671
672For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
673
674| ID   | Error Message                                          |
675|----------|------------------------------------------------|
676| 7400101  | Parameter missing or parameter type incorrect. |
677| 7400201  | Camera service fatal error.                    |
678
679**Example**
680
681```ts
682import { BusinessError } from '@kit.BasicServicesKit';
683
684function createPhotoOutput(cameraOutputCapability: camera.CameraOutputCapability, cameraManager: camera.CameraManager): camera.PhotoOutput | undefined {
685  let profile: camera.Profile = cameraOutputCapability.photoProfiles[0];
686  let photoOutput: camera.PhotoOutput | undefined = undefined;
687  try {
688    photoOutput = cameraManager.createPhotoOutput(profile);
689  } catch (error) {
690    // If the operation fails, error.code is returned and processed.
691    let err = error as BusinessError;
692    console.error(`The createPhotoOutput call failed. error code: ${err.code}`);
693  }
694  return photoOutput;
695}
696```
697
698### createVideoOutput
699
700createVideoOutput(profile: VideoProfile, surfaceId: string): VideoOutput
701
702Creates a **VideoOutput** instance. This API returns the result synchronously.
703
704**System capability**: SystemCapability.Multimedia.Camera.Core
705
706**Parameters**
707
708| Name    | Type                                       | Mandatory| Description                             |
709| -------- | ------------------------------------------- | ---- | ------------------------------ |
710| profile  | [VideoProfile](#videoprofile)               | Yes  | Supported video profile, which is obtained through [getSupportedOutputCapability](#getsupportedoutputcapability11).|
711| surfaceId| string          | Yes  | Surface ID, which is obtained from [AVRecorder](../apis-media-kit/js-apis-media.md#avrecorder9).|
712
713**Return value**
714
715| Type       | Description                         |
716| ---------- | ----------------------------- |
717| [VideoOutput](#videooutput)   | **VideoOutput** instance created. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
718
719**Error codes**
720
721For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
722
723| ID        | Error Message       |
724| --------------- | --------------- |
725| 7400101                |  Parameter missing or parameter type incorrect.               |
726| 7400201                |  Camera service fatal error.               |
727
728**Example**
729
730```ts
731import { BusinessError } from '@kit.BasicServicesKit';
732
733function createVideoOutput(cameraOutputCapability: camera.CameraOutputCapability, cameraManager: camera.CameraManager, surfaceId: string): camera.VideoOutput | undefined {
734  let profile: camera.VideoProfile = cameraOutputCapability.videoProfiles[0];
735  let videoOutput: camera.VideoOutput | undefined = undefined;
736  try {
737    videoOutput = cameraManager.createVideoOutput(profile, surfaceId);
738  } catch (error) {
739    // If the operation fails, error.code is returned and processed.
740    let err = error as BusinessError;
741    console.error(`The createVideoOutput call failed. error code: ${err.code}`);
742  }
743  return videoOutput;
744}
745```
746
747### createVideoOutput<sup>12+</sup>
748
749createVideoOutput(surfaceId: string): VideoOutput
750
751Creates a **VideoOutput** instance without configuration. This API returns the result synchronously. It must be used together with [preconfig](#preconfig12-1).
752
753**System capability**: SystemCapability.Multimedia.Camera.Core
754
755**Parameters**
756
757| Name      | Type    | Mandatory   | Description                                                                        |
758|-----------|--------|-------|----------------------------------------------------------------------------|
759| surfaceId | string | Yes    | Surface ID, which is obtained from [AVRecorder](../apis-media-kit/js-apis-media.md#avrecorder9).|
760
761**Return value**
762
763| Type       | Description                         |
764| ---------- | ----------------------------- |
765| [VideoOutput](#videooutput)   | **VideoOutput** instance created. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
766
767**Error codes**
768
769For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
770
771| ID   | Error Message                                          |
772|----------|------------------------------------------------|
773| 7400101  | Parameter missing or parameter type incorrect. |
774| 7400201  | Camera service fatal error.                    |
775
776**Example**
777
778```ts
779import { BusinessError } from '@kit.BasicServicesKit';
780
781function createVideoOutput(cameraManager: camera.CameraManager, surfaceId: string): camera.VideoOutput | undefined {
782  let videoOutput: camera.VideoOutput | undefined = undefined;
783  try {
784    videoOutput = cameraManager.createVideoOutput(surfaceId);
785  } catch (error) {
786    // If the operation fails, error.code is returned and processed.
787    let err = error as BusinessError;
788    console.error(`The createVideoOutput call failed. error code: ${err.code}`);
789  }
790  return videoOutput;
791}
792```
793
794### createMetadataOutput
795
796createMetadataOutput(metadataObjectTypes: Array\<MetadataObjectType\>): MetadataOutput
797
798Creates a **MetadataOutput** instance. This API returns the result synchronously.
799
800**System capability**: SystemCapability.Multimedia.Camera.Core
801
802**Parameters**
803
804| Name                 | Type                                              | Mandatory| Description                         |
805| -------------------- | -------------------------------------------------- | --- | ---------------------------- |
806| metadataObjectTypes  | Array\<[MetadataObjectType](#metadataobjecttype)\>  | Yes | Metadata object types, which are obtained through [getSupportedOutputCapability](#getsupportedoutputcapability11).|
807
808**Return value**
809
810| Type       | Description                         |
811| ---------- | ----------------------------- |
812| [MetadataOutput](#metadataoutput)   | **MetadataOutput** instance created. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
813
814**Error codes**
815
816For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
817
818| ID        | Error Message       |
819| --------------- | --------------- |
820| 7400101                |  Parameter missing or parameter type incorrect.               |
821| 7400201                |  Camera service fatal error.               |
822
823**Example**
824
825```ts
826import { BusinessError } from '@kit.BasicServicesKit';
827
828function createMetadataOutput(cameraManager: camera.CameraManager, cameraOutputCapability: camera.CameraOutputCapability): void {
829  let metadataObjectTypes: Array<camera.MetadataObjectType> = cameraOutputCapability.supportedMetadataObjectTypes;
830  let metadataOutput: camera.MetadataOutput | undefined = undefined;
831  try {
832    metadataOutput = cameraManager.createMetadataOutput(metadataObjectTypes);
833  } catch (error) {
834    // If the operation fails, error.code is returned and processed.
835    let err = error as BusinessError;
836    console.error(`createMetadataOutput error. error code: ${err.code}`);
837  }
838}
839```
840
841### createCaptureSession<sup>(deprecated)</sup>
842
843createCaptureSession(): CaptureSession
844
845Creates a **CaptureSession** instance. This API returns the result synchronously.
846
847> **NOTE**
848>
849> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [createSession](#createsession11) instead.
850
851**System capability**: SystemCapability.Multimedia.Camera.Core
852
853**Return value**
854
855| Type       | Description                         |
856| ---------- | ----------------------------- |
857| [CaptureSession](#capturesessiondeprecated)   | **CaptureSession** instance created. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
858
859**Error codes**
860
861For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
862
863| ID        | Error Message       |
864| --------------- | --------------- |
865| 7400201                |  Camera service fatal error.               |
866
867**Example**
868
869```ts
870import { BusinessError } from '@kit.BasicServicesKit';
871
872function createCaptureSession(cameraManager: camera.CameraManager): camera.CaptureSession | undefined {
873  let captureSession: camera.CaptureSession | undefined = undefined;
874  try {
875    captureSession = cameraManager.createCaptureSession();
876  } catch (error) {
877    // If the operation fails, error.code is returned and processed.
878    let err = error as BusinessError;
879    console.error(`createCaptureSession error. error code: ${err.code}`);
880  }
881  return captureSession;
882}
883```
884
885### createSession<sup>11+</sup>
886
887createSession\<T extends Session\>(mode: SceneMode): T
888
889Creates a **Session** instance with a given scene mode. This API returns the result synchronously.
890
891**System capability**: SystemCapability.Multimedia.Camera.Core
892
893**Parameters**
894
895| Name  | Type             | Mandatory| Description      |
896| -------- | -----------------| ---- | --------- |
897| mode     | [SceneMode](#scenemode11)     | Yes  | Scene mode. The API does not take effect if the input parameter is invalid (for example, the value is out of range, null, or undefined).|
898
899**Return value**
900
901| Type       | Description                         |
902| ---------- | ----------------------------- |
903| [T extends Session](#session11)   | **Session** instance created. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
904
905**Error codes**
906
907For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
908
909| ID        | Error Message                                                                                                                                          |
910| --------------- |------------------------------------------------------------------------------------------------------------------------------------------------|
911| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3.Parameter verification failed. |
912| 7400201                | Camera service fatal error.                                                                                                                    |
913
914**Example**
915
916```ts
917import { BusinessError } from '@kit.BasicServicesKit';
918
919function createSession(cameraManager: camera.CameraManager, mode: camera.SceneMode): camera.Session | undefined {
920  let photoSession: camera.PhotoSession | undefined = undefined;
921  try {
922    photoSession = cameraManager.createSession(mode) as camera.PhotoSession;
923  } catch (error) {
924    // If the operation fails, error.code is returned and processed.
925    let err = error as BusinessError;
926    console.error(`createCaptureSession error. error code: ${err.code}`);
927  }
928  return photoSession;
929}
930```
931
932### on('cameraStatus')
933
934on(type: 'cameraStatus', callback: AsyncCallback\<CameraStatusInfo\>): void
935
936Subscribes to camera status events. This API uses an asynchronous callback to return the result.
937
938> **NOTE**
939>
940> Currently, you cannot use **off()** to unregister the callback in the callback method of **on()**.
941
942**System capability**: SystemCapability.Multimedia.Camera.Core
943
944**Parameters**
945
946| Name    | Type           | Mandatory| Description      |
947| -------- | -----------------| ---- | --------- |
948| type     | string           | Yes  | Event type. The value is fixed at **'cameraStatus'**. The event can be listened for when a **CameraManager** instance is obtained. This event is triggered and the corresponding information is returned only when the camera device is enabled or disabled.|
949| callback | AsyncCallback\<[CameraStatusInfo](#camerastatusinfo)\> | Yes  | Callback used to return the camera status change.|                 |
950
951**Example**
952
953```ts
954import { BusinessError } from '@kit.BasicServicesKit';
955
956function callback(err: BusinessError, cameraStatusInfo: camera.CameraStatusInfo): void {
957  if (err !== undefined && err.code !== 0) {
958    console.error('cameraStatus with errorCode = ' + err.code);
959    return;
960  }
961  console.info(`camera : ${cameraStatusInfo.camera.cameraId}`);
962  console.info(`status: ${cameraStatusInfo.status}`);
963}
964
965function registerCameraStatus(cameraManager: camera.CameraManager): void {
966  cameraManager.on('cameraStatus', callback);
967}
968```
969
970### off('cameraStatus')
971
972off(type: 'cameraStatus', callback?: AsyncCallback\<CameraStatusInfo\>): void
973
974Unsubscribes from camera status events. This API uses an asynchronous callback to return the result.
975
976**System capability**: SystemCapability.Multimedia.Camera.Core
977
978**Parameters**
979
980| Name    | Type           | Mandatory| Description      |
981| -------- | -----------------| ---- | --------- |
982| type     | string           | Yes  | Event type. The value is fixed at **'cameraStatus'**. The event can be listened for when a **CameraManager** instance is obtained.|
983| callback | AsyncCallback\<[CameraStatusInfo](#camerastatusinfo)\> | No  | Callback used to return the result. If this parameter is specified, the subscription to the specified event with the specified callback is canceled. (The callback object cannot be an anonymous function.) Otherwise, the subscriptions to the specified event with all the callbacks are canceled.|
984
985**Example**
986
987```ts
988function unregisterCameraStatus(cameraManager: camera.CameraManager): void {
989  cameraManager.off('cameraStatus');
990}
991```
992
993### on('foldStatusChange')<sup>12+</sup>
994
995on(type: 'foldStatusChange', callback: AsyncCallback\<FoldStatusInfo\>): void
996
997Subscribes to folding status change events of the foldable device. This API uses an asynchronous callback to return the result.
998
999> **NOTE**
1000>
1001> Currently, you cannot use **off()** to unregister the callback in the callback method of **on()**.
1002
1003**System capability**: SystemCapability.Multimedia.Camera.Core
1004
1005**Parameters**
1006
1007| Name    | Type           | Mandatory| Description      |
1008| -------- | -----------------| ---- | --------- |
1009| type     | string           | Yes  | Event type. The value is fixed at **'foldStatusChange'**. The event is triggered when the folding status of the foldable device changes.|
1010| callback | AsyncCallback\<[FoldStatusInfo](#foldstatusinfo12)\> | Yes  | Callback used to return the folding status information about the foldable device.|
1011
1012**Example**
1013
1014```ts
1015import { BusinessError } from '@kit.BasicServicesKit';
1016
1017function callback(err: BusinessError, foldStatusInfo: camera.FoldStatusInfo): void {
1018  if (err !== undefined && err.code !== 0) {
1019    console.error('foldStatusChange with errorCode = ' + err.code);
1020    return;
1021  }
1022  console.info(`camera length: ${foldStatusInfo.supportedCameras.length}`);
1023  console.info(`foldStatus: ${foldStatusInfo.foldStatus}`);
1024}
1025
1026function registerFoldStatusChange(cameraManager: camera.CameraManager): void {
1027  cameraManager.on('foldStatusChange', callback);
1028}
1029```
1030
1031### off('foldStatusChange')<sup>12+</sup>
1032
1033off(type: 'foldStatusChange', callback?: AsyncCallback\<FoldStatusInfo\>): void
1034
1035Unsubscribes from folding status change events of the foldable device.
1036
1037**System capability**: SystemCapability.Multimedia.Camera.Core
1038
1039**Parameters**
1040
1041| Name    | Type           | Mandatory| Description      |
1042| -------- | -----------------| ---- | --------- |
1043| type     | string           | Yes  | Event type. The value is fixed at **'foldStatusChange'**. The event is triggered when the folding status of the foldable device changes.|
1044| callback | AsyncCallback\<[FoldStatusInfo](#foldstatusinfo12)\> | No  | Callback used to return the folding status information about the foldable device. If this parameter is specified, the subscription to the specified event with the specified callback is canceled. (The callback object cannot be an anonymous function.) Otherwise, the subscriptions to the specified event with all the callbacks are canceled.|
1045
1046**Example**
1047
1048```ts
1049function unregisterFoldStatusChange(cameraManager: camera.CameraManager): void {
1050  cameraManager.off('foldStatusChange');
1051}
1052```
1053
1054### isTorchSupported<sup>11+</sup>
1055
1056isTorchSupported(): boolean
1057
1058Checks whether the camera device supports the flashlight.
1059
1060**System capability**: SystemCapability.Multimedia.Camera.Core
1061
1062**Return value**
1063
1064| Type       | Description                         |
1065| ---------- | ----------------------------- |
1066| boolean    | **true**: The camera device supports the flashlight.<br>**false**: The camera device does not support the flashlight.|
1067
1068**Example**
1069
1070```ts
1071function isTorchSupported(cameraManager: camera.CameraManager): boolean {
1072  let isSupported = cameraManager.isTorchSupported();
1073  return isSupported;
1074}
1075```
1076
1077### isTorchModeSupported<sup>11+</sup>
1078
1079isTorchModeSupported(mode: TorchMode): boolean
1080
1081Checks whether a flashlight mode is supported.
1082
1083**System capability**: SystemCapability.Multimedia.Camera.Core
1084
1085**Parameters**
1086
1087| Name    | Type            | Mandatory| Description      |
1088| -------- | --------------- | ---- | --------- |
1089| mode | [TorchMode](#torchmode11) | Yes| Flashlight mode. If the input parameter is null or undefined, it is treated as 0 and the flashlight is turned off.|
1090
1091**Return value**
1092
1093| Type       | Description                         |
1094| ---------- | ----------------------------- |
1095| boolean    | **true**: The flashlight mode is supported.<br>**false**: The flashlight mode is not supported.|
1096
1097**Example**
1098
1099```ts
1100function isTorchModeSupported(cameraManager: camera.CameraManager, torchMode: camera.TorchMode): boolean {
1101  let isSupported = cameraManager.isTorchModeSupported(torchMode);
1102  return isSupported;
1103}
1104```
1105
1106### getTorchMode<sup>11+</sup>
1107
1108getTorchMode(): TorchMode
1109
1110Obtains the flashlight mode of this camera device.
1111
1112**System capability**: SystemCapability.Multimedia.Camera.Core
1113
1114**Return value**
1115
1116| Type       | Description                         |
1117| ---------- | ----------------------------- |
1118| [TorchMode](#torchmode11)    | Flashlight mode.|
1119
1120**Example**
1121
1122```ts
1123function getTorchMode(cameraManager: camera.CameraManager): camera.TorchMode | undefined {
1124  let torchMode: camera.TorchMode | undefined = undefined;
1125  torchMode = cameraManager.getTorchMode();
1126  return torchMode;
1127}
1128```
1129
1130### setTorchMode<sup>11+</sup>
1131
1132setTorchMode(mode: TorchMode): void
1133
1134Sets the flashlight mode.
1135
1136**System capability**: SystemCapability.Multimedia.Camera.Core
1137
1138**Parameters**
1139
1140| Name    | Type            | Mandatory| Description      |
1141| -------- | --------------- | ---- | --------- |
1142| mode | [TorchMode](#torchmode11) | Yes| Flashlight mode. If the input parameter is null or undefined, it is treated as 0 and the flashlight is turned off.|
1143
1144**Error codes**
1145
1146For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
1147
1148| ID        | Error Message       |
1149| --------------- | --------------- |
1150| 7400101 | Parameter missing or parameter type incorrect. |
1151| 7400102 | Operation not allowed. |
1152| 7400201 | Camera service fatal error. |
1153
1154**Example**
1155
1156```ts
1157import { BusinessError } from '@kit.BasicServicesKit';
1158
1159function setTorchMode(cameraManager: camera.CameraManager, torchMode: camera.TorchMode): void {
1160  try {
1161    cameraManager.setTorchMode(torchMode);
1162  } catch (error) {
1163    // If the operation fails, error.code is returned and processed.
1164    let err = error as BusinessError;
1165    console.error(`The setTorchMode call failed. error code: ${err.code}`);
1166  }
1167}
1168```
1169
1170### on('torchStatusChange')<sup>11+</sup>
1171
1172on(type: 'torchStatusChange', callback: AsyncCallback\<TorchStatusInfo\>): void
1173
1174Subscribes to flashlight status change events. This API uses an asynchronous callback to return the result.
1175
1176> **NOTE**
1177>
1178> Currently, you cannot use **off()** to unregister the callback in the callback method of **on()**.
1179
1180**System capability**: SystemCapability.Multimedia.Camera.Core
1181
1182**Parameters**
1183
1184| Name    | Type            | Mandatory| Description      |
1185| -------- | --------------- | ---- | --------- |
1186| type     | string          | Yes  | Event type. The value is fixed at **'torchStatusChange'**. The event can be listened for when a **CameraManager** instance is obtained. Currently, this event is triggered only in the following scenarios: The flashlight is turned on or turned off, or becomes unavailable or available.|
1187| callback | AsyncCallback\<TorchStatusInfo> | Yes  | Callback used to return the flashlight status.              |
1188
1189**Example**
1190
1191```ts
1192import { BusinessError } from '@kit.BasicServicesKit';
1193
1194function callback(err: BusinessError, torchStatusInfo: camera.TorchStatusInfo): void {
1195  if (err !== undefined && err.code !== 0) {
1196    console.error(`Callback Error, errorCode: ${err.code}`);
1197    return;
1198  }
1199  console.info(`onTorchStatusChange, isTorchAvailable: ${torchStatusInfo.isTorchAvailable}, isTorchActive: ${torchStatusInfo.isTorchActive}, level: ${torchStatusInfo.torchLevel}`);
1200}
1201
1202function registerTorchStatusChange(cameraManager: camera.CameraManager): void {
1203  cameraManager.on('torchStatusChange', callback);
1204}
1205```
1206
1207### off('torchStatusChange')<sup>11+</sup>
1208
1209off(type: 'torchStatusChange', callback?: AsyncCallback\<TorchStatusInfo\>): void
1210
1211Unsubscribes from flashlight status change events. This API uses an asynchronous callback to return the result.
1212
1213**System capability**: SystemCapability.Multimedia.Camera.Core
1214
1215**Parameters**
1216
1217| Name    | Type            | Mandatory| Description      |
1218| -------- | --------------- | ---- | --------- |
1219| type     | string          | Yes  | Event type. The value is fixed at **'torchStatusChange'**. The event can be listened for when a **CameraManager** instance is obtained.|
1220| callback | AsyncCallback\<TorchStatusInfo> | No  | Callback used to return the result. If this parameter is specified, the subscription to the specified event with the specified callback is canceled. (The callback object cannot be an anonymous function.) Otherwise, the subscriptions to the specified event with all the callbacks are canceled.|
1221
1222**Example**
1223
1224```ts
1225function unregisterTorchStatusChange(cameraManager: camera.CameraManager): void {
1226  cameraManager.off('torchStatusChange');
1227}
1228```
1229
1230## TorchMode<sup>11+</sup>
1231
1232Enumerates the flashlight modes.
1233
1234**System capability**: SystemCapability.Multimedia.Camera.Core
1235
1236| Name                         | Value  | Description          |
1237| ---------------------------- | ---- | ------------- |
1238| OFF    | 0    | The flashlight is off.     |
1239| ON  | 1    | The flashlight is on.|
1240| AUTO      | 2    | The flashlight mode is auto.|
1241
1242## TorchStatusInfo<sup>11+</sup>
1243
1244Defines the flashlight status information.
1245
1246**System capability**: SystemCapability.Multimedia.Camera.Core
1247
1248| Name             | Type      | Read-only| Optional| Description       |
1249| ---------------- | ---------- | ---- | ---- | ----------- |
1250| isTorchAvailable | boolean    | Yes  | No  | Whether the flashlight is available.|
1251| isTorchActive    | boolean    | Yes  | No  | Whether the flashlight is activated.   |
1252| torchLevel       | number     | Yes  | No  | Flashlight level. The value range is [0, 1]. A larger value indicates a greater luminance.   |
1253
1254## Size
1255
1256Defines the output capability.
1257
1258**System capability**: SystemCapability.Multimedia.Camera.Core
1259
1260| Name  | Type   | Read-only| Optional | Description        |
1261| ------ | ------ | ---- |-----| ------------ |
1262| height | number | No  | No  | Image height, in pixels.|
1263| width  | number | No  | No  | Image width, in pixels.|
1264
1265## Point
1266
1267Defines the point coordinates, which are used for focus and exposure configuration.
1268
1269**System capability**: SystemCapability.Multimedia.Camera.Core
1270
1271| Name   | Type  | Read-only  | Optional  | Description        |
1272| ------ | ------ | ------ | ------ | ------------ |
1273| x      | number | No    | No    | X coordinate of a point.  |
1274| y      | number | No    | No    | Y coordinate of a point.  |
1275
1276## CameraFormat
1277
1278Enumerates the camera output formats.
1279
1280**System capability**: SystemCapability.Multimedia.Camera.Core
1281
1282| Name                    | Value       | Description        |
1283| ----------------------- | --------- | ------------ |
1284| CAMERA_FORMAT_RGBA_8888 | 3         | RGBA_888 image.       |
1285| CAMERA_FORMAT_YUV_420_SP| 1003      | YUV_420_SP image.     |
1286| CAMERA_FORMAT_JPEG      | 2000      | JPEG image.           |
1287| CAMERA_FORMAT_YCBCR_P010<sup>11+</sup> |   2001    | YCBCR_P010 image.     |
1288| CAMERA_FORMAT_YCRCB_P010<sup>11+</sup> |   2002    | YCRCB_P010 image.     |
1289| CAMERA_FORMAT_HEIC<sup>13+</sup>       |   2003    | HEIF image.           |
1290
1291## VideoCodecType<sup>13+</sup>
1292
1293Enumerates the video codec types.
1294
1295**System capability**: SystemCapability.Multimedia.Camera.Core
1296
1297| Name  | Value   | Description         |
1298|------|------|-------------|
1299| AVC  | 0    | AVC. |
1300| HEVC | 1 | HEVC.|
1301
1302## CameraInput
1303
1304Defines the camera input object.
1305
1306Provides camera device information used in [Session](#session11).
1307
1308### open
1309
1310open(callback: AsyncCallback\<void\>): void
1311
1312Opens this camera device. This API uses an asynchronous callback to return the result.
1313
1314**System capability**: SystemCapability.Multimedia.Camera.Core
1315
1316**Parameters**
1317
1318| Name    | Type                 | Mandatory| Description                 |
1319| -------- | -------------------- | ---- | ------------------- |
1320| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
1321
1322**Error codes**
1323
1324For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
1325
1326| ID        | Error Message       |
1327| --------------- | --------------- |
1328| 7400107                |  Can not use camera cause of conflict.               |
1329| 7400108                |  Camera disabled cause of security reason.                                  |
1330| 7400201                |  Camera service fatal error.                                  |
1331
1332**Example**
1333
1334```ts
1335import { BusinessError } from '@kit.BasicServicesKit';
1336
1337function openCameraInput(cameraInput: camera.CameraInput): void {
1338  cameraInput.open((err: BusinessError) => {
1339    if (err) {
1340      console.error(`Failed to open the camera, error code: ${err.code}.`);
1341      return;
1342    }
1343    console.info('Callback returned with camera opened.');
1344  });
1345}
1346```
1347
1348### open
1349
1350open(): Promise\<void\>
1351
1352Opens this camera device. This API uses a promise to return the result.
1353
1354**System capability**: SystemCapability.Multimedia.Camera.Core
1355
1356**Return value**
1357
1358| Type          | Description                     |
1359| -------------- | ----------------------- |
1360| Promise\<void\> | Promise that returns no value.|
1361
1362**Error codes**
1363
1364For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
1365
1366| ID  | Error Message                                     |
1367|---------|-------------------------------------------|
1368| 7400102 | Operation not allowed.                    |
1369| 7400107 | Can not use camera cause of conflict.     |
1370| 7400108 | Camera disabled cause of security reason. |
1371| 7400201 | Camera service fatal error.               |
1372
1373**Example**
1374
1375```ts
1376import { BusinessError } from '@kit.BasicServicesKit';
1377
1378function openCameraInput(cameraInput: camera.CameraInput): void {
1379  cameraInput.open().then(() => {
1380    console.info('Promise returned with camera opened.');
1381  }).catch((error: BusinessError) => {
1382    console.error(`Failed to open the camera, error code: ${error.code}.`);
1383  });
1384}
1385```
1386
1387### open<sup>12+</sup>
1388
1389open(isSecureEnabled: boolean): Promise\<bigint\>
1390
1391Opens this camera device and obtains the handle to the camera in secure mode.
1392
1393**System capability**: SystemCapability.Multimedia.Camera.Core
1394
1395**Parameters**
1396
1397| Name    | Type                 | Mandatory| Description                                                                     |
1398| -------- | -------------------- | ---- |-------------------------------------------------------------------------|
1399| isSecureEnabled | boolean | Yes  | Whether the camera can be enabled in secure mode. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
1400
1401**Return value**
1402
1403| Type          | Description                     |
1404| -------------- | ----------------------- |
1405| Promise\<bigint\> | Promise used to return the handle to the camera.|
1406
1407**Error codes**
1408
1409For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
1410
1411| ID        | Error Message       |
1412| --------------- | --------------- |
1413| 7400107                |  Can not use camera cause of conflict.               |
1414| 7400108                |  Camera disabled cause of security reason.                                  |
1415| 7400201                |  Camera service fatal error.                                  |
1416
1417**Example**
1418
1419```ts
1420import { BusinessError } from '@kit.BasicServicesKit';
1421
1422function openCameraInput(cameraInput: camera.CameraInput): void {
1423  cameraInput.open(true).then(() => {
1424    console.info('Promise returned with camera opened.');
1425  }).catch((error: BusinessError) => {
1426    console.error(`Failed to open the camera, error code: ${error.code}.`);
1427  });
1428}
1429```
1430
1431### close
1432
1433close(callback: AsyncCallback\<void\>\): void
1434
1435Closes this camera device. This API uses an asynchronous callback to return the result.
1436
1437**System capability**: SystemCapability.Multimedia.Camera.Core
1438
1439**Parameters**
1440
1441| Name    | Type                  | Mandatory| Description                 |
1442| -------- | -------------------- | ---- | -------------------- |
1443| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
1444
1445**Error codes**
1446
1447For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
1448
1449| ID        | Error Message       |
1450| --------------- | --------------- |
1451| 7400201                |  Camera service fatal error.                                  |
1452
1453**Example**
1454
1455```ts
1456import { BusinessError } from '@kit.BasicServicesKit';
1457
1458function closeCameraInput(cameraInput: camera.CameraInput): void {
1459  cameraInput.close((err: BusinessError) => {
1460    if (err) {
1461      console.error(`Failed to close the cameras, error code: ${err.code}.`);
1462      return;
1463    }
1464    console.info('Callback returned with camera closed.');
1465  });
1466}
1467```
1468
1469### close
1470
1471close(): Promise\<void\>
1472
1473Closes this camera device. This API uses a promise to return the result.
1474
1475**System capability**: SystemCapability.Multimedia.Camera.Core
1476
1477**Return value**
1478
1479| Type          | Description                     |
1480| -------------- | ----------------------- |
1481| Promise\<void\> | Promise that returns no value.|
1482
1483**Error codes**
1484
1485For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
1486
1487| ID        | Error Message       |
1488| --------------- | --------------- |
1489| 7400201                |  Camera service fatal error.                                  |
1490
1491**Example**
1492
1493```ts
1494import { BusinessError } from '@kit.BasicServicesKit';
1495
1496function closeCameraInput(cameraInput: camera.CameraInput): void {
1497  cameraInput.close().then(() => {
1498    console.info('Promise returned with camera closed.');
1499  }).catch((error: BusinessError) => {
1500    console.error(`Failed to close the cameras, error code: ${error.code}.`);
1501  });
1502}
1503```
1504
1505### on('error')
1506
1507on(type: 'error', camera: CameraDevice, callback: ErrorCallback): void
1508
1509Subscribes to **CameraInput** error events. This API uses an asynchronous callback to return the result.
1510
1511> **NOTE**
1512>
1513> Currently, you cannot use **off()** to unregister the callback in the callback method of **on()**.
1514
1515**System capability**: SystemCapability.Multimedia.Camera.Core
1516
1517**Parameters**
1518
1519| Name    | Type                             | Mandatory| Description                                         |
1520| -------- | -------------------------------- | --- | ------------------------------------------- |
1521| type     | string                           | Yes  | Event type. The value is fixed at **'error'**. The event can be listened for when a **CameraInput** instance is created. This event is triggered and the result is returned when an error occurs on the camera device. For example, if the camera device is unavailable or a conflict occurs, the error information is returned.|
1522| camera   | [CameraDevice](#cameradevice)    | Yes  | Camera device.|
1523| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback) | Yes  | Callback used to return an error code defined in [CameraErrorCode](#cameraerrorcode). |
1524
1525**Example**
1526
1527```ts
1528import { BusinessError } from '@kit.BasicServicesKit';
1529
1530function callback(err: BusinessError): void {
1531  console.error(`Camera input error code: ${err.code}`);
1532}
1533
1534function registerCameraInputError(cameraInput: camera.CameraInput, camera: camera.CameraDevice): void {
1535  cameraInput.on('error', camera, callback);
1536}
1537```
1538
1539### off('error')
1540
1541off(type: 'error', camera: CameraDevice, callback?: ErrorCallback): void
1542
1543Unsubscribes from **CameraInput** error events.
1544
1545**System capability**: SystemCapability.Multimedia.Camera.Core
1546
1547**Parameters**
1548
1549| Name    | Type                             | Mandatory| Description                                         |
1550| -------- | -------------------------------- | --- | ------------------------------------------- |
1551| type     | string                           | Yes  | Event type. The value is fixed at **'error'**. The event can be listened for when a **CameraInput** instance is created. This event is triggered and the result is returned when an error occurs on the camera device. For example, if the camera device is unavailable or a conflict occurs, the error information is returned.|
1552| camera   | [CameraDevice](#cameradevice)    | Yes  | Camera device.|
1553| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback) | No  | Callback used to return the result. If this parameter is specified, the subscription to the specified event with the specified callback is canceled. (The callback object cannot be an anonymous function.) Otherwise, the subscriptions to the specified event with all the callbacks are canceled.|
1554
1555**Example**
1556
1557```ts
1558function unregisterCameraInputError(cameraInput: camera.CameraInput, camera: camera.CameraDevice): void {
1559  cameraInput.off('error', camera);
1560}
1561```
1562
1563## CameraOutput
1564
1565Implements output information used in [Session](#session11). It is the base class of **output**.
1566
1567### release
1568
1569release(callback: AsyncCallback\<void\>): void
1570
1571Releases output resources. This API uses an asynchronous callback to return the result.
1572
1573**System capability**: SystemCapability.Multimedia.Camera.Core
1574
1575**Parameters**
1576
1577| Name     | Type                 | Mandatory| Description                |
1578| -------- | -------------------- | ---- | ------------------- |
1579| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
1580
1581**Error codes**
1582
1583For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
1584
1585| ID        | Error Message       |
1586| --------------- | --------------- |
1587| 7400201                |  Camera service fatal error.                           |
1588
1589**Example**
1590
1591```ts
1592import { BusinessError } from '@kit.BasicServicesKit';
1593
1594function releasePreviewOutput(previewOutput: camera.PreviewOutput): void {
1595  previewOutput.release((err: BusinessError) => {
1596    if (err) {
1597      console.error(`Failed to release the Preview output instance ${err.code}`);
1598      return;
1599    }
1600    console.info('Callback invoked to indicate that the preview output instance is released successfully.');
1601  });
1602}
1603
1604function releaseVideoOutput(videoOutput: camera.VideoOutput): void {
1605  videoOutput.release((err: BusinessError) => {
1606    if (err) {
1607      console.error(`Failed to release the video output instance ${err.code}`);
1608      return;
1609    }
1610    console.info('Callback invoked to indicate that the video output instance is released successfully.');
1611  });
1612}
1613```
1614
1615### release
1616
1617release(): Promise\<void\>
1618
1619Releases output resources. This API uses a promise to return the result.
1620
1621**System capability**: SystemCapability.Multimedia.Camera.Core
1622
1623**Return value**
1624
1625| Type           | Description                    |
1626| -------------- | ----------------------- |
1627| Promise\<void\> | Promise that returns no value.|
1628
1629**Error codes**
1630
1631For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
1632
1633| ID        | Error Message       |
1634| --------------- | --------------- |
1635| 7400201                |  Camera service fatal error.                           |
1636
1637**Example**
1638
1639```ts
1640import { BusinessError } from '@kit.BasicServicesKit';
1641
1642function releasePreviewOutput(previewOutput: camera.PreviewOutput): void {
1643  previewOutput.release().then(() => {
1644    console.info('Promise returned to indicate that the preview output instance is released successfully.');
1645  }).catch((error: BusinessError) => {
1646    console.error(`Failed to preview output release, error code: ${error.code}`);
1647  });
1648}
1649
1650function releaseVideoOutput(videoOutput: camera.VideoOutput): void {
1651  videoOutput.release().then(() => {
1652    console.info('Promise returned to indicate that the video output instance is released successfully.');
1653  }).catch((error: BusinessError) => {
1654    console.error(`Failed to video output release, error code: ${error.code}`);
1655  });
1656}
1657```
1658
1659## PreviewOutput
1660
1661Implements preview output. It inherits from [CameraOutput](#cameraoutput).
1662
1663### start<sup>(deprecated)</sup>
1664
1665start(callback: AsyncCallback\<void\>): void
1666
1667Starts to output preview streams. This API uses an asynchronous callback to return the result.
1668
1669> **NOTE**
1670>
1671> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Session.start](#start11) instead.
1672
1673**System capability**: SystemCapability.Multimedia.Camera.Core
1674
1675**Parameters**
1676
1677| Name     | Type                 | Mandatory| Description                |
1678| -------- | -------------------- | ---- | -------------------- |
1679| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
1680
1681**Error codes**
1682
1683For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
1684
1685| ID        | Error Message       |
1686| --------------- | --------------- |
1687| 7400103                |  Session not config.                                   |
1688
1689**Example**
1690
1691```ts
1692import { BusinessError } from '@kit.BasicServicesKit';
1693
1694function startPreviewOutput(previewOutput: camera.PreviewOutput): void {
1695  previewOutput.start((err: BusinessError) => {
1696    if (err) {
1697      console.error(`Failed to start the preview output, error code: ${err.code}.`);
1698      return;
1699    }
1700    console.info('Callback returned with preview output started.');
1701  });
1702}
1703```
1704
1705### start<sup>(deprecated)</sup>
1706
1707start(): Promise\<void\>
1708
1709Starts to output preview streams. This API uses a promise to return the result.
1710
1711> **NOTE**
1712>
1713> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Session.start](#start11-1) instead.
1714
1715**System capability**: SystemCapability.Multimedia.Camera.Core
1716
1717**Return value**
1718
1719| Type           | Description               |
1720| -------------- |-------------------|
1721| Promise\<void\> | Promise that returns no value. |
1722
1723**Error codes**
1724
1725For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
1726
1727| ID        | Error Message       |
1728| --------------- | --------------- |
1729| 7400103                |  Session not config.                                   |
1730
1731**Example**
1732
1733```ts
1734import { BusinessError } from '@kit.BasicServicesKit';
1735
1736function startPreviewOutput(previewOutput: camera.PreviewOutput): void {
1737  previewOutput.start().then(() => {
1738    console.info('Promise returned with preview output started.');
1739  }).catch((error: BusinessError) => {
1740    console.error(`Failed to preview output start, error code: ${error.code}.`);
1741  });
1742}
1743```
1744
1745### stop<sup>(deprecated)</sup>
1746
1747stop(callback: AsyncCallback\<void\>): void
1748
1749Stops outputting preview streams. This API uses an asynchronous callback to return the result.
1750
1751> **NOTE**
1752>
1753> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Session.stop](#stop11) instead.
1754
1755**System capability**: SystemCapability.Multimedia.Camera.Core
1756
1757**Parameters**
1758
1759| Name     | Type                 | Mandatory| Description                |
1760| -------- | -------------------- | ---- | -------------------- |
1761| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
1762
1763**Example**
1764
1765```ts
1766import { BusinessError } from '@kit.BasicServicesKit';
1767
1768function stopPreviewOutput(previewOutput: camera.PreviewOutput): void {
1769  previewOutput.stop((err: BusinessError) => {
1770    if (err) {
1771      console.error(`Failed to stop the preview output, error code: ${err.code}.`);
1772      return;
1773    }
1774    console.info('Returned with preview output stopped.');
1775  })
1776}
1777```
1778
1779### stop<sup>(deprecated)</sup>
1780
1781stop(): Promise\<void\>
1782
1783Stops outputting preview streams. This API uses a promise to return the result.
1784
1785> **NOTE**
1786>
1787> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Session.stop](#stop11-1) instead.
1788
1789**System capability**: SystemCapability.Multimedia.Camera.Core
1790
1791**Return value**
1792
1793| Type           | Description                    |
1794| -------------- | ------------------------ |
1795| Promise\<void\> | Promise that returns no value.|
1796
1797**Example**
1798
1799```ts
1800import { BusinessError } from '@kit.BasicServicesKit';
1801
1802function stopPreviewOutput(previewOutput: camera.PreviewOutput): void {
1803  previewOutput.stop().then(() => {
1804    console.info('Callback returned with preview output stopped.');
1805  }).catch((error: BusinessError) => {
1806    console.error(`Failed to preview output stop, error code: ${error.code}.`);
1807  });
1808}
1809```
1810
1811### on('frameStart')
1812
1813on(type: 'frameStart', callback: AsyncCallback\<void\>): void
1814
1815Subscribes to preview frame start events. This API uses an asynchronous callback to return the result.
1816
1817> **NOTE**
1818>
1819> Currently, you cannot use **off()** to unregister the callback in the callback method of **on()**.
1820
1821**System capability**: SystemCapability.Multimedia.Camera.Core
1822
1823**Parameters**
1824
1825| Name     | Type                 | Mandatory| Description                                    |
1826| -------- | -------------------- | ---- | --------------------------------------- |
1827| type     | string               | Yes  | Event type. The value is fixed at **'frameStart'**. The event can be listened for when a **previewOutput** instance is created. This event is triggered and returned when the bottom layer starts exposure for the first time.|
1828| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result. The preview starts as long as this event is returned.                   |
1829
1830**Example**
1831
1832```ts
1833import { BusinessError } from '@kit.BasicServicesKit';
1834
1835function callback(err: BusinessError): void {
1836  if (err !== undefined && err.code !== 0) {
1837    console.error(`Callback Error, errorCode: ${err.code}`);
1838    return;
1839  }
1840  console.info('Preview frame started');
1841}
1842
1843function registerPreviewOutputFrameStart(previewOutput: camera.PreviewOutput): void {
1844  previewOutput.on('frameStart', callback);
1845}
1846```
1847
1848### off('frameStart')
1849
1850off(type: 'frameStart', callback?: AsyncCallback\<void\>): void
1851
1852Unsubscribes from preview frame start events.
1853
1854**System capability**: SystemCapability.Multimedia.Camera.Core
1855
1856**Parameters**
1857
1858| Name     | Type                 | Mandatory| Description                                    |
1859| -------- | -------------------- | ---- | --------------------------------------- |
1860| type     | string               | Yes  | Event type. The value is fixed at **'frameStart'**. The event can be listened for when a **previewOutput** instance is created.|
1861| callback | AsyncCallback\<void\> | No  | Callback used to return the result. If this parameter is specified, the subscription to the specified event with the specified callback is canceled. (The callback object cannot be an anonymous function.) Otherwise, the subscriptions to the specified event with all the callbacks are canceled.|
1862
1863**Example**
1864
1865```ts
1866function unregisterPreviewOutputFrameStart(previewOutput: camera.PreviewOutput): void {
1867  previewOutput.off('frameStart');
1868}
1869```
1870
1871### on('frameEnd')
1872
1873on(type: 'frameEnd', callback: AsyncCallback\<void\>): void
1874
1875Subscribes to preview frame end events. This API uses an asynchronous callback to return the result.
1876
1877> **NOTE**
1878>
1879> Currently, you cannot use **off()** to unregister the callback in the callback method of **on()**.
1880
1881**System capability**: SystemCapability.Multimedia.Camera.Core
1882
1883**Parameters**
1884
1885| Name     | Type                 | Mandatory| Description                                 |
1886| -------- | -------------------- | ---- | ------------------------------------- |
1887| type     | string               | Yes  | Event type. The value is fixed at **'frameEnd'**. The event can be listened for when a **previewOutput** instance is created. This event is triggered and returned when the last frame of preview ends.|
1888| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result. The preview ends as long as this event is returned.               |
1889
1890**Example**
1891
1892```ts
1893import { BusinessError } from '@kit.BasicServicesKit';
1894
1895function callback(err: BusinessError): void {
1896  if (err !== undefined && err.code !== 0) {
1897    console.error(`Callback Error, errorCode: ${err.code}`);
1898    return;
1899  }
1900  console.info('Preview frame ended');
1901}
1902
1903function registerPreviewOutputFrameEnd(previewOutput: camera.PreviewOutput): void {
1904  previewOutput.on('frameEnd', callback);
1905}
1906```
1907
1908### off('frameEnd')
1909
1910off(type: 'frameEnd', callback?: AsyncCallback\<void\>): void
1911
1912Unsubscribes from preview frame end events.
1913
1914**System capability**: SystemCapability.Multimedia.Camera.Core
1915
1916**Parameters**
1917
1918| Name     | Type                 | Mandatory| Description                                 |
1919| -------- | -------------------- | ---- | ------------------------------------- |
1920| type     | string               | Yes  | Event type. The value is fixed at **'frameEnd'**. The event can be listened for when a **previewOutput** instance is created.|
1921| callback | AsyncCallback\<void\> | No  | Callback used to return the result. If this parameter is specified, the subscription to the specified event with the specified callback is canceled. (The callback object cannot be an anonymous function.) Otherwise, the subscriptions to the specified event with all the callbacks are canceled.|
1922
1923**Example**
1924
1925```ts
1926function unregisterPreviewOutputFrameEnd(previewOutput: camera.PreviewOutput): void {
1927  previewOutput.off('frameEnd');
1928}
1929```
1930
1931### on('error')
1932
1933on(type: 'error', callback: ErrorCallback): void
1934
1935Subscribes to **PreviewOutput** error events. This API uses an asynchronous callback to return the result.
1936
1937> **NOTE**
1938>
1939> Currently, you cannot use **off()** to unregister the callback in the callback method of **on()**.
1940
1941**System capability**: SystemCapability.Multimedia.Camera.Core
1942
1943**Parameters**
1944
1945| Name    | Type        | Mandatory| Description                      |
1946| -------- | --------------| ---- | ------------------------ |
1947| type     | string        | Yes  | Event type. The value is fixed at **'error'**. The event can be listened for when a **previewOutput** instance is created. This event is triggered and the corresponding error message is returned when an error occurs during the use of a preview-related API such as [Session.start](#start11-1) or [CameraOutput.release](#release-1).|
1948| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback) | Yes  | Callback used to return an error code defined in [CameraErrorCode](#cameraerrorcode). |
1949
1950**Example**
1951
1952```ts
1953import { BusinessError } from '@kit.BasicServicesKit';
1954
1955function callback(previewOutputError: BusinessError): void {
1956  console.error(`Preview output error code: ${previewOutputError.code}`);
1957}
1958
1959function registerPreviewOutputError(previewOutput: camera.PreviewOutput): void {
1960  previewOutput.on('error', callback)
1961}
1962```
1963
1964### off('error')
1965
1966off(type: 'error', callback?: ErrorCallback): void
1967
1968Unsubscribes from **PreviewOutput** error events.
1969
1970**System capability**: SystemCapability.Multimedia.Camera.Core
1971
1972**Parameters**
1973
1974| Name    | Type        | Mandatory| Description                      |
1975| -------- | --------------| ---- | ------------------------ |
1976| type     | string        | Yes  | Event type. The value is fixed at **'error'**. The event can be listened for when a **previewOutput** instance is created.|
1977| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback) | No  | Callback used to return the result. If this parameter is specified, the subscription to the specified event with the specified callback is canceled. (The callback object cannot be an anonymous function.) Otherwise, the subscriptions to the specified event with all the callbacks are canceled.|
1978
1979**Example**
1980
1981```ts
1982function unregisterPreviewOutputError(previewOutput: camera.PreviewOutput): void {
1983  previewOutput.off('error');
1984}
1985```
1986
1987### getSupportedFrameRates<sup>12+</sup>
1988
1989 getSupportedFrameRates(): Array\<FrameRateRange\>
1990
1991Obtains the supported frame rates.
1992
1993**System capability**: SystemCapability.Multimedia.Camera.Core
1994
1995**Return value**
1996|      Type     |     Description    |
1997| -------------  | ------------ |
1998| Array<[FrameRateRange](#frameraterange)> | Array of supported frame rates.|
1999
2000**Example**
2001
2002```ts
2003function getSupportedFrameRates(previewOutput: camera.PreviewOutput): Array<camera.FrameRateRange> {
2004  let supportedFrameRatesArray: Array<camera.FrameRateRange> = previewOutput.getSupportedFrameRates();
2005  return supportedFrameRatesArray;
2006}
2007```
2008
2009### setFrameRate<sup>12+</sup>
2010
2011setFrameRate(minFps: number, maxFps: number): void
2012
2013Sets a frame rate range for preview streams. The range must be within the supported frame rate range, which can be obtained by calling [getSupportedFrameRates](#getsupportedframerates12).
2014
2015> **NOTE**
2016>
2017> This API is valid only in [PhotoSession](#photosession11) or [VideoSession](#videosession11) mode.
2018
2019**System capability**: SystemCapability.Multimedia.Camera.Core
2020
2021**Parameters**
2022
2023| Name    | Type        | Mandatory| Description                      |
2024| -------- | --------------| ---- | ------------------------ |
2025| minFps   | number        | Yes  | Minimum frame rate.|
2026| maxFps   | number        | Yes  | Maximum frame rate. When the minimum value is greater than the maximum value, the API does not take effect.|
2027
2028**Error codes**
2029
2030For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
2031
2032| ID       | Error Message       |
2033| --------------- | --------------- |
2034| 7400101                |  Parameter missing or parameter type incorrect.        |
2035| 7400110                |  Unresolved conflicts with current configurations.     |
2036
2037**Example**
2038
2039```ts
2040function setFrameRateRange(previewOutput: camera.PreviewOutput, frameRateRange: Array<number>): void {
2041  previewOutput.setFrameRate(frameRateRange[0], frameRateRange[1]);
2042}
2043```
2044
2045### getActiveFrameRate<sup>12+</sup>
2046
2047getActiveFrameRate(): FrameRateRange
2048
2049Obtains the configured frame rate range.
2050
2051This API is valid only after [setFrameRate](#setframerate12) is called to set a frame rate range for preview streams.
2052
2053**System capability**: SystemCapability.Multimedia.Camera.Core
2054
2055**Return value**
2056
2057|      Type     |     Description    |
2058| -------------  | ------------ |
2059| [FrameRateRange](#frameraterange) | Frame rate range.|
2060
2061**Example**
2062
2063```ts
2064function getActiveFrameRate(previewOutput: camera.PreviewOutput): camera.FrameRateRange {
2065  let activeFrameRate: camera.FrameRateRange = previewOutput.getActiveFrameRate();
2066  return activeFrameRate;
2067}
2068```
2069
2070### getActiveProfile<sup>12+</sup>
2071
2072getActiveProfile(): Profile
2073
2074Obtains the profile that takes effect currently.
2075
2076**System capability**: SystemCapability.Multimedia.Camera.Core
2077
2078**Return value**
2079
2080|      Type     | Description       |
2081| -------------  |-----------|
2082| [Profile](#profile) | Profile obtained.|
2083
2084**Error codes**
2085
2086For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
2087
2088| ID  | Error Message                        |
2089|---------|------------------------------|
2090| 7400201 | Camera service fatal error.  |
2091
2092**Example**
2093
2094```ts
2095function testGetActiveProfile(previewOutput: camera.PreviewOutput): camera.Profile | undefined {
2096  let activeProfile: camera.Profile | undefined = undefined;
2097  try {
2098    activeProfile = previewOutput.getActiveProfile();
2099  } catch (error) {
2100    // If the operation fails, error.code is returned and processed.
2101    let err = error as BusinessError;
2102    console.error(`The previewOutput.getActiveProfile call failed. error code: ${err.code}`);
2103  }
2104  return activeProfile;
2105}
2106```
2107
2108### getPreviewRotation<sup>12+</sup>
2109
2110getPreviewRotation(displayRotation: number): ImageRotation
2111
2112Obtains the preview rotation degree.
2113
2114- Device' natural orientation: The default orientation of the device (phone) is in portrait mode, with the charging port facing downward.
2115- Camera lens angle: equivalent to the angle at which the camera is rotated clockwise to match the device's natural direction. The rear camera sensor of a phone is installed in landscape mode. Therefore, it needs to be rotated by 90 degrees clockwise to match the device's natural direction.
2116- Screen orientation: The upper left corner of the image displayed on the screen is the first pixel, which is the coordinate origin. In the case of lock screen, the direction is the same as the device's natural orientation.
2117
2118**System capability**: SystemCapability.Multimedia.Camera.Core
2119
2120**Parameters**
2121
2122| Name    | Type        | Mandatory| Description                      |
2123| -------- | --------------| ---- | ------------------------ |
2124| displayRotation | number  | Yes  | Screen rotation angle of the display. It is obtained by calling [display.getDefaultDisplaySync](../apis-arkui/js-apis-display.md#displaygetdefaultdisplaysync9).|
2125
2126**Return value**
2127
2128|      Type     | Description       |
2129| -------------  |-----------|
2130| [ImageRotation](#imagerotation) | Preview rotation degree.|
2131
2132**Error codes**
2133
2134For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
2135
2136| ID  | Error Message                        |
2137|---------|------------------------------|
2138| 7400101 | Parameter missing or parameter type incorrect.  |
2139| 7400201 | Camera service fatal error.  |
2140
2141**Example**
2142
2143```ts
2144function testGetPreviewRotation(previewOutput: camera.PreviewOutput, imageRotation : camera.ImageRotation): camera.ImageRotation {
2145  let previewRotation: camera.ImageRotation = camera.ImageRotation.ROTATION_0;
2146  try {
2147    previewRotation = previewOutput.getPreviewRotation(imageRotation);
2148    console.log(`Preview rotation is: ${previewRotation}`);
2149  } catch (error) {
2150    // If the operation fails, error.code is returned and processed.
2151    let err = error as BusinessError;
2152    console.error(`The previewOutput.getPreviewRotation call failed. error code: ${err.code}`);
2153  }
2154  return previewRotation;
2155}
2156```
2157### setPreviewRotation<sup>12+</sup>
2158setPreviewRotation(previewRotation: ImageRotation, isDisplayLocked?: boolean): void
2159
2160Sets the preview rotation degree.
2161
2162**System capability**: SystemCapability.Multimedia.Camera.Core
2163
2164**Parameters**
2165
2166| Name    | Type        | Mandatory| Description                      |
2167| -------- | --------------| ---- | ------------------------ |
2168| previewRotation | [ImageRotation](#imagerotation)  | Yes  | Preview rotation angle.|
2169| isDisplayLocked | boolean  | No  | Whether the display is locked.|
2170
2171**Error codes**
2172
2173For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
2174
2175| ID  | Error Message                        |
2176|---------|------------------------------|
2177| 7400101 | Parameter missing or parameter type incorrect.  |
2178| 7400201 | Camera service fatal error.  |
2179
2180**Example**
2181
2182```ts
2183function testSetPreviewRotation(previewOutput: camera.PreviewOutput, previewRotation : camera.ImageRotation, isDisplayLocked: boolean): void {
2184  try {
2185    previewOutput.setPreviewRotation(previewRotation, isDisplayLocked);
2186  } catch (error) {
2187    // If the operation fails, error.code is returned and processed.
2188    let err = error as BusinessError;
2189    console.error(`The previewOutput.setPreviewRotation call failed. error code: ${err.code}`);
2190  }
2191  return;
2192}
2193```
2194## ImageRotation
2195
2196Enumerates the image rotation angles.
2197
2198**System capability**: SystemCapability.Multimedia.Camera.Core
2199
2200| Name         | Value  | Description          |
2201| ------------ | ---- | ------------- |
2202| ROTATION_0   | 0    | The image rotates 0 degrees.  |
2203| ROTATION_90  | 90   | The image rotates 90 degrees. |
2204| ROTATION_180 | 180  | The image rotates 180 degrees.|
2205| ROTATION_270 | 270  | The image rotates 270 degrees.|
2206
2207## Location
2208
2209Defines the geolocation information.
2210
2211**System capability**: SystemCapability.Multimedia.Camera.Core
2212
2213| Name         | Type  | Read-only| Optional |Description        |
2214| ------------ | ------ | ---- |-----|------------ |
2215| latitude     | number |  No | No  |Latitude, in degrees.   |
2216| longitude    | number |  No | No  |Longitude, in degrees.   |
2217| altitude     | number |  No | No  |Altitude, in meters.   |
2218
2219## QualityLevel
2220
2221Enumerates the image quality levels.
2222
2223**System capability**: SystemCapability.Multimedia.Camera.Core
2224
2225| Name                 | Value  | Description        |
2226| -------------------- | ---- | ------------ |
2227| QUALITY_LEVEL_HIGH   | 0    | High image quality.  |
2228| QUALITY_LEVEL_MEDIUM | 1    | Medium image quality.|
2229| QUALITY_LEVEL_LOW    | 2    | Low image quality.  |
2230
2231
2232## PhotoCaptureSetting
2233
2234Defines the settings for taking an image.
2235
2236**System capability**: SystemCapability.Multimedia.Camera.Core
2237
2238| Name     | Type                           | Read-only| Optional| Description                                                                  |
2239| -------- | ------------------------------- | ---- | ---- |----------------------------------------------------------------------|
2240| quality  | [QualityLevel](#qualitylevel)   | No  | Yes  | Image quality (low by default).                                                          |
2241| rotation | [ImageRotation](#imagerotation) | No  | Yes  | Rotation angle of the image. The default value is **0**, indicating clockwise rotation.                                                 |
2242| location | [Location](#location)           | No  | Yes  | Geolocation information of the image (depending on the device hardware information by default).                                              |
2243| mirror   | boolean                         | No  | Yes  | Whether mirror photography is enabled (disabled by default). Before using this enumerated value, call [isMirrorSupported](#ismirrorsupported) to check whether mirror photography is supported.|
2244
2245## Photo<sup>11+</sup>
2246
2247Defines a higher-resolution image object.
2248
2249### Attributes
2250
2251**System capability**: SystemCapability.Multimedia.Camera.Core
2252
2253| Name  | Type                           |     Mandatory    | Description      |
2254| ------ | ----------------------------- | -------------- | ---------- |
2255| main<sup>11+</sup> | [image.Image](../apis-image-kit/js-apis-image.md#image9) |        Yes      | Higher-resolution image.|
2256
2257### release<sup>11+</sup>
2258
2259release(): Promise\<void\>
2260
2261Releases output resources. This API uses a promise to return the result.
2262
2263**System capability**: SystemCapability.Multimedia.Camera.Core
2264
2265**Return value**
2266
2267| Type           | Description                    |
2268| -------------- | ----------------------- |
2269| Promise\<void\> | Promise that returns no value.|
2270
2271**Example**
2272
2273```ts
2274async function releasePhoto(photo: camera.Photo): Promise<void> {
2275  await photo.release();
2276}
2277```
2278
2279## PhotoOutput
2280
2281Implements output information used in a photo session. It inherits from [CameraOutput](#cameraoutput).
2282
2283### capture
2284
2285capture(callback: AsyncCallback\<void\>): void
2286
2287Captures a photo with the default photo capture parameters. This API uses an asynchronous callback to return the result.
2288
2289**System capability**: SystemCapability.Multimedia.Camera.Core
2290
2291**Parameters**
2292
2293| Name     | Type                 | Mandatory| Description                |
2294| -------- | -------------------- | ---- | ------------------- |
2295| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
2296
2297**Error codes**
2298
2299For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
2300
2301| ID        | Error Message       |
2302| --------------- | --------------- |
2303| 7400104                |  Session not running.                                  |
2304| 7400201                |  Camera service fatal error.                           |
2305
2306**Example**
2307
2308```ts
2309import { BusinessError } from '@kit.BasicServicesKit';
2310
2311function capture(photoOutput: camera.PhotoOutput): void {
2312  photoOutput.capture((err: BusinessError) => {
2313    if (err) {
2314      console.error(`Failed to capture the photo, error code: ${err.code}.`);
2315      return;
2316    }
2317    console.info('Callback invoked to indicate the photo capture request success.');
2318  });
2319}
2320```
2321
2322### capture
2323
2324capture(): Promise\<void\>
2325
2326Captures a photo with the default photo capture parameters. This API uses a promise to return the result.
2327
2328**System capability**: SystemCapability.Multimedia.Camera.Core
2329
2330**Return value**
2331
2332| Type           | Description                    |
2333| -------------- | ------------------------ |
2334| Promise\<void\> | Promise that returns no value.|
2335
2336**Error codes**
2337
2338For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
2339
2340| ID        | Error Message       |
2341| --------------- | --------------- |
2342| 7400104                |  Session not running.                                  |
2343| 7400201                |  Camera service fatal error.                           |
2344
2345**Example**
2346
2347```ts
2348import { BusinessError } from '@kit.BasicServicesKit';
2349
2350function capture(photoOutput: camera.PhotoOutput): void {
2351  photoOutput.capture().then(() => {
2352    console.info('Promise returned to indicate that photo capture request success.');
2353  }).catch((error: BusinessError) => {
2354    console.error(`Failed to photo output capture, error code: ${error.code}.`);
2355  });
2356}
2357```
2358
2359### capture
2360
2361capture(setting: PhotoCaptureSetting, callback: AsyncCallback\<void\>): void
2362
2363Captures a photo with the specified photo capture parameters. This API uses an asynchronous callback to return the result.
2364
2365**System capability**: SystemCapability.Multimedia.Camera.Core
2366
2367**Parameters**
2368
2369| Name     | Type                                        | Mandatory| Description                 |
2370| -------- | ------------------------------------------- | ---- | -------------------- |
2371| setting  | [PhotoCaptureSetting](#photocapturesetting) | Yes  | Photo capture settings.            |
2372| callback | AsyncCallback\<void\>                        | Yes  | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned. |
2373
2374**Error codes**
2375
2376For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
2377
2378| ID        | Error Message       |
2379| --------------- | --------------- |
2380| 7400101                |  Parameter missing or parameter type incorrect.        |
2381| 7400104                |  Session not running.                                  |
2382| 7400201                |  Camera service fatal error.                           |
2383
2384**Example**
2385
2386```ts
2387import { BusinessError } from '@kit.BasicServicesKit';
2388
2389function capture(photoOutput: camera.PhotoOutput): void {
2390  let captureLocation: camera.Location = {
2391    latitude: 0,
2392    longitude: 0,
2393    altitude: 0
2394  }
2395  let settings: camera.PhotoCaptureSetting = {
2396    quality: camera.QualityLevel.QUALITY_LEVEL_LOW,
2397    rotation: camera.ImageRotation.ROTATION_0,
2398    location: captureLocation,
2399    mirror: false
2400  }
2401  photoOutput.capture(settings, (err: BusinessError) => {
2402    if (err) {
2403      console.error(`Failed to capture the photo, error code: ${err.code}.`);
2404      return;
2405    }
2406    console.info('Callback invoked to indicate the photo capture request success.');
2407  });
2408}
2409```
2410
2411### capture
2412
2413capture(setting: PhotoCaptureSetting): Promise\<void\>
2414
2415Captures a photo with the specified photo capture parameters. This API uses a promise to return the result.
2416
2417**System capability**: SystemCapability.Multimedia.Camera.Core
2418
2419**Parameters**
2420
2421| Name    | Type                                        | Mandatory| Description     |
2422| ------- | ------------------------------------------- | ---- | -------- |
2423| setting | [PhotoCaptureSetting](#photocapturesetting) | Yes  | Photo capture parameters. The input of **undefined** is processed as if no parameters were passed.|
2424
2425**Return value**
2426
2427| Type           | Description                    |
2428| -------------- | ------------------------ |
2429| Promise\<void\> | Promise that returns no value.|
2430
2431**Error codes**
2432
2433For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
2434
2435| ID        | Error Message       |
2436| --------------- | --------------- |
2437| 7400101                |  Parameter missing or parameter type incorrect.        |
2438| 7400104                |  Session not running.                                  |
2439| 7400201                |  Camera service fatal error.                           |
2440
2441**Example**
2442
2443```ts
2444import { BusinessError } from '@kit.BasicServicesKit';
2445
2446function capture(photoOutput: camera.PhotoOutput): void {
2447  let captureLocation: camera.Location = {
2448    latitude: 0,
2449    longitude: 0,
2450    altitude: 0
2451  }
2452  let settings: camera.PhotoCaptureSetting = {
2453    quality: camera.QualityLevel.QUALITY_LEVEL_LOW,
2454    rotation: camera.ImageRotation.ROTATION_0,
2455    location: captureLocation,
2456    mirror: false
2457  }
2458  photoOutput.capture(settings).then(() => {
2459    console.info('Promise returned to indicate that photo capture request success.');
2460  }).catch((error: BusinessError) => {
2461    console.error(`Failed to photo output capture, error code: ${error.code}.`);
2462  });
2463}
2464```
2465
2466### on('photoAvailable')<sup>11+</sup>
2467
2468on(type: 'photoAvailable', callback: AsyncCallback\<Photo\>): void
2469
2470Subscribes to events indicating available high-resolution images. This API uses an asynchronous callback to return the result.
2471
2472> **NOTE**
2473>
2474> Currently, you cannot use **off()** to unregister the callback in the callback method of **on()**.
2475
2476**System capability**: SystemCapability.Multimedia.Camera.Core
2477
2478**Parameters**
2479
2480| Name    | Type     | Mandatory| Description                                 |
2481| -------- | ---------- | --- | ------------------------------------ |
2482| type     | string     | Yes  | Event type. The value is fixed at **'photoAvailable'**. The event can be listened for when a **photoOutput** instance is created.|
2483| callback | AsyncCallback\<[Photo](#photo11)\> | Yes  | Callback used to return the high-resolution image.|
2484
2485**Example**
2486
2487```ts
2488import { BusinessError } from '@kit.BasicServicesKit';
2489import { image } from '@kit.ImageKit';
2490
2491function callback(err: BusinessError, photo: camera.Photo): void {
2492  if (err !== undefined && err.code !== 0) {
2493    console.error(`Callback Error, errorCode: ${err.code}`);
2494    return;
2495  }
2496  let mainImage: image.Image = photo.main;
2497}
2498
2499function registerPhotoOutputPhotoAvailable(photoOutput: camera.PhotoOutput): void {
2500  photoOutput.on('photoAvailable', callback);
2501}
2502```
2503
2504### off('photoAvailable')<sup>11+</sup>
2505
2506off(type: 'photoAvailable', callback?: AsyncCallback\<Photo\>): void
2507
2508Unsubscribes from events indicating available high-resolution images.
2509
2510**System capability**: SystemCapability.Multimedia.Camera.Core
2511
2512**Parameters**
2513
2514| Name     | Type                   | Mandatory| Description                                      |
2515| -------- | ---------------------- | ---- | ------------------------------------------ |
2516| type     | string                 | Yes  | Event type. The value is fixed at **'photoAvailable'**. The event can be listened for when a **photoOutput** instance is created.|
2517| callback | AsyncCallback\<[Photo](#photo11)\> | No  | Callback used to return the result. If this parameter is specified, the subscription to the specified event with the specified callback is canceled. (The callback object cannot be an anonymous function.) Otherwise, the subscriptions to the specified event with all the callbacks are canceled.|
2518
2519**Example**
2520
2521```ts
2522import { BusinessError } from '@kit.BasicServicesKit';
2523import { image } from '@kit.ImageKit';
2524
2525function callback(err: BusinessError, photo: camera.Photo): void {
2526  if (err !== undefined && err.code !== 0) {
2527    console.error(`Callback Error, errorCode: ${err.code}`);
2528    return;
2529  }
2530  let mainImage: image.Image = photo.main;
2531}
2532
2533function unRegisterPhotoOutputPhotoAvailable(photoOutput: camera.PhotoOutput): void {
2534  photoOutput.off('photoAvailable', callback);
2535}
2536```
2537
2538### on('captureStartWithInfo')<sup>11+</sup>
2539
2540on(type: 'captureStartWithInfo', callback: AsyncCallback\<CaptureStartInfo\>): void
2541
2542Subscribes to capture start events. This API uses an asynchronous callback to return the result.
2543
2544> **NOTE**
2545>
2546> Currently, you cannot use **off()** to unregister the callback in the callback method of **on()**.
2547
2548**System capability**: SystemCapability.Multimedia.Camera.Core
2549
2550**Parameters**
2551
2552| Name    | Type     | Mandatory| Description                                 |
2553| -------- | ---------- | --- | ------------------------------------ |
2554| type     | string     | Yes  | Event type. The value is fixed at **'captureStartWithInfo'**. The event can be listened for when a **photoOutput** instance is created.|
2555| callback | AsyncCallback\<[CaptureStartInfo](#capturestartinfo11)\> | Yes  | Callback used to return the capture ID.|
2556
2557**Example**
2558
2559```ts
2560import { BusinessError } from '@kit.BasicServicesKit';
2561
2562function callback(err: BusinessError, captureStartInfo: camera.CaptureStartInfo): void {
2563  if (err !== undefined && err.code !== 0) {
2564    console.error(`Callback Error, errorCode: ${err.code}`);
2565    return;
2566  }
2567  console.info(`photo capture started, captureStartInfo : ${captureStartInfo}`);
2568}
2569
2570function registerCaptureStartWithInfo(photoOutput: camera.PhotoOutput): void {
2571  photoOutput.on('captureStartWithInfo', callback);
2572}
2573```
2574
2575### off('captureStartWithInfo')<sup>11+</sup>
2576
2577off(type: 'captureStartWithInfo', callback?: AsyncCallback\<CaptureStartInfo\>): void
2578
2579Unsubscribes from capture start events.
2580
2581**System capability**: SystemCapability.Multimedia.Camera.Core
2582
2583**Parameters**
2584
2585| Name     | Type                   | Mandatory| Description                                      |
2586| -------- | ---------------------- | ---- | ------------------------------------------ |
2587| type     | string                 | Yes  | Event type. The value is fixed at **'captureStartWithInfo'**. The event can be listened for when a **photoOutput** instance is created.|
2588| callback | AsyncCallback\<[CaptureStartInfo](#capturestartinfo11)\> | No  | Callback used to return the result. If this parameter is specified, the subscription to the specified event with the specified callback is canceled. (The callback object cannot be an anonymous function.) Otherwise, the subscriptions to the specified event with all the callbacks are canceled.|
2589
2590**Example**
2591
2592```ts
2593import { BusinessError } from '@kit.BasicServicesKit';
2594
2595function unRegisterCaptureStartWithInfo(photoOutput: camera.PhotoOutput): void {
2596  photoOutput.off('captureStartWithInfo');
2597}
2598```
2599
2600### isMovingPhotoSupported<sup>12+</sup>
2601
2602isMovingPhotoSupported(): boolean
2603
2604Checks whether taking moving photos is supported.
2605
2606**System capability**: SystemCapability.Multimedia.Camera.Core
2607
2608**Return value**
2609
2610| Type           | Description                    |
2611| -------------- | ----------------------- |
2612| boolean | **true**: Taking moving photos is supported.<br>**false**: Taking moving photos is not supported.|
2613
2614**Error codes**
2615
2616For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
2617
2618| ID      | Error Message      |
2619| -------------- | --------------- |
2620| 7400201 |  Camera service fatal error. |
2621
2622**Example**
2623
2624```ts
2625import { BusinessError } from '@kit.BasicServicesKit';
2626
2627function isMovingPhotoSupported(photoOutput: camera.PhotoOutput): boolean {
2628  let isSupported: boolean = false;
2629  try {
2630    isSupported = photoOutput.isMovingPhotoSupported();
2631  } catch (error) {
2632    // If the operation fails, error.code is returned and processed.
2633    let err = error as BusinessError;
2634    console.error(`The isMovingPhotoSupported call failed. error code: ${err.code}`);
2635  }
2636  return isSupported;
2637}
2638```
2639
2640### enableMovingPhoto<sup>12+</sup>
2641
2642enableMovingPhoto(enabled: boolean): void
2643
2644Enables or disables the feature of taking moving photos.
2645
2646**Required permissions:** ohos.permission.MICROPHONE
2647
2648**System capability**: SystemCapability.Multimedia.Camera.Core
2649
2650**Parameters**
2651
2652| Name     | Type                   | Mandatory| Description                                      |
2653| -------- | ---------------------- | ---- | ------------------------------------------ |
2654| enabled  | boolean                | Yes  | Whether to enable the feature of taking moving photos. The value **true** means to enable the feature, and **false** means the opposite.    |
2655
2656**Error codes**
2657
2658For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
2659
2660| ID   | Error Message                                          |
2661| -------- |------------------------------------------------|
2662| 201      | permission denied.                             |
2663| 7400101  | Parameter missing or parameter type incorrect. |
2664| 7400201  | Camera service fatal error.                    |
2665
2666**Example**
2667
2668```ts
2669import { BusinessError } from '@kit.BasicServicesKit';
2670
2671function enableMovingPhoto(photoOutput: camera.PhotoOutput): void {
2672  try {
2673    photoOutput.enableMovingPhoto(true);
2674  } catch (error) {
2675    // If the operation fails, error.code is returned and processed.
2676    let err = error as BusinessError;
2677    console.error(`The enableMovingPhoto call failed. error code: ${err.code}`);
2678  }
2679}
2680```
2681
2682### on('photoAssetAvailable')<sup>12+</sup>
2683
2684on(type: 'photoAssetAvailable', callback: AsyncCallback\<photoAccessHelper.PhotoAsset\>): void
2685
2686Subscribes to photo asset available events. This API uses an asynchronous callback to return the result.
2687
2688> **NOTE**
2689>
2690> Currently, you cannot use **off()** to unregister the callback in the callback method of **on()**.
2691
2692**System capability**: SystemCapability.Multimedia.Camera.Core
2693
2694**Parameters**
2695
2696| Name    | Type     | Mandatory| Description                                 |
2697| -------- | ---------- | --- | ------------------------------------ |
2698| type     | string     | Yes  | Event type. The value is fixed at **'photoAssetAvailable'**. The event can be listened for when a **photoOutput** instance is created.|
2699| callback | AsyncCallback\<[photoAccessHelper.PhotoAsset](../apis-media-library-kit/js-apis-photoAccessHelper.md#photoasset)\> | Yes  | Callback used to return the photo asset.|
2700
2701**Example**
2702
2703```ts
2704import { BusinessError } from '@kit.BasicServicesKit';
2705import { photoAccessHelper } from '@kit.MediaLibraryKit';
2706
2707function photoAssetAvailableCallback(err: BusinessError, photoAsset: photoAccessHelper.PhotoAsset): void {
2708  if (err) {
2709    console.info(`photoAssetAvailable error: ${JSON.stringify(err)}.`);
2710    return;
2711  }
2712  console.info('photoOutPutCallBack photoAssetAvailable');
2713  // You can use photoAsset to obtain image information.
2714}
2715
2716function onPhotoOutputPhotoAssetAvailable(photoOutput: camera.PhotoOutput): void {
2717  photoOutput.on('photoAssetAvailable', photoAssetAvailableCallback);
2718}
2719```
2720
2721### off('photoAssetAvailable')<sup>12+</sup>
2722
2723off(type: 'photoAssetAvailable', callback?: AsyncCallback\<photoAccessHelper.PhotoAsset\>): void
2724
2725Unsubscribes from photo asset available events.
2726
2727**System capability**: SystemCapability.Multimedia.Camera.Core
2728
2729**Parameters**
2730
2731| Name    | Type     | Mandatory | Description                                                                        |
2732| -------- | ---------- |-----|----------------------------------------------------------------------------|
2733| type     | string     | Yes  | Event type. The value is fixed at **'photoAssetAvailable'**. The event can be listened for when a **photoOutput** instance is created.                        |
2734| callback | AsyncCallback\<[photoAccessHelper.PhotoAsset](../apis-media-library-kit/js-apis-photoAccessHelper.md#photoasset)\> | No  | Callback used for unsubscription. If this parameter is specified, the subscription to the specified event with the specified callback is canceled. (The callback object cannot be an anonymous function.) Otherwise, the subscriptions to the specified event with all the callbacks are canceled.|
2735
2736**Example**
2737
2738```ts
2739function offPhotoOutputPhotoAssetAvailable(photoOutput: camera.PhotoOutput): void {
2740  photoOutput.off('photoAssetAvailable');
2741}
2742```
2743
2744### isMirrorSupported
2745
2746isMirrorSupported(): boolean
2747
2748Checks whether mirror photography is supported.
2749
2750**System capability**: SystemCapability.Multimedia.Camera.Core
2751
2752**Return value**
2753
2754| Type           | Description                    |
2755| -------------- | ----------------------- |
2756| boolean | **true**: Mirror photography is supported.<br>**false**: Mirror photography is not supported.|
2757
2758**Example**
2759
2760```ts
2761function isMirrorSupported(photoOutput: camera.PhotoOutput): boolean {
2762  let isSupported: boolean = photoOutput.isMirrorSupported();
2763  return isSupported;
2764}
2765```
2766
2767### enableMirror<sup>13+</sup>
2768
2769enableMirror(enabled: boolean): void
2770
2771Enables mirror photography.
2772
2773**System capability**: SystemCapability.Multimedia.Camera.Core
2774
2775**Parameters**
2776
2777| Name     | Type                   | Mandatory| Description                       |
2778|----------| ---------------------- | ---- |---------------------------|
2779| enabled | boolean                | Yes  | Whether to enable mirror photography. The value **true** means to enable it, and **false** means to diable it.|
2780
2781**Error codes**
2782
2783For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
2784
2785| ID   | Error Message                                          |
2786| -------- |------------------------------------------------|
2787| 7400101  | Parameter missing or parameter type incorrect. |
2788| 7400103  | Session not config.                    |
2789| 7400201  | Camera service fatal error.            |
2790
2791
2792**Example**
2793
2794```ts
2795import { BusinessError } from '@kit.BasicServicesKit';
2796
2797function enableMirror(photoOutput: camera.PhotoOutput): void {
2798  try {
2799    photoOutput.enableMirror(true);
2800  } catch (error) {
2801    // If the operation fails, error.code is returned and processed.
2802    let err = error as BusinessError;
2803    console.error(`The enableMirror call failed. error code: ${err.code}`);
2804  }
2805}
2806```
2807
2808### getSupportedMovingPhotoVideoCodecTypes<sup>13+</sup>
2809
2810getSupportedMovingPhotoVideoCodecTypes(): Array\<VideoCodecType\>
2811
2812Obtains the supported video codec types of moving photos.
2813
2814**System capability**: SystemCapability.Multimedia.Camera.Core
2815
2816**Return value**
2817
2818| Type           | Description               |
2819| -------------- |-------------------|
2820| Array\<[VideoCodecType](#videocodectype13)\> | Array holding the supported video codec types.|
2821
2822**Error codes**
2823
2824For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
2825
2826| ID       | Error Message                     |
2827| --------------- | ---------------               |
2828| 7400201         |  Camera service fatal error.  |
2829
2830**Example**
2831
2832```ts
2833function getSupportedMovingPhotoVideoCodecType(photoOutput: camera.PhotoOutput): Array<camera.VideoCodecType> {
2834  let supportedVideoCodecTypesArray: Array<camera.VideoCodecType> = photoOutput.getSupportedMovingPhotoVideoCodecTypes();
2835  return supportedVideoCodecTypesArray;
2836}
2837```
2838
2839### setMovingPhotoVideoCodecType<sup>13+</sup>
2840
2841setMovingPhotoVideoCodecType(codecType: VideoCodecType): void
2842
2843Sets a video codec type for moving photos.
2844
2845**System capability**: SystemCapability.Multimedia.Camera.Core
2846
2847**Parameters**
2848
2849| Name       | Type                                 | Mandatory|  Description               |
2850| ------------- |-------------------------------------|-------| ------------        |
2851| codecType     | [VideoCodecType](#videocodectype13) |  Yes   |Video codec type. |
2852
2853**Error codes**
2854
2855For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
2856
2857| ID       | Error Message                     |
2858| --------------- | ---------------               |
2859| 7400201         |  Camera service fatal error.  |
2860
2861**Example**
2862
2863```ts
2864function setMovingPhotoVideoCodecTypes(photoOutput: camera.PhotoOutput, videoCodecType: camera.VideoCodecType): void {
2865   photoOutput.setMovingPhotoVideoCodecType(videoCodecType);
2866}
2867```
2868
2869### on('captureStart')<sup>(deprecated)</sup>
2870
2871on(type: 'captureStart', callback: AsyncCallback\<number\>): void
2872
2873Subscribes to capture start events. This API uses an asynchronous callback to return the result.
2874
2875> **NOTE**
2876> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [on('captureStartWithInfo')](#oncapturestartwithinfo11) instead.
2877>
2878> Currently, you cannot use **off()** to unregister the callback in the callback method of **on()**.
2879
2880**System capability**: SystemCapability.Multimedia.Camera.Core
2881
2882**Parameters**
2883
2884| Name     | Type                   | Mandatory| Description                                      |
2885| -------- | ---------------------- | ---- | ------------------------------------------ |
2886| type     | string                 | Yes  | Event type. The value is fixed at **'captureStart'**. The event can be listened for when a **photoOutput** instance is created. This event is triggered and returned when the bottom layer starts exposure each time a photo is taken.|
2887| callback | AsyncCallback\<number\> | Yes  | Callback used to return the capture ID.           |
2888
2889**Example**
2890
2891```ts
2892import { BusinessError } from '@kit.BasicServicesKit';
2893
2894function callback(err: BusinessError, captureId: number): void {
2895  if (err !== undefined && err.code !== 0) {
2896    console.error(`Callback Error, errorCode: ${err.code}`);
2897    return;
2898  }
2899  console.info(`photo capture started, captureId : ${captureId}`);
2900}
2901
2902function registerPhotoOutputCaptureStart(photoOutput: camera.PhotoOutput): void {
2903  photoOutput.on('captureStart', callback);
2904}
2905```
2906
2907### off('captureStart')<sup>(deprecated)</sup>
2908
2909off(type: 'captureStart', callback?: AsyncCallback\<number\>): void
2910
2911Unsubscribes from capture start events.
2912
2913> **NOTE**
2914> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [off('captureStartWithInfo')](#offcapturestartwithinfo11) instead.
2915>
2916> Currently, you cannot use **off()** to unregister the callback in the callback method of **on()**.
2917
2918**System capability**: SystemCapability.Multimedia.Camera.Core
2919
2920**Parameters**
2921
2922| Name     | Type                   | Mandatory| Description                                      |
2923| -------- | ---------------------- | ---- | ------------------------------------------ |
2924| type     | string                 | Yes  | Event type. The value is fixed at **'captureStart'**. The event can be listened for when a **photoOutput** instance is created.|
2925| callback | AsyncCallback\<number\> | No  | Callback used to return the result. If this parameter is specified, the subscription to the specified event with the specified callback is canceled. (The callback object cannot be an anonymous function.) Otherwise, the subscriptions to the specified event with all the callbacks are canceled.|
2926
2927**Example**
2928
2929```ts
2930function unregisterPhotoOutputCaptureStart(photoOutput: camera.PhotoOutput): void {
2931  photoOutput.off('captureStart');
2932}
2933```
2934
2935### on('frameShutter')
2936
2937on(type: 'frameShutter', callback: AsyncCallback\<FrameShutterInfo\>): void
2938
2939Subscribes to frame shutter events. This API uses an asynchronous callback to return the result.
2940
2941**System capability**: SystemCapability.Multimedia.Camera.Core
2942
2943**Parameters**
2944
2945| Name    | Type     | Mandatory| Description                                 |
2946| -------- | ---------- | --- | ------------------------------------ |
2947| type     | string     | Yes  | Event type. The value is fixed at **'frameShutter'**. The event can be listened for when a **photoOutput** instance is created.|
2948| callback | AsyncCallback\<[FrameShutterInfo](#frameshutterinfo)\> | Yes  | Callback used to return the result. A new photographing request can be delivered as long as this event is returned.            |
2949
2950**Example**
2951
2952```ts
2953import { BusinessError } from '@kit.BasicServicesKit';
2954
2955function callback(err: BusinessError, frameShutterInfo: camera.FrameShutterInfo): void {
2956  if (err !== undefined && err.code !== 0) {
2957    console.error(`Callback Error, errorCode: ${err.code}`);
2958    return;
2959  }
2960  console.info(`CaptureId for frame : ${frameShutterInfo.captureId}`);
2961  console.info(`Timestamp for frame : ${frameShutterInfo.timestamp}`);
2962}
2963
2964function registerPhotoOutputFrameShutter(photoOutput: camera.PhotoOutput): void {
2965  photoOutput.on('frameShutter', callback);
2966}
2967```
2968
2969### off('frameShutter')
2970
2971off(type: 'frameShutter', callback?: AsyncCallback\<FrameShutterInfo\>): void
2972
2973Unsubscribes from frame shutter events.
2974
2975**System capability**: SystemCapability.Multimedia.Camera.Core
2976
2977**Parameters**
2978
2979| Name    | Type     | Mandatory| Description                                 |
2980| -------- | ---------- | --- | ------------------------------------ |
2981| type     | string     | Yes  | Event type. The value is fixed at **'frameShutter'**. The event can be listened for when a **photoOutput** instance is created.|
2982| callback | AsyncCallback\<[FrameShutterInfo](#frameshutterinfo)\> | No  | Callback used to return the result. If this parameter is specified, the subscription to the specified event with the specified callback is canceled. (The callback object cannot be an anonymous function.) Otherwise, the subscriptions to the specified event with all the callbacks are canceled.|
2983
2984**Example**
2985
2986```ts
2987function unregisterPhotoOutputFrameShutter(photoOutput: camera.PhotoOutput): void {
2988  photoOutput.off('frameShutter');
2989}
2990```
2991
2992### on('captureEnd')
2993
2994on(type: 'captureEnd', callback: AsyncCallback\<CaptureEndInfo\>): void
2995
2996Subscribes to capture end events. This API uses an asynchronous callback to return the result.
2997
2998> **NOTE**
2999>
3000> Currently, you cannot use **off()** to unregister the callback in the callback method of **on()**.
3001
3002**System capability**: SystemCapability.Multimedia.Camera.Core
3003
3004**Parameters**
3005
3006| Name    | Type          | Mandatory| Description                                      |
3007| -------- | --------------- | ---- | ---------------------------------------- |
3008| type     | string          | Yes  | Event type. The value is fixed at **'captureEnd'**. The event can be listened for when a **photoOutput** instance is created. This event is triggered and the corresponding information is returned when the photographing is complete.|
3009| callback | AsyncCallback\<[CaptureEndInfo](#captureendinfo)\> | Yes  | Callback used to return the result.                 |
3010
3011**Example**
3012
3013```ts
3014import { BusinessError } from '@kit.BasicServicesKit';
3015
3016function callback(err: BusinessError, captureEndInfo: camera.CaptureEndInfo): void {
3017  if (err !== undefined && err.code !== 0) {
3018    console.error(`Callback Error, errorCode: ${err.code}`);
3019    return;
3020  }
3021  console.info(`photo capture end, captureId : ${captureEndInfo.captureId}`);
3022  console.info(`frameCount : ${captureEndInfo.frameCount}`);
3023}
3024
3025function registerPhotoOutputCaptureEnd(photoOutput: camera.PhotoOutput): void {
3026  photoOutput.on('captureEnd', callback);
3027}
3028```
3029
3030### off('captureEnd')
3031
3032off(type: 'captureEnd', callback?: AsyncCallback\<CaptureEndInfo\>): void
3033
3034Unsubscribes from capture end events.
3035
3036**System capability**: SystemCapability.Multimedia.Camera.Core
3037
3038**Parameters**
3039
3040| Name    | Type          | Mandatory| Description                                      |
3041| -------- | --------------- | ---- | ---------------------------------------- |
3042| type     | string          | Yes  | Event type. The value is fixed at **'captureEnd'**. The event can be listened for when a **photoOutput** instance is created.|
3043| callback | AsyncCallback\<[CaptureEndInfo](#captureendinfo)\> | No  | Callback used to return the result. If this parameter is specified, the subscription to the specified event with the specified callback is canceled. (The callback object cannot be an anonymous function.) Otherwise, the subscriptions to the specified event with all the callbacks are canceled.|
3044
3045**Example**
3046
3047```ts
3048function unregisterPhotoOutputCaptureEnd(photoOutput: camera.PhotoOutput): void {
3049  photoOutput.off('captureEnd');
3050}
3051```
3052
3053### on('frameShutterEnd')<sup>12+</sup>
3054
3055on(type: 'frameShutterEnd', callback: AsyncCallback\<FrameShutterEndInfo\>): void
3056
3057Subscribes to frame shutter end events. This API uses an asynchronous callback to return the result.
3058
3059> **NOTE**
3060>
3061> Currently, you cannot use **off()** to unregister the callback in the callback method of **on()**.
3062
3063**System capability**: SystemCapability.Multimedia.Camera.Core
3064
3065**Parameters**
3066
3067| Name  | Type                                                        | Mandatory| Description                                                        |
3068| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
3069| type     | string                                                       | Yes  | Event type. The value is fixed at **'frameShutterEnd'**. The event can be listened for when a **photoOutput** instance is created.|
3070| callback | AsyncCallback\<[FrameShutterEndInfo](#frameshutterendinfo12)\> | Yes  | Callback used to return the result. It is invoked when the frame shutter ends.  |
3071
3072**Example**
3073
3074```ts
3075import { BusinessError } from '@kit.BasicServicesKit';
3076
3077function callback(err: BusinessError, frameShutterEndInfo: camera.FrameShutterEndInfo): void {
3078  if (err !== undefined && err.code !== 0) {
3079    console.error(`Callback Error, errorCode: ${err.code}`);
3080    return;
3081  }
3082  console.info(`CaptureId for frame : ${frameShutterEndInfo.captureId}`);
3083}
3084
3085function registerPhotoOutputFrameShutterEnd(photoOutput: camera.PhotoOutput): void {
3086  photoOutput.on('frameShutterEnd', callback);
3087}
3088```
3089
3090### off('frameShutterEnd')<sup>12+</sup>
3091
3092off(type: 'frameShutterEnd', callback?: AsyncCallback\<FrameShutterEndInfo\>): void
3093
3094Unsubscribes from frame shutter end events.
3095
3096**System capability**: SystemCapability.Multimedia.Camera.Core
3097
3098**Parameters**
3099
3100| Name  | Type                                                        | Mandatory| Description                                                        |
3101| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
3102| type     | string                                                       | Yes  | Event type. The value is fixed at **'frameShutterEnd'**. The event can be listened for when a **photoOutput** instance is created.|
3103| callback | AsyncCallback\<[FrameShutterEndInfo](#frameshutterendinfo12)\> | No  | Callback used to return the result. If this parameter is specified, the subscription to the specified event with the specified callback is canceled. (The callback object cannot be an anonymous function.) Otherwise, the subscriptions to the specified event with all the callbacks are canceled.|
3104
3105**Example**
3106
3107```ts
3108function unregisterPhotoOutputFrameShutterEnd(photoOutput: camera.PhotoOutput): void {
3109  photoOutput.off('frameShutterEnd');
3110}
3111```
3112
3113### on('captureReady')<sup>12+</sup>
3114
3115on(type: 'captureReady', callback: AsyncCallback\<void\>): void
3116
3117Subscribes to capture ready events. This API uses an asynchronous callback to return the result.
3118
3119> **NOTE**
3120>
3121> Currently, you cannot use **off()** to unregister the callback in the callback method of **on()**.
3122
3123**System capability**: SystemCapability.Multimedia.Camera.Core
3124
3125**Parameters**
3126
3127| Name  | Type                 | Mandatory| Description                                                        |
3128| -------- | --------------------- | ---- | ------------------------------------------------------------ |
3129| type     | string                | Yes  | Event type. The value is fixed at **'captureReady'**. The event can be listened for when a **photoOutput** instance is created. The event is triggered and the corresponding information is returned when it is ready to take the next photo.|
3130| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.                                |
3131
3132**Example**
3133
3134```ts
3135import { BusinessError } from '@kit.BasicServicesKit';
3136
3137function callback(err: BusinessError): void {
3138  if (err !== undefined && err.code !== 0) {
3139    console.error(`Callback Error, errorCode: ${err.code}`);
3140    return;
3141  }
3142  console.info(`photo capture ready`);
3143}
3144
3145function registerPhotoOutputCaptureReady(photoOutput: camera.PhotoOutput): void {
3146  photoOutput.on('captureReady', callback);
3147}
3148```
3149
3150### off('captureReady')<sup>12+</sup>
3151
3152off(type: 'captureReady', callback?: AsyncCallback\<void\>): void
3153
3154Unsubscribes from capture ready events.
3155
3156**System capability**: SystemCapability.Multimedia.Camera.Core
3157
3158**Parameters**
3159
3160| Name  | Type                                                | Mandatory| Description                                                        |
3161| -------- | ---------------------------------------------------- | ---- | ------------------------------------------------------------ |
3162| type     | string                                               | Yes  | Event type. The value is fixed at **'captureReady'**. The event can be listened for when a **photoOutput** instance is created.|
3163| callback | AsyncCallback\<[CaptureReadyInfo](#captureendinfo)\> | No  | Callback used to return the result. If this parameter is specified, the subscription to the specified event with the specified callback is canceled. (The callback object cannot be an anonymous function.) Otherwise, the subscriptions to the specified event with all the callbacks are canceled.|
3164
3165**Example**
3166
3167```ts
3168function unregisterPhotoOutputCaptureReady(photoOutput: camera.PhotoOutput): void {
3169  photoOutput.off('captureReady');
3170}
3171```
3172
3173### on('estimatedCaptureDuration')<sup>12+</sup>
3174
3175on(type: 'estimatedCaptureDuration', callback: AsyncCallback\<number\>): void
3176
3177Subscribes to estimated capture duration events. This API uses an asynchronous callback to return the result.
3178
3179> **NOTE**
3180>
3181> Currently, you cannot use **off()** to unregister the callback in the callback method of **on()**.
3182
3183**System capability**: SystemCapability.Multimedia.Camera.Core
3184
3185**Parameters**
3186
3187| Name  | Type                  | Mandatory| Description                                                        |
3188| -------- | ---------------------- | ---- | ------------------------------------------------------------ |
3189| type     | string                 | Yes  | Event type. The value is fixed at **'estimatedCaptureDuration'**. The event can be listened for when a **photoOutput** instance is created. This event is triggered and the corresponding information is returned when the photographing is complete.|
3190| callback | AsyncCallback\<number> | Yes  | Callback used to return the estimated duration when the sensor captures frames at the bottom layer in a single capture. If **–1** is reported, there is no estimated duration.                                |
3191
3192**Example**
3193
3194```ts
3195import { BusinessError } from '@kit.BasicServicesKit';
3196
3197function callback(err: BusinessError, duration: number): void {
3198  if (err !== undefined && err.code !== 0) {
3199    console.error(`Callback Error, errorCode: ${err.code}`);
3200    return;
3201  }
3202  console.info(`photo estimated capture duration : ${duration}`);
3203}
3204
3205function registerPhotoOutputEstimatedCaptureDuration(photoOutput: camera.PhotoOutput): void {
3206  photoOutput.on('estimatedCaptureDuration', callback);
3207}
3208```
3209
3210### off('estimatedCaptureDuration')<sup>12+</sup>
3211
3212off(type: 'estimatedCaptureDuration', callback?: AsyncCallback\<number\>): void
3213
3214Unsubscribes from estimated capture duration events.
3215
3216**System capability**: SystemCapability.Multimedia.Camera.Core
3217
3218**Parameters**
3219
3220| Name  | Type                   | Mandatory| Description                                                        |
3221| -------- | ----------------------- | ---- | ------------------------------------------------------------ |
3222| type     | string                  | Yes  | Event type. The value is fixed at **'estimatedCaptureDuration'**. The event can be listened for when a **photoOutput** instance is created.|
3223| callback | AsyncCallback\<number\> | No  | Callback used to return the result. If this parameter is specified, the subscription to the specified event with the specified callback is canceled. (The callback object cannot be an anonymous function.) Otherwise, the subscriptions to the specified event with all the callbacks are canceled.|
3224
3225**Example**
3226
3227```ts
3228function unregisterPhotoOutputEstimatedCaptureDuration(photoOutput: camera.PhotoOutput): void {
3229  photoOutput.off('estimatedCaptureDuration');
3230}
3231```
3232
3233### on('error')
3234
3235on(type: 'error', callback: ErrorCallback): void
3236
3237Subscribes to **PhotoOutput** error events. This API uses an asynchronous callback to return the result.
3238
3239> **NOTE**
3240>
3241> Currently, you cannot use **off()** to unregister the callback in the callback method of **on()**.
3242
3243**System capability**: SystemCapability.Multimedia.Camera.Core
3244
3245**Parameters**
3246
3247| Name    | Type        | Mandatory| Description                                |
3248| -------- | ------------- | ---- | ----------------------------------- |
3249| type     | string       | Yes  | Event type. The value is fixed at **'error'**. The event can be listened for when a **photoOutput** instance is created. This event is triggered and the corresponding error message is returned when an error occurs during the calling of a photo-related API.|
3250| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback) | Yes  | Callback used to return an error code defined in [CameraErrorCode](#cameraerrorcode).            |
3251
3252**Example**
3253
3254```ts
3255import { BusinessError } from '@kit.BasicServicesKit';
3256
3257function callback(err: BusinessError): void {
3258  console.error(`Photo output error code: ${err.code}`);
3259}
3260
3261function registerPhotoOutputError(photoOutput: camera.PhotoOutput): void {
3262  photoOutput.on('error', callback);
3263}
3264```
3265
3266### off('error')
3267
3268off(type: 'error', callback?: ErrorCallback): void
3269
3270Unsubscribes from **PhotoOutput** error events.
3271
3272**System capability**: SystemCapability.Multimedia.Camera.Core
3273
3274**Parameters**
3275
3276| Name    | Type        | Mandatory| Description                                |
3277| -------- | ------------- | ---- | ----------------------------------- |
3278| type     | string       | Yes  | Event type. The value is fixed at **'error'**. The event can be listened for when a **photoOutput** instance is created.|
3279| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback) | No  | Callback used to return the result. If this parameter is specified, the subscription to the specified event with the specified callback is canceled. (The callback object cannot be an anonymous function.) Otherwise, the subscriptions to the specified event with all the callbacks are canceled.|
3280
3281**Example**
3282
3283```ts
3284function unregisterPhotoOutputError(photoOutput: camera.PhotoOutput): void {
3285  photoOutput.off('error');
3286}
3287```
3288
3289### getActiveProfile<sup>12+</sup>
3290
3291getActiveProfile(): Profile
3292
3293Obtains the profile that takes effect currently.
3294
3295**System capability**: SystemCapability.Multimedia.Camera.Core
3296
3297**Return value**
3298
3299|      Type     | Description       |
3300| -------------  |-----------|
3301| [Profile](#profile) | Profile obtained.|
3302
3303**Error codes**
3304
3305For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
3306
3307| ID  | Error Message                        |
3308|---------|------------------------------|
3309| 7400201 | Camera service fatal error.  |
3310
3311**Example**
3312
3313```ts
3314function testGetActiveProfile(photoOutput: camera.PhotoOutput): camera.Profile | undefined {
3315  let activeProfile: camera.Profile | undefined = undefined;
3316  try {
3317    activeProfile = photoOutput.getActiveProfile();
3318  } catch (error) {
3319    // If the operation fails, error.code is returned and processed.
3320    let err = error as BusinessError;
3321    console.error(`The photoOutput.getActiveProfile call failed. error code: ${err.code}`);
3322  }
3323  return activeProfile;
3324}
3325```
3326### getPhotoRotation<sup>12+</sup>
3327
3328getPhotoRotation(deviceDegree: number): ImageRotation
3329
3330Obtains the photo rotation degree.
3331
3332- Device' natural orientation: The default orientation of the device (phone) is in portrait mode, with the charging port facing downward.
3333- Camera lens angle: equivalent to the angle at which the camera is rotated clockwise to match the device's natural direction. The rear camera sensor of a phone is installed in landscape mode. Therefore, it needs to be rotated by 90 degrees clockwise to match the device's natural direction.
3334- Screen orientation: The upper left corner of the image displayed on the screen is the first pixel, which is the coordinate origin. In the case of lock screen, the direction is the same as the device's natural orientation.
3335
3336**System capability**: SystemCapability.Multimedia.Camera.Core
3337
3338**Parameters**
3339
3340| Name    | Type        | Mandatory| Description                      |
3341| -------- | --------------| ---- | ------------------------ |
3342| deviceDegree | number | Yes  | Rotation angle.|
3343
3344**Return value**
3345
3346|      Type     | Description       |
3347| -------------  |-----------|
3348| [ImageRotation](#imagerotation) | Photo rotation degree.|
3349
3350**Error codes**
3351
3352For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
3353
3354| ID  | Error Message                        |
3355|---------|------------------------------|
3356| 7400101 | Parameter missing or parameter type incorrect.  |
3357| 7400201 | Camera service fatal error.  |
3358
3359**Example**
3360
3361```ts
3362function testGetPhotoRotation(photoOutput: camera.PhotoOutput, deviceDegree : number): camera.ImageRotation {
3363  let photoRotation: camera.ImageRotation = camera.ImageRotation.ROTATION_0;
3364  try {
3365    photoRotation = photoOutput.getPhotoRotation(deviceDegree);
3366    console.log(`Photo rotation is: ${photoRotation}`);
3367  } catch (error) {
3368    // If the operation fails, error.code is returned and processed.
3369    let err = error as BusinessError;
3370    console.error(`The photoOutput.getPhotoRotation call failed. error code: ${err.code}`);
3371  }
3372  return photoRotation;
3373}
3374```
3375
3376## FrameShutterInfo
3377
3378Defines the frame shutter information.
3379
3380**System capability**: SystemCapability.Multimedia.Camera.Core
3381
3382| Name      | Type  | Read-only| Optional| Description       |
3383| --------- | ------ | ---- | ---- | ---------- |
3384| captureId | number | No  | No  | ID of this capture action. |
3385| timestamp | number | No  | No  | Timestamp when the frame shutter event is triggered.|
3386
3387## FrameShutterEndInfo<sup>12+</sup>
3388
3389Describes the frame shutter end information during capture.
3390
3391**System capability**: SystemCapability.Multimedia.Camera.Core
3392
3393| Name     | Type  | Read-only| Optional| Description      |
3394| --------- | ------ | ---- | ---- | ---------- |
3395| captureId | number | No  | No  | ID of this capture action.|
3396
3397## CaptureStartInfo<sup>11+</sup>
3398
3399Defines the capture start information.
3400
3401**System capability**: SystemCapability.Multimedia.Camera.Core
3402
3403| Name      | Type   | Read-only| Optional| Description      |
3404| ---------- | ------ | ---- | ---- | --------- |
3405| captureId  | number | No  | No  | ID of this capture action.|
3406| time       | number | No  | No  | Estimated duration when the sensor captures frames at the bottom layer in a single capture. If **–1** is reported, there is no estimated duration.   |
3407
3408## CaptureEndInfo
3409
3410Defines the capture end information.
3411
3412**System capability**: SystemCapability.Multimedia.Camera.Core
3413
3414| Name      | Type   | Read-only| Optional| Description      |
3415| ---------- | ------ | ---- | ---- | ---------|
3416| captureId  | number | No  | No  | ID of this capture action.|
3417| frameCount | number | No  | No  | Number of frames captured.   |
3418
3419## AutoDeviceSwitchStatus<sup>13+</sup>
3420
3421Describes the information about the automatic camera switch status.
3422
3423**System capability**: SystemCapability.Multimedia.Camera.Core
3424
3425| Name      | Type     | Read-only| Optional| Description                     |
3426| ---------- |---------| ---- | ---- |-------------------------|
3427| isDeviceSwitched  | boolean | No  | No  | Whether the camera is automatically switched.            |
3428| isDeviceCapabilityChanged | boolean  | No  | No  | Whether the camera capability is changed after the camera is automatically switched.|
3429
3430## VideoOutput
3431
3432Implements output information used in a video session. It inherits from [CameraOutput](#cameraoutput).
3433
3434### start
3435
3436start(callback: AsyncCallback\<void\>): void
3437
3438Starts video recording. This API uses an asynchronous callback to return the result.
3439
3440**System capability**: SystemCapability.Multimedia.Camera.Core
3441
3442**Parameters**
3443
3444| Name     | Type                 | Mandatory| Description                |
3445| -------- | -------------------- | ---- | -------------------- |
3446| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
3447
3448**Error codes**
3449
3450For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
3451
3452| ID        | Error Message       |
3453| --------------- | --------------- |
3454| 7400103                |  Session not config.                                   |
3455| 7400201                |  Camera service fatal error.                           |
3456
3457**Example**
3458
3459```ts
3460import { BusinessError } from '@kit.BasicServicesKit';
3461
3462function startVideoOutput(videoOutput: camera.VideoOutput): void {
3463  videoOutput.start((err: BusinessError) => {
3464    if (err) {
3465      console.error(`Failed to start the video output, error code: ${err.code}.`);
3466      return;
3467    }
3468    console.info('Callback invoked to indicate the video output start success.');
3469  });
3470}
3471```
3472
3473### start
3474
3475start(): Promise\<void\>
3476
3477Starts video recording. This API uses a promise to return the result.
3478
3479**System capability**: SystemCapability.Multimedia.Camera.Core
3480
3481**Return value**
3482
3483| Type           | Description                    |
3484| -------------- | ----------------------- |
3485| Promise\<void\> | Promise that returns no value.|
3486
3487**Error codes**
3488
3489For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
3490
3491| ID        | Error Message       |
3492| --------------- | --------------- |
3493| 7400103                |  Session not config.                                   |
3494| 7400201                |  Camera service fatal error.                           |
3495
3496**Example**
3497
3498```ts
3499import { BusinessError } from '@kit.BasicServicesKit';
3500
3501function startVideoOutput(videoOutput: camera.VideoOutput): void {
3502  videoOutput.start().then(() => {
3503    console.info('Promise returned to indicate that start method execution success.');
3504  }).catch((error: BusinessError) => {
3505    console.error(`Failed to video output start, error code: ${error.code}.`);
3506  });
3507}
3508```
3509
3510### stop
3511
3512stop(callback: AsyncCallback\<void\>): void
3513
3514Stops video recording. This API uses an asynchronous callback to return the result.
3515
3516**System capability**: SystemCapability.Multimedia.Camera.Core
3517
3518**Parameters**
3519
3520| Name    | Type                | Mandatory| Description                    |
3521| -------- | -------------------- | ---- | ------------------------ |
3522| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
3523
3524**Example**
3525
3526```ts
3527import { BusinessError } from '@kit.BasicServicesKit';
3528
3529function stopVideoOutput(videoOutput: camera.VideoOutput): void {
3530  videoOutput.stop((err: BusinessError) => {
3531    if (err) {
3532      console.error(`Failed to stop the video output, error code: ${err.code}.`);
3533      return;
3534    }
3535    console.info('Callback invoked to indicate the video output stop success.');
3536  });
3537}
3538```
3539
3540### stop
3541
3542stop(): Promise\<void\>
3543
3544Stops video recording. This API uses a promise to return the result.
3545
3546**System capability**: SystemCapability.Multimedia.Camera.Core
3547
3548**Return value**
3549
3550| Type           | Description                    |
3551| -------------- | ----------------------- |
3552| Promise\<void\> | Promise that returns no value.|
3553
3554**Example**
3555
3556```ts
3557import { BusinessError } from '@kit.BasicServicesKit';
3558
3559function stopVideoOutput(videoOutput: camera.VideoOutput): void {
3560  videoOutput.stop().then(() => {
3561    console.info('Promise returned to indicate that stop method execution success.');
3562  }).catch((error: BusinessError) => {
3563    console.error(`Failed to video output stop, error code: ${error.code}.`);
3564  });
3565}
3566```
3567
3568### on('frameStart')
3569
3570on(type: 'frameStart', callback: AsyncCallback\<void\>): void
3571
3572Subscribes to video recording start events. This API uses an asynchronous callback to return the result.
3573
3574> **NOTE**
3575>
3576> Currently, you cannot use **off()** to unregister the callback in the callback method of **on()**.
3577
3578**System capability**: SystemCapability.Multimedia.Camera.Core
3579
3580**Parameters**
3581
3582| Name     | Type                 | Mandatory| Description                                      |
3583| -------- | -------------------- | ---- | ----------------------------------------- |
3584| type     | string               | Yes  | Event type. The value is fixed at **'frameStart'**. The event can be listened for when a **videoOutput** instance is created. The event is triggered and the corresponding information is returned when the bottom layer starts exposure for the first time.|
3585| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.  The recording starts as long as this event is returned.                    |
3586
3587**Example**
3588
3589```ts
3590import { BusinessError } from '@kit.BasicServicesKit';
3591
3592function callback(err: BusinessError): void {
3593  if (err !== undefined && err.code !== 0) {
3594    console.error(`Callback Error, errorCode: ${err.code}`);
3595    return;
3596  }
3597  console.info('Video frame started');
3598}
3599
3600function registerVideoOutputFrameStart(videoOutput: camera.VideoOutput): void {
3601  videoOutput.on('frameStart', callback);
3602}
3603```
3604
3605### off('frameStart')
3606
3607off(type: 'frameStart', callback?: AsyncCallback\<void\>): void
3608
3609Unsubscribes from video recording start events.
3610
3611> **NOTE**
3612>
3613> Currently, you cannot use **off()** to unregister the callback in the callback method of **on()**.
3614
3615**System capability**: SystemCapability.Multimedia.Camera.Core
3616
3617**Parameters**
3618
3619| Name     | Type                 | Mandatory| Description                                      |
3620| -------- | -------------------- | ---- | ----------------------------------------- |
3621| type     | string               | Yes  | Event type. The value is fixed at **'frameStart'**. The event can be listened for when a **videoOutput** instance is created.|
3622| callback | AsyncCallback\<void\> | No  | Callback used to return the result. If this parameter is specified, the subscription to the specified event with the specified callback is canceled. (The callback object cannot be an anonymous function.) Otherwise, the subscriptions to the specified event with all the callbacks are canceled.|
3623
3624**Example**
3625
3626```ts
3627function unregisterVideoOutputFrameStart(videoOutput: camera.VideoOutput): void {
3628  videoOutput.off('frameStart');
3629}
3630
3631```
3632
3633### on('frameEnd')
3634
3635on(type: 'frameEnd', callback: AsyncCallback\<void\>): void
3636
3637Subscribes to video recording stop events. This API uses an asynchronous callback to return the result.
3638
3639**System capability**: SystemCapability.Multimedia.Camera.Core
3640
3641**Parameters**
3642
3643| Name     | Type                 | Mandatory| Description                                      |
3644| -------- | -------------------- | ---- | ------------------------------------------ |
3645| type     | string               | Yes  | Event type. The value is fixed at **'frameEnd'**. The event can be listened for when a **videoOutput** instance is created. This event is triggered and returned when the last frame of recording is complete.|
3646| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result. The recording ends as long as this event is returned.                     |
3647
3648**Example**
3649
3650```ts
3651import { BusinessError } from '@kit.BasicServicesKit';
3652
3653function callback(err: BusinessError): void {
3654  if (err !== undefined && err.code !== 0) {
3655    console.error(`Callback Error, errorCode: ${err.code}`);
3656    return;
3657  }
3658  console.info('Video frame ended');
3659}
3660
3661function registerVideoOutputFrameEnd(videoOutput: camera.VideoOutput): void {
3662  videoOutput.on('frameEnd', callback);
3663}
3664```
3665
3666### off('frameEnd')
3667
3668off(type: 'frameEnd', callback?: AsyncCallback\<void\>): void
3669
3670Unsubscribes from video recording stop events.
3671
3672**System capability**: SystemCapability.Multimedia.Camera.Core
3673
3674**Parameters**
3675
3676| Name     | Type                 | Mandatory| Description                                      |
3677| -------- | -------------------- | ---- | ------------------------------------------ |
3678| type     | string               | Yes  | Event type. The value is fixed at **'frameEnd'**. The event can be listened for when a **videoOutput** instance is created.|
3679| callback | AsyncCallback\<void\> | No  | Callback used to return the result. If this parameter is specified, the subscription to the specified event with the specified callback is canceled. (The callback object cannot be an anonymous function.) Otherwise, the subscriptions to the specified event with all the callbacks are canceled.|
3680
3681**Example**
3682
3683```ts
3684function unregisterVideoOutputFrameEnd(videoOutput: camera.VideoOutput): void {
3685  videoOutput.off('frameEnd');
3686}
3687```
3688
3689### on('error')
3690
3691on(type: 'error', callback: ErrorCallback): void
3692
3693Subscribes to **VideoOutput** error events. This API uses an asynchronous callback to return the result.
3694
3695> **NOTE**
3696>
3697> Currently, you cannot use **off()** to unregister the callback in the callback method of **on()**.
3698
3699**System capability**: SystemCapability.Multimedia.Camera.Core
3700
3701**Parameters**
3702
3703| Name    | Type      | Mandatory| Description                                   |
3704| -------- | ----------- | ---- | -------------------------------------- |
3705| type     | string      | Yes  | Event type. The value is fixed at **'error'**. The event can be listened for when a **videoOutput** instance is created. This event is triggered and the corresponding error message is returned when an error occurs during the use of a recording-related API such as [start](#start-1) or [CameraOutput.release](#release-1).|
3706| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback) | Yes  | Callback used to return an error code defined in [CameraErrorCode](#cameraerrorcode).                |
3707
3708**Example**
3709
3710```ts
3711import { BusinessError } from '@kit.BasicServicesKit';
3712
3713function callback(err: BusinessError): void {
3714  console.error(`Video output error code: ${err.code}`);
3715}
3716
3717function registerVideoOutputError(videoOutput: camera.VideoOutput): void {
3718  videoOutput.on('error', callback);
3719}
3720```
3721
3722### off('error')
3723
3724off(type: 'error', callback?: ErrorCallback): void
3725
3726Unsubscribes from **VideoOutput** error events.
3727
3728**System capability**: SystemCapability.Multimedia.Camera.Core
3729
3730**Parameters**
3731
3732| Name    | Type        | Mandatory| Description                                |
3733| -------- | ------------- | ---- | ----------------------------------- |
3734| type     | string       | Yes  | Event type. The value is fixed at **'error'**. The event can be listened for when a **photoOutput** instance is created.|
3735| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback) | No  | Callback used to return the result. If this parameter is specified, the subscription to the specified event with the specified callback is canceled. (The callback object cannot be an anonymous function.) Otherwise, the subscriptions to the specified event with all the callbacks are canceled.|
3736
3737**Example**
3738
3739```ts
3740function unregisterVideoOutputError(videoOutput: camera.VideoOutput): void {
3741  videoOutput.off('error');
3742}
3743```
3744
3745### getSupportedFrameRates<sup>12+</sup>
3746
3747getSupportedFrameRates(): Array\<FrameRateRange\>
3748
3749Obtains the supported frame rates.
3750
3751**System capability**: SystemCapability.Multimedia.Camera.Core
3752
3753**Return value**
3754
3755|      Type     |     Description    |
3756| -------------  | ------------ |
3757| Array<[FrameRateRange](#frameraterange)> | Array of supported frame rates.|
3758
3759**Example**
3760
3761```ts
3762function getSupportedFrameRates(videoOutput: camera.VideoOutput): Array<camera.FrameRateRange> {
3763  let supportedFrameRatesArray: Array<camera.FrameRateRange> = videoOutput.getSupportedFrameRates();
3764  return supportedFrameRatesArray;
3765}
3766```
3767
3768### setFrameRate<sup>12+</sup>
3769
3770setFrameRate(minFps: number, maxFps: number): void
3771
3772Sets a frame rate range for video streams. The range must be within the supported frame rate range, which can be obtained by calling [getSupportedFrameRates](#getsupportedframerates12-1).
3773
3774> **NOTE**
3775>
3776> This API is valid only in [PhotoSession](#photosession11) or [VideoSession](#videosession11) mode.
3777
3778**System capability**: SystemCapability.Multimedia.Camera.Core
3779
3780**Parameters**
3781
3782| Name    | Type        | Mandatory| Description                      |
3783| -------- | --------------| ---- | ------------------------ |
3784| minFps   | number        | Yes  | Minimum frame rate.|
3785| maxFps   | number        | Yes  | Maximum frame rate. When the minimum value is greater than the maximum value, the API does not take effect.|
3786
3787**Error codes**
3788
3789For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
3790
3791| ID       | Error Message       |
3792| --------------- | --------------- |
3793| 7400101                |  Parameter missing or parameter type incorrect.        |
3794| 7400110                |  Unresolved conflicts with current configurations.     |
3795
3796**Example**
3797
3798```ts
3799function setFrameRateRange(videoOutput: camera.VideoOutput, frameRateRange: Array<number>): void {
3800  videoOutput.setFrameRate(frameRateRange[0], frameRateRange[1]);
3801}
3802```
3803
3804### getActiveFrameRate<sup>12+</sup>
3805
3806getActiveFrameRate(): FrameRateRange
3807
3808Obtains the configured frame rate range.
3809
3810This API is valid only after [setFrameRate](#setframerate12-1) is called to set a frame rate range for video streams.
3811
3812**System capability**: SystemCapability.Multimedia.Camera.Core
3813
3814**Return value**
3815
3816|      Type     |     Description    |
3817| -------------  | ------------ |
3818| [FrameRateRange](#frameraterange) | Frame rate range.|
3819
3820**Example**
3821
3822```ts
3823function getActiveFrameRate(videoOutput: camera.VideoOutput): camera.FrameRateRange {
3824  let activeFrameRate: camera.FrameRateRange = videoOutput.getActiveFrameRate();
3825  return activeFrameRate;
3826}
3827```
3828
3829### getActiveProfile<sup>12+</sup>
3830
3831getActiveProfile(): VideoProfile
3832
3833Obtains the profile that takes effect currently.
3834
3835**System capability**: SystemCapability.Multimedia.Camera.Core
3836
3837**Return value**
3838
3839|      Type     | Description       |
3840| -------------  |-----------|
3841| [VideoProfile](#videoprofile) | Profile obtained.|
3842
3843**Error codes**
3844
3845For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
3846
3847| ID  | Error Message                        |
3848|---------|------------------------------|
3849| 7400201 | Camera service fatal error.  |
3850
3851**Example**
3852
3853```ts
3854function testGetActiveProfile(videoOutput: camera.VideoOutput): camera.Profile | undefined {
3855  let activeProfile: camera.VideoProfile | undefined = undefined;
3856  try {
3857    activeProfile = videoOutput.getActiveProfile();
3858  } catch (error) {
3859    // If the operation fails, error.code is returned and processed.
3860    let err = error as BusinessError;
3861    console.error(`The videoOutput.getActiveProfile call failed. error code: ${err.code}`);
3862  }
3863  return activeProfile;
3864}
3865```
3866
3867### getVideoRotation<sup>12+</sup>
3868
3869getVideoRotation(deviceDegree: number): ImageRotation
3870
3871Obtains the video rotation degree.
3872
3873- Device' natural orientation: The default orientation of the device (phone) is in portrait mode, with the charging port facing downward.
3874- Camera lens angle: equivalent to the angle at which the camera is rotated clockwise to match the device's natural direction. The rear camera sensor of a phone is installed in landscape mode. Therefore, it needs to be rotated by 90 degrees clockwise to match the device's natural direction.
3875- Screen orientation: The upper left corner of the image displayed on the screen is the first pixel, which is the coordinate origin. In the case of lock screen, the direction is the same as the device's natural orientation.
3876
3877**System capability**: SystemCapability.Multimedia.Camera.Core
3878
3879**Parameters**
3880
3881| Name    | Type        | Mandatory| Description                      |
3882| -------- | --------------| ---- | ------------------------ |
3883| deviceDegree | number | Yes  | Rotation angle.|
3884
3885**Return value**
3886
3887|      Type     | Description       |
3888| -------------  |-----------|
3889| [ImageRotation](#imagerotation) | Video rotation degree.|
3890
3891**Error codes**
3892
3893For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
3894
3895| ID  | Error Message                        |
3896|---------|------------------------------|
3897| 7400101 | Parameter missing or parameter type incorrect.  |
3898| 7400201 | Camera service fatal error.  |
3899
3900**Example**
3901
3902```ts
3903function testGetVideoRotation(videoOutput: camera.VideoOutput, deviceDegree : number): camera.ImageRotation {
3904  let videoRotation: camera.ImageRotation = camera.ImageRotation.ROTATION_0;
3905  try {
3906    videoRotation = videoOutput.getVideoRotation(deviceDegree);
3907    console.log(`Video rotation is: ${videoRotation}`);
3908  } catch (error) {
3909    // If the operation fails, error.code is returned and processed.
3910    let err = error as BusinessError;
3911    console.error(`The videoOutput.getVideoRotation call failed. error code: ${err.code}`);
3912  }
3913  return videoRotation;
3914}
3915```
3916
3917## MetadataOutput
3918
3919Implements metadata streams. It inherits from [CameraOutput](#cameraoutput).
3920
3921### start
3922
3923start(callback: AsyncCallback\<void\>): void
3924
3925Starts to output metadata. This API uses an asynchronous callback to return the result.
3926
3927**System capability**: SystemCapability.Multimedia.Camera.Core
3928
3929**Parameters**
3930
3931| Name    | Type                                                        | Mandatory| Description                |
3932| -------- | -------------------------- | ---- | ------------------- |
3933| callback | AsyncCallback\<void\>       | Yes  | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
3934
3935**Error codes**
3936
3937For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
3938
3939| ID        | Error Message       |
3940| --------------- | --------------- |
3941| 7400103                |  Session not config.                                   |
3942| 7400201                |  Camera service fatal error.                           |
3943
3944**Example**
3945
3946```ts
3947import { BusinessError } from '@kit.BasicServicesKit';
3948
3949function startMetadataOutput(metadataOutput: camera.MetadataOutput): void {
3950  metadataOutput.start((err: BusinessError) => {
3951    if (err) {
3952      console.error(`Failed to start metadata output, error code: ${err.code}.`);
3953      return;
3954    }
3955    console.info('Callback returned with metadata output started.');
3956  });
3957}
3958```
3959
3960### start
3961
3962start(): Promise\<void\>
3963
3964Starts to output metadata. This API uses a promise to return the result.
3965
3966**System capability**: SystemCapability.Multimedia.Camera.Core
3967
3968**Return value**
3969
3970| Type                    | Description                    |
3971| ----------------------  | ------------------------ |
3972| Promise\<void\>          | Promise that returns no value.|
3973
3974**Error codes**
3975
3976For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
3977
3978| ID        | Error Message       |
3979| --------------- | --------------- |
3980| 7400103                |  Session not config.                                   |
3981| 7400201                |  Camera service fatal error.                           |
3982
3983**Example**
3984
3985```ts
3986import { BusinessError } from '@kit.BasicServicesKit';
3987
3988function startMetadataOutput(metadataOutput: camera.MetadataOutput): void {
3989  metadataOutput.start().then(() => {
3990    console.info('Callback returned with metadata output started.');
3991  }).catch((error: BusinessError) => {
3992    console.error(`Failed to metadata output stop, error code: ${error.code}`);
3993  });
3994}
3995```
3996
3997### stop
3998
3999stop(callback: AsyncCallback\<void\>): void
4000
4001Stops outputting metadata. This API uses an asynchronous callback to return the result.
4002
4003**System capability**: SystemCapability.Multimedia.Camera.Core
4004
4005**Parameters**
4006
4007| Name    | Type                        | Mandatory| Description                 |
4008| -------- | -------------------------- | ---- | ------------------- |
4009| callback | AsyncCallback\<void\>       | Yes  | Callback used to return the result.|
4010
4011**Example**
4012
4013```ts
4014import { BusinessError } from '@kit.BasicServicesKit';
4015
4016function stopMetadataOutput(metadataOutput: camera.MetadataOutput): void {
4017  metadataOutput.stop((err: BusinessError) => {
4018    if (err) {
4019      console.error(`Failed to stop the metadata output, error code: ${err.code}.`);
4020      return;
4021    }
4022    console.info('Callback returned with metadata output stopped.');
4023  })
4024}
4025```
4026
4027### stop
4028
4029stop(): Promise\<void\>
4030
4031Stops outputting metadata. This API uses a promise to return the result.
4032
4033**System capability**: SystemCapability.Multimedia.Camera.Core
4034
4035**Return value**
4036
4037| Type                   | Description                       |
4038| ----------------------  | --------------------------- |
4039| Promise\<void\>         | Promise that returns no value.|
4040
4041**Example**
4042
4043```ts
4044import { BusinessError } from '@kit.BasicServicesKit';
4045
4046function stopMetadataOutput(metadataOutput: camera.MetadataOutput): void {
4047  metadataOutput.stop().then(() => {
4048    console.info('Callback returned with metadata output stopped.');
4049  }).catch((error: BusinessError) => {
4050    console.error(`Failed to metadata output stop, error code: ${error.code}`);
4051  });
4052}
4053```
4054
4055### on('metadataObjectsAvailable')
4056
4057on(type: 'metadataObjectsAvailable', callback: AsyncCallback\<Array\<MetadataObject\>\>): void
4058
4059Subscribes to events indicating available metadata objects. This API uses an asynchronous callback to return the result.
4060
4061> **NOTE**
4062>
4063> Currently, you cannot use **off()** to unregister the callback in the callback method of **on()**.
4064
4065**System capability**: SystemCapability.Multimedia.Camera.Core
4066
4067**Parameters**
4068
4069| Name     | Type        | Mandatory| Description                                 |
4070| -------- | -------------- | ---- | ------------------------------------ |
4071| type     | string         | Yes  | Event type. The value is fixed at **'metadataObjectsAvailable'**. The event can be listened for when a **metadataOutput** instance is created. This event is triggered and the corresponding metadata is returned when valid metadata is detected.|
4072| callback | AsyncCallback\<Array\<[MetadataObject](#metadataobject)\>\> | Yes  | Callback used to return the metadata.|
4073
4074**Example**
4075
4076```ts
4077import { BusinessError } from '@kit.BasicServicesKit';
4078
4079function callback(err: BusinessError, metadataObjectArr: Array<camera.MetadataObject>): void {
4080  if (err !== undefined && err.code !== 0) {
4081    console.error(`Callback Error, errorCode: ${err.code}`);
4082    return;
4083  }
4084  console.info('metadata output metadataObjectsAvailable');
4085}
4086
4087function registerMetadataObjectsAvailable(metadataOutput: camera.MetadataOutput): void {
4088  metadataOutput.on('metadataObjectsAvailable', callback);
4089}
4090```
4091
4092### off('metadataObjectsAvailable')
4093
4094off(type: 'metadataObjectsAvailable', callback?: AsyncCallback\<Array\<MetadataObject\>\>): void
4095
4096Unsubscribes from events indicating available metadata objects.
4097
4098**System capability**: SystemCapability.Multimedia.Camera.Core
4099
4100**Parameters**
4101
4102| Name     | Type        | Mandatory| Description                                 |
4103| -------- | -------------- | ---- | ------------------------------------ |
4104| type     | string         | Yes  | Event type. The value is fixed at **'metadataObjectsAvailable'**. The event can be listened for when a **metadataOutput** instance is created.|
4105| callback | AsyncCallback\<Array\<[MetadataObject](#metadataobject)\>\> | No  | Callback used to return the result. If this parameter is specified, the subscription to the specified event with the specified callback is canceled. (The callback object cannot be an anonymous function.) Otherwise, the subscriptions to the specified event with all the callbacks are canceled.|
4106
4107**Example**
4108
4109```ts
4110function unregisterMetadataObjectsAvailable(metadataOutput: camera.MetadataOutput): void {
4111  metadataOutput.off('metadataObjectsAvailable');
4112}
4113```
4114
4115### on('error')
4116
4117on(type: 'error', callback: ErrorCallback): void
4118
4119Subscribes to metadata error events. This API uses an asynchronous callback to return the result.
4120
4121> **NOTE**
4122>
4123> Currently, you cannot use **off()** to unregister the callback in the callback method of **on()**.
4124
4125**System capability**: SystemCapability.Multimedia.Camera.Core
4126
4127**Parameters**
4128
4129| Name    | Type        | Mandatory| Description                                    |
4130| -------- | ------------- | ---- | --------------------------------------- |
4131| type     | string        | Yes  | Event type. The value is fixed at **'error'**. The event can be listened for when a **metadataOutput** instance is created. This event is triggered and the corresponding error message is returned when an error occurs during the use of a metadata-related API such as [start](#start-3) or [CameraOutput.release](#release-1).|
4132| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback) | Yes  | Callback used to return an error code defined in [CameraErrorCode](#cameraerrorcode).           |
4133
4134**Example**
4135
4136```ts
4137import { BusinessError } from '@kit.BasicServicesKit';
4138
4139function callback(metadataOutputError: BusinessError): void {
4140  console.error(`Metadata output error code: ${metadataOutputError.code}`);
4141}
4142
4143function registerMetadataOutputError(metadataOutput: camera.MetadataOutput): void {
4144  metadataOutput.on('error', callback);
4145}
4146```
4147
4148### off('error')
4149
4150off(type: 'error', callback?: ErrorCallback): void
4151
4152Unsubscribes from metadata error events.
4153
4154**System capability**: SystemCapability.Multimedia.Camera.Core
4155
4156**Parameters**
4157
4158| Name    | Type        | Mandatory| Description                                    |
4159| -------- | ------------- | ---- | --------------------------------------- |
4160| type     | string        | Yes  | Event type. The value is fixed at **'error'**. The event can be listened for when a **metadataOutput** instance is created.|
4161| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback) | No  | Callback used to return the result. If this parameter is specified, the subscription to the specified event with the specified callback is canceled. (The callback object cannot be an anonymous function.) Otherwise, the subscriptions to the specified event with all the callbacks are canceled.|
4162
4163**Example**
4164
4165```ts
4166function unregisterMetadataOutputError(metadataOutput: camera.MetadataOutput): void {
4167  metadataOutput.off('error');
4168}
4169```
4170
4171## MetadataObjectType
4172
4173Enumerates the metadata object types.
4174
4175**System capability**: SystemCapability.Multimedia.Camera.Core
4176
4177| Name                      | Value  | Description             |
4178| ------------------------- | ---- | ----------------- |
4179| FACE_DETECTION            | 0    | Metadata object used for face detection.<br> The detection point must be in the coordinate system (0-1), where the upper left corner is (0, 0) and the lower right corner is (1, 1).<br> The coordinate system is based on the horizontal device direction with the device's charging port on the right.<br>If the layout of a preview screen of an application is based on the vertical direction with the charging port on the lower side,<br>the layout width and height are (w, h) and the return point is (x, y), then the coordinate point after conversion is (1-y, x).|
4180
4181## Rect
4182
4183Defines a rectangle.
4184
4185**System capability**: SystemCapability.Multimedia.Camera.Core
4186
4187| Name     | Type  |  Read-only | Optional |           Description        |
4188| -------- | ------ | ------ |-----| --------------------- |
4189| topLeftX | number |   No  | No  | X-axis coordinate of the upper left corner of the rectangle.  |
4190| topLeftY | number |   No  | No  | Y-axis coordinate of the upper left corner of the rectangle.  |
4191| width    | number |   No  | No  | Width of the rectangle, which is a relative value. The value range is [0, 1]. |
4192| height   | number |   No  | No  | Height of the rectangle, which is a relative value. The value range is [0, 1]. |
4193
4194## MetadataObject
4195
4196Implements camera metadata, which is the data source of [CameraInput](#camerainput). The metadata is obtained through metadataOutput.on('metadataObjectsAvailable').
4197
4198**System capability**: SystemCapability.Multimedia.Camera.Core
4199
4200| Name        | Type                                       | Read-only| Optional|Description               |
4201| ----------- | ------------------------------------------- | ---- | ---- | ----------------- |
4202| type        | [MetadataObjectType](#metadataobjecttype)   |  Yes |  No | Metadata object type.   |
4203| timestamp   | number                                      |  Yes |  No | Current timestamp, in milliseconds.|
4204| boundingBox | [Rect](#rect)                               |  Yes |  No | Metadata rectangle. |
4205
4206## FlashMode
4207
4208Enumerates the flash modes.
4209
4210**System capability**: SystemCapability.Multimedia.Camera.Core
4211
4212| Name                   | Value  | Description       |
4213| ---------------------- | ---- | ---------- |
4214| FLASH_MODE_CLOSE       | 0    | The flash is off.|
4215| FLASH_MODE_OPEN        | 1    | The flash is on.|
4216| FLASH_MODE_AUTO        | 2    | The flash mode is auto, indicating that the flash fires automatically depending on the photo capture conditions.|
4217| FLASH_MODE_ALWAYS_OPEN | 3    | The flash is steady on.|
4218
4219## ExposureMode
4220
4221Enumerates the exposure modes.
4222
4223**System capability**: SystemCapability.Multimedia.Camera.Core
4224
4225| Name                          | Value  | Description        |
4226| ----------------------------- | ---- | ----------- |
4227| EXPOSURE_MODE_LOCKED          | 0    | Exposure locked. The metering point cannot be set.|
4228| EXPOSURE_MODE_AUTO            | 1    | Auto exposure. The metering point can be set by calling [AutoExposure.setMeteringPoint](#setmeteringpoint11).|
4229| EXPOSURE_MODE_CONTINUOUS_AUTO | 2    | Continuous auto exposure. The metering point cannot be set.|
4230
4231## FocusMode
4232
4233Enumerates the focus modes.
4234
4235**System capability**: SystemCapability.Multimedia.Camera.Core
4236
4237| Name                       | Value  | Description         |
4238| -------------------------- | ---- | ------------ |
4239| FOCUS_MODE_MANUAL          | 0    | Manual focus. The focal length of the camera can be manually set to change the focus position. However, the focal point cannot be set.    |
4240| FOCUS_MODE_CONTINUOUS_AUTO | 1    | Continuous auto focus. The focal point cannot be set.|
4241| FOCUS_MODE_AUTO            | 2    | Auto focus. The focal point can be set by calling [Focus.setFocusPoint](#setfocuspoint11), and auto focus is performed once based on the focal point.   |
4242| FOCUS_MODE_LOCKED          | 3    | Focus locked. The focal point cannot be set.    |
4243
4244## FocusState
4245
4246Enumerates the focus states.
4247
4248**System capability**: SystemCapability.Multimedia.Camera.Core
4249
4250| Name                  | Value  | Description      |
4251| --------------------- | ---- | --------- |
4252| FOCUS_STATE_SCAN      | 0    | Focusing. |
4253| FOCUS_STATE_FOCUSED   | 1    | Focused. |
4254| FOCUS_STATE_UNFOCUSED | 2    | Unfocused.|
4255
4256## VideoStabilizationMode
4257
4258Enumerates the video stabilization modes.
4259
4260**System capability**: SystemCapability.Multimedia.Camera.Core
4261
4262| Name      | Value  | Description        |
4263| --------- | ---- | ------------ |
4264| OFF       | 0    | Video stabilization is disabled.  |
4265| LOW       | 1    | The basic video stabilization algorithm is used.  |
4266| MIDDLE    | 2    | A video stabilization algorithm with a stabilization effect better than that of the **LOW** type is used.  |
4267| HIGH      | 3    | A video stabilization algorithm with a stabilization effect better than that of the **MIDDLE** type is used.  |
4268| AUTO      | 4    | Automatic video stabilization is used.  |
4269
4270## Session<sup>11+</sup>
4271
4272Implements a session, which saves all [CameraInput](#camerainput) and [CameraOutput](#cameraoutput) instances required to run the camera and requests the camera to take a photo or record a video.
4273
4274### beginConfig<sup>11+</sup>
4275
4276beginConfig(): void
4277
4278Starts configuration for the session.
4279
4280**System capability**: SystemCapability.Multimedia.Camera.Core
4281
4282**Error codes**
4283
4284For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
4285
4286| ID        | Error Message       |
4287| --------------- | --------------- |
4288| 7400105                |  Session config locked.               |
4289| 7400201                |  Camera service fatal error.               |
4290
4291**Example**
4292
4293```ts
4294import { BusinessError } from '@kit.BasicServicesKit';
4295
4296function beginConfig(session: camera.Session): void {
4297  try {
4298    session.beginConfig();
4299  } catch (error) {
4300    // If the operation fails, error.code is returned and processed.
4301    let err = error as BusinessError;
4302    console.error(`The beginConfig call failed. error code: ${err.code}`);
4303  }
4304}
4305```
4306
4307### commitConfig<sup>11+</sup>
4308
4309commitConfig(callback: AsyncCallback\<void\>): void
4310
4311Commits the configuration for this session. This API uses an asynchronous callback to return the result.
4312
4313**System capability**: SystemCapability.Multimedia.Camera.Core
4314
4315**Parameters**
4316
4317| Name    | Type                  | Mandatory| Description                 |
4318| -------- | -------------------- | ---- | -------------------- |
4319| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
4320
4321**Error codes**
4322
4323For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
4324
4325| ID        | Error Message       |
4326| --------------- | --------------- |
4327| 7400102                |  Operation not allowed.                                  |
4328| 7400201                |  Camera service fatal error.                           |
4329
4330**Example**
4331
4332```ts
4333import { BusinessError } from '@kit.BasicServicesKit';
4334
4335function commitConfig(session: camera.Session): void {
4336  session.commitConfig((err: BusinessError) => {
4337    if (err) {
4338      console.error(`The commitConfig call failed. error code: ${err.code}`);
4339      return;
4340    }
4341    console.info('Callback invoked to indicate the commit config success.');
4342  });
4343}
4344```
4345
4346### commitConfig<sup>11+</sup>
4347
4348commitConfig(): Promise\<void\>
4349
4350Commits the configuration for this session. This API uses a promise to return the result.
4351
4352**System capability**: SystemCapability.Multimedia.Camera.Core
4353
4354**Return value**
4355
4356| Type           | Description                    |
4357| -------------- | ------------------------ |
4358| Promise\<void\> | Promise that returns no value.|
4359
4360**Error codes**
4361
4362For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
4363
4364| ID        | Error Message       |
4365| --------------- | --------------- |
4366| 7400102                |  Operation not allowed.                                  |
4367| 7400201                |  Camera service fatal error.                           |
4368
4369**Example**
4370
4371```ts
4372import { BusinessError } from '@kit.BasicServicesKit';
4373
4374function commitConfig(session: camera.Session): void {
4375  session.commitConfig().then(() => {
4376    console.info('Promise returned to indicate the commit config success.');
4377  }).catch((error: BusinessError) => {
4378    // If the operation fails, error.code is returned and processed.
4379    console.error(`The commitConfig call failed. error code: ${error.code}`);
4380  });
4381}
4382```
4383
4384### canAddInput<sup>11+</sup>
4385
4386canAddInput(cameraInput: CameraInput): boolean
4387
4388Determines whether a **CameraInput** instance can be added to this session. This API must be called after [beginConfig](#beginconfig11) and before [commitConfig](#commitconfig11-1).
4389
4390**System capability**: SystemCapability.Multimedia.Camera.Core
4391
4392**Parameters**
4393
4394| Name       | Type                         | Mandatory| Description                    |
4395| ----------- | --------------------------- | ---- | ------------------------ |
4396| cameraInput | [CameraInput](#camerainput) | Yes  | **CameraInput** instance to add. The API does not take effect if the input parameter is invalid (for example, the value is out of range, null, or undefined).|
4397
4398**Return value**
4399
4400| Type           | Description                    |
4401| -------------- | ------------------------ |
4402| boolean | **true**: The **CameraInput** instance can be added.<br>**false**: The **CameraInput** instance cannot be added.|
4403
4404**Example**
4405
4406```ts
4407import { BusinessError } from '@kit.BasicServicesKit';
4408
4409function canAddInput(session: camera.Session, cameraInput: camera.CameraInput): void {
4410  let canAdd: boolean = session.canAddInput(cameraInput);
4411  console.info(`The input canAddInput: ${canAdd}`);
4412}
4413```
4414
4415### addInput<sup>11+</sup>
4416
4417addInput(cameraInput: CameraInput): void
4418
4419Adds a [CameraInput](#camerainput) instance to this session.
4420
4421**System capability**: SystemCapability.Multimedia.Camera.Core
4422
4423**Parameters**
4424
4425| Name       | Type                         | Mandatory| Description                    |
4426| ----------- | --------------------------- | ---- | ------------------------ |
4427| cameraInput | [CameraInput](#camerainput) | Yes  | **CameraInput** instance to add.|
4428
4429**Error codes**
4430
4431For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
4432
4433| ID        | Error Message       |
4434| --------------- | --------------- |
4435| 7400101                |  Parameter missing or parameter type incorrect.        |
4436| 7400102                |  Operation not allowed.                                  |
4437| 7400103                |  Session not config.                                   |
4438| 7400201                |  Camera service fatal error.                                   |
4439
4440**Example**
4441
4442```ts
4443import { BusinessError } from '@kit.BasicServicesKit';
4444
4445function addInput(session: camera.Session, cameraInput: camera.CameraInput): void {
4446  try {
4447    session.addInput(cameraInput);
4448  } catch (error) {
4449    // If the operation fails, error.code is returned and processed.
4450    let err = error as BusinessError;
4451    console.error(`The addInput call failed. error code: ${err.code}`);
4452  }
4453}
4454```
4455
4456### removeInput<sup>11+</sup>
4457
4458removeInput(cameraInput: CameraInput): void
4459
4460Removes a [CameraInput](#camerainput) instance from this session. This API must be called after [beginConfig](#beginconfig11) and before [commitConfig](#commitconfig11-1).
4461
4462**System capability**: SystemCapability.Multimedia.Camera.Core
4463
4464**Parameters**
4465
4466| Name       | Type                         | Mandatory| Description                     |
4467| ----------- | --------------------------- | ---- | ------------------------ |
4468| cameraInput | [CameraInput](#camerainput) | Yes  | **CameraInput** instance to remove.|
4469
4470**Error codes**
4471
4472For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
4473
4474| ID        | Error Message       |
4475| --------------- | --------------- |
4476| 7400101                |  Parameter missing or parameter type incorrect.        |
4477| 7400102                |  Operation not allowed.                                  |
4478| 7400103                |  Session not config.                                   |
4479| 7400201                |  Camera service fatal error.                                   |
4480
4481**Example**
4482
4483```ts
4484import { BusinessError } from '@kit.BasicServicesKit';
4485
4486function removeInput(session: camera.Session, cameraInput: camera.CameraInput): void {
4487  try {
4488    session.removeInput(cameraInput);
4489  } catch (error) {
4490    // If the operation fails, error.code is returned and processed.
4491    let err = error as BusinessError;
4492    console.error(`The removeInput call failed. error code: ${err.code}`);
4493  }
4494}
4495```
4496
4497### canAddOutput<sup>11+</sup>
4498
4499canAddOutput(cameraOutput: CameraOutput): boolean
4500
4501Determines whether a **CameraOutput** instance can be added to this session. This API must be called after [addInput](#addinput11) and before [commitConfig](#commitconfig11-1).
4502
4503**System capability**: SystemCapability.Multimedia.Camera.Core
4504
4505**Parameters**
4506
4507| Name       | Type                         | Mandatory| Description                    |
4508| ----------- | --------------------------- | ---- | ------------------------ |
4509| cameraOutput | [CameraOutput](#cameraoutput) | Yes  | **CameraOutput** instance to add. The API does not take effect if the input parameter is invalid (for example, the value is out of range, null, or undefined).|
4510
4511**Return value**
4512
4513| Type           | Description                    |
4514| -------------- | ------------------------ |
4515| boolean | **true**: The **CameraOutput** instance can be added.<br>**false**: The **CameraOutput** instance cannot be added.|
4516
4517**Example**
4518
4519```ts
4520import { BusinessError } from '@kit.BasicServicesKit';
4521
4522function canAddOutput(session: camera.Session, cameraOutput: camera.CameraOutput): void {
4523  let canAdd: boolean = session.canAddOutput(cameraOutput);
4524  console.info(`This addOutput can add: ${canAdd}`);
4525}
4526```
4527
4528### addOutput<sup>11+</sup>
4529
4530addOutput(cameraOutput: CameraOutput): void
4531
4532Adds a [CameraOutput](#cameraoutput) instance to this session.
4533
4534**System capability**: SystemCapability.Multimedia.Camera.Core
4535
4536**Parameters**
4537
4538| Name          | Type                            | Mandatory| Description                     |
4539| ------------- | ------------------------------- | ---- | ------------------------ |
4540| cameraOutput  | [CameraOutput](#cameraoutput)   | Yes  | **CameraOutput** instance to add.|
4541
4542**Error codes**
4543
4544For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
4545
4546| ID        | Error Message       |
4547| --------------- | --------------- |
4548| 7400101                |  Parameter missing or parameter type incorrect.        |
4549| 7400102                |  Operation not allowed.                                  |
4550| 7400103                |  Session not config.                                   |
4551| 7400201                |  Camera service fatal error.                                   |
4552
4553**Example**
4554
4555```ts
4556import { BusinessError } from '@kit.BasicServicesKit';
4557
4558function addOutput(session: camera.Session, cameraOutput: camera.CameraOutput): void {
4559  try {
4560    session.addOutput(cameraOutput);
4561  } catch (error) {
4562    // If the operation fails, error.code is returned and processed.
4563    let err = error as BusinessError;
4564    console.error(`The addOutput call failed. error code: ${err.code}`);
4565  }
4566}
4567```
4568
4569### removeOutput<sup>11+</sup>
4570
4571removeOutput(cameraOutput: CameraOutput): void
4572
4573Removes a [CameraOutput](#cameraoutput) instance from this session.
4574
4575**System capability**: SystemCapability.Multimedia.Camera.Core
4576
4577**Parameters**
4578
4579| Name          | Type                            | Mandatory| Description                     |
4580| ------------- | ------------------------------- | ---- | ------------------------ |
4581| cameraOutput  | [CameraOutput](#cameraoutput)   | Yes  | **CameraOutput** instance to remove.|
4582
4583**Error codes**
4584
4585For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
4586
4587| ID        | Error Message       |
4588| --------------- | --------------- |
4589| 7400101                |  Parameter missing or parameter type incorrect.        |
4590| 7400102                |  Operation not allowed.                                  |
4591| 7400103                |  Session not config.                                   |
4592| 7400201                |  Camera service fatal error.                                   |
4593
4594**Example**
4595
4596```ts
4597import { BusinessError } from '@kit.BasicServicesKit';
4598
4599function removeOutput(session: camera.Session, previewOutput: camera.PreviewOutput): void {
4600  try {
4601    session.removeOutput(previewOutput);
4602  } catch (error) {
4603    // If the operation fails, error.code is returned and processed.
4604    let err = error as BusinessError;
4605    console.error(`The removeOutput call failed. error code: ${err.code}`);
4606  }
4607}
4608```
4609
4610### start<sup>11+</sup>
4611
4612start(callback: AsyncCallback\<void\>): void
4613
4614Starts this session. This API uses an asynchronous callback to return the result.
4615
4616**System capability**: SystemCapability.Multimedia.Camera.Core
4617
4618**Parameters**
4619
4620| Name     | Type                 | Mandatory| Description                |
4621| -------- | -------------------- | ---- | -------------------- |
4622| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
4623
4624**Error codes**
4625
4626For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
4627
4628| ID        | Error Message       |
4629| --------------- | --------------- |
4630| 7400102                |  Operation not allowed.                                |
4631| 7400103                |  Session not config.                                   |
4632| 7400201                |  Camera service fatal error.                           |
4633
4634**Example**
4635
4636```ts
4637import { BusinessError } from '@kit.BasicServicesKit';
4638
4639function startCaptureSession(session: camera.Session): void {
4640  session.start((err: BusinessError) => {
4641    if (err) {
4642      console.error(`Failed to start the session, error code: ${err.code}.`);
4643      return;
4644    }
4645    console.info('Callback invoked to indicate the session start success.');
4646  });
4647}
4648```
4649
4650### start<sup>11+</sup>
4651
4652start(): Promise\<void\>
4653
4654Starts this session. This API uses a promise to return the result.
4655
4656**System capability**: SystemCapability.Multimedia.Camera.Core
4657
4658**Return value**
4659
4660| Type           | Description                    |
4661| -------------- | ------------------------ |
4662| Promise\<void\> | Promise that returns no value.|
4663
4664**Error codes**
4665
4666For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
4667
4668| ID        | Error Message       |
4669| --------------- | --------------- |
4670| 7400102                |  Operation not allowed.                                |
4671| 7400103                |  Session not config.                                   |
4672| 7400201                |  Camera service fatal error.                           |
4673
4674**Example**
4675
4676```ts
4677import { BusinessError } from '@kit.BasicServicesKit';
4678
4679function startCaptureSession(session: camera.Session): void {
4680  session.start().then(() => {
4681    console.info('Promise returned to indicate the session start success.');
4682  }).catch((error: BusinessError) => {
4683    console.error(`Failed to start the session, error code: ${error.code}.`);
4684  });
4685}
4686```
4687
4688### stop<sup>11+</sup>
4689
4690stop(callback: AsyncCallback\<void\>): void
4691
4692Stops this session. This API uses an asynchronous callback to return the result.
4693
4694**System capability**: SystemCapability.Multimedia.Camera.Core
4695
4696**Parameters**
4697
4698| Name     | Type                 | Mandatory| Description                |
4699| -------- | -------------------- | ---- | ------------------- |
4700| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
4701
4702**Error codes**
4703
4704For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
4705
4706| ID        | Error Message       |
4707| --------------- | --------------- |
4708| 7400201                |  Camera service fatal error.                           |
4709
4710**Example**
4711
4712```ts
4713import { BusinessError } from '@kit.BasicServicesKit';
4714
4715function stopCaptureSession(session: camera.Session): void {
4716  session.stop((err: BusinessError) => {
4717    if (err) {
4718      console.error(`Failed to stop the session, error code: ${err.code}.`);
4719      return;
4720    }
4721    console.info('Callback invoked to indicate the session stop success.');
4722  });
4723}
4724```
4725
4726### stop<sup>11+</sup>
4727
4728stop(): Promise\<void\>
4729
4730Stops this session. This API uses a promise to return the result.
4731
4732**System capability**: SystemCapability.Multimedia.Camera.Core
4733
4734**Return value**
4735
4736| Type           | Description               |
4737| -------------- |-------------------|
4738| Promise\<void\> | Promise that returns no value. |
4739
4740**Error codes**
4741
4742For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
4743
4744| ID        | Error Message       |
4745| --------------- | --------------- |
4746| 7400201                |  Camera service fatal error.                           |
4747
4748**Example**
4749
4750```ts
4751import { BusinessError } from '@kit.BasicServicesKit';
4752
4753function stopCaptureSession(session: camera.Session): void {
4754  session.stop().then(() => {
4755    console.info('Promise returned to indicate the session stop success.');
4756  }).catch((error: BusinessError) => {
4757    console.error(`Failed to stop the session, error code: ${error.code}.`);
4758  });
4759}
4760```
4761
4762### release<sup>11+</sup>
4763
4764release(callback: AsyncCallback\<void\>): void
4765
4766Releases this session. This API uses an asynchronous callback to return the result.
4767
4768**System capability**: SystemCapability.Multimedia.Camera.Core
4769
4770**Parameters**
4771
4772| Name     | Type                 | Mandatory| Description                |
4773| -------- | -------------------- | ---- | -------------------- |
4774| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
4775
4776**Error codes**
4777
4778For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
4779
4780| ID        | Error Message       |
4781| --------------- | --------------- |
4782| 7400201                |  Camera service fatal error.                           |
4783
4784**Example**
4785
4786```ts
4787import { BusinessError } from '@kit.BasicServicesKit';
4788
4789function releaseCaptureSession(session: camera.Session): void {
4790  session.release((err: BusinessError) => {
4791    if (err) {
4792      console.error(`Failed to release the session instance, error code: ${err.code}.`);
4793      return;
4794    }
4795    console.info('Callback invoked to indicate that the session instance is released successfully.');
4796  });
4797}
4798```
4799
4800### release<sup>11+</sup>
4801
4802release(): Promise\<void\>
4803
4804Releases this session. This API uses a promise to return the result.
4805
4806**System capability**: SystemCapability.Multimedia.Camera.Core
4807
4808**Return value**
4809
4810| Type           | Description                    |
4811| -------------- | ------------------------ |
4812| Promise\<void\> | Promise that returns no value.|
4813
4814**Error codes**
4815
4816For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
4817
4818| ID        | Error Message       |
4819| --------------- | --------------- |
4820| 7400201                |  Camera service fatal error.                           |
4821
4822**Example**
4823
4824```ts
4825import { BusinessError } from '@kit.BasicServicesKit';
4826
4827function releaseCaptureSession(session: camera.Session): void {
4828  session.release().then(() => {
4829    console.info('Promise returned to indicate that the session instance is released successfully.');
4830  }).catch((error: BusinessError) => {
4831    console.error(`Failed to release the session instance, error code: ${error.code}.`);
4832  });
4833}
4834```
4835
4836## Flash<sup>11+</sup>
4837
4838Flash extends [FlashQuery](#flashquery12)
4839
4840Provides APIs related to the flash.
4841
4842### setFlashMode<sup>11+</sup>
4843
4844setFlashMode(flashMode: FlashMode): void
4845
4846Sets a flash mode.
4847
4848Before the setting, do the following checks:
4849
48501. Use [hasFlash](#hasflash11) to check whether the camera device has flash.
48512. Use [isFlashModeSupported](#isflashmodesupported11) to check whether the camera device supports the flash mode.
4852
4853**System capability**: SystemCapability.Multimedia.Camera.Core
4854
4855**Parameters**
4856
4857| Name      | Type                    | Mandatory| Description                 |
4858| --------- | ----------------------- | ---- | --------------------- |
4859| flashMode | [FlashMode](#flashmode) | Yes  | Flash mode. If the input parameter is null or undefined, it is treated as 0 and the flash is turned off.      |
4860
4861**Error codes**
4862
4863For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
4864
4865| ID        | Error Message       |
4866| --------------- | --------------- |
4867| 7400103                |  Session not config.                                   |
4868
4869**Example**
4870
4871```ts
4872import { BusinessError } from '@kit.BasicServicesKit';
4873
4874function setFlashMode(photoSession: camera.PhotoSession): void {
4875  try {
4876    photoSession.setFlashMode(camera.FlashMode.FLASH_MODE_AUTO);
4877  } catch (error) {
4878    // If the operation fails, error.code is returned and processed.
4879    let err = error as BusinessError;
4880    console.error(`The setFlashMode call failed. error code: ${err.code}`);
4881  }
4882}
4883```
4884
4885### getFlashMode<sup>11+</sup>
4886
4887getFlashMode(): FlashMode
4888
4889Obtains the flash mode in use.
4890
4891**System capability**: SystemCapability.Multimedia.Camera.Core
4892
4893**Return value**
4894
4895| Type       | Description                         |
4896| ---------- | ----------------------------- |
4897| [FlashMode](#flashmode)    | Flash mode obtained. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
4898
4899**Error codes**
4900
4901For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
4902
4903| ID        | Error Message       |
4904| --------------- | --------------- |
4905| 7400103                |  Session not config.                                   |
4906
4907**Example**
4908
4909```ts
4910import { BusinessError } from '@kit.BasicServicesKit';
4911
4912function getFlashMode(photoSession: camera.PhotoSession): camera.FlashMode | undefined {
4913  let flashMode: camera.FlashMode | undefined = undefined;
4914  try {
4915    flashMode = photoSession.getFlashMode();
4916  } catch (error) {
4917    // If the operation fails, error.code is returned and processed.
4918    let err = error as BusinessError;
4919    console.error(`The getFlashMode call failed.error code: ${err.code}`);
4920  }
4921  return flashMode;
4922}
4923```
4924
4925## FlashQuery<sup>12+</sup>
4926
4927Provides APIs to query the flash status and mode of a camera device.
4928
4929### hasFlash<sup>11+</sup>
4930
4931hasFlash(): boolean
4932
4933Checks whether the camera device has flash. This API uses an asynchronous callback to return the result.
4934
4935**System capability**: SystemCapability.Multimedia.Camera.Core
4936
4937**Return value**
4938
4939| Type       | Description                         |
4940| ---------- | ----------------------------- |
4941| boolean    | **true**: The camera device has flash.<br>**false**: The camera device does not have flash. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
4942
4943**Error codes**
4944
4945For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
4946
4947| ID        | Error Message       |
4948| --------------- | --------------- |
4949| 7400103                |  Session not config, only throw in session usage.       |
4950
4951**Example**
4952
4953```ts
4954import { BusinessError } from '@kit.BasicServicesKit';
4955
4956function hasFlash(photoSession: camera.PhotoSession): boolean {
4957  let status: boolean = false;
4958  try {
4959    status = photoSession.hasFlash();
4960  } catch (error) {
4961    // If the operation fails, error.code is returned and processed.
4962    let err = error as BusinessError;
4963    console.error(`The hasFlash call failed. error code: ${err.code}`);
4964  }
4965  return status;
4966}
4967```
4968
4969### isFlashModeSupported<sup>11+</sup>
4970
4971isFlashModeSupported(flashMode: FlashMode): boolean
4972
4973Checks whether a flash mode is supported.
4974
4975**System capability**: SystemCapability.Multimedia.Camera.Core
4976
4977**Parameters**
4978
4979| Name      | Type                    | Mandatory| Description                              |
4980| --------- | ----------------------- | ---- | --------------------------------- |
4981| flashMode | [FlashMode](#flashmode) | Yes  | Flash mode. If the input parameter is null or undefined, it is treated as 0 and the flash is turned off.            |
4982
4983**Return value**
4984
4985| Type       | Description                         |
4986| ---------- | ----------------------------- |
4987| boolean    | **true**: The flash mode is supported.<br>**false**: The flash mode is not supported. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
4988
4989**Error codes**
4990
4991For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
4992
4993| ID        | Error Message       |
4994| --------------- | --------------- |
4995| 7400103                |  Session not config, only throw in session usage.             |
4996
4997**Example**
4998
4999```ts
5000import { BusinessError } from '@kit.BasicServicesKit';
5001
5002function isFlashModeSupported(photoSession: camera.PhotoSession): boolean {
5003  let status: boolean = false;
5004  try {
5005    status = photoSession.isFlashModeSupported(camera.FlashMode.FLASH_MODE_AUTO);
5006  } catch (error) {
5007    // If the operation fails, error.code is returned and processed.
5008    let err = error as BusinessError;
5009    console.error(`The isFlashModeSupported call failed. error code: ${err.code}`);
5010  }
5011  return status;
5012}
5013```
5014
5015## AutoExposure<sup>11+</sup>
5016
5017AutoExposure extends [AutoExposureQuery](#autoexposurequery12)
5018
5019Provides APIs related to auto exposure.
5020
5021### getExposureMode<sup>11+</sup>
5022
5023getExposureMode(): ExposureMode
5024
5025Obtains the exposure mode in use.
5026
5027**System capability**: SystemCapability.Multimedia.Camera.Core
5028
5029**Return value**
5030
5031| Type       | Description                         |
5032| ---------- | ----------------------------- |
5033| [ExposureMode](#exposuremode)    | Exposure mode obtained. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
5034
5035**Error codes**
5036
5037For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
5038
5039| ID        | Error Message       |
5040| --------------- | --------------- |
5041| 7400103                |  Session not config.                                   |
5042
5043**Example**
5044
5045```ts
5046import { BusinessError } from '@kit.BasicServicesKit';
5047
5048function getExposureMode(photoSession: camera.PhotoSession): camera.ExposureMode | undefined {
5049  let exposureMode: camera.ExposureMode | undefined = undefined;
5050  try {
5051    exposureMode = photoSession.getExposureMode();
5052  } catch (error) {
5053    // If the operation fails, error.code is returned and processed.
5054    let err = error as BusinessError;
5055    console.error(`The getExposureMode call failed. error code: ${err.code}`);
5056  }
5057  return exposureMode;
5058}
5059```
5060
5061### setExposureMode<sup>11+</sup>
5062
5063setExposureMode(aeMode: ExposureMode): void
5064
5065Sets an exposure mode. Before the setting, call [isExposureModeSupported](#isexposuremodesupported11) to check whether the target exposure mode is supported.
5066
5067**System capability**: SystemCapability.Multimedia.Camera.Core
5068
5069**Parameters**
5070
5071| Name     | Type                           | Mandatory| Description                   |
5072| -------- | -------------------------------| ---- | ----------------------- |
5073| aeMode   | [ExposureMode](#exposuremode)  | Yes  | Exposure mode. If the input parameter is null or undefined, it is treated as 0 and exposure is locked.               |
5074
5075**Error codes**
5076
5077For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
5078
5079| ID        | Error Message       |
5080| --------------- | --------------- |
5081| 7400103                |  Session not config.                                   |
5082
5083**Example**
5084
5085```ts
5086import { BusinessError } from '@kit.BasicServicesKit';
5087
5088function setExposureMode(photoSession: camera.PhotoSession): void {
5089  try {
5090    photoSession.setExposureMode(camera.ExposureMode.EXPOSURE_MODE_LOCKED);
5091  } catch (error) {
5092    // If the operation fails, error.code is returned and processed.
5093    let err = error as BusinessError;
5094    console.error(`The setExposureMode call failed. error code: ${err.code}`);
5095  }
5096}
5097```
5098
5099### getMeteringPoint<sup>11+</sup>
5100
5101getMeteringPoint(): Point
5102
5103Obtains the metering point of the camera device.
5104
5105**System capability**: SystemCapability.Multimedia.Camera.Core
5106
5107**Return value**
5108
5109| Type       | Description                         |
5110| ---------- | ----------------------------- |
5111| [Point](#point)    | Metering point obtained. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
5112
5113**Error codes**
5114
5115For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
5116
5117| ID        | Error Message       |
5118| --------------- | --------------- |
5119| 7400103                |  Session not config.                                   |
5120
5121**Example**
5122
5123```ts
5124import { BusinessError } from '@kit.BasicServicesKit';
5125
5126function getMeteringPoint(photoSession: camera.PhotoSession): camera.Point | undefined {
5127  let exposurePoint: camera.Point | undefined = undefined;
5128  try {
5129    exposurePoint = photoSession.getMeteringPoint();
5130  } catch (error) {
5131    // If the operation fails, error.code is returned and processed.
5132    let err = error as BusinessError;
5133    console.error(`The getMeteringPoint call failed. error code: ${err.code}`);
5134  }
5135  return exposurePoint;
5136}
5137```
5138
5139### setMeteringPoint<sup>11+</sup>
5140
5141setMeteringPoint(point: Point): void
5142
5143Sets the metering point, which is the center point of the metering rectangle.
5144
5145The metering point must be in the coordinate system (0-1), where the upper left corner is {0, 0} and the lower right corner is {1, 1}.
5146
5147The coordinate system is based on the horizontal device direction with the device's charging port on the right. If the layout of the preview screen of an application is based on the vertical direction with the charging port on the lower side, the layout width and height are {w, h}, and the touch point is {x, y}, then the coordinate point after conversion is {y/h, 1-x/w}.
5148
5149**System capability**: SystemCapability.Multimedia.Camera.Core
5150
5151**Parameters**
5152
5153| Name          | Type                           | Mandatory| Description                |
5154| ------------- | -------------------------------| ---- | ------------------- |
5155| point | [Point](#point)                | Yes  | Metering point. The value range of x and y must be within [0, 1]. If a value less than 0 is passed, the value **0** is used. If a value greater than **1** is passed, the value **1** is used.            |
5156
5157**Error codes**
5158
5159For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
5160
5161| ID        | Error Message       |
5162| --------------- | --------------- |
5163| 7400103                |  Session not config.                                   |
5164
5165**Example**
5166
5167```ts
5168import { BusinessError } from '@kit.BasicServicesKit';
5169
5170function setMeteringPoint(photoSession: camera.PhotoSession): void {
5171  const point: camera.Point = {x: 1, y: 1};
5172  try {
5173    photoSession.setMeteringPoint(point);
5174  } catch (error) {
5175    // If the operation fails, error.code is returned and processed.
5176    let err = error as BusinessError;
5177    console.error(`The setMeteringPoint call failed. error code: ${err.code}`);
5178  }
5179}
5180```
5181
5182### setExposureBias<sup>11+</sup>
5183
5184setExposureBias(exposureBias: number): void
5185
5186Sets an exposure compensation value (EV).
5187
5188Before the setting, you are advised to use [getExposureBiasRange](#getexposurebiasrange11) to obtain the supported values.
5189
5190**System capability**: SystemCapability.Multimedia.Camera.Core
5191
5192**Parameters**
5193
5194| Name    | Type                           | Mandatory| Description                                                                                                                                                                                           |
5195| -------- | -------------------------------| ---- |-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
5196| exposureBias   | number                   | Yes  | EV. The supported EV range can be obtained by calling [getExposureBiasRange](#getexposurebiasrange11). If the value passed is not within the supported range, the nearest critical point is used.<br>There is a step for EV. For example, if the step is 0.5 and this parameter is set to 1.2, the EV that takes effect is 1.0.<br>If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
5197
5198**Error codes**
5199
5200For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
5201
5202| ID        | Error Message       |
5203| --------------- | --------------- |
5204| 7400102                |  Operation not allowed.                                |
5205| 7400103                |  Session not config.                                   |
5206
5207**Example**
5208
5209```ts
5210import { BusinessError } from '@kit.BasicServicesKit';
5211
5212function setExposureBias(photoSession: camera.PhotoSession, biasRangeArray: Array<number>): void {
5213  if (biasRangeArray && biasRangeArray.length > 0) {
5214    let exposureBias = biasRangeArray[0];
5215    try {
5216      photoSession.setExposureBias(exposureBias);
5217    } catch (error) {
5218      // If the operation fails, error.code is returned and processed.
5219      let err = error as BusinessError;
5220      console.error(`The setExposureBias call failed. error code: ${err.code}`);
5221    }
5222  }
5223}
5224```
5225
5226### getExposureValue<sup>11+</sup>
5227
5228getExposureValue(): number
5229
5230Obtains the exposure value in use.
5231
5232**System capability**: SystemCapability.Multimedia.Camera.Core
5233
5234**Return value**
5235
5236| Type       | Description                         |
5237| ---------- | ----------------------------- |
5238| number    | Exposure value obtained. There is a step for EV. For example, if the step is 0.5 and this parameter is set to 1.2, the EV that takes effect is 1.0.<br>If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
5239
5240**Error codes**
5241
5242For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
5243
5244| ID        | Error Message       |
5245| --------------- | --------------- |
5246| 7400103                |  Session not config.                                   |
5247
5248**Example**
5249
5250```ts
5251import { BusinessError } from '@kit.BasicServicesKit';
5252
5253function getExposureValue(photoSession: camera.PhotoSession): number {
5254  const invalidValue: number = -1;
5255  let exposureValue: number = invalidValue;
5256  try {
5257    exposureValue = photoSession.getExposureValue();
5258  } catch (error) {
5259    // If the operation fails, error.code is returned and processed.
5260    let err = error as BusinessError;
5261    console.error(`The getExposureValue call failed. error code: ${err.code}`);
5262  }
5263  return exposureValue;
5264}
5265```
5266
5267## AutoExposureQuery<sup>12+</sup>
5268
5269Provides APIs to query the automatic exposure feature of a camera device.
5270
5271### isExposureModeSupported<sup>11+</sup>
5272
5273isExposureModeSupported(aeMode: ExposureMode): boolean
5274
5275Checks whether an exposure mode is supported.
5276
5277**System capability**: SystemCapability.Multimedia.Camera.Core
5278
5279**Parameters**
5280
5281| Name     | Type                          | Mandatory | Description                          |
5282| -------- | -------------------------------| ---- | ----------------------------- |
5283| aeMode   | [ExposureMode](#exposuremode)  | Yes  | Exposure mode. If the input parameter is null or undefined, it is treated as 0 and exposure is locked.                |
5284
5285**Return value**
5286
5287| Type       | Description                         |
5288| ---------- | ----------------------------- |
5289| boolean    | **true**: The exposure mode is supported.<br>**false**: The exposure mode is not supported. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
5290
5291**Error codes**
5292
5293For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
5294
5295| ID        | Error Message       |
5296| --------------- | --------------- |
5297| 7400103                |  Session not config, only throw in session usage.          |
5298
5299**Example**
5300
5301```ts
5302import { BusinessError } from '@kit.BasicServicesKit';
5303
5304function isExposureModeSupported(photoSession: camera.PhotoSession): boolean {
5305  let isSupported: boolean = false;
5306  try {
5307    isSupported = photoSession.isExposureModeSupported(camera.ExposureMode.EXPOSURE_MODE_LOCKED);
5308  } catch (error) {
5309    // If the operation fails, error.code is returned and processed.
5310    let err = error as BusinessError;
5311    console.error(`The isExposureModeSupported call failed. error code: ${err.code}`);
5312  }
5313  return isSupported;
5314}
5315```
5316
5317### getExposureBiasRange<sup>11+</sup>
5318
5319getExposureBiasRange(): Array\<number\>
5320
5321Obtains the exposure compensation values of the camera device.
5322
5323**System capability**: SystemCapability.Multimedia.Camera.Core
5324
5325**Return value**
5326
5327| Type       | Description                         |
5328| ---------- | ----------------------------- |
5329| Array\<number\>   | Array of compensation values. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
5330
5331**Error codes**
5332
5333For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
5334
5335| ID        | Error Message       |
5336| --------------- | --------------- |
5337| 7400103                |  Session not config, only throw in session usage.               |
5338
5339**Example**
5340
5341```ts
5342import { BusinessError } from '@kit.BasicServicesKit';
5343
5344function getExposureBiasRange(photoSession: camera.PhotoSession): Array<number> {
5345  let biasRangeArray: Array<number> = [];
5346  try {
5347    biasRangeArray = photoSession.getExposureBiasRange();
5348  } catch (error) {
5349    // If the operation fails, error.code is returned and processed.
5350    let err = error as BusinessError;
5351    console.error(`The getExposureBiasRange call failed. error code: ${err.code}`);
5352  }
5353  return biasRangeArray;
5354}
5355```
5356
5357## Focus<sup>11+</sup>
5358
5359Focus extends [FocusQuery](#focusquery12)
5360
5361Provides APIs related to focus operations.
5362
5363### setFocusMode<sup>11+</sup>
5364
5365setFocusMode(afMode: FocusMode): void
5366
5367Sets a focus mode.
5368
5369Before the setting, call [isFocusModeSupported](#isfocusmodesupported11) to check whether the focus mode is supported.
5370
5371**System capability**: SystemCapability.Multimedia.Camera.Core
5372
5373**Parameters**
5374
5375| Name     | Type                    | Mandatory| Description                |
5376| -------- | ----------------------- | ---- | ------------------- |
5377| afMode   | [FocusMode](#focusmode) | Yes  | Focus mode. If the input parameter is null or undefined, it is treated as 0 and manual focus is used.      |
5378
5379**Error codes**
5380
5381For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
5382
5383| ID        | Error Message       |
5384| --------------- | --------------- |
5385| 7400103                |  Session not config.                                   |
5386
5387**Example**
5388
5389```ts
5390import { BusinessError } from '@kit.BasicServicesKit';
5391
5392function setFocusMode(photoSession: camera.PhotoSession): void {
5393  try {
5394    photoSession.setFocusMode(camera.FocusMode.FOCUS_MODE_AUTO);
5395  } catch (error) {
5396    // If the operation fails, error.code is returned and processed.
5397    let err = error as BusinessError;
5398    console.error(`The setFocusMode call failed. error code: ${err.code}`);
5399  }
5400}
5401```
5402
5403### getFocusMode<sup>11+</sup>
5404
5405getFocusMode(): FocusMode
5406
5407Obtains the focus mode in use.
5408
5409**System capability**: SystemCapability.Multimedia.Camera.Core
5410
5411**Return value**
5412
5413| Type       | Description                         |
5414| ---------- | ----------------------------- |
5415| [FocusMode](#focusmode)   | Focus mode obtained. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
5416
5417**Error codes**
5418
5419For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
5420
5421| ID        | Error Message       |
5422| --------------- | --------------- |
5423| 7400103                |  Session not config.                                   |
5424
5425**Example**
5426
5427```ts
5428import { BusinessError } from '@kit.BasicServicesKit';
5429
5430function getFocusMode(photoSession: camera.PhotoSession): camera.FocusMode | undefined {
5431  let afMode: camera.FocusMode | undefined = undefined;
5432  try {
5433    afMode = photoSession.getFocusMode();
5434  } catch (error) {
5435    // If the operation fails, error.code is returned and processed.
5436    let err = error as BusinessError;
5437    console.error(`The getFocusMode call failed. error code: ${err.code}`);
5438  }
5439  return afMode;
5440}
5441```
5442
5443### setFocusPoint<sup>11+</sup>
5444
5445setFocusPoint(point: Point): void
5446
5447Sets the focal point. The focal point must be in the coordinate system (0-1), where the upper left corner is {0, 0} and the lower right corner is {1, 1}.
5448
5449The coordinate system is based on the horizontal device direction with the device's charging port on the right. If the layout of the preview screen of an application is based on the vertical direction with the charging port on the lower side, the layout width and height are {w, h}, and the touch point is {x, y}, then the coordinate point after conversion is {y/h, 1-x/w}.
5450
5451**System capability**: SystemCapability.Multimedia.Camera.Core
5452
5453**Parameters**
5454
5455| Name     | Type                    | Mandatory| Description                |
5456| -------- | ----------------------- | ---- | ------------------- |
5457| point    | [Point](#point)         | Yes  | Focal point. The value range of x and y must be within [0, 1]. If a value less than 0 is passed, the value **0** is used. If a value greater than **1** is passed, the value **1** is used.  |
5458
5459**Error codes**
5460
5461For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
5462
5463| ID        | Error Message       |
5464| --------------- | --------------- |
5465| 7400103                |  Session not config.                                   |
5466
5467**Example**
5468
5469```ts
5470import { BusinessError } from '@kit.BasicServicesKit';
5471
5472function setFocusPoint(photoSession: camera.PhotoSession): void {
5473  const focusPoint: camera.Point = {x: 1, y: 1};
5474  try {
5475    photoSession.setFocusPoint(focusPoint);
5476  } catch (error) {
5477    // If the operation fails, error.code is returned and processed.
5478    let err = error as BusinessError;
5479    console.error(`The setFocusPoint call failed. error code: ${err.code}`);
5480  }
5481}
5482```
5483
5484### getFocusPoint<sup>11+</sup>
5485
5486getFocusPoint(): Point
5487
5488Obtains the focal point of the camera device.
5489
5490**System capability**: SystemCapability.Multimedia.Camera.Core
5491
5492**Return value**
5493
5494| Type       | Description                         |
5495| ---------- | ----------------------------- |
5496| [Point](#point)    | Focal point obtained. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
5497
5498**Error codes**
5499
5500For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
5501
5502| ID        | Error Message       |
5503| --------------- | --------------- |
5504| 7400103                |  Session not config.                                   |
5505
5506**Example**
5507
5508```ts
5509import { BusinessError } from '@kit.BasicServicesKit';
5510
5511function getFocusPoint(photoSession: camera.PhotoSession): camera.Point | undefined {
5512  let point: camera.Point | undefined = undefined;
5513  try {
5514    point = photoSession.getFocusPoint();
5515  } catch (error) {
5516    // If the operation fails, error.code is returned and processed.
5517    let err = error as BusinessError;
5518    console.error(`The getFocusPoint call failed. error code: ${err.code}`);
5519  }
5520  return point;
5521}
5522```
5523
5524### getFocalLength<sup>11+</sup>
5525
5526getFocalLength(): number
5527
5528Obtains the focal length of the camera device.
5529
5530**System capability**: SystemCapability.Multimedia.Camera.Core
5531
5532**Return value**
5533
5534| Type       | Description                         |
5535| ---------- | ----------------------------- |
5536| number    | Focal length, in mm. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
5537
5538**Error codes**
5539
5540For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
5541
5542| ID        | Error Message       |
5543| --------------- | --------------- |
5544| 7400103                |  Session not config.                                   |
5545
5546**Example**
5547
5548```ts
5549import { BusinessError } from '@kit.BasicServicesKit';
5550
5551function getFocalLength(photoSession: camera.PhotoSession): number {
5552  const invalidValue: number = -1;
5553  let focalLength: number = invalidValue;
5554  try {
5555    focalLength = photoSession.getFocalLength();
5556  } catch (error) {
5557    // If the operation fails, error.code is returned and processed.
5558    let err = error as BusinessError;
5559    console.error(`The getFocalLength call failed. error code: ${err.code}`);
5560  }
5561  return focalLength;
5562}
5563```
5564
5565## FocusQuery<sup>12+</sup>
5566
5567Provides APIs to check whether a focus mode is supported.
5568
5569### isFocusModeSupported<sup>11+</sup>
5570
5571isFocusModeSupported(afMode: FocusMode): boolean
5572
5573Checks whether a focus mode is supported.
5574
5575**System capability**: SystemCapability.Multimedia.Camera.Core
5576
5577**Parameters**
5578
5579| Name     | Type                    | Mandatory| Description                             |
5580| -------- | ----------------------- | ---- | -------------------------------- |
5581| afMode   | [FocusMode](#focusmode) | Yes  | Focus mode. If the input parameter is null or undefined, it is treated as 0 and manual focus is used.                   |
5582
5583**Return value**
5584
5585| Type       | Description                         |
5586| ---------- | ----------------------------- |
5587| boolean    | **true**: The focus mode is supported.<br>**false**: The focus mode is not supported. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
5588
5589**Error codes**
5590
5591For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
5592
5593| ID        | Error Message       |
5594| --------------- | --------------- |
5595| 7400103                |  Session not config, only throw in session usage.          |
5596
5597**Example**
5598
5599```ts
5600import { BusinessError } from '@kit.BasicServicesKit';
5601
5602function isFocusModeSupported(photoSession: camera.PhotoSession): boolean {
5603  let status: boolean = false;
5604  try {
5605    status = photoSession.isFocusModeSupported(camera.FocusMode.FOCUS_MODE_AUTO);
5606  } catch (error) {
5607    // If the operation fails, error.code is returned and processed.
5608    let err = error as BusinessError;
5609    console.error(`The isFocusModeSupported call failed. error code: ${err.code}`);
5610  }
5611  return status;
5612}
5613```
5614
5615## SmoothZoomMode<sup>11+</sup>
5616
5617Enumerates the smooth zoom modes.
5618
5619**System capability**: SystemCapability.Multimedia.Camera.Core
5620
5621| Name        | Value  | Description           |
5622| ------------ | ---- | -------------- |
5623| NORMAL       | 0    | Bessel curve mode. |
5624
5625## SmoothZoomInfo<sup>11+</sup>
5626
5627Defines the smooth zoom information.
5628
5629**System capability**: SystemCapability.Multimedia.Camera.Core
5630
5631| Name    | Type       |   Read-only  |   Optional  | Description      |
5632| -------- | ---------- | -------- | -------- | ---------- |
5633| duration |   number   |   No    |    No   | Total duration of smooth zoom, in ms.|
5634
5635## Zoom<sup>11+</sup>
5636
5637Zoom extends [ZoomQuery](#zoomquery12)
5638
5639Provides APIs related to zoom operations.
5640
5641### setZoomRatio<sup>11+</sup>
5642
5643setZoomRatio(zoomRatio: number): void
5644
5645Sets a zoom ratio, with a maximum precision of two decimal places.
5646
5647**System capability**: SystemCapability.Multimedia.Camera.Core
5648
5649**Parameters**
5650
5651| Name      | Type                 | Mandatory| Description                                                                                                                             |
5652| --------- | -------------------- | ---- |---------------------------------------------------------------------------------------------------------------------------------|
5653| zoomRatio | number               | Yes  | Zoom ratio. The supported zoom ratio range can be obtained by calling [getZoomRatioRange](#getzoomratiorange11). If the value passed in is not within the supported range, the value within the precision range is retained.<br>It takes some time for the zoom ratio to take effect at the bottom layer. To obtain the correct zoom ratio, you need to wait for one to two frames.|
5654
5655**Error codes**
5656
5657For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
5658
5659| ID        | Error Message       |
5660| --------------- | --------------- |
5661| 7400103                |  Session not config.                                   |
5662
5663**Example**
5664
5665```ts
5666import { BusinessError } from '@kit.BasicServicesKit';
5667
5668function setZoomRatio(photoSession: camera.PhotoSession, zoomRatioRange: Array<number>): void {
5669  if (zoomRatioRange === undefined || zoomRatioRange.length <= 0) {
5670    return;
5671  }
5672  let zoomRatio = zoomRatioRange[0];
5673  try {
5674    photoSession.setZoomRatio(zoomRatio);
5675  } catch (error) {
5676    // If the operation fails, error.code is returned and processed.
5677    let err = error as BusinessError;
5678    console.error(`The setZoomRatio call failed. error code: ${err.code}`);
5679  }
5680}
5681```
5682
5683### getZoomRatio<sup>11+</sup>
5684
5685getZoomRatio(): number
5686
5687Obtains the zoom ratio in use.
5688
5689**System capability**: SystemCapability.Multimedia.Camera.Core
5690
5691**Return value**
5692
5693| Type       | Description                         |
5694| ---------- | ----------------------------- |
5695| number    | Zoom ratio obtained. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
5696
5697**Error codes**
5698
5699For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
5700
5701| ID        | Error Message       |
5702| --------------- | --------------- |
5703| 7400103                |  Session not config.                                   |
5704| 7400201                |  Camera service fatal error.                           |
5705
5706**Example**
5707
5708```ts
5709import { BusinessError } from '@kit.BasicServicesKit';
5710
5711function getZoomRatio(photoSession: camera.PhotoSession): number {
5712  const invalidValue: number = -1;
5713  let zoomRatio: number = invalidValue;
5714  try {
5715    zoomRatio = photoSession.getZoomRatio();
5716  } catch (error) {
5717    // If the operation fails, error.code is returned and processed.
5718    let err = error as BusinessError;
5719    console.error(`The getZoomRatio call failed. error code: ${err.code}`);
5720  }
5721  return zoomRatio;
5722}
5723```
5724
5725### setSmoothZoom<sup>11+</sup>
5726
5727setSmoothZoom(targetRatio: number, mode?: SmoothZoomMode): void
5728
5729Sets smooth zoom.
5730
5731**System capability**: SystemCapability.Multimedia.Camera.Core
5732
5733**Parameters**
5734
5735| Name      | Type           | Mandatory| Description              |
5736| ------------ | -------------- | ---- | ----------------- |
5737| targetRatio  | number         | Yes  | Target zoom ratio.     |
5738| mode         | [SmoothZoomMode](#smoothzoommode11) | No  | Smooth zoom mode.     |
5739
5740**Error codes**
5741
5742For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
5743
5744| ID        | Error Message       |
5745| --------------- | --------------- |
5746| 7400103                |  Session not config.                                   |
5747
5748**Example**
5749
5750```ts
5751import { BusinessError } from '@kit.BasicServicesKit';
5752
5753function setSmoothZoom(sessionExtendsZoom: camera.Zoom, targetZoomRatio: number, mode: camera.SmoothZoomMode): void {
5754  try {
5755    sessionExtendsZoom.setSmoothZoom(targetZoomRatio, mode);
5756  } catch (error) {
5757    // If the operation fails, error.code is returned and processed.
5758    let err = error as BusinessError;
5759    console.error(`The setSmoothZoom call failed. error code: ${err.code}`);
5760  }
5761}
5762```
5763
5764## ZoomQuery<sup>12+</sup>
5765
5766Provides APIs to query the zoom feature of a device camera, including the API to obtain the supported zoom ratio range.
5767
5768### getZoomRatioRange<sup>11+</sup>
5769
5770getZoomRatioRange(): Array\<number\>
5771
5772Obtains the supported zoom ratio range.
5773
5774**System capability**: SystemCapability.Multimedia.Camera.Core
5775
5776**Return value**
5777
5778| Type       | Description                         |
5779| ---------- | ----------------------------- |
5780| Array\<number\>   | Array containing the minimum and maximum zoom ratios. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
5781
5782**Error codes**
5783
5784For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
5785
5786| ID        | Error Message       |
5787| --------------- | --------------- |
5788| 7400103                |  Session not config, only throw in session usage.            |
5789
5790**Example**
5791
5792```ts
5793import { BusinessError } from '@kit.BasicServicesKit';
5794
5795function getZoomRatioRange(photoSession: camera.PhotoSession): Array<number> {
5796  let zoomRatioRange: Array<number> = [];
5797  try {
5798    zoomRatioRange = photoSession.getZoomRatioRange();
5799  } catch (error) {
5800    // If the operation fails, error.code is returned and processed.
5801    let err = error as BusinessError;
5802    console.error(`The getZoomRatioRange call failed. error code: ${err.code}`);
5803  }
5804  return zoomRatioRange;
5805}
5806```
5807
5808## Stabilization<sup>11+</sup>
5809
5810Stabilization extends [StabilizationQuery](#stabilizationquery12)
5811
5812Provides APIs to set video stabilization.
5813
5814 > **NOTE**
5815 >
5816 > You can set video stabilization only when a [VideoOutput](#videooutput) stream exists in the session.
5817 > The enumerated value **HIGH** of [VideoStabilizationMode](#videostabilizationmode) takes effect only when the resolution of [Profile](#profile) is 1920 x 1080.
5818
5819### getActiveVideoStabilizationMode<sup>11+</sup>
5820
5821getActiveVideoStabilizationMode(): VideoStabilizationMode
5822
5823Obtains the video stabilization mode in use.
5824
5825**System capability**: SystemCapability.Multimedia.Camera.Core
5826
5827**Return value**
5828
5829| Type       | Description         |
5830| ---------- |-------------|
5831| [VideoStabilizationMode](#videostabilizationmode)    | Video stabilization mode obtained.|
5832
5833**Error codes**
5834
5835For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
5836
5837| ID        | Error Message       |
5838| --------------- | --------------- |
5839| 7400103                |  Session not config.                                   |
5840
5841**Example**
5842
5843```ts
5844import { BusinessError } from '@kit.BasicServicesKit';
5845
5846function getActiveVideoStabilizationMode(videoSession: camera.VideoSession): camera.VideoStabilizationMode | undefined {
5847  let vsMode: camera.VideoStabilizationMode | undefined = undefined;
5848  try {
5849    vsMode = videoSession.getActiveVideoStabilizationMode();
5850  } catch (error) {
5851    // If the operation fails, error.code is returned and processed.
5852    let err = error as BusinessError;
5853    console.error(`The getActiveVideoStabilizationMode call failed. error code: ${err.code}`);
5854  }
5855  return vsMode;
5856}
5857```
5858
5859### setVideoStabilizationMode<sup>11+</sup>
5860
5861setVideoStabilizationMode(mode: VideoStabilizationMode): void
5862
5863Sets a video stabilization mode. Before the setting, call [isVideoStabilizationModeSupported](#isvideostabilizationmodesupported11) to check whether the target video stabilization mode is supported.
5864
5865**System capability**: SystemCapability.Multimedia.Camera.Core
5866
5867**Parameters**
5868
5869| Name     | Type                                             | Mandatory| Description                   |
5870| -------- | ------------------------------------------------- | ---- | --------------------- |
5871| mode     | [VideoStabilizationMode](#videostabilizationmode) | Yes  | Video stabilization mode.  |
5872
5873**Error codes**
5874
5875For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
5876
5877| ID        | Error Message       |
5878| --------------- | --------------- |
5879| 7400103                |  Session not config.                                   |
5880
5881**Example**
5882
5883```ts
5884import { BusinessError } from '@kit.BasicServicesKit';
5885
5886function setVideoStabilizationMode(videoSession: camera.VideoSession): void {
5887  try {
5888    videoSession.setVideoStabilizationMode(camera.VideoStabilizationMode.OFF);
5889  } catch (error) {
5890    // If the operation fails, error.code is returned and processed.
5891    let err = error as BusinessError;
5892    console.error(`The setVideoStabilizationMode call failed. error code: ${err.code}`);
5893  }
5894}
5895```
5896
5897## StabilizationQuery<sup>12+</sup>
5898
5899Provides APIs to check the support for video stabilization.
5900
5901### isVideoStabilizationModeSupported<sup>11+</sup>
5902
5903isVideoStabilizationModeSupported(vsMode: VideoStabilizationMode): boolean
5904
5905Checks whether a video stabilization mode is supported.
5906
5907**System capability**: SystemCapability.Multimedia.Camera.Core
5908
5909**Parameters**
5910
5911| Name     | Type                                             | Mandatory| Description                            |
5912| -------- | ------------------------------------------------- | ---- | ------------------------------ |
5913| vsMode   | [VideoStabilizationMode](#videostabilizationmode) | Yes  | Video stabilization mode.                   |
5914
5915**Return value**
5916
5917| Type       | Description                         |
5918| ---------- | ----------------------------- |
5919| boolean    | **true**: The video stabilization mode is supported.<br>**false**: The video stabilization mode is not supported. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
5920
5921**Error codes**
5922
5923For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
5924
5925| ID        | Error Message       |
5926| --------------- | --------------- |
5927| 7400103                |  Session not config, only throw in session usage.             |
5928
5929**Example**
5930
5931```ts
5932import { BusinessError } from '@kit.BasicServicesKit';
5933
5934function isVideoStabilizationModeSupported(videoSession: camera.VideoSession): boolean {
5935  let isSupported: boolean = false;
5936  try {
5937    isSupported = videoSession.isVideoStabilizationModeSupported(camera.VideoStabilizationMode.OFF);
5938  } catch (error) {
5939    // If the operation fails, error.code is returned and processed.
5940    let err = error as BusinessError;
5941    console.error(`The isVideoStabilizationModeSupported call failed. error code: ${err.code}`);
5942  }
5943  return isSupported;
5944}
5945```
5946
5947## CaptureSession<sup>(deprecated)</sup>
5948
5949Implements a capture session, which saves all [CameraInput](#camerainput) and [CameraOutput](#cameraoutput) instances required to run the camera and requests the camera to complete shooting or video recording.
5950
5951> **NOTE**
5952>
5953>This API is supported since API version 10 and deprecated since API version 11. You are advised to use [PhotoSession](#photosession11) and [VideoSession](#videosession11) instead.
5954
5955### beginConfig<sup>(deprecated)</sup>
5956
5957beginConfig(): void
5958
5959Starts configuration for the session.
5960
5961> **NOTE**
5962>
5963>This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Session.beginConfig](#beginconfig11) instead.
5964
5965**System capability**: SystemCapability.Multimedia.Camera.Core
5966
5967**Error codes**
5968
5969For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
5970
5971| ID        | Error Message       |
5972| --------------- | --------------- |
5973| 7400105         |  Session config locked.               |
5974
5975**Example**
5976
5977```ts
5978import { BusinessError } from '@kit.BasicServicesKit';
5979
5980function beginConfig(captureSession: camera.CaptureSession): void {
5981  try {
5982    captureSession.beginConfig();
5983  } catch (error) {
5984    // If the operation fails, error.code is returned and processed.
5985    let err = error as BusinessError;
5986    console.error(`The beginConfig call failed. error code: ${err.code}`);
5987  }
5988}
5989```
5990
5991### commitConfig<sup>(deprecated)</sup>
5992
5993commitConfig(callback: AsyncCallback\<void\>): void
5994
5995Commits the configuration for this session. This API uses an asynchronous callback to return the result.
5996
5997> **NOTE**
5998>
5999>This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Session.commitConfig](#commitconfig11) instead.
6000
6001**System capability**: SystemCapability.Multimedia.Camera.Core
6002
6003**Parameters**
6004
6005| Name    | Type                  | Mandatory| Description                 |
6006| -------- | -------------------- | ---- | -------------------- |
6007| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
6008
6009**Error codes**
6010
6011For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
6012
6013| ID        | Error Message       |
6014| --------------- | --------------- |
6015| 7400102                |  Operation not allowed.                                  |
6016| 7400201                |  Camera service fatal error.                           |
6017
6018**Example**
6019
6020```ts
6021import { BusinessError } from '@kit.BasicServicesKit';
6022
6023function commitConfig(captureSession: camera.CaptureSession): void {
6024  captureSession.commitConfig((err: BusinessError) => {
6025    if (err) {
6026      console.error(`The commitConfig call failed. error code: ${err.code}`);
6027      return;
6028    }
6029    console.info('Callback invoked to indicate the commit config success.');
6030  });
6031}
6032```
6033
6034### commitConfig<sup>(deprecated)</sup>
6035
6036commitConfig(): Promise\<void\>
6037
6038Commits the configuration for this session. This API uses a promise to return the result.
6039
6040> **NOTE**
6041>
6042>This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Session.commitConfig](#commitconfig11-1) instead.
6043
6044**System capability**: SystemCapability.Multimedia.Camera.Core
6045
6046**Return value**
6047
6048| Type           | Description               |
6049| -------------- |-------------------|
6050| Promise\<void\> | Promise that returns no value.|
6051
6052**Error codes**
6053
6054For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
6055
6056| ID        | Error Message       |
6057| --------------- | --------------- |
6058| 7400102                |  Operation not allowed.                                  |
6059| 7400201                |  Camera service fatal error.                           |
6060
6061**Example**
6062
6063```ts
6064import { BusinessError } from '@kit.BasicServicesKit';
6065
6066function commitConfig(captureSession: camera.CaptureSession): void {
6067  captureSession.commitConfig().then(() => {
6068    console.info('Promise returned to indicate the commit config success.');
6069  }).catch((error: BusinessError) => {
6070    // If the operation fails, error.code is returned and processed.
6071    console.error(`The commitConfig call failed. error code: ${error.code}`);
6072  });
6073}
6074```
6075
6076### addInput<sup>(deprecated)</sup>
6077
6078addInput(cameraInput: CameraInput): void
6079
6080Adds a [CameraInput](#camerainput) instance to this session.
6081
6082> **NOTE**
6083>
6084>This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Session.addInput](#addinput11) instead.
6085
6086**System capability**: SystemCapability.Multimedia.Camera.Core
6087
6088**Parameters**
6089
6090| Name       | Type                         | Mandatory| Description                    |
6091| ----------- | --------------------------- | ---- | ------------------------ |
6092| cameraInput | [CameraInput](#camerainput) | Yes  | **CameraInput** instance to add.|
6093
6094**Error codes**
6095
6096For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
6097
6098| ID  | Error Message                                         |
6099|---------|-----------------------------------------------|
6100| 7400101 | Parameter missing or parameter type incorrect. |
6101| 7400102 | Operation not allowed.                           |
6102
6103**Example**
6104
6105```ts
6106import { BusinessError } from '@kit.BasicServicesKit';
6107
6108function addInput(captureSession: camera.CaptureSession, cameraInput: camera.CameraInput): void {
6109  try {
6110    captureSession.addInput(cameraInput);
6111  } catch (error) {
6112    // If the operation fails, error.code is returned and processed.
6113    let err = error as BusinessError;
6114    console.error(`The addInput call failed. error code: ${err.code}`);
6115  }
6116}
6117```
6118
6119### removeInput<sup>(deprecated)</sup>
6120
6121removeInput(cameraInput: CameraInput): void
6122
6123Removes a [CameraInput](#camerainput) instance from this session.
6124
6125> **NOTE**
6126>
6127>This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Session.removeInput](#removeinput11) instead.
6128
6129**System capability**: SystemCapability.Multimedia.Camera.Core
6130
6131**Parameters**
6132
6133| Name       | Type                         | Mandatory| Description                     |
6134| ----------- | --------------------------- | ---- | ------------------------ |
6135| cameraInput | [CameraInput](#camerainput) | Yes  | **CameraInput** instance to remove.|
6136
6137**Error codes**
6138
6139For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
6140
6141| ID        | Error Message       |
6142| --------------- | --------------- |
6143| 7400101                |  Parameter missing or parameter type incorrect.        |
6144| 7400102                |  Operation not allowed.                                  |
6145
6146**Example**
6147
6148```ts
6149import { BusinessError } from '@kit.BasicServicesKit';
6150
6151function removeInput(captureSession: camera.CaptureSession, cameraInput: camera.CameraInput): void {
6152  try {
6153    captureSession.removeInput(cameraInput);
6154  } catch (error) {
6155    // If the operation fails, error.code is returned and processed.
6156    let err = error as BusinessError;
6157    console.error(`The removeInput call failed. error code: ${err.code}`);
6158  }
6159}
6160```
6161
6162### addOutput<sup>(deprecated)</sup>
6163
6164addOutput(cameraOutput: CameraOutput): void
6165
6166Adds a [CameraOutput](#cameraoutput) instance to this session.
6167
6168> **NOTE**
6169>
6170>This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Session.addOutput](#addoutput11) instead.
6171
6172**System capability**: SystemCapability.Multimedia.Camera.Core
6173
6174**Parameters**
6175
6176| Name          | Type                            | Mandatory| Description                     |
6177| ------------- | ------------------------------- | ---- | ------------------------ |
6178| cameraOutput  | [CameraOutput](#cameraoutput)   | Yes  | **CameraOutput** instance to add.|
6179
6180**Error codes**
6181
6182For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
6183
6184| ID        | Error Message       |
6185| --------------- | --------------- |
6186| 7400101                |  Parameter missing or parameter type incorrect.        |
6187| 7400102                |  Operation not allowed.                                  |
6188
6189**Example**
6190
6191```ts
6192import { BusinessError } from '@kit.BasicServicesKit';
6193
6194function addOutput(captureSession: camera.CaptureSession, cameraOutput: camera.CameraOutput): void {
6195  try {
6196    captureSession.addOutput(cameraOutput);
6197  } catch (error) {
6198    // If the operation fails, error.code is returned and processed.
6199    let err = error as BusinessError;
6200    console.error(`The addOutput call failed. error code: ${err.code}`);
6201  }
6202}
6203```
6204
6205### removeOutput<sup>(deprecated)</sup>
6206
6207removeOutput(cameraOutput: CameraOutput): void
6208
6209Removes a [CameraOutput](#cameraoutput) instance from this session.
6210
6211> **NOTE**
6212>
6213>This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Session.removeOutput](#removeoutput11) instead.
6214
6215**System capability**: SystemCapability.Multimedia.Camera.Core
6216
6217**Parameters**
6218
6219| Name          | Type                            | Mandatory| Description                     |
6220| ------------- | ------------------------------- | ---- | ------------------------ |
6221| cameraOutput  | [CameraOutput](#cameraoutput)   | Yes  | **CameraOutput** instance to remove.|
6222
6223**Error codes**
6224
6225For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
6226
6227| ID        | Error Message       |
6228| --------------- | --------------- |
6229| 7400101                |  Parameter missing or parameter type incorrect.        |
6230| 7400102                |  Operation not allowed.                                  |
6231
6232**Example**
6233
6234```ts
6235import { BusinessError } from '@kit.BasicServicesKit';
6236
6237function removeOutput(captureSession: camera.CaptureSession, previewOutput: camera.PreviewOutput): void {
6238  try {
6239    captureSession.removeOutput(previewOutput);
6240  } catch (error) {
6241    // If the operation fails, error.code is returned and processed.
6242    let err = error as BusinessError;
6243    console.error(`The removeOutput call failed. error code: ${err.code}`);
6244  }
6245}
6246```
6247
6248### start<sup>(deprecated)</sup>
6249
6250start(callback: AsyncCallback\<void\>): void
6251
6252Starts this session. This API uses an asynchronous callback to return the result.
6253
6254> **NOTE**
6255>
6256>This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Session.start](#start11) instead.
6257
6258**System capability**: SystemCapability.Multimedia.Camera.Core
6259
6260**Parameters**
6261
6262| Name     | Type                 | Mandatory| Description                |
6263| -------- | -------------------- | ---- | -------------------- |
6264| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
6265
6266**Error codes**
6267
6268For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
6269
6270| ID        | Error Message       |
6271| --------------- | --------------- |
6272| 7400103                |  Session not config.                                   |
6273| 7400201                |  Camera service fatal error.                           |
6274
6275**Example**
6276
6277```ts
6278import { BusinessError } from '@kit.BasicServicesKit';
6279
6280function startCaptureSession(captureSession: camera.CaptureSession): void {
6281  captureSession.start((err: BusinessError) => {
6282    if (err) {
6283      console.error(`Failed to start the session, error code: ${err.code}.`);
6284      return;
6285    }
6286    console.info('Callback invoked to indicate the session start success.');
6287  });
6288}
6289```
6290
6291### start<sup>(deprecated)</sup>
6292
6293start(): Promise\<void\>
6294
6295Starts this session. This API uses a promise to return the result.
6296
6297> **NOTE**
6298>
6299>This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Session.start](#start11-1) instead.
6300
6301**System capability**: SystemCapability.Multimedia.Camera.Core
6302
6303**Return value**
6304
6305| Type           | Description                    |
6306| -------------- | ------------------------ |
6307| Promise\<void\> | Promise that returns no value.|
6308
6309**Error codes**
6310
6311For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
6312
6313| ID        | Error Message       |
6314| --------------- | --------------- |
6315| 7400103                |  Session not config.                                   |
6316| 7400201                |  Camera service fatal error.                           |
6317
6318**Example**
6319
6320```ts
6321import { BusinessError } from '@kit.BasicServicesKit';
6322
6323function startCaptureSession(captureSession: camera.CaptureSession): void {
6324  captureSession.start().then(() => {
6325    console.info('Promise returned to indicate the session start success.');
6326  }).catch((err: BusinessError) => {
6327    console.error(`Failed to start the session, error code: ${err.code}.`);
6328  });
6329}
6330```
6331
6332### stop<sup>(deprecated)</sup>
6333
6334stop(callback: AsyncCallback\<void\>): void
6335
6336Stops this session. This API uses an asynchronous callback to return the result.
6337
6338> **NOTE**
6339>
6340>This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Session.stop](#stop11) instead.
6341
6342**System capability**: SystemCapability.Multimedia.Camera.Core
6343
6344**Parameters**
6345
6346| Name     | Type                 | Mandatory| Description                |
6347| -------- | -------------------- | ---- | ------------------- |
6348| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
6349
6350**Error codes**
6351
6352For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
6353
6354| ID        | Error Message       |
6355| --------------- | --------------- |
6356| 7400201                |  Camera service fatal error.                           |
6357
6358**Example**
6359
6360```ts
6361import { BusinessError } from '@kit.BasicServicesKit';
6362
6363function stopCaptureSession(captureSession: camera.CaptureSession): void {
6364  captureSession.stop((err: BusinessError) => {
6365    if (err) {
6366      console.error(`Failed to stop the session, error code: ${err.code}.`);
6367      return;
6368    }
6369    console.info('Callback invoked to indicate the session stop success.');
6370  });
6371}
6372```
6373
6374### stop<sup>(deprecated)</sup>
6375
6376stop(): Promise\<void\>
6377
6378Stops this session. This API uses a promise to return the result.
6379
6380> **NOTE**
6381>
6382>This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Session.stop](#stop11-1) instead.
6383
6384**System capability**: SystemCapability.Multimedia.Camera.Core
6385
6386**Return value**
6387
6388| Type           | Description                    |
6389| -------------- | ----------------------- |
6390| Promise\<void\> | Promise that returns no value.|
6391
6392**Error codes**
6393
6394For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
6395
6396| ID        | Error Message       |
6397| --------------- | --------------- |
6398| 7400201                |  Camera service fatal error.                           |
6399
6400**Example**
6401
6402```ts
6403import { BusinessError } from '@kit.BasicServicesKit';
6404
6405function stopCaptureSession(captureSession: camera.CaptureSession): void {
6406  captureSession.stop().then(() => {
6407    console.info('Promise returned to indicate the session stop success.');
6408  }).catch((err: BusinessError) => {
6409    console.error(`Failed to stop the session, error code: ${err.code}.`);
6410  });
6411}
6412```
6413
6414### release<sup>(deprecated)</sup>
6415
6416release(callback: AsyncCallback\<void\>): void
6417
6418Releases this session. This API uses an asynchronous callback to return the result.
6419
6420> **NOTE**
6421>
6422>This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Session.release](#release11-1) instead.
6423
6424**System capability**: SystemCapability.Multimedia.Camera.Core
6425
6426**Parameters**
6427
6428| Name     | Type                 | Mandatory| Description                |
6429| -------- | -------------------- | ---- | -------------------- |
6430| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
6431
6432**Error codes**
6433
6434For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
6435
6436| ID        | Error Message       |
6437| --------------- | --------------- |
6438| 7400201                |  Camera service fatal error.                           |
6439
6440**Example**
6441
6442```ts
6443import { BusinessError } from '@kit.BasicServicesKit';
6444
6445function releaseCaptureSession(captureSession: camera.CaptureSession): void {
6446  captureSession.release((err: BusinessError) => {
6447    if (err) {
6448      console.error(`Failed to release the CaptureSession instance, error code: ${err.code}.`);
6449      return;
6450    }
6451    console.info('Callback invoked to indicate that the CaptureSession instance is released successfully.');
6452  });
6453}
6454```
6455
6456### release<sup>(deprecated)</sup>
6457
6458release(): Promise\<void\>
6459
6460Releases this session. This API uses a promise to return the result.
6461
6462> **NOTE**
6463>
6464>This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Session.release](#release11-2) instead.
6465
6466**System capability**: SystemCapability.Multimedia.Camera.Core
6467
6468**Return value**
6469
6470| Type           | Description                    |
6471| -------------- | ------------------------ |
6472| Promise\<void\> | Promise that returns no value.|
6473
6474**Error codes**
6475
6476For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
6477
6478| ID        | Error Message       |
6479| --------------- | --------------- |
6480| 7400201                |  Camera service fatal error.                           |
6481
6482**Example**
6483
6484```ts
6485import { BusinessError } from '@kit.BasicServicesKit';
6486
6487function releaseCaptureSession(captureSession: camera.CaptureSession): void {
6488  captureSession.release().then(() => {
6489    console.info('Promise returned to indicate that the CaptureSession instance is released successfully.');
6490  }).catch((err: BusinessError) => {
6491    console.error(`Failed to release the CaptureSession instance, error code: ${err.code}.`);
6492  });
6493}
6494```
6495
6496### hasFlash<sup>(deprecated)</sup>
6497
6498hasFlash(): boolean
6499
6500Checks whether the camera device has flash.
6501
6502> **NOTE**
6503>
6504>This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Flash.hasFlash](#hasflash11) instead.
6505
6506**System capability**: SystemCapability.Multimedia.Camera.Core
6507
6508**Return value**
6509
6510| Type       | Description                         |
6511| ---------- | ----------------------------- |
6512| boolean    | **true**: The camera device has flash.<br>**false**: The camera device does not have flash. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
6513
6514**Error codes**
6515
6516For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
6517
6518| ID        | Error Message       |
6519| --------------- | --------------- |
6520| 7400103                |  Session not config.                                   |
6521
6522**Example**
6523
6524```ts
6525import { BusinessError } from '@kit.BasicServicesKit';
6526
6527function hasFlash(captureSession: camera.CaptureSession): boolean {
6528  let status: boolean = false;
6529  try {
6530    status = captureSession.hasFlash();
6531  } catch (error) {
6532    // If the operation fails, error.code is returned and processed.
6533    let err = error as BusinessError;
6534    console.error(`The hasFlash call failed. error code: ${err.code}`);
6535  }
6536  return status;
6537}
6538```
6539
6540### isFlashModeSupported<sup>(deprecated)</sup>
6541
6542isFlashModeSupported(flashMode: FlashMode): boolean
6543
6544Checks whether a flash mode is supported.
6545
6546> **NOTE**
6547>
6548>This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Flash.isFlashModeSupported](#isflashmodesupported11) instead.
6549
6550**System capability**: SystemCapability.Multimedia.Camera.Core
6551
6552**Parameters**
6553
6554| Name      | Type                    | Mandatory| Description                              |
6555| --------- | ----------------------- | ---- | --------------------------------- |
6556| flashMode | [FlashMode](#flashmode) | Yes  | Flash mode.                    |
6557
6558**Return value**
6559
6560| Type       | Description                         |
6561| ---------- | ----------------------------- |
6562| boolean    | **true**: The flash mode is supported.<br>**false**: The flash mode is not supported. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
6563
6564**Error codes**
6565
6566For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
6567
6568| ID        | Error Message       |
6569| --------------- | --------------- |
6570| 7400103                |  Session not config.                                   |
6571
6572**Example**
6573
6574```ts
6575import { BusinessError } from '@kit.BasicServicesKit';
6576
6577function isFlashModeSupported(captureSession: camera.CaptureSession): boolean {
6578  let status: boolean = false;
6579  try {
6580    status = captureSession.isFlashModeSupported(camera.FlashMode.FLASH_MODE_AUTO);
6581  } catch (error) {
6582    // If the operation fails, error.code is returned and processed.
6583    let err = error as BusinessError;
6584    console.error(`The isFlashModeSupported call failed. error code: ${err.code}`);
6585  }
6586  return status;
6587}
6588```
6589
6590### setFlashMode<sup>(deprecated)</sup>
6591
6592setFlashMode(flashMode: FlashMode): void
6593
6594Sets a flash mode.
6595
6596Before the setting, do the following checks:
6597
65981. Use [hasFlash](#hasflashdeprecated) to check whether the camera device has flash.
65992. Use [isFlashModeSupported](#isflashmodesupporteddeprecated) to check whether the camera device supports the flash mode.
6600
6601> **NOTE**
6602>
6603>This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Flash.setFlashMode](#setflashmode11) instead.
6604
6605**System capability**: SystemCapability.Multimedia.Camera.Core
6606
6607**Parameters**
6608
6609| Name    | Type                   | Mandatory| Description                |
6610| --------- | ----------------------- | ---- | -------------------- |
6611| flashMode | [FlashMode](#flashmode) | Yes  | Flash mode.      |
6612
6613**Error codes**
6614
6615For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
6616
6617| ID        | Error Message       |
6618| --------------- | --------------- |
6619| 7400103                |  Session not config.                                   |
6620
6621**Example**
6622
6623```ts
6624import { BusinessError } from '@kit.BasicServicesKit';
6625
6626function setFlashMode(captureSession: camera.CaptureSession): void {
6627  try {
6628    captureSession.setFlashMode(camera.FlashMode.FLASH_MODE_AUTO);
6629  } catch (error) {
6630    // If the operation fails, error.code is returned and processed.
6631    let err = error as BusinessError;
6632    console.error(`The setFlashMode call failed. error code: ${err.code}`);
6633  }
6634}
6635```
6636
6637### getFlashMode<sup>(deprecated)</sup>
6638
6639getFlashMode(): FlashMode
6640
6641Obtains the flash mode in use.
6642
6643> **NOTE**
6644>
6645>This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Flash.getFlashMode](#getflashmode11) instead.
6646
6647**System capability**: SystemCapability.Multimedia.Camera.Core
6648
6649**Return value**
6650
6651| Type       | Description                         |
6652| ---------- | ----------------------------- |
6653| [FlashMode](#flashmode)    | Flash mode obtained. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
6654
6655**Error codes**
6656
6657For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
6658
6659| ID        | Error Message       |
6660| --------------- | --------------- |
6661| 7400103                |  Session not config.                                   |
6662
6663**Example**
6664
6665```ts
6666import { BusinessError } from '@kit.BasicServicesKit';
6667
6668function getFlashMode(captureSession: camera.CaptureSession): camera.FlashMode | undefined {
6669  let flashMode: camera.FlashMode | undefined = undefined;
6670  try {
6671    flashMode = captureSession.getFlashMode();
6672  } catch (error) {
6673    // If the operation fails, error.code is returned and processed.
6674    let err = error as BusinessError;
6675    console.error(`The getFlashMode call failed.error code: ${err.code}`);
6676  }
6677  return flashMode;
6678}
6679```
6680
6681### isExposureModeSupported<sup>(deprecated)</sup>
6682
6683isExposureModeSupported(aeMode: ExposureMode): boolean
6684
6685Checks whether an exposure mode is supported.
6686
6687> **NOTE**
6688>
6689>This API is supported since API version 10 and deprecated since API version 11. You are advised to use [AutoExposure.isExposureModeSupported](#isexposuremodesupported11) instead.
6690
6691**System capability**: SystemCapability.Multimedia.Camera.Core
6692
6693**Parameters**
6694
6695| Name     | Type                          | Mandatory | Description                          |
6696| -------- | -------------------------------| ---- | ----------------------------- |
6697| aeMode   | [ExposureMode](#exposuremode)  | Yes  | Exposure mode.                     |
6698
6699**Return value**
6700
6701| Type       | Description                         |
6702| ---------- | ----------------------------- |
6703| boolean    | **true**: The exposure mode is supported.<br>**false**: The exposure mode is not supported. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
6704
6705**Error codes**
6706
6707For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
6708
6709| ID        | Error Message       |
6710| --------------- | --------------- |
6711| 7400103                |  Session not config.                                   |
6712
6713**Example**
6714
6715```ts
6716import { BusinessError } from '@kit.BasicServicesKit';
6717
6718function isExposureModeSupported(captureSession: camera.CaptureSession): boolean {
6719  let isSupported: boolean = false;
6720  try {
6721    isSupported = captureSession.isExposureModeSupported(camera.ExposureMode.EXPOSURE_MODE_LOCKED);
6722  } catch (error) {
6723    // If the operation fails, error.code is returned and processed.
6724    let err = error as BusinessError;
6725    console.error(`The isExposureModeSupported call failed. error code: ${err.code}`);
6726  }
6727  return isSupported;
6728}
6729```
6730
6731### getExposureMode<sup>(deprecated)</sup>
6732
6733getExposureMode(): ExposureMode
6734
6735Obtains the exposure mode in use.
6736
6737> **NOTE**
6738>
6739>This API is supported since API version 10 and deprecated since API version 11. You are advised to use [AutoExposure.getExposureMode](#getexposuremode11) instead.
6740
6741**System capability**: SystemCapability.Multimedia.Camera.Core
6742
6743**Return value**
6744
6745| Type       | Description                         |
6746| ---------- | ----------------------------- |
6747| [ExposureMode](#exposuremode)    | Exposure mode obtained. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
6748
6749**Error codes**
6750
6751For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
6752
6753| ID        | Error Message       |
6754| --------------- | --------------- |
6755| 7400103                |  Session not config.                                   |
6756
6757**Example**
6758
6759```ts
6760import { BusinessError } from '@kit.BasicServicesKit';
6761
6762function getExposureMode(captureSession: camera.CaptureSession): camera.ExposureMode | undefined {
6763  let exposureMode: camera.ExposureMode | undefined = undefined;
6764  try {
6765    exposureMode = captureSession.getExposureMode();
6766  } catch (error) {
6767    // If the operation fails, error.code is returned and processed.
6768    let err = error as BusinessError;
6769    console.error(`The getExposureMode call failed. error code: ${err.code}`);
6770  }
6771  return exposureMode;
6772}
6773```
6774
6775### setExposureMode<sup>(deprecated)</sup>
6776
6777setExposureMode(aeMode: ExposureMode): void
6778
6779Sets an exposure mode. Before the setting, call [isExposureModeSupported](#isexposuremodesupporteddeprecated) to check whether the target exposure mode is supported.
6780
6781> **NOTE**
6782>
6783>This API is supported since API version 10 and deprecated since API version 11. You are advised to use [AutoExposure.setExposureMode](#setexposuremode11) instead.
6784
6785**System capability**: SystemCapability.Multimedia.Camera.Core
6786
6787**Parameters**
6788
6789| Name     | Type                           | Mandatory| Description                   |
6790| -------- | -------------------------------| ---- | ----------------------- |
6791| aeMode   | [ExposureMode](#exposuremode)  | Yes  | Exposure mode.               |
6792
6793**Error codes**
6794
6795For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
6796
6797| ID        | Error Message       |
6798| --------------- | --------------- |
6799| 7400103                |  Session not config.                                   |
6800
6801**Example**
6802
6803```ts
6804import { BusinessError } from '@kit.BasicServicesKit';
6805
6806function setExposureMode(captureSession: camera.CaptureSession): void {
6807  try {
6808    captureSession.setExposureMode(camera.ExposureMode.EXPOSURE_MODE_LOCKED);
6809  } catch (error) {
6810    // If the operation fails, error.code is returned and processed.
6811    let err = error as BusinessError;
6812    console.error(`The setExposureMode call failed. error code: ${err.code}`);
6813  }
6814}
6815```
6816
6817### getMeteringPoint<sup>(deprecated)</sup>
6818
6819getMeteringPoint(): Point
6820
6821Obtains the metering point of the camera device.
6822
6823> **NOTE**
6824>
6825>This API is supported since API version 10 and deprecated since API version 11. You are advised to use [AutoExposure.getMeteringPoint](#getmeteringpoint11) instead.
6826
6827**System capability**: SystemCapability.Multimedia.Camera.Core
6828
6829**Return value**
6830
6831| Type       | Description                         |
6832| ---------- | ----------------------------- |
6833| [Point](#point)    | Metering point obtained. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
6834
6835**Error codes**
6836
6837For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
6838
6839| ID        | Error Message       |
6840| --------------- | --------------- |
6841| 7400103                |  Session not config.                                   |
6842
6843**Example**
6844
6845```ts
6846import { BusinessError } from '@kit.BasicServicesKit';
6847
6848function getMeteringPoint(captureSession: camera.CaptureSession): camera.Point | undefined {
6849  let exposurePoint: camera.Point | undefined = undefined;
6850  try {
6851    exposurePoint = captureSession.getMeteringPoint();
6852  } catch (error) {
6853    // If the operation fails, error.code is returned and processed.
6854    let err = error as BusinessError;
6855    console.error(`The getMeteringPoint call failed. error code: ${err.code}`);
6856  }
6857  return exposurePoint;
6858}
6859```
6860
6861### setMeteringPoint<sup>(deprecated)</sup>
6862
6863setMeteringPoint(point: Point): void
6864
6865Sets the metering point, which is the center point of the metering rectangle.
6866
6867The metering point must be in the coordinate system (0-1), where the upper left corner is {0, 0} and the lower right corner is {1, 1}.
6868
6869The coordinate system is based on the horizontal device direction with the device's charging port on the right. If the layout of the preview screen of an application is based on the vertical direction with the charging port on the lower side, the layout width and height are {w, h}, and the touch point is {x, y}, then the coordinate point after conversion is {y/h, 1-x/w}.
6870
6871> **NOTE**
6872>
6873>This API is supported since API version 10 and deprecated since API version 11. You are advised to use [AutoExposure.setMeteringPoint](#setmeteringpoint11) instead.
6874
6875**System capability**: SystemCapability.Multimedia.Camera.Core
6876
6877**Parameters**
6878
6879| Name          | Type                           | Mandatory| Description                |
6880| ------------- | -------------------------------| ---- | ------------------- |
6881| point | [Point](#point)                | Yes  | Metering point. The value range of x and y must be within [0,1]. If a value less than 0 is passed, the value **0** is used. If a value greater than **1** is passed, the value **1** is used.            |
6882
6883**Error codes**
6884
6885For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
6886
6887| ID        | Error Message       |
6888| --------------- | --------------- |
6889| 7400103                |  Session not config.                                   |
6890
6891**Example**
6892
6893```ts
6894import { BusinessError } from '@kit.BasicServicesKit';
6895
6896function setMeteringPoint(captureSession: camera.CaptureSession): void {
6897  const point: camera.Point = {x: 1, y: 1};
6898  try {
6899    captureSession.setMeteringPoint(point);
6900  } catch (error) {
6901    // If the operation fails, error.code is returned and processed.
6902    let err = error as BusinessError;
6903    console.error(`The setMeteringPoint call failed. error code: ${err.code}`);
6904  }
6905}
6906```
6907
6908### getExposureBiasRange<sup>(deprecated)</sup>
6909
6910getExposureBiasRange(): Array\<number\>
6911
6912Obtains the exposure compensation values of the camera device.
6913
6914> **NOTE**
6915>
6916>This API is supported since API version 10 and deprecated since API version 11. You are advised to use [AutoExposure.getExposureBiasRange](#getexposurebiasrange11) instead.
6917
6918**System capability**: SystemCapability.Multimedia.Camera.Core
6919
6920**Return value**
6921
6922| Type       | Description                         |
6923| ---------- | ----------------------------- |
6924| Array\<number\>   | Array of compensation values. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
6925
6926**Error codes**
6927
6928For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
6929
6930| ID        | Error Message       |
6931| --------------- | --------------- |
6932| 7400103                |  Session not config.                                   |
6933
6934**Example**
6935
6936```ts
6937import { BusinessError } from '@kit.BasicServicesKit';
6938
6939function getExposureBiasRange(captureSession: camera.CaptureSession): Array<number> {
6940  let biasRangeArray: Array<number> = [];
6941  try {
6942    biasRangeArray = captureSession.getExposureBiasRange();
6943  } catch (error) {
6944    // If the operation fails, error.code is returned and processed.
6945    let err = error as BusinessError;
6946    console.error(`The getExposureBiasRange call failed. error code: ${err.code}`);
6947  }
6948  return biasRangeArray;
6949}
6950```
6951
6952### setExposureBias<sup>(deprecated)</sup>
6953
6954setExposureBias(exposureBias: number): void
6955
6956Sets an exposure compensation value (EV).
6957
6958Before the setting, you are advised to use [getExposureBiasRange](#getexposurebiasrangedeprecated) to obtain the supported values.
6959
6960> **NOTE**
6961>
6962>This API is supported since API version 10 and deprecated since API version 11. You are advised to use [AutoExposure.setExposureBias](#setexposurebias11) instead.
6963
6964**System capability**: SystemCapability.Multimedia.Camera.Core
6965
6966**Parameters**
6967
6968| Name    | Type                           | Mandatory | Description                                                                                                                                                                                   |
6969| -------- | -------------------------------|-----|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
6970| exposureBias   | number                   | Yes | EV. The supported EV range can be obtained by calling [getExposureBiasRange](#getexposurebiasrange11). If the value passed is not within the supported range, the nearest critical point is used. There is a step for EV. For example, if the step is 0.5 and this parameter is set to 1.2, the EV that takes effect is 1.0. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned. If the input parameter is null or undefined, the EV is set to 0.|
6971
6972**Error codes**
6973
6974For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
6975
6976| ID        | Error Message       |
6977| --------------- | --------------- |
6978| 7400103                |  Session not config.                                   |
6979
6980**Example**
6981
6982```ts
6983import { BusinessError } from '@kit.BasicServicesKit';
6984
6985function setExposureBias(captureSession: camera.CaptureSession, biasRangeArray: Array<number>): void {
6986  if (biasRangeArray && biasRangeArray.length > 0) {
6987    let exposureBias = biasRangeArray[0];
6988    try {
6989      captureSession.setExposureBias(exposureBias);
6990    } catch (error) {
6991      // If the operation fails, error.code is returned and processed.
6992      let err = error as BusinessError;
6993      console.error(`The setExposureBias call failed. error code: ${err.code}`);
6994    }
6995  }
6996}
6997```
6998
6999### getExposureValue<sup>(deprecated)</sup>
7000
7001getExposureValue(): number
7002
7003Obtains the exposure value in use.
7004
7005> **NOTE**
7006>
7007>This API is supported since API version 10 and deprecated since API version 11. You are advised to use [AutoExposure.getExposureValue](#getexposurevalue11) instead.
7008
7009**System capability**: SystemCapability.Multimedia.Camera.Core
7010
7011**Return value**
7012
7013| Type       | Description                         |
7014| ---------- | ----------------------------- |
7015| number    | Exposure value obtained. There is a step for EV. For example, if the step is 0.5 and this parameter is set to 1.2, the EV that takes effect is 1.0. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
7016
7017**Error codes**
7018
7019For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
7020
7021| ID        | Error Message       |
7022| --------------- | --------------- |
7023| 7400103                |  Session not config.                                   |
7024
7025**Example**
7026
7027```ts
7028import { BusinessError } from '@kit.BasicServicesKit';
7029
7030function getExposureValue(captureSession: camera.CaptureSession): number {
7031  const invalidValue: number = -1;
7032  let exposureValue: number = invalidValue;
7033  try {
7034    exposureValue = captureSession.getExposureValue();
7035  } catch (error) {
7036    // If the operation fails, error.code is returned and processed.
7037    let err = error as BusinessError;
7038    console.error(`The getExposureValue call failed. error code: ${err.code}`);
7039  }
7040  return exposureValue;
7041}
7042```
7043
7044### isFocusModeSupported<sup>(deprecated)</sup>
7045
7046isFocusModeSupported(afMode: FocusMode): boolean
7047
7048Checks whether a focus mode is supported.
7049
7050> **NOTE**
7051>
7052>This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Focus.isFocusModeSupported](#isfocusmodesupported11) instead.
7053
7054**System capability**: SystemCapability.Multimedia.Camera.Core
7055
7056**Parameters**
7057
7058| Name     | Type                    | Mandatory| Description                             |
7059| -------- | ----------------------- | ---- | -------------------------------- |
7060| afMode   | [FocusMode](#focusmode) | Yes  | Focus mode.                   |
7061
7062**Return value**
7063
7064| Type       | Description                         |
7065| ---------- | ----------------------------- |
7066| boolean    | **true**: The focus mode is supported.<br>**false**: The focus mode is not supported. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
7067
7068**Error codes**
7069
7070For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
7071
7072| ID        | Error Message       |
7073| --------------- | --------------- |
7074| 7400103                |  Session not config.                                   |
7075
7076**Example**
7077
7078```ts
7079import { BusinessError } from '@kit.BasicServicesKit';
7080
7081function isFocusModeSupported(captureSession: camera.CaptureSession): boolean {
7082  let status: boolean = false;
7083  try {
7084    status = captureSession.isFocusModeSupported(camera.FocusMode.FOCUS_MODE_AUTO);
7085  } catch (error) {
7086    // If the operation fails, error.code is returned and processed.
7087    let err = error as BusinessError;
7088    console.error(`The isFocusModeSupported call failed. error code: ${err.code}`);
7089  }
7090  return status;
7091}
7092```
7093
7094### setFocusMode<sup>(deprecated)</sup>
7095
7096setFocusMode(afMode: FocusMode): void
7097
7098Sets a focus mode.
7099
7100Before the setting, call [isFocusModeSupported](#isfocusmodesupporteddeprecated) to check whether the focus mode is supported.
7101
7102> **NOTE**
7103>
7104>This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Focus.setFocusMode](#setfocusmode11) instead.
7105
7106**System capability**: SystemCapability.Multimedia.Camera.Core
7107
7108**Parameters**
7109
7110| Name     | Type                    | Mandatory| Description                |
7111| -------- | ----------------------- | ---- | ------------------- |
7112| afMode   | [FocusMode](#focusmode) | Yes  | Focus mode.      |
7113
7114**Error codes**
7115
7116For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
7117
7118| ID        | Error Message       |
7119| --------------- | --------------- |
7120| 7400103                |  Session not config.                                   |
7121
7122**Example**
7123
7124```ts
7125import { BusinessError } from '@kit.BasicServicesKit';
7126
7127function setFocusMode(captureSession: camera.CaptureSession): void {
7128  try {
7129    captureSession.setFocusMode(camera.FocusMode.FOCUS_MODE_AUTO);
7130  } catch (error) {
7131    // If the operation fails, error.code is returned and processed.
7132    let err = error as BusinessError;
7133    console.error(`The setFocusMode call failed. error code: ${err.code}`);
7134  }
7135}
7136```
7137
7138### getFocusMode<sup>(deprecated)</sup>
7139
7140getFocusMode(): FocusMode
7141
7142Obtains the focus mode in use.
7143
7144> **NOTE**
7145>
7146>This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Focus.getFocusMode](#getfocusmode11) instead.
7147
7148**System capability**: SystemCapability.Multimedia.Camera.Core
7149
7150**Return value**
7151
7152| Type       | Description                         |
7153| ---------- | ----------------------------- |
7154| [FocusMode](#focusmode)   | Focus mode obtained. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
7155
7156**Error codes**
7157
7158For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
7159
7160| ID        | Error Message       |
7161| --------------- | --------------- |
7162| 7400103                |  Session not config.                                   |
7163
7164**Example**
7165
7166```ts
7167import { BusinessError } from '@kit.BasicServicesKit';
7168
7169function getFocusMode(captureSession: camera.CaptureSession): camera.FocusMode | undefined {
7170  let afMode: camera.FocusMode | undefined = undefined;
7171  try {
7172    afMode = captureSession.getFocusMode();
7173  } catch (error) {
7174    // If the operation fails, error.code is returned and processed.
7175    let err = error as BusinessError;
7176    console.error(`The getFocusMode call failed. error code: ${err.code}`);
7177  }
7178  return afMode;
7179}
7180```
7181
7182### setFocusPoint<sup>(deprecated)</sup>
7183
7184setFocusPoint(point: Point): void
7185
7186Sets the focal point. The focal point must be in the coordinate system (0-1), where the upper left corner is {0, 0} and the lower right corner is {1, 1}.
7187
7188The coordinate system is based on the horizontal device direction with the device's charging port on the right. If the layout of the preview screen of an application is based on the vertical direction with the charging port on the lower side, the layout width and height are {w, h}, and the touch point is {x, y}, then the coordinate point after conversion is {y/h, 1-x/w}.
7189
7190> **NOTE**
7191>
7192> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Focus.setFocusPoint](#setfocuspoint11) instead.
7193
7194**System capability**: SystemCapability.Multimedia.Camera.Core
7195
7196**Parameters**
7197
7198| Name  | Type                    | Mandatory | Description                |
7199|-------| ----------------------- |-----| ------------------- |
7200| point | [Point](#point)         | Yes | Focal point. The value range of x and y must be within [0,1]. If a value less than 0 is passed, the value **0** is used. If a value greater than **1** is passed, the value **1** is used.  |
7201
7202**Error codes**
7203
7204For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
7205
7206| ID        | Error Message       |
7207| --------------- | --------------- |
7208| 7400103                |  Session not config.                                   |
7209
7210**Example**
7211
7212```ts
7213import { BusinessError } from '@kit.BasicServicesKit';
7214
7215function setFocusPoint(captureSession: camera.CaptureSession): void {
7216  const focusPoint: camera.Point = {x: 1, y: 1};
7217  try {
7218    captureSession.setFocusPoint(focusPoint);
7219  } catch (error) {
7220    // If the operation fails, error.code is returned and processed.
7221    let err = error as BusinessError;
7222    console.error(`The setFocusPoint call failed. error code: ${err.code}`);
7223  }
7224}
7225```
7226
7227### getFocusPoint<sup>(deprecated)</sup>
7228
7229getFocusPoint(): Point
7230
7231Obtains the focal point of the camera device.
7232
7233> **NOTE**
7234>
7235> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Focus.getFocusPoint](#getfocuspoint11) instead.
7236
7237**System capability**: SystemCapability.Multimedia.Camera.Core
7238
7239**Return value**
7240
7241| Type       | Description                         |
7242| ---------- | ----------------------------- |
7243| [Point](#point)    | Focal point obtained. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
7244
7245**Error codes**
7246
7247For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
7248
7249| ID        | Error Message       |
7250| --------------- | --------------- |
7251| 7400103                |  Session not config.                                   |
7252
7253**Example**
7254
7255```ts
7256import { BusinessError } from '@kit.BasicServicesKit';
7257
7258function getFocusPoint(captureSession: camera.CaptureSession): camera.Point | undefined {
7259  let point: camera.Point | undefined = undefined;
7260  try {
7261    point = captureSession.getFocusPoint();
7262  } catch (error) {
7263    // If the operation fails, error.code is returned and processed.
7264    let err = error as BusinessError;
7265    console.error(`The getFocusPoint call failed. error code: ${err.code}`);
7266  }
7267  return point;
7268}
7269```
7270
7271### getFocalLength<sup>(deprecated)</sup>
7272
7273getFocalLength(): number
7274
7275Obtains the focal length of the camera device.
7276
7277> **NOTE**
7278>
7279> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Focus.getFocalLength](#getfocallength11) instead.
7280
7281**System capability**: SystemCapability.Multimedia.Camera.Core
7282
7283**Return value**
7284
7285| Type       | Description                         |
7286| ---------- | ----------------------------- |
7287| number    | Focal length obtained. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
7288
7289**Error codes**
7290
7291For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
7292
7293| ID        | Error Message       |
7294| --------------- | --------------- |
7295| 7400103                |  Session not config.                                   |
7296
7297**Example**
7298
7299```ts
7300import { BusinessError } from '@kit.BasicServicesKit';
7301
7302function getFocalLength(captureSession: camera.CaptureSession): number {
7303  const invalidValue: number = -1;
7304  let focalLength: number = invalidValue;
7305  try {
7306    focalLength = captureSession.getFocalLength();
7307  } catch (error) {
7308    // If the operation fails, error.code is returned and processed.
7309    let err = error as BusinessError;
7310    console.error(`The getFocalLength call failed. error code: ${err.code}`);
7311  }
7312  return focalLength;
7313}
7314```
7315
7316### getZoomRatioRange<sup>(deprecated)</sup>
7317
7318getZoomRatioRange(): Array\<number\>
7319
7320Obtains the supported zoom ratio range.
7321
7322> **NOTE**
7323>
7324> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Zoom.getZoomRatioRange](#getzoomratiorange11) instead.
7325
7326**System capability**: SystemCapability.Multimedia.Camera.Core
7327
7328**Return value**
7329
7330| Type       | Description                         |
7331| ---------- | ----------------------------- |
7332| Array\<number\>   | Array containing the minimum and maximum zoom ratios. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
7333
7334**Error codes**
7335
7336For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
7337
7338| ID        | Error Message       |
7339| --------------- | --------------- |
7340| 7400103                |  Session not config.                                   |
7341
7342**Example**
7343
7344```ts
7345import { BusinessError } from '@kit.BasicServicesKit';
7346
7347function getZoomRatioRange(captureSession: camera.CaptureSession): Array<number> {
7348  let zoomRatioRange: Array<number> = [];
7349  try {
7350    zoomRatioRange = captureSession.getZoomRatioRange();
7351  } catch (error) {
7352    // If the operation fails, error.code is returned and processed.
7353    let err = error as BusinessError;
7354    console.error(`The getZoomRatioRange call failed. error code: ${err.code}`);
7355  }
7356  return zoomRatioRange;
7357}
7358```
7359
7360### setZoomRatio<sup>(deprecated)</sup>
7361
7362setZoomRatio(zoomRatio: number): void
7363
7364Sets a zoom ratio, with a maximum precision of two decimal places.
7365
7366> **NOTE**
7367>
7368> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Zoom.setZoomRatio](#setzoomratio11) instead.
7369
7370**System capability**: SystemCapability.Multimedia.Camera.Core
7371
7372**Parameters**
7373
7374| Name      | Type                 | Mandatory | Description                |
7375| --------- | -------------------- |-----| ------------------- |
7376| zoomRatio | number               | Yes | Zoom ratio. The supported zoom ratio range can be obtained by calling [getZoomRatioRange](#getzoomratiorange11). If the value passed in is not within the supported range, the value within the precision range is retained. If the input parameter is null or undefined, it is treated as 0 and the minimum zoom ratio is used.|
7377
7378**Error codes**
7379
7380For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
7381
7382| ID        | Error Message       |
7383| --------------- | --------------- |
7384| 7400103                |  Session not config.                                   |
7385
7386**Example**
7387
7388```ts
7389import { BusinessError } from '@kit.BasicServicesKit';
7390
7391function setZoomRatio(captureSession: camera.CaptureSession, zoomRatioRange: Array<number>): void {
7392  if (zoomRatioRange === undefined || zoomRatioRange.length <= 0) {
7393    return;
7394  }
7395  let zoomRatio = zoomRatioRange[0];
7396  try {
7397    captureSession.setZoomRatio(zoomRatio);
7398  } catch (error) {
7399    // If the operation fails, error.code is returned and processed.
7400    let err = error as BusinessError;
7401    console.error(`The setZoomRatio call failed. error code: ${err.code}`);
7402  }
7403}
7404```
7405
7406### getZoomRatio<sup>(deprecated)</sup>
7407
7408getZoomRatio(): number
7409
7410Obtains the zoom ratio in use.
7411
7412> **NOTE**
7413>
7414> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Zoom.getZoomRatio](#getzoomratio11) instead.
7415
7416**System capability**: SystemCapability.Multimedia.Camera.Core
7417
7418**Return value**
7419
7420| Type       | Description                         |
7421| ---------- | ----------------------------- |
7422| number    | Zoom ratio obtained. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
7423
7424**Error codes**
7425
7426For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
7427
7428| ID        | Error Message       |
7429| --------------- | --------------- |
7430| 7400103                |  Session not config.                                   |
7431
7432**Example**
7433
7434```ts
7435import { BusinessError } from '@kit.BasicServicesKit';
7436
7437function getZoomRatio(captureSession: camera.CaptureSession): number {
7438  const invalidValue: number = -1;
7439  let zoomRatio: number = invalidValue;
7440  try {
7441    zoomRatio = captureSession.getZoomRatio();
7442  } catch (error) {
7443    // If the operation fails, error.code is returned and processed.
7444    let err = error as BusinessError;
7445    console.error(`The getZoomRatio call failed. error code: ${err.code}`);
7446  }
7447  return zoomRatio;
7448}
7449```
7450
7451### isVideoStabilizationModeSupported<sup>(deprecated)</sup>
7452
7453isVideoStabilizationModeSupported(vsMode: VideoStabilizationMode): boolean
7454
7455Checks whether a video stabilization mode is supported.
7456
7457> **NOTE**
7458>
7459> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Stabilization.isVideoStabilizationModeSupported](#isvideostabilizationmodesupported11) instead.
7460
7461**System capability**: SystemCapability.Multimedia.Camera.Core
7462
7463**Parameters**
7464
7465| Name     | Type                                             | Mandatory| Description                            |
7466| -------- | ------------------------------------------------- | ---- | ------------------------------ |
7467| vsMode   | [VideoStabilizationMode](#videostabilizationmode) | Yes  | Video stabilization mode. If the input parameter is null or undefined, it is treated as 0 and video stabilization is disabled.             |
7468
7469**Return value**
7470
7471| Type       | Description                         |
7472| ---------- | ----------------------------- |
7473| boolean    | **true**: The video stabilization mode is supported.<br>**false**: The video stabilization mode is not supported. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
7474
7475**Error codes**
7476
7477For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
7478
7479| ID        | Error Message       |
7480| --------------- | --------------- |
7481| 7400103                |  Session not config.                                   |
7482
7483**Example**
7484
7485```ts
7486import { BusinessError } from '@kit.BasicServicesKit';
7487
7488function isVideoStabilizationModeSupported(captureSession: camera.CaptureSession): boolean {
7489  let isSupported: boolean = false;
7490  try {
7491    isSupported = captureSession.isVideoStabilizationModeSupported(camera.VideoStabilizationMode.OFF);
7492  } catch (error) {
7493    // If the operation fails, error.code is returned and processed.
7494    let err = error as BusinessError;
7495    console.error(`The isVideoStabilizationModeSupported call failed. error code: ${err.code}`);
7496  }
7497  return isSupported;
7498}
7499```
7500
7501### getActiveVideoStabilizationMode<sup>(deprecated)</sup>
7502
7503getActiveVideoStabilizationMode(): VideoStabilizationMode
7504
7505Obtains the video stabilization mode in use.
7506
7507> **NOTE**
7508>
7509> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Stabilization.getActiveVideoStabilizationMode](#getactivevideostabilizationmode11) instead.
7510
7511**System capability**: SystemCapability.Multimedia.Camera.Core
7512
7513**Return value**
7514
7515| Type       | Description                         |
7516| ---------- | ----------------------------- |
7517| [VideoStabilizationMode](#videostabilizationmode)    | Video stabilization mode obtained. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
7518
7519**Error codes**
7520
7521For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
7522
7523| ID        | Error Message       |
7524| --------------- | --------------- |
7525| 7400103                |  Session not config.                                   |
7526
7527**Example**
7528
7529```ts
7530import { BusinessError } from '@kit.BasicServicesKit';
7531
7532function getActiveVideoStabilizationMode(captureSession: camera.CaptureSession): camera.VideoStabilizationMode | undefined {
7533  let vsMode: camera.VideoStabilizationMode | undefined = undefined;
7534  try {
7535    vsMode = captureSession.getActiveVideoStabilizationMode();
7536  } catch (error) {
7537    // If the operation fails, error.code is returned and processed.
7538    let err = error as BusinessError;
7539    console.error(`The getActiveVideoStabilizationMode call failed. error code: ${err.code}`);
7540  }
7541  return vsMode;
7542}
7543```
7544
7545### setVideoStabilizationMode<sup>(deprecated)</sup>
7546
7547setVideoStabilizationMode(mode: VideoStabilizationMode): void
7548
7549Sets a video stabilization mode. Before the setting, call [isVideoStabilizationModeSupported](#isvideostabilizationmodesupporteddeprecated) to check whether the target video stabilization mode is supported.
7550
7551> **NOTE**
7552>
7553> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Stabilization.setVideoStabilizationMode](#setvideostabilizationmode11) instead.
7554
7555**System capability**: SystemCapability.Multimedia.Camera.Core
7556
7557**Parameters**
7558
7559| Name     | Type                                             | Mandatory| Description                   |
7560| -------- | ------------------------------------------------- | ---- | --------------------- |
7561| mode     | [VideoStabilizationMode](#videostabilizationmode) | Yes  | Video stabilization mode. If the input parameter is null or undefined, it is treated as 0 and video stabilization is disabled.  |
7562
7563**Error codes**
7564
7565For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
7566
7567| ID        | Error Message       |
7568| --------------- | --------------- |
7569| 7400103                |  Session not config.                                   |
7570
7571**Example**
7572
7573```ts
7574import { BusinessError } from '@kit.BasicServicesKit';
7575
7576function setVideoStabilizationMode(captureSession: camera.CaptureSession): void {
7577  try {
7578    captureSession.setVideoStabilizationMode(camera.VideoStabilizationMode.OFF);
7579  } catch (error) {
7580    // If the operation fails, error.code is returned and processed.
7581    let err = error as BusinessError;
7582    console.error(`The setVideoStabilizationMode call failed. error code: ${err.code}`);
7583  }
7584}
7585```
7586
7587### on('focusStateChange')<sup>(deprecated)</sup>
7588
7589on(type: 'focusStateChange', callback: AsyncCallback\<FocusState\>): void
7590
7591Subscribes to focus state change events. This API uses an asynchronous callback to return the result.
7592
7593> **NOTE**
7594> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [VideoSession.on('focusStateChange')](#onfocusstatechange11-1) instead.
7595>
7596> Currently, you cannot use **off()** to unregister the callback in the callback method of **on()**.
7597
7598**System capability**: SystemCapability.Multimedia.Camera.Core
7599
7600**Parameters**
7601
7602| Name    | Type                                     | Mandatory| Description                      |
7603| -------- | ----------------------------------------- | ---- | ------------------------ |
7604| type     | string                                    | Yes  | Event type. The value is fixed at **'focusStateChange'**. The event can be listened for when a session is created. This event is triggered only when the camera focus state changes in auto focus mode.|
7605| callback | AsyncCallback\<[FocusState](#focusstate)\> | Yes  | Callback used to return the focus state change. |
7606
7607**Example**
7608
7609```ts
7610import { BusinessError } from '@kit.BasicServicesKit';
7611
7612function registerFocusStateChange(captureSession: camera.CaptureSession): void {
7613  captureSession.on('focusStateChange', (err: BusinessError, focusState: camera.FocusState) => {
7614    if (err !== undefined && err.code !== 0) {
7615      console.error(`Callback Error, errorCode: ${err.code}`);
7616      return;
7617    }
7618    console.info(`Focus state: ${focusState}`);
7619  });
7620}
7621```
7622
7623### off('focusStateChange')<sup>(deprecated)</sup>
7624
7625off(type: 'focusStateChange', callback?: AsyncCallback\<FocusState\>): void
7626
7627Unsubscribes from focus state change events.
7628
7629> **NOTE**
7630>
7631> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [VideoSession.off('focusStateChange')](#offfocusstatechange11-1) instead.
7632
7633**System capability**: SystemCapability.Multimedia.Camera.Core
7634
7635**Parameters**
7636
7637| Name    | Type                                     | Mandatory| Description                      |
7638| -------- | ----------------------------------------- | ---- | ------------------------ |
7639| type     | string                                    | Yes  | Event type. The value is fixed at **'focusStateChange'**. The event can be listened for when a session is created.|
7640| callback | AsyncCallback\<[FocusState](#focusstate)\> | No  | Callback used to return the result. If this parameter is specified, the subscription to the specified event with the specified callback is canceled. (The callback object cannot be an anonymous function.) Otherwise, the subscriptions to the specified event with all the callbacks are canceled.|
7641
7642**Example**
7643
7644```ts
7645function unregisterFocusStateChange(captureSession: camera.CaptureSession): void {
7646  captureSession.off('focusStateChange');
7647}
7648```
7649
7650### on('error')<sup>(deprecated)</sup>
7651
7652on(type: 'error', callback: ErrorCallback): void
7653
7654Subscribes to **CaptureSession** error events. This API uses an asynchronous callback to return the result.
7655
7656> **NOTE**
7657>
7658> Currently, you cannot use **off()** to unregister the callback in the callback method of **on()**.
7659
7660> **NOTE**
7661>
7662> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [VideoSession.on('error')](#onerror11-1) instead.
7663
7664**System capability**: SystemCapability.Multimedia.Camera.Core
7665
7666**Parameters**
7667
7668| Name    | Type                                                                      | Mandatory| Description                          |
7669| -------- |--------------------------------------------------------------------------| ---- | ------------------------------ |
7670| type     | string                                                                   | Yes  | Event type. The value is fixed at **'error'**. The event can be listened for when a session is created. This event is triggered and the error message is returned when an error occurs during the calling of a session-related API such as [beginConfig](#beginconfigdeprecated), [commitConfig](#commitconfigdeprecated-1), and [addInput](#addinputdeprecated).|
7671| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback) | Yes  | Callback used to return an error code defined in [CameraErrorCode](#cameraerrorcode).       |
7672
7673**Example**
7674
7675```ts
7676import { BusinessError } from '@kit.BasicServicesKit';
7677
7678function registerCaptureSessionError(captureSession: camera.CaptureSession): void {
7679  captureSession.on('error', (error: BusinessError) => {
7680    console.error(`Capture session error code: ${error.code}`);
7681  });
7682}
7683```
7684
7685### off('error')<sup>(deprecated)</sup>
7686
7687off(type: 'error', callback?: ErrorCallback): void
7688
7689Unsubscribes from **CaptureSession** error events. This API uses a callback to return the result.
7690
7691> **NOTE**
7692>
7693> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [VideoSession.off('error')](#offerror11-1) instead.
7694
7695**System capability**: SystemCapability.Multimedia.Camera.Core
7696
7697**Parameters**
7698
7699| Name    | Type                                                         | Mandatory| Description                          |
7700| -------- | ----------------------------------------------------------- | ---- | ------------------------------ |
7701| type     | string                                                      | Yes  | Event type. The value is fixed at **'error'**. The event can be listened for when a session is created.|
7702| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| No  | Callback used to return the result. If this parameter is specified, the subscription to the specified event with the specified callback is canceled. (The callback object cannot be an anonymous function.) Otherwise, the subscriptions to the specified event with all the callbacks are canceled.|
7703
7704**Example**
7705
7706```ts
7707function unregisterCaptureSessionError(captureSession: camera.CaptureSession): void {
7708  captureSession.off('error');
7709}
7710```
7711## ColorManagementQuery<sup>12+</sup>
7712
7713Provides the APIs for color space query.
7714
7715### getSupportedColorSpaces<sup>12+</sup>
7716
7717getSupportedColorSpaces(): Array\<colorSpaceManager.ColorSpace\>
7718
7719Obtains the supported color spaces.
7720
7721**System capability**: SystemCapability.Multimedia.Camera.Core
7722
7723**Return value**
7724
7725| Type                                            | Description                          |
7726| ----------------------------------------------- | ---------------------------- |
7727| Array<[colorSpaceManager.ColorSpace](../apis-arkgraphics2d/js-apis-colorSpaceManager.md#colorspace)>| Array of color spaces supported.    |
7728
7729**Error codes**
7730
7731For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
7732
7733| ID        | Error Message       |
7734| --------------- | --------------- |
7735| 7400103         |  Session not config, only throw in session usage.                       |
7736
7737**Example**
7738
7739```ts
7740import { BusinessError } from '@kit.BasicServicesKit';
7741import { colorSpaceManager } from '@kit.ArkGraphics2D';
7742
7743function getSupportedColorSpaces(session: camera.PhotoSession): Array<colorSpaceManager.ColorSpace> {
7744  let colorSpaces: Array<colorSpaceManager.ColorSpace> = [];
7745  try {
7746    colorSpaces = session.getSupportedColorSpaces();
7747  } catch (error) {
7748    let err = error as BusinessError;
7749    console.error(`The getSupportedColorSpaces call failed. error code: ${err.code}`);
7750  }
7751  return colorSpaces;
7752}
7753```
7754## ColorManagement<sup>12+</sup>
7755
7756ColorManagement extends [ColorManagementQuery](#colormanagementquery12)
7757
7758Implements color space management. It inherits from [ColorManagementQuery](#colormanagementquery12).
7759
7760### setColorSpace<sup>12+</sup>
7761
7762setColorSpace(colorSpace: colorSpaceManager.ColorSpace): void
7763
7764Sets a color space. Before the setting, call [getSupportedColorSpaces](#getsupportedcolorspaces12) to obtain the supported color spaces.
7765
7766P3 and HDR Imaging
7767
7768An application can deliver different color space parameters to declare its support for P3 and HDR.
7769
7770If an application does not proactively set the color space, HDR is used by default in photographing and video recording scenarios.
7771
7772In photo mode, P3 can be directly supported by setting the HDR effect.
7773
7774For details about how to enable the HDR effect and set the color space in different modes, see the following table.
7775
7776**Recording Mode**
7777
7778| SDR/HRD Photographing        | CameraFormat             | ColorSpace       |
7779|--------------------|--------------------------|------------------|
7780| SDR                | CAMERA_FORMAT_YUV_420_SP | BT709_LIMIT      |
7781| HDR_VIVID(Default) | CAMERA_FORMAT_YCRCB_P010 | BT2020_HLG_LIMIT |
7782
7783**Photo Mode**
7784
7785| SDR/HRD Photographing   | ColorSpace |
7786|--------------|------------|
7787| SDR          | SRGB       |
7788| HDR(Default) | DISPLAY_P3 |
7789
7790**System capability**: SystemCapability.Multimedia.Camera.Core
7791
7792**Parameters**
7793
7794| Name        | Type                | Mandatory| Description                     |
7795| ------------ |---------------------- | -- | -------------------------- |
7796| colorSpace | [colorSpaceManager.ColorSpace](../apis-arkgraphics2d/js-apis-colorSpaceManager.md#colorspace)  | Yes| Color space, which can be obtained through [getSupportedColorSpaces](#getsupportedcolorspaces12).  |
7797
7798**Error codes**
7799
7800For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
7801
7802| ID        | Error Message       |
7803| --------------- | --------------- |
7804| 7400101         |  Parameter missing or parameter type incorrect.     |
7805| 7400102         |  The colorSpace does not match the format.     |
7806| 7400103         |  Session not config.                           |
7807| 7400201         |  Camera service fatal error.                   |
7808
7809**Example**
7810
7811```ts
7812import { BusinessError } from '@kit.BasicServicesKit';
7813import { colorSpaceManager } from '@kit.ArkGraphics2D';
7814
7815function setColorSpace(session: camera.PhotoSession, colorSpaces: Array<colorSpaceManager.ColorSpace>): void {
7816  if (colorSpaces === undefined || colorSpaces.length <= 0) {
7817    return;
7818  }
7819  try {
7820    session.setColorSpace(colorSpaces[0]);
7821  } catch (error) {
7822    let err = error as BusinessError;
7823    console.error(`The setColorSpace call failed, error code: ${err.code}`);
7824  }
7825}
7826```
7827
7828### getActiveColorSpace<sup>12+</sup>
7829
7830getActiveColorSpace(): colorSpaceManager.ColorSpace
7831
7832Obtains the color space in use.
7833
7834**System capability**: SystemCapability.Multimedia.Camera.Core
7835
7836**Return value**
7837
7838| Type                                            | Description                          |
7839| ----------------------------------------------- | ---------------------------- |
7840| [colorSpaceManager.ColorSpace](../apis-arkgraphics2d/js-apis-colorSpaceManager.md#colorspace)               | Color space.               |
7841
7842**Error codes**
7843
7844For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
7845
7846| ID        | Error Message       |
7847| --------------- | --------------- |
7848| 7400103                |  Session not config.                                   |
7849
7850**Example**
7851
7852```ts
7853import { BusinessError } from '@kit.BasicServicesKit';
7854import { colorSpaceManager } from '@kit.ArkGraphics2D';
7855
7856function getActiveColorSpace(session: camera.PhotoSession): colorSpaceManager.ColorSpace | undefined {
7857  let colorSpace: colorSpaceManager.ColorSpace | undefined = undefined;
7858  try {
7859    colorSpace = session.getActiveColorSpace();
7860  } catch (error) {
7861    let err = error as BusinessError;
7862    console.error(`The getActiveColorSpace call failed. error code: ${err.code}`);
7863  }
7864  return colorSpace;
7865}
7866```
7867
7868## AutoDeviceSwitchQuery<sup>13+</sup>
7869
7870A class for checking whether a device supports automatic camera switch.
7871
7872### isAutoDeviceSwitchSupported<sup>13+</sup>
7873
7874isAutoDeviceSwitchSupported(): boolean
7875
7876Checks whether the device supports automatic camera switch.
7877
7878**System capability**: SystemCapability.Multimedia.Camera.Core
7879
7880**Return value**
7881
7882| Type                                            | Description         |
7883| ----------------------------------------------- |-------------|
7884| boolean               | Whether the device supports automatic camera switch.|
7885
7886**Error codes**
7887
7888For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
7889
7890| ID        | Error Message                                             |
7891| --------------- |---------------------------------------------------|
7892| 7400103         | Session not config, only throw in session usage.  |
7893
7894**Example**
7895
7896```ts
7897import { BusinessError } from '@kit.BasicServicesKit';
7898
7899function isAutoDeviceSwitchSupported(session: camera.PhotoSession): boolean {
7900  let isSupported = false;
7901  try {
7902    isSupported = session.isAutoDeviceSwitchSupported();
7903  } catch (error) {
7904    let err = error as BusinessError;
7905    console.error(`The isAutoDeviceSwitchSupported call failed, error code: ${err.code}`);
7906  }
7907  return isSupported;
7908}
7909```
7910
7911## AutoDeviceSwitch<sup>13+</sup>
7912
7913AutoDeviceSwitch extends [AutoDeviceSwitchQuery](#autodeviceswitchquery13)
7914
7915A class that is used to enable or disable automatic camera switch. This class inherits from [AutoDeviceSwitchQuery](#autodeviceswitchquery13).
7916
7917It is recommended that the system completes input device switch, session configuration, and parameter connection during automatic camera switch. If the system detects that the zoom ranges of the two cameras are different, it notifies the application through the **isDeviceCapabilityChanged** field in [AutoDeviceSwitchStatus](#autodeviceswitchstatus13). The application needs to process the UX change by itself. For example, if the zoom range is different, the application needs to call [getZoomRatioRange](#getzoomratiorange11) to obtain data and update the UX. Therefore, this class is more applicable to a simplified UX exchange scenario.
7918
7919### enableAutoDeviceSwitch<sup>13+</sup>
7920
7921enableAutoDeviceSwitch(enabled: boolean): void
7922
7923Enables or disables automatic camera switch. You can use [isAutoDeviceSwitchSupported](#isautodeviceswitchsupported13) to check whether the device supports automatic camera switch.
7924
7925> **NOTE**
7926>
7927> This API is used only for foldable devices with multiple front cameras. In different folding states, the system can automatically switch to an available front camera. It does not enable automatic switching between front and rear cameras.
7928
7929**System capability**: SystemCapability.Multimedia.Camera.Core
7930
7931**Parameters**
7932
7933| Name        | Type | Mandatory| Description |
7934| ----------- |---------------------- |---| -------------------------- |
7935| enabled | boolean  | Yes| Whether to enable automatic camera switch.  |
7936
7937**Error codes**
7938
7939For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
7940
7941| ID  | Error Message                                                                                                                                      |
7942|----------|------------------------------------------------------------------------------------------------------------------------------------------------|
7943| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
7944| 7400102  | Operation not allowed.                                                                                                                         |
7945| 7400103  | Session not config.                                                                                                                            |
7946| 7400201  | Camera service fatal error.                                                                                                                    |
7947
7948**Example**
7949
7950```ts
7951import { BusinessError } from '@kit.BasicServicesKit';
7952
7953function enableAutoDeviceSwitch(session: camera.PhotoSession, isEnable: boolean): void {
7954  try {
7955    session.enableAutoDeviceSwitch(isEnable);
7956  } catch (error) {
7957    let err = error as BusinessError;
7958    console.error(`The enableAutoDeviceSwitch call failed, error code: ${err.code}`);
7959  }
7960}
7961```
7962
7963## PreconfigType<sup>12+</sup>
7964
7965Enumerates the preconfigured resolution types.
7966
7967**System capability**: SystemCapability.Multimedia.Camera.Core
7968
7969| Name                     | Value| Description        |
7970|-------------------------|---|------------|
7971| PRECONFIG_720P          | 0 | 720p resolution.  |
7972| PRECONFIG_1080P         | 1 | 1080p resolution. |
7973| PRECONFIG_4K            | 2 | 4K resolution.    |
7974| PRECONFIG_HIGH_QUALITY  | 3 | High-quality resolution.   |
7975
7976## PreconfigRatio<sup>12+</sup>
7977
7978Enumerates the preconfigured aspect ratios.
7979
7980**System capability**: SystemCapability.Multimedia.Camera.Core
7981
7982| Name                      | Value| Description     |
7983|--------------------------|---|---------|
7984| PRECONFIG_RATIO_1_1      | 0 | 1:1 aspect ratio. |
7985| PRECONFIG_RATIO_4_3      | 1 | 4:3 aspect ratio. |
7986| PRECONFIG_RATIO_16_9     | 2 | 16:9 aspect ratio.|
7987
7988## PhotoSession<sup>11+</sup>
7989
7990PhotoSession extends [Session](#session11), [Flash](#flash11), [AutoExposure](#autoexposure11), [Focus](#focus11), [Zoom](#zoom11), [ColorManagement](#colormanagement12), [AutoDeviceSwitch](#autodeviceswitch13)
7991
7992Implements a photo session, which provides operations on the flash, exposure, focus, zoom, and color space.
7993
7994> **NOTE**
7995>
7996> This class is provided for the default photo mode. It is used to take standard photos. It supports multiple photo formats and resolutions, which are suitable for most daily photographing scenarios.
7997
7998### canPreconfig<sup>12+</sup>
7999
8000canPreconfig(preconfigType: PreconfigType, preconfigRatio?: PreconfigRatio): boolean
8001
8002Checks whether this session supports a preconfigured resolution.
8003
8004**System capability**: SystemCapability.Multimedia.Camera.Core
8005
8006**Parameters**
8007
8008| Name           | Type                                 | Mandatory | Description             |
8009|----------------|-------------------------------------|-----|-----------------|
8010| preconfigType  | [PreconfigType](#preconfigtype12)   | Yes  | Resolution type.     |
8011| preconfigRatio | [PreconfigRatio](#preconfigratio12) | No  | Aspect ratio. The default value is 4:3. |
8012
8013**Return value**
8014
8015| Type     | Description                                     |
8016|---------|-----------------------------------------|
8017| boolean | **true**: The preconfigured resolution is supported.<br>**false**: The preconfigured resolution is not supported.|
8018
8019**Error codes**
8020
8021For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
8022
8023| ID  | Error Message                       |
8024|---------|-----------------------------|
8025| 7400201 | Camera service fatal error. |
8026
8027**Example**
8028
8029```ts
8030function testCanPreconfig(photoSession: camera.PhotoSession, preconfigType: camera.PreconfigType,
8031  preconfigRatio: camera.PreconfigRatio): void {
8032  try {
8033    let result = photoSession.canPreconfig(preconfigType, preconfigRatio);
8034    console.info(`canPreconfig ${preconfigType} ${preconfigRatio} result is : ${result}`);
8035  } catch (error) {
8036    let err = error as BusinessError;
8037    console.error(`The canPreconfig call failed. error code: ${err.code}`);
8038  }
8039}
8040```
8041
8042### preconfig<sup>12+</sup>
8043
8044preconfig(preconfigType: PreconfigType, preconfigRatio?: PreconfigRatio): void
8045
8046Preconfigures this session.
8047
8048**System capability**: SystemCapability.Multimedia.Camera.Core
8049
8050**Parameters**
8051
8052| Name           | Type                                 | Mandatory | Description             |
8053|----------------|-------------------------------------|-----|-----------------|
8054| preconfigType  | [PreconfigType](#preconfigtype12)   | Yes  | Resolution type.     |
8055| preconfigRatio | [PreconfigRatio](#preconfigratio12) | No  | Aspect ratio. The default value is 4:3. |
8056
8057**Error codes**
8058
8059For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
8060
8061| ID  | Error Message                       |
8062|---------|-----------------------------|
8063| 7400201 | Camera service fatal error. |
8064
8065**Example**
8066
8067```ts
8068function testPreconfig(photoSession: camera.PhotoSession, preconfigType: camera.PreconfigType,
8069  preconfigRatio: camera.PreconfigRatio): void {
8070  try {
8071    photoSession.preconfig(preconfigType, preconfigRatio);
8072    console.info(`preconfig ${preconfigType} ${preconfigRatio} success`);
8073  } catch (error) {
8074    let err = error as BusinessError;
8075    console.error(`The preconfig call failed. error code: ${err.code}`);
8076  }
8077}
8078```
8079
8080### on('error')<sup>11+</sup>
8081
8082on(type: 'error', callback: ErrorCallback): void
8083
8084Subscribes to **PhotoSession** error events. This API uses an asynchronous callback to return the result.
8085
8086> **NOTE**
8087>
8088> Currently, you cannot use **off()** to unregister the callback in the callback method of **on()**.
8089
8090**System capability**: SystemCapability.Multimedia.Camera.Core
8091
8092**Parameters**
8093
8094| Name    | Type                                                         | Mandatory| Description                          |
8095| -------- | ----------------------------------------------------------- | ---- | ------------------------------ |
8096| type     | string                                                      | Yes  | Event type. The value is fixed at **'error'**. The event can be listened for when a session is created. This event is triggered and the error message is returned when an error occurs during the calling of a session-related API such as [beginConfig](#beginconfig11), [commitConfig](#commitconfig11-1), and [addInput](#addinput11).|
8097| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| Yes  | Callback used to return an error code defined in [CameraErrorCode](#cameraerrorcode).       |
8098
8099**Example**
8100
8101```ts
8102import { BusinessError } from '@kit.BasicServicesKit';
8103
8104function callback(err: BusinessError): void {
8105  console.error(`Photo session error code: ${err.code}`);
8106}
8107
8108function registerSessionError(photoSession: camera.PhotoSession): void {
8109  photoSession.on('error', callback);
8110}
8111```
8112
8113### off('error')<sup>11+</sup>
8114
8115off(type: 'error', callback?: ErrorCallback): void
8116
8117Unsubscribes from **PhotoSession** error events. This API uses a callback to return the result.
8118
8119**System capability**: SystemCapability.Multimedia.Camera.Core
8120
8121**Parameters**
8122
8123| Name    | Type                           | Mandatory| Description                          |
8124| -------- | -------------------------------- | ---- | ------------------------------ |
8125| type     | string                           | Yes  | Event type. The value is fixed at **'error'**. The event can be listened for when a session is created.|
8126| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| No  | Callback used to return the result. If this parameter is specified, the subscription to the specified event with the specified callback is canceled. (The callback object cannot be an anonymous function.) Otherwise, the subscriptions to the specified event with all the callbacks are canceled.|
8127
8128**Example**
8129
8130```ts
8131function unregisterSessionError(photoSession: camera.PhotoSession): void {
8132  photoSession.off('error');
8133}
8134```
8135
8136### on('focusStateChange')<sup>11+</sup>
8137
8138on(type: 'focusStateChange', callback: AsyncCallback\<FocusState\>): void
8139
8140Subscribes to focus state change events. This API uses an asynchronous callback to return the result.
8141
8142> **NOTE**
8143>
8144> Currently, you cannot use **off()** to unregister the callback in the callback method of **on()**.
8145
8146**System capability**: SystemCapability.Multimedia.Camera.Core
8147
8148**Parameters**
8149
8150| Name    | Type                   | Mandatory| Description                      |
8151| -------- | ---------------- | ---- | ------------------------ |
8152| type     | string                                    | Yes  | Event type. The value is fixed at **'focusStateChange'**. The event can be listened for when a session is created. This event is triggered only when the camera focus state changes in auto focus mode.|
8153| callback | AsyncCallback\<[FocusState](#focusstate)\> | Yes  | Callback used to return the focus state change. |
8154
8155**Example**
8156
8157```ts
8158import { BusinessError } from '@kit.BasicServicesKit';
8159
8160function callback(err: BusinessError, focusState: camera.FocusState): void {
8161  if (err !== undefined && err.code !== 0) {
8162    console.error(`Callback Error, errorCode: ${err.code}`);
8163    return;
8164  }
8165  console.info(`Focus state: ${focusState}`);
8166}
8167
8168function registerFocusStateChange(photoSession: camera.PhotoSession): void {
8169  photoSession.on('focusStateChange', callback);
8170}
8171```
8172
8173### off('focusStateChange')<sup>11+</sup>
8174
8175off(type: 'focusStateChange', callback?: AsyncCallback\<FocusState\>): void
8176
8177Unsubscribes from focus state change events.
8178
8179**System capability**: SystemCapability.Multimedia.Camera.Core
8180
8181**Parameters**
8182
8183| Name    | Type                                     | Mandatory| Description                      |
8184| -------- | ----------------------------------------- | ---- | ------------------------ |
8185| type     | string                                    | Yes  | Event type. The value is fixed at **'focusStateChange'**. The event can be listened for when a session is created.|
8186| callback | AsyncCallback\<[FocusState](#focusstate)\> | No  | Callback used to return the result. If this parameter is specified, the subscription to the specified event with the specified callback is canceled. (The callback object cannot be an anonymous function.) Otherwise, the subscriptions to the specified event with all the callbacks are canceled.|
8187
8188**Example**
8189
8190```ts
8191function unregisterFocusStateChange(photoSession: camera.PhotoSession): void {
8192  photoSession.off('focusStateChange');
8193}
8194```
8195
8196### on('smoothZoomInfoAvailable')<sup>11+</sup>
8197
8198on(type: 'smoothZoomInfoAvailable', callback: AsyncCallback\<SmoothZoomInfo\>): void
8199
8200Subscribes to smooth zoom state change events. This API uses an asynchronous callback to return the result.
8201
8202> **NOTE**
8203>
8204> Currently, you cannot use **off()** to unregister the callback in the callback method of **on()**.
8205
8206**System capability**: SystemCapability.Multimedia.Camera.Core
8207
8208**Parameters**
8209
8210| Name    | Type                  | Mandatory| Description                      |
8211| -------- | ----------------------- | ---- | ------------------------ |
8212| type     | string                  | Yes  | Event type. The value is fixed at **'smoothZoomInfoAvailable'**. The event can be listened for when a session is created.|
8213| callback | AsyncCallback\<[SmoothZoomInfo](#smoothzoominfo11)\> | Yes  | Callback used to return the smooth zoom state change. |
8214
8215**Example**
8216
8217```ts
8218import { BusinessError } from '@kit.BasicServicesKit';
8219
8220function callback(err: BusinessError, smoothZoomInfo: camera.SmoothZoomInfo): void {
8221  if (err !== undefined && err.code !== 0) {
8222    console.error(`Callback Error, errorCode: ${err.code}`);
8223    return;
8224  }
8225  console.info(`The duration of smooth zoom: ${smoothZoomInfo.duration}`);
8226}
8227
8228function registerSmoothZoomInfo(photoSession: camera.PhotoSession): void {
8229  photoSession.on('smoothZoomInfoAvailable', callback);
8230}
8231```
8232
8233### off('smoothZoomInfoAvailable')<sup>11+</sup>
8234
8235off(type: 'smoothZoomInfoAvailable', callback?: AsyncCallback\<SmoothZoomInfo\>): void
8236
8237Unsubscribes from smooth zoom state change events.
8238
8239**System capability**: SystemCapability.Multimedia.Camera.Core
8240
8241**Parameters**
8242
8243| Name    | Type                                     | Mandatory| Description                      |
8244| -------- | ----------------------------------------- | ---- | ------------------------ |
8245| type     | string              | Yes  | Event type. The value is fixed at **'smoothZoomInfoAvailable'**. The event can be listened for when a session is created.|
8246| callback | AsyncCallback\<[SmoothZoomInfo](#smoothzoominfo11)\> | No  | Callback used to return the result. If this parameter is specified, the subscription to the specified event with the specified callback is canceled. (The callback object cannot be an anonymous function.) Otherwise, the subscriptions to the specified event with all the callbacks are canceled.|
8247
8248**Example**
8249
8250```ts
8251function unregisterSmoothZoomInfo(photoSession: camera.PhotoSession): void {
8252  photoSession.off('smoothZoomInfoAvailable');
8253}
8254```
8255
8256### on('autoDeviceSwitchStatusChange')<sup>13+</sup>
8257
8258on(type: 'autoDeviceSwitchStatusChange', callback: AsyncCallback\<AutoDeviceSwitchStatus\>): void
8259
8260Subscribes to automatic camera switch status change events. This API uses an asynchronous callback to return the result.
8261
8262> **NOTE**
8263>
8264> Currently, you cannot use **off()** to unregister the callback in the callback method of **on()**.
8265
8266**System capability**: SystemCapability.Multimedia.Camera.Core
8267
8268**Parameters**
8269
8270| Name    | Type                                                                  | Mandatory| Description                                                    |
8271| -------- |----------------------------------------------------------------------| ---- |--------------------------------------------------------|
8272| type     | string                                                               | Yes  | Event type. The value is fixed at **'autoDeviceSwitchStatusChange'**. The event can be listened for when a session is created.|
8273| callback | AsyncCallback\<[AutoDeviceSwitchStatus](#autodeviceswitchstatus13)\> | Yes  | Callback function, which is used to obtain the status of automatic camera switch.                                 |
8274
8275**Example**
8276
8277```ts
8278import { BusinessError } from '@kit.BasicServicesKit';
8279
8280function callback(err: BusinessError, autoDeviceSwitchStatus: camera.AutoDeviceSwitchStatus): void {
8281  if (err !== undefined && err.code !== 0) {
8282    console.error(`Callback Error, errorCode: ${err.code}`);
8283    return;
8284  }
8285  console.info(`isDeviceSwitched: ${autoDeviceSwitchStatus.isDeviceSwitched}, isDeviceCapabilityChanged: ${autoDeviceSwitchStatus.isDeviceCapabilityChanged}`);
8286}
8287
8288function registerAutoDeviceSwitchStatus(photoSession: camera.PhotoSession): void {
8289  photoSession.on('autoDeviceSwitchStatusChange', callback);
8290}
8291```
8292
8293### off('autoDeviceSwitchStatusChange')<sup>13+</sup>
8294
8295off(type: 'autoDeviceSwitchStatusChange', callback?: AsyncCallback\<AutoDeviceSwitchStatus\>): void
8296
8297Unsubscribes from automatic camera switch status change events.
8298
8299**System capability**: SystemCapability.Multimedia.Camera.Core
8300
8301**Parameters**
8302
8303| Name    | Type                                          | Mandatory| Description                      |
8304| -------- |----------------------------------------------| ---- | ------------------------ |
8305| type     | string                                       | Yes  | Event type. The value is fixed at **'autoDeviceSwitchStatusChange'**. The event can be listened for when a session is created.|
8306| callback | AsyncCallback\<[AutoDeviceSwitchStatus](#autodeviceswitchstatus13)\> | No  | Callback used to return the result. If this parameter is specified, the subscription to the specified event with the specified callback is canceled. (The callback object cannot be an anonymous function.) Otherwise, the subscriptions to the specified event with all the callbacks are canceled.|
8307
8308**Example**
8309
8310```ts
8311function unregisterSmoothZoomInfo(photoSession: camera.PhotoSession): void {
8312  photoSession.off('autoDeviceSwitchStatusChange');
8313}
8314```
8315
8316## VideoSession<sup>11+</sup>
8317
8318VideoSession extends [Session](#session11), [Flash](#flash11), [AutoExposure](#autoexposure11), [Focus](#focus11), [Zoom](#zoom11), [Stabilization](#stabilization11), [ColorManagement](#colormanagement12), [AutoDeviceSwitch](#autodeviceswitch13)
8319
8320Implements a video session, which provides operations on the flash, exposure, focus, zoom, video stabilization, and color space.
8321
8322> **NOTE**
8323>
8324> This class is provided for the default video recording mode. It applies to common scenarios. It supports recording at various resolutions (such as 720p and 1080p) and frame rates (such as 30 fps and 60 fps).
8325
8326### canPreconfig<sup>12+</sup>
8327
8328canPreconfig(preconfigType: PreconfigType, preconfigRatio?: PreconfigRatio): boolean
8329
8330Checks whether this session supports a preconfigured resolution.
8331
8332**System capability**: SystemCapability.Multimedia.Camera.Core
8333
8334**Parameters**
8335
8336| Name           | Type                                 | Mandatory | Description             |
8337|----------------|-------------------------------------|-----|-----------------|
8338| preconfigType  | [PreconfigType](#preconfigtype12)   | Yes  | Resolution type.     |
8339| preconfigRatio | [PreconfigRatio](#preconfigratio12) | No  | Aspect ratio. The default value is 16:9.|
8340
8341**Return value**
8342
8343| Type     | Description                                     |
8344|---------|-----------------------------------------|
8345| boolean | **true**: The preconfigured resolution is supported.<br>**false**: The preconfigured resolution is not supported.|
8346
8347**Error codes**
8348
8349For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
8350
8351| ID  | Error Message                       |
8352|---------|-----------------------------|
8353| 7400201 | Camera service fatal error. |
8354
8355**Example**
8356
8357```ts
8358function testCanPreconfig(videoSession: camera.VideoSession, preconfigType: camera.PreconfigType,
8359  preconfigRatio: camera.PreconfigRatio): void {
8360  try {
8361    let result = videoSession.canPreconfig(preconfigType, preconfigRatio);
8362    console.info(`canPreconfig ${preconfigType} ${preconfigRatio} result is : ${result}`);
8363  } catch (error) {
8364    let err = error as BusinessError;
8365    console.error(`The canPreconfig call failed. error code: ${err.code}`);
8366  }
8367}
8368```
8369
8370### preconfig<sup>12+</sup>
8371
8372preconfig(preconfigType: PreconfigType, preconfigRatio?: PreconfigRatio): void
8373
8374Preconfigures this session.
8375
8376**System capability**: SystemCapability.Multimedia.Camera.Core
8377
8378**Parameters**
8379
8380| Name           | Type                                 | Mandatory | Description             |
8381|----------------|-------------------------------------|-----|-----------------|
8382| preconfigType  | [PreconfigType](#preconfigtype12)   | Yes  | Resolution type.     |
8383| preconfigRatio | [PreconfigRatio](#preconfigratio12) | No  | Aspect ratio. The default value is 16:9.|
8384
8385**Error codes**
8386
8387For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
8388
8389| ID  | Error Message                       |
8390|---------|-----------------------------|
8391| 7400201 | Camera service fatal error. |
8392
8393**Example**
8394
8395```ts
8396function testPreconfig(videoSession: camera.VideoSession, preconfigType: camera.PreconfigType,
8397  preconfigRatio: camera.PreconfigRatio): void {
8398  try {
8399    videoSession.preconfig(preconfigType, preconfigRatio);
8400    console.info(`preconfig ${preconfigType} ${preconfigRatio} success`);
8401  } catch (error) {
8402    let err = error as BusinessError;
8403    console.error(`The preconfig call failed. error code: ${err.code}`);
8404  }
8405}
8406```
8407
8408### on('error')<sup>11+</sup>
8409
8410on(type: 'error', callback: ErrorCallback): void
8411
8412Subscribes to **VideoSession** error events. This API uses an asynchronous callback to return the result.
8413
8414> **NOTE**
8415>
8416> Currently, you cannot use **off()** to unregister the callback in the callback method of **on()**.
8417
8418**System capability**: SystemCapability.Multimedia.Camera.Core
8419
8420**Parameters**
8421
8422| Name    | Type             | Mandatory| Description                          |
8423| -------- | ------------------ | ---- | ------------------------------ |
8424| type     | string             | Yes  | Event type. The value is fixed at **'error'**. The event can be listened for when a session is created. This event is triggered and the error message is returned when an error occurs during the calling of a session-related API such as [beginConfig](#beginconfig11), [commitConfig](#commitconfig11-1), and [addInput](#addinput11).|
8425| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)      | Yes  | Callback used to return an error code defined in [CameraErrorCode](#cameraerrorcode).  |
8426
8427**Example**
8428
8429```ts
8430import { BusinessError } from '@kit.BasicServicesKit';
8431
8432function callback(err: BusinessError): void {
8433  console.error(`Video session error code: ${err.code}`);
8434}
8435
8436function registerSessionError(videoSession: camera.VideoSession): void {
8437  videoSession.on('error', callback);
8438}
8439```
8440
8441### off('error')<sup>11+</sup>
8442
8443off(type: 'error', callback?: ErrorCallback): void
8444
8445Unsubscribes from **VideoSession** error events. This API uses a callback to return the result.
8446
8447**System capability**: SystemCapability.Multimedia.Camera.Core
8448
8449**Parameters**
8450
8451| Name    | Type                         | Mandatory| Description                          |
8452| -------- | --------------------------- | ---- | ------------------------------ |
8453| type     | string                    | Yes  | Event type. The value is fixed at **'error'**. The event can be listened for when a session is created.|
8454| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| No  | Callback used to return the result. If this parameter is specified, the subscription to the specified event with the specified callback is canceled. (The callback object cannot be an anonymous function.) Otherwise, the subscriptions to the specified event with all the callbacks are canceled.|
8455
8456**Example**
8457
8458```ts
8459function unregisterSessionError(videoSession: camera.VideoSession): void {
8460  videoSession.off('error');
8461}
8462```
8463
8464### on('focusStateChange')<sup>11+</sup>
8465
8466on(type: 'focusStateChange', callback: AsyncCallback\<FocusState\>): void
8467
8468Subscribes to focus state change events. This API uses an asynchronous callback to return the result.
8469
8470> **NOTE**
8471>
8472> Currently, you cannot use **off()** to unregister the callback in the callback method of **on()**.
8473
8474**System capability**: SystemCapability.Multimedia.Camera.Core
8475
8476**Parameters**
8477
8478| Name    | Type                   | Mandatory| Description                      |
8479| -------- | ---------------- | ---- | ------------------------ |
8480| type     | string                                    | Yes  | Event type. The value is fixed at **'focusStateChange'**. The event can be listened for when a session is created. This event is triggered only when the camera focus state changes in auto focus mode.|
8481| callback | AsyncCallback\<[FocusState](#focusstate)\> | Yes  | Callback used to return the focus state change. |
8482
8483**Example**
8484
8485```ts
8486import { BusinessError } from '@kit.BasicServicesKit';
8487
8488function callback(err: BusinessError, focusState: camera.FocusState): void {
8489  if (err !== undefined && err.code !== 0) {
8490    console.error(`Callback Error, errorCode: ${err.code}`);
8491    return;
8492  }
8493  console.info(`Focus state: ${focusState}`);
8494}
8495
8496function registerFocusStateChange(videoSession: camera.VideoSession): void {
8497  videoSession.on('focusStateChange', callback);
8498}
8499```
8500
8501### off('focusStateChange')<sup>11+</sup>
8502
8503off(type: 'focusStateChange', callback?: AsyncCallback\<FocusState\>): void
8504
8505Unsubscribes from focus state change events.
8506
8507**System capability**: SystemCapability.Multimedia.Camera.Core
8508
8509**Parameters**
8510
8511| Name    | Type                                     | Mandatory| Description                      |
8512| -------- | ----------------------------------------- | ---- | ------------------------ |
8513| type     | string                                    | Yes  | Event type. The value is fixed at **'focusStateChange'**. The event can be listened for when a session is created.|
8514| callback | AsyncCallback\<[FocusState](#focusstate)\> | No | Callback used to return the result. If this parameter is specified, the subscription to the specified event with the specified callback is canceled. (The callback object cannot be an anonymous function.) Otherwise, the subscriptions to the specified event with all the callbacks are canceled.|
8515
8516**Example**
8517
8518```ts
8519function unregisterFocusStateChange(videoSession: camera.VideoSession): void {
8520  videoSession.off('focusStateChange');
8521}
8522```
8523
8524### on('smoothZoomInfoAvailable')<sup>11+</sup>
8525
8526on(type: 'smoothZoomInfoAvailable', callback: AsyncCallback\<SmoothZoomInfo\>): void
8527
8528Subscribes to smooth zoom state change events. This API uses an asynchronous callback to return the result.
8529
8530> **NOTE**
8531>
8532> Currently, you cannot use **off()** to unregister the callback in the callback method of **on()**.
8533
8534**System capability**: SystemCapability.Multimedia.Camera.Core
8535
8536**Parameters**
8537
8538| Name    | Type                  | Mandatory| Description                      |
8539| -------- | ----------------------- | ---- | ------------------------ |
8540| type     | string                  | Yes  | Event type. The value is fixed at **'smoothZoomInfoAvailable'**. The event can be listened for when a session is created.|
8541| callback | AsyncCallback\<[SmoothZoomInfo](#smoothzoominfo11)\> | Yes  | Callback used to return the smooth zoom state change. |
8542
8543**Example**
8544
8545```ts
8546import { BusinessError } from '@kit.BasicServicesKit';
8547
8548function callback(err: BusinessError, smoothZoomInfo: camera.SmoothZoomInfo): void {
8549  if (err !== undefined && err.code !== 0) {
8550    console.error(`Callback Error, errorCode: ${err.code}`);
8551    return;
8552  }
8553  console.info(`The duration of smooth zoom: ${smoothZoomInfo.duration}`);
8554}
8555
8556function registerSmoothZoomInfo(videoSession: camera.VideoSession): void {
8557  videoSession.on('smoothZoomInfoAvailable', callback);
8558}
8559```
8560
8561### off('smoothZoomInfoAvailable')<sup>11+</sup>
8562
8563off(type: 'smoothZoomInfoAvailable', callback?: AsyncCallback\<SmoothZoomInfo\>): void
8564
8565Unsubscribes from smooth zoom state change events.
8566
8567**System capability**: SystemCapability.Multimedia.Camera.Core
8568
8569**Parameters**
8570
8571| Name    | Type                                     | Mandatory| Description                      |
8572| -------- | ----------------------------------------- | ---- | ------------------------ |
8573| type     | string              | Yes  | Event type. The value is fixed at **'smoothZoomInfoAvailable'**. The event can be listened for when a session is created.|
8574| callback | AsyncCallback\<[SmoothZoomInfo](#smoothzoominfo11)\> | No  | Callback used to return the result. If this parameter is specified, the subscription to the specified event with the specified callback is canceled. (The callback object cannot be an anonymous function.) Otherwise, the subscriptions to the specified event with all the callbacks are canceled.|
8575
8576**Example**
8577
8578```ts
8579function unregisterSmoothZoomInfo(videoSession: camera.VideoSession): void {
8580  videoSession.off('smoothZoomInfoAvailable');
8581}
8582```
8583
8584### on('autoDeviceSwitchStatusChange')<sup>13+</sup>
8585
8586on(type: 'autoDeviceSwitchStatusChange', callback: AsyncCallback\<AutoDeviceSwitchStatus\>): void
8587
8588Subscribes to automatic camera switch status change events. This API uses an asynchronous callback to return the result.
8589
8590> **NOTE**
8591>
8592> Currently, you cannot use **off()** to unregister the callback in the callback method of **on()**.
8593
8594**System capability**: SystemCapability.Multimedia.Camera.Core
8595
8596**Parameters**
8597
8598| Name    | Type                                                                  | Mandatory| Description                      |
8599| -------- |----------------------------------------------------------------------| ---- | ------------------------ |
8600| type     | string                                                               | Yes  | Event type. The value is fixed at **'autoDeviceSwitchStatusChange'**. The event can be listened for when a session is created.|
8601| callback | AsyncCallback\<[AutoDeviceSwitchStatus](#autodeviceswitchstatus13)\> | Yes  | Callback function, which is used to obtain the status of automatic camera switch. |
8602
8603**Example**
8604
8605```ts
8606import { BusinessError } from '@kit.BasicServicesKit';
8607
8608function callback(err: BusinessError, autoDeviceSwitchStatus: camera.AutoDeviceSwitchStatus): void {
8609  if (err !== undefined && err.code !== 0) {
8610    console.error(`Callback Error, errorCode: ${err.code}`);
8611    return;
8612  }
8613  console.info(`isDeviceSwitched: ${autoDeviceSwitchStatus.isDeviceSwitched}, isDeviceCapabilityChanged: ${autoDeviceSwitchStatus.isDeviceCapabilityChanged}`);
8614}
8615
8616function registerAutoDeviceSwitchStatus(videoSession: camera.VideoSession): void {
8617  videoSession.on('autoDeviceSwitchStatusChange', callback);
8618}
8619```
8620
8621### off('autoDeviceSwitchStatusChange')<sup>13+</sup>
8622
8623off(type: 'autoDeviceSwitchStatusChange', callback?: AsyncCallback\<AutoDeviceSwitchStatus\>): void
8624
8625Unsubscribes from automatic camera switch status change events.
8626
8627**System capability**: SystemCapability.Multimedia.Camera.Core
8628
8629**Parameters**
8630
8631| Name    | Type                                          | Mandatory| Description                      |
8632| -------- |----------------------------------------------| ---- | ------------------------ |
8633| type     | string                                       | Yes  | Event type. The value is fixed at **'autoDeviceSwitchStatusChange'**. The event can be listened for when a session is created.|
8634| callback | AsyncCallback\<[AutoDeviceSwitchStatus](#autodeviceswitchstatus13)\> | No  | Callback used to return the result. If this parameter is specified, the subscription to the specified event with the specified callback is canceled. (The callback object cannot be an anonymous function.) Otherwise, the subscriptions to the specified event with all the callbacks are canceled.|
8635
8636**Example**
8637
8638```ts
8639function unregisterSmoothZoomInfo(videoSession: camera.VideoSession): void {
8640  videoSession.off('autoDeviceSwitchStatusChange');
8641}
8642```
8643
8644## SecureSession<sup>12+</sup>
8645
8646SecureSession extends [Session](#session11), [Flash](#flash11), [AutoExposure](#autoexposure11), [Focus](#focus11), [Zoom](#zoom11)
8647
8648Implements a secure session, which provides operations on the flash, exposure, focus, and zoom.
8649
8650> **NOTE**
8651>
8652> You can call [createSession](#createsession11) with [SceneMode](#scenemode11) set to **SECURE_PHOTO** to create a session in secure mode. This class is designed for applications with high security requirements, such as facial recognition systems and banking services. It must be used together with the <!--RP1-->security TA<!--RP1End--> to support service scenarios where both standard preview streams and security streams are generated.<!--RP2-->
8653> The security TA can verify the signature of data delivered by the server, sign images, parse and assemble TLV logic, and read, create, and operate keys. It applies to image processing.<!--RP2End-->
8654
8655### addSecureOutput<sup>12+</sup>
8656
8657addSecureOutput(previewOutput: PreviewOutput): void
8658
8659Marks a [PreviewOutput](#previewoutput) stream as secure output.
8660
8661**System capability**: SystemCapability.Multimedia.Camera.Core
8662
8663**Parameters**
8664
8665| Name          | Type                            | Mandatory| Description           |
8666| ------------- | ------------------------------- | ---- |---------------|
8667| previewOutput  | [PreviewOutput](#previewoutput)   | Yes  | Preview output stream. An error code is returned if the input parameter is invalid.|
8668
8669**Error codes**
8670
8671For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
8672
8673| ID        | Error Message       |
8674| --------------- | --------------- |
8675| 7400101                |  Parameter missing or parameter type incorrect.        |
8676| 7400102                |  Operation not allowed.                                  |
8677| 7400103                |  Session not config.                                   |
8678
8679**Example**
8680
8681```ts
8682import { BusinessError } from '@kit.BasicServicesKit';
8683
8684function addSecureOutput(session: camera.SecureSession, previewOutput: camera.PreviewOutput): void {
8685  try {
8686    session.addSecureOutput(previewOutput);
8687  } catch (error) {
8688    // If the operation fails, error.code is returned and processed.
8689    let err = error as BusinessError;
8690    console.error(`The addOutput call failed. error code: ${err.code}`);
8691  }
8692}
8693```
8694### on('error')<sup>12+</sup>
8695
8696on(type: 'error', callback: ErrorCallback): void
8697
8698Subscribes to **SecureSession** error events. This API uses an asynchronous callback to return the result.
8699
8700> **NOTE**
8701>
8702> Currently, you cannot use **off()** to unregister the callback in the callback method of **on()**.
8703
8704**System capability**: SystemCapability.Multimedia.Camera.Core
8705
8706**Parameters**
8707
8708| Name    | Type             | Mandatory| Description                          |
8709| -------- | ------------------ | ---- | ------------------------------ |
8710| type     | string             | Yes  | Event type. The value is fixed at **'error'**. The event can be listened for when a session is created. This event is triggered and the error message is returned when an error occurs during the calling of a session-related API such as [beginConfig](#beginconfig11), [commitConfig](#commitconfig11-1), and [addInput](#addinput11).|
8711| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)      | Yes  | Callback used to return an error code defined in [CameraErrorCode](#cameraerrorcode).  |
8712
8713**Example**
8714
8715```ts
8716import { BusinessError } from '@kit.BasicServicesKit';
8717
8718function callback(err: BusinessError): void {
8719  console.error(`Video session error code: ${err.code}`);
8720}
8721
8722function registerSessionError(secureSession: camera.SecureSession): void {
8723  secureSession.on('error', callback);
8724}
8725```
8726
8727### off('error')<sup>12+</sup>
8728
8729off(type: 'error', callback?: ErrorCallback): void
8730
8731Unsubscribes from **SecureSession** error events.
8732
8733**System capability**: SystemCapability.Multimedia.Camera.Core
8734
8735**Parameters**
8736
8737| Name    | Type                         | Mandatory| Description                          |
8738| -------- | --------------------------- | ---- | ------------------------------ |
8739| type     | string                    | Yes  | Event type. The value is fixed at **'error'**. The event can be listened for when a session is created.|
8740| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| No  | Callback used to return the result. If this parameter is specified, the subscription to the specified event with the specified callback is canceled. (The callback object cannot be an anonymous function.) Otherwise, the subscriptions to the specified event with all the callbacks are canceled.|
8741
8742**Example**
8743
8744```ts
8745function unregisterSessionError(secureSession: camera.SecureSession): void {
8746  secureSession.off('error');
8747}
8748```
8749
8750### on('focusStateChange')<sup>12+</sup>
8751
8752on(type: 'focusStateChange', callback: AsyncCallback\<FocusState\>): void
8753
8754Subscribes to focus state change events. This API uses an asynchronous callback to return the result.
8755
8756> **NOTE**
8757>
8758> Currently, you cannot use **off()** to unregister the callback in the callback method of **on()**.
8759
8760**System capability**: SystemCapability.Multimedia.Camera.Core
8761
8762**Parameters**
8763
8764| Name    | Type                   | Mandatory| Description                      |
8765| -------- | ---------------- | ---- | ------------------------ |
8766| type     | string                                    | Yes  | Event type. The value is fixed at **'focusStateChange'**. The event can be listened for when a session is created. This event is triggered only when the camera focus state changes in auto focus mode.|
8767| callback | AsyncCallback\<[FocusState](#focusstate)\> | Yes  | Callback used to return the focus state change. |
8768
8769**Example**
8770
8771```ts
8772import { BusinessError } from '@kit.BasicServicesKit';
8773
8774function callback(err: BusinessError, focusState: camera.FocusState): void {
8775  if (err !== undefined && err.code !== 0) {
8776    console.error(`Callback Error, errorCode: ${err.code}`);
8777    return;
8778  }
8779  console.info(`Focus state: ${focusState}`);
8780}
8781
8782function registerFocusStateChange(secureSession: camera.SecureSession): void {
8783  secureSession.on('focusStateChange', callback);
8784}
8785```
8786
8787### off('focusStateChange')<sup>12+</sup>
8788
8789off(type: 'focusStateChange', callback?: AsyncCallback\<FocusState\>): void
8790
8791Unsubscribes from focus state change events.
8792
8793**System capability**: SystemCapability.Multimedia.Camera.Core
8794
8795**Parameters**
8796
8797| Name    | Type                                     | Mandatory| Description                      |
8798| -------- | ----------------------------------------- | ---- | ------------------------ |
8799| type     | string                                    | Yes  | Event type. The value is fixed at **'focusStateChange'**. The event can be listened for when a session is created.|
8800| callback | AsyncCallback\<[FocusState](#focusstate)\> | No | Callback used to return the result. If this parameter is specified, the subscription to the specified event with the specified callback is canceled. (The callback object cannot be an anonymous function.) Otherwise, the subscriptions to the specified event with all the callbacks are canceled.|
8801
8802**Example**
8803
8804```ts
8805function unregisterFocusStateChange(secureSession: camera.SecureSession): void {
8806  secureSession.off('focusStateChange');
8807}
8808```
8809