• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.multimedia.camera (Camera Management)
2<!--Kit: Camera Kit-->
3<!--Subsystem: Multimedia-->
4<!--Owner: @qano-->
5<!--SE: @leo_ysl-->
6<!--TSE: @xchaosioda-->
7
8The module provides a set of easy-to-use camera service APIs. With these APIs, you can create camera applications that access and control camera hardware to achieve basic functions like previewing, taking photos, and recording videos. In addition, you can combine these APIs to perform advanced operations, such as controlling the flash, exposure time, and focus.
9
10> **NOTE**
11>
12> 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.
13
14## Modules to Import
15
16```ts
17import { camera } from '@kit.CameraKit';
18```
19
20## camera.getCameraManager
21
22getCameraManager(context: Context): CameraManager
23
24Obtains a CameraManager instance. This API returns the result synchronously.
25
26**Atomic service API**: This API can be used in atomic services since API version 19.
27
28**System capability**: SystemCapability.Multimedia.Camera.Core
29
30**Parameters**
31
32| Name    | Type                                            | Mandatory| Description                          |
33| -------- | ----------------------------------------------- | ---- | ---------------------------- |
34| context  | [Context](../apis-ability-kit/js-apis-inner-application-context.md)      | Yes  | Application context.                  |
35
36**Return value**
37
38| Type                                            | Description                          |
39| ----------------------------------------------- | ---------------------------- |
40| [CameraManager](#cameramanager)           | CameraManager instance obtained.                  |
41
42**Error codes**
43
44For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
45
46| ID        | Error Message       |
47| --------------- | --------------- |
48| 7400101                |  Parameter missing or parameter type incorrect.               |
49| 7400201                |  Camera service fatal error.                                  |
50
51**Example**
52
53```ts
54import { common } from '@kit.AbilityKit';
55import { BusinessError } from '@kit.BasicServicesKit';
56
57function getCameraManager(context: common.BaseContext): camera.CameraManager | undefined {
58  let cameraManager: camera.CameraManager | undefined = undefined;
59  try {
60    cameraManager = camera.getCameraManager(context);
61  } catch (error) {
62    let err = error as BusinessError;
63    console.error(`The getCameraManager call failed. error code: ${err.code}`);
64  }
65  return cameraManager;
66}
67```
68
69## CameraDevice
70
71Describes the camera device information.
72
73**Atomic service API**: This API can be used in atomic services since API version 19.
74
75**System capability**: SystemCapability.Multimedia.Camera.Core
76
77| Name                             | Type                                 | Read-only| Optional| Description       |
78|---------------------------------|-------------------------------------| ---- |----|---------- |
79| cameraId                        | string                              | Yes  | No | Camera ID.|
80| cameraPosition                  | [CameraPosition](#cameraposition)   | Yes  | No | Camera position.   |
81| cameraType                      | [CameraType](#cameratype)           | Yes  | No | Camera type.   |
82| connectionType                  | [ConnectionType](#connectiontype)   | Yes  | No | Camera connection type.|
83| cameraOrientation<sup>12+</sup> | number                              | Yes  | No | Camera installation angle, which does not change as the screen rotates. The value ranges from 0° to 360°, measured in degrees.|
84| hostDeviceName<sup>15+</sup>    | string                              | Yes  | No | Remote device name.|
85| hostDeviceType<sup>15+</sup>    | [HostDeviceType](#hostdevicetype15) | Yes  | No | Remote device type.|
86
87## CameraPosition
88
89Enumerates the camera positions.
90
91**Atomic service API**: This API can be used in atomic services since API version 12.
92
93**System capability**: SystemCapability.Multimedia.Camera.Core
94
95| Name                        | Value  | Description                                                             |
96| --------------------------- | ---- |-----------------------------------------------------------------|
97| CAMERA_POSITION_UNSPECIFIED | 0    | A camera that does not have a fixed orientation relative to the device screen.                                                       |
98| CAMERA_POSITION_BACK        | 1    | Rear camera.                                                          |
99| CAMERA_POSITION_FRONT       | 2    | Front camera.                                                          |
100| 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.|
101
102## CameraType
103
104Enumerates the camera types.
105
106**Atomic service API**: This API can be used in atomic services since API version 19.
107
108**System capability**: SystemCapability.Multimedia.Camera.Core
109
110| Name                    | Value  | Description           |
111| ----------------------- | ---- | -------------- |
112| CAMERA_TYPE_DEFAULT     | 0    | Unspecified camera type. |
113| CAMERA_TYPE_WIDE_ANGLE  | 1    | Wide camera.      |
114| CAMERA_TYPE_ULTRA_WIDE  | 2    | Ultra wide camera.    |
115| CAMERA_TYPE_TELEPHOTO   | 3    | Telephoto camera.      |
116| CAMERA_TYPE_TRUE_DEPTH  | 4    | Camera with depth of field information.|
117
118## ConnectionType
119
120Enumerates the camera connection types.
121
122**Atomic service API**: This API can be used in atomic services since API version 19.
123
124**System capability**: SystemCapability.Multimedia.Camera.Core
125
126| Name                         | Value  | Description          |
127| ---------------------------- | ---- | ------------- |
128| CAMERA_CONNECTION_BUILT_IN   | 0    | Built-in camera.     |
129| CAMERA_CONNECTION_USB_PLUGIN | 1    | Camera connected using USB.|
130| CAMERA_CONNECTION_REMOTE     | 2    | Remote camera.|
131
132## HostDeviceType<sup>15+</sup>
133
134Enumerates the remote camera types.
135
136**Atomic service API**: This API can be used in atomic services since API version 19.
137
138**System capability**: SystemCapability.Multimedia.Camera.Core
139
140| Name                         | Value      | Description     |
141| ---------------------------- | ----     |---------|
142| UNKNOWN_TYPE                 | 0        | Unknown type.|
143| PHONE                        | 0x0E     | Mobile phone.  |
144| TABLET                       | 0x11     | Tablet.  |
145
146## CameraStatus
147
148Enumerates the camera statuses.
149
150**Atomic service API**: This API can be used in atomic services since API version 19.
151
152**System capability**: SystemCapability.Multimedia.Camera.Core
153
154| Name                      | Value  | Description           |
155| ------------------------- | ---- | ------------    |
156| CAMERA_STATUS_APPEAR      | 0    | A camera appears.  |
157| CAMERA_STATUS_DISAPPEAR   | 1    | The camera disappears.    |
158| CAMERA_STATUS_AVAILABLE   | 2    | The camera is available.      |
159| CAMERA_STATUS_UNAVAILABLE | 3    | The camera is unavailable.    |
160
161## FoldStatus<sup>12+</sup>
162
163Enumerates the fold states available for a fordable device.
164
165**Atomic service API**: This API can be used in atomic services since API version 19.
166
167**System capability**: SystemCapability.Multimedia.Camera.Core
168
169| Name                      | Value  | Description           |
170| ------------------------- | ---- | ------------    |
171| NON_FOLDABLE      | 0    | The device is not foldable.  |
172| EXPANDED   | 1    | The device is fully unfolded.|
173| FOLDED   | 2    | The device is folded.      |
174
175## CameraStatusInfo
176
177Describes the camera status information.
178
179**Atomic service API**: This API can be used in atomic services since API version 19.
180
181**System capability**: SystemCapability.Multimedia.Camera.Core
182
183| Name  | Type                          |    Read-only  |     Optional    | Description      |
184| ------ | ----------------------------- | --------- |------------ | ---------- |
185| camera | [CameraDevice](#cameradevice) |     No   |       No    | Camera device.|
186| status | [CameraStatus](#camerastatus) |     No   |       No    | Camera status.|
187
188## FoldStatusInfo<sup>12+</sup>
189
190Describes the fold state information about a foldable device.
191
192**Atomic service API**: This API can be used in atomic services since API version 19.
193
194**System capability**: SystemCapability.Multimedia.Camera.Core
195
196| Name  | Type                          |    Read-only  |     Optional    | Description      |
197| ------ | ----------------------------- | --------- |------------ | ---------- |
198| supportedCameras | [Array<CameraDevice\>](#cameradevice) |     No   |       No    | List of cameras supported in the current fold state.|
199| foldStatus | [FoldStatus](#foldstatus12) |     No   |       No    | Fold state.|
200
201## Profile
202
203Describes the camera profile.
204
205**Atomic service API**: This API can be used in atomic services since API version 19.
206
207**System capability**: SystemCapability.Multimedia.Camera.Core
208
209| Name     | Type                         | Read-only| Optional| Description        |
210| -------- | ----------------------------- |---- | ---- | ------------- |
211| format   | [CameraFormat](#cameraformat) | Yes |  No | Output format.     |
212| size     | [Size](#size)                 | Yes |  No | Resolution.<br>The size setting corresponds to the camera's resolution width and height, rather than the actual dimensions of the output image. |
213
214## FrameRateRange
215
216Describes the frame rate range.
217
218**Atomic service API**: This API can be used in atomic services since API version 19.
219
220**System capability**: SystemCapability.Multimedia.Camera.Core
221
222| Name     | Type                         | Read-only| Optional| Description           |
223| -------- | ----------------------------- |----- |---| -------------- |
224| min      | number                        |  Yes | No| Minimum frame rate.     |
225| max      | number                        |  Yes | No| Maximum frame rate.     |
226
227## VideoProfile
228
229Describes the video configuration information. It inherits from [Profile](#profile).
230
231**Atomic service API**: This API can be used in atomic services since API version 19.
232
233**System capability**: SystemCapability.Multimedia.Camera.Core
234
235| Name                      | Type                                     | Read-only| Optional| Description       |
236| ------------------------- | ----------------------------------------- | --- | ---- |----------- |
237| frameRateRange            | [FrameRateRange](#frameraterange)         | Yes |  No | Frame rate range, in units of frames per second (FPS).|
238
239## CameraOutputCapability
240
241Describes the camera output capability.
242
243**Atomic service API**: This API can be used in atomic services since API version 19.
244
245**System capability**: SystemCapability.Multimedia.Camera.Core
246
247| Name                          | Type                                               | Read-only| Optional| Description               |
248| ----------------------------- | --------------------------------------------------- | ---- | ---- |-------------------|
249| previewProfiles               | Array\<[Profile](#profile)\>                        |  Yes | No| Supported preview profiles.     |
250| photoProfiles                 | Array\<[Profile](#profile)\>                        |  Yes | No| Supported photo profiles.       |
251| videoProfiles                 | Array\<[VideoProfile](#videoprofile)\>              |  Yes | No| Supported video profiles.       |
252| supportedMetadataObjectTypes  | Array\<[MetadataObjectType](#metadataobjecttype)\>  |  Yes | No| Supported metadata object types.|
253
254## SceneMode<sup>11+</sup>
255
256Enumerates the camera scene modes.
257
258**Atomic service API**: This API can be used in atomic services since API version 19.
259
260**System capability**: SystemCapability.Multimedia.Camera.Core
261
262| Name                        | Value      | Description                                         |
263|----------------------------|---------|---------------------------------------------|
264| NORMAL_PHOTO               | 1       | Normal photo mode. For details, see [PhotoSession](#photosession11).  |
265| NORMAL_VIDEO               | 2       | Normal record mode. For details, see [VideoSession](#videosession11).  |
266| SECURE_PHOTO<sup>12+</sup> | 12      | Secure mode. For details, see [SecureSession](#securesession12).|
267
268## CameraErrorCode
269
270Enumerates the camera error codes,
271
272which are returned when an API call is incorrect or the **on()** API is used to listen for the error status.
273
274**Atomic service API**: This API can be used in atomic services since API version 19.
275
276**System capability**: SystemCapability.Multimedia.Camera.Core
277
278| Name                      | Value         | Description           |
279| -------------------------  | ----       | ------------    |
280| INVALID_ARGUMENT           | 7400101    | A parameter is missing or the parameter type is incorrect.  |
281| OPERATION_NOT_ALLOWED      | 7400102    | The operation is not allowed.    |
282| SESSION_NOT_CONFIG         | 7400103    | The session is not configured.      |
283| SESSION_NOT_RUNNING        | 7400104    | The session is not running.   |
284| SESSION_CONFIG_LOCKED      | 7400105    | The session configuration is locked.    |
285| DEVICE_SETTING_LOCKED      | 7400106    | The device setting is locked.    |
286| CONFLICT_CAMERA            | 7400107    | The device is already started.    |
287| DEVICE_DISABLED            | 7400108    | The camera is disabled for security reasons.    |
288| DEVICE_PREEMPTED           | 7400109    | The camera is preempted.    |
289| UNRESOLVED_CONFLICTS_WITH_CURRENT_CONFIGURATIONS<sup>12+</sup> | 7400110   | The configuration conflicts with the current configuration.    |
290| SERVICE_FATAL_ERROR        | 7400201    | An error occurs in the camera service.    |
291
292## CameraManager
293
294Implements camera management. Before calling any API in CameraManager, you must use [getCameraManager](#cameragetcameramanager) to obtain a CameraManager instance.
295
296### getSupportedCameras
297
298getSupportedCameras(): Array\<CameraDevice\>
299
300Obtains the supported camera devices. This API returns the result synchronously.
301
302**Atomic service API**: This API can be used in atomic services since API version 19.
303
304**System capability**: SystemCapability.Multimedia.Camera.Core
305
306**Return value**
307
308| Type                                            | Description                          |
309| ----------------------------------------------- | ---------------------------- |
310|  Array\<[CameraDevice](#cameradevice)>            | Array of camera devices supported.                  |
311
312**Example**
313
314```ts
315import { BusinessError } from '@kit.BasicServicesKit';
316
317function getSupportedCameras(cameraManager: camera.CameraManager): Array<camera.CameraDevice> {
318  let cameras: Array<camera.CameraDevice> = [];
319  try {
320    cameras = cameraManager.getSupportedCameras();
321  } catch (error) {
322    let err = error as BusinessError;
323    console.error(`The getSupportedCameras call failed. error code: ${err.code}`);
324  }
325  return cameras;
326}
327```
328
329### getSupportedSceneModes<sup>11+</sup>
330
331getSupportedSceneModes(camera: CameraDevice): Array\<SceneMode\>
332
333Obtains the scene modes supported by a camera device. This API returns the result synchronously.
334
335**Atomic service API**: This API can be used in atomic services since API version 19.
336
337**System capability**: SystemCapability.Multimedia.Camera.Core
338
339**Parameters**
340
341| Name        | Type                                                           | Mandatory| Description                     |
342| ------------ |--------------------------------------------------------------- | -- | -------------------------- |
343| camera | [CameraDevice](#cameradevice)                              | Yes| CameraDevice instance, which is obtained through [getSupportedCameras](#getsupportedcameras). An error code is returned if the input parameter is invalid.      |
344
345**Return value**
346
347| Type                                            | Description                          |
348| ----------------------------------------------- | ---------------------------- |
349|  Array\<[SceneMode](#scenemode11)>            | Array of scene modes supported.                  |
350
351**Example**
352
353```ts
354import { BusinessError } from '@kit.BasicServicesKit';
355
356function getSupportedSceneModes(cameraManager: camera.CameraManager, camera: camera.CameraDevice): Array<camera.SceneMode> {
357  let modes: Array<camera.SceneMode> = [];
358  try {
359    modes = cameraManager.getSupportedSceneModes(camera);
360  } catch (error) {
361    let err = error as BusinessError;
362    console.error(`The getSupportedSceneModes call failed. error code: ${err.code}`);
363  }
364  return modes;
365}
366```
367
368### getSupportedOutputCapability<sup>(deprecated)</sup>
369
370getSupportedOutputCapability(camera: CameraDevice): CameraOutputCapability
371
372Obtains the output capability supported by a camera device. This API returns the result synchronously.
373
374> **NOTE**
375>
376> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [getSupportedOutputCapability](#getsupportedoutputcapability11) instead.
377
378**System capability**: SystemCapability.Multimedia.Camera.Core
379
380**Parameters**
381
382| Name        | Type                                                           | Mandatory| Description                     |
383| ------------ |--------------------------------------------------------------- | -- | -------------------------- |
384| camera | [CameraDevice](#cameradevice)                              | Yes| CameraDevice instance, which is obtained through [getSupportedCameras](#getsupportedcameras). An error code is returned if the input parameter is invalid.     |
385
386**Return value**
387
388| Type                                            | Description                          |
389| ----------------------------------------------- | ---------------------------- |
390| [CameraOutputCapability](#cameraoutputcapability)            | Camera output capability obtained.                  |
391
392**Example**
393
394```ts
395function getSupportedOutputCapability(camera: camera.CameraDevice, cameraManager: camera.CameraManager): camera.CameraOutputCapability {
396  let cameraOutputCapability: camera.CameraOutputCapability = cameraManager.getSupportedOutputCapability(camera);
397  return cameraOutputCapability;
398}
399```
400
401### getSupportedOutputCapability<sup>11+</sup>
402
403getSupportedOutputCapability(camera: CameraDevice, mode: SceneMode): CameraOutputCapability
404
405Obtains the output capability supported by a camera device in a given scene mode. This API returns the result synchronously.
406
407**Atomic service API**: This API can be used in atomic services since API version 19.
408
409**System capability**: SystemCapability.Multimedia.Camera.Core
410
411**Parameters**
412
413| Name        | Type                                                           | Mandatory| Description                     |
414| ------------ |--------------------------------------------------------------- | -- | -------------------------- |
415| camera | [CameraDevice](#cameradevice)                              | Yes| CameraDevice instance, which is obtained through [getSupportedCameras](#getsupportedcameras).      |
416| mode | [SceneMode](#scenemode11)                              | Yes| Scene mode, which is obtained through [getSupportedSceneModes](#getsupportedscenemodes11).      |
417
418**Return value**
419
420| Type                                            | Description                          |
421| ----------------------------------------------- | ---------------------------- |
422| [CameraOutputCapability](#cameraoutputcapability)            | Camera output capability obtained.                  |
423
424**Example**
425
426```ts
427function getSupportedOutputCapability(camera: camera.CameraDevice, cameraManager: camera.CameraManager, sceneMode: camera.SceneMode): camera.CameraOutputCapability {
428  let cameraOutputCapability: camera.CameraOutputCapability = cameraManager.getSupportedOutputCapability(camera, sceneMode);
429  return cameraOutputCapability;
430}
431```
432
433### isCameraMuted
434
435isCameraMuted(): boolean
436
437Checks whether this camera is muted.
438
439**Atomic service API**: This API can be used in atomic services since API version 19.
440
441**System capability**: SystemCapability.Multimedia.Camera.Core
442
443**Return value**
444
445| Type       | Description                                        |
446| ---------- | -------------------------------------------- |
447| boolean    | Check result. The value **true** means that the camera device is muted, and **false** means the opposite.|
448
449**Example**
450
451```ts
452function isCameraMuted(cameraManager: camera.CameraManager): boolean {
453  let isMuted: boolean = cameraManager.isCameraMuted();
454  return isMuted;
455}
456```
457
458### createCameraInput
459
460createCameraInput(camera: CameraDevice): CameraInput
461
462Creates a CameraInput instance with the specified CameraDevice instance. This API returns the result synchronously.
463
464Before calling this API, call [getSupportedCameras](#getsupportedcameras) to obtain the list of supported camera devices, select the camera device that meets the requirements based on the actual usage scenario, and then create the CameraInput instance.
465
466**Required permissions**: ohos.permission.CAMERA
467
468**Atomic service API**: This API can be used in atomic services since API version 19.
469
470**System capability**: SystemCapability.Multimedia.Camera.Core
471
472**Parameters**
473
474| Name    | Type                                        | Mandatory| Description                                              |
475| -------- | ------------------------------------------- | ---- |--------------------------------------------------|
476| camera  | [CameraDevice](#cameradevice)         | Yes  | CameraDevice instance, which is obtained through [getSupportedCameras](#getsupportedcameras).|
477
478**Return value**
479
480| Type       | Description                         |
481| ---------- | ----------------------------- |
482| [CameraInput](#camerainput)    | CameraInput instance created. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
483
484**Error codes**
485
486For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
487
488| ID        | Error Message       |
489| --------------- | --------------- |
490| 7400101                |  Parameter missing or parameter type incorrect.               |
491| 7400102                |  Operation not allowed.               |
492| 7400201                |  Camera service fatal error.               |
493
494**Example**
495
496```ts
497import { BusinessError } from '@kit.BasicServicesKit';
498
499function createCameraInput(camera: camera.CameraDevice, cameraManager: camera.CameraManager): camera.CameraInput | undefined {
500  let cameraInput: camera.CameraInput | undefined = undefined;
501  try {
502    cameraInput = cameraManager.createCameraInput(camera);
503  } catch (error) {
504    // If the operation fails, error.code is returned and processed.
505    let err = error as BusinessError;
506    console.error(`The createCameraInput call failed. error code: ${err.code}`);
507  }
508  return cameraInput;
509}
510```
511
512### createCameraInput
513
514createCameraInput(position: CameraPosition, type: CameraType): CameraInput
515
516Creates a CameraInput instance with the specified camera position and type. This API returns the result synchronously.
517
518Before calling this API, specify the camera position and type based on the usage scenario. For example, open the front camera for the selfie feature
519
520**Required permissions**: ohos.permission.CAMERA
521
522**Atomic service API**: This API can be used in atomic services since API version 19.
523
524**System capability**: SystemCapability.Multimedia.Camera.Core
525
526**Parameters**
527
528| Name    | Type                                       | Mandatory| Description                               |
529| -------- | ------------------------------------------- | ---- | --------------------------------- |
530| position | [CameraPosition](#cameraposition)           | Yes  | Camera position. You need to obtain the supported camera object by calling [getSupportedCameras](#getsupportedcameras) and then obtain the device position information based on the returned camera object. |
531| type     | [CameraType](#cameratype)                   | Yes  | Camera type. You need to obtain the supported camera object by calling [getSupportedCameras](#getsupportedcameras) and then obtain the camera type based on the returned camera object.|
532
533**Return value**
534
535| Type       | Description                         |
536| ---------- | ----------------------------- |
537| [CameraInput](#camerainput)    | CameraInput 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| 7400102                |  Operation not allowed.               |
547| 7400201                |  Camera service fatal error.               |
548
549**Example**
550
551```ts
552import { BusinessError } from '@kit.BasicServicesKit';
553
554function createCameraInput(camera: camera.CameraDevice, cameraManager: camera.CameraManager): camera.CameraInput | undefined {
555  let position: camera.CameraPosition = camera.cameraPosition;
556  let type: camera.CameraType = camera.cameraType;
557  let cameraInput: camera.CameraInput | undefined = undefined;
558  try {
559    cameraInput = cameraManager.createCameraInput(position, type);
560  } catch (error) {
561    // If the operation fails, error.code is returned and processed.
562    let err = error as BusinessError;
563    console.error(`The createCameraInput call failed. error code: ${err.code}`);
564  }
565  return cameraInput;
566}
567```
568
569### createPreviewOutput
570
571createPreviewOutput(profile: Profile, surfaceId: string): PreviewOutput
572
573Creates a PreviewOutput instance. This API returns the result synchronously.
574
575**Atomic service API**: This API can be used in atomic services since API version 19.
576
577**System capability**: SystemCapability.Multimedia.Camera.Core
578
579**Parameters**
580
581| Name    | Type                                            | Mandatory| Description                             |
582| -------- | ----------------------------------------------- | ---- | ------------------------------- |
583| profile  | [Profile](#profile)                             | Yes  | Supported preview profile, which is obtained through [getSupportedOutputCapability](#getsupportedoutputcapability11).|
584| surfaceId| string | Yes  | Surface ID, which is obtained from [XComponent](../apis-arkui/arkui-ts/ts-basic-components-xcomponent.md) or [ImageReceiver](../apis-image-kit/arkts-apis-image-ImageReceiver.md).|
585
586**Return value**
587
588| Type       | Description                         |
589| ---------- | ----------------------------- |
590| [PreviewOutput](#previewoutput)    | PreviewOutput instance created. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
591
592**Error codes**
593
594For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
595
596| ID        | Error Message       |
597| --------------- | --------------- |
598| 7400101                |  Parameter missing or parameter type incorrect.               |
599| 7400201                |  Camera service fatal error.               |
600
601**Example**
602
603```ts
604import { BusinessError } from '@kit.BasicServicesKit';
605
606function createPreviewOutput(cameraOutputCapability: camera.CameraOutputCapability, cameraManager: camera.CameraManager, surfaceId: string): camera.PreviewOutput | undefined {
607  let profile: camera.Profile = cameraOutputCapability.previewProfiles[0];
608  let previewOutput: camera.PreviewOutput | undefined = undefined;
609  try {
610    previewOutput = cameraManager.createPreviewOutput(profile, surfaceId);
611  } catch (error) {
612    // If the operation fails, error.code is returned and processed.
613    let err = error as BusinessError;
614    console.error(`The createPreviewOutput call failed. error code: ${err.code}`);
615  }
616  return previewOutput;
617}
618```
619
620### createPreviewOutput<sup>12+</sup>
621
622createPreviewOutput(surfaceId: string): PreviewOutput
623
624Creates a PreviewOutput instance without configuration. This API returns the result synchronously. It must be used together with [preconfig](#preconfig12).
625
626**Atomic service API**: This API can be used in atomic services since API version 19.
627
628**System capability**: SystemCapability.Multimedia.Camera.Core
629
630**Parameters**
631
632| Name    | Type                                            | Mandatory| Description                             |
633| -------- | ----------------------------------------------- | ---- | ------------------------------- |
634| surfaceId| string | Yes  | Surface ID, which is obtained from [XComponent](../apis-arkui/arkui-ts/ts-basic-components-xcomponent.md) or [ImageReceiver](../apis-image-kit/arkts-apis-image-ImageReceiver.md).|
635
636**Return value**
637
638| Type       | Description                         |
639| ---------- | ----------------------------- |
640| [PreviewOutput](#previewoutput)    | PreviewOutput instance created. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
641
642**Error codes**
643
644For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
645
646| ID  | Error Message                                          |
647|---------|------------------------------------------------|
648| 7400101 | Parameter missing or parameter type incorrect. |
649| 7400201 | Camera service fatal error.                    |
650
651**Example**
652
653```ts
654import { BusinessError } from '@kit.BasicServicesKit';
655
656function createPreviewOutput(cameraManager: camera.CameraManager, surfaceId: string): camera.PreviewOutput | undefined {
657  let previewOutput: camera.PreviewOutput | undefined = undefined;
658  try {
659    previewOutput = cameraManager.createPreviewOutput(surfaceId);
660  } catch (error) {
661    // If the operation fails, error.code is returned and processed.
662    let err = error as BusinessError;
663    console.error(`The createPreviewOutput call failed. error code: ${err.code}`);
664  }
665  return previewOutput;
666}
667```
668
669### createPhotoOutput<sup>(deprecated)</sup>
670
671createPhotoOutput(profile: Profile, surfaceId: string): PhotoOutput
672
673Creates a PhotoOutput instance. This API returns the result synchronously.
674
675> **NOTE**
676>
677> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [createPhotoOutput](#createphotooutput11) instead.
678
679**System capability**: SystemCapability.Multimedia.Camera.Core
680
681**Parameters**
682
683| Name    | Type                                        | Mandatory| Description                                 |
684| -------- | ------------------------------------------- | ---- | ----------------------------------- |
685| profile  | [Profile](#profile)                         | Yes  | Supported photo profile, which is obtained through [getSupportedOutputCapability](#getsupportedoutputcapability11).|
686| surfaceId| string            | Yes  | Surface ID, which is obtained from [ImageReceiver](../apis-image-kit/arkts-apis-image-ImageReceiver.md).|
687
688**Return value**
689
690| Type       | Description                         |
691| ---------- | ----------------------------- |
692| [PhotoOutput](#photooutput)   | PhotoOutput instance created. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
693
694**Error codes**
695
696For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
697
698| ID        | Error Message       |
699| --------------- | --------------- |
700| 7400101                |  Parameter missing or parameter type incorrect.               |
701
702```ts
703import { BusinessError } from '@kit.BasicServicesKit';
704
705function createPhotoOutput(cameraOutputCapability: camera.CameraOutputCapability, cameraManager: camera.CameraManager, surfaceId: string): camera.PhotoOutput | undefined {
706  let profile: camera.Profile = cameraOutputCapability.photoProfiles[0];
707  let photoOutput: camera.PhotoOutput | undefined = undefined;
708  try {
709    photoOutput = cameraManager.createPhotoOutput(profile, surfaceId);
710  } catch (error) {
711    // If the operation fails, error.code is returned and processed.
712    let err = error as BusinessError;
713    console.error(`The createPhotoOutput call failed. error code: ${err.code}`);
714  }
715  return photoOutput;
716}
717```
718
719### createPhotoOutput<sup>11+</sup>
720
721createPhotoOutput(profile?: Profile): PhotoOutput
722
723Creates a PhotoOutput instance. This API returns the result synchronously.
724
725**Atomic service API**: This API can be used in atomic services since API version 19.
726
727**System capability**: SystemCapability.Multimedia.Camera.Core
728
729**Parameters**
730
731| Name    | Type                                        | Mandatory| Description                                 |
732| -------- | ------------------------------------------- |----| ----------------------------------- |
733| 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**.|
734
735**Return value**
736
737| Type       | Description                         |
738| ---------- | ----------------------------- |
739| [PhotoOutput](#photooutput)   | PhotoOutput instance created. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
740
741**Error codes**
742
743For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
744
745| ID   | Error Message                                          |
746|----------|------------------------------------------------|
747| 7400101  | Parameter missing or parameter type incorrect. |
748| 7400201  | Camera service fatal error.                    |
749
750**Example**
751
752```ts
753import { BusinessError } from '@kit.BasicServicesKit';
754
755function createPhotoOutput(cameraOutputCapability: camera.CameraOutputCapability, cameraManager: camera.CameraManager): camera.PhotoOutput | undefined {
756  let profile: camera.Profile = cameraOutputCapability.photoProfiles[0];
757  let photoOutput: camera.PhotoOutput | undefined = undefined;
758  try {
759    photoOutput = cameraManager.createPhotoOutput(profile);
760  } catch (error) {
761    // If the operation fails, error.code is returned and processed.
762    let err = error as BusinessError;
763    console.error(`The createPhotoOutput call failed. error code: ${err.code}`);
764  }
765  return photoOutput;
766}
767```
768
769### createVideoOutput
770
771createVideoOutput(profile: VideoProfile, surfaceId: string): VideoOutput
772
773Creates a VideoOutput instance. This API returns the result synchronously.
774
775**Atomic service API**: This API can be used in atomic services since API version 19.
776
777**System capability**: SystemCapability.Multimedia.Camera.Core
778
779**Parameters**
780
781| Name    | Type                                       | Mandatory| Description                             |
782| -------- | ------------------------------------------- | ---- | ------------------------------ |
783| profile  | [VideoProfile](#videoprofile)               | Yes  | Supported video profile, which is obtained through [getSupportedOutputCapability](#getsupportedoutputcapability11).|
784| surfaceId| string          | Yes  | Surface ID, which is obtained from [AVRecorder](../apis-media-kit/js-apis-media.md#avrecorder9).|
785
786**Return value**
787
788| Type       | Description                         |
789| ---------- | ----------------------------- |
790| [VideoOutput](#videooutput)   | VideoOutput instance created. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
791
792**Error codes**
793
794For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
795
796| ID        | Error Message       |
797| --------------- | --------------- |
798| 7400101                |  Parameter missing or parameter type incorrect.               |
799| 7400201                |  Camera service fatal error.               |
800
801**Example**
802
803```ts
804import { BusinessError } from '@kit.BasicServicesKit';
805
806function createVideoOutput(cameraOutputCapability: camera.CameraOutputCapability, cameraManager: camera.CameraManager, surfaceId: string): camera.VideoOutput | undefined {
807  let profile: camera.VideoProfile = cameraOutputCapability.videoProfiles[0];
808  let videoOutput: camera.VideoOutput | undefined = undefined;
809  try {
810    videoOutput = cameraManager.createVideoOutput(profile, surfaceId);
811  } catch (error) {
812    // If the operation fails, error.code is returned and processed.
813    let err = error as BusinessError;
814    console.error(`The createVideoOutput call failed. error code: ${err.code}`);
815  }
816  return videoOutput;
817}
818```
819
820### createVideoOutput<sup>12+</sup>
821
822createVideoOutput(surfaceId: string): VideoOutput
823
824Creates a VideoOutput instance without configuration. This API returns the result synchronously. It must be used together with [preconfig](#preconfig12-1).
825
826**Atomic service API**: This API can be used in atomic services since API version 19.
827
828**System capability**: SystemCapability.Multimedia.Camera.Core
829
830**Parameters**
831
832| Name      | Type    | Mandatory   | Description                                                                        |
833|-----------|--------|-------|----------------------------------------------------------------------------|
834| surfaceId | string | Yes    | Surface ID, which is obtained from [AVRecorder](../apis-media-kit/js-apis-media.md#avrecorder9).|
835
836**Return value**
837
838| Type       | Description                         |
839| ---------- | ----------------------------- |
840| [VideoOutput](#videooutput)   | VideoOutput instance created. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
841
842**Error codes**
843
844For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
845
846| ID   | Error Message                                          |
847|----------|------------------------------------------------|
848| 7400101  | Parameter missing or parameter type incorrect. |
849| 7400201  | Camera service fatal error.                    |
850
851**Example**
852
853```ts
854import { BusinessError } from '@kit.BasicServicesKit';
855
856function createVideoOutput(cameraManager: camera.CameraManager, surfaceId: string): camera.VideoOutput | undefined {
857  let videoOutput: camera.VideoOutput | undefined = undefined;
858  try {
859    videoOutput = cameraManager.createVideoOutput(surfaceId);
860  } catch (error) {
861    // If the operation fails, error.code is returned and processed.
862    let err = error as BusinessError;
863    console.error(`The createVideoOutput call failed. error code: ${err.code}`);
864  }
865  return videoOutput;
866}
867```
868
869### createMetadataOutput
870
871createMetadataOutput(metadataObjectTypes: Array\<MetadataObjectType\>): MetadataOutput
872
873Creates a MetadataOutput instance. This API returns the result synchronously.
874
875**Atomic service API**: This API can be used in atomic services since API version 19.
876
877**System capability**: SystemCapability.Multimedia.Camera.Core
878
879**Parameters**
880
881| Name                 | Type                                              | Mandatory| Description                         |
882| -------------------- | -------------------------------------------------- | --- | ---------------------------- |
883| metadataObjectTypes  | Array\<[MetadataObjectType](#metadataobjecttype)\>  | Yes | Metadata object types, which are obtained through [getSupportedOutputCapability](#getsupportedoutputcapability11).|
884
885**Return value**
886
887| Type       | Description                         |
888| ---------- | ----------------------------- |
889| [MetadataOutput](#metadataoutput)   | MetadataOutput instance created. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
890
891**Error codes**
892
893For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
894
895| ID        | Error Message       |
896| --------------- | --------------- |
897| 7400101                |  Parameter missing or parameter type incorrect.               |
898| 7400201                |  Camera service fatal error.               |
899
900**Example**
901
902```ts
903import { BusinessError } from '@kit.BasicServicesKit';
904
905function createMetadataOutput(cameraManager: camera.CameraManager, cameraOutputCapability: camera.CameraOutputCapability): void {
906  let metadataObjectTypes: Array<camera.MetadataObjectType> = cameraOutputCapability.supportedMetadataObjectTypes;
907  let metadataOutput: camera.MetadataOutput | undefined = undefined;
908  try {
909    metadataOutput = cameraManager.createMetadataOutput(metadataObjectTypes);
910  } catch (error) {
911    // If the operation fails, error.code is returned and processed.
912    let err = error as BusinessError;
913    console.error(`createMetadataOutput error. error code: ${err.code}`);
914  }
915}
916```
917
918### createCaptureSession<sup>(deprecated)</sup>
919
920createCaptureSession(): CaptureSession
921
922Creates a CaptureSession instance. This API returns the result synchronously.
923
924> **NOTE**
925>
926> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [createSession](#createsession11) instead.
927
928**System capability**: SystemCapability.Multimedia.Camera.Core
929
930**Return value**
931
932| Type       | Description                         |
933| ---------- | ----------------------------- |
934| [CaptureSession](#capturesessiondeprecated)   | CaptureSession instance created. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
935
936**Error codes**
937
938For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
939
940| ID        | Error Message       |
941| --------------- | --------------- |
942| 7400201                |  Camera service fatal error.               |
943
944**Example**
945
946```ts
947import { BusinessError } from '@kit.BasicServicesKit';
948
949function createCaptureSession(cameraManager: camera.CameraManager): camera.CaptureSession | undefined {
950  let captureSession: camera.CaptureSession | undefined = undefined;
951  try {
952    captureSession = cameraManager.createCaptureSession();
953  } catch (error) {
954    // If the operation fails, error.code is returned and processed.
955    let err = error as BusinessError;
956    console.error(`createCaptureSession error. error code: ${err.code}`);
957  }
958  return captureSession;
959}
960```
961
962### createSession<sup>11+</sup>
963
964createSession\<T extends Session\>(mode: SceneMode): T
965
966Creates a Session instance with a given scene mode. This API returns the result synchronously.
967
968**Atomic service API**: This API can be used in atomic services since API version 19.
969
970**System capability**: SystemCapability.Multimedia.Camera.Core
971
972**Parameters**
973
974| Name  | Type             | Mandatory| Description      |
975| -------- | -----------------| ---- | --------- |
976| 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).|
977
978**Return value**
979
980| Type       | Description                         |
981| ---------- | ----------------------------- |
982| [T extends Session](#session11)   | Session instance created. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
983
984**Error codes**
985
986For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
987
988| ID  | Error Message                                                                                                                                          |
989|---------|------------------------------------------------------------------------------------------------------------------------------------------------|
990| 7400101 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3.Parameter verification failed. |
991| 7400201 | Camera service fatal error.                                                                                                                    |
992
993**Example**
994
995```ts
996import { BusinessError } from '@kit.BasicServicesKit';
997
998function createSession(cameraManager: camera.CameraManager, mode: camera.SceneMode): camera.Session | undefined {
999  let photoSession: camera.PhotoSession | undefined = undefined;
1000  try {
1001    photoSession = cameraManager.createSession(mode) as camera.PhotoSession;
1002  } catch (error) {
1003    // If the operation fails, error.code is returned and processed.
1004    let err = error as BusinessError;
1005    console.error(`createCaptureSession error. error code: ${err.code}`);
1006  }
1007  return photoSession;
1008}
1009```
1010
1011### on('cameraStatus')
1012
1013on(type: 'cameraStatus', callback: AsyncCallback\<CameraStatusInfo\>): void
1014
1015Subscribes to camera status events. This API uses an asynchronous callback to return the result.
1016
1017> **NOTE**
1018>
1019> Currently, you cannot use **off()** to unregister the callback in the callback method of **on()**.
1020
1021**Atomic service API**: This API can be used in atomic services since API version 19.
1022
1023**System capability**: SystemCapability.Multimedia.Camera.Core
1024
1025**Parameters**
1026
1027| Name    | Type           | Mandatory| Description      |
1028| -------- | -----------------| ---- | --------- |
1029| 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.|
1030| callback | AsyncCallback\<[CameraStatusInfo](#camerastatusinfo)\> | Yes  | Callback used to return the camera status change.|                 |
1031
1032**Example**
1033
1034```ts
1035import { BusinessError } from '@kit.BasicServicesKit';
1036
1037function callback(err: BusinessError, cameraStatusInfo: camera.CameraStatusInfo): void {
1038  if (err !== undefined && err.code !== 0) {
1039    console.error('cameraStatus with errorCode = ' + err.code);
1040    return;
1041  }
1042  console.info(`camera : ${cameraStatusInfo.camera.cameraId}`);
1043  console.info(`status: ${cameraStatusInfo.status}`);
1044}
1045
1046function registerCameraStatus(cameraManager: camera.CameraManager): void {
1047  cameraManager.on('cameraStatus', callback);
1048}
1049```
1050
1051### off('cameraStatus')
1052
1053off(type: 'cameraStatus', callback?: AsyncCallback\<CameraStatusInfo\>): void
1054
1055Unsubscribes from camera status events. This API uses an asynchronous callback to return the result.
1056
1057**Atomic service API**: This API can be used in atomic services since API version 19.
1058
1059**System capability**: SystemCapability.Multimedia.Camera.Core
1060
1061**Parameters**
1062
1063| Name    | Type           | Mandatory| Description      |
1064| -------- | -----------------| ---- | --------- |
1065| type     | string           | Yes  | Event type. The value is fixed at **'cameraStatus'**. The event can be listened for when a CameraManager instance is obtained.|
1066| 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.|
1067
1068**Example**
1069
1070```ts
1071function unregisterCameraStatus(cameraManager: camera.CameraManager): void {
1072  cameraManager.off('cameraStatus');
1073}
1074```
1075
1076### on('foldStatusChange')<sup>12+</sup>
1077
1078on(type: 'foldStatusChange', callback: AsyncCallback\<FoldStatusInfo\>): void
1079
1080Subscribes to fold status change events of the foldable device. This API uses an asynchronous callback to return the result.
1081
1082> **NOTE**
1083>
1084> Currently, you cannot use **off()** to unregister the callback in the callback method of **on()**.
1085
1086**Atomic service API**: This API can be used in atomic services since API version 19.
1087
1088**System capability**: SystemCapability.Multimedia.Camera.Core
1089
1090**Parameters**
1091
1092| Name    | Type           | Mandatory| Description      |
1093| -------- | -----------------| ---- | --------- |
1094| type     | string           | Yes  | Event type. The value is fixed at **'foldStatusChange'**. The event is triggered when the fold state of the foldable device changes.|
1095| callback | AsyncCallback\<[FoldStatusInfo](#foldstatusinfo12)\> | Yes  | Callback used to return the fold state information about the foldable device.|
1096
1097**Example**
1098
1099```ts
1100import { BusinessError } from '@kit.BasicServicesKit';
1101
1102function callback(err: BusinessError, foldStatusInfo: camera.FoldStatusInfo): void {
1103  if (err !== undefined && err.code !== 0) {
1104    console.error('foldStatusChange with errorCode = ' + err.code);
1105    return;
1106  }
1107  console.info(`camera length: ${foldStatusInfo.supportedCameras.length}`);
1108  console.info(`foldStatus: ${foldStatusInfo.foldStatus}`);
1109}
1110
1111function registerFoldStatusChange(cameraManager: camera.CameraManager): void {
1112  cameraManager.on('foldStatusChange', callback);
1113}
1114```
1115
1116### off('foldStatusChange')<sup>12+</sup>
1117
1118off(type: 'foldStatusChange', callback?: AsyncCallback\<FoldStatusInfo\>): void
1119
1120Unsubscribes from fold state change events of the foldable device.
1121
1122**Atomic service API**: This API can be used in atomic services since API version 19.
1123
1124**System capability**: SystemCapability.Multimedia.Camera.Core
1125
1126**Parameters**
1127
1128| Name    | Type           | Mandatory| Description      |
1129| -------- | -----------------| ---- | --------- |
1130| type     | string           | Yes  | Event type. The value is fixed at **'foldStatusChange'**. The event is triggered when the fold state of the foldable device changes.|
1131| callback | AsyncCallback\<[FoldStatusInfo](#foldstatusinfo12)\> | No  | Callback used to return the fold state 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.|
1132
1133**Example**
1134
1135```ts
1136function unregisterFoldStatusChange(cameraManager: camera.CameraManager): void {
1137  cameraManager.off('foldStatusChange');
1138}
1139```
1140
1141### isTorchSupported<sup>11+</sup>
1142
1143isTorchSupported(): boolean
1144
1145Checks whether the camera device supports the flashlight.
1146
1147**Atomic service API**: This API can be used in atomic services since API version 19.
1148
1149**System capability**: SystemCapability.Multimedia.Camera.Core
1150
1151**Return value**
1152
1153| Type       | Description                         |
1154| ---------- | ----------------------------- |
1155| boolean    | Check result for the support of the flashlight. **true** if supported, **false** otherwise.|
1156
1157**Example**
1158
1159```ts
1160function isTorchSupported(cameraManager: camera.CameraManager): boolean {
1161  let isSupported = cameraManager.isTorchSupported();
1162  return isSupported;
1163}
1164```
1165
1166### isTorchModeSupported<sup>11+</sup>
1167
1168isTorchModeSupported(mode: TorchMode): boolean
1169
1170Checks whether a flashlight mode is supported.
1171
1172**Atomic service API**: This API can be used in atomic services since API version 19.
1173
1174**System capability**: SystemCapability.Multimedia.Camera.Core
1175
1176**Parameters**
1177
1178| Name    | Type            | Mandatory| Description      |
1179| -------- | --------------- | ---- | --------- |
1180| 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.|
1181
1182**Return value**
1183
1184| Type       | Description                         |
1185| ---------- | ----------------------------- |
1186| boolean    | Check result for the support of the flashlight mode. **true** if supported, **false** otherwise.|
1187
1188**Example**
1189
1190```ts
1191function isTorchModeSupported(cameraManager: camera.CameraManager, torchMode: camera.TorchMode): boolean {
1192  let isSupported = cameraManager.isTorchModeSupported(torchMode);
1193  return isSupported;
1194}
1195```
1196
1197### getTorchMode<sup>11+</sup>
1198
1199getTorchMode(): TorchMode
1200
1201Obtains the flashlight mode of this camera device.
1202
1203**Atomic service API**: This API can be used in atomic services since API version 19.
1204
1205**System capability**: SystemCapability.Multimedia.Camera.Core
1206
1207**Return value**
1208
1209| Type       | Description                         |
1210| ---------- | ----------------------------- |
1211| [TorchMode](#torchmode11)    | Flashlight mode.|
1212
1213**Example**
1214
1215```ts
1216function getTorchMode(cameraManager: camera.CameraManager): camera.TorchMode | undefined {
1217  let torchMode: camera.TorchMode | undefined = undefined;
1218  torchMode = cameraManager.getTorchMode();
1219  return torchMode;
1220}
1221```
1222
1223### setTorchMode<sup>11+</sup>
1224
1225setTorchMode(mode: TorchMode): void
1226
1227Sets the flashlight mode.
1228
1229**Atomic service API**: This API can be used in atomic services since API version 19.
1230
1231**System capability**: SystemCapability.Multimedia.Camera.Core
1232
1233**Parameters**
1234
1235| Name    | Type            | Mandatory| Description      |
1236| -------- | --------------- | ---- | --------- |
1237| 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.|
1238
1239**Error codes**
1240
1241For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
1242
1243| ID        | Error Message       |
1244| --------------- | --------------- |
1245| 7400102 | Operation not allowed. |
1246| 7400201 | Camera service fatal error. |
1247
1248**Example**
1249
1250```ts
1251import { BusinessError } from '@kit.BasicServicesKit';
1252
1253function setTorchMode(cameraManager: camera.CameraManager, torchMode: camera.TorchMode): void {
1254  try {
1255    cameraManager.setTorchMode(torchMode);
1256  } catch (error) {
1257    // If the operation fails, error.code is returned and processed.
1258    let err = error as BusinessError;
1259    console.error(`The setTorchMode call failed. error code: ${err.code}`);
1260  }
1261}
1262```
1263
1264### on('torchStatusChange')<sup>11+</sup>
1265
1266on(type: 'torchStatusChange', callback: AsyncCallback\<TorchStatusInfo\>): void
1267
1268Subscribes to flashlight status change events. This API uses an asynchronous callback to return the result.
1269
1270> **NOTE**
1271>
1272> Currently, you cannot use **off()** to unregister the callback in the callback method of **on()**.
1273
1274**Atomic service API**: This API can be used in atomic services since API version 19.
1275
1276**System capability**: SystemCapability.Multimedia.Camera.Core
1277
1278**Parameters**
1279
1280| Name    | Type            | Mandatory| Description      |
1281| -------- | --------------- | ---- | --------- |
1282| 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.|
1283| callback | AsyncCallback\<TorchStatusInfo> | Yes  | Callback used to return the flashlight status.              |
1284
1285**Example**
1286
1287```ts
1288import { BusinessError } from '@kit.BasicServicesKit';
1289
1290function callback(err: BusinessError, torchStatusInfo: camera.TorchStatusInfo): void {
1291  if (err !== undefined && err.code !== 0) {
1292    console.error(`Callback Error, errorCode: ${err.code}`);
1293    return;
1294  }
1295  console.info(`onTorchStatusChange, isTorchAvailable: ${torchStatusInfo.isTorchAvailable}, isTorchActive: ${torchStatusInfo.isTorchActive}, level: ${torchStatusInfo.torchLevel}`);
1296}
1297
1298function registerTorchStatusChange(cameraManager: camera.CameraManager): void {
1299  cameraManager.on('torchStatusChange', callback);
1300}
1301```
1302
1303### off('torchStatusChange')<sup>11+</sup>
1304
1305off(type: 'torchStatusChange', callback?: AsyncCallback\<TorchStatusInfo\>): void
1306
1307Unsubscribes from flashlight status change events. This API uses an asynchronous callback to return the result.
1308
1309**Atomic service API**: This API can be used in atomic services since API version 19.
1310
1311**System capability**: SystemCapability.Multimedia.Camera.Core
1312
1313**Parameters**
1314
1315| Name    | Type            | Mandatory| Description      |
1316| -------- | --------------- | ---- | --------- |
1317| type     | string          | Yes  | Event type. The value is fixed at **'torchStatusChange'**. The event can be listened for when a CameraManager instance is obtained.|
1318| 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.|
1319
1320**Example**
1321
1322```ts
1323function unregisterTorchStatusChange(cameraManager: camera.CameraManager): void {
1324  cameraManager.off('torchStatusChange');
1325}
1326```
1327
1328### getCameraDevice<sup>18+</sup>
1329
1330getCameraDevice(position:CameraPosition, type: CameraType): CameraDevice
1331
1332Obtains the specified camera based on the camera position and type.
1333
1334**Atomic service API**: This API can be used in atomic services since API version 19.
1335
1336**System capability**: SystemCapability.Multimedia.Camera.Core
1337
1338**Parameters**
1339
1340| Name    | Type            | Mandatory| Description      |
1341| -------- | --------------- | ---- | --------- |
1342| position | [CameraPosition](#cameraposition)   | Yes  | Camera position.|
1343| type     | [CameraType](#cameratype)   | Yes  | Camera type.|
1344
1345**Return value**
1346
1347| Type            | Description                    |
1348| -----------------| ------------------------ |
1349|  [CameraDevice](#cameradevice)     | Camera obtained.     |
1350
1351**Error codes**
1352
1353For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Camera Error Codes](errorcode-camera.md).
1354
1355| ID        | Error Message       |
1356| --------------- | --------------- |
1357| 7400201 | Camera service fatal error. |
1358
1359**Example**
1360
1361```ts
1362import { camera } from '@kit.CameraKit';
1363
1364function getCameraDevice(cameraManager: camera.CameraManager, position: camera.CameraPosition, type: camera.CameraType): void {
1365  try {
1366    let curCameraDev: camera.CameraDevice | undefined = undefined;
1367    curCameraDev = cameraManager.getCameraDevice(position, type);
1368  } catch (error) {
1369    // If the operation fails, an error code is returned and processed.
1370    let err = error as BusinessError;
1371    console.error(`The getCameraDevice call failed. error code: ${err.code}`);
1372  }
1373}
1374```
1375
1376### getCameraConcurrentInfos<sup>18+</sup>
1377
1378getCameraConcurrentInfos(cameras: Array\<CameraDevice\>): Array\<CameraConcurrentInfo\>
1379
1380Obtains the concurrency information of the specified cameras. If the return value is an empty array, concurrency is not supported.
1381
1382**Atomic service API**: This API can be used in atomic services since API version 19.
1383
1384**System capability**: SystemCapability.Multimedia.Camera.Core
1385
1386**Parameters**
1387
1388| Name    | Type            | Mandatory| Description      |
1389| -------- | --------------- | ---- | --------- |
1390| cameras | Array\<[CameraDevice](#cameradevice)\>  | Yes  | Array of CameraDevice objects. You are advised to use the front and rear cameras obtained by calling [getCameraDevice](#getcameradevice18).|
1391
1392**Return value**
1393
1394| Type            | Description                    |
1395| -----------------| ------------------------ |
1396|  Array\<[CameraConcurrentInfo](#cameraconcurrentinfo18)\>    |  Array of concurrency information corresponding to the provided CameraDevice objects, with a one-to-one mapping.     |
1397
1398**Error codes**
1399
1400For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Camera Error Codes](errorcode-camera.md).
1401
1402| ID        | Error Message       |
1403| --------------- | --------------- |
1404| 7400201 | Camera service fatal error. |
1405
1406**Example**
1407
1408```ts
1409import { camera } from '@kit.CameraKit';
1410
1411function getCameraConcurrentInfos(cameraManager: camera.CameraManager, cameraDeviceArray: Array<camera.CameraDevice>): void {
1412  try {
1413    let cameraconcurrentinfos: Array<camera.CameraConcurrentInfo> = [];
1414    cameraconcurrentinfos = cameraManager.getCameraConcurrentInfos(cameraDeviceArray);
1415  } catch (error) {
1416    // If the operation fails, an error code is returned and processed.
1417    let err = error as BusinessError;
1418    console.error(`The getCameraConcurrentInfos call failed. error code: ${err.code}`);
1419  }
1420}
1421```
1422
1423## TorchMode<sup>11+</sup>
1424
1425Enumerates the flashlight modes.
1426
1427**Atomic service API**: This API can be used in atomic services since API version 19.
1428
1429**System capability**: SystemCapability.Multimedia.Camera.Core
1430
1431| Name                         | Value  | Description          |
1432| ---------------------------- | ---- | ------------- |
1433| OFF    | 0    | The flashlight is off.     |
1434| ON  | 1    | The flashlight is on.|
1435| AUTO      | 2    | The system automatically adjusts the flashlight brightness according to the environment.|
1436
1437## TorchStatusInfo<sup>11+</sup>
1438
1439Describes the flashlight status information.
1440
1441**Atomic service API**: This API can be used in atomic services since API version 19.
1442
1443**System capability**: SystemCapability.Multimedia.Camera.Core
1444
1445| Name             | Type      | Read-only| Optional| Description       |
1446| ---------------- | ---------- | ---- | ---- | ----------- |
1447| isTorchAvailable | boolean    | Yes  | No  | Whether the flashlight is available. **true** if available, **false** otherwise.|
1448| isTorchActive    | boolean    | Yes  | No  | Whether the flashlight is activated. **true** if activated, **false** otherwise.|
1449| torchLevel       | number     | Yes  | No  | Flashlight brightness level. The value range is [0, 1]. A larger value indicates a greater luminance. |
1450
1451## Size
1452
1453Describes the output capability.
1454
1455**Atomic service API**: This API can be used in atomic services since API version 19.
1456
1457**System capability**: SystemCapability.Multimedia.Camera.Core
1458
1459| Name  | Type   | Read-only| Optional | Description        |
1460| ------ | ------ | ---- |-----| ------------ |
1461| height | number | No  | No  | Image height, in pixels.|
1462| width  | number | No  | No  | Image width, in pixels.|
1463
1464## Point
1465
1466Describes the point coordinates, which are used for focus and exposure configuration.
1467
1468**Atomic service API**: This API can be used in atomic services since API version 19.
1469
1470**System capability**: SystemCapability.Multimedia.Camera.Core
1471
1472| Name   | Type  | Read-only  | Optional  | Description        |
1473| ------ | ------ | ------ | ------ | ------------ |
1474| x      | number | No    | No    | X coordinate of a point.  |
1475| y      | number | No    | No    | Y coordinate of a point.  |
1476
1477## CameraFormat
1478
1479Enumerates the camera output formats.
1480
1481**Atomic service API**: This API can be used in atomic services since API version 19.
1482
1483**System capability**: SystemCapability.Multimedia.Camera.Core
1484
1485| Name                    | Value       | Description        |
1486| ----------------------- | --------- | ------------ |
1487| CAMERA_FORMAT_RGBA_8888 | 3         | RGBA_8888 image.       |
1488| CAMERA_FORMAT_YUV_420_SP| 1003      | YUV_420_SP image.     |
1489| CAMERA_FORMAT_JPEG      | 2000      | JPEG image.           |
1490| CAMERA_FORMAT_YCBCR_P010<sup>11+</sup> |   2001    | YCBCR_P010 image.     |
1491| CAMERA_FORMAT_YCRCB_P010<sup>11+</sup> |   2002    | YCRCB_P010 image.     |
1492| CAMERA_FORMAT_HEIC<sup>13+</sup>       |   2003    | HEIF image.           |
1493
1494## VideoCodecType<sup>13+</sup>
1495
1496Enumerates the video codec types.
1497
1498**Atomic service API**: This API can be used in atomic services since API version 19.
1499
1500**System capability**: SystemCapability.Multimedia.Camera.Core
1501
1502| Name  | Value   | Description         |
1503|------|------|-------------|
1504| AVC  | 0    | AVC.|
1505| HEVC | 1 | HEVC.|
1506
1507## CameraConcurrentType<sup>18+</sup>
1508
1509Enumerates the camera concurrency types.
1510
1511**Atomic service API**: This API can be used in atomic services since API version 19.
1512
1513**System capability**: SystemCapability.Multimedia.Camera.Core
1514
1515| Name  | Value   | Description         |
1516|------|------|-------------|
1517| CAMERA_LIMITED_CAPABILITY  | 0 | Limited camera concurrency. |
1518| CAMERA_FULL_CAPABILITY     | 1 | Full camera concurrency.|
1519
1520## CameraConcurrentInfo<sup>18+</sup>
1521
1522Describes the camera's concurrency information.
1523
1524**Atomic service API**: This API can be used in atomic services since API version 19.
1525
1526**System capability**: SystemCapability.Multimedia.Camera.Core
1527
1528| Name  | Type   | Read-only| Optional | Description        |
1529| ------ | ------ | ---- |-----| ------------ |
1530| device              | [CameraDevice](#cameradevice)   | Yes  | No  | Concurrent camera device.|
1531| type                | [CameraConcurrentType](#cameraconcurrenttype18)  | Yes  | No  | Concurrency type.|
1532| modes               | Array\<[SceneMode](#scenemode11) \>              | Yes  | No  | Scene mode.|
1533| outputCapabilities  | Array\<[CameraOutputCapability](#cameraoutputcapability) \> | Yes  | No  | Output capabilities of the camera.|
1534
1535## CameraInput
1536
1537Defines the camera input object.
1538
1539It provides camera device information used in [Session](#session11).
1540
1541### open
1542
1543open(callback: AsyncCallback\<void\>): void
1544
1545Opens this camera device. This API uses an asynchronous callback to return the result.
1546
1547**Atomic service API**: This API can be used in atomic services since API version 19.
1548
1549**System capability**: SystemCapability.Multimedia.Camera.Core
1550
1551**Parameters**
1552
1553| Name    | Type                 | Mandatory| Description                 |
1554| -------- | -------------------- | ---- | ------------------- |
1555| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
1556
1557**Error codes**
1558
1559For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
1560
1561| ID        | Error Message       |
1562| --------------- | --------------- |
1563| 7400107                |  Can not use camera cause of conflict.               |
1564| 7400108                |  Camera disabled cause of security reason.                                  |
1565| 7400201                |  Camera service fatal error.                                  |
1566
1567**Example**
1568
1569```ts
1570import { BusinessError } from '@kit.BasicServicesKit';
1571
1572function openCameraInput(cameraInput: camera.CameraInput): void {
1573  cameraInput.open((err: BusinessError) => {
1574    if (err) {
1575      console.error(`Failed to open the camera, error code: ${err.code}.`);
1576      return;
1577    }
1578    console.info('Callback returned with camera opened.');
1579  });
1580}
1581```
1582
1583### open
1584
1585open(): Promise\<void\>
1586
1587Opens this camera device. This API uses a promise to return the result.
1588
1589**Atomic service API**: This API can be used in atomic services since API version 19.
1590
1591**System capability**: SystemCapability.Multimedia.Camera.Core
1592
1593**Return value**
1594
1595| Type          | Description                     |
1596| -------------- | ----------------------- |
1597| Promise\<void\> | Promise that returns no value.|
1598
1599**Error codes**
1600
1601For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
1602
1603| ID  | Error Message                                     |
1604|---------|-------------------------------------------|
1605| 7400102 | Operation not allowed.                    |
1606| 7400107 | Can not use camera cause of conflict.     |
1607| 7400108 | Camera disabled cause of security reason. |
1608| 7400201 | Camera service fatal error.               |
1609
1610**Example**
1611
1612```ts
1613import { BusinessError } from '@kit.BasicServicesKit';
1614
1615function openCameraInput(cameraInput: camera.CameraInput): void {
1616  cameraInput.open().then(() => {
1617    console.info('Promise returned with camera opened.');
1618  }).catch((error: BusinessError) => {
1619    console.error(`Failed to open the camera, error code: ${error.code}.`);
1620  });
1621}
1622```
1623
1624### open<sup>12+</sup>
1625
1626open(isSecureEnabled: boolean): Promise\<bigint\>
1627
1628Opens this camera device and obtains the handle to the camera in secure mode.
1629
1630**Atomic service API**: This API can be used in atomic services since API version 19.
1631
1632**System capability**: SystemCapability.Multimedia.Camera.Core
1633
1634**Parameters**
1635
1636| Name    | Type                 | Mandatory| Description                                                                     |
1637| -------- | -------------------- | ---- |-------------------------------------------------------------------------|
1638| isSecureEnabled | boolean | Yes  | Whether to open the camera device in secure mode. **true** to open in secure mode, **false** otherwise. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
1639
1640**Return value**
1641
1642| Type          | Description                     |
1643| -------------- | ----------------------- |
1644| Promise\<bigint\> | Promise used to return the handle to the camera.|
1645
1646**Error codes**
1647
1648For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
1649
1650| ID        | Error Message       |
1651| --------------- | --------------- |
1652| 7400107                |  Can not use camera cause of conflict.               |
1653| 7400108                |  Camera disabled cause of security reason.                                  |
1654| 7400201                |  Camera service fatal error.                                  |
1655
1656**Example**
1657
1658```ts
1659import { BusinessError } from '@kit.BasicServicesKit';
1660
1661function openCameraInput(cameraInput: camera.CameraInput): void {
1662  cameraInput.open(true).then(() => {
1663    console.info('Promise returned with camera opened.');
1664  }).catch((error: BusinessError) => {
1665    console.error(`Failed to open the camera, error code: ${error.code}.`);
1666  });
1667}
1668```
1669
1670### open<sup>18+</sup>
1671
1672open(type: CameraConcurrentType): Promise\<void\>
1673
1674Opens the camera with the specified concurrency type.
1675
1676**Atomic service API**: This API can be used in atomic services since API version 19.
1677
1678**System capability**: SystemCapability.Multimedia.Camera.Core
1679
1680**Parameters**
1681
1682| Name    | Type                 | Mandatory| Description                                                                     |
1683| -------- | -------------------- | ---- |-------------------------------------------------------------------------|
1684| type | [CameraConcurrentType](#cameraconcurrenttype18) | Yes  | Concurrency type. If the API fails to be called, an error code is returned.|
1685
1686**Return value**
1687
1688| Type          | Description                     |
1689| -------------- | ----------------------- |
1690| Promise\<void\> | Promise that returns no value.|
1691
1692**Error codes**
1693
1694For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
1695
1696| ID  | Error Message                                     |
1697|---------|-------------------------------------------|
1698| 7400102 | Operation not allowed.                    |
1699| 7400107 | Can not use camera cause of conflict.     |
1700| 7400108 | Camera disabled cause of security reason. |
1701| 7400201 | Camera service fatal error.               |
1702
1703**Example**
1704
1705```ts
1706import { BusinessError } from '@kit.BasicServicesKit';
1707
1708function openCameraInput(cameraInput: camera.CameraInput): void {
1709  cameraInput.open(0).then(() => {
1710    console.info('Promise returned with camera opened.');
1711  }).catch((error: BusinessError) => {
1712    console.error(`Failed to open the camera, error code: ${error.code}.`);
1713  });
1714}
1715```
1716
1717### close
1718
1719close(callback: AsyncCallback\<void\>\): void
1720
1721Closes this camera device. This API uses an asynchronous callback to return the result.
1722
1723**Atomic service API**: This API can be used in atomic services since API version 19.
1724
1725**System capability**: SystemCapability.Multimedia.Camera.Core
1726
1727**Parameters**
1728
1729| Name    | Type                  | Mandatory| Description                 |
1730| -------- | -------------------- | ---- | -------------------- |
1731| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
1732
1733**Error codes**
1734
1735For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
1736
1737| ID        | Error Message       |
1738| --------------- | --------------- |
1739| 7400201                |  Camera service fatal error.                                  |
1740
1741**Example**
1742
1743```ts
1744import { BusinessError } from '@kit.BasicServicesKit';
1745
1746function closeCameraInput(cameraInput: camera.CameraInput): void {
1747  cameraInput.close((err: BusinessError) => {
1748    if (err) {
1749      console.error(`Failed to close the cameras, error code: ${err.code}.`);
1750      return;
1751    }
1752    console.info('Callback returned with camera closed.');
1753  });
1754}
1755```
1756
1757### close
1758
1759close(): Promise\<void\>
1760
1761Closes this camera device. This API uses a promise to return the result.
1762
1763**Atomic service API**: This API can be used in atomic services since API version 19.
1764
1765**System capability**: SystemCapability.Multimedia.Camera.Core
1766
1767**Return value**
1768
1769| Type          | Description                     |
1770| -------------- | ----------------------- |
1771| Promise\<void\> | Promise that returns no value.|
1772
1773**Error codes**
1774
1775For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
1776
1777| ID        | Error Message       |
1778| --------------- | --------------- |
1779| 7400201                |  Camera service fatal error.                                  |
1780
1781**Example**
1782
1783```ts
1784import { BusinessError } from '@kit.BasicServicesKit';
1785
1786function closeCameraInput(cameraInput: camera.CameraInput): void {
1787  cameraInput.close().then(() => {
1788    console.info('Promise returned with camera closed.');
1789  }).catch((error: BusinessError) => {
1790    console.error(`Failed to close the cameras, error code: ${error.code}.`);
1791  });
1792}
1793```
1794
1795### on('error')
1796
1797on(type: 'error', camera: CameraDevice, callback: ErrorCallback): void
1798
1799Subscribes to CameraInput error events. This API uses an asynchronous callback to return the result.
1800
1801> **NOTE**
1802>
1803> Currently, you cannot use **off()** to unregister the callback in the callback method of **on()**.
1804
1805**Atomic service API**: This API can be used in atomic services since API version 19.
1806
1807**System capability**: SystemCapability.Multimedia.Camera.Core
1808
1809**Parameters**
1810
1811| Name    | Type                             | Mandatory| Description                                         |
1812| -------- | -------------------------------- | --- | ------------------------------------------- |
1813| 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.|
1814| camera   | [CameraDevice](#cameradevice)    | Yes  | Camera device.|
1815| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback) | Yes  | Callback used to return an error code defined in [CameraErrorCode](#cameraerrorcode). |
1816
1817**Example**
1818
1819```ts
1820import { BusinessError } from '@kit.BasicServicesKit';
1821
1822function callback(err: BusinessError): void {
1823  console.error(`Camera input error code: ${err.code}`);
1824}
1825
1826function registerCameraInputError(cameraInput: camera.CameraInput, camera: camera.CameraDevice): void {
1827  cameraInput.on('error', camera, callback);
1828}
1829```
1830
1831### off('error')
1832
1833off(type: 'error', camera: CameraDevice, callback?: ErrorCallback): void
1834
1835Unsubscribes from CameraInput error events.
1836
1837**Atomic service API**: This API can be used in atomic services since API version 19.
1838
1839**System capability**: SystemCapability.Multimedia.Camera.Core
1840
1841**Parameters**
1842
1843| Name    | Type                             | Mandatory| Description                                         |
1844| -------- | -------------------------------- | --- | ------------------------------------------- |
1845| 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.|
1846| camera   | [CameraDevice](#cameradevice)    | Yes  | Camera device.|
1847| 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.|
1848
1849**Example**
1850
1851```ts
1852function unregisterCameraInputError(cameraInput: camera.CameraInput, camera: camera.CameraDevice): void {
1853  cameraInput.off('error', camera);
1854}
1855```
1856
1857## CameraOutput
1858
1859Implements output information used in [Session](#session11). It is the base class of **output**.
1860
1861### release
1862
1863release(callback: AsyncCallback\<void\>): void
1864
1865Releases output resources. This API uses an asynchronous callback to return the result.
1866
1867**Atomic service API**: This API can be used in atomic services since API version 19.
1868
1869**System capability**: SystemCapability.Multimedia.Camera.Core
1870
1871**Parameters**
1872
1873| Name     | Type                 | Mandatory| Description                |
1874| -------- | -------------------- | ---- | ------------------- |
1875| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
1876
1877**Error codes**
1878
1879For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
1880
1881| ID        | Error Message       |
1882| --------------- | --------------- |
1883| 7400201                |  Camera service fatal error.                           |
1884
1885**Example**
1886
1887```ts
1888import { BusinessError } from '@kit.BasicServicesKit';
1889
1890function releasePreviewOutput(previewOutput: camera.PreviewOutput): void {
1891  previewOutput.release((err: BusinessError) => {
1892    if (err) {
1893      console.error(`Failed to release the Preview output instance ${err.code}`);
1894      return;
1895    }
1896    console.info('Callback invoked to indicate that the preview output instance is released successfully.');
1897  });
1898}
1899
1900function releaseVideoOutput(videoOutput: camera.VideoOutput): void {
1901  videoOutput.release((err: BusinessError) => {
1902    if (err) {
1903      console.error(`Failed to release the video output instance ${err.code}`);
1904      return;
1905    }
1906    console.info('Callback invoked to indicate that the video output instance is released successfully.');
1907  });
1908}
1909```
1910
1911### release
1912
1913release(): Promise\<void\>
1914
1915Releases output resources. This API uses a promise to return the result.
1916
1917**Atomic service API**: This API can be used in atomic services since API version 19.
1918
1919**System capability**: SystemCapability.Multimedia.Camera.Core
1920
1921**Return value**
1922
1923| Type           | Description                    |
1924| -------------- | ----------------------- |
1925| Promise\<void\> | Promise that returns no value.|
1926
1927**Error codes**
1928
1929For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
1930
1931| ID        | Error Message       |
1932| --------------- | --------------- |
1933| 7400201                |  Camera service fatal error.                           |
1934
1935**Example**
1936
1937```ts
1938import { BusinessError } from '@kit.BasicServicesKit';
1939
1940function releasePreviewOutput(previewOutput: camera.PreviewOutput): void {
1941  previewOutput.release().then(() => {
1942    console.info('Promise returned to indicate that the preview output instance is released successfully.');
1943  }).catch((error: BusinessError) => {
1944    console.error(`Failed to preview output release, error code: ${error.code}`);
1945  });
1946}
1947
1948function releaseVideoOutput(videoOutput: camera.VideoOutput): void {
1949  videoOutput.release().then(() => {
1950    console.info('Promise returned to indicate that the video output instance is released successfully.');
1951  }).catch((error: BusinessError) => {
1952    console.error(`Failed to video output release, error code: ${error.code}`);
1953  });
1954}
1955```
1956
1957## PreviewOutput
1958
1959Implements preview output. It inherits from [CameraOutput](#cameraoutput).
1960
1961### start<sup>(deprecated)</sup>
1962
1963start(callback: AsyncCallback\<void\>): void
1964
1965Starts to output preview streams. This API uses an asynchronous callback to return the result.
1966
1967> **NOTE**
1968>
1969> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Session.start](#start11) instead.
1970
1971**System capability**: SystemCapability.Multimedia.Camera.Core
1972
1973**Parameters**
1974
1975| Name     | Type                 | Mandatory| Description                |
1976| -------- | -------------------- | ---- | -------------------- |
1977| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
1978
1979**Error codes**
1980
1981For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
1982
1983| ID        | Error Message       |
1984| --------------- | --------------- |
1985| 7400103                |  Session not config.                                   |
1986
1987**Example**
1988
1989```ts
1990import { BusinessError } from '@kit.BasicServicesKit';
1991
1992function startPreviewOutput(previewOutput: camera.PreviewOutput): void {
1993  previewOutput.start((err: BusinessError) => {
1994    if (err) {
1995      console.error(`Failed to start the preview output, error code: ${err.code}.`);
1996      return;
1997    }
1998    console.info('Callback returned with preview output started.');
1999  });
2000}
2001```
2002
2003### start<sup>(deprecated)</sup>
2004
2005start(): Promise\<void\>
2006
2007Starts to output preview streams. This API uses a promise to return the result.
2008
2009> **NOTE**
2010>
2011> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Session.start](#start11-1) instead.
2012
2013**System capability**: SystemCapability.Multimedia.Camera.Core
2014
2015**Return value**
2016
2017| Type           | Description               |
2018| -------------- |-------------------|
2019| Promise\<void\> | Promise that returns no value. |
2020
2021**Error codes**
2022
2023For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
2024
2025| ID        | Error Message       |
2026| --------------- | --------------- |
2027| 7400103                |  Session not config.                                   |
2028
2029**Example**
2030
2031```ts
2032import { BusinessError } from '@kit.BasicServicesKit';
2033
2034function startPreviewOutput(previewOutput: camera.PreviewOutput): void {
2035  previewOutput.start().then(() => {
2036    console.info('Promise returned with preview output started.');
2037  }).catch((error: BusinessError) => {
2038    console.error(`Failed to preview output start, error code: ${error.code}.`);
2039  });
2040}
2041```
2042
2043### stop<sup>(deprecated)</sup>
2044
2045stop(callback: AsyncCallback\<void\>): void
2046
2047Stops outputting preview streams. This API uses an asynchronous callback to return the result.
2048
2049> **NOTE**
2050>
2051> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Session.stop](#stop11) instead.
2052
2053**System capability**: SystemCapability.Multimedia.Camera.Core
2054
2055**Parameters**
2056
2057| Name     | Type                 | Mandatory| Description                |
2058| -------- | -------------------- | ---- | -------------------- |
2059| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
2060
2061**Example**
2062
2063```ts
2064import { BusinessError } from '@kit.BasicServicesKit';
2065
2066function stopPreviewOutput(previewOutput: camera.PreviewOutput): void {
2067  previewOutput.stop((err: BusinessError) => {
2068    if (err) {
2069      console.error(`Failed to stop the preview output, error code: ${err.code}.`);
2070      return;
2071    }
2072    console.info('Returned with preview output stopped.');
2073  })
2074}
2075```
2076
2077### stop<sup>(deprecated)</sup>
2078
2079stop(): Promise\<void\>
2080
2081Stops outputting preview streams. This API uses a promise to return the result.
2082
2083> **NOTE**
2084>
2085> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Session.stop](#stop11-1) instead.
2086
2087**System capability**: SystemCapability.Multimedia.Camera.Core
2088
2089**Return value**
2090
2091| Type           | Description                    |
2092| -------------- | ------------------------ |
2093| Promise\<void\> | Promise that returns no value.|
2094
2095**Example**
2096
2097```ts
2098import { BusinessError } from '@kit.BasicServicesKit';
2099
2100function stopPreviewOutput(previewOutput: camera.PreviewOutput): void {
2101  previewOutput.stop().then(() => {
2102    console.info('Callback returned with preview output stopped.');
2103  }).catch((error: BusinessError) => {
2104    console.error(`Failed to preview output stop, error code: ${error.code}.`);
2105  });
2106}
2107```
2108
2109### on('frameStart')
2110
2111on(type: 'frameStart', callback: AsyncCallback\<void\>): void
2112
2113Subscribes to preview frame start events. This API uses an asynchronous callback to return the result.
2114
2115> **NOTE**
2116>
2117> Currently, you cannot use **off()** to unregister the callback in the callback method of **on()**.
2118
2119**Atomic service API**: This API can be used in atomic services since API version 19.
2120
2121**System capability**: SystemCapability.Multimedia.Camera.Core
2122
2123**Parameters**
2124
2125| Name     | Type                 | Mandatory| Description                                    |
2126| -------- | -------------------- | ---- | --------------------------------------- |
2127| 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.|
2128| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result. The preview starts as long as this event is returned.                   |
2129
2130**Example**
2131
2132```ts
2133import { BusinessError } from '@kit.BasicServicesKit';
2134
2135function callback(err: BusinessError): void {
2136  if (err !== undefined && err.code !== 0) {
2137    console.error(`Callback Error, errorCode: ${err.code}`);
2138    return;
2139  }
2140  console.info('Preview frame started');
2141}
2142
2143function registerPreviewOutputFrameStart(previewOutput: camera.PreviewOutput): void {
2144  previewOutput.on('frameStart', callback);
2145}
2146```
2147
2148### off('frameStart')
2149
2150off(type: 'frameStart', callback?: AsyncCallback\<void\>): void
2151
2152Unsubscribes from preview frame start events.
2153
2154**Atomic service API**: This API can be used in atomic services since API version 19.
2155
2156**System capability**: SystemCapability.Multimedia.Camera.Core
2157
2158**Parameters**
2159
2160| Name     | Type                 | Mandatory| Description                                    |
2161| -------- | -------------------- | ---- | --------------------------------------- |
2162| type     | string               | Yes  | Event type. The value is fixed at **'frameStart'**. The event can be listened for when a previewOutput instance is created.|
2163| 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.|
2164
2165**Example**
2166
2167```ts
2168function unregisterPreviewOutputFrameStart(previewOutput: camera.PreviewOutput): void {
2169  previewOutput.off('frameStart');
2170}
2171```
2172
2173### on('frameEnd')
2174
2175on(type: 'frameEnd', callback: AsyncCallback\<void\>): void
2176
2177Subscribes to preview frame end events. This API uses an asynchronous callback to return the result.
2178
2179> **NOTE**
2180>
2181> Currently, you cannot use **off()** to unregister the callback in the callback method of **on()**.
2182
2183**Atomic service API**: This API can be used in atomic services since API version 19.
2184
2185**System capability**: SystemCapability.Multimedia.Camera.Core
2186
2187**Parameters**
2188
2189| Name     | Type                 | Mandatory| Description                                 |
2190| -------- | -------------------- | ---- | ------------------------------------- |
2191| 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.|
2192| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result. The preview ends as long as this event is returned.               |
2193
2194**Example**
2195
2196```ts
2197import { BusinessError } from '@kit.BasicServicesKit';
2198
2199function callback(err: BusinessError): void {
2200  if (err !== undefined && err.code !== 0) {
2201    console.error(`Callback Error, errorCode: ${err.code}`);
2202    return;
2203  }
2204  console.info('Preview frame ended');
2205}
2206
2207function registerPreviewOutputFrameEnd(previewOutput: camera.PreviewOutput): void {
2208  previewOutput.on('frameEnd', callback);
2209}
2210```
2211
2212### off('frameEnd')
2213
2214off(type: 'frameEnd', callback?: AsyncCallback\<void\>): void
2215
2216Unsubscribes from preview frame end events.
2217
2218**Atomic service API**: This API can be used in atomic services since API version 19.
2219
2220**System capability**: SystemCapability.Multimedia.Camera.Core
2221
2222**Parameters**
2223
2224| Name     | Type                 | Mandatory| Description                                 |
2225| -------- | -------------------- | ---- | ------------------------------------- |
2226| type     | string               | Yes  | Event type. The value is fixed at **'frameEnd'**. The event can be listened for when a previewOutput instance is created.|
2227| 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.|
2228
2229**Example**
2230
2231```ts
2232function unregisterPreviewOutputFrameEnd(previewOutput: camera.PreviewOutput): void {
2233  previewOutput.off('frameEnd');
2234}
2235```
2236
2237### on('error')
2238
2239on(type: 'error', callback: ErrorCallback): void
2240
2241Subscribes to PreviewOutput error events. This API uses an asynchronous callback to return the result.
2242
2243> **NOTE**
2244>
2245> Currently, you cannot use **off()** to unregister the callback in the callback method of **on()**.
2246
2247**Atomic service API**: This API can be used in atomic services since API version 19.
2248
2249**System capability**: SystemCapability.Multimedia.Camera.Core
2250
2251**Parameters**
2252
2253| Name    | Type        | Mandatory| Description                      |
2254| -------- | --------------| ---- | ------------------------ |
2255| 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).|
2256| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback) | Yes  | Callback used to return an error code defined in [CameraErrorCode](#cameraerrorcode). |
2257
2258**Example**
2259
2260```ts
2261import { BusinessError } from '@kit.BasicServicesKit';
2262
2263function callback(previewOutputError: BusinessError): void {
2264  console.error(`Preview output error code: ${previewOutputError.code}`);
2265}
2266
2267function registerPreviewOutputError(previewOutput: camera.PreviewOutput): void {
2268  previewOutput.on('error', callback)
2269}
2270```
2271
2272### off('error')
2273
2274off(type: 'error', callback?: ErrorCallback): void
2275
2276Unsubscribes from PreviewOutput error events.
2277
2278**Atomic service API**: This API can be used in atomic services since API version 19.
2279
2280**System capability**: SystemCapability.Multimedia.Camera.Core
2281
2282**Parameters**
2283
2284| Name    | Type        | Mandatory| Description                      |
2285| -------- | --------------| ---- | ------------------------ |
2286| type     | string        | Yes  | Event type. The value is fixed at **'error'**. The event can be listened for when a previewOutput instance is created.|
2287| 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.|
2288
2289**Example**
2290
2291```ts
2292function unregisterPreviewOutputError(previewOutput: camera.PreviewOutput): void {
2293  previewOutput.off('error');
2294}
2295```
2296
2297### getSupportedFrameRates<sup>12+</sup>
2298
2299 getSupportedFrameRates(): Array\<FrameRateRange\>
2300
2301Obtains the supported frame rates.
2302
2303**Atomic service API**: This API can be used in atomic services since API version 19.
2304
2305**System capability**: SystemCapability.Multimedia.Camera.Core
2306
2307**Return value**
2308|      Type     |     Description    |
2309| -------------  | ------------ |
2310| Array<[FrameRateRange](#frameraterange)> | Array of supported frame rates.|
2311
2312**Example**
2313
2314```ts
2315function getSupportedFrameRates(previewOutput: camera.PreviewOutput): Array<camera.FrameRateRange> {
2316  let supportedFrameRatesArray: Array<camera.FrameRateRange> = previewOutput.getSupportedFrameRates();
2317  return supportedFrameRatesArray;
2318}
2319```
2320
2321### setFrameRate<sup>12+</sup>
2322
2323setFrameRate(minFps: number, maxFps: number): void
2324
2325Sets 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).
2326
2327> **NOTE**
2328>
2329> This API is valid only in [PhotoSession](#photosession11) or [VideoSession](#videosession11) mode.
2330
2331**Atomic service API**: This API can be used in atomic services since API version 19.
2332
2333**System capability**: SystemCapability.Multimedia.Camera.Core
2334
2335**Parameters**
2336
2337| Name    | Type        | Mandatory| Description                      |
2338| -------- | --------------| ---- | ------------------------ |
2339| minFps   | number        | Yes  | Minimum frame rate, in fps.|
2340| maxFps   | number        | Yes  | Maximum frame rate, in fps. When the minimum value is greater than the maximum value, the API does not take effect.|
2341
2342**Error codes**
2343
2344For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
2345
2346| ID       | Error Message       |
2347| --------------- | --------------- |
2348| 7400101                |  Parameter missing or parameter type incorrect.        |
2349| 7400110                |  Unresolved conflicts with current configurations.     |
2350
2351**Example**
2352
2353```ts
2354function setFrameRateRange(previewOutput: camera.PreviewOutput, frameRateRange: Array<number>): void {
2355  previewOutput.setFrameRate(frameRateRange[0], frameRateRange[1]);
2356}
2357```
2358
2359### getActiveFrameRate<sup>12+</sup>
2360
2361getActiveFrameRate(): FrameRateRange
2362
2363Obtains the configured frame rate range.
2364
2365This API is valid only after [setFrameRate](#setframerate12) is called to set a frame rate range for preview streams.
2366
2367**Atomic service API**: This API can be used in atomic services since API version 19.
2368
2369**System capability**: SystemCapability.Multimedia.Camera.Core
2370
2371**Return value**
2372
2373|      Type     |     Description    |
2374| -------------  | ------------ |
2375| [FrameRateRange](#frameraterange) | Frame rate range.|
2376
2377**Example**
2378
2379```ts
2380function getActiveFrameRate(previewOutput: camera.PreviewOutput): camera.FrameRateRange {
2381  let activeFrameRate: camera.FrameRateRange = previewOutput.getActiveFrameRate();
2382  return activeFrameRate;
2383}
2384```
2385
2386### getActiveProfile<sup>12+</sup>
2387
2388getActiveProfile(): Profile
2389
2390Obtains the profile that takes effect currently.
2391
2392**Atomic service API**: This API can be used in atomic services since API version 19.
2393
2394**System capability**: SystemCapability.Multimedia.Camera.Core
2395
2396**Return value**
2397
2398|      Type     | Description       |
2399| -------------  |-----------|
2400| [Profile](#profile) | Profile obtained.|
2401
2402**Error codes**
2403
2404For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
2405
2406| ID  | Error Message                        |
2407|---------|------------------------------|
2408| 7400201 | Camera service fatal error.  |
2409
2410**Example**
2411
2412```ts
2413function testGetActiveProfile(previewOutput: camera.PreviewOutput): camera.Profile | undefined {
2414  let activeProfile: camera.Profile | undefined = undefined;
2415  try {
2416    activeProfile = previewOutput.getActiveProfile();
2417  } catch (error) {
2418    // If the operation fails, error.code is returned and processed.
2419    let err = error as BusinessError;
2420    console.error(`The previewOutput.getActiveProfile call failed. error code: ${err.code}`);
2421  }
2422  return activeProfile;
2423}
2424```
2425
2426### getPreviewRotation<sup>12+</sup>
2427
2428getPreviewRotation(displayRotation: number): ImageRotation
2429
2430Obtains the preview rotation degree.
2431
2432- Device' natural orientation: The default orientation of the device (phone) is in portrait mode, with the charging port facing downward.
2433- 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.
2434- 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.
2435
2436**Atomic service API**: This API can be used in atomic services since API version 19.
2437
2438**System capability**: SystemCapability.Multimedia.Camera.Core
2439
2440**Parameters**
2441
2442| Name    | Type        | Mandatory| Description                      |
2443| -------- | --------------| ---- | ------------------------ |
2444| displayRotation | number  | Yes  | Screen rotation angle of the display. It is obtained by calling [display.getDefaultDisplaySync](../apis-arkui/js-apis-display.md#displaygetdefaultdisplaysync9).|
2445
2446**Return value**
2447
2448|      Type     | Description       |
2449| -------------  |-----------|
2450| [ImageRotation](#imagerotation) | Preview rotation degree.|
2451
2452**Error codes**
2453
2454For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
2455
2456| ID  | Error Message                        |
2457|---------|------------------------------|
2458| 7400101 | Parameter missing or parameter type incorrect.  |
2459| 7400201 | Camera service fatal error.  |
2460
2461**Example**
2462
2463```ts
2464function testGetPreviewRotation(previewOutput: camera.PreviewOutput, imageRotation : camera.ImageRotation): camera.ImageRotation {
2465  let previewRotation: camera.ImageRotation = camera.ImageRotation.ROTATION_0;
2466  try {
2467    previewRotation = previewOutput.getPreviewRotation(imageRotation);
2468    console.log(`Preview rotation is: ${previewRotation}`);
2469  } catch (error) {
2470    // If the operation fails, error.code is returned and processed.
2471    let err = error as BusinessError;
2472    console.error(`The previewOutput.getPreviewRotation call failed. error code: ${err.code}`);
2473  }
2474  return previewRotation;
2475}
2476```
2477### setPreviewRotation<sup>12+</sup>
2478
2479setPreviewRotation(previewRotation: ImageRotation, isDisplayLocked?: boolean): void
2480
2481Sets the preview rotation degree.
2482
2483**Atomic service API**: This API can be used in atomic services since API version 19.
2484
2485**System capability**: SystemCapability.Multimedia.Camera.Core
2486
2487**Parameters**
2488
2489| Name    | Type        | Mandatory| Description                      |
2490| -------- | --------------| ---- | ------------------------ |
2491| previewRotation | [ImageRotation](#imagerotation)  | Yes  | Preview rotation angle.|
2492| isDisplayLocked | boolean  | No  | Whether the display is locked.|
2493
2494**Error codes**
2495
2496For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
2497
2498| ID  | Error Message                        |
2499|---------|------------------------------|
2500| 7400101 | Parameter missing or parameter type incorrect.  |
2501| 7400201 | Camera service fatal error.  |
2502
2503**Example**
2504
2505```ts
2506function testSetPreviewRotation(previewOutput: camera.PreviewOutput, previewRotation : camera.ImageRotation, isDisplayLocked: boolean): void {
2507  try {
2508    previewOutput.setPreviewRotation(previewRotation, isDisplayLocked);
2509  } catch (error) {
2510    // If the operation fails, error.code is returned and processed.
2511    let err = error as BusinessError;
2512    console.error(`The previewOutput.setPreviewRotation call failed. error code: ${err.code}`);
2513  }
2514  return;
2515}
2516```
2517## ImageRotation
2518
2519Enumerates the image rotation angles.
2520
2521**Atomic service API**: This API can be used in atomic services since API version 19.
2522
2523**System capability**: SystemCapability.Multimedia.Camera.Core
2524
2525| Name         | Value  | Description          |
2526| ------------ | ---- | ------------- |
2527| ROTATION_0   | 0    | The image rotates 0 degrees.  |
2528| ROTATION_90  | 90   | The image rotates 90 degrees. |
2529| ROTATION_180 | 180  | The image rotates 180 degrees.|
2530| ROTATION_270 | 270  | The image rotates 270 degrees.|
2531
2532## Location
2533
2534Describes the geolocation information.
2535
2536**Atomic service API**: This API can be used in atomic services since API version 19.
2537
2538**System capability**: SystemCapability.Multimedia.Camera.Core
2539
2540| Name         | Type  | Read-only| Optional |Description        |
2541| ------------ | ------ | ---- |-----|------------ |
2542| latitude     | number |  No | No  |Latitude, in degrees.   |
2543| longitude    | number |  No | No  |Longitude, in degrees.   |
2544| altitude     | number |  No | No  |Altitude, in meters.   |
2545
2546## QualityLevel
2547
2548Enumerates the image quality levels.
2549
2550**Atomic service API**: This API can be used in atomic services since API version 19.
2551
2552**System capability**: SystemCapability.Multimedia.Camera.Core
2553
2554| Name                 | Value  | Description        |
2555| -------------------- | ---- | ------------ |
2556| QUALITY_LEVEL_HIGH   | 0    | High image quality.  |
2557| QUALITY_LEVEL_MEDIUM | 1    | Medium image quality.|
2558| QUALITY_LEVEL_LOW    | 2    | Low image quality.  |
2559
2560
2561## PhotoCaptureSetting
2562
2563Describes the settings for taking an image.
2564
2565**Atomic service API**: This API can be used in atomic services since API version 19.
2566
2567**System capability**: SystemCapability.Multimedia.Camera.Core
2568
2569| Name     | Type                           | Read-only| Optional| Description                                                                  |
2570| -------- | ------------------------------- | ---- | ---- |----------------------------------------------------------------------|
2571| quality  | [QualityLevel](#qualitylevel)   | No  | Yes  | Image quality (low by default).                                                          |
2572| rotation | [ImageRotation](#imagerotation) | No  | Yes  | Rotation angle of the image. The default value is **0**, indicating clockwise rotation.                                                 |
2573| location | [Location](#location)           | No  | Yes  | Geolocation information of the image (depending on the device hardware information by default).                                              |
2574| 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.|
2575
2576## Photo<sup>11+</sup>
2577
2578Defines a full-quality image object.
2579
2580### Properties
2581
2582**Atomic service API**: This API can be used in atomic services since API version 19.
2583
2584**System capability**: SystemCapability.Multimedia.Camera.Core
2585
2586| Name  | Type                           |     Mandatory    | Description      |
2587| ------ | ----------------------------- | -------------- | ---------- |
2588| main<sup>11+</sup> | [image.Image](../apis-image-kit/arkts-apis-image-Image.md) |        Yes      | Full-quality image.|
2589
2590### release<sup>11+</sup>
2591
2592release(): Promise\<void\>
2593
2594Releases output resources. This API uses a promise to return the result.
2595
2596**Atomic service API**: This API can be used in atomic services since API version 19.
2597
2598**System capability**: SystemCapability.Multimedia.Camera.Core
2599
2600**Return value**
2601
2602| Type           | Description                    |
2603| -------------- | ----------------------- |
2604| Promise\<void\> | Promise that returns no value.|
2605
2606**Example**
2607
2608```ts
2609async function releasePhoto(photo: camera.Photo): Promise<void> {
2610  await photo.release();
2611}
2612```
2613
2614## PhotoOutput
2615
2616Implements output information used in a photo session. It inherits from [CameraOutput](#cameraoutput).
2617
2618### capture
2619
2620capture(callback: AsyncCallback\<void\>): void
2621
2622Captures a photo with the default photo capture parameters. This API uses an asynchronous callback to return the result.
2623
2624**Atomic service API**: This API can be used in atomic services since API version 19.
2625
2626**System capability**: SystemCapability.Multimedia.Camera.Core
2627
2628**Parameters**
2629
2630| Name     | Type                 | Mandatory| Description                |
2631| -------- | -------------------- | ---- | ------------------- |
2632| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
2633
2634**Error codes**
2635
2636For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
2637
2638| ID        | Error Message       |
2639| --------------- | --------------- |
2640| 7400104                |  Session not running.                                  |
2641| 7400201                |  Camera service fatal error.                           |
2642
2643**Example**
2644
2645```ts
2646import { BusinessError } from '@kit.BasicServicesKit';
2647
2648function capture(photoOutput: camera.PhotoOutput): void {
2649  photoOutput.capture((err: BusinessError) => {
2650    if (err) {
2651      console.error(`Failed to capture the photo, error code: ${err.code}.`);
2652      return;
2653    }
2654    console.info('Callback invoked to indicate the photo capture request success.');
2655  });
2656}
2657```
2658
2659### capture
2660
2661capture(): Promise\<void\>
2662
2663Captures a photo with the default photo capture parameters. This API uses a promise to return the result.
2664
2665**Atomic service API**: This API can be used in atomic services since API version 19.
2666
2667**System capability**: SystemCapability.Multimedia.Camera.Core
2668
2669**Return value**
2670
2671| Type           | Description                    |
2672| -------------- | ------------------------ |
2673| Promise\<void\> | Promise that returns no value.|
2674
2675**Error codes**
2676
2677For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
2678
2679| ID        | Error Message       |
2680| --------------- | --------------- |
2681| 7400104                |  Session not running.                                  |
2682| 7400201                |  Camera service fatal error.                           |
2683
2684**Example**
2685
2686```ts
2687import { BusinessError } from '@kit.BasicServicesKit';
2688
2689function capture(photoOutput: camera.PhotoOutput): void {
2690  photoOutput.capture().then(() => {
2691    console.info('Promise returned to indicate that photo capture request success.');
2692  }).catch((error: BusinessError) => {
2693    console.error(`Failed to photo output capture, error code: ${error.code}.`);
2694  });
2695}
2696```
2697
2698### capture
2699
2700capture(setting: PhotoCaptureSetting, callback: AsyncCallback\<void\>): void
2701
2702Captures a photo with the specified photo capture parameters. This API uses an asynchronous callback to return the result.
2703
2704**Atomic service API**: This API can be used in atomic services since API version 19.
2705
2706**System capability**: SystemCapability.Multimedia.Camera.Core
2707
2708**Parameters**
2709
2710| Name     | Type                                        | Mandatory| Description                 |
2711| -------- | ------------------------------------------- | ---- | -------------------- |
2712| setting  | [PhotoCaptureSetting](#photocapturesetting) | Yes  | Photo capture settings.            |
2713| callback | AsyncCallback\<void\>                        | Yes  | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned. |
2714
2715**Error codes**
2716
2717For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
2718
2719| ID        | Error Message       |
2720| --------------- | --------------- |
2721| 7400101                |  Parameter missing or parameter type incorrect.        |
2722| 7400104                |  Session not running.                                  |
2723| 7400201                |  Camera service fatal error.                           |
2724
2725**Example**
2726
2727```ts
2728import { BusinessError } from '@kit.BasicServicesKit';
2729
2730function capture(photoOutput: camera.PhotoOutput): void {
2731  let captureLocation: camera.Location = {
2732    latitude: 0,
2733    longitude: 0,
2734    altitude: 0
2735  }
2736  let settings: camera.PhotoCaptureSetting = {
2737    quality: camera.QualityLevel.QUALITY_LEVEL_LOW,
2738    rotation: camera.ImageRotation.ROTATION_0,
2739    location: captureLocation,
2740    mirror: false
2741  }
2742  photoOutput.capture(settings, (err: BusinessError) => {
2743    if (err) {
2744      console.error(`Failed to capture the photo, error code: ${err.code}.`);
2745      return;
2746    }
2747    console.info('Callback invoked to indicate the photo capture request success.');
2748  });
2749}
2750```
2751
2752### capture
2753
2754capture(setting: PhotoCaptureSetting): Promise\<void\>
2755
2756Captures a photo with the specified photo capture parameters. This API uses a promise to return the result.
2757
2758**Atomic service API**: This API can be used in atomic services since API version 19.
2759
2760**System capability**: SystemCapability.Multimedia.Camera.Core
2761
2762**Parameters**
2763
2764| Name    | Type                                        | Mandatory| Description     |
2765| ------- | ------------------------------------------- | ---- | -------- |
2766| setting | [PhotoCaptureSetting](#photocapturesetting) | Yes  | Photo capture parameters. The input of **undefined** is processed as if no parameters were passed.|
2767
2768**Return value**
2769
2770| Type           | Description                    |
2771| -------------- | ------------------------ |
2772| Promise\<void\> | Promise that returns no value.|
2773
2774**Error codes**
2775
2776For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
2777
2778| ID        | Error Message       |
2779| --------------- | --------------- |
2780| 7400101                |  Parameter missing or parameter type incorrect.        |
2781| 7400104                |  Session not running.                                  |
2782| 7400201                |  Camera service fatal error.                           |
2783
2784**Example**
2785
2786```ts
2787import { BusinessError } from '@kit.BasicServicesKit';
2788
2789function capture(photoOutput: camera.PhotoOutput): void {
2790  let captureLocation: camera.Location = {
2791    latitude: 0,
2792    longitude: 0,
2793    altitude: 0
2794  }
2795  let settings: camera.PhotoCaptureSetting = {
2796    quality: camera.QualityLevel.QUALITY_LEVEL_LOW,
2797    rotation: camera.ImageRotation.ROTATION_0,
2798    location: captureLocation,
2799    mirror: false
2800  }
2801  photoOutput.capture(settings).then(() => {
2802    console.info('Promise returned to indicate that photo capture request success.');
2803  }).catch((error: BusinessError) => {
2804    console.error(`Failed to photo output capture, error code: ${error.code}.`);
2805  });
2806}
2807```
2808
2809### on('photoAvailable')<sup>11+</sup>
2810
2811on(type: 'photoAvailable', callback: AsyncCallback\<Photo\>): void
2812
2813Subscribes to events indicating available high-resolution images. This API uses an asynchronous callback to return the result.
2814
2815> **NOTE**
2816>
2817> Currently, you cannot use **off()** to unregister the callback in the callback method of **on()**.
2818
2819**Atomic service API**: This API can be used in atomic services since API version 19.
2820
2821**System capability**: SystemCapability.Multimedia.Camera.Core
2822
2823**Parameters**
2824
2825| Name    | Type     | Mandatory| Description                                 |
2826| -------- | ---------- | --- | ------------------------------------ |
2827| type     | string     | Yes  | Event type. The value is fixed at **'photoAvailable'**. The event can be listened for when a photoOutput instance is created.|
2828| callback | AsyncCallback\<[Photo](#photo11)\> | Yes  | Callback used to return the high-resolution image.|
2829
2830**Example**
2831
2832```ts
2833import { BusinessError } from '@kit.BasicServicesKit';
2834import { image } from '@kit.ImageKit';
2835
2836function callback(err: BusinessError, photo: camera.Photo): void {
2837  if (err !== undefined && err.code !== 0) {
2838    console.error(`Callback Error, errorCode: ${err.code}`);
2839    return;
2840  }
2841  let mainImage: image.Image = photo.main;
2842}
2843
2844function registerPhotoOutputPhotoAvailable(photoOutput: camera.PhotoOutput): void {
2845  photoOutput.on('photoAvailable', callback);
2846}
2847```
2848
2849### off('photoAvailable')<sup>11+</sup>
2850
2851off(type: 'photoAvailable', callback?: AsyncCallback\<Photo\>): void
2852
2853Unsubscribes from events indicating available high-resolution images.
2854
2855**Atomic service API**: This API can be used in atomic services since API version 19.
2856
2857**System capability**: SystemCapability.Multimedia.Camera.Core
2858
2859**Parameters**
2860
2861| Name     | Type                   | Mandatory| Description                                      |
2862| -------- | ---------------------- | ---- | ------------------------------------------ |
2863| type     | string                 | Yes  | Event type. The value is fixed at **'photoAvailable'**. The event can be listened for when a photoOutput instance is created.|
2864| 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.|
2865
2866**Example**
2867
2868```ts
2869import { BusinessError } from '@kit.BasicServicesKit';
2870import { image } from '@kit.ImageKit';
2871
2872function callback(err: BusinessError, photo: camera.Photo): void {
2873  if (err !== undefined && err.code !== 0) {
2874    console.error(`Callback Error, errorCode: ${err.code}`);
2875    return;
2876  }
2877  let mainImage: image.Image = photo.main;
2878}
2879
2880function unRegisterPhotoOutputPhotoAvailable(photoOutput: camera.PhotoOutput): void {
2881  photoOutput.off('photoAvailable', callback);
2882}
2883```
2884
2885### on('captureStartWithInfo')<sup>11+</sup>
2886
2887on(type: 'captureStartWithInfo', callback: AsyncCallback\<CaptureStartInfo\>): void
2888
2889Subscribes to capture start events. This API uses an asynchronous callback to return the result.
2890
2891> **NOTE**
2892>
2893> Currently, you cannot use **off()** to unregister the callback in the callback method of **on()**.
2894
2895**Atomic service API**: This API can be used in atomic services since API version 19.
2896
2897**System capability**: SystemCapability.Multimedia.Camera.Core
2898
2899**Parameters**
2900
2901| Name    | Type     | Mandatory| Description                                 |
2902| -------- | ---------- | --- | ------------------------------------ |
2903| type     | string     | Yes  | Event type. The value is fixed at **'captureStartWithInfo'**. The event can be listened for when a photoOutput instance is created.|
2904| callback | AsyncCallback\<[CaptureStartInfo](#capturestartinfo11)\> | Yes  | Callback used to return the capture ID.|
2905
2906**Example**
2907
2908```ts
2909import { BusinessError } from '@kit.BasicServicesKit';
2910
2911function callback(err: BusinessError, captureStartInfo: camera.CaptureStartInfo): void {
2912  if (err !== undefined && err.code !== 0) {
2913    console.error(`Callback Error, errorCode: ${err.code}`);
2914    return;
2915  }
2916  console.info(`photo capture started, captureStartInfo : ${captureStartInfo}`);
2917}
2918
2919function registerCaptureStartWithInfo(photoOutput: camera.PhotoOutput): void {
2920  photoOutput.on('captureStartWithInfo', callback);
2921}
2922```
2923
2924### off('captureStartWithInfo')<sup>11+</sup>
2925
2926off(type: 'captureStartWithInfo', callback?: AsyncCallback\<CaptureStartInfo\>): void
2927
2928Unsubscribes from capture start events.
2929
2930**Atomic service API**: This API can be used in atomic services since API version 19.
2931
2932**System capability**: SystemCapability.Multimedia.Camera.Core
2933
2934**Parameters**
2935
2936| Name     | Type                   | Mandatory| Description                                      |
2937| -------- | ---------------------- | ---- | ------------------------------------------ |
2938| type     | string                 | Yes  | Event type. The value is fixed at **'captureStartWithInfo'**. The event can be listened for when a photoOutput instance is created.|
2939| 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.|
2940
2941**Example**
2942
2943```ts
2944import { BusinessError } from '@kit.BasicServicesKit';
2945
2946function unRegisterCaptureStartWithInfo(photoOutput: camera.PhotoOutput): void {
2947  photoOutput.off('captureStartWithInfo');
2948}
2949```
2950
2951### isMovingPhotoSupported<sup>12+</sup>
2952
2953isMovingPhotoSupported(): boolean
2954
2955Checks whether taking moving photos is supported.
2956
2957**Atomic service API**: This API can be used in atomic services since API version 19.
2958
2959**System capability**: SystemCapability.Multimedia.Camera.Core
2960
2961**Return value**
2962
2963| Type           | Description                    |
2964| -------------- | ----------------------- |
2965| boolean | Check result for the support of taking moving photos. **true** if supported, **false** otherwise.|
2966
2967**Error codes**
2968
2969For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
2970
2971| ID      | Error Message      |
2972| -------------- | --------------- |
2973| 7400201 |  Camera service fatal error. |
2974
2975**Example**
2976
2977```ts
2978import { BusinessError } from '@kit.BasicServicesKit';
2979
2980function isMovingPhotoSupported(photoOutput: camera.PhotoOutput): boolean {
2981  let isSupported: boolean = false;
2982  try {
2983    isSupported = photoOutput.isMovingPhotoSupported();
2984  } catch (error) {
2985    // If the operation fails, error.code is returned and processed.
2986    let err = error as BusinessError;
2987    console.error(`The isMovingPhotoSupported call failed. error code: ${err.code}`);
2988  }
2989  return isSupported;
2990}
2991```
2992
2993### enableMovingPhoto<sup>12+</sup>
2994
2995enableMovingPhoto(enabled: boolean): void
2996
2997Enables or disables the feature of taking moving photos.
2998
2999**Required permissions:** ohos.permission.MICROPHONE
3000
3001**Atomic service API**: This API can be used in atomic services since API version 19.
3002
3003**System capability**: SystemCapability.Multimedia.Camera.Core
3004
3005**Parameters**
3006
3007| Name     | Type                   | Mandatory| Description                                      |
3008| -------- | ---------------------- | ---- | ------------------------------------------ |
3009| enabled  | boolean                | Yes  | Whether to enable the feature of taking moving photos. **true** to enable, **false** otherwise.    |
3010
3011**Error codes**
3012
3013For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
3014
3015| ID   | Error Message                                          |
3016| -------- |------------------------------------------------|
3017| 201      | permission denied.                             |
3018| 7400101  | Parameter missing or parameter type incorrect. |
3019| 7400201  | Camera service fatal error.                    |
3020
3021**Example**
3022
3023```ts
3024import { BusinessError } from '@kit.BasicServicesKit';
3025
3026function enableMovingPhoto(photoOutput: camera.PhotoOutput): void {
3027  try {
3028    photoOutput.enableMovingPhoto(true);
3029  } catch (error) {
3030    // If the operation fails, error.code is returned and processed.
3031    let err = error as BusinessError;
3032    console.error(`The enableMovingPhoto call failed. error code: ${err.code}`);
3033  }
3034}
3035```
3036
3037### on('photoAssetAvailable')<sup>12+</sup>
3038
3039on(type: 'photoAssetAvailable', callback: AsyncCallback\<photoAccessHelper.PhotoAsset\>): void
3040
3041Subscribes to photo asset available events. This API uses an asynchronous callback to return the result.
3042
3043> **NOTE**
3044>
3045> Currently, you cannot use **off()** to unregister the callback in the callback method of **on()**.
3046
3047**Atomic service API**: This API can be used in atomic services since API version 19.
3048
3049**System capability**: SystemCapability.Multimedia.Camera.Core
3050
3051**Parameters**
3052
3053| Name    | Type     | Mandatory| Description                                 |
3054| -------- | ---------- | --- | ------------------------------------ |
3055| type     | string     | Yes  | Event type. The value is fixed at **'photoAssetAvailable'**. The event can be listened for when a photoOutput instance is created.|
3056| callback | AsyncCallback\<[photoAccessHelper.PhotoAsset](../apis-media-library-kit/js-apis-photoAccessHelper.md#photoasset)\> | Yes  | Callback used to return the photo asset.|
3057
3058**Example**
3059
3060```ts
3061import { BusinessError } from '@kit.BasicServicesKit';
3062import { photoAccessHelper } from '@kit.MediaLibraryKit';
3063
3064function photoAssetAvailableCallback(err: BusinessError, photoAsset: photoAccessHelper.PhotoAsset): void {
3065  if (err) {
3066    console.info(`photoAssetAvailable error: ${JSON.stringify(err)}.`);
3067    return;
3068  }
3069  console.info('photoOutPutCallBack photoAssetAvailable');
3070  // You can use photoAsset to obtain image information.
3071}
3072
3073function onPhotoOutputPhotoAssetAvailable(photoOutput: camera.PhotoOutput): void {
3074  photoOutput.on('photoAssetAvailable', photoAssetAvailableCallback);
3075}
3076```
3077
3078### off('photoAssetAvailable')<sup>12+</sup>
3079
3080off(type: 'photoAssetAvailable', callback?: AsyncCallback\<photoAccessHelper.PhotoAsset\>): void
3081
3082Unsubscribes from photo asset available events.
3083
3084**Atomic service API**: This API can be used in atomic services since API version 19.
3085
3086**System capability**: SystemCapability.Multimedia.Camera.Core
3087
3088**Parameters**
3089
3090| Name    | Type     | Mandatory | Description                                                                        |
3091| -------- | ---------- |-----|----------------------------------------------------------------------------|
3092| type     | string     | Yes  | Event type. The value is fixed at **'photoAssetAvailable'**. The event can be listened for when a photoOutput instance is created.                        |
3093| 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.|
3094
3095**Example**
3096
3097```ts
3098function offPhotoOutputPhotoAssetAvailable(photoOutput: camera.PhotoOutput): void {
3099  photoOutput.off('photoAssetAvailable');
3100}
3101```
3102
3103### isMirrorSupported
3104
3105isMirrorSupported(): boolean
3106
3107Checks whether mirror photography is supported.
3108
3109**Atomic service API**: This API can be used in atomic services since API version 19.
3110
3111**System capability**: SystemCapability.Multimedia.Camera.Core
3112
3113**Return value**
3114
3115| Type           | Description                    |
3116| -------------- | ----------------------- |
3117| boolean | Check result for the support of mirror photography. **true** if supported, **false** otherwise.|
3118
3119**Example**
3120
3121```ts
3122function isMirrorSupported(photoOutput: camera.PhotoOutput): boolean {
3123  let isSupported: boolean = photoOutput.isMirrorSupported();
3124  return isSupported;
3125}
3126```
3127
3128### enableMirror<sup>13+</sup>
3129
3130enableMirror(enabled: boolean): void
3131
3132Enables dynamic photo capture.
3133
3134Before calling this API, check whether dynamic photo capture is supported by calling [isMovingPhotoSupported](#ismovingphotosupported12) and whether mirroring is supported by calling [isMirrorSupported](#ismirrorsupported).
3135
3136**Atomic service API**: This API can be used in atomic services since API version 19.
3137
3138**System capability**: SystemCapability.Multimedia.Camera.Core
3139
3140**Parameters**
3141
3142| Name     | Type                   | Mandatory| Description                       |
3143|----------| ---------------------- | ---- |---------------------------|
3144| enabled | boolean                | Yes  | Whether to enable or disable dynamic photo capture. **true** to enable, **false** otherwise.|
3145
3146**Error codes**
3147
3148For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
3149
3150| ID   | Error Message                                          |
3151| -------- |------------------------------------------------|
3152| 7400101  | Parameter missing or parameter type incorrect. |
3153| 7400103  | Session not config.                    |
3154| 7400201  | Camera service fatal error.            |
3155
3156
3157**Example**
3158
3159```ts
3160import { BusinessError } from '@kit.BasicServicesKit';
3161
3162function enableMirror(photoOutput: camera.PhotoOutput): void {
3163  try {
3164    photoOutput.enableMirror(true);
3165  } catch (error) {
3166    // If the operation fails, error.code is returned and processed.
3167    let err = error as BusinessError;
3168    console.error(`The enableMirror call failed. error code: ${err.code}`);
3169  }
3170}
3171```
3172
3173### getSupportedMovingPhotoVideoCodecTypes<sup>13+</sup>
3174
3175getSupportedMovingPhotoVideoCodecTypes(): Array\<VideoCodecType\>
3176
3177Obtains the supported video codec types of moving photos.
3178
3179**Atomic service API**: This API can be used in atomic services since API version 19.
3180
3181**System capability**: SystemCapability.Multimedia.Camera.Core
3182
3183**Return value**
3184
3185| Type           | Description               |
3186| -------------- |-------------------|
3187| Array\<[VideoCodecType](#videocodectype13)\> | Array holding the supported video codec types.|
3188
3189**Error codes**
3190
3191For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
3192
3193| ID       | Error Message                     |
3194| --------------- | ---------------               |
3195| 7400201         |  Camera service fatal error.  |
3196
3197**Example**
3198
3199```ts
3200function getSupportedMovingPhotoVideoCodecType(photoOutput: camera.PhotoOutput): Array<camera.VideoCodecType> {
3201  let supportedVideoCodecTypesArray: Array<camera.VideoCodecType> = photoOutput.getSupportedMovingPhotoVideoCodecTypes();
3202  return supportedVideoCodecTypesArray;
3203}
3204```
3205
3206### setMovingPhotoVideoCodecType<sup>13+</sup>
3207
3208setMovingPhotoVideoCodecType(codecType: VideoCodecType): void
3209
3210Sets a video codec type for moving photos.
3211
3212**Atomic service API**: This API can be used in atomic services since API version 19.
3213
3214**System capability**: SystemCapability.Multimedia.Camera.Core
3215
3216**Parameters**
3217
3218| Name       | Type                                 | Mandatory|  Description               |
3219| ------------- |-------------------------------------|-------| ------------        |
3220| codecType     | [VideoCodecType](#videocodectype13) |  Yes   |Video codec type. |
3221
3222**Error codes**
3223
3224For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
3225
3226| ID       | Error Message                     |
3227| --------------- | ---------------               |
3228| 7400201         |  Camera service fatal error.  |
3229
3230**Example**
3231
3232```ts
3233function setMovingPhotoVideoCodecTypes(photoOutput: camera.PhotoOutput, videoCodecType: camera.VideoCodecType): void {
3234   photoOutput.setMovingPhotoVideoCodecType(videoCodecType);
3235}
3236```
3237
3238### on('captureStart')<sup>(deprecated)</sup>
3239
3240on(type: 'captureStart', callback: AsyncCallback\<number\>): void
3241
3242Subscribes to capture start events. This API uses an asynchronous callback to return the result.
3243
3244> **NOTE**
3245> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [on('captureStartWithInfo')](#oncapturestartwithinfo11) instead.
3246>
3247> Currently, you cannot use **off()** to unregister the callback in the callback method of **on()**.
3248
3249**System capability**: SystemCapability.Multimedia.Camera.Core
3250
3251**Parameters**
3252
3253| Name     | Type                   | Mandatory| Description                                      |
3254| -------- | ---------------------- | ---- | ------------------------------------------ |
3255| 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.|
3256| callback | AsyncCallback\<number\> | Yes  | Callback used to return the capture ID.           |
3257
3258**Example**
3259
3260```ts
3261import { BusinessError } from '@kit.BasicServicesKit';
3262
3263function callback(err: BusinessError, captureId: number): void {
3264  if (err !== undefined && err.code !== 0) {
3265    console.error(`Callback Error, errorCode: ${err.code}`);
3266    return;
3267  }
3268  console.info(`photo capture started, captureId : ${captureId}`);
3269}
3270
3271function registerPhotoOutputCaptureStart(photoOutput: camera.PhotoOutput): void {
3272  photoOutput.on('captureStart', callback);
3273}
3274```
3275
3276### off('captureStart')<sup>(deprecated)</sup>
3277
3278off(type: 'captureStart', callback?: AsyncCallback\<number\>): void
3279
3280Unsubscribes from capture start events.
3281
3282> **NOTE**
3283> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [off('captureStartWithInfo')](#offcapturestartwithinfo11) instead.
3284>
3285> Currently, you cannot use **off()** to unregister the callback in the callback method of **on()**.
3286
3287**System capability**: SystemCapability.Multimedia.Camera.Core
3288
3289**Parameters**
3290
3291| Name     | Type                   | Mandatory| Description                                      |
3292| -------- | ---------------------- | ---- | ------------------------------------------ |
3293| type     | string                 | Yes  | Event type. The value is fixed at **'captureStart'**. The event can be listened for when a photoOutput instance is created.|
3294| 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.|
3295
3296**Example**
3297
3298```ts
3299function unregisterPhotoOutputCaptureStart(photoOutput: camera.PhotoOutput): void {
3300  photoOutput.off('captureStart');
3301}
3302```
3303
3304### on('frameShutter')
3305
3306on(type: 'frameShutter', callback: AsyncCallback\<FrameShutterInfo\>): void
3307
3308Subscribes to frame shutter events. This API uses an asynchronous callback to return the result.
3309
3310**Atomic service API**: This API can be used in atomic services since API version 19.
3311
3312**System capability**: SystemCapability.Multimedia.Camera.Core
3313
3314**Parameters**
3315
3316| Name    | Type     | Mandatory| Description                                 |
3317| -------- | ---------- | --- | ------------------------------------ |
3318| type     | string     | Yes  | Event type. The value is fixed at **'frameShutter'**. The event can be listened for when a photoOutput instance is created.|
3319| 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.            |
3320
3321**Example**
3322
3323```ts
3324import { BusinessError } from '@kit.BasicServicesKit';
3325
3326function callback(err: BusinessError, frameShutterInfo: camera.FrameShutterInfo): void {
3327  if (err !== undefined && err.code !== 0) {
3328    console.error(`Callback Error, errorCode: ${err.code}`);
3329    return;
3330  }
3331  console.info(`CaptureId for frame : ${frameShutterInfo.captureId}`);
3332  console.info(`Timestamp for frame : ${frameShutterInfo.timestamp}`);
3333}
3334
3335function registerPhotoOutputFrameShutter(photoOutput: camera.PhotoOutput): void {
3336  photoOutput.on('frameShutter', callback);
3337}
3338```
3339
3340### off('frameShutter')
3341
3342off(type: 'frameShutter', callback?: AsyncCallback\<FrameShutterInfo\>): void
3343
3344Unsubscribes from frame shutter events.
3345
3346**Atomic service API**: This API can be used in atomic services since API version 19.
3347
3348**System capability**: SystemCapability.Multimedia.Camera.Core
3349
3350**Parameters**
3351
3352| Name    | Type     | Mandatory| Description                                 |
3353| -------- | ---------- | --- | ------------------------------------ |
3354| type     | string     | Yes  | Event type. The value is fixed at **'frameShutter'**. The event can be listened for when a photoOutput instance is created.|
3355| 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.|
3356
3357**Example**
3358
3359```ts
3360function unregisterPhotoOutputFrameShutter(photoOutput: camera.PhotoOutput): void {
3361  photoOutput.off('frameShutter');
3362}
3363```
3364
3365### on('captureEnd')
3366
3367on(type: 'captureEnd', callback: AsyncCallback\<CaptureEndInfo\>): void
3368
3369Subscribes to capture end events. This API uses an asynchronous callback to return the result.
3370
3371> **NOTE**
3372>
3373> Currently, you cannot use **off()** to unregister the callback in the callback method of **on()**.
3374
3375**Atomic service API**: This API can be used in atomic services since API version 19.
3376
3377**System capability**: SystemCapability.Multimedia.Camera.Core
3378
3379**Parameters**
3380
3381| Name    | Type          | Mandatory| Description                                      |
3382| -------- | --------------- | ---- | ---------------------------------------- |
3383| 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.|
3384| callback | AsyncCallback\<[CaptureEndInfo](#captureendinfo)\> | Yes  | Callback used to return the result.                 |
3385
3386**Example**
3387
3388```ts
3389import { BusinessError } from '@kit.BasicServicesKit';
3390
3391function callback(err: BusinessError, captureEndInfo: camera.CaptureEndInfo): void {
3392  if (err !== undefined && err.code !== 0) {
3393    console.error(`Callback Error, errorCode: ${err.code}`);
3394    return;
3395  }
3396  console.info(`photo capture end, captureId : ${captureEndInfo.captureId}`);
3397  console.info(`frameCount : ${captureEndInfo.frameCount}`);
3398}
3399
3400function registerPhotoOutputCaptureEnd(photoOutput: camera.PhotoOutput): void {
3401  photoOutput.on('captureEnd', callback);
3402}
3403```
3404
3405### off('captureEnd')
3406
3407off(type: 'captureEnd', callback?: AsyncCallback\<CaptureEndInfo\>): void
3408
3409Unsubscribes from capture end events.
3410
3411**Atomic service API**: This API can be used in atomic services since API version 19.
3412
3413**System capability**: SystemCapability.Multimedia.Camera.Core
3414
3415**Parameters**
3416
3417| Name    | Type          | Mandatory| Description                                      |
3418| -------- | --------------- | ---- | ---------------------------------------- |
3419| type     | string          | Yes  | Event type. The value is fixed at **'captureEnd'**. The event can be listened for when a photoOutput instance is created.|
3420| 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.|
3421
3422**Example**
3423
3424```ts
3425function unregisterPhotoOutputCaptureEnd(photoOutput: camera.PhotoOutput): void {
3426  photoOutput.off('captureEnd');
3427}
3428```
3429
3430### on('frameShutterEnd')<sup>12+</sup>
3431
3432on(type: 'frameShutterEnd', callback: AsyncCallback\<FrameShutterEndInfo\>): void
3433
3434Subscribes to frame shutter end events. This API uses an asynchronous callback to return the result.
3435
3436> **NOTE**
3437>
3438> Currently, you cannot use **off()** to unregister the callback in the callback method of **on()**.
3439
3440**Atomic service API**: This API can be used in atomic services since API version 19.
3441
3442**System capability**: SystemCapability.Multimedia.Camera.Core
3443
3444**Parameters**
3445
3446| Name  | Type                                                        | Mandatory| Description                                                        |
3447| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
3448| type     | string                                                       | Yes  | Event type. The value is fixed at **'frameShutterEnd'**. The event can be listened for when a photoOutput instance is created.|
3449| callback | AsyncCallback\<[FrameShutterEndInfo](#frameshutterendinfo12)\> | Yes  | Callback used to return the result. It is invoked when the frame shutter ends.  |
3450
3451**Example**
3452
3453```ts
3454import { BusinessError } from '@kit.BasicServicesKit';
3455
3456function callback(err: BusinessError, frameShutterEndInfo: camera.FrameShutterEndInfo): void {
3457  if (err !== undefined && err.code !== 0) {
3458    console.error(`Callback Error, errorCode: ${err.code}`);
3459    return;
3460  }
3461  console.info(`CaptureId for frame : ${frameShutterEndInfo.captureId}`);
3462}
3463
3464function registerPhotoOutputFrameShutterEnd(photoOutput: camera.PhotoOutput): void {
3465  photoOutput.on('frameShutterEnd', callback);
3466}
3467```
3468
3469### off('frameShutterEnd')<sup>12+</sup>
3470
3471off(type: 'frameShutterEnd', callback?: AsyncCallback\<FrameShutterEndInfo\>): void
3472
3473Unsubscribes from frame shutter end events.
3474
3475**Atomic service API**: This API can be used in atomic services since API version 19.
3476
3477**System capability**: SystemCapability.Multimedia.Camera.Core
3478
3479**Parameters**
3480
3481| Name  | Type                                                        | Mandatory| Description                                                        |
3482| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
3483| type     | string                                                       | Yes  | Event type. The value is fixed at **'frameShutterEnd'**. The event can be listened for when a photoOutput instance is created.|
3484| 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.|
3485
3486**Example**
3487
3488```ts
3489function unregisterPhotoOutputFrameShutterEnd(photoOutput: camera.PhotoOutput): void {
3490  photoOutput.off('frameShutterEnd');
3491}
3492```
3493
3494### on('captureReady')<sup>12+</sup>
3495
3496on(type: 'captureReady', callback: AsyncCallback\<void\>): void
3497
3498Subscribes to capture ready events. This API uses an asynchronous callback to return the result.
3499
3500> **NOTE**
3501>
3502> Currently, you cannot use **off()** to unregister the callback in the callback method of **on()**.
3503
3504**Atomic service API**: This API can be used in atomic services since API version 19.
3505
3506**System capability**: SystemCapability.Multimedia.Camera.Core
3507
3508**Parameters**
3509
3510| Name  | Type                 | Mandatory| Description                                                        |
3511| -------- | --------------------- | ---- | ------------------------------------------------------------ |
3512| 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.|
3513| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.                                |
3514
3515**Example**
3516
3517```ts
3518import { BusinessError } from '@kit.BasicServicesKit';
3519
3520function callback(err: BusinessError): void {
3521  if (err !== undefined && err.code !== 0) {
3522    console.error(`Callback Error, errorCode: ${err.code}`);
3523    return;
3524  }
3525  console.info(`photo capture ready`);
3526}
3527
3528function registerPhotoOutputCaptureReady(photoOutput: camera.PhotoOutput): void {
3529  photoOutput.on('captureReady', callback);
3530}
3531```
3532
3533### off('captureReady')<sup>12+</sup>
3534
3535off(type: 'captureReady', callback?: AsyncCallback\<void\>): void
3536
3537Unsubscribes from capture ready events.
3538
3539**Atomic service API**: This API can be used in atomic services since API version 19.
3540
3541**System capability**: SystemCapability.Multimedia.Camera.Core
3542
3543**Parameters**
3544
3545| Name  | Type                                                | Mandatory| Description                                                        |
3546| -------- | ---------------------------------------------------- | ---- | ------------------------------------------------------------ |
3547| type     | string                                               | Yes  | Event type. The value is fixed at **'captureReady'**. The event can be listened for when a photoOutput instance is created.|
3548| 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.|
3549
3550**Example**
3551
3552```ts
3553function unregisterPhotoOutputCaptureReady(photoOutput: camera.PhotoOutput): void {
3554  photoOutput.off('captureReady');
3555}
3556```
3557
3558### on('estimatedCaptureDuration')<sup>12+</sup>
3559
3560on(type: 'estimatedCaptureDuration', callback: AsyncCallback\<number\>): void
3561
3562Subscribes to estimated capture duration events. This API uses an asynchronous callback to return the result.
3563
3564> **NOTE**
3565>
3566> Currently, you cannot use **off()** to unregister the callback in the callback method of **on()**.
3567
3568**Atomic service API**: This API can be used in atomic services since API version 19.
3569
3570**System capability**: SystemCapability.Multimedia.Camera.Core
3571
3572**Parameters**
3573
3574| Name  | Type                  | Mandatory| Description                                                        |
3575| -------- | ---------------------- | ---- | ------------------------------------------------------------ |
3576| 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.|
3577| 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.                                |
3578
3579**Example**
3580
3581```ts
3582import { BusinessError } from '@kit.BasicServicesKit';
3583
3584function callback(err: BusinessError, duration: number): void {
3585  if (err !== undefined && err.code !== 0) {
3586    console.error(`Callback Error, errorCode: ${err.code}`);
3587    return;
3588  }
3589  console.info(`photo estimated capture duration : ${duration}`);
3590}
3591
3592function registerPhotoOutputEstimatedCaptureDuration(photoOutput: camera.PhotoOutput): void {
3593  photoOutput.on('estimatedCaptureDuration', callback);
3594}
3595```
3596
3597### off('estimatedCaptureDuration')<sup>12+</sup>
3598
3599off(type: 'estimatedCaptureDuration', callback?: AsyncCallback\<number\>): void
3600
3601Unsubscribes from estimated capture duration events.
3602
3603**Atomic service API**: This API can be used in atomic services since API version 19.
3604
3605**System capability**: SystemCapability.Multimedia.Camera.Core
3606
3607**Parameters**
3608
3609| Name  | Type                   | Mandatory| Description                                                        |
3610| -------- | ----------------------- | ---- | ------------------------------------------------------------ |
3611| type     | string                  | Yes  | Event type. The value is fixed at **'estimatedCaptureDuration'**. The event can be listened for when a photoOutput instance is created.|
3612| 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.|
3613
3614**Example**
3615
3616```ts
3617function unregisterPhotoOutputEstimatedCaptureDuration(photoOutput: camera.PhotoOutput): void {
3618  photoOutput.off('estimatedCaptureDuration');
3619}
3620```
3621
3622### on('error')
3623
3624on(type: 'error', callback: ErrorCallback): void
3625
3626Subscribes to PhotoOutput error events. This API uses an asynchronous callback to return the result.
3627
3628> **NOTE**
3629>
3630> Currently, you cannot use **off()** to unregister the callback in the callback method of **on()**.
3631
3632**Atomic service API**: This API can be used in atomic services since API version 19.
3633
3634**System capability**: SystemCapability.Multimedia.Camera.Core
3635
3636**Parameters**
3637
3638| Name    | Type        | Mandatory| Description                                |
3639| -------- | ------------- | ---- | ----------------------------------- |
3640| 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.|
3641| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback) | Yes  | Callback used to return an error code defined in [CameraErrorCode](#cameraerrorcode).            |
3642
3643**Example**
3644
3645```ts
3646import { BusinessError } from '@kit.BasicServicesKit';
3647
3648function callback(err: BusinessError): void {
3649  console.error(`Photo output error code: ${err.code}`);
3650}
3651
3652function registerPhotoOutputError(photoOutput: camera.PhotoOutput): void {
3653  photoOutput.on('error', callback);
3654}
3655```
3656
3657### off('error')
3658
3659off(type: 'error', callback?: ErrorCallback): void
3660
3661Unsubscribes from PhotoOutput error events.
3662
3663**Atomic service API**: This API can be used in atomic services since API version 19.
3664
3665**System capability**: SystemCapability.Multimedia.Camera.Core
3666
3667**Parameters**
3668
3669| Name    | Type        | Mandatory| Description                                |
3670| -------- | ------------- | ---- | ----------------------------------- |
3671| type     | string       | Yes  | Event type. The value is fixed at **'error'**. The event can be listened for when a photoOutput instance is created.|
3672| 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.|
3673
3674**Example**
3675
3676```ts
3677function unregisterPhotoOutputError(photoOutput: camera.PhotoOutput): void {
3678  photoOutput.off('error');
3679}
3680```
3681
3682### getActiveProfile<sup>12+</sup>
3683
3684getActiveProfile(): Profile
3685
3686Obtains the profile that takes effect currently.
3687
3688**Atomic service API**: This API can be used in atomic services since API version 19.
3689
3690**System capability**: SystemCapability.Multimedia.Camera.Core
3691
3692**Return value**
3693
3694|      Type     | Description       |
3695| -------------  |-----------|
3696| [Profile](#profile) | Profile obtained.|
3697
3698**Error codes**
3699
3700For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
3701
3702| ID  | Error Message                        |
3703|---------|------------------------------|
3704| 7400201 | Camera service fatal error.  |
3705
3706**Example**
3707
3708```ts
3709function testGetActiveProfile(photoOutput: camera.PhotoOutput): camera.Profile | undefined {
3710  let activeProfile: camera.Profile | undefined = undefined;
3711  try {
3712    activeProfile = photoOutput.getActiveProfile();
3713  } catch (error) {
3714    // If the operation fails, error.code is returned and processed.
3715    let err = error as BusinessError;
3716    console.error(`The photoOutput.getActiveProfile call failed. error code: ${err.code}`);
3717  }
3718  return activeProfile;
3719}
3720```
3721### getPhotoRotation<sup>12+</sup>
3722
3723getPhotoRotation(deviceDegree: number): ImageRotation
3724
3725Obtains the photo rotation degree.
3726
3727- Device' natural orientation: The default orientation of the device (phone) is in portrait mode, with the charging port facing downward.
3728- 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.
3729- 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.
3730
3731**Atomic service API**: This API can be used in atomic services since API version 19.
3732
3733**System capability**: SystemCapability.Multimedia.Camera.Core
3734
3735**Parameters**
3736
3737| Name    | Type        | Mandatory| Description                      |
3738| -------- | --------------| ---- | ------------------------ |
3739| deviceDegree | number | Yes  | Rotation angle.|
3740
3741**Return value**
3742
3743|      Type     | Description       |
3744| -------------  |-----------|
3745| [ImageRotation](#imagerotation) | Photo rotation degree.|
3746
3747**Error codes**
3748
3749For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
3750
3751| ID  | Error Message                        |
3752|---------|------------------------------|
3753| 7400101 | Parameter missing or parameter type incorrect.  |
3754| 7400201 | Camera service fatal error.  |
3755
3756**Example**
3757
3758```ts
3759function testGetPhotoRotation(photoOutput: camera.PhotoOutput, deviceDegree : number): camera.ImageRotation {
3760  let photoRotation: camera.ImageRotation = camera.ImageRotation.ROTATION_0;
3761  try {
3762    photoRotation = photoOutput.getPhotoRotation(deviceDegree);
3763    console.log(`Photo rotation is: ${photoRotation}`);
3764  } catch (error) {
3765    // If the operation fails, error.code is returned and processed.
3766    let err = error as BusinessError;
3767    console.error(`The photoOutput.getPhotoRotation call failed. error code: ${err.code}`);
3768  }
3769  return photoRotation;
3770}
3771```
3772
3773## FrameShutterInfo
3774
3775Describes the frame shutter information.
3776
3777**Atomic service API**: This API can be used in atomic services since API version 19.
3778
3779**System capability**: SystemCapability.Multimedia.Camera.Core
3780
3781| Name      | Type  | Read-only| Optional| Description       |
3782| --------- | ------ | ---- | ---- | ---------- |
3783| captureId | number | No  | No  | ID of this capture action.|
3784| timestamp | number | No  | No  | Timestamp when the frame shutter event is triggered.|
3785
3786## FrameShutterEndInfo<sup>12+</sup>
3787
3788Describes the frame shutter end information during capture.
3789
3790**Atomic service API**: This API can be used in atomic services since API version 19.
3791
3792**System capability**: SystemCapability.Multimedia.Camera.Core
3793
3794| Name     | Type  | Read-only| Optional| Description      |
3795| --------- | ------ | ---- | ---- | ---------- |
3796| captureId | number | No  | No  | ID of this capture action.|
3797
3798## CaptureStartInfo<sup>11+</sup>
3799
3800Describes the capture start information.
3801
3802**Atomic service API**: This API can be used in atomic services since API version 19.
3803
3804**System capability**: SystemCapability.Multimedia.Camera.Core
3805
3806| Name      | Type   | Read-only| Optional| Description      |
3807| ---------- | ------ | ---- | ---- | --------- |
3808| captureId  | number | No  | No  | ID of this capture action.|
3809| 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.   |
3810
3811## CaptureEndInfo
3812
3813Describes the capture end information.
3814
3815**Atomic service API**: This API can be used in atomic services since API version 19.
3816
3817**System capability**: SystemCapability.Multimedia.Camera.Core
3818
3819| Name      | Type   | Read-only| Optional| Description      |
3820| ---------- | ------ | ---- | ---- | ---------|
3821| captureId  | number | No  | No  | ID of this capture action.|
3822| frameCount | number | No  | No  | Number of frames captured.|
3823
3824## AutoDeviceSwitchStatus<sup>13+</sup>
3825
3826Describes the information about the automatic camera switch status.
3827
3828**Atomic service API**: This API can be used in atomic services since API version 19.
3829
3830**System capability**: SystemCapability.Multimedia.Camera.Core
3831
3832| Name      | Type     | Read-only| Optional| Description                     |
3833| ---------- |---------| ---- | ---- |-------------------------|
3834| isDeviceSwitched  | boolean | No  | No  | Whether the camera is automatically switched. **true** if auto-switched, **false** otherwise.      |
3835| isDeviceCapabilityChanged | boolean  | No  | No  | Whether the camera capability is changed after the camera is automatically switched. **true** if changed, **false** otherwise.|
3836
3837## VideoOutput
3838
3839Implements output information used in a video session. It inherits from [CameraOutput](#cameraoutput).
3840
3841### start
3842
3843start(callback: AsyncCallback\<void\>): void
3844
3845Starts video recording. This API uses an asynchronous callback to return the result.
3846
3847**Atomic service API**: This API can be used in atomic services since API version 19.
3848
3849**System capability**: SystemCapability.Multimedia.Camera.Core
3850
3851**Parameters**
3852
3853| Name     | Type                 | Mandatory| Description                |
3854| -------- | -------------------- | ---- | -------------------- |
3855| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
3856
3857**Error codes**
3858
3859For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
3860
3861| ID        | Error Message       |
3862| --------------- | --------------- |
3863| 7400103                |  Session not config.                                   |
3864| 7400201                |  Camera service fatal error.                           |
3865
3866**Example**
3867
3868```ts
3869import { BusinessError } from '@kit.BasicServicesKit';
3870
3871function startVideoOutput(videoOutput: camera.VideoOutput): void {
3872  videoOutput.start((err: BusinessError) => {
3873    if (err) {
3874      console.error(`Failed to start the video output, error code: ${err.code}.`);
3875      return;
3876    }
3877    console.info('Callback invoked to indicate the video output start success.');
3878  });
3879}
3880```
3881
3882### start
3883
3884start(): Promise\<void\>
3885
3886Starts video recording. This API uses a promise to return the result.
3887
3888**Atomic service API**: This API can be used in atomic services since API version 19.
3889
3890**System capability**: SystemCapability.Multimedia.Camera.Core
3891
3892**Return value**
3893
3894| Type           | Description                    |
3895| -------------- | ----------------------- |
3896| Promise\<void\> | Promise that returns no value.|
3897
3898**Error codes**
3899
3900For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
3901
3902| ID        | Error Message       |
3903| --------------- | --------------- |
3904| 7400103                |  Session not config.                                   |
3905| 7400201                |  Camera service fatal error.                           |
3906
3907**Example**
3908
3909```ts
3910import { BusinessError } from '@kit.BasicServicesKit';
3911
3912function startVideoOutput(videoOutput: camera.VideoOutput): void {
3913  videoOutput.start().then(() => {
3914    console.info('Promise returned to indicate that start method execution success.');
3915  }).catch((error: BusinessError) => {
3916    console.error(`Failed to video output start, error code: ${error.code}.`);
3917  });
3918}
3919```
3920
3921### stop
3922
3923stop(callback: AsyncCallback\<void\>): void
3924
3925Stops video recording. This API uses an asynchronous callback to return the result.
3926
3927**Atomic service API**: This API can be used in atomic services since API version 19.
3928
3929**System capability**: SystemCapability.Multimedia.Camera.Core
3930
3931**Parameters**
3932
3933| Name    | Type                | Mandatory| Description                    |
3934| -------- | -------------------- | ---- | ------------------------ |
3935| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
3936
3937**Example**
3938
3939```ts
3940import { BusinessError } from '@kit.BasicServicesKit';
3941
3942function stopVideoOutput(videoOutput: camera.VideoOutput): void {
3943  videoOutput.stop((err: BusinessError) => {
3944    if (err) {
3945      console.error(`Failed to stop the video output, error code: ${err.code}.`);
3946      return;
3947    }
3948    console.info('Callback invoked to indicate the video output stop success.');
3949  });
3950}
3951```
3952
3953### stop
3954
3955stop(): Promise\<void\>
3956
3957Stops video recording. This API uses a promise to return the result.
3958
3959**Atomic service API**: This API can be used in atomic services since API version 19.
3960
3961**System capability**: SystemCapability.Multimedia.Camera.Core
3962
3963**Return value**
3964
3965| Type           | Description                    |
3966| -------------- | ----------------------- |
3967| Promise\<void\> | Promise that returns no value.|
3968
3969**Example**
3970
3971```ts
3972import { BusinessError } from '@kit.BasicServicesKit';
3973
3974function stopVideoOutput(videoOutput: camera.VideoOutput): void {
3975  videoOutput.stop().then(() => {
3976    console.info('Promise returned to indicate that stop method execution success.');
3977  }).catch((error: BusinessError) => {
3978    console.error(`Failed to video output stop, error code: ${error.code}.`);
3979  });
3980}
3981```
3982
3983### on('frameStart')
3984
3985on(type: 'frameStart', callback: AsyncCallback\<void\>): void
3986
3987Subscribes to video recording start events. This API uses an asynchronous callback to return the result.
3988
3989> **NOTE**
3990>
3991> Currently, you cannot use **off()** to unregister the callback in the callback method of **on()**.
3992
3993**Atomic service API**: This API can be used in atomic services since API version 19.
3994
3995**System capability**: SystemCapability.Multimedia.Camera.Core
3996
3997**Parameters**
3998
3999| Name     | Type                 | Mandatory| Description                                      |
4000| -------- | -------------------- | ---- | ----------------------------------------- |
4001| 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.|
4002| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.  The recording starts as long as this event is returned.                    |
4003
4004**Example**
4005
4006```ts
4007import { BusinessError } from '@kit.BasicServicesKit';
4008
4009function callback(err: BusinessError): void {
4010  if (err !== undefined && err.code !== 0) {
4011    console.error(`Callback Error, errorCode: ${err.code}`);
4012    return;
4013  }
4014  console.info('Video frame started');
4015}
4016
4017function registerVideoOutputFrameStart(videoOutput: camera.VideoOutput): void {
4018  videoOutput.on('frameStart', callback);
4019}
4020```
4021
4022### off('frameStart')
4023
4024off(type: 'frameStart', callback?: AsyncCallback\<void\>): void
4025
4026Unsubscribes from video recording start events.
4027
4028> **NOTE**
4029>
4030> Currently, you cannot use **off()** to unregister the callback in the callback method of **on()**.
4031
4032**Atomic service API**: This API can be used in atomic services since API version 19.
4033
4034**System capability**: SystemCapability.Multimedia.Camera.Core
4035
4036**Parameters**
4037
4038| Name     | Type                 | Mandatory| Description                                      |
4039| -------- | -------------------- | ---- | ----------------------------------------- |
4040| type     | string               | Yes  | Event type. The value is fixed at **'frameStart'**. The event can be listened for when a videoOutput instance is created.|
4041| 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.|
4042
4043**Example**
4044
4045```ts
4046function unregisterVideoOutputFrameStart(videoOutput: camera.VideoOutput): void {
4047  videoOutput.off('frameStart');
4048}
4049
4050```
4051
4052### on('frameEnd')
4053
4054on(type: 'frameEnd', callback: AsyncCallback\<void\>): void
4055
4056Subscribes to video recording stop events. This API uses an asynchronous callback to return the result.
4057
4058**Atomic service API**: This API can be used in atomic services since API version 19.
4059
4060**System capability**: SystemCapability.Multimedia.Camera.Core
4061
4062**Parameters**
4063
4064| Name     | Type                 | Mandatory| Description                                      |
4065| -------- | -------------------- | ---- | ------------------------------------------ |
4066| 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.|
4067| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result. The recording ends as long as this event is returned.                     |
4068
4069**Example**
4070
4071```ts
4072import { BusinessError } from '@kit.BasicServicesKit';
4073
4074function callback(err: BusinessError): void {
4075  if (err !== undefined && err.code !== 0) {
4076    console.error(`Callback Error, errorCode: ${err.code}`);
4077    return;
4078  }
4079  console.info('Video frame ended');
4080}
4081
4082function registerVideoOutputFrameEnd(videoOutput: camera.VideoOutput): void {
4083  videoOutput.on('frameEnd', callback);
4084}
4085```
4086
4087### off('frameEnd')
4088
4089off(type: 'frameEnd', callback?: AsyncCallback\<void\>): void
4090
4091Unsubscribes from video recording stop events.
4092
4093**Atomic service API**: This API can be used in atomic services since API version 19.
4094
4095**System capability**: SystemCapability.Multimedia.Camera.Core
4096
4097**Parameters**
4098
4099| Name     | Type                 | Mandatory| Description                                      |
4100| -------- | -------------------- | ---- | ------------------------------------------ |
4101| type     | string               | Yes  | Event type. The value is fixed at **'frameEnd'**. The event can be listened for when a videoOutput instance is created.|
4102| 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.|
4103
4104**Example**
4105
4106```ts
4107function unregisterVideoOutputFrameEnd(videoOutput: camera.VideoOutput): void {
4108  videoOutput.off('frameEnd');
4109}
4110```
4111
4112### on('error')
4113
4114on(type: 'error', callback: ErrorCallback): void
4115
4116Subscribes to VideoOutput error events. This API uses an asynchronous callback to return the result.
4117
4118> **NOTE**
4119>
4120> Currently, you cannot use **off()** to unregister the callback in the callback method of **on()**.
4121
4122**Atomic service API**: This API can be used in atomic services since API version 19.
4123
4124**System capability**: SystemCapability.Multimedia.Camera.Core
4125
4126**Parameters**
4127
4128| Name    | Type      | Mandatory| Description                                   |
4129| -------- | ----------- | ---- | -------------------------------------- |
4130| 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).|
4131| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback) | Yes  | Callback used to return an error code defined in [CameraErrorCode](#cameraerrorcode).                |
4132
4133**Example**
4134
4135```ts
4136import { BusinessError } from '@kit.BasicServicesKit';
4137
4138function callback(err: BusinessError): void {
4139  console.error(`Video output error code: ${err.code}`);
4140}
4141
4142function registerVideoOutputError(videoOutput: camera.VideoOutput): void {
4143  videoOutput.on('error', callback);
4144}
4145```
4146
4147### off('error')
4148
4149off(type: 'error', callback?: ErrorCallback): void
4150
4151Unsubscribes from VideoOutput error events.
4152
4153**Atomic service API**: This API can be used in atomic services since API version 19.
4154
4155**System capability**: SystemCapability.Multimedia.Camera.Core
4156
4157**Parameters**
4158
4159| Name    | Type        | Mandatory| Description                                |
4160| -------- | ------------- | ---- | ----------------------------------- |
4161| type     | string       | Yes  | Event type. The value is fixed at **'error'**. The event can be listened for when a photoOutput instance is created.|
4162| 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.|
4163
4164**Example**
4165
4166```ts
4167function unregisterVideoOutputError(videoOutput: camera.VideoOutput): void {
4168  videoOutput.off('error');
4169}
4170```
4171
4172### getSupportedFrameRates<sup>12+</sup>
4173
4174getSupportedFrameRates(): Array\<FrameRateRange\>
4175
4176Obtains the supported frame rates.
4177
4178**Atomic service API**: This API can be used in atomic services since API version 19.
4179
4180**System capability**: SystemCapability.Multimedia.Camera.Core
4181
4182**Return value**
4183
4184|      Type     |     Description    |
4185| -------------  | ------------ |
4186| Array<[FrameRateRange](#frameraterange)> | Array of supported frame rates.|
4187
4188**Example**
4189
4190```ts
4191function getSupportedFrameRates(videoOutput: camera.VideoOutput): Array<camera.FrameRateRange> {
4192  let supportedFrameRatesArray: Array<camera.FrameRateRange> = videoOutput.getSupportedFrameRates();
4193  return supportedFrameRatesArray;
4194}
4195```
4196
4197### setFrameRate<sup>12+</sup>
4198
4199setFrameRate(minFps: number, maxFps: number): void
4200
4201Sets 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).
4202
4203> **NOTE**
4204>
4205> This API is valid only in [PhotoSession](#photosession11) or [VideoSession](#videosession11) mode.
4206
4207**Atomic service API**: This API can be used in atomic services since API version 19.
4208
4209**System capability**: SystemCapability.Multimedia.Camera.Core
4210
4211**Parameters**
4212
4213| Name    | Type        | Mandatory| Description                      |
4214| -------- | --------------| ---- | ------------------------ |
4215| minFps   | number        | Yes  | Minimum frame rate.|
4216| maxFps   | number        | Yes  | Maximum frame rate. When the minimum value is greater than the maximum value, the API does not take effect.|
4217
4218**Error codes**
4219
4220For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
4221
4222| ID       | Error Message       |
4223| --------------- | --------------- |
4224| 7400101                |  Parameter missing or parameter type incorrect.        |
4225| 7400110                |  Unresolved conflicts with current configurations.     |
4226
4227**Example**
4228
4229```ts
4230function setFrameRateRange(videoOutput: camera.VideoOutput, frameRateRange: Array<number>): void {
4231  videoOutput.setFrameRate(frameRateRange[0], frameRateRange[1]);
4232}
4233```
4234
4235### getActiveFrameRate<sup>12+</sup>
4236
4237getActiveFrameRate(): FrameRateRange
4238
4239Obtains the configured frame rate range.
4240
4241This API is valid only after [setFrameRate](#setframerate12-1) is called to set a frame rate range for video streams.
4242
4243**Atomic service API**: This API can be used in atomic services since API version 19.
4244
4245**System capability**: SystemCapability.Multimedia.Camera.Core
4246
4247**Return value**
4248
4249|      Type     |     Description    |
4250| -------------  | ------------ |
4251| [FrameRateRange](#frameraterange) | Frame rate range.|
4252
4253**Example**
4254
4255```ts
4256function getActiveFrameRate(videoOutput: camera.VideoOutput): camera.FrameRateRange {
4257  let activeFrameRate: camera.FrameRateRange = videoOutput.getActiveFrameRate();
4258  return activeFrameRate;
4259}
4260```
4261
4262### getActiveProfile<sup>12+</sup>
4263
4264getActiveProfile(): VideoProfile
4265
4266Obtains the profile that takes effect currently.
4267
4268**Atomic service API**: This API can be used in atomic services since API version 19.
4269
4270**System capability**: SystemCapability.Multimedia.Camera.Core
4271
4272**Return value**
4273
4274|      Type     | Description       |
4275| -------------  |-----------|
4276| [VideoProfile](#videoprofile) | Profile obtained.|
4277
4278**Error codes**
4279
4280For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
4281
4282| ID  | Error Message                        |
4283|---------|------------------------------|
4284| 7400201 | Camera service fatal error.  |
4285
4286**Example**
4287
4288```ts
4289function testGetActiveProfile(videoOutput: camera.VideoOutput): camera.Profile | undefined {
4290  let activeProfile: camera.VideoProfile | undefined = undefined;
4291  try {
4292    activeProfile = videoOutput.getActiveProfile();
4293  } catch (error) {
4294    // If the operation fails, error.code is returned and processed.
4295    let err = error as BusinessError;
4296    console.error(`The videoOutput.getActiveProfile call failed. error code: ${err.code}`);
4297  }
4298  return activeProfile;
4299}
4300```
4301### isMirrorSupported<sup>15+</sup>
4302
4303isMirrorSupported(): boolean
4304
4305Checks whether mirror recording is supported.
4306
4307**Atomic service API**: This API can be used in atomic services since API version 19.
4308
4309**System capability**: SystemCapability.Multimedia.Camera.Core
4310
4311**Return value**
4312
4313| Type           | Description                             |
4314| -------------- |---------------------------------|
4315| boolean | Check result for the support of mirror recording. **true** if supported, **false** otherwise.|
4316
4317**Example**
4318
4319```ts
4320function testIsMirrorSupported(videoOutput: camera.VideoOutput): boolean {
4321  let isSupported: boolean = videoOutput.isMirrorSupported();
4322  return isSupported;
4323}
4324```
4325### enableMirror<sup>15+</sup>
4326
4327enableMirror(enabled: boolean): void
4328
4329Enables or disables mirror recording.
4330
4331- Before calling this API, check whether mirror recording is supported by using [isMirrorSupported](#ismirrorsupported15).
4332
4333- After enabling or disabling mirror recording, call [getVideoRotation](#getvideorotation12) and [updateRotation](../apis-media-kit/js-apis-media.md#updaterotation12) to update the rotation angle.
4334
4335**Atomic service API**: This API can be used in atomic services since API version 19.
4336
4337**System capability**: SystemCapability.Multimedia.Camera.Core
4338
4339**Parameters**
4340
4341| Name     | Type                   | Mandatory| Description                       |
4342|----------| ---------------------- | ---- |---------------------------|
4343| enabled | boolean                | Yes  | Whether to enable mirror recording. **true** to enable, **false** otherwise.|
4344
4345**Error codes**
4346
4347For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
4348
4349| ID   | Error Message                                          |
4350| -------- |------------------------------------------------|
4351| 7400101  | Parameter missing or parameter type incorrect. |
4352| 7400103  | Session not config.                    |
4353
4354
4355**Example**
4356
4357```ts
4358import { camera } from '@kit.CameraKit';
4359import { media } from '@kit.MediaKit';
4360import { BusinessError } from '@kit.BasicServicesKit';
4361
4362function enableMirror(videoOutput: camera.VideoOutput, mirrorMode: boolean, aVRecorder: media.AVRecorder, deviceDegree : number): void {
4363    try {
4364        videoOutput.enableMirror(mirrorMode);
4365        aVRecorder.updateRotation(videoOutput.getVideoRotation(deviceDegree));
4366    } catch (error) {
4367        let err = error as BusinessError;
4368    }
4369}
4370```
4371
4372### getVideoRotation<sup>12+</sup>
4373
4374getVideoRotation(deviceDegree: number): ImageRotation
4375
4376Obtains the video rotation degree.
4377
4378- Device' natural orientation: The default orientation of the device (phone) is in portrait mode, with the charging port facing downward.
4379- 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.
4380- 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.
4381
4382**Atomic service API**: This API can be used in atomic services since API version 19.
4383
4384**System capability**: SystemCapability.Multimedia.Camera.Core
4385
4386**Parameters**
4387
4388| Name    | Type        | Mandatory| Description                      |
4389| -------- | --------------| ---- | ------------------------ |
4390| deviceDegree | number | Yes  | Rotation angle, in degrees.|
4391
4392**Return value**
4393
4394|      Type     | Description       |
4395| -------------  |-----------|
4396| [ImageRotation](#imagerotation) | Video rotation degree.|
4397
4398**Error codes**
4399
4400For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
4401
4402| ID  | Error Message                        |
4403|---------|------------------------------|
4404| 7400101 | Parameter missing or parameter type incorrect.  |
4405| 7400201 | Camera service fatal error.  |
4406
4407**Example**
4408
4409```ts
4410import { camera } from '@kit.CameraKit';
4411import { Decimal } from '@kit.ArkTS';
4412import { sensor } from '@kit.SensorServiceKit';
4413import { BusinessError } from '@kit.BasicServicesKit';
4414
4415function getVideoRotation(videoOutput: camera.VideoOutput): camera.ImageRotation {
4416    let videoRotation: camera.ImageRotation = camera.ImageRotation.ROTATION_0;
4417    try {
4418        videoRotation = videoOutput.getVideoRotation(getDeviceDegree());
4419    } catch (error) {
4420        let err = error as BusinessError;
4421    }
4422    return videoRotation;
4423}
4424
4425// Obtain deviceDegree.
4426function getDeviceDegree(): number {
4427    let deviceDegree: number = -1;
4428    try {
4429        sensor.once(sensor.SensorId.GRAVITY, (data: sensor.GravityResponse) => {
4430            console.info('Succeeded in invoking once. X-coordinate component: ' + data.x);
4431            console.info('Succeeded in invoking once. Y-coordinate component: ' + data.y);
4432            console.info('Succeeded in invoking once. Z-coordinate component: ' + data.z);
4433            let x = data.x;
4434            let y = data.y;
4435            let z = data.z;
4436            if ((x * x + y * y) * 3 < z * z) {
4437                deviceDegree = -1;
4438            } else {
4439                let sd: Decimal = Decimal.atan2(y, -x);
4440                let sc: Decimal = Decimal.round(Number(sd) / 3.141592653589 * 180)
4441                deviceDegree = 90 - Number(sc);
4442                deviceDegree = deviceDegree >= 0 ? deviceDegree% 360 : deviceDegree% 360 + 360;
4443            }
4444        });
4445    } catch (error) {
4446        let err: BusinessError = error as BusinessError;
4447    }
4448    return deviceDegree;
4449}
4450```
4451
4452## MetadataOutput
4453
4454Implements metadata streams. It inherits from [CameraOutput](#cameraoutput).
4455
4456### start
4457
4458start(callback: AsyncCallback\<void\>): void
4459
4460Starts to output metadata. This API uses an asynchronous callback to return the result.
4461
4462**Atomic service API**: This API can be used in atomic services since API version 19.
4463
4464**System capability**: SystemCapability.Multimedia.Camera.Core
4465
4466**Parameters**
4467
4468| Name    | Type                                                        | Mandatory| Description                |
4469| -------- | -------------------------- | ---- | ------------------- |
4470| callback | AsyncCallback\<void\>       | Yes  | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
4471
4472**Error codes**
4473
4474For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
4475
4476| ID        | Error Message       |
4477| --------------- | --------------- |
4478| 7400103                |  Session not config.                                   |
4479| 7400201                |  Camera service fatal error.                           |
4480
4481**Example**
4482
4483```ts
4484import { BusinessError } from '@kit.BasicServicesKit';
4485
4486function startMetadataOutput(metadataOutput: camera.MetadataOutput): void {
4487  metadataOutput.start((err: BusinessError) => {
4488    if (err) {
4489      console.error(`Failed to start metadata output, error code: ${err.code}.`);
4490      return;
4491    }
4492    console.info('Callback returned with metadata output started.');
4493  });
4494}
4495```
4496
4497### start
4498
4499start(): Promise\<void\>
4500
4501Starts to output metadata. This API uses a promise to return the result.
4502
4503**Atomic service API**: This API can be used in atomic services since API version 19.
4504
4505**System capability**: SystemCapability.Multimedia.Camera.Core
4506
4507**Return value**
4508
4509| Type                    | Description                    |
4510| ----------------------  | ------------------------ |
4511| Promise\<void\>          | Promise that returns no value.|
4512
4513**Error codes**
4514
4515For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
4516
4517| ID        | Error Message       |
4518| --------------- | --------------- |
4519| 7400103                |  Session not config.                                   |
4520| 7400201                |  Camera service fatal error.                           |
4521
4522**Example**
4523
4524```ts
4525import { BusinessError } from '@kit.BasicServicesKit';
4526
4527function startMetadataOutput(metadataOutput: camera.MetadataOutput): void {
4528  metadataOutput.start().then(() => {
4529    console.info('Callback returned with metadata output started.');
4530  }).catch((error: BusinessError) => {
4531    console.error(`Failed to metadata output stop, error code: ${error.code}`);
4532  });
4533}
4534```
4535
4536### stop
4537
4538stop(callback: AsyncCallback\<void\>): void
4539
4540Stops outputting metadata. This API uses an asynchronous callback to return the result.
4541
4542**Atomic service API**: This API can be used in atomic services since API version 19.
4543
4544**System capability**: SystemCapability.Multimedia.Camera.Core
4545
4546**Parameters**
4547
4548| Name    | Type                        | Mandatory| Description                 |
4549| -------- | -------------------------- | ---- | ------------------- |
4550| callback | AsyncCallback\<void\>       | Yes  | Callback used to return the result.|
4551
4552**Example**
4553
4554```ts
4555import { BusinessError } from '@kit.BasicServicesKit';
4556
4557function stopMetadataOutput(metadataOutput: camera.MetadataOutput): void {
4558  metadataOutput.stop((err: BusinessError) => {
4559    if (err) {
4560      console.error(`Failed to stop the metadata output, error code: ${err.code}.`);
4561      return;
4562    }
4563    console.info('Callback returned with metadata output stopped.');
4564  })
4565}
4566```
4567
4568### stop
4569
4570stop(): Promise\<void\>
4571
4572Stops outputting metadata. This API uses a promise to return the result.
4573
4574**Atomic service API**: This API can be used in atomic services since API version 19.
4575
4576**System capability**: SystemCapability.Multimedia.Camera.Core
4577
4578**Return value**
4579
4580| Type                   | Description                       |
4581| ----------------------  | --------------------------- |
4582| Promise\<void\>         | Promise that returns no value.|
4583
4584**Example**
4585
4586```ts
4587import { BusinessError } from '@kit.BasicServicesKit';
4588
4589function stopMetadataOutput(metadataOutput: camera.MetadataOutput): void {
4590  metadataOutput.stop().then(() => {
4591    console.info('Callback returned with metadata output stopped.');
4592  }).catch((error: BusinessError) => {
4593    console.error(`Failed to metadata output stop, error code: ${error.code}`);
4594  });
4595}
4596```
4597
4598### on('metadataObjectsAvailable')
4599
4600on(type: 'metadataObjectsAvailable', callback: AsyncCallback\<Array\<MetadataObject\>\>): void
4601
4602Subscribes to events indicating available metadata objects. This API uses an asynchronous callback to return the result.
4603
4604> **NOTE**
4605>
4606> Currently, you cannot use **off()** to unregister the callback in the callback method of **on()**.
4607
4608**Atomic service API**: This API can be used in atomic services since API version 19.
4609
4610**System capability**: SystemCapability.Multimedia.Camera.Core
4611
4612**Parameters**
4613
4614| Name     | Type        | Mandatory| Description                                 |
4615| -------- | -------------- | ---- | ------------------------------------ |
4616| 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.|
4617| callback | AsyncCallback\<Array\<[MetadataObject](#metadataobject)\>\> | Yes  | Callback used to return the metadata.|
4618
4619**Example**
4620
4621```ts
4622import { BusinessError } from '@kit.BasicServicesKit';
4623
4624function callback(err: BusinessError, metadataObjectArr: Array<camera.MetadataObject>): void {
4625  if (err !== undefined && err.code !== 0) {
4626    console.error(`Callback Error, errorCode: ${err.code}`);
4627    return;
4628  }
4629  console.info('metadata output metadataObjectsAvailable');
4630}
4631
4632function registerMetadataObjectsAvailable(metadataOutput: camera.MetadataOutput): void {
4633  metadataOutput.on('metadataObjectsAvailable', callback);
4634}
4635```
4636
4637### off('metadataObjectsAvailable')
4638
4639off(type: 'metadataObjectsAvailable', callback?: AsyncCallback\<Array\<MetadataObject\>\>): void
4640
4641Unsubscribes from events indicating available metadata objects.
4642
4643**Atomic service API**: This API can be used in atomic services since API version 19.
4644
4645**System capability**: SystemCapability.Multimedia.Camera.Core
4646
4647**Parameters**
4648
4649| Name     | Type        | Mandatory| Description                                 |
4650| -------- | -------------- | ---- | ------------------------------------ |
4651| type     | string         | Yes  | Event type. The value is fixed at **'metadataObjectsAvailable'**. The event can be listened for when a metadataOutput instance is created.|
4652| 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.|
4653
4654**Example**
4655
4656```ts
4657function unregisterMetadataObjectsAvailable(metadataOutput: camera.MetadataOutput): void {
4658  metadataOutput.off('metadataObjectsAvailable');
4659}
4660```
4661
4662### on('error')
4663
4664on(type: 'error', callback: ErrorCallback): void
4665
4666Subscribes to metadata error events. This API uses an asynchronous callback to return the result.
4667
4668> **NOTE**
4669>
4670> Currently, you cannot use **off()** to unregister the callback in the callback method of **on()**.
4671
4672**Atomic service API**: This API can be used in atomic services since API version 19.
4673
4674**System capability**: SystemCapability.Multimedia.Camera.Core
4675
4676**Parameters**
4677
4678| Name    | Type        | Mandatory| Description                                    |
4679| -------- | ------------- | ---- | --------------------------------------- |
4680| 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).|
4681| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback) | Yes  | Callback used to return an error code defined in [CameraErrorCode](#cameraerrorcode).           |
4682
4683**Example**
4684
4685```ts
4686import { BusinessError } from '@kit.BasicServicesKit';
4687
4688function callback(metadataOutputError: BusinessError): void {
4689  console.error(`Metadata output error code: ${metadataOutputError.code}`);
4690}
4691
4692function registerMetadataOutputError(metadataOutput: camera.MetadataOutput): void {
4693  metadataOutput.on('error', callback);
4694}
4695```
4696
4697### off('error')
4698
4699off(type: 'error', callback?: ErrorCallback): void
4700
4701Unsubscribes from metadata error events.
4702
4703**Atomic service API**: This API can be used in atomic services since API version 19.
4704
4705**System capability**: SystemCapability.Multimedia.Camera.Core
4706
4707**Parameters**
4708
4709| Name    | Type        | Mandatory| Description                                    |
4710| -------- | ------------- | ---- | --------------------------------------- |
4711| type     | string        | Yes  | Event type. The value is fixed at **'error'**. The event can be listened for when a metadataOutput instance is created.|
4712| 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.|
4713
4714**Example**
4715
4716```ts
4717function unregisterMetadataOutputError(metadataOutput: camera.MetadataOutput): void {
4718  metadataOutput.off('error');
4719}
4720```
4721
4722## MetadataObjectType
4723
4724Enumerates the metadata object types.
4725
4726**Atomic service API**: This API can be used in atomic services since API version 19.
4727
4728**System capability**: SystemCapability.Multimedia.Camera.Core
4729
4730| Name                      | Value  | Description             |
4731| ------------------------- | ---- | ----------------- |
4732| 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).|
4733
4734## Rect
4735
4736Describes a rectangle.
4737
4738**Atomic service API**: This API can be used in atomic services since API version 19.
4739
4740**System capability**: SystemCapability.Multimedia.Camera.Core
4741
4742| Name     | Type  |  Read-only | Optional |           Description        |
4743| -------- | ------ | ------ |-----| --------------------- |
4744| topLeftX | number |   No  | No  | X-axis coordinate of the upper left corner of the rectangle.  |
4745| topLeftY | number |   No  | No  | Y-axis coordinate of the upper left corner of the rectangle.  |
4746| width    | number |   No  | No  | Width of the rectangle, which is a relative value. The value range is [0, 1]. |
4747| height   | number |   No  | No  | Height of the rectangle, which is a relative value. The value range is [0, 1]. |
4748
4749## MetadataObject
4750
4751Describes the camera metadata, which is the data source of [CameraInput](#camerainput). The metadata is obtained through metadataOutput.on('metadataObjectsAvailable').
4752
4753**Atomic service API**: This API can be used in atomic services since API version 19.
4754
4755**System capability**: SystemCapability.Multimedia.Camera.Core
4756
4757| Name        | Type                                       | Read-only| Optional|Description               |
4758| ----------- | ------------------------------------------- | ---- | ---- | ----------------- |
4759| type        | [MetadataObjectType](#metadataobjecttype)   |  Yes |  No | Metadata object type.   |
4760| timestamp   | number                                      |  Yes |  No | Current timestamp, in milliseconds.|
4761| boundingBox | [Rect](#rect)                               |  Yes |  No | Metadata rectangle. |
4762
4763## FlashMode
4764
4765Enumerates the flash modes.
4766
4767**Atomic service API**: This API can be used in atomic services since API version 19.
4768
4769**System capability**: SystemCapability.Multimedia.Camera.Core
4770
4771| Name                   | Value  | Description       |
4772| ---------------------- | ---- | ---------- |
4773| FLASH_MODE_CLOSE       | 0    | The flash is off.|
4774| FLASH_MODE_OPEN        | 1    | The flash is on.|
4775| FLASH_MODE_AUTO        | 2    | The flash mode is auto, indicating that the flash fires automatically depending on the photo capture conditions.|
4776| FLASH_MODE_ALWAYS_OPEN | 3    | The flash is steady on.|
4777
4778## ExposureMode
4779
4780Enumerates the exposure modes.
4781
4782**Atomic service API**: This API can be used in atomic services since API version 19.
4783
4784**System capability**: SystemCapability.Multimedia.Camera.Core
4785
4786| Name                          | Value  | Description        |
4787| ----------------------------- | ---- | ----------- |
4788| EXPOSURE_MODE_LOCKED          | 0    | Exposure locked. The metering point cannot be set.|
4789| EXPOSURE_MODE_AUTO            | 1    | Auto exposure. The metering point can be set by calling [AutoExposure.setMeteringPoint](#setmeteringpoint11).|
4790| EXPOSURE_MODE_CONTINUOUS_AUTO | 2    | Continuous auto exposure. The metering point cannot be set.|
4791
4792## FocusMode
4793
4794Enumerates the focus modes.
4795
4796**Atomic service API**: This API can be used in atomic services since API version 19.
4797
4798**System capability**: SystemCapability.Multimedia.Camera.Core
4799
4800| Name                       | Value  | Description         |
4801| -------------------------- | ---- | ------------ |
4802| 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.    |
4803| FOCUS_MODE_CONTINUOUS_AUTO | 1    | Continuous auto focus. The focal point cannot be set.|
4804| 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.   |
4805| FOCUS_MODE_LOCKED          | 3    | Focus locked. The focal point cannot be set.    |
4806
4807## FocusState
4808
4809Enumerates the focus states.
4810
4811**Atomic service API**: This API can be used in atomic services since API version 19.
4812
4813**System capability**: SystemCapability.Multimedia.Camera.Core
4814
4815| Name                  | Value  | Description      |
4816| --------------------- | ---- | --------- |
4817| FOCUS_STATE_SCAN      | 0    | Focusing. |
4818| FOCUS_STATE_FOCUSED   | 1    | Focused. |
4819| FOCUS_STATE_UNFOCUSED | 2    | Unfocused.|
4820
4821## VideoStabilizationMode
4822
4823Enumerates the video stabilization modes.
4824
4825**Atomic service API**: This API can be used in atomic services since API version 19.
4826
4827**System capability**: SystemCapability.Multimedia.Camera.Core
4828
4829| Name      | Value  | Description        |
4830| --------- | ---- | ------------ |
4831| OFF       | 0    | Video stabilization is disabled.  |
4832| LOW       | 1    | The basic video stabilization algorithm is used.  |
4833| MIDDLE    | 2    | A video stabilization algorithm with a stabilization effect better than that of the **LOW** type is used.  |
4834| HIGH      | 3    | A video stabilization algorithm with a stabilization effect better than that of the **MIDDLE** type is used.  |
4835| AUTO      | 4    | The system automatically selects a video stabilization algorithm.  |
4836
4837## Session<sup>11+</sup>
4838
4839Implements 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.
4840
4841### beginConfig<sup>11+</sup>
4842
4843beginConfig(): void
4844
4845Starts configuration for the session.
4846
4847**Atomic service API**: This API can be used in atomic services since API version 19.
4848
4849**System capability**: SystemCapability.Multimedia.Camera.Core
4850
4851**Error codes**
4852
4853For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
4854
4855| ID        | Error Message       |
4856| --------------- | --------------- |
4857| 7400105                |  Session config locked.               |
4858| 7400201                |  Camera service fatal error.               |
4859
4860**Example**
4861
4862```ts
4863import { BusinessError } from '@kit.BasicServicesKit';
4864
4865function beginConfig(session: camera.Session): void {
4866  try {
4867    session.beginConfig();
4868  } catch (error) {
4869    // If the operation fails, error.code is returned and processed.
4870    let err = error as BusinessError;
4871    console.error(`The beginConfig call failed. error code: ${err.code}`);
4872  }
4873}
4874```
4875
4876### commitConfig<sup>11+</sup>
4877
4878commitConfig(callback: AsyncCallback\<void\>): void
4879
4880Commits the configuration for this session. This API uses an asynchronous callback to return the result.
4881
4882**Atomic service API**: This API can be used in atomic services since API version 19.
4883
4884**System capability**: SystemCapability.Multimedia.Camera.Core
4885
4886**Parameters**
4887
4888| Name    | Type                  | Mandatory| Description                 |
4889| -------- | -------------------- | ---- | -------------------- |
4890| 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.|
4891
4892**Error codes**
4893
4894For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
4895
4896| ID        | Error Message       |
4897| --------------- | --------------- |
4898| 7400102                |  Operation not allowed.                                  |
4899| 7400201                |  Camera service fatal error.                           |
4900
4901**Example**
4902
4903```ts
4904import { BusinessError } from '@kit.BasicServicesKit';
4905
4906function commitConfig(session: camera.Session): void {
4907  session.commitConfig((err: BusinessError) => {
4908    if (err) {
4909      console.error(`The commitConfig call failed. error code: ${err.code}`);
4910      return;
4911    }
4912    console.info('Callback invoked to indicate the commit config success.');
4913  });
4914}
4915```
4916
4917### commitConfig<sup>11+</sup>
4918
4919commitConfig(): Promise\<void\>
4920
4921Commits the configuration for this session. This API uses a promise to return the result.
4922
4923**Atomic service API**: This API can be used in atomic services since API version 19.
4924
4925**System capability**: SystemCapability.Multimedia.Camera.Core
4926
4927**Return value**
4928
4929| Type           | Description                    |
4930| -------------- | ------------------------ |
4931| Promise\<void\> | Promise that returns no value.|
4932
4933**Error codes**
4934
4935For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
4936
4937| ID        | Error Message       |
4938| --------------- | --------------- |
4939| 7400102                |  Operation not allowed.                                  |
4940| 7400201                |  Camera service fatal error.                           |
4941
4942**Example**
4943
4944```ts
4945import { BusinessError } from '@kit.BasicServicesKit';
4946
4947function commitConfig(session: camera.Session): void {
4948  session.commitConfig().then(() => {
4949    console.info('Promise returned to indicate the commit config success.');
4950  }).catch((error: BusinessError) => {
4951    // If the operation fails, error.code is returned and processed.
4952    console.error(`The commitConfig call failed. error code: ${error.code}`);
4953  });
4954}
4955```
4956
4957### canAddInput<sup>11+</sup>
4958
4959canAddInput(cameraInput: CameraInput): boolean
4960
4961Checks whether a CameraInput instance can be added to this session. This API must be called after [beginConfig](#beginconfig11) and before [commitConfig](#commitconfig11-1).
4962
4963**Atomic service API**: This API can be used in atomic services since API version 19.
4964
4965**System capability**: SystemCapability.Multimedia.Camera.Core
4966
4967**Parameters**
4968
4969| Name       | Type                         | Mandatory| Description                    |
4970| ----------- | --------------------------- | ---- | ------------------------ |
4971| 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).|
4972
4973**Return value**
4974
4975| Type           | Description                    |
4976| -------------- | ------------------------ |
4977| boolean | Check result for adding the CameraInput instance. **true** if it can be added, **false** otherwise.|
4978
4979**Example**
4980
4981```ts
4982import { BusinessError } from '@kit.BasicServicesKit';
4983
4984function canAddInput(session: camera.Session, cameraInput: camera.CameraInput): void {
4985  let canAdd: boolean = session.canAddInput(cameraInput);
4986  console.info(`The input canAddInput: ${canAdd}`);
4987}
4988```
4989
4990### addInput<sup>11+</sup>
4991
4992addInput(cameraInput: CameraInput): void
4993
4994Adds a [CameraInput](#camerainput) instance to this session.
4995
4996**Atomic service API**: This API can be used in atomic services since API version 19.
4997
4998**System capability**: SystemCapability.Multimedia.Camera.Core
4999
5000**Parameters**
5001
5002| Name       | Type                         | Mandatory| Description                    |
5003| ----------- | --------------------------- | ---- | ------------------------ |
5004| cameraInput | [CameraInput](#camerainput) | Yes  | CameraInput instance to add.|
5005
5006**Error codes**
5007
5008For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
5009
5010| ID        | Error Message       |
5011| --------------- | --------------- |
5012| 7400101                |  Parameter missing or parameter type incorrect.        |
5013| 7400102                |  Operation not allowed.                                  |
5014| 7400201                |  Camera service fatal error.                                   |
5015
5016**Example**
5017
5018```ts
5019import { BusinessError } from '@kit.BasicServicesKit';
5020
5021function addInput(session: camera.Session, cameraInput: camera.CameraInput): void {
5022  try {
5023    session.addInput(cameraInput);
5024  } catch (error) {
5025    // If the operation fails, error.code is returned and processed.
5026    let err = error as BusinessError;
5027    console.error(`The addInput call failed. error code: ${err.code}`);
5028  }
5029}
5030```
5031
5032### removeInput<sup>11+</sup>
5033
5034removeInput(cameraInput: CameraInput): void
5035
5036Removes a [CameraInput](#camerainput) instance from this session. This API must be called after [beginConfig](#beginconfig11) and before [commitConfig](#commitconfig11-1).
5037
5038**Atomic service API**: This API can be used in atomic services since API version 19.
5039
5040**System capability**: SystemCapability.Multimedia.Camera.Core
5041
5042**Parameters**
5043
5044| Name       | Type                         | Mandatory| Description                     |
5045| ----------- | --------------------------- | ---- | ------------------------ |
5046| cameraInput | [CameraInput](#camerainput) | Yes  | CameraInput instance to remove.|
5047
5048**Error codes**
5049
5050For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
5051
5052| ID        | Error Message       |
5053| --------------- | --------------- |
5054| 7400101                |  Parameter missing or parameter type incorrect.        |
5055| 7400102                |  Operation not allowed.                                  |
5056| 7400201                |  Camera service fatal error.                                   |
5057
5058**Example**
5059
5060```ts
5061import { BusinessError } from '@kit.BasicServicesKit';
5062
5063function removeInput(session: camera.Session, cameraInput: camera.CameraInput): void {
5064  try {
5065    session.removeInput(cameraInput);
5066  } catch (error) {
5067    // If the operation fails, error.code is returned and processed.
5068    let err = error as BusinessError;
5069    console.error(`The removeInput call failed. error code: ${err.code}`);
5070  }
5071}
5072```
5073
5074### canAddOutput<sup>11+</sup>
5075
5076canAddOutput(cameraOutput: CameraOutput): boolean
5077
5078Determines whether a CameraOutput instance can be added to this session. This API must be called after [addInput](#addinput11) and before [commitConfig](#commitconfig11-1).
5079
5080**Atomic service API**: This API can be used in atomic services since API version 19.
5081
5082**System capability**: SystemCapability.Multimedia.Camera.Core
5083
5084**Parameters**
5085
5086| Name       | Type                         | Mandatory| Description                    |
5087| ----------- | --------------------------- | ---- | ------------------------ |
5088| 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).|
5089
5090**Return value**
5091
5092| Type           | Description                    |
5093| -------------- | ------------------------ |
5094| boolean | Check result for adding the CameraOutput instance. **true** if it can be added, **false** otherwise.|
5095
5096**Example**
5097
5098```ts
5099import { BusinessError } from '@kit.BasicServicesKit';
5100
5101function canAddOutput(session: camera.Session, cameraOutput: camera.CameraOutput): void {
5102  let canAdd: boolean = session.canAddOutput(cameraOutput);
5103  console.info(`This addOutput can add: ${canAdd}`);
5104}
5105```
5106
5107### addOutput<sup>11+</sup>
5108
5109addOutput(cameraOutput: CameraOutput): void
5110
5111Adds a [CameraOutput](#cameraoutput) instance to this session.
5112
5113**Atomic service API**: This API can be used in atomic services since API version 19.
5114
5115**System capability**: SystemCapability.Multimedia.Camera.Core
5116
5117**Parameters**
5118
5119| Name          | Type                            | Mandatory| Description                     |
5120| ------------- | ------------------------------- | ---- | ------------------------ |
5121| cameraOutput  | [CameraOutput](#cameraoutput)   | Yes  | CameraOutput instance to add.|
5122
5123**Error codes**
5124
5125For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
5126
5127| ID        | Error Message       |
5128| --------------- | --------------- |
5129| 7400101                |  Parameter missing or parameter type incorrect.        |
5130| 7400102                |  Operation not allowed.                                  |
5131| 7400201                |  Camera service fatal error.                                   |
5132
5133**Example**
5134
5135```ts
5136import { BusinessError } from '@kit.BasicServicesKit';
5137
5138function addOutput(session: camera.Session, cameraOutput: camera.CameraOutput): void {
5139  try {
5140    session.addOutput(cameraOutput);
5141  } catch (error) {
5142    // If the operation fails, error.code is returned and processed.
5143    let err = error as BusinessError;
5144    console.error(`The addOutput call failed. error code: ${err.code}`);
5145  }
5146}
5147```
5148
5149### removeOutput<sup>11+</sup>
5150
5151removeOutput(cameraOutput: CameraOutput): void
5152
5153Removes a [CameraOutput](#cameraoutput) instance from this session.
5154
5155**Atomic service API**: This API can be used in atomic services since API version 19.
5156
5157**System capability**: SystemCapability.Multimedia.Camera.Core
5158
5159**Parameters**
5160
5161| Name          | Type                            | Mandatory| Description                     |
5162| ------------- | ------------------------------- | ---- | ------------------------ |
5163| cameraOutput  | [CameraOutput](#cameraoutput)   | Yes  | CameraOutput instance to remove.|
5164
5165**Error codes**
5166
5167For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
5168
5169| ID        | Error Message       |
5170| --------------- | --------------- |
5171| 7400101                |  Parameter missing or parameter type incorrect.        |
5172| 7400102                |  Operation not allowed.                                  |
5173| 7400201                |  Camera service fatal error.                                   |
5174
5175**Example**
5176
5177```ts
5178import { BusinessError } from '@kit.BasicServicesKit';
5179
5180function removeOutput(session: camera.Session, previewOutput: camera.PreviewOutput): void {
5181  try {
5182    session.removeOutput(previewOutput);
5183  } catch (error) {
5184    // If the operation fails, error.code is returned and processed.
5185    let err = error as BusinessError;
5186    console.error(`The removeOutput call failed. error code: ${err.code}`);
5187  }
5188}
5189```
5190
5191### start<sup>11+</sup>
5192
5193start(callback: AsyncCallback\<void\>): void
5194
5195Starts this session. This API uses an asynchronous callback to return the result.
5196
5197**Atomic service API**: This API can be used in atomic services since API version 19.
5198
5199**System capability**: SystemCapability.Multimedia.Camera.Core
5200
5201**Parameters**
5202
5203| Name     | Type                 | Mandatory| Description                |
5204| -------- | -------------------- | ---- | -------------------- |
5205| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
5206
5207**Error codes**
5208
5209For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
5210
5211| ID        | Error Message       |
5212| --------------- | --------------- |
5213| 7400102                |  Operation not allowed.                                |
5214| 7400103                |  Session not config.                                   |
5215| 7400201                |  Camera service fatal error.                           |
5216
5217**Example**
5218
5219```ts
5220import { BusinessError } from '@kit.BasicServicesKit';
5221
5222function startCaptureSession(session: camera.Session): void {
5223  session.start((err: BusinessError) => {
5224    if (err) {
5225      console.error(`Failed to start the session, error code: ${err.code}.`);
5226      return;
5227    }
5228    console.info('Callback invoked to indicate the session start success.');
5229  });
5230}
5231```
5232
5233### start<sup>11+</sup>
5234
5235start(): Promise\<void\>
5236
5237Starts this session. This API uses a promise to return the result.
5238
5239**Atomic service API**: This API can be used in atomic services since API version 19.
5240
5241**System capability**: SystemCapability.Multimedia.Camera.Core
5242
5243**Return value**
5244
5245| Type           | Description                    |
5246| -------------- | ------------------------ |
5247| Promise\<void\> | Promise that returns no value.|
5248
5249**Error codes**
5250
5251For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
5252
5253| ID        | Error Message       |
5254| --------------- | --------------- |
5255| 7400102                |  Operation not allowed.                                |
5256| 7400103                |  Session not config.                                   |
5257| 7400201                |  Camera service fatal error.                           |
5258
5259**Example**
5260
5261```ts
5262import { BusinessError } from '@kit.BasicServicesKit';
5263
5264function startCaptureSession(session: camera.Session): void {
5265  session.start().then(() => {
5266    console.info('Promise returned to indicate the session start success.');
5267  }).catch((error: BusinessError) => {
5268    console.error(`Failed to start the session, error code: ${error.code}.`);
5269  });
5270}
5271```
5272
5273### stop<sup>11+</sup>
5274
5275stop(callback: AsyncCallback\<void\>): void
5276
5277Stops this session. This API uses an asynchronous callback to return the result.
5278
5279**Atomic service API**: This API can be used in atomic services since API version 19.
5280
5281**System capability**: SystemCapability.Multimedia.Camera.Core
5282
5283**Parameters**
5284
5285| Name     | Type                 | Mandatory| Description                |
5286| -------- | -------------------- | ---- | ------------------- |
5287| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
5288
5289**Error codes**
5290
5291For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
5292
5293| ID        | Error Message       |
5294| --------------- | --------------- |
5295| 7400201                |  Camera service fatal error.                           |
5296
5297**Example**
5298
5299```ts
5300import { BusinessError } from '@kit.BasicServicesKit';
5301
5302function stopCaptureSession(session: camera.Session): void {
5303  session.stop((err: BusinessError) => {
5304    if (err) {
5305      console.error(`Failed to stop the session, error code: ${err.code}.`);
5306      return;
5307    }
5308    console.info('Callback invoked to indicate the session stop success.');
5309  });
5310}
5311```
5312
5313### stop<sup>11+</sup>
5314
5315stop(): Promise\<void\>
5316
5317Stops this session. This API uses a promise to return the result.
5318
5319**Atomic service API**: This API can be used in atomic services since API version 19.
5320
5321**System capability**: SystemCapability.Multimedia.Camera.Core
5322
5323**Return value**
5324
5325| Type           | Description               |
5326| -------------- |-------------------|
5327| Promise\<void\> | Promise that returns no value. |
5328
5329**Error codes**
5330
5331For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
5332
5333| ID        | Error Message       |
5334| --------------- | --------------- |
5335| 7400201                |  Camera service fatal error.                           |
5336
5337**Example**
5338
5339```ts
5340import { BusinessError } from '@kit.BasicServicesKit';
5341
5342function stopCaptureSession(session: camera.Session): void {
5343  session.stop().then(() => {
5344    console.info('Promise returned to indicate the session stop success.');
5345  }).catch((error: BusinessError) => {
5346    console.error(`Failed to stop the session, error code: ${error.code}.`);
5347  });
5348}
5349```
5350
5351### release<sup>11+</sup>
5352
5353release(callback: AsyncCallback\<void\>): void
5354
5355Releases this session. This API uses an asynchronous callback to return the result.
5356
5357**Atomic service API**: This API can be used in atomic services since API version 19.
5358
5359**System capability**: SystemCapability.Multimedia.Camera.Core
5360
5361**Parameters**
5362
5363| Name     | Type                 | Mandatory| Description                |
5364| -------- | -------------------- | ---- | -------------------- |
5365| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
5366
5367**Error codes**
5368
5369For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
5370
5371| ID        | Error Message       |
5372| --------------- | --------------- |
5373| 7400201                |  Camera service fatal error.                           |
5374
5375**Example**
5376
5377```ts
5378import { BusinessError } from '@kit.BasicServicesKit';
5379
5380function releaseCaptureSession(session: camera.Session): void {
5381  session.release((err: BusinessError) => {
5382    if (err) {
5383      console.error(`Failed to release the session instance, error code: ${err.code}.`);
5384      return;
5385    }
5386    console.info('Callback invoked to indicate that the session instance is released successfully.');
5387  });
5388}
5389```
5390
5391### release<sup>11+</sup>
5392
5393release(): Promise\<void\>
5394
5395Releases this session. This API uses a promise to return the result.
5396
5397**Atomic service API**: This API can be used in atomic services since API version 19.
5398
5399**System capability**: SystemCapability.Multimedia.Camera.Core
5400
5401**Return value**
5402
5403| Type           | Description                    |
5404| -------------- | ------------------------ |
5405| Promise\<void\> | Promise that returns no value.|
5406
5407**Error codes**
5408
5409For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
5410
5411| ID        | Error Message       |
5412| --------------- | --------------- |
5413| 7400201                |  Camera service fatal error.                           |
5414
5415**Example**
5416
5417```ts
5418import { BusinessError } from '@kit.BasicServicesKit';
5419
5420function releaseCaptureSession(session: camera.Session): void {
5421  session.release().then(() => {
5422    console.info('Promise returned to indicate that the session instance is released successfully.');
5423  }).catch((error: BusinessError) => {
5424    console.error(`Failed to release the session instance, error code: ${error.code}.`);
5425  });
5426}
5427```
5428
5429## Flash<sup>11+</sup>
5430
5431Flash extends [FlashQuery](#flashquery12).
5432
5433It provides APIs related to the flash.
5434
5435### setFlashMode<sup>11+</sup>
5436
5437setFlashMode(flashMode: FlashMode): void
5438
5439Sets a flash mode.
5440
5441Before the setting, do the following checks:
5442
54431. Use [hasFlash](#hasflash11) to check whether the camera device has flash.
54442. Use [isFlashModeSupported](#isflashmodesupported11) to check whether the camera device supports the flash mode.
5445
5446**Atomic service API**: This API can be used in atomic services since API version 19.
5447
5448**System capability**: SystemCapability.Multimedia.Camera.Core
5449
5450**Parameters**
5451
5452| Name      | Type                    | Mandatory| Description                 |
5453| --------- | ----------------------- | ---- | --------------------- |
5454| 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.      |
5455
5456**Error codes**
5457
5458For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
5459
5460| ID        | Error Message       |
5461| --------------- | --------------- |
5462| 7400103                |  Session not config.                                   |
5463
5464**Example**
5465
5466```ts
5467import { BusinessError } from '@kit.BasicServicesKit';
5468
5469function setFlashMode(photoSession: camera.PhotoSession): void {
5470  try {
5471    photoSession.setFlashMode(camera.FlashMode.FLASH_MODE_AUTO);
5472  } catch (error) {
5473    // If the operation fails, error.code is returned and processed.
5474    let err = error as BusinessError;
5475    console.error(`The setFlashMode call failed. error code: ${err.code}`);
5476  }
5477}
5478```
5479
5480### getFlashMode<sup>11+</sup>
5481
5482getFlashMode(): FlashMode
5483
5484Obtains the flash mode in use.
5485
5486**Atomic service API**: This API can be used in atomic services since API version 19.
5487
5488**System capability**: SystemCapability.Multimedia.Camera.Core
5489
5490**Return value**
5491
5492| Type       | Description                         |
5493| ---------- | ----------------------------- |
5494| [FlashMode](#flashmode)    | Flash mode obtained. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
5495
5496**Error codes**
5497
5498For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
5499
5500| ID        | Error Message       |
5501| --------------- | --------------- |
5502| 7400103                |  Session not config.                                   |
5503
5504**Example**
5505
5506```ts
5507import { BusinessError } from '@kit.BasicServicesKit';
5508
5509function getFlashMode(photoSession: camera.PhotoSession): camera.FlashMode | undefined {
5510  let flashMode: camera.FlashMode | undefined = undefined;
5511  try {
5512    flashMode = photoSession.getFlashMode();
5513  } catch (error) {
5514    // If the operation fails, error.code is returned and processed.
5515    let err = error as BusinessError;
5516    console.error(`The getFlashMode call failed.error code: ${err.code}`);
5517  }
5518  return flashMode;
5519}
5520```
5521
5522## FlashQuery<sup>12+</sup>
5523
5524Provides APIs to query the flash status and mode of a camera device.
5525
5526### hasFlash<sup>11+</sup>
5527
5528hasFlash(): boolean
5529
5530Checks whether the camera device has flash. This API uses an asynchronous callback to return the result.
5531
5532**Atomic service API**: This API can be used in atomic services since API version 19.
5533
5534**System capability**: SystemCapability.Multimedia.Camera.Core
5535
5536**Return value**
5537
5538| Type       | Description                         |
5539| ---------- | ----------------------------- |
5540| boolean    | Check result for whether the camera device has flash. **true** if it has flash, **false** otherwise. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
5541
5542**Error codes**
5543
5544For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
5545
5546| ID        | Error Message       |
5547| --------------- | --------------- |
5548| 7400103                |  Session not config, only throw in session usage.       |
5549
5550**Example**
5551
5552```ts
5553import { BusinessError } from '@kit.BasicServicesKit';
5554
5555function hasFlash(photoSession: camera.PhotoSession): boolean {
5556  let status: boolean = false;
5557  try {
5558    status = photoSession.hasFlash();
5559  } catch (error) {
5560    // If the operation fails, error.code is returned and processed.
5561    let err = error as BusinessError;
5562    console.error(`The hasFlash call failed. error code: ${err.code}`);
5563  }
5564  return status;
5565}
5566```
5567
5568### isFlashModeSupported<sup>11+</sup>
5569
5570isFlashModeSupported(flashMode: FlashMode): boolean
5571
5572Checks whether a flash mode is supported.
5573
5574**Atomic service API**: This API can be used in atomic services since API version 19.
5575
5576**System capability**: SystemCapability.Multimedia.Camera.Core
5577
5578**Parameters**
5579
5580| Name      | Type                    | Mandatory| Description                              |
5581| --------- | ----------------------- | ---- | --------------------------------- |
5582| 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.            |
5583
5584**Return value**
5585
5586| Type       | Description                         |
5587| ---------- | ----------------------------- |
5588| boolean    | Check result for the support of the flash mode. **true** if supported, **false** otherwise. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
5589
5590**Error codes**
5591
5592For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
5593
5594| ID        | Error Message       |
5595| --------------- | --------------- |
5596| 7400103                |  Session not config, only throw in session usage.             |
5597
5598**Example**
5599
5600```ts
5601import { BusinessError } from '@kit.BasicServicesKit';
5602
5603function isFlashModeSupported(photoSession: camera.PhotoSession): boolean {
5604  let status: boolean = false;
5605  try {
5606    status = photoSession.isFlashModeSupported(camera.FlashMode.FLASH_MODE_AUTO);
5607  } catch (error) {
5608    // If the operation fails, error.code is returned and processed.
5609    let err = error as BusinessError;
5610    console.error(`The isFlashModeSupported call failed. error code: ${err.code}`);
5611  }
5612  return status;
5613}
5614```
5615
5616## AutoExposure<sup>11+</sup>
5617
5618AutoExposure extends [AutoExposureQuery](#autoexposurequery12).
5619
5620It provides APIs related to auto exposure.
5621
5622### getExposureMode<sup>11+</sup>
5623
5624getExposureMode(): ExposureMode
5625
5626Obtains the exposure mode in use.
5627
5628**Atomic service API**: This API can be used in atomic services since API version 19.
5629
5630**System capability**: SystemCapability.Multimedia.Camera.Core
5631
5632**Return value**
5633
5634| Type       | Description                         |
5635| ---------- | ----------------------------- |
5636| [ExposureMode](#exposuremode)    | Exposure mode obtained. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
5637
5638**Error codes**
5639
5640For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
5641
5642| ID        | Error Message       |
5643| --------------- | --------------- |
5644| 7400103                |  Session not config.                                   |
5645
5646**Example**
5647
5648```ts
5649import { BusinessError } from '@kit.BasicServicesKit';
5650
5651function getExposureMode(photoSession: camera.PhotoSession): camera.ExposureMode | undefined {
5652  let exposureMode: camera.ExposureMode | undefined = undefined;
5653  try {
5654    exposureMode = photoSession.getExposureMode();
5655  } catch (error) {
5656    // If the operation fails, error.code is returned and processed.
5657    let err = error as BusinessError;
5658    console.error(`The getExposureMode call failed. error code: ${err.code}`);
5659  }
5660  return exposureMode;
5661}
5662```
5663
5664### setExposureMode<sup>11+</sup>
5665
5666setExposureMode(aeMode: ExposureMode): void
5667
5668Sets an exposure mode. Before the setting, call [isExposureModeSupported](#isexposuremodesupported11) to check whether the target exposure mode is supported.
5669
5670**Atomic service API**: This API can be used in atomic services since API version 19.
5671
5672**System capability**: SystemCapability.Multimedia.Camera.Core
5673
5674**Parameters**
5675
5676| Name     | Type                           | Mandatory| Description                   |
5677| -------- | -------------------------------| ---- | ----------------------- |
5678| aeMode   | [ExposureMode](#exposuremode)  | Yes  | Exposure mode. If the input parameter is null or undefined, it is treated as 0 and exposure is locked.               |
5679
5680**Error codes**
5681
5682For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
5683
5684| ID        | Error Message       |
5685| --------------- | --------------- |
5686| 7400102                | Operation not allowed.                                 |
5687| 7400103                |  Session not config.                                   |
5688
5689**Example**
5690
5691```ts
5692import { BusinessError } from '@kit.BasicServicesKit';
5693
5694function setExposureMode(photoSession: camera.PhotoSession): void {
5695  try {
5696    photoSession.setExposureMode(camera.ExposureMode.EXPOSURE_MODE_LOCKED);
5697  } catch (error) {
5698    // If the operation fails, error.code is returned and processed.
5699    let err = error as BusinessError;
5700    console.error(`The setExposureMode call failed. error code: ${err.code}`);
5701  }
5702}
5703```
5704
5705### getMeteringPoint<sup>11+</sup>
5706
5707getMeteringPoint(): Point
5708
5709Obtains the metering point of the camera device.
5710
5711**Atomic service API**: This API can be used in atomic services since API version 19.
5712
5713**System capability**: SystemCapability.Multimedia.Camera.Core
5714
5715**Return value**
5716
5717| Type       | Description                         |
5718| ---------- | ----------------------------- |
5719| [Point](#point)    | Metering point obtained. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
5720
5721**Error codes**
5722
5723For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
5724
5725| ID  | Error Message       |
5726|---------| --------------- |
5727| 7400103 |  Session not config.                                   |
5728
5729**Example**
5730
5731```ts
5732import { BusinessError } from '@kit.BasicServicesKit';
5733
5734function getMeteringPoint(photoSession: camera.PhotoSession): camera.Point | undefined {
5735  let exposurePoint: camera.Point | undefined = undefined;
5736  try {
5737    exposurePoint = photoSession.getMeteringPoint();
5738  } catch (error) {
5739    // If the operation fails, error.code is returned and processed.
5740    let err = error as BusinessError;
5741    console.error(`The getMeteringPoint call failed. error code: ${err.code}`);
5742  }
5743  return exposurePoint;
5744}
5745```
5746
5747### setMeteringPoint<sup>11+</sup>
5748
5749setMeteringPoint(point: Point): void
5750
5751Sets the metering point, which is the center point of the metering rectangle.
5752
5753The 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}.
5754
5755The 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}.
5756**Atomic service API**: This API can be used in atomic services since API version 19.
5757
5758**System capability**: SystemCapability.Multimedia.Camera.Core
5759
5760**Parameters**
5761
5762| Name          | Type                           | Mandatory| Description                |
5763| ------------- | -------------------------------| ---- | ------------------- |
5764| 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.            |
5765
5766**Error codes**
5767
5768For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
5769
5770| ID        | Error Message       |
5771| --------------- | --------------- |
5772| 7400103                |  Session not config.                                   |
5773
5774**Example**
5775
5776```ts
5777import { BusinessError } from '@kit.BasicServicesKit';
5778
5779function setMeteringPoint(photoSession: camera.PhotoSession): void {
5780  const point: camera.Point = {x: 1, y: 1};
5781  try {
5782    photoSession.setMeteringPoint(point);
5783  } catch (error) {
5784    // If the operation fails, error.code is returned and processed.
5785    let err = error as BusinessError;
5786    console.error(`The setMeteringPoint call failed. error code: ${err.code}`);
5787  }
5788}
5789```
5790
5791### setExposureBias<sup>11+</sup>
5792
5793setExposureBias(exposureBias: number): void
5794
5795Sets an exposure compensation value (EV).
5796
5797Before the setting, you are advised to use [getExposureBiasRange](#getexposurebiasrange11) to obtain the supported values.
5798
5799**Atomic service API**: This API can be used in atomic services since API version 19.
5800
5801**System capability**: SystemCapability.Multimedia.Camera.Core
5802
5803**Parameters**
5804
5805| Name    | Type                           | Mandatory| Description                                                                                                                                                                                           |
5806| -------- | -------------------------------| ---- |-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
5807| 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.|
5808
5809**Error codes**
5810
5811For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
5812
5813| ID        | Error Message       |
5814| --------------- | --------------- |
5815| 7400102                |  Operation not allowed.                                |
5816| 7400103                |  Session not config.                                   |
5817
5818**Example**
5819
5820```ts
5821import { BusinessError } from '@kit.BasicServicesKit';
5822
5823function setExposureBias(photoSession: camera.PhotoSession, biasRangeArray: Array<number>): void {
5824  if (biasRangeArray && biasRangeArray.length > 0) {
5825    let exposureBias = biasRangeArray[0];
5826    try {
5827      photoSession.setExposureBias(exposureBias);
5828    } catch (error) {
5829      // If the operation fails, error.code is returned and processed.
5830      let err = error as BusinessError;
5831      console.error(`The setExposureBias call failed. error code: ${err.code}`);
5832    }
5833  }
5834}
5835```
5836
5837### getExposureValue<sup>11+</sup>
5838
5839getExposureValue(): number
5840
5841Obtains the exposure value in use.
5842
5843**Atomic service API**: This API can be used in atomic services since API version 19.
5844
5845**System capability**: SystemCapability.Multimedia.Camera.Core
5846
5847**Return value**
5848
5849| Type       | Description                         |
5850| ---------- | ----------------------------- |
5851| 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.|
5852
5853**Error codes**
5854
5855For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
5856
5857| ID        | Error Message       |
5858| --------------- | --------------- |
5859| 7400103                |  Session not config.                                   |
5860
5861**Example**
5862
5863```ts
5864import { BusinessError } from '@kit.BasicServicesKit';
5865
5866function getExposureValue(photoSession: camera.PhotoSession): number {
5867  const invalidValue: number = -1;
5868  let exposureValue: number = invalidValue;
5869  try {
5870    exposureValue = photoSession.getExposureValue();
5871  } catch (error) {
5872    // If the operation fails, error.code is returned and processed.
5873    let err = error as BusinessError;
5874    console.error(`The getExposureValue call failed. error code: ${err.code}`);
5875  }
5876  return exposureValue;
5877}
5878```
5879
5880## AutoExposureQuery<sup>12+</sup>
5881
5882Provides APIs to query the automatic exposure feature of a camera device.
5883
5884### isExposureModeSupported<sup>11+</sup>
5885
5886isExposureModeSupported(aeMode: ExposureMode): boolean
5887
5888Checks whether an exposure mode is supported.
5889
5890**Atomic service API**: This API can be used in atomic services since API version 19.
5891
5892**System capability**: SystemCapability.Multimedia.Camera.Core
5893
5894**Parameters**
5895
5896| Name     | Type                          | Mandatory | Description                          |
5897| -------- | -------------------------------| ---- | ----------------------------- |
5898| aeMode   | [ExposureMode](#exposuremode)  | Yes  | Exposure mode. If the input parameter is null or undefined, it is treated as 0 and exposure is locked.                |
5899
5900**Return value**
5901
5902| Type       | Description                         |
5903| ---------- | ----------------------------- |
5904| boolean    | Check result for the support of the exposure mode. **true** if supported, **false** otherwise. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
5905
5906**Error codes**
5907
5908For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
5909
5910| ID        | Error Message       |
5911| --------------- | --------------- |
5912| 7400103                |  Session not config, only throw in session usage.          |
5913
5914**Example**
5915
5916```ts
5917import { BusinessError } from '@kit.BasicServicesKit';
5918
5919function isExposureModeSupported(photoSession: camera.PhotoSession): boolean {
5920  let isSupported: boolean = false;
5921  try {
5922    isSupported = photoSession.isExposureModeSupported(camera.ExposureMode.EXPOSURE_MODE_LOCKED);
5923  } catch (error) {
5924    // If the operation fails, error.code is returned and processed.
5925    let err = error as BusinessError;
5926    console.error(`The isExposureModeSupported call failed. error code: ${err.code}`);
5927  }
5928  return isSupported;
5929}
5930```
5931
5932### getExposureBiasRange<sup>11+</sup>
5933
5934getExposureBiasRange(): Array\<number\>
5935
5936Obtains the exposure compensation values of the camera device.
5937
5938**Atomic service API**: This API can be used in atomic services since API version 19.
5939
5940**System capability**: SystemCapability.Multimedia.Camera.Core
5941
5942**Return value**
5943
5944| Type       | Description                         |
5945| ---------- | ----------------------------- |
5946| Array\<number\>   | Array of compensation values. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
5947
5948**Error codes**
5949
5950For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
5951
5952| ID        | Error Message       |
5953| --------------- | --------------- |
5954| 7400103                |  Session not config, only throw in session usage.               |
5955
5956**Example**
5957
5958```ts
5959import { BusinessError } from '@kit.BasicServicesKit';
5960
5961function getExposureBiasRange(photoSession: camera.PhotoSession): Array<number> {
5962  let biasRangeArray: Array<number> = [];
5963  try {
5964    biasRangeArray = photoSession.getExposureBiasRange();
5965  } catch (error) {
5966    // If the operation fails, error.code is returned and processed.
5967    let err = error as BusinessError;
5968    console.error(`The getExposureBiasRange call failed. error code: ${err.code}`);
5969  }
5970  return biasRangeArray;
5971}
5972```
5973
5974## Focus<sup>11+</sup>
5975
5976Focus extends [FocusQuery](#focusquery12)
5977
5978Provides APIs related to focus operations.
5979
5980### setFocusMode<sup>11+</sup>
5981
5982setFocusMode(afMode: FocusMode): void
5983
5984Sets a focus mode.
5985
5986Before the setting, call [isFocusModeSupported](#isfocusmodesupported11) to check whether the focus mode is supported.
5987
5988**Atomic service API**: This API can be used in atomic services since API version 19.
5989
5990**System capability**: SystemCapability.Multimedia.Camera.Core
5991
5992**Parameters**
5993
5994| Name     | Type                    | Mandatory| Description                |
5995| -------- | ----------------------- | ---- | ------------------- |
5996| afMode   | [FocusMode](#focusmode) | Yes  | Focus mode. If the input parameter is null or undefined, it is treated as 0 and manual focus is used.      |
5997
5998**Error codes**
5999
6000For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
6001
6002| ID        | Error Message       |
6003| --------------- | --------------- |
6004| 7400103                |  Session not config.                                   |
6005
6006**Example**
6007
6008```ts
6009import { BusinessError } from '@kit.BasicServicesKit';
6010
6011function setFocusMode(photoSession: camera.PhotoSession): void {
6012  try {
6013    photoSession.setFocusMode(camera.FocusMode.FOCUS_MODE_AUTO);
6014  } catch (error) {
6015    // If the operation fails, error.code is returned and processed.
6016    let err = error as BusinessError;
6017    console.error(`The setFocusMode call failed. error code: ${err.code}`);
6018  }
6019}
6020```
6021
6022### getFocusMode<sup>11+</sup>
6023
6024getFocusMode(): FocusMode
6025
6026Obtains the focus mode in use.
6027
6028**Atomic service API**: This API can be used in atomic services since API version 19.
6029
6030**System capability**: SystemCapability.Multimedia.Camera.Core
6031
6032**Return value**
6033
6034| Type       | Description                         |
6035| ---------- | ----------------------------- |
6036| [FocusMode](#focusmode)   | Focus mode obtained. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
6037
6038**Error codes**
6039
6040For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
6041
6042| ID        | Error Message       |
6043| --------------- | --------------- |
6044| 7400103                |  Session not config.                                   |
6045
6046**Example**
6047
6048```ts
6049import { BusinessError } from '@kit.BasicServicesKit';
6050
6051function getFocusMode(photoSession: camera.PhotoSession): camera.FocusMode | undefined {
6052  let afMode: camera.FocusMode | undefined = undefined;
6053  try {
6054    afMode = photoSession.getFocusMode();
6055  } catch (error) {
6056    // If the operation fails, error.code is returned and processed.
6057    let err = error as BusinessError;
6058    console.error(`The getFocusMode call failed. error code: ${err.code}`);
6059  }
6060  return afMode;
6061}
6062```
6063
6064### setFocusPoint<sup>11+</sup>
6065
6066setFocusPoint(point: Point): void
6067
6068Sets 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}.
6069
6070The 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}.
6071
6072**Atomic service API**: This API can be used in atomic services since API version 19.
6073
6074**System capability**: SystemCapability.Multimedia.Camera.Core
6075
6076**Parameters**
6077
6078| Name     | Type                    | Mandatory| Description                |
6079| -------- | ----------------------- | ---- | ------------------- |
6080| 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.  |
6081
6082**Error codes**
6083
6084For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
6085
6086| ID        | Error Message       |
6087| --------------- | --------------- |
6088| 7400103                |  Session not config.                                   |
6089
6090**Example**
6091
6092```ts
6093import { BusinessError } from '@kit.BasicServicesKit';
6094
6095function setFocusPoint(photoSession: camera.PhotoSession): void {
6096  const focusPoint: camera.Point = {x: 1, y: 1};
6097  try {
6098    photoSession.setFocusPoint(focusPoint);
6099  } catch (error) {
6100    // If the operation fails, error.code is returned and processed.
6101    let err = error as BusinessError;
6102    console.error(`The setFocusPoint call failed. error code: ${err.code}`);
6103  }
6104}
6105```
6106
6107### getFocusPoint<sup>11+</sup>
6108
6109getFocusPoint(): Point
6110
6111Obtains the focal point in use.
6112
6113**Atomic service API**: This API can be used in atomic services since API version 19.
6114
6115**System capability**: SystemCapability.Multimedia.Camera.Core
6116
6117**Return value**
6118
6119| Type       | Description                         |
6120| ---------- | ----------------------------- |
6121| [Point](#point)    | Focal point obtained. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
6122
6123**Error codes**
6124
6125For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
6126
6127| ID        | Error Message       |
6128| --------------- | --------------- |
6129| 7400103                |  Session not config.                                   |
6130
6131**Example**
6132
6133```ts
6134import { BusinessError } from '@kit.BasicServicesKit';
6135
6136function getFocusPoint(photoSession: camera.PhotoSession): camera.Point | undefined {
6137  let point: camera.Point | undefined = undefined;
6138  try {
6139    point = photoSession.getFocusPoint();
6140  } catch (error) {
6141    // If the operation fails, error.code is returned and processed.
6142    let err = error as BusinessError;
6143    console.error(`The getFocusPoint call failed. error code: ${err.code}`);
6144  }
6145  return point;
6146}
6147```
6148
6149### getFocalLength<sup>11+</sup>
6150
6151getFocalLength(): number
6152
6153Obtains the focal length in use.
6154
6155**Atomic service API**: This API can be used in atomic services since API version 19.
6156
6157**System capability**: SystemCapability.Multimedia.Camera.Core
6158
6159**Return value**
6160
6161| Type       | Description                         |
6162| ---------- | ----------------------------- |
6163| number    | Focal length, in mm. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
6164
6165**Error codes**
6166
6167For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
6168
6169| ID        | Error Message       |
6170| --------------- | --------------- |
6171| 7400103                |  Session not config.                                   |
6172
6173**Example**
6174
6175```ts
6176import { BusinessError } from '@kit.BasicServicesKit';
6177
6178function getFocalLength(photoSession: camera.PhotoSession): number {
6179  const invalidValue: number = -1;
6180  let focalLength: number = invalidValue;
6181  try {
6182    focalLength = photoSession.getFocalLength();
6183  } catch (error) {
6184    // If the operation fails, error.code is returned and processed.
6185    let err = error as BusinessError;
6186    console.error(`The getFocalLength call failed. error code: ${err.code}`);
6187  }
6188  return focalLength;
6189}
6190```
6191
6192## FocusQuery<sup>12+</sup>
6193
6194Provides APIs to check whether a focus mode is supported.
6195
6196### isFocusModeSupported<sup>11+</sup>
6197
6198isFocusModeSupported(afMode: FocusMode): boolean
6199
6200Checks whether a focus mode is supported.
6201
6202**Atomic service API**: This API can be used in atomic services since API version 19.
6203
6204**System capability**: SystemCapability.Multimedia.Camera.Core
6205
6206**Parameters**
6207
6208| Name     | Type                    | Mandatory| Description                             |
6209| -------- | ----------------------- | ---- | -------------------------------- |
6210| afMode   | [FocusMode](#focusmode) | Yes  | Focus mode. If the input parameter is null or undefined, it is treated as 0 and manual focus is used.                   |
6211
6212**Return value**
6213
6214| Type       | Description                         |
6215| ---------- | ----------------------------- |
6216| boolean    | Check result for the support of the focus mode. **true** if supported, **false** otherwise. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
6217
6218**Error codes**
6219
6220For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
6221
6222| ID        | Error Message       |
6223| --------------- | --------------- |
6224| 7400103                |  Session not config, only throw in session usage.          |
6225
6226**Example**
6227
6228```ts
6229import { BusinessError } from '@kit.BasicServicesKit';
6230
6231function isFocusModeSupported(photoSession: camera.PhotoSession): boolean {
6232  let status: boolean = false;
6233  try {
6234    status = photoSession.isFocusModeSupported(camera.FocusMode.FOCUS_MODE_AUTO);
6235  } catch (error) {
6236    // If the operation fails, error.code is returned and processed.
6237    let err = error as BusinessError;
6238    console.error(`The isFocusModeSupported call failed. error code: ${err.code}`);
6239  }
6240  return status;
6241}
6242```
6243
6244## MacroQuery<sup>19+</sup>
6245
6246Provides the API to check the support for macro photography.
6247
6248### isMacroSupported<sup>19+</sup>
6249
6250isMacroSupported(): boolean
6251
6252Checks whether macro photography is supported in the current state. This API must be called after [commitConfig](#commitconfig11-1).
6253
6254**Atomic service API**: This API can be used in atomic services since API version 19.
6255
6256**System capability**: SystemCapability.Multimedia.Camera.Core
6257
6258**Return value**
6259
6260| Type       | Description                         |
6261| ---------- | ----------------------------- |
6262|   boolean  | Check result for the support of macro photography. **true** if supported, **false** otherwise.|
6263
6264**Example**
6265
6266```ts
6267function isMacroSupported(photoSession: camera.PhotoSession): boolean {
6268  let isSupported: boolean = photoSession.isMacroSupported();
6269  return isSupported;
6270}
6271```
6272
6273## Macro<sup>19+</sup>
6274
6275Macro extends [MacroQuery](#macroquery19).
6276
6277It provides the API to enable macro photography.
6278
6279### enableMacro<sup>19+</sup>
6280
6281enableMacro(enabled: boolean): void
6282
6283Enables or disables macro photography. This API can be called only when macro photography is supported.
6284
6285**Atomic service API**: This API can be used in atomic services since API version 19.
6286
6287**System capability**: SystemCapability.Multimedia.Camera.Core
6288
6289**Parameters**
6290
6291| Name    | Type                  | Mandatory| Description                 |
6292| -------- | -------------------- | ---- | -------------------- |
6293| enabled | boolean | Yes  | Whether to enable macro photography. **true** to enable, **false** otherwise.|
6294
6295**Error codes**
6296
6297For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
6298
6299| ID   | Error Message                    |
6300|----------|--------------------------|
6301| 7400102  | Operation not allowed.   |
6302| 7400103  | Session not config.      |
6303
6304**Example**
6305
6306```ts
6307function enableMacro(photoSession: camera.PhotoSession): void {
6308  let isSupported: boolean = photoSession.isMacroSupported();
6309  if (isSupported) {
6310    photoSession.enableMacro(true);
6311  }
6312}
6313```
6314
6315## SmoothZoomMode<sup>11+</sup>
6316
6317Enumerates the smooth zoom modes.
6318
6319**Atomic service API**: This API can be used in atomic services since API version 19.
6320
6321**System capability**: SystemCapability.Multimedia.Camera.Core
6322
6323| Name        | Value  | Description           |
6324| ------------ | ---- | -------------- |
6325| NORMAL       | 0    | Bessel curve mode. |
6326
6327## SmoothZoomInfo<sup>11+</sup>
6328
6329Describes the smooth zoom information.
6330
6331**Atomic service API**: This API can be used in atomic services since API version 19.
6332
6333**System capability**: SystemCapability.Multimedia.Camera.Core
6334
6335| Name    | Type       |   Read-only  |   Optional  | Description      |
6336| -------- | ---------- | -------- | -------- | ---------- |
6337| duration |   number   |   No    |    No   | Total duration of smooth zoom, in ms.|
6338
6339## Zoom<sup>11+</sup>
6340
6341Zoom extends [ZoomQuery](#zoomquery12).
6342
6343It provides APIs related to zoom operations.
6344
6345### setZoomRatio<sup>11+</sup>
6346
6347setZoomRatio(zoomRatio: number): void
6348
6349Sets a zoom ratio, with a maximum precision of two decimal places.
6350
6351**Atomic service API**: This API can be used in atomic services since API version 19.
6352
6353**System capability**: SystemCapability.Multimedia.Camera.Core
6354
6355**Parameters**
6356
6357| Name      | Type                 | Mandatory| Description                                                                                                                             |
6358| --------- | -------------------- | ---- |---------------------------------------------------------------------------------------------------------------------------------|
6359| 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.|
6360
6361**Error codes**
6362
6363For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
6364
6365| ID        | Error Message       |
6366| --------------- | --------------- |
6367| 7400103                |  Session not config.                                   |
6368
6369**Example**
6370
6371```ts
6372import { BusinessError } from '@kit.BasicServicesKit';
6373
6374function setZoomRatio(photoSession: camera.PhotoSession, zoomRatioRange: Array<number>): void {
6375  if (zoomRatioRange === undefined || zoomRatioRange.length <= 0) {
6376    return;
6377  }
6378  let zoomRatio = zoomRatioRange[0];
6379  try {
6380    photoSession.setZoomRatio(zoomRatio);
6381  } catch (error) {
6382    // If the operation fails, error.code is returned and processed.
6383    let err = error as BusinessError;
6384    console.error(`The setZoomRatio call failed. error code: ${err.code}`);
6385  }
6386}
6387```
6388
6389### getZoomRatio<sup>11+</sup>
6390
6391getZoomRatio(): number
6392
6393Obtains the zoom ratio in use.
6394
6395**Atomic service API**: This API can be used in atomic services since API version 19.
6396
6397**System capability**: SystemCapability.Multimedia.Camera.Core
6398
6399**Return value**
6400
6401| Type       | Description                         |
6402| ---------- | ----------------------------- |
6403| number    | Zoom ratio obtained. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
6404
6405**Error codes**
6406
6407For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
6408
6409| ID        | Error Message       |
6410| --------------- | --------------- |
6411| 7400103                |  Session not config.                                   |
6412| 7400201                |  Camera service fatal error.                           |
6413
6414**Example**
6415
6416```ts
6417import { BusinessError } from '@kit.BasicServicesKit';
6418
6419function getZoomRatio(photoSession: camera.PhotoSession): number {
6420  const invalidValue: number = -1;
6421  let zoomRatio: number = invalidValue;
6422  try {
6423    zoomRatio = photoSession.getZoomRatio();
6424  } catch (error) {
6425    // If the operation fails, error.code is returned and processed.
6426    let err = error as BusinessError;
6427    console.error(`The getZoomRatio call failed. error code: ${err.code}`);
6428  }
6429  return zoomRatio;
6430}
6431```
6432
6433### setSmoothZoom<sup>11+</sup>
6434
6435setSmoothZoom(targetRatio: number, mode?: SmoothZoomMode): void
6436
6437Sets smooth zoom.
6438
6439**Atomic service API**: This API can be used in atomic services since API version 19.
6440
6441**System capability**: SystemCapability.Multimedia.Camera.Core
6442
6443**Parameters**
6444
6445| Name      | Type           | Mandatory| Description              |
6446| ------------ | -------------- | ---- | ----------------- |
6447| targetRatio  | number         | Yes  | Target zoom ratio.     |
6448| mode         | [SmoothZoomMode](#smoothzoommode11) | No  | Smooth zoom mode.     |
6449
6450**Example**
6451
6452```ts
6453import { BusinessError } from '@kit.BasicServicesKit';
6454
6455function setSmoothZoom(sessionExtendsZoom: camera.Zoom, targetZoomRatio: number, mode: camera.SmoothZoomMode): void {
6456  sessionExtendsZoom.setSmoothZoom(targetZoomRatio, mode);
6457}
6458```
6459
6460## ZoomQuery<sup>12+</sup>
6461
6462Provides APIs to query the zoom feature of a device camera, including the API to obtain the supported zoom ratio range.
6463
6464### getZoomRatioRange<sup>11+</sup>
6465
6466getZoomRatioRange(): Array\<number\>
6467
6468Obtains the supported zoom ratio range.
6469
6470**Atomic service API**: This API can be used in atomic services since API version 19.
6471
6472**System capability**: SystemCapability.Multimedia.Camera.Core
6473
6474**Return value**
6475
6476| Type       | Description                         |
6477| ---------- | ----------------------------- |
6478| Array\<number\>   | Array containing the minimum and maximum zoom ratios. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
6479
6480**Error codes**
6481
6482For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
6483
6484| ID        | Error Message       |
6485| --------------- | --------------- |
6486| 7400103                |  Session not config, only throw in session usage.            |
6487
6488**Example**
6489
6490```ts
6491import { BusinessError } from '@kit.BasicServicesKit';
6492
6493function getZoomRatioRange(photoSession: camera.PhotoSession): Array<number> {
6494  let zoomRatioRange: Array<number> = [];
6495  try {
6496    zoomRatioRange = photoSession.getZoomRatioRange();
6497  } catch (error) {
6498    // If the operation fails, error.code is returned and processed.
6499    let err = error as BusinessError;
6500    console.error(`The getZoomRatioRange call failed. error code: ${err.code}`);
6501  }
6502  return zoomRatioRange;
6503}
6504```
6505
6506## Stabilization<sup>11+</sup>
6507
6508Stabilization extends [StabilizationQuery](#stabilizationquery12).
6509
6510It provides APIs to set video stabilization.
6511
6512 > **NOTE**
6513 >
6514 > You can set video stabilization only when a [VideoOutput](#videooutput) stream exists in the session.
6515 > The enumerated value **HIGH** of [VideoStabilizationMode](#videostabilizationmode) takes effect only when the resolution of [Profile](#profile) is 1920 x 1080.
6516
6517### getActiveVideoStabilizationMode<sup>11+</sup>
6518
6519getActiveVideoStabilizationMode(): VideoStabilizationMode
6520
6521Obtains the video stabilization mode in use.
6522
6523**Atomic service API**: This API can be used in atomic services since API version 19.
6524
6525**System capability**: SystemCapability.Multimedia.Camera.Core
6526
6527**Return value**
6528
6529| Type       | Description         |
6530| ---------- |-------------|
6531| [VideoStabilizationMode](#videostabilizationmode)    | Video stabilization mode obtained.|
6532
6533**Error codes**
6534
6535For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
6536
6537| ID        | Error Message       |
6538| --------------- | --------------- |
6539| 7400103                |  Session not config.                                   |
6540
6541**Example**
6542
6543```ts
6544import { BusinessError } from '@kit.BasicServicesKit';
6545
6546function getActiveVideoStabilizationMode(videoSession: camera.VideoSession): camera.VideoStabilizationMode | undefined {
6547  let vsMode: camera.VideoStabilizationMode | undefined = undefined;
6548  try {
6549    vsMode = videoSession.getActiveVideoStabilizationMode();
6550  } catch (error) {
6551    // If the operation fails, error.code is returned and processed.
6552    let err = error as BusinessError;
6553    console.error(`The getActiveVideoStabilizationMode call failed. error code: ${err.code}`);
6554  }
6555  return vsMode;
6556}
6557```
6558
6559### setVideoStabilizationMode<sup>11+</sup>
6560
6561setVideoStabilizationMode(mode: VideoStabilizationMode): void
6562
6563Sets a video stabilization mode. Before the setting, call [isVideoStabilizationModeSupported](#isvideostabilizationmodesupported11) to check whether the target video stabilization mode is supported.
6564
6565**Atomic service API**: This API can be used in atomic services since API version 19.
6566
6567**System capability**: SystemCapability.Multimedia.Camera.Core
6568
6569**Parameters**
6570
6571| Name     | Type                                             | Mandatory| Description                   |
6572| -------- | ------------------------------------------------- | ---- | --------------------- |
6573| mode     | [VideoStabilizationMode](#videostabilizationmode) | Yes  | Video stabilization mode.  |
6574
6575**Error codes**
6576
6577For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
6578
6579| ID        | Error Message       |
6580| --------------- | --------------- |
6581| 7400103                |  Session not config.                                   |
6582
6583**Example**
6584
6585```ts
6586import { BusinessError } from '@kit.BasicServicesKit';
6587
6588function setVideoStabilizationMode(videoSession: camera.VideoSession): void {
6589  try {
6590    videoSession.setVideoStabilizationMode(camera.VideoStabilizationMode.OFF);
6591  } catch (error) {
6592    // If the operation fails, error.code is returned and processed.
6593    let err = error as BusinessError;
6594    console.error(`The setVideoStabilizationMode call failed. error code: ${err.code}`);
6595  }
6596}
6597```
6598
6599## StabilizationQuery<sup>12+</sup>
6600
6601Provides APIs to check the support for video stabilization.
6602
6603### isVideoStabilizationModeSupported<sup>11+</sup>
6604
6605isVideoStabilizationModeSupported(vsMode: VideoStabilizationMode): boolean
6606
6607Checks whether a video stabilization mode is supported.
6608
6609**Atomic service API**: This API can be used in atomic services since API version 19.
6610
6611**System capability**: SystemCapability.Multimedia.Camera.Core
6612
6613**Parameters**
6614
6615| Name     | Type                                             | Mandatory| Description                            |
6616| -------- | ------------------------------------------------- | ---- | ------------------------------ |
6617| vsMode   | [VideoStabilizationMode](#videostabilizationmode) | Yes  | Video stabilization mode.                   |
6618
6619**Return value**
6620
6621| Type       | Description                         |
6622| ---------- | ----------------------------- |
6623| boolean    | Check result for the support of the video stabilization mode. **true** if supported, **false** otherwise. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
6624
6625**Error codes**
6626
6627For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
6628
6629| ID        | Error Message       |
6630| --------------- | --------------- |
6631| 7400103                |  Session not config, only throw in session usage.             |
6632
6633**Example**
6634
6635```ts
6636import { BusinessError } from '@kit.BasicServicesKit';
6637
6638function isVideoStabilizationModeSupported(videoSession: camera.VideoSession): boolean {
6639  let isSupported: boolean = false;
6640  try {
6641    isSupported = videoSession.isVideoStabilizationModeSupported(camera.VideoStabilizationMode.OFF);
6642  } catch (error) {
6643    // If the operation fails, error.code is returned and processed.
6644    let err = error as BusinessError;
6645    console.error(`The isVideoStabilizationModeSupported call failed. error code: ${err.code}`);
6646  }
6647  return isSupported;
6648}
6649```
6650
6651## CaptureSession<sup>(deprecated)</sup>
6652
6653Implements 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.
6654
6655> **NOTE**
6656>
6657> 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.
6658
6659### beginConfig<sup>(deprecated)</sup>
6660
6661beginConfig(): void
6662
6663Starts configuration for the session.
6664
6665> **NOTE**
6666>
6667> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Session.beginConfig](#beginconfig11) instead.
6668
6669**System capability**: SystemCapability.Multimedia.Camera.Core
6670
6671**Error codes**
6672
6673For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
6674
6675| ID        | Error Message       |
6676| --------------- | --------------- |
6677| 7400105         |  Session config locked.               |
6678
6679**Example**
6680
6681```ts
6682import { BusinessError } from '@kit.BasicServicesKit';
6683
6684function beginConfig(captureSession: camera.CaptureSession): void {
6685  try {
6686    captureSession.beginConfig();
6687  } catch (error) {
6688    // If the operation fails, error.code is returned and processed.
6689    let err = error as BusinessError;
6690    console.error(`The beginConfig call failed. error code: ${err.code}`);
6691  }
6692}
6693```
6694
6695### commitConfig<sup>(deprecated)</sup>
6696
6697commitConfig(callback: AsyncCallback\<void\>): void
6698
6699Commits the configuration for this session. This API uses an asynchronous callback to return the result.
6700
6701> **NOTE**
6702>
6703> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Session.commitConfig](#commitconfig11) instead.
6704
6705**System capability**: SystemCapability.Multimedia.Camera.Core
6706
6707**Parameters**
6708
6709| Name    | Type                  | Mandatory| Description                 |
6710| -------- | -------------------- | ---- | -------------------- |
6711| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
6712
6713**Error codes**
6714
6715For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
6716
6717| ID        | Error Message       |
6718| --------------- | --------------- |
6719| 7400102                |  Operation not allowed.                                  |
6720| 7400201                |  Camera service fatal error.                           |
6721
6722**Example**
6723
6724```ts
6725import { BusinessError } from '@kit.BasicServicesKit';
6726
6727function commitConfig(captureSession: camera.CaptureSession): void {
6728  captureSession.commitConfig((err: BusinessError) => {
6729    if (err) {
6730      console.error(`The commitConfig call failed. error code: ${err.code}`);
6731      return;
6732    }
6733    console.info('Callback invoked to indicate the commit config success.');
6734  });
6735}
6736```
6737
6738### commitConfig<sup>(deprecated)</sup>
6739
6740commitConfig(): Promise\<void\>
6741
6742Commits the configuration for this session. This API uses a promise to return the result.
6743
6744> **NOTE**
6745>
6746> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Session.commitConfig](#commitconfig11-1) instead.
6747
6748**System capability**: SystemCapability.Multimedia.Camera.Core
6749
6750**Return value**
6751
6752| Type           | Description               |
6753| -------------- |-------------------|
6754| Promise\<void\> | Promise that returns no value.|
6755
6756**Error codes**
6757
6758For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
6759
6760| ID        | Error Message       |
6761| --------------- | --------------- |
6762| 7400102                |  Operation not allowed.                                  |
6763| 7400201                |  Camera service fatal error.                           |
6764
6765**Example**
6766
6767```ts
6768import { BusinessError } from '@kit.BasicServicesKit';
6769
6770function commitConfig(captureSession: camera.CaptureSession): void {
6771  captureSession.commitConfig().then(() => {
6772    console.info('Promise returned to indicate the commit config success.');
6773  }).catch((error: BusinessError) => {
6774    // If the operation fails, error.code is returned and processed.
6775    console.error(`The commitConfig call failed. error code: ${error.code}`);
6776  });
6777}
6778```
6779
6780### addInput<sup>(deprecated)</sup>
6781
6782addInput(cameraInput: CameraInput): void
6783
6784Adds a [CameraInput](#camerainput) instance to this session.
6785
6786> **NOTE**
6787>
6788> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Session.addInput](#addinput11) instead.
6789
6790**System capability**: SystemCapability.Multimedia.Camera.Core
6791
6792**Parameters**
6793
6794| Name       | Type                         | Mandatory| Description                    |
6795| ----------- | --------------------------- | ---- | ------------------------ |
6796| cameraInput | [CameraInput](#camerainput) | Yes  | CameraInput instance to add.|
6797
6798**Error codes**
6799
6800For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
6801
6802| ID  | Error Message                                         |
6803|---------|-----------------------------------------------|
6804| 7400101 | Parameter missing or parameter type incorrect. |
6805| 7400102 | Operation not allowed.                           |
6806
6807**Example**
6808
6809```ts
6810import { BusinessError } from '@kit.BasicServicesKit';
6811
6812function addInput(captureSession: camera.CaptureSession, cameraInput: camera.CameraInput): void {
6813  try {
6814    captureSession.addInput(cameraInput);
6815  } catch (error) {
6816    // If the operation fails, error.code is returned and processed.
6817    let err = error as BusinessError;
6818    console.error(`The addInput call failed. error code: ${err.code}`);
6819  }
6820}
6821```
6822
6823### removeInput<sup>(deprecated)</sup>
6824
6825removeInput(cameraInput: CameraInput): void
6826
6827Removes a [CameraInput](#camerainput) instance from this session.
6828
6829> **NOTE**
6830>
6831> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Session.removeInput](#removeinput11) instead.
6832
6833**System capability**: SystemCapability.Multimedia.Camera.Core
6834
6835**Parameters**
6836
6837| Name       | Type                         | Mandatory| Description                     |
6838| ----------- | --------------------------- | ---- | ------------------------ |
6839| cameraInput | [CameraInput](#camerainput) | Yes  | CameraInput instance to remove.|
6840
6841**Error codes**
6842
6843For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
6844
6845| ID        | Error Message       |
6846| --------------- | --------------- |
6847| 7400101                |  Parameter missing or parameter type incorrect.        |
6848| 7400102                |  Operation not allowed.                                  |
6849
6850**Example**
6851
6852```ts
6853import { BusinessError } from '@kit.BasicServicesKit';
6854
6855function removeInput(captureSession: camera.CaptureSession, cameraInput: camera.CameraInput): void {
6856  try {
6857    captureSession.removeInput(cameraInput);
6858  } catch (error) {
6859    // If the operation fails, error.code is returned and processed.
6860    let err = error as BusinessError;
6861    console.error(`The removeInput call failed. error code: ${err.code}`);
6862  }
6863}
6864```
6865
6866### addOutput<sup>(deprecated)</sup>
6867
6868addOutput(cameraOutput: CameraOutput): void
6869
6870Adds a [CameraOutput](#cameraoutput) instance to this session.
6871
6872> **NOTE**
6873>
6874> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Session.addOutput](#addoutput11) instead.
6875
6876**System capability**: SystemCapability.Multimedia.Camera.Core
6877
6878**Parameters**
6879
6880| Name          | Type                            | Mandatory| Description                     |
6881| ------------- | ------------------------------- | ---- | ------------------------ |
6882| cameraOutput  | [CameraOutput](#cameraoutput)   | Yes  | CameraOutput instance to add.|
6883
6884**Error codes**
6885
6886For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
6887
6888| ID        | Error Message       |
6889| --------------- | --------------- |
6890| 7400101                |  Parameter missing or parameter type incorrect.        |
6891| 7400102                |  Operation not allowed.                                  |
6892
6893**Example**
6894
6895```ts
6896import { BusinessError } from '@kit.BasicServicesKit';
6897
6898function addOutput(captureSession: camera.CaptureSession, cameraOutput: camera.CameraOutput): void {
6899  try {
6900    captureSession.addOutput(cameraOutput);
6901  } catch (error) {
6902    // If the operation fails, error.code is returned and processed.
6903    let err = error as BusinessError;
6904    console.error(`The addOutput call failed. error code: ${err.code}`);
6905  }
6906}
6907```
6908
6909### removeOutput<sup>(deprecated)</sup>
6910
6911removeOutput(cameraOutput: CameraOutput): void
6912
6913Removes a [CameraOutput](#cameraoutput) instance from this session.
6914
6915> **NOTE**
6916>
6917> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Session.removeOutput](#removeoutput11) instead.
6918
6919**System capability**: SystemCapability.Multimedia.Camera.Core
6920
6921**Parameters**
6922
6923| Name          | Type                            | Mandatory| Description                     |
6924| ------------- | ------------------------------- | ---- | ------------------------ |
6925| cameraOutput  | [CameraOutput](#cameraoutput)   | Yes  | CameraOutput instance to remove.|
6926
6927**Error codes**
6928
6929For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
6930
6931| ID        | Error Message       |
6932| --------------- | --------------- |
6933| 7400101                |  Parameter missing or parameter type incorrect.        |
6934| 7400102                |  Operation not allowed.                                  |
6935
6936**Example**
6937
6938```ts
6939import { BusinessError } from '@kit.BasicServicesKit';
6940
6941function removeOutput(captureSession: camera.CaptureSession, previewOutput: camera.PreviewOutput): void {
6942  try {
6943    captureSession.removeOutput(previewOutput);
6944  } catch (error) {
6945    // If the operation fails, error.code is returned and processed.
6946    let err = error as BusinessError;
6947    console.error(`The removeOutput call failed. error code: ${err.code}`);
6948  }
6949}
6950```
6951
6952### start<sup>(deprecated)</sup>
6953
6954start(callback: AsyncCallback\<void\>): void
6955
6956Starts this session. This API uses an asynchronous callback to return the result.
6957
6958> **NOTE**
6959>
6960> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Session.start](#start11) instead.
6961
6962**System capability**: SystemCapability.Multimedia.Camera.Core
6963
6964**Parameters**
6965
6966| Name     | Type                 | Mandatory| Description                |
6967| -------- | -------------------- | ---- | -------------------- |
6968| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
6969
6970**Error codes**
6971
6972For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
6973
6974| ID        | Error Message       |
6975| --------------- | --------------- |
6976| 7400103                |  Session not config.                                   |
6977| 7400201                |  Camera service fatal error.                           |
6978
6979**Example**
6980
6981```ts
6982import { BusinessError } from '@kit.BasicServicesKit';
6983
6984function startCaptureSession(captureSession: camera.CaptureSession): void {
6985  captureSession.start((err: BusinessError) => {
6986    if (err) {
6987      console.error(`Failed to start the session, error code: ${err.code}.`);
6988      return;
6989    }
6990    console.info('Callback invoked to indicate the session start success.');
6991  });
6992}
6993```
6994
6995### start<sup>(deprecated)</sup>
6996
6997start(): Promise\<void\>
6998
6999Starts this session. This API uses a promise to return the result.
7000
7001> **NOTE**
7002>
7003> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Session.start](#start11-1) instead.
7004
7005**System capability**: SystemCapability.Multimedia.Camera.Core
7006
7007**Return value**
7008
7009| Type           | Description                    |
7010| -------------- | ------------------------ |
7011| Promise\<void\> | Promise that returns no value.|
7012
7013**Error codes**
7014
7015For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
7016
7017| ID        | Error Message       |
7018| --------------- | --------------- |
7019| 7400103                |  Session not config.                                   |
7020| 7400201                |  Camera service fatal error.                           |
7021
7022**Example**
7023
7024```ts
7025import { BusinessError } from '@kit.BasicServicesKit';
7026
7027function startCaptureSession(captureSession: camera.CaptureSession): void {
7028  captureSession.start().then(() => {
7029    console.info('Promise returned to indicate the session start success.');
7030  }).catch((err: BusinessError) => {
7031    console.error(`Failed to start the session, error code: ${err.code}.`);
7032  });
7033}
7034```
7035
7036### stop<sup>(deprecated)</sup>
7037
7038stop(callback: AsyncCallback\<void\>): void
7039
7040Stops this session. This API uses an asynchronous callback to return the result.
7041
7042> **NOTE**
7043>
7044> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Session.stop](#stop11) instead.
7045
7046**System capability**: SystemCapability.Multimedia.Camera.Core
7047
7048**Parameters**
7049
7050| Name     | Type                 | Mandatory| Description                |
7051| -------- | -------------------- | ---- | ------------------- |
7052| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
7053
7054**Error codes**
7055
7056For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
7057
7058| ID        | Error Message       |
7059| --------------- | --------------- |
7060| 7400201                |  Camera service fatal error.                           |
7061
7062**Example**
7063
7064```ts
7065import { BusinessError } from '@kit.BasicServicesKit';
7066
7067function stopCaptureSession(captureSession: camera.CaptureSession): void {
7068  captureSession.stop((err: BusinessError) => {
7069    if (err) {
7070      console.error(`Failed to stop the session, error code: ${err.code}.`);
7071      return;
7072    }
7073    console.info('Callback invoked to indicate the session stop success.');
7074  });
7075}
7076```
7077
7078### stop<sup>(deprecated)</sup>
7079
7080stop(): Promise\<void\>
7081
7082Stops this session. This API uses a promise to return the result.
7083
7084> **NOTE**
7085>
7086> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Session.stop](#stop11-1) instead.
7087
7088**System capability**: SystemCapability.Multimedia.Camera.Core
7089
7090**Return value**
7091
7092| Type           | Description                    |
7093| -------------- | ----------------------- |
7094| Promise\<void\> | Promise that returns no value.|
7095
7096**Error codes**
7097
7098For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
7099
7100| ID        | Error Message       |
7101| --------------- | --------------- |
7102| 7400201                |  Camera service fatal error.                           |
7103
7104**Example**
7105
7106```ts
7107import { BusinessError } from '@kit.BasicServicesKit';
7108
7109function stopCaptureSession(captureSession: camera.CaptureSession): void {
7110  captureSession.stop().then(() => {
7111    console.info('Promise returned to indicate the session stop success.');
7112  }).catch((err: BusinessError) => {
7113    console.error(`Failed to stop the session, error code: ${err.code}.`);
7114  });
7115}
7116```
7117
7118### release<sup>(deprecated)</sup>
7119
7120release(callback: AsyncCallback\<void\>): void
7121
7122Releases this session. This API uses an asynchronous callback to return the result.
7123
7124> **NOTE**
7125>
7126> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Session.release](#release11-1) instead.
7127
7128**System capability**: SystemCapability.Multimedia.Camera.Core
7129
7130**Parameters**
7131
7132| Name     | Type                 | Mandatory| Description                |
7133| -------- | -------------------- | ---- | -------------------- |
7134| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
7135
7136**Error codes**
7137
7138For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
7139
7140| ID        | Error Message       |
7141| --------------- | --------------- |
7142| 7400201                |  Camera service fatal error.                           |
7143
7144**Example**
7145
7146```ts
7147import { BusinessError } from '@kit.BasicServicesKit';
7148
7149function releaseCaptureSession(captureSession: camera.CaptureSession): void {
7150  captureSession.release((err: BusinessError) => {
7151    if (err) {
7152      console.error(`Failed to release the CaptureSession instance, error code: ${err.code}.`);
7153      return;
7154    }
7155    console.info('Callback invoked to indicate that the CaptureSession instance is released successfully.');
7156  });
7157}
7158```
7159
7160### release<sup>(deprecated)</sup>
7161
7162release(): Promise\<void\>
7163
7164Releases this session. This API uses a promise to return the result.
7165
7166> **NOTE**
7167>
7168> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Session.release](#release11-2) instead.
7169
7170**System capability**: SystemCapability.Multimedia.Camera.Core
7171
7172**Return value**
7173
7174| Type           | Description                    |
7175| -------------- | ------------------------ |
7176| Promise\<void\> | Promise that returns no value.|
7177
7178**Error codes**
7179
7180For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
7181
7182| ID        | Error Message       |
7183| --------------- | --------------- |
7184| 7400201                |  Camera service fatal error.                           |
7185
7186**Example**
7187
7188```ts
7189import { BusinessError } from '@kit.BasicServicesKit';
7190
7191function releaseCaptureSession(captureSession: camera.CaptureSession): void {
7192  captureSession.release().then(() => {
7193    console.info('Promise returned to indicate that the CaptureSession instance is released successfully.');
7194  }).catch((err: BusinessError) => {
7195    console.error(`Failed to release the CaptureSession instance, error code: ${err.code}.`);
7196  });
7197}
7198```
7199
7200### hasFlash<sup>(deprecated)</sup>
7201
7202hasFlash(): boolean
7203
7204Checks whether the camera device has flash.
7205
7206> **NOTE**
7207>
7208> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Flash.hasFlash](#hasflash11) instead.
7209
7210**System capability**: SystemCapability.Multimedia.Camera.Core
7211
7212**Return value**
7213
7214| Type       | Description                         |
7215| ---------- | ----------------------------- |
7216| boolean    | Check result for whether the camera device has flash. **true** if it has flash, **false** otherwise. 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 hasFlash(captureSession: camera.CaptureSession): boolean {
7232  let status: boolean = false;
7233  try {
7234    status = captureSession.hasFlash();
7235  } catch (error) {
7236    // If the operation fails, error.code is returned and processed.
7237    let err = error as BusinessError;
7238    console.error(`The hasFlash call failed. error code: ${err.code}`);
7239  }
7240  return status;
7241}
7242```
7243
7244### isFlashModeSupported<sup>(deprecated)</sup>
7245
7246isFlashModeSupported(flashMode: FlashMode): boolean
7247
7248Checks whether a flash mode is supported.
7249
7250> **NOTE**
7251>
7252> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Flash.isFlashModeSupported](#isflashmodesupported11) instead.
7253
7254**System capability**: SystemCapability.Multimedia.Camera.Core
7255
7256**Parameters**
7257
7258| Name      | Type                    | Mandatory| Description                              |
7259| --------- | ----------------------- | ---- | --------------------------------- |
7260| flashMode | [FlashMode](#flashmode) | Yes  | Flash mode.                    |
7261
7262**Return value**
7263
7264| Type       | Description                         |
7265| ---------- | ----------------------------- |
7266| boolean    | Check result for the support of the flash mode. **true** if supported, **false** otherwise. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
7267
7268**Error codes**
7269
7270For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
7271
7272| ID        | Error Message       |
7273| --------------- | --------------- |
7274| 7400103                |  Session not config.                                   |
7275
7276**Example**
7277
7278```ts
7279import { BusinessError } from '@kit.BasicServicesKit';
7280
7281function isFlashModeSupported(captureSession: camera.CaptureSession): boolean {
7282  let status: boolean = false;
7283  try {
7284    status = captureSession.isFlashModeSupported(camera.FlashMode.FLASH_MODE_AUTO);
7285  } catch (error) {
7286    // If the operation fails, error.code is returned and processed.
7287    let err = error as BusinessError;
7288    console.error(`The isFlashModeSupported call failed. error code: ${err.code}`);
7289  }
7290  return status;
7291}
7292```
7293
7294### setFlashMode<sup>(deprecated)</sup>
7295
7296setFlashMode(flashMode: FlashMode): void
7297
7298Sets a flash mode.
7299
7300Before the setting, do the following checks:
7301
73021. Use [hasFlash](#hasflashdeprecated) to check whether the camera device has flash.
73032. Use [isFlashModeSupported](#isflashmodesupporteddeprecated) to check whether the camera device supports the flash mode.
7304
7305> **NOTE**
7306>
7307> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Flash.setFlashMode](#setflashmode11) instead.
7308
7309**System capability**: SystemCapability.Multimedia.Camera.Core
7310
7311**Parameters**
7312
7313| Name    | Type                   | Mandatory| Description                |
7314| --------- | ----------------------- | ---- | -------------------- |
7315| flashMode | [FlashMode](#flashmode) | Yes  | Flash mode.      |
7316
7317**Error codes**
7318
7319For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
7320
7321| ID        | Error Message       |
7322| --------------- | --------------- |
7323| 7400103                |  Session not config.                                   |
7324
7325**Example**
7326
7327```ts
7328import { BusinessError } from '@kit.BasicServicesKit';
7329
7330function setFlashMode(captureSession: camera.CaptureSession): void {
7331  try {
7332    captureSession.setFlashMode(camera.FlashMode.FLASH_MODE_AUTO);
7333  } catch (error) {
7334    // If the operation fails, error.code is returned and processed.
7335    let err = error as BusinessError;
7336    console.error(`The setFlashMode call failed. error code: ${err.code}`);
7337  }
7338}
7339```
7340
7341### getFlashMode<sup>(deprecated)</sup>
7342
7343getFlashMode(): FlashMode
7344
7345Obtains the flash mode in use.
7346
7347> **NOTE**
7348>
7349> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Flash.getFlashMode](#getflashmode11) instead.
7350
7351**System capability**: SystemCapability.Multimedia.Camera.Core
7352
7353**Return value**
7354
7355| Type       | Description                         |
7356| ---------- | ----------------------------- |
7357| [FlashMode](#flashmode)    | Flash mode obtained. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
7358
7359**Error codes**
7360
7361For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
7362
7363| ID        | Error Message       |
7364| --------------- | --------------- |
7365| 7400103                |  Session not config.                                   |
7366
7367**Example**
7368
7369```ts
7370import { BusinessError } from '@kit.BasicServicesKit';
7371
7372function getFlashMode(captureSession: camera.CaptureSession): camera.FlashMode | undefined {
7373  let flashMode: camera.FlashMode | undefined = undefined;
7374  try {
7375    flashMode = captureSession.getFlashMode();
7376  } catch (error) {
7377    // If the operation fails, error.code is returned and processed.
7378    let err = error as BusinessError;
7379    console.error(`The getFlashMode call failed.error code: ${err.code}`);
7380  }
7381  return flashMode;
7382}
7383```
7384
7385### isExposureModeSupported<sup>(deprecated)</sup>
7386
7387isExposureModeSupported(aeMode: ExposureMode): boolean
7388
7389Checks whether an exposure mode is supported.
7390
7391> **NOTE**
7392>
7393> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [AutoExposure.isExposureModeSupported](#isexposuremodesupported11) instead.
7394
7395**System capability**: SystemCapability.Multimedia.Camera.Core
7396
7397**Parameters**
7398
7399| Name     | Type                          | Mandatory | Description                          |
7400| -------- | -------------------------------| ---- | ----------------------------- |
7401| aeMode   | [ExposureMode](#exposuremode)  | Yes  | Exposure mode.                     |
7402
7403**Return value**
7404
7405| Type       | Description                         |
7406| ---------- | ----------------------------- |
7407| boolean    | Check result for the support of the exposure mode. **true** if supported, **false** otherwise. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
7408
7409**Error codes**
7410
7411For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
7412
7413| ID        | Error Message       |
7414| --------------- | --------------- |
7415| 7400103                |  Session not config.                                   |
7416
7417**Example**
7418
7419```ts
7420import { BusinessError } from '@kit.BasicServicesKit';
7421
7422function isExposureModeSupported(captureSession: camera.CaptureSession): boolean {
7423  let isSupported: boolean = false;
7424  try {
7425    isSupported = captureSession.isExposureModeSupported(camera.ExposureMode.EXPOSURE_MODE_LOCKED);
7426  } catch (error) {
7427    // If the operation fails, error.code is returned and processed.
7428    let err = error as BusinessError;
7429    console.error(`The isExposureModeSupported call failed. error code: ${err.code}`);
7430  }
7431  return isSupported;
7432}
7433```
7434
7435### getExposureMode<sup>(deprecated)</sup>
7436
7437getExposureMode(): ExposureMode
7438
7439Obtains the exposure mode in use.
7440
7441> **NOTE**
7442>
7443> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [AutoExposure.getExposureMode](#getexposuremode11) instead.
7444
7445**System capability**: SystemCapability.Multimedia.Camera.Core
7446
7447**Return value**
7448
7449| Type       | Description                         |
7450| ---------- | ----------------------------- |
7451| [ExposureMode](#exposuremode)    | Exposure mode obtained. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
7452
7453**Error codes**
7454
7455For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
7456
7457| ID        | Error Message       |
7458| --------------- | --------------- |
7459| 7400103                |  Session not config.                                   |
7460
7461**Example**
7462
7463```ts
7464import { BusinessError } from '@kit.BasicServicesKit';
7465
7466function getExposureMode(captureSession: camera.CaptureSession): camera.ExposureMode | undefined {
7467  let exposureMode: camera.ExposureMode | undefined = undefined;
7468  try {
7469    exposureMode = captureSession.getExposureMode();
7470  } catch (error) {
7471    // If the operation fails, error.code is returned and processed.
7472    let err = error as BusinessError;
7473    console.error(`The getExposureMode call failed. error code: ${err.code}`);
7474  }
7475  return exposureMode;
7476}
7477```
7478
7479### setExposureMode<sup>(deprecated)</sup>
7480
7481setExposureMode(aeMode: ExposureMode): void
7482
7483Sets an exposure mode. Before the setting, call [isExposureModeSupported](#isexposuremodesupporteddeprecated) to check whether the target exposure mode is supported.
7484
7485> **NOTE**
7486>
7487> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [AutoExposure.setExposureMode](#setexposuremode11) instead.
7488
7489**System capability**: SystemCapability.Multimedia.Camera.Core
7490
7491**Parameters**
7492
7493| Name     | Type                           | Mandatory| Description                   |
7494| -------- | -------------------------------| ---- | ----------------------- |
7495| aeMode   | [ExposureMode](#exposuremode)  | Yes  | Exposure mode.               |
7496
7497**Error codes**
7498
7499For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
7500
7501| ID        | Error Message       |
7502| --------------- | --------------- |
7503| 7400103                |  Session not config.                                   |
7504
7505**Example**
7506
7507```ts
7508import { BusinessError } from '@kit.BasicServicesKit';
7509
7510function setExposureMode(captureSession: camera.CaptureSession): void {
7511  try {
7512    captureSession.setExposureMode(camera.ExposureMode.EXPOSURE_MODE_LOCKED);
7513  } catch (error) {
7514    // If the operation fails, error.code is returned and processed.
7515    let err = error as BusinessError;
7516    console.error(`The setExposureMode call failed. error code: ${err.code}`);
7517  }
7518}
7519```
7520
7521### getMeteringPoint<sup>(deprecated)</sup>
7522
7523getMeteringPoint(): Point
7524
7525Obtains the metering point of the camera device.
7526
7527> **NOTE**
7528>
7529> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [AutoExposure.getMeteringPoint](#getmeteringpoint11) instead.
7530
7531**System capability**: SystemCapability.Multimedia.Camera.Core
7532
7533**Return value**
7534
7535| Type       | Description                         |
7536| ---------- | ----------------------------- |
7537| [Point](#point)    | Metering point obtained. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
7538
7539**Error codes**
7540
7541For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
7542
7543| ID        | Error Message       |
7544| --------------- | --------------- |
7545| 7400103                |  Session not config.                                   |
7546
7547**Example**
7548
7549```ts
7550import { BusinessError } from '@kit.BasicServicesKit';
7551
7552function getMeteringPoint(captureSession: camera.CaptureSession): camera.Point | undefined {
7553  let exposurePoint: camera.Point | undefined = undefined;
7554  try {
7555    exposurePoint = captureSession.getMeteringPoint();
7556  } catch (error) {
7557    // If the operation fails, error.code is returned and processed.
7558    let err = error as BusinessError;
7559    console.error(`The getMeteringPoint call failed. error code: ${err.code}`);
7560  }
7561  return exposurePoint;
7562}
7563```
7564
7565### setMeteringPoint<sup>(deprecated)</sup>
7566
7567setMeteringPoint(point: Point): void
7568
7569Sets the metering point, which is the center point of the metering rectangle.
7570
7571The 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}.
7572
7573The 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}.
7574
7575> **NOTE**
7576>
7577> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [AutoExposure.setMeteringPoint](#setmeteringpoint11) instead.
7578
7579**System capability**: SystemCapability.Multimedia.Camera.Core
7580
7581**Parameters**
7582
7583| Name          | Type                           | Mandatory| Description                |
7584| ------------- | -------------------------------| ---- | ------------------- |
7585| 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.            |
7586
7587**Error codes**
7588
7589For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
7590
7591| ID        | Error Message       |
7592| --------------- | --------------- |
7593| 7400103                |  Session not config.                                   |
7594
7595**Example**
7596
7597```ts
7598import { BusinessError } from '@kit.BasicServicesKit';
7599
7600function setMeteringPoint(captureSession: camera.CaptureSession): void {
7601  const point: camera.Point = {x: 1, y: 1};
7602  try {
7603    captureSession.setMeteringPoint(point);
7604  } catch (error) {
7605    // If the operation fails, error.code is returned and processed.
7606    let err = error as BusinessError;
7607    console.error(`The setMeteringPoint call failed. error code: ${err.code}`);
7608  }
7609}
7610```
7611
7612### getExposureBiasRange<sup>(deprecated)</sup>
7613
7614getExposureBiasRange(): Array\<number\>
7615
7616Obtains the exposure compensation values of the camera device.
7617
7618> **NOTE**
7619>
7620> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [AutoExposure.getExposureBiasRange](#getexposurebiasrange11) instead.
7621
7622**System capability**: SystemCapability.Multimedia.Camera.Core
7623
7624**Return value**
7625
7626| Type       | Description                         |
7627| ---------- | ----------------------------- |
7628| Array\<number\>   | Array of compensation values. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
7629
7630**Error codes**
7631
7632For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
7633
7634| ID        | Error Message       |
7635| --------------- | --------------- |
7636| 7400103                |  Session not config.                                   |
7637
7638**Example**
7639
7640```ts
7641import { BusinessError } from '@kit.BasicServicesKit';
7642
7643function getExposureBiasRange(captureSession: camera.CaptureSession): Array<number> {
7644  let biasRangeArray: Array<number> = [];
7645  try {
7646    biasRangeArray = captureSession.getExposureBiasRange();
7647  } catch (error) {
7648    // If the operation fails, error.code is returned and processed.
7649    let err = error as BusinessError;
7650    console.error(`The getExposureBiasRange call failed. error code: ${err.code}`);
7651  }
7652  return biasRangeArray;
7653}
7654```
7655
7656### setExposureBias<sup>(deprecated)</sup>
7657
7658setExposureBias(exposureBias: number): void
7659
7660Sets an exposure compensation value (EV).
7661
7662Before the setting, you are advised to use [getExposureBiasRange](#getexposurebiasrangedeprecated) to obtain the supported values.
7663
7664> **NOTE**
7665>
7666> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [AutoExposure.setExposureBias](#setexposurebias11) instead.
7667
7668**System capability**: SystemCapability.Multimedia.Camera.Core
7669
7670**Parameters**
7671
7672| Name    | Type                           | Mandatory | Description                                                                                                                                                                                   |
7673| -------- | -------------------------------|-----|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
7674| 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.|
7675
7676**Error codes**
7677
7678For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
7679
7680| ID        | Error Message       |
7681| --------------- | --------------- |
7682| 7400103                |  Session not config.                                   |
7683
7684**Example**
7685
7686```ts
7687import { BusinessError } from '@kit.BasicServicesKit';
7688
7689function setExposureBias(captureSession: camera.CaptureSession, biasRangeArray: Array<number>): void {
7690  if (biasRangeArray && biasRangeArray.length > 0) {
7691    let exposureBias = biasRangeArray[0];
7692    try {
7693      captureSession.setExposureBias(exposureBias);
7694    } catch (error) {
7695      // If the operation fails, error.code is returned and processed.
7696      let err = error as BusinessError;
7697      console.error(`The setExposureBias call failed. error code: ${err.code}`);
7698    }
7699  }
7700}
7701```
7702
7703### getExposureValue<sup>(deprecated)</sup>
7704
7705getExposureValue(): number
7706
7707Obtains the exposure value in use.
7708
7709> **NOTE**
7710>
7711> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [AutoExposure.getExposureValue](#getexposurevalue11) instead.
7712
7713**System capability**: SystemCapability.Multimedia.Camera.Core
7714
7715**Return value**
7716
7717| Type       | Description                         |
7718| ---------- | ----------------------------- |
7719| 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.|
7720
7721**Error codes**
7722
7723For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
7724
7725| ID        | Error Message       |
7726| --------------- | --------------- |
7727| 7400103                |  Session not config.                                   |
7728
7729**Example**
7730
7731```ts
7732import { BusinessError } from '@kit.BasicServicesKit';
7733
7734function getExposureValue(captureSession: camera.CaptureSession): number {
7735  const invalidValue: number = -1;
7736  let exposureValue: number = invalidValue;
7737  try {
7738    exposureValue = captureSession.getExposureValue();
7739  } catch (error) {
7740    // If the operation fails, error.code is returned and processed.
7741    let err = error as BusinessError;
7742    console.error(`The getExposureValue call failed. error code: ${err.code}`);
7743  }
7744  return exposureValue;
7745}
7746```
7747
7748### isFocusModeSupported<sup>(deprecated)</sup>
7749
7750isFocusModeSupported(afMode: FocusMode): boolean
7751
7752Checks whether a focus mode is supported.
7753
7754> **NOTE**
7755>
7756> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Focus.isFocusModeSupported](#isfocusmodesupported11) instead.
7757
7758**System capability**: SystemCapability.Multimedia.Camera.Core
7759
7760**Parameters**
7761
7762| Name     | Type                    | Mandatory| Description                             |
7763| -------- | ----------------------- | ---- | -------------------------------- |
7764| afMode   | [FocusMode](#focusmode) | Yes  | Focus mode.                   |
7765
7766**Return value**
7767
7768| Type       | Description                         |
7769| ---------- | ----------------------------- |
7770| boolean    | Check result for the support of the focus mode. **true** if supported, **false** otherwise. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
7771
7772**Error codes**
7773
7774For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
7775
7776| ID        | Error Message       |
7777| --------------- | --------------- |
7778| 7400103                |  Session not config.                                   |
7779
7780**Example**
7781
7782```ts
7783import { BusinessError } from '@kit.BasicServicesKit';
7784
7785function isFocusModeSupported(captureSession: camera.CaptureSession): boolean {
7786  let status: boolean = false;
7787  try {
7788    status = captureSession.isFocusModeSupported(camera.FocusMode.FOCUS_MODE_AUTO);
7789  } catch (error) {
7790    // If the operation fails, error.code is returned and processed.
7791    let err = error as BusinessError;
7792    console.error(`The isFocusModeSupported call failed. error code: ${err.code}`);
7793  }
7794  return status;
7795}
7796```
7797
7798### setFocusMode<sup>(deprecated)</sup>
7799
7800setFocusMode(afMode: FocusMode): void
7801
7802Sets a focus mode.
7803
7804Before the setting, call [isFocusModeSupported](#isfocusmodesupporteddeprecated) to check whether the focus mode is supported.
7805
7806> **NOTE**
7807>
7808> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Focus.setFocusMode](#setfocusmode11) instead.
7809
7810**System capability**: SystemCapability.Multimedia.Camera.Core
7811
7812**Parameters**
7813
7814| Name     | Type                    | Mandatory| Description                |
7815| -------- | ----------------------- | ---- | ------------------- |
7816| afMode   | [FocusMode](#focusmode) | Yes  | Focus mode.      |
7817
7818**Error codes**
7819
7820For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
7821
7822| ID        | Error Message       |
7823| --------------- | --------------- |
7824| 7400103                |  Session not config.                                   |
7825
7826**Example**
7827
7828```ts
7829import { BusinessError } from '@kit.BasicServicesKit';
7830
7831function setFocusMode(captureSession: camera.CaptureSession): void {
7832  try {
7833    captureSession.setFocusMode(camera.FocusMode.FOCUS_MODE_AUTO);
7834  } catch (error) {
7835    // If the operation fails, error.code is returned and processed.
7836    let err = error as BusinessError;
7837    console.error(`The setFocusMode call failed. error code: ${err.code}`);
7838  }
7839}
7840```
7841
7842### getFocusMode<sup>(deprecated)</sup>
7843
7844getFocusMode(): FocusMode
7845
7846Obtains the focus mode in use.
7847
7848> **NOTE**
7849>
7850> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Focus.getFocusMode](#getfocusmode11) instead.
7851
7852**System capability**: SystemCapability.Multimedia.Camera.Core
7853
7854**Return value**
7855
7856| Type       | Description                         |
7857| ---------- | ----------------------------- |
7858| [FocusMode](#focusmode)   | Focus mode obtained. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
7859
7860**Error codes**
7861
7862For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
7863
7864| ID        | Error Message       |
7865| --------------- | --------------- |
7866| 7400103                |  Session not config.                                   |
7867
7868**Example**
7869
7870```ts
7871import { BusinessError } from '@kit.BasicServicesKit';
7872
7873function getFocusMode(captureSession: camera.CaptureSession): camera.FocusMode | undefined {
7874  let afMode: camera.FocusMode | undefined = undefined;
7875  try {
7876    afMode = captureSession.getFocusMode();
7877  } catch (error) {
7878    // If the operation fails, error.code is returned and processed.
7879    let err = error as BusinessError;
7880    console.error(`The getFocusMode call failed. error code: ${err.code}`);
7881  }
7882  return afMode;
7883}
7884```
7885
7886### setFocusPoint<sup>(deprecated)</sup>
7887
7888setFocusPoint(point: Point): void
7889
7890Sets 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}.
7891
7892The 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}.
7893
7894> **NOTE**
7895>
7896> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Focus.setFocusPoint](#setfocuspoint11) instead.
7897
7898**System capability**: SystemCapability.Multimedia.Camera.Core
7899
7900**Parameters**
7901
7902| Name  | Type                    | Mandatory | Description                |
7903|-------| ----------------------- |-----| ------------------- |
7904| 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.  |
7905
7906**Error codes**
7907
7908For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
7909
7910| ID        | Error Message       |
7911| --------------- | --------------- |
7912| 7400103                |  Session not config.                                   |
7913
7914**Example**
7915
7916```ts
7917import { BusinessError } from '@kit.BasicServicesKit';
7918
7919function setFocusPoint(captureSession: camera.CaptureSession): void {
7920  const focusPoint: camera.Point = {x: 1, y: 1};
7921  try {
7922    captureSession.setFocusPoint(focusPoint);
7923  } catch (error) {
7924    // If the operation fails, error.code is returned and processed.
7925    let err = error as BusinessError;
7926    console.error(`The setFocusPoint call failed. error code: ${err.code}`);
7927  }
7928}
7929```
7930
7931### getFocusPoint<sup>(deprecated)</sup>
7932
7933getFocusPoint(): Point
7934
7935Obtains the focal point of the camera device.
7936
7937> **NOTE**
7938>
7939> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Focus.getFocusPoint](#getfocuspoint11) instead.
7940
7941**System capability**: SystemCapability.Multimedia.Camera.Core
7942
7943**Return value**
7944
7945| Type       | Description                         |
7946| ---------- | ----------------------------- |
7947| [Point](#point)    | Focal point obtained. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
7948
7949**Error codes**
7950
7951For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
7952
7953| ID        | Error Message       |
7954| --------------- | --------------- |
7955| 7400103                |  Session not config.                                   |
7956
7957**Example**
7958
7959```ts
7960import { BusinessError } from '@kit.BasicServicesKit';
7961
7962function getFocusPoint(captureSession: camera.CaptureSession): camera.Point | undefined {
7963  let point: camera.Point | undefined = undefined;
7964  try {
7965    point = captureSession.getFocusPoint();
7966  } catch (error) {
7967    // If the operation fails, error.code is returned and processed.
7968    let err = error as BusinessError;
7969    console.error(`The getFocusPoint call failed. error code: ${err.code}`);
7970  }
7971  return point;
7972}
7973```
7974
7975### getFocalLength<sup>(deprecated)</sup>
7976
7977getFocalLength(): number
7978
7979Obtains the focal length of the camera device.
7980
7981> **NOTE**
7982>
7983> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Focus.getFocalLength](#getfocallength11) instead.
7984
7985**System capability**: SystemCapability.Multimedia.Camera.Core
7986
7987**Return value**
7988
7989| Type       | Description                         |
7990| ---------- | ----------------------------- |
7991| number    | Focal length obtained. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
7992
7993**Error codes**
7994
7995For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
7996
7997| ID        | Error Message       |
7998| --------------- | --------------- |
7999| 7400103                |  Session not config.                                   |
8000
8001**Example**
8002
8003```ts
8004import { BusinessError } from '@kit.BasicServicesKit';
8005
8006function getFocalLength(captureSession: camera.CaptureSession): number {
8007  const invalidValue: number = -1;
8008  let focalLength: number = invalidValue;
8009  try {
8010    focalLength = captureSession.getFocalLength();
8011  } catch (error) {
8012    // If the operation fails, error.code is returned and processed.
8013    let err = error as BusinessError;
8014    console.error(`The getFocalLength call failed. error code: ${err.code}`);
8015  }
8016  return focalLength;
8017}
8018```
8019
8020### getZoomRatioRange<sup>(deprecated)</sup>
8021
8022getZoomRatioRange(): Array\<number\>
8023
8024Obtains the supported zoom ratio range.
8025
8026> **NOTE**
8027>
8028> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Zoom.getZoomRatioRange](#getzoomratiorange11) instead.
8029
8030**System capability**: SystemCapability.Multimedia.Camera.Core
8031
8032**Return value**
8033
8034| Type       | Description                         |
8035| ---------- | ----------------------------- |
8036| Array\<number\>   | Array containing the minimum and maximum zoom ratios. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
8037
8038**Error codes**
8039
8040For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
8041
8042| ID        | Error Message       |
8043| --------------- | --------------- |
8044| 7400103                |  Session not config.                                   |
8045
8046**Example**
8047
8048```ts
8049import { BusinessError } from '@kit.BasicServicesKit';
8050
8051function getZoomRatioRange(captureSession: camera.CaptureSession): Array<number> {
8052  let zoomRatioRange: Array<number> = [];
8053  try {
8054    zoomRatioRange = captureSession.getZoomRatioRange();
8055  } catch (error) {
8056    // If the operation fails, error.code is returned and processed.
8057    let err = error as BusinessError;
8058    console.error(`The getZoomRatioRange call failed. error code: ${err.code}`);
8059  }
8060  return zoomRatioRange;
8061}
8062```
8063
8064### setZoomRatio<sup>(deprecated)</sup>
8065
8066setZoomRatio(zoomRatio: number): void
8067
8068Sets a zoom ratio, with a maximum precision of two decimal places.
8069
8070> **NOTE**
8071>
8072> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Zoom.setZoomRatio](#setzoomratio11) instead.
8073
8074**System capability**: SystemCapability.Multimedia.Camera.Core
8075
8076**Parameters**
8077
8078| Name      | Type                 | Mandatory | Description                |
8079| --------- | -------------------- |-----| ------------------- |
8080| 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.|
8081
8082**Error codes**
8083
8084For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
8085
8086| ID        | Error Message       |
8087| --------------- | --------------- |
8088| 7400103                |  Session not config.                                   |
8089
8090**Example**
8091
8092```ts
8093import { BusinessError } from '@kit.BasicServicesKit';
8094
8095function setZoomRatio(captureSession: camera.CaptureSession, zoomRatioRange: Array<number>): void {
8096  if (zoomRatioRange === undefined || zoomRatioRange.length <= 0) {
8097    return;
8098  }
8099  let zoomRatio = zoomRatioRange[0];
8100  try {
8101    captureSession.setZoomRatio(zoomRatio);
8102  } catch (error) {
8103    // If the operation fails, error.code is returned and processed.
8104    let err = error as BusinessError;
8105    console.error(`The setZoomRatio call failed. error code: ${err.code}`);
8106  }
8107}
8108```
8109
8110### getZoomRatio<sup>(deprecated)</sup>
8111
8112getZoomRatio(): number
8113
8114Obtains the zoom ratio in use.
8115
8116> **NOTE**
8117>
8118> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Zoom.getZoomRatio](#getzoomratio11) instead.
8119
8120**System capability**: SystemCapability.Multimedia.Camera.Core
8121
8122**Return value**
8123
8124| Type       | Description                         |
8125| ---------- | ----------------------------- |
8126| number    | Zoom ratio obtained. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
8127
8128**Error codes**
8129
8130For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
8131
8132| ID        | Error Message       |
8133| --------------- | --------------- |
8134| 7400103                |  Session not config.                                   |
8135
8136**Example**
8137
8138```ts
8139import { BusinessError } from '@kit.BasicServicesKit';
8140
8141function getZoomRatio(captureSession: camera.CaptureSession): number {
8142  const invalidValue: number = -1;
8143  let zoomRatio: number = invalidValue;
8144  try {
8145    zoomRatio = captureSession.getZoomRatio();
8146  } catch (error) {
8147    // If the operation fails, error.code is returned and processed.
8148    let err = error as BusinessError;
8149    console.error(`The getZoomRatio call failed. error code: ${err.code}`);
8150  }
8151  return zoomRatio;
8152}
8153```
8154
8155### isVideoStabilizationModeSupported<sup>(deprecated)</sup>
8156
8157isVideoStabilizationModeSupported(vsMode: VideoStabilizationMode): boolean
8158
8159Checks whether a video stabilization mode is supported.
8160
8161> **NOTE**
8162>
8163> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Stabilization.isVideoStabilizationModeSupported](#isvideostabilizationmodesupported11) instead.
8164
8165**System capability**: SystemCapability.Multimedia.Camera.Core
8166
8167**Parameters**
8168
8169| Name     | Type                                             | Mandatory| Description                            |
8170| -------- | ------------------------------------------------- | ---- | ------------------------------ |
8171| 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.             |
8172
8173**Return value**
8174
8175| Type       | Description                         |
8176| ---------- | ----------------------------- |
8177| boolean    | Check result for the support of the video stabilization mode. **true** if supported, **false** otherwise. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
8178
8179**Error codes**
8180
8181For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
8182
8183| ID        | Error Message       |
8184| --------------- | --------------- |
8185| 7400103                |  Session not config.                                   |
8186
8187**Example**
8188
8189```ts
8190import { BusinessError } from '@kit.BasicServicesKit';
8191
8192function isVideoStabilizationModeSupported(captureSession: camera.CaptureSession): boolean {
8193  let isSupported: boolean = false;
8194  try {
8195    isSupported = captureSession.isVideoStabilizationModeSupported(camera.VideoStabilizationMode.OFF);
8196  } catch (error) {
8197    // If the operation fails, error.code is returned and processed.
8198    let err = error as BusinessError;
8199    console.error(`The isVideoStabilizationModeSupported call failed. error code: ${err.code}`);
8200  }
8201  return isSupported;
8202}
8203```
8204
8205### getActiveVideoStabilizationMode<sup>(deprecated)</sup>
8206
8207getActiveVideoStabilizationMode(): VideoStabilizationMode
8208
8209Obtains the video stabilization mode in use.
8210
8211> **NOTE**
8212>
8213> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Stabilization.getActiveVideoStabilizationMode](#getactivevideostabilizationmode11) instead.
8214
8215**System capability**: SystemCapability.Multimedia.Camera.Core
8216
8217**Return value**
8218
8219| Type       | Description                         |
8220| ---------- | ----------------------------- |
8221| [VideoStabilizationMode](#videostabilizationmode)    | Video stabilization mode obtained. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
8222
8223**Error codes**
8224
8225For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
8226
8227| ID        | Error Message       |
8228| --------------- | --------------- |
8229| 7400103                |  Session not config.                                   |
8230
8231**Example**
8232
8233```ts
8234import { BusinessError } from '@kit.BasicServicesKit';
8235
8236function getActiveVideoStabilizationMode(captureSession: camera.CaptureSession): camera.VideoStabilizationMode | undefined {
8237  let vsMode: camera.VideoStabilizationMode | undefined = undefined;
8238  try {
8239    vsMode = captureSession.getActiveVideoStabilizationMode();
8240  } catch (error) {
8241    // If the operation fails, error.code is returned and processed.
8242    let err = error as BusinessError;
8243    console.error(`The getActiveVideoStabilizationMode call failed. error code: ${err.code}`);
8244  }
8245  return vsMode;
8246}
8247```
8248
8249### setVideoStabilizationMode<sup>(deprecated)</sup>
8250
8251setVideoStabilizationMode(mode: VideoStabilizationMode): void
8252
8253Sets a video stabilization mode. Before the setting, call [isVideoStabilizationModeSupported](#isvideostabilizationmodesupporteddeprecated) to check whether the target video stabilization mode is supported.
8254
8255> **NOTE**
8256>
8257> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [Stabilization.setVideoStabilizationMode](#setvideostabilizationmode11) instead.
8258
8259**System capability**: SystemCapability.Multimedia.Camera.Core
8260
8261**Parameters**
8262
8263| Name     | Type                                             | Mandatory| Description                   |
8264| -------- | ------------------------------------------------- | ---- | --------------------- |
8265| 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.  |
8266
8267**Error codes**
8268
8269For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
8270
8271| ID        | Error Message       |
8272| --------------- | --------------- |
8273| 7400103                |  Session not config.                                   |
8274
8275**Example**
8276
8277```ts
8278import { BusinessError } from '@kit.BasicServicesKit';
8279
8280function setVideoStabilizationMode(captureSession: camera.CaptureSession): void {
8281  try {
8282    captureSession.setVideoStabilizationMode(camera.VideoStabilizationMode.OFF);
8283  } catch (error) {
8284    // If the operation fails, error.code is returned and processed.
8285    let err = error as BusinessError;
8286    console.error(`The setVideoStabilizationMode call failed. error code: ${err.code}`);
8287  }
8288}
8289```
8290
8291### on('focusStateChange')<sup>(deprecated)</sup>
8292
8293on(type: 'focusStateChange', callback: AsyncCallback\<FocusState\>): void
8294
8295Subscribes to focus state change events. This API uses an asynchronous callback to return the result.
8296
8297> **NOTE**
8298>
8299> 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.
8300>
8301> Currently, you cannot use **off()** to unregister the callback in the callback method of **on()**.
8302
8303**System capability**: SystemCapability.Multimedia.Camera.Core
8304
8305**Parameters**
8306
8307| Name    | Type                                     | Mandatory| Description                      |
8308| -------- | ----------------------------------------- | ---- | ------------------------ |
8309| 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.|
8310| callback | AsyncCallback\<[FocusState](#focusstate)\> | Yes  | Callback used to return the focus state change. |
8311
8312**Example**
8313
8314```ts
8315import { BusinessError } from '@kit.BasicServicesKit';
8316
8317function registerFocusStateChange(captureSession: camera.CaptureSession): void {
8318  captureSession.on('focusStateChange', (err: BusinessError, focusState: camera.FocusState) => {
8319    if (err !== undefined && err.code !== 0) {
8320      console.error(`Callback Error, errorCode: ${err.code}`);
8321      return;
8322    }
8323    console.info(`Focus state: ${focusState}`);
8324  });
8325}
8326```
8327
8328### off('focusStateChange')<sup>(deprecated)</sup>
8329
8330off(type: 'focusStateChange', callback?: AsyncCallback\<FocusState\>): void
8331
8332Unsubscribes from focus state change events.
8333
8334> **NOTE**
8335>
8336> 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.
8337
8338**System capability**: SystemCapability.Multimedia.Camera.Core
8339
8340**Parameters**
8341
8342| Name    | Type                                     | Mandatory| Description                      |
8343| -------- | ----------------------------------------- | ---- | ------------------------ |
8344| type     | string                                    | Yes  | Event type. The value is fixed at **'focusStateChange'**. The event can be listened for when a session is created.|
8345| 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.|
8346
8347**Example**
8348
8349```ts
8350function unregisterFocusStateChange(captureSession: camera.CaptureSession): void {
8351  captureSession.off('focusStateChange');
8352}
8353```
8354
8355### on('error')<sup>(deprecated)</sup>
8356
8357on(type: 'error', callback: ErrorCallback): void
8358
8359Subscribes to CaptureSession error events. This API uses an asynchronous callback to return the result.
8360
8361> **NOTE**
8362>
8363> Currently, you cannot use **off()** to unregister the callback in the callback method of **on()**.
8364
8365> **NOTE**
8366>
8367> 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.
8368
8369**System capability**: SystemCapability.Multimedia.Camera.Core
8370
8371**Parameters**
8372
8373| Name    | Type                                                                      | Mandatory| Description                          |
8374| -------- |--------------------------------------------------------------------------| ---- | ------------------------------ |
8375| 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).|
8376| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback) | Yes  | Callback used to return an error code defined in [CameraErrorCode](#cameraerrorcode).       |
8377
8378**Example**
8379
8380```ts
8381import { BusinessError } from '@kit.BasicServicesKit';
8382
8383function registerCaptureSessionError(captureSession: camera.CaptureSession): void {
8384  captureSession.on('error', (error: BusinessError) => {
8385    console.error(`Capture session error code: ${error.code}`);
8386  });
8387}
8388```
8389
8390### off('error')<sup>(deprecated)</sup>
8391
8392off(type: 'error', callback?: ErrorCallback): void
8393
8394Unsubscribes from CaptureSession error events. This API uses a callback to return the result.
8395
8396> **NOTE**
8397>
8398> 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.
8399
8400**System capability**: SystemCapability.Multimedia.Camera.Core
8401
8402**Parameters**
8403
8404| Name    | Type                                                         | Mandatory| Description                          |
8405| -------- | ----------------------------------------------------------- | ---- | ------------------------------ |
8406| type     | string                                                      | Yes  | Event type. The value is fixed at **'error'**. The event can be listened for when a session is created.|
8407| 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.|
8408
8409**Example**
8410
8411```ts
8412function unregisterCaptureSessionError(captureSession: camera.CaptureSession): void {
8413  captureSession.off('error');
8414}
8415```
8416## ColorManagementQuery<sup>12+</sup>
8417
8418Provides the APIs for color space query.
8419
8420### getSupportedColorSpaces<sup>12+</sup>
8421
8422getSupportedColorSpaces(): Array\<colorSpaceManager.ColorSpace\>
8423
8424Obtains the supported color spaces.
8425
8426**Atomic service API**: This API can be used in atomic services since API version 19.
8427
8428**System capability**: SystemCapability.Multimedia.Camera.Core
8429
8430**Return value**
8431
8432| Type                                            | Description                          |
8433| ----------------------------------------------- | ---------------------------- |
8434| Array<[colorSpaceManager.ColorSpace](../apis-arkgraphics2d/js-apis-colorSpaceManager.md#colorspace)>| Array of color spaces supported.    |
8435
8436**Example**
8437
8438```ts
8439import { BusinessError } from '@kit.BasicServicesKit';
8440import { colorSpaceManager } from '@kit.ArkGraphics2D';
8441
8442function getSupportedColorSpaces(session: camera.PhotoSession): Array<colorSpaceManager.ColorSpace> {
8443  let colorSpaces: Array<colorSpaceManager.ColorSpace> = [];
8444  colorSpaces = session.getSupportedColorSpaces();
8445  return colorSpaces;
8446}
8447```
8448## ColorManagement<sup>12+</sup>
8449
8450ColorManagement extends [ColorManagementQuery](#colormanagementquery12).
8451
8452It implements color space management. It inherits from [ColorManagementQuery](#colormanagementquery12).
8453
8454### setColorSpace<sup>12+</sup>
8455
8456setColorSpace(colorSpace: colorSpaceManager.ColorSpace): void
8457
8458Sets a color space. Before the setting, call [getSupportedColorSpaces](#getsupportedcolorspaces12) to obtain the supported color spaces.
8459
8460**P3 and HDR Imaging**
8461
8462An application can deliver different color space parameters to declare its support for P3 and HDR.
8463
8464If an application does not proactively set the color space, SDR is used by default in photo capture scenarios.
8465
8466In photo mode, P3 can be directly supported by setting the HDR effect.
8467
8468For details about how to enable the HDR effect and set the color space in different modes, see the following table.
8469
8470**Recording Mode**
8471
8472| SDR/HRD Photo Capture        | CameraFormat             | ColorSpace       |
8473|--------------------|--------------------------|------------------|
8474| SDR                | CAMERA_FORMAT_YUV_420_SP | BT709_LIMIT      |
8475| HDR_VIVID          | CAMERA_FORMAT_YCRCB_P010 | BT2020_HLG_LIMIT |
8476
8477**Photo Mode**
8478
8479| SDR/HRD Photo Capture       | ColorSpace |
8480|--------------------|------------|
8481| SDR(Default)       | SRGB       |
8482| HDR                | DISPLAY_P3 |
8483
8484**Atomic service API**: This API can be used in atomic services since API version 19.
8485
8486**System capability**: SystemCapability.Multimedia.Camera.Core
8487
8488**Parameters**
8489
8490| Name        | Type                | Mandatory| Description                     |
8491| ------------ |---------------------- | -- | -------------------------- |
8492| colorSpace | [colorSpaceManager.ColorSpace](../apis-arkgraphics2d/js-apis-colorSpaceManager.md#colorspace)  | Yes| Color space, which is obtained by calling [getSupportedColorSpaces](#getsupportedcolorspaces12).  |
8493
8494**Error codes**
8495
8496For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
8497
8498| ID        | Error Message       |
8499| --------------- | --------------- |
8500| 7400101         |  Parameter missing or parameter type incorrect.     |
8501| 7400102         |  The colorSpace does not match the format.     |
8502| 7400103         |  Session not config.                           |
8503| 7400201         |  Camera service fatal error.                   |
8504
8505**Example**
8506
8507```ts
8508import { BusinessError } from '@kit.BasicServicesKit';
8509import { colorSpaceManager } from '@kit.ArkGraphics2D';
8510
8511function setColorSpace(session: camera.PhotoSession, colorSpaces: Array<colorSpaceManager.ColorSpace>): void {
8512  if (colorSpaces === undefined || colorSpaces.length <= 0) {
8513    return;
8514  }
8515  try {
8516    session.setColorSpace(colorSpaces[0]);
8517  } catch (error) {
8518    let err = error as BusinessError;
8519    console.error(`The setColorSpace call failed, error code: ${err.code}`);
8520  }
8521}
8522```
8523
8524### getActiveColorSpace<sup>12+</sup>
8525
8526getActiveColorSpace(): colorSpaceManager.ColorSpace
8527
8528Obtains the color space in use.
8529
8530**Atomic service API**: This API can be used in atomic services since API version 19.
8531
8532**System capability**: SystemCapability.Multimedia.Camera.Core
8533
8534**Return value**
8535
8536| Type                                            | Description                          |
8537| ----------------------------------------------- | ---------------------------- |
8538| [colorSpaceManager.ColorSpace](../apis-arkgraphics2d/js-apis-colorSpaceManager.md#colorspace)               | Color space.               |
8539
8540**Error codes**
8541
8542For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
8543
8544| ID        | Error Message       |
8545| --------------- | --------------- |
8546| 7400103                |  Session not config.                                   |
8547
8548**Example**
8549
8550```ts
8551import { BusinessError } from '@kit.BasicServicesKit';
8552import { colorSpaceManager } from '@kit.ArkGraphics2D';
8553
8554function getActiveColorSpace(session: camera.PhotoSession): colorSpaceManager.ColorSpace | undefined {
8555  let colorSpace: colorSpaceManager.ColorSpace | undefined = undefined;
8556  try {
8557    colorSpace = session.getActiveColorSpace();
8558  } catch (error) {
8559    let err = error as BusinessError;
8560    console.error(`The getActiveColorSpace call failed. error code: ${err.code}`);
8561  }
8562  return colorSpace;
8563}
8564```
8565
8566## AutoDeviceSwitchQuery<sup>13+</sup>
8567
8568A class for checking whether a device supports automatic camera switch.
8569
8570### isAutoDeviceSwitchSupported<sup>13+</sup>
8571
8572isAutoDeviceSwitchSupported(): boolean
8573
8574Checks whether the device supports automatic camera switch.
8575
8576**Atomic service API**: This API can be used in atomic services since API version 19.
8577
8578**System capability**: SystemCapability.Multimedia.Camera.Core
8579
8580**Return value**
8581
8582| Type                                            | Description         |
8583| ----------------------------------------------- |-------------|
8584| boolean               | Check result for the support of automatic camera switch. **true** if supported, **false** otherwise.|
8585
8586**Example**
8587
8588```ts
8589import { BusinessError } from '@kit.BasicServicesKit';
8590
8591function isAutoDeviceSwitchSupported(session: camera.PhotoSession): boolean {
8592  let isSupported = false;
8593  isSupported = session.isAutoDeviceSwitchSupported();
8594  return isSupported;
8595}
8596```
8597
8598## AutoDeviceSwitch<sup>13+</sup>
8599
8600AutoDeviceSwitch extends [AutoDeviceSwitchQuery](#autodeviceswitchquery13).
8601
8602It is a class used to enable or disable automatic camera switch. This class inherits from [AutoDeviceSwitchQuery](#autodeviceswitchquery13).
8603
8604It 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.
8605
8606### enableAutoDeviceSwitch<sup>13+</sup>
8607
8608enableAutoDeviceSwitch(enabled: boolean): void
8609
8610Enables or disables automatic camera switch. You can use [isAutoDeviceSwitchSupported](#isautodeviceswitchsupported13) to check whether the device supports automatic camera switch.
8611
8612> **NOTE**
8613>
8614> This API is used only for foldable devices with multiple front cameras. In different fold states, the system can automatically switch to an available front camera. It does not enable automatic switching between front and rear cameras.
8615
8616**Atomic service API**: This API can be used in atomic services since API version 19.
8617
8618**System capability**: SystemCapability.Multimedia.Camera.Core
8619
8620**Parameters**
8621
8622| Name        | Type | Mandatory| Description |
8623| ----------- |---------------------- |---| -------------------------- |
8624| enabled | boolean  | Yes| Whether to enable automatic camera switch. **true** to enable, **false** otherwise.  |
8625
8626**Error codes**
8627
8628For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
8629
8630| ID  | Error Message                                                                                                                                      |
8631|---------|------------------------------------------------------------------------------------------------------------------------------------------------|
8632| 7400101 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameters verification failed. |
8633| 7400102 | Operation not allowed.                                                                                                                         |
8634| 7400103 | Session not config.                                                                                                                            |
8635| 7400201 | Camera service fatal error.                                                                                                                    |
8636
8637**Example**
8638
8639```ts
8640import { BusinessError } from '@kit.BasicServicesKit';
8641
8642function enableAutoDeviceSwitch(session: camera.PhotoSession, isEnable: boolean): void {
8643  try {
8644    session.enableAutoDeviceSwitch(isEnable);
8645  } catch (error) {
8646    let err = error as BusinessError;
8647    console.error(`The enableAutoDeviceSwitch call failed, error code: ${err.code}`);
8648  }
8649}
8650```
8651
8652## PreconfigType<sup>12+</sup>
8653
8654Enumerates the preconfigured resolution types.
8655
8656**Atomic service API**: This API can be used in atomic services since API version 19.
8657
8658**System capability**: SystemCapability.Multimedia.Camera.Core
8659
8660| Name                     | Value| Description        |
8661|-------------------------|---|------------|
8662| PRECONFIG_720P          | 0 | 720p resolution.  |
8663| PRECONFIG_1080P         | 1 | 1080p resolution. |
8664| PRECONFIG_4K            | 2 | 4K resolution.    |
8665| PRECONFIG_HIGH_QUALITY  | 3 | High-quality resolution.   |
8666
8667## PreconfigRatio<sup>12+</sup>
8668
8669Enumerates the preconfigured aspect ratios.
8670
8671**Atomic service API**: This API can be used in atomic services since API version 19.
8672
8673**System capability**: SystemCapability.Multimedia.Camera.Core
8674
8675| Name                      | Value| Description     |
8676|--------------------------|---|---------|
8677| PRECONFIG_RATIO_1_1      | 0 | 1:1 aspect ratio. |
8678| PRECONFIG_RATIO_4_3      | 1 | 4:3 aspect ratio. |
8679| PRECONFIG_RATIO_16_9     | 2 | 16:9 aspect ratio.|
8680
8681## PhotoSession<sup>11+</sup>
8682
8683PhotoSession extends [Session](#session11), [Flash](#flash11), [AutoExposure](#autoexposure11), [Focus](#focus11), [Zoom](#zoom11), [ColorManagement](#colormanagement12), [AutoDeviceSwitch](#autodeviceswitch13), and [Macro](#macro19).
8684
8685It implements a photo session, which provides operations on the flash, exposure, focus, zoom, color space, and macro mode.
8686
8687> **NOTE**
8688>
8689> 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.
8690
8691### canPreconfig<sup>12+</sup>
8692
8693canPreconfig(preconfigType: PreconfigType, preconfigRatio?: PreconfigRatio): boolean
8694
8695Checks whether this session supports a preconfigured resolution.
8696
8697**Atomic service API**: This API can be used in atomic services since API version 19.
8698
8699**System capability**: SystemCapability.Multimedia.Camera.Core
8700
8701**Parameters**
8702
8703| Name           | Type                                 | Mandatory | Description             |
8704|----------------|-------------------------------------|-----|-----------------|
8705| preconfigType  | [PreconfigType](#preconfigtype12)   | Yes  | Resolution type.     |
8706| preconfigRatio | [PreconfigRatio](#preconfigratio12) | No  | Aspect ratio. The default value is 4:3. |
8707
8708**Return value**
8709
8710| Type     | Description                                     |
8711|---------|-----------------------------------------|
8712| boolean | **true**: The preconfigured resolution is supported.<br>**false**: The preconfigured resolution is not supported.|
8713
8714**Error codes**
8715
8716For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
8717
8718| ID  | Error Message                       |
8719|---------|-----------------------------|
8720| 7400201 | Camera service fatal error. |
8721
8722**Example**
8723
8724```ts
8725function testCanPreconfig(photoSession: camera.PhotoSession, preconfigType: camera.PreconfigType,
8726  preconfigRatio: camera.PreconfigRatio): void {
8727  try {
8728    let result = photoSession.canPreconfig(preconfigType, preconfigRatio);
8729    console.info(`canPreconfig ${preconfigType} ${preconfigRatio} result is : ${result}`);
8730  } catch (error) {
8731    let err = error as BusinessError;
8732    console.error(`The canPreconfig call failed. error code: ${err.code}`);
8733  }
8734}
8735```
8736
8737### preconfig<sup>12+</sup>
8738
8739preconfig(preconfigType: PreconfigType, preconfigRatio?: PreconfigRatio): void
8740
8741Preconfigures this session.
8742
8743**Atomic service API**: This API can be used in atomic services since API version 19.
8744
8745**System capability**: SystemCapability.Multimedia.Camera.Core
8746
8747**Parameters**
8748
8749| Name           | Type                                 | Mandatory | Description             |
8750|----------------|-------------------------------------|-----|-----------------|
8751| preconfigType  | [PreconfigType](#preconfigtype12)   | Yes  | Resolution type.     |
8752| preconfigRatio | [PreconfigRatio](#preconfigratio12) | No  | Aspect ratio. The default value is 4:3. |
8753
8754**Error codes**
8755
8756For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
8757
8758| ID  | Error Message                       |
8759|---------|-----------------------------|
8760| 7400201 | Camera service fatal error. |
8761
8762**Example**
8763
8764```ts
8765function testPreconfig(photoSession: camera.PhotoSession, preconfigType: camera.PreconfigType,
8766  preconfigRatio: camera.PreconfigRatio): void {
8767  try {
8768    photoSession.preconfig(preconfigType, preconfigRatio);
8769    console.info(`preconfig ${preconfigType} ${preconfigRatio} success`);
8770  } catch (error) {
8771    let err = error as BusinessError;
8772    console.error(`The preconfig call failed. error code: ${err.code}`);
8773  }
8774}
8775```
8776
8777### on('error')<sup>11+</sup>
8778
8779on(type: 'error', callback: ErrorCallback): void
8780
8781Subscribes to PhotoSession error events. This API uses an asynchronous callback to return the result.
8782
8783> **NOTE**
8784>
8785> Currently, you cannot use **off()** to unregister the callback in the callback method of **on()**.
8786
8787**Atomic service API**: This API can be used in atomic services since API version 19.
8788
8789**System capability**: SystemCapability.Multimedia.Camera.Core
8790
8791**Parameters**
8792
8793| Name    | Type                                                         | Mandatory| Description                          |
8794| -------- | ----------------------------------------------------------- | ---- | ------------------------------ |
8795| 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).|
8796| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| Yes  | Callback used to return an error code defined in [CameraErrorCode](#cameraerrorcode).       |
8797
8798**Example**
8799
8800```ts
8801import { BusinessError } from '@kit.BasicServicesKit';
8802
8803function callback(err: BusinessError): void {
8804  console.error(`Photo session error code: ${err.code}`);
8805}
8806
8807function registerSessionError(photoSession: camera.PhotoSession): void {
8808  photoSession.on('error', callback);
8809}
8810```
8811
8812### off('error')<sup>11+</sup>
8813
8814off(type: 'error', callback?: ErrorCallback): void
8815
8816Unsubscribes from PhotoSession error events. This API uses a callback to return the result.
8817
8818**Atomic service API**: This API can be used in atomic services since API version 19.
8819
8820**System capability**: SystemCapability.Multimedia.Camera.Core
8821
8822**Parameters**
8823
8824| Name    | Type                           | Mandatory| Description                          |
8825| -------- | -------------------------------- | ---- | ------------------------------ |
8826| type     | string                           | Yes  | Event type. The value is fixed at **'error'**. The event can be listened for when a session is created.|
8827| 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.|
8828
8829**Example**
8830
8831```ts
8832function unregisterSessionError(photoSession: camera.PhotoSession): void {
8833  photoSession.off('error');
8834}
8835```
8836
8837### on('focusStateChange')<sup>11+</sup>
8838
8839on(type: 'focusStateChange', callback: AsyncCallback\<FocusState\>): void
8840
8841Subscribes to focus state change events. This API uses an asynchronous callback to return the result.
8842
8843> **NOTE**
8844>
8845> Currently, you cannot use **off()** to unregister the callback in the callback method of **on()**.
8846
8847**Atomic service API**: This API can be used in atomic services since API version 19.
8848
8849**System capability**: SystemCapability.Multimedia.Camera.Core
8850
8851**Parameters**
8852
8853| Name    | Type                   | Mandatory| Description                      |
8854| -------- | ---------------- | ---- | ------------------------ |
8855| 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.|
8856| callback | AsyncCallback\<[FocusState](#focusstate)\> | Yes  | Callback used to return the focus state change. |
8857
8858**Example**
8859
8860```ts
8861import { BusinessError } from '@kit.BasicServicesKit';
8862
8863function callback(err: BusinessError, focusState: camera.FocusState): void {
8864  if (err !== undefined && err.code !== 0) {
8865    console.error(`Callback Error, errorCode: ${err.code}`);
8866    return;
8867  }
8868  console.info(`Focus state: ${focusState}`);
8869}
8870
8871function registerFocusStateChange(photoSession: camera.PhotoSession): void {
8872  photoSession.on('focusStateChange', callback);
8873}
8874```
8875
8876### off('focusStateChange')<sup>11+</sup>
8877
8878off(type: 'focusStateChange', callback?: AsyncCallback\<FocusState\>): void
8879
8880Unsubscribes from focus state change events.
8881
8882**Atomic service API**: This API can be used in atomic services since API version 19.
8883
8884**System capability**: SystemCapability.Multimedia.Camera.Core
8885
8886**Parameters**
8887
8888| Name    | Type                                     | Mandatory| Description                      |
8889| -------- | ----------------------------------------- | ---- | ------------------------ |
8890| type     | string                                    | Yes  | Event type. The value is fixed at **'focusStateChange'**. The event can be listened for when a session is created.|
8891| 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.|
8892
8893**Example**
8894
8895```ts
8896function unregisterFocusStateChange(photoSession: camera.PhotoSession): void {
8897  photoSession.off('focusStateChange');
8898}
8899```
8900
8901### on('smoothZoomInfoAvailable')<sup>11+</sup>
8902
8903on(type: 'smoothZoomInfoAvailable', callback: AsyncCallback\<SmoothZoomInfo\>): void
8904
8905Subscribes to smooth zoom state change events. This API uses an asynchronous callback to return the result.
8906
8907> **NOTE**
8908>
8909> Currently, you cannot use **off()** to unregister the callback in the callback method of **on()**.
8910
8911**Atomic service API**: This API can be used in atomic services since API version 19.
8912
8913**System capability**: SystemCapability.Multimedia.Camera.Core
8914
8915**Parameters**
8916
8917| Name    | Type                  | Mandatory| Description                      |
8918| -------- | ----------------------- | ---- | ------------------------ |
8919| type     | string                  | Yes  | Event type. The value is fixed at **'smoothZoomInfoAvailable'**. The event can be listened for when a session is created.|
8920| callback | AsyncCallback\<[SmoothZoomInfo](#smoothzoominfo11)\> | Yes  | Callback used to return the smooth zoom state change. |
8921
8922**Example**
8923
8924```ts
8925import { BusinessError } from '@kit.BasicServicesKit';
8926
8927function callback(err: BusinessError, smoothZoomInfo: camera.SmoothZoomInfo): void {
8928  if (err !== undefined && err.code !== 0) {
8929    console.error(`Callback Error, errorCode: ${err.code}`);
8930    return;
8931  }
8932  console.info(`The duration of smooth zoom: ${smoothZoomInfo.duration}`);
8933}
8934
8935function registerSmoothZoomInfo(photoSession: camera.PhotoSession): void {
8936  photoSession.on('smoothZoomInfoAvailable', callback);
8937}
8938```
8939
8940### off('smoothZoomInfoAvailable')<sup>11+</sup>
8941
8942off(type: 'smoothZoomInfoAvailable', callback?: AsyncCallback\<SmoothZoomInfo\>): void
8943
8944Unsubscribes from smooth zoom state change events.
8945
8946**Atomic service API**: This API can be used in atomic services since API version 19.
8947
8948**System capability**: SystemCapability.Multimedia.Camera.Core
8949
8950**Parameters**
8951
8952| Name    | Type                                     | Mandatory| Description                      |
8953| -------- | ----------------------------------------- | ---- | ------------------------ |
8954| type     | string              | Yes  | Event type. The value is fixed at **'smoothZoomInfoAvailable'**. The event can be listened for when a session is created.|
8955| 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.|
8956
8957**Example**
8958
8959```ts
8960function unregisterSmoothZoomInfo(photoSession: camera.PhotoSession): void {
8961  photoSession.off('smoothZoomInfoAvailable');
8962}
8963```
8964
8965### on('autoDeviceSwitchStatusChange')<sup>13+</sup>
8966
8967on(type: 'autoDeviceSwitchStatusChange', callback: AsyncCallback\<AutoDeviceSwitchStatus\>): void
8968
8969Subscribes to automatic camera switch status change events. This API uses an asynchronous callback to return the result.
8970
8971> **NOTE**
8972>
8973> Currently, you cannot use **off()** to unregister the callback in the callback method of **on()**.
8974
8975**Atomic service API**: This API can be used in atomic services since API version 19.
8976
8977**System capability**: SystemCapability.Multimedia.Camera.Core
8978
8979**Parameters**
8980
8981| Name    | Type                                                                  | Mandatory| Description                                                    |
8982| -------- |----------------------------------------------------------------------| ---- |--------------------------------------------------------|
8983| type     | string                                                               | Yes  | Event type. The value is fixed at **'autoDeviceSwitchStatusChange'**. The event can be listened for when a session is created.|
8984| callback | AsyncCallback\<[AutoDeviceSwitchStatus](#autodeviceswitchstatus13)\> | Yes  | Callback function, which is used to obtain the status of automatic camera switch.                                 |
8985
8986**Example**
8987
8988```ts
8989import { BusinessError } from '@kit.BasicServicesKit';
8990
8991function callback(err: BusinessError, autoDeviceSwitchStatus: camera.AutoDeviceSwitchStatus): void {
8992  if (err !== undefined && err.code !== 0) {
8993    console.error(`Callback Error, errorCode: ${err.code}`);
8994    return;
8995  }
8996  console.info(`isDeviceSwitched: ${autoDeviceSwitchStatus.isDeviceSwitched}, isDeviceCapabilityChanged: ${autoDeviceSwitchStatus.isDeviceCapabilityChanged}`);
8997}
8998
8999function registerAutoDeviceSwitchStatus(photoSession: camera.PhotoSession): void {
9000  photoSession.on('autoDeviceSwitchStatusChange', callback);
9001}
9002```
9003
9004### off('autoDeviceSwitchStatusChange')<sup>13+</sup>
9005
9006off(type: 'autoDeviceSwitchStatusChange', callback?: AsyncCallback\<AutoDeviceSwitchStatus\>): void
9007
9008Unsubscribes from automatic camera switch status change events.
9009
9010**Atomic service API**: This API can be used in atomic services since API version 19.
9011
9012**System capability**: SystemCapability.Multimedia.Camera.Core
9013
9014**Parameters**
9015
9016| Name    | Type                                          | Mandatory| Description                      |
9017| -------- |----------------------------------------------| ---- | ------------------------ |
9018| type     | string                                       | Yes  | Event type. The value is fixed at **'autoDeviceSwitchStatusChange'**. The event can be listened for when a session is created.|
9019| 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.|
9020
9021**Example**
9022
9023```ts
9024function unregisterSmoothZoomInfo(photoSession: camera.PhotoSession): void {
9025  photoSession.off('autoDeviceSwitchStatusChange');
9026}
9027```
9028
9029## QualityPrioritization<sup>14+</sup>
9030
9031Enumerates the priority levels for video recording quality.
9032
9033**Atomic service API**: This API can be used in atomic services since API version 19.
9034
9035**System capability**: SystemCapability.Multimedia.Camera.Core
9036
9037| Name         | Value | Description      |
9038| ------------- | --- | ---------- |
9039| HIGH_QUALITY  | 0   | Prioritizes high-quality video recording.  |
9040| POWER_BALANCE | 1   | Prioritizes video recording quality while balancing power consumption.|
9041
9042## VideoSession<sup>11+</sup>
9043
9044VideoSession extends [Session](#session11), [Flash](#flash11), [AutoExposure](#autoexposure11), [Focus](#focus11), [Zoom](#zoom11), [Stabilization](#stabilization11), [ColorManagement](#colormanagement12), [AutoDeviceSwitch](#autodeviceswitch13), and [Macro](#macro19).
9045
9046It implements a video session, which provides operations on the flash, exposure, focus, zoom, video stabilization, color space, and macro mode.
9047
9048> **NOTE**
9049>
9050> 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).
9051
9052### canPreconfig<sup>12+</sup>
9053
9054canPreconfig(preconfigType: PreconfigType, preconfigRatio?: PreconfigRatio): boolean
9055
9056Checks whether this session supports a preconfigured resolution.
9057
9058**Atomic service API**: This API can be used in atomic services since API version 19.
9059
9060**System capability**: SystemCapability.Multimedia.Camera.Core
9061
9062**Parameters**
9063
9064| Name           | Type                                 | Mandatory | Description             |
9065|----------------|-------------------------------------|-----|-----------------|
9066| preconfigType  | [PreconfigType](#preconfigtype12)   | Yes  | Resolution type.     |
9067| preconfigRatio | [PreconfigRatio](#preconfigratio12) | No  | Aspect ratio. The default value is 16:9.|
9068
9069**Return value**
9070
9071| Type     | Description                                     |
9072|---------|-----------------------------------------|
9073| boolean | **true**: The preconfigured resolution is supported.<br>**false**: The preconfigured resolution is not supported.|
9074
9075**Error codes**
9076
9077For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
9078
9079| ID  | Error Message                       |
9080|---------|-----------------------------|
9081| 7400201 | Camera service fatal error. |
9082
9083**Example**
9084
9085```ts
9086function testCanPreconfig(videoSession: camera.VideoSession, preconfigType: camera.PreconfigType,
9087  preconfigRatio: camera.PreconfigRatio): void {
9088  try {
9089    let result = videoSession.canPreconfig(preconfigType, preconfigRatio);
9090    console.info(`canPreconfig ${preconfigType} ${preconfigRatio} result is : ${result}`);
9091  } catch (error) {
9092    let err = error as BusinessError;
9093    console.error(`The canPreconfig call failed. error code: ${err.code}`);
9094  }
9095}
9096```
9097
9098### preconfig<sup>12+</sup>
9099
9100preconfig(preconfigType: PreconfigType, preconfigRatio?: PreconfigRatio): void
9101
9102Preconfigures this session.
9103
9104**Atomic service API**: This API can be used in atomic services since API version 19.
9105
9106**System capability**: SystemCapability.Multimedia.Camera.Core
9107
9108**Parameters**
9109
9110| Name           | Type                                 | Mandatory | Description             |
9111|----------------|-------------------------------------|-----|-----------------|
9112| preconfigType  | [PreconfigType](#preconfigtype12)   | Yes  | Resolution type.     |
9113| preconfigRatio | [PreconfigRatio](#preconfigratio12) | No  | Aspect ratio. The default value is 16:9.|
9114
9115**Error codes**
9116
9117For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
9118
9119| ID  | Error Message                       |
9120|---------|-----------------------------|
9121| 7400201 | Camera service fatal error. |
9122
9123**Example**
9124
9125```ts
9126function testPreconfig(videoSession: camera.VideoSession, preconfigType: camera.PreconfigType,
9127  preconfigRatio: camera.PreconfigRatio): void {
9128  try {
9129    videoSession.preconfig(preconfigType, preconfigRatio);
9130    console.info(`preconfig ${preconfigType} ${preconfigRatio} success`);
9131  } catch (error) {
9132    let err = error as BusinessError;
9133    console.error(`The preconfig call failed. error code: ${err.code}`);
9134  }
9135}
9136```
9137
9138### on('error')<sup>11+</sup>
9139
9140on(type: 'error', callback: ErrorCallback): void
9141
9142Subscribes to VideoSession error events. This API uses an asynchronous callback to return the result.
9143
9144> **NOTE**
9145>
9146> Currently, you cannot use **off()** to unregister the callback in the callback method of **on()**.
9147
9148**Atomic service API**: This API can be used in atomic services since API version 19.
9149
9150**System capability**: SystemCapability.Multimedia.Camera.Core
9151
9152**Parameters**
9153
9154| Name    | Type             | Mandatory| Description                          |
9155| -------- | ------------------ | ---- | ------------------------------ |
9156| 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).|
9157| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)      | Yes  | Callback used to return an error code defined in [CameraErrorCode](#cameraerrorcode).  |
9158
9159**Example**
9160
9161```ts
9162import { BusinessError } from '@kit.BasicServicesKit';
9163
9164function callback(err: BusinessError): void {
9165  console.error(`Video session error code: ${err.code}`);
9166}
9167
9168function registerSessionError(videoSession: camera.VideoSession): void {
9169  videoSession.on('error', callback);
9170}
9171```
9172
9173### off('error')<sup>11+</sup>
9174
9175off(type: 'error', callback?: ErrorCallback): void
9176
9177Unsubscribes from VideoSession error events. This API uses a callback to return the result.
9178
9179**Atomic service API**: This API can be used in atomic services since API version 19.
9180
9181**System capability**: SystemCapability.Multimedia.Camera.Core
9182
9183**Parameters**
9184
9185| Name    | Type                         | Mandatory| Description                          |
9186| -------- | --------------------------- | ---- | ------------------------------ |
9187| type     | string                    | Yes  | Event type. The value is fixed at **'error'**. The event can be listened for when a session is created.|
9188| 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.|
9189
9190**Example**
9191
9192```ts
9193function unregisterSessionError(videoSession: camera.VideoSession): void {
9194  videoSession.off('error');
9195}
9196```
9197
9198### on('focusStateChange')<sup>11+</sup>
9199
9200on(type: 'focusStateChange', callback: AsyncCallback\<FocusState\>): void
9201
9202Subscribes to focus state change events. This API uses an asynchronous callback to return the result.
9203
9204> **NOTE**
9205>
9206> Currently, you cannot use **off()** to unregister the callback in the callback method of **on()**.
9207
9208**Atomic service API**: This API can be used in atomic services since API version 19.
9209
9210**System capability**: SystemCapability.Multimedia.Camera.Core
9211
9212**Parameters**
9213
9214| Name    | Type                   | Mandatory| Description                      |
9215| -------- | ---------------- | ---- | ------------------------ |
9216| 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.|
9217| callback | AsyncCallback\<[FocusState](#focusstate)\> | Yes  | Callback used to return the focus state change. |
9218
9219**Example**
9220
9221```ts
9222import { BusinessError } from '@kit.BasicServicesKit';
9223
9224function callback(err: BusinessError, focusState: camera.FocusState): void {
9225  if (err !== undefined && err.code !== 0) {
9226    console.error(`Callback Error, errorCode: ${err.code}`);
9227    return;
9228  }
9229  console.info(`Focus state: ${focusState}`);
9230}
9231
9232function registerFocusStateChange(videoSession: camera.VideoSession): void {
9233  videoSession.on('focusStateChange', callback);
9234}
9235```
9236
9237### off('focusStateChange')<sup>11+</sup>
9238
9239off(type: 'focusStateChange', callback?: AsyncCallback\<FocusState\>): void
9240
9241Unsubscribes from focus state change events.
9242
9243**Atomic service API**: This API can be used in atomic services since API version 19.
9244
9245**System capability**: SystemCapability.Multimedia.Camera.Core
9246
9247**Parameters**
9248
9249| Name    | Type                                     | Mandatory| Description                      |
9250| -------- | ----------------------------------------- | ---- | ------------------------ |
9251| type     | string                                    | Yes  | Event type. The value is fixed at **'focusStateChange'**. The event can be listened for when a session is created.|
9252| 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.|
9253
9254**Example**
9255
9256```ts
9257function unregisterFocusStateChange(videoSession: camera.VideoSession): void {
9258  videoSession.off('focusStateChange');
9259}
9260```
9261
9262### on('smoothZoomInfoAvailable')<sup>11+</sup>
9263
9264on(type: 'smoothZoomInfoAvailable', callback: AsyncCallback\<SmoothZoomInfo\>): void
9265
9266Subscribes to smooth zoom state change events. This API uses an asynchronous callback to return the result.
9267
9268> **NOTE**
9269>
9270> Currently, you cannot use **off()** to unregister the callback in the callback method of **on()**.
9271
9272**Atomic service API**: This API can be used in atomic services since API version 19.
9273
9274**System capability**: SystemCapability.Multimedia.Camera.Core
9275
9276**Parameters**
9277
9278| Name    | Type                  | Mandatory| Description                      |
9279| -------- | ----------------------- | ---- | ------------------------ |
9280| type     | string                  | Yes  | Event type. The value is fixed at **'smoothZoomInfoAvailable'**. The event can be listened for when a session is created.|
9281| callback | AsyncCallback\<[SmoothZoomInfo](#smoothzoominfo11)\> | Yes  | Callback used to return the smooth zoom state change. |
9282
9283**Example**
9284
9285```ts
9286import { BusinessError } from '@kit.BasicServicesKit';
9287
9288function callback(err: BusinessError, smoothZoomInfo: camera.SmoothZoomInfo): void {
9289  if (err !== undefined && err.code !== 0) {
9290    console.error(`Callback Error, errorCode: ${err.code}`);
9291    return;
9292  }
9293  console.info(`The duration of smooth zoom: ${smoothZoomInfo.duration}`);
9294}
9295
9296function registerSmoothZoomInfo(videoSession: camera.VideoSession): void {
9297  videoSession.on('smoothZoomInfoAvailable', callback);
9298}
9299```
9300
9301### off('smoothZoomInfoAvailable')<sup>11+</sup>
9302
9303off(type: 'smoothZoomInfoAvailable', callback?: AsyncCallback\<SmoothZoomInfo\>): void
9304
9305Unsubscribes from smooth zoom state change events.
9306
9307**Atomic service API**: This API can be used in atomic services since API version 19.
9308
9309**System capability**: SystemCapability.Multimedia.Camera.Core
9310
9311**Parameters**
9312
9313| Name    | Type                                     | Mandatory| Description                      |
9314| -------- | ----------------------------------------- | ---- | ------------------------ |
9315| type     | string              | Yes  | Event type. The value is fixed at **'smoothZoomInfoAvailable'**. The event can be listened for when a session is created.|
9316| 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.|
9317
9318**Example**
9319
9320```ts
9321function unregisterSmoothZoomInfo(videoSession: camera.VideoSession): void {
9322  videoSession.off('smoothZoomInfoAvailable');
9323}
9324```
9325
9326### on('autoDeviceSwitchStatusChange')<sup>13+</sup>
9327
9328on(type: 'autoDeviceSwitchStatusChange', callback: AsyncCallback\<AutoDeviceSwitchStatus\>): void
9329
9330Subscribes to automatic camera switch status change events. This API uses an asynchronous callback to return the result.
9331
9332> **NOTE**
9333>
9334> Currently, you cannot use **off()** to unregister the callback in the callback method of **on()**.
9335
9336**Atomic service API**: This API can be used in atomic services since API version 19.
9337
9338**System capability**: SystemCapability.Multimedia.Camera.Core
9339
9340**Parameters**
9341
9342| Name    | Type                                                                  | Mandatory| Description                      |
9343| -------- |----------------------------------------------------------------------| ---- | ------------------------ |
9344| type     | string                                                               | Yes  | Event type. The value is fixed at **'autoDeviceSwitchStatusChange'**. The event can be listened for when a session is created.|
9345| callback | AsyncCallback\<[AutoDeviceSwitchStatus](#autodeviceswitchstatus13)\> | Yes  | Callback function, which is used to obtain the status of automatic camera switch. |
9346
9347**Example**
9348
9349```ts
9350import { BusinessError } from '@kit.BasicServicesKit';
9351
9352function callback(err: BusinessError, autoDeviceSwitchStatus: camera.AutoDeviceSwitchStatus): void {
9353  if (err !== undefined && err.code !== 0) {
9354    console.error(`Callback Error, errorCode: ${err.code}`);
9355    return;
9356  }
9357  console.info(`isDeviceSwitched: ${autoDeviceSwitchStatus.isDeviceSwitched}, isDeviceCapabilityChanged: ${autoDeviceSwitchStatus.isDeviceCapabilityChanged}`);
9358}
9359
9360function registerAutoDeviceSwitchStatus(videoSession: camera.VideoSession): void {
9361  videoSession.on('autoDeviceSwitchStatusChange', callback);
9362}
9363```
9364
9365### off('autoDeviceSwitchStatusChange')<sup>13+</sup>
9366
9367off(type: 'autoDeviceSwitchStatusChange', callback?: AsyncCallback\<AutoDeviceSwitchStatus\>): void
9368
9369Unsubscribes from automatic camera switch status change events.
9370
9371**Atomic service API**: This API can be used in atomic services since API version 19.
9372
9373**System capability**: SystemCapability.Multimedia.Camera.Core
9374
9375**Parameters**
9376
9377| Name    | Type                                          | Mandatory| Description                      |
9378| -------- |----------------------------------------------| ---- | ------------------------ |
9379| type     | string                                       | Yes  | Event type. The value is fixed at **'autoDeviceSwitchStatusChange'**. The event can be listened for when a session is created.|
9380| 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.|
9381
9382**Example**
9383
9384```ts
9385function unregisterSmoothZoomInfo(videoSession: camera.VideoSession): void {
9386  videoSession.off('autoDeviceSwitchStatusChange');
9387}
9388```
9389
9390### setQualityPrioritization<sup>14+</sup>
9391
9392setQualityPrioritization(quality : QualityPrioritization) : void;
9393
9394Sets the priority level for video recording quality.
9395
9396> **NOTE**
9397>
9398> 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.
9399
9400**Atomic service API**: This API can be used in atomic services since API version 19.
9401
9402**System capability**: SystemCapability.Multimedia.Camera.Core
9403
9404**Parameters**
9405
9406| Name | Type                                             | Mandatory| Description                                      |
9407| ------- | ------------------------------------------------- | ---- | ------------------------------------------ |
9408| quality | [QualityPrioritization](#qualityprioritization14) | Yes  | Priority level to set. The default value is **HIGH_QUALITY**.|
9409
9410**Error codes**
9411
9412For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
9413
9414| ID| Error Message                                                                                                                                       |
9415| -------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
9416| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
9417| 7400103  | Session not config. The session has not been committed or configured.                                                                           |
9418
9419**Example**
9420
9421```ts
9422import { BusinessError } from '@kit.BasicServicesKit';
9423
9424function setQualityPrioritization(videoSession: camera.VideoSession): void {
9425  try {
9426    videoSession.setQualityPrioritization(camera.QualityPrioritization.POWER_BALANCE);
9427  } catch (error) {
9428    // If the operation fails, error.code is returned and processed.
9429    let err = error as BusinessError;
9430    console.error(`The setQualityPrioritization call failed. error code: ${err.code}`);
9431  }
9432}
9433```
9434
9435## SecureSession<sup>12+</sup>
9436
9437SecureSession extends [Session](#session11), [Flash](#flash11), [AutoExposure](#autoexposure11), [Focus](#focus11), and [Zoom](#zoom11).
9438
9439It implements a secure session, which provides operations on the flash, exposure, focus, and zoom.
9440
9441> **NOTE**
9442>
9443> 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-->
9444>
9445> 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-->
9446
9447### addSecureOutput<sup>12+</sup>
9448
9449addSecureOutput(previewOutput: PreviewOutput): void
9450
9451Marks a [PreviewOutput](#previewoutput) stream as secure output.
9452
9453**Atomic service API**: This API can be used in atomic services since API version 19.
9454
9455**System capability**: SystemCapability.Multimedia.Camera.Core
9456
9457**Parameters**
9458
9459| Name          | Type                            | Mandatory| Description           |
9460| ------------- | ------------------------------- | ---- |---------------|
9461| previewOutput  | [PreviewOutput](#previewoutput)   | Yes  | Preview output stream. An error code is returned if the input parameter is invalid.|
9462
9463**Error codes**
9464
9465For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
9466
9467| ID        | Error Message       |
9468| --------------- | --------------- |
9469| 7400101                |  Parameter missing or parameter type incorrect.        |
9470| 7400102                |  Operation not allowed.                                  |
9471
9472**Example**
9473
9474```ts
9475import { BusinessError } from '@kit.BasicServicesKit';
9476
9477function addSecureOutput(session: camera.SecureSession, previewOutput: camera.PreviewOutput): void {
9478  try {
9479    session.addSecureOutput(previewOutput);
9480  } catch (error) {
9481    // If the operation fails, error.code is returned and processed.
9482    let err = error as BusinessError;
9483    console.error(`The addOutput call failed. error code: ${err.code}`);
9484  }
9485}
9486```
9487### on('error')<sup>12+</sup>
9488
9489on(type: 'error', callback: ErrorCallback): void
9490
9491Subscribes to SecureSession error events. This API uses an asynchronous callback to return the result.
9492
9493> **NOTE**
9494>
9495> Currently, you cannot use **off()** to unregister the callback in the callback method of **on()**.
9496
9497**Atomic service API**: This API can be used in atomic services since API version 19.
9498
9499**System capability**: SystemCapability.Multimedia.Camera.Core
9500
9501**Parameters**
9502
9503| Name    | Type             | Mandatory| Description                          |
9504| -------- | ------------------ | ---- | ------------------------------ |
9505| 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).|
9506| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)      | Yes  | Callback used to return an error code defined in [CameraErrorCode](#cameraerrorcode).  |
9507
9508**Example**
9509
9510```ts
9511import { BusinessError } from '@kit.BasicServicesKit';
9512
9513function callback(err: BusinessError): void {
9514  console.error(`Video session error code: ${err.code}`);
9515}
9516
9517function registerSessionError(secureSession: camera.SecureSession): void {
9518  secureSession.on('error', callback);
9519}
9520```
9521
9522### off('error')<sup>12+</sup>
9523
9524off(type: 'error', callback?: ErrorCallback): void
9525
9526Unsubscribes from SecureSession error events.
9527
9528**Atomic service API**: This API can be used in atomic services since API version 19.
9529
9530**System capability**: SystemCapability.Multimedia.Camera.Core
9531
9532**Parameters**
9533
9534| Name    | Type                         | Mandatory| Description                          |
9535| -------- | --------------------------- | ---- | ------------------------------ |
9536| type     | string                    | Yes  | Event type. The value is fixed at **'error'**. The event can be listened for when a session is created.|
9537| 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.|
9538
9539**Example**
9540
9541```ts
9542function unregisterSessionError(secureSession: camera.SecureSession): void {
9543  secureSession.off('error');
9544}
9545```
9546
9547### on('focusStateChange')<sup>12+</sup>
9548
9549on(type: 'focusStateChange', callback: AsyncCallback\<FocusState\>): void
9550
9551Subscribes to focus state change events. This API uses an asynchronous callback to return the result.
9552
9553> **NOTE**
9554>
9555> Currently, you cannot use **off()** to unregister the callback in the callback method of **on()**.
9556
9557**Atomic service API**: This API can be used in atomic services since API version 19.
9558
9559**System capability**: SystemCapability.Multimedia.Camera.Core
9560
9561**Parameters**
9562
9563| Name    | Type                   | Mandatory| Description                      |
9564| -------- | ---------------- | ---- | ------------------------ |
9565| 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.|
9566| callback | AsyncCallback\<[FocusState](#focusstate)\> | Yes  | Callback used to return the focus state change. |
9567
9568**Example**
9569
9570```ts
9571import { BusinessError } from '@kit.BasicServicesKit';
9572
9573function callback(err: BusinessError, focusState: camera.FocusState): void {
9574  if (err !== undefined && err.code !== 0) {
9575    console.error(`Callback Error, errorCode: ${err.code}`);
9576    return;
9577  }
9578  console.info(`Focus state: ${focusState}`);
9579}
9580
9581function registerFocusStateChange(secureSession: camera.SecureSession): void {
9582  secureSession.on('focusStateChange', callback);
9583}
9584```
9585
9586### off('focusStateChange')<sup>12+</sup>
9587
9588off(type: 'focusStateChange', callback?: AsyncCallback\<FocusState\>): void
9589
9590Unsubscribes from focus state change events.
9591
9592**Atomic service API**: This API can be used in atomic services since API version 19.
9593
9594**System capability**: SystemCapability.Multimedia.Camera.Core
9595
9596**Parameters**
9597
9598| Name    | Type                                     | Mandatory| Description                      |
9599| -------- | ----------------------------------------- | ---- | ------------------------ |
9600| type     | string                                    | Yes  | Event type. The value is fixed at **'focusStateChange'**. The event can be listened for when a session is created.|
9601| 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.|
9602
9603**Example**
9604
9605```ts
9606function unregisterFocusStateChange(secureSession: camera.SecureSession): void {
9607  secureSession.off('focusStateChange');
9608}
9609```
9610
9611## WhiteBalanceMode<sup>20+</sup>
9612
9613Enumerates the white balance modes.
9614
9615**Atomic service API**: This API can be used in atomic services since API version 20.
9616
9617**System capability**: SystemCapability.Multimedia.Camera.Core
9618
9619| Name            | Value| Description        |
9620|----------------|---| ----------- |
9621| AUTO           | 0 | Automatic.|
9622| CLOUDY         | 1 | Cloudy.|
9623| INCANDESCENT   | 2 | Incandescent light.|
9624| FLUORESCENT    | 3 | Fluorescence light.|
9625| DAYLIGHT     	 | 4 | Daylight.|
9626| MANUAL         | 5 | Manual.|
9627
9628## WhiteBalanceQuery<sup>20+</sup>
9629
9630Provides APIs to check whether a white balance mode is supported and obtain the white balance mode range supported.
9631
9632**Atomic service API**: This API can be used in atomic services since API version 20.
9633
9634**System capability**: SystemCapability.Multimedia.Camera.Core
9635
9636### isWhiteBalanceModeSupported<sup>20+</sup>
9637
9638isWhiteBalanceModeSupported(mode: WhiteBalanceMode): boolean
9639
9640Checks whether a white balance mode is supported.
9641
9642**Atomic service API**: This API can be used in atomic services since API version 20.
9643
9644**System capability**: SystemCapability.Multimedia.Camera.Core
9645
9646**Parameters**
9647
9648| Name     | Type                                     | Mandatory | Description                          |
9649| -------- |-----------------------------------------| ---- | ----------------------------- |
9650| mode   | [WhiteBalanceMode](#whitebalancemode20) | Yes  | White balance mode.                     |
9651
9652**Return value**
9653
9654| Type       | Description                         |
9655| ---------- | ----------------------------- |
9656| boolean    | Check result for the support of the white balance mode. **true** if supported, **false** otherwise.|
9657
9658**Error codes**
9659
9660For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
9661
9662| ID        | Error Message       |
9663| --------------- | --------------- |
9664| 7400101                |  Parameter missing or parameter type incorrect.        |
9665| 7400103                |  Session not config, only throw in session usage.                                  |
9666
9667**Example**
9668
9669```ts
9670import { BusinessError } from '@kit.BasicServicesKit';
9671
9672function isWhiteBalanceModeSupported(session: camera.PhotoSession | camera.VideoSession): boolean {
9673  let status: boolean = false;
9674  try {
9675	let mode: WhiteBalanceMode = camera.WhiteBalanceMode.DAYLIGHT;
9676    status = session.isWhiteBalanceModeSupported(mode);
9677  } catch (error) {
9678    let err = error as BusinessError;
9679    console.error(`The isWhiteBalanceModeSupported call failed. error code: ${err.code}`);
9680  }
9681  return status;
9682}
9683```
9684
9685### getWhiteBalanceRange<sup>20+</sup>
9686
9687getWhiteBalanceRange(): Array\<number\>
9688
9689Obtains the range of white balance values in manual white balance mode.
9690
9691**Atomic service API**: This API can be used in atomic services since API version 20.
9692
9693**System capability**: SystemCapability.Multimedia.Camera.Core
9694
9695**Return value**
9696
9697| Type       | Description                         |
9698| ---------- | ----------------------------- |
9699| Array\<number\>   | Range of white balance values, for example, [2800, ...,10000], in units of K (Kelvin). The actual value depends on the bottom-layer capability.|
9700
9701**Error codes**
9702
9703For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
9704
9705| ID        | Error Message       |
9706| --------------- | --------------- |
9707| 7400103                |  Session not config, only throw in session usage.                                  |
9708
9709**Example**
9710
9711```ts
9712import { BusinessError } from '@kit.BasicServicesKit';
9713
9714function getWhiteBalanceRange(session: camera.PhotoSession | camera.VideoSession): Array<number> {
9715  let range: Array<number> = [];
9716  try {
9717    range = session.getWhiteBalanceRange();
9718  } catch (error) {
9719    let err = error as BusinessError;
9720    console.error(`The getWhiteBalanceRange call failed. error code: ${err.code}`);
9721  }
9722  return range;
9723}
9724```
9725
9726## WhiteBalance<sup>20+</sup>
9727
9728WhiteBalance extends [WhiteBalanceQuery](#whitebalancequery20).
9729
9730It provides APIs to process white balance, including obtaining and setting the white balance mode and white balance value.
9731
9732**Atomic service API**: This API can be used in atomic services since API version 20.
9733
9734**System capability**: SystemCapability.Multimedia.Camera.Core
9735
9736### setWhiteBalanceMode<sup>20+</sup>
9737
9738setWhiteBalanceMode(mode: WhiteBalanceMode): void
9739
9740Sets a white balance mode. Before setting the white balance mode, run [isWhiteBalanceModeSupported](#iswhitebalancemodesupported20) to check whether the device supports the specified white balance mode.
9741
9742**Atomic service API**: This API can be used in atomic services since API version 20.
9743
9744**System capability**: SystemCapability.Multimedia.Camera.Core
9745
9746**Parameters**
9747
9748| Name     | Type                                     | Mandatory| Description                   |
9749| -------- |-----------------------------------------| ---- | ----------------------- |
9750| mode   | [WhiteBalanceMode](#whitebalancemode20) | Yes  | White balance mode.               |
9751
9752**Error codes**
9753
9754For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
9755
9756| ID        | Error Message       |
9757| --------------- | --------------- |
9758| 7400101                |  Parameter missing or parameter type incorrect.        |
9759| 7400103                |  Session not config.                                   |
9760
9761**Example**
9762
9763```ts
9764import { BusinessError } from '@kit.BasicServicesKit';
9765
9766function setWhiteBalanceMode(session: camera.PhotoSession | camera.VideoSession): void {
9767  try {
9768    session.setWhiteBalanceMode(camera.WhiteBalanceMode.DAYLIGHT);
9769  } catch (error) {
9770    let err = error as BusinessError;
9771    console.error(`The setWhiteBalanceMode call failed. error code: ${err.code}`);
9772  }
9773}
9774```
9775
9776### getWhiteBalanceMode<sup>20+</sup>
9777
9778getWhiteBalanceMode(): WhiteBalanceMode
9779
9780Obtains the white balance mode in use.
9781
9782**Atomic service API**: This API can be used in atomic services since API version 20.
9783
9784**System capability**: SystemCapability.Multimedia.Camera.Core
9785
9786**Return value**
9787
9788| Type                                     | Description                         |
9789|-----------------------------------------| ----------------------------- |
9790| [WhiteBalanceMode](#whitebalancemode20) | White balance mode in use.|
9791
9792**Error codes**
9793
9794For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
9795
9796| ID        | Error Message       |
9797| --------------- | --------------- |
9798| 7400103                |  Session not config.                                   |
9799
9800**Example**
9801
9802```ts
9803import { BusinessError } from '@kit.BasicServicesKit';
9804
9805function getWhiteBalanceMode(session: camera.PhotoSession | camera.VideoSession): camera.WhiteBalanceMode | undefined {
9806  let whiteBalanceMode: camera.WhiteBalanceMode | undefined = undefined;
9807  try {
9808    whiteBalanceMode = session.getWhiteBalanceMode();
9809  } catch (error) {
9810    let err = error as BusinessError;
9811    console.error(`The getWhiteBalanceMode call failed. error code: ${err.code}`);
9812  }
9813  return whiteBalanceMode;
9814}
9815```
9816
9817### setWhiteBalance<sup>20+</sup>
9818setWhiteBalance(whiteBalance: number): void
9819
9820Sets a white balance value.
9821
9822**Atomic service API**: This API can be used in atomic services since API version 20.
9823
9824**System capability**: SystemCapability.Multimedia.Camera.Core
9825
9826**Parameters**
9827
9828| Name     | Type                    | Mandatory| Description                |
9829| -------- | ----------------------- | ---- | ------------------- |
9830| whiteBalance | number | Yes  | White balance value.|
9831
9832**Error codes**
9833
9834For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
9835
9836| ID        | Error Message       |
9837| --------------- | --------------- |
9838| 7400101                |  Parameter missing or parameter type incorrect.        |
9839| 7400103                |  Session not config.                                   |
9840
9841**Example**
9842
9843```ts
9844import { BusinessError } from '@kit.BasicServicesKit';
9845
9846function setWhiteBalance(session: camera.PhotoSession | camera.VideoSession): void {
9847  try {
9848    let whiteBalance: number = 1000;
9849    session.setWhiteBalance(whiteBalance);
9850  } catch (error) {
9851    let err = error as BusinessError;
9852    console.error(`The setWhiteBalance call failed. error code: ${err.code}`);
9853  }
9854}
9855```
9856
9857### getWhiteBalance<sup>20+</sup>
9858
9859getWhiteBalance(): number
9860
9861Obtains the current white balance value.
9862
9863**Atomic service API**: This API can be used in atomic services since API version 20.
9864
9865**System capability**: SystemCapability.Multimedia.Camera.Core
9866
9867**Return value**
9868
9869| Type       | Description                         |
9870| ---------- | ----------------------------- |
9871| number    | White balance value.|
9872
9873**Error codes**
9874
9875For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
9876
9877| ID        | Error Message       |
9878| --------------- | --------------- |
9879| 7400103                |  Session not config.                                   |
9880
9881**Example**
9882
9883```ts
9884import { BusinessError } from '@kit.BasicServicesKit';
9885
9886function getWhiteBalance(session: camera.PhotoSession | camera.VideoSession): number {
9887  let whiteBalance: number = 0;
9888  try {
9889    whiteBalance = session.getWhiteBalance();
9890  } catch (error) {
9891    let err = error as BusinessError;
9892    console.error(`The getWhiteBalance call failed. error code: ${err.code}`);
9893  }
9894  return whiteBalance;
9895}
9896```
9897