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