• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.multimedia.camera (Camera Management)
2
3> **NOTE**
4>
5> - The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
6> - The APIs provided by this module are system APIs.
7
8## Modules to Import
9
10```js
11import camera from '@ohos.multimedia.camera';
12```
13
14## camera.getCameraManager
15
16getCameraManager(context: Context): CameraManager
17
18Obtains a **CameraManager** instance. This API returns the result synchronously.
19
20**System capability**: SystemCapability.Multimedia.Camera.Core
21
22**Parameters**
23
24| Name    | Type                                            | Mandatory| Description                          |
25| -------- | ----------------------------------------------- | ---- | ---------------------------- |
26| context  | [Context](js-apis-inner-app-context.md)      | Yes  | Application context.                  |
27
28**Return value**
29
30| Type                                            | Description                          |
31| ----------------------------------------------- | ---------------------------- |
32| [CameraManager](#cameramanager)           | **CameraManager** instance obtained.                  |
33
34**Error codes**
35
36For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
37
38| ID        | Error Message       |
39| --------------- | --------------- |
40| 7400101                |  Parameter missing or parameter type incorrect               |
41| 7400201                |  Camera service fatal error.                                  |
42
43**Example**
44
45```js
46let cameraManager = camera.getCameraManager(context);
47```
48
49## CameraStatus
50
51Enumerates the camera statuses.
52
53**System capability**: SystemCapability.Multimedia.Camera.Core
54
55| Name                      | Value  | Description           |
56| ------------------------- | ---- | ------------    |
57| CAMERA_STATUS_APPEAR      | 0    | A camera appears.  |
58| CAMERA_STATUS_DISAPPEAR   | 1    | The camera disappears.    |
59| CAMERA_STATUS_AVAILABLE   | 2    | The camera is available.      |
60| CAMERA_STATUS_UNAVAILABLE | 3    | The camera is unavailable.    |
61
62## Profile
63
64Defines the camera profile.
65
66**System capability**: SystemCapability.Multimedia.Camera.Core
67
68| Name     | Type                          | Mandatory| Description        |
69| -------- | ----------------------------- |---- | ------------- |
70| format   | [CameraFormat](#cameraformat) | Yes | Output format.     |
71| size     | [Size](#size)                 | Yes | Resolution.      |
72
73## FrameRateRange
74
75Defines the frame rate range.
76
77**System capability**: SystemCapability.Multimedia.Camera.Core
78
79| Name     | Type                          | Mandatory| Description        |
80| -------- | ----------------------------- |---- | ------------- |
81| min      | number                        | Yes | Minimum frame rate.     |
82| max      | number                        | Yes | Maximum frame rate.     |
83
84## VideoProfile
85
86Defines the video profile.
87
88**System capability**: SystemCapability.Multimedia.Camera.Core
89
90| Name                      | Type                                     | Mandatory| Description       |
91| ------------------------- | ----------------------------------------- | --- |----------- |
92| frameRateRange            | [FrameRateRange](#frameraterange)         | Yes | Frame rate range.  |
93
94## CameraOutputCapability
95
96Defines the camera output capability.
97
98**System capability**: SystemCapability.Multimedia.Camera.Core
99
100| Name                          | Type                                              | Mandatory| Description               |
101| ----------------------------- | -------------------------------------------------- | --- |------------------- |
102| previewProfiles               | Array<[Profile](#profile)\>                        | Yes | Supported preview profiles.   |
103| photoProfiles                 | Array<[Profile](#profile)\>                        | Yes | Supported shooting profiles.   |
104| videoProfiles                 | Array<[VideoProfile](#videoprofile)\>              | Yes | Supported video recording profiles.   |
105| supportedMetadataObjectTypes  | Array<[MetadataObjectType](#metadataobjecttype)\>  | Yes | Supported metadata object types.|
106
107## CameraErrorCode
108
109Enumerates the camera error codes, which are returned when an API call is incorrect or the **on()** API is used to listen for the error status.
110
111**System capability**: SystemCapability.Multimedia.Camera.Core
112
113| Name                      | Value  | Description           |
114| ------------------------- | ---- | ------------    |
115| INVALID_ARGUMENT       | 7400101    | A parameter is missing or the parameter type is incorrect.  |
116| OPERATION_NOT_ALLOWED    | 7400102    | The operation is not allowed.    |
117| SESSION_NOT_CONFIG    | 7400103    | The session is not configured.      |
118| SESSION_NOT_RUNNING  | 7400104    | The session is not running.   |
119| SESSION_CONFIG_LOCKED  | 7400105    | The session configuration is locked.    |
120| DEVICE_SETTING_LOCKED  | 7400106    | The device setting is locked.    |
121| CONFILICT_CAMERA  | 7400107    | The device is already started.    |
122| DEVICE_DISABLED  | 7400108    | The camera is disabled for security reasons.    |
123| SERVICE_FATAL_ERROR  | 7400201    | An error occurs in the camera service.    |
124
125## CameraManager
126
127Implements camera management. Before calling any API in **CameraManager**, you must use **getCameraManager** to obtain a **CameraManager** instance.
128
129### getSupportedCameras
130
131getSupportedCameras(): Array<CameraDevice\>
132
133Obtains supported cameras. This API returns the result synchronously.
134
135**System capability**: SystemCapability.Multimedia.Camera.Core
136
137**Return value**
138
139| Type                                            | Description                          |
140| ----------------------------------------------- | ---------------------------- |
141|  Array<[CameraDevice](#cameradevice)>            | An array of supported cameras.                  |
142
143**Example**
144
145```js
146let cameras = cameraManager.getSupportedCameras();
147
148```
149
150### getSupportedOutputCapability
151
152getSupportedOutputCapability(cameraDevice:CameraDevice): CameraOutputCapability
153
154Obtains the output capability supported by a camera. This API returns the result synchronously.
155
156**System capability**: SystemCapability.Multimedia.Camera.Core
157
158**Parameters**
159
160| Name        | Type                                                           | Mandatory| Description                     |
161| ------------ |--------------------------------------------------------------- | -- | -------------------------- |
162| cameraDevice | [CameraDevice](#cameradevice)                              | Yes| Target camera, which is obtained through **getSupportedCameras**.      |
163
164**Return value**
165
166| Type                                            | Description                          |
167| ----------------------------------------------- | ---------------------------- |
168| [CameraOutputCapability](#cameraoutputcapability)            | Camera output capability obtained.                  |
169
170**Example**
171
172```js
173let cameraDevice = cameras[0];
174let cameraOutputCapability = cameraManager.getSupportedOutputCapability(cameraDevice);
175
176```
177
178### isCameraMuted
179
180isCameraMuted(): boolean
181
182Checks whether the camera is muted.
183
184Before calling the API, ensure that the camera can be muted. You can use [isCameraMuteSupported](#iscameramutesupported) to check whether the camera can be muted.
185
186**System capability**: SystemCapability.Multimedia.Camera.Core
187
188**Return value**
189
190| Type       | Description                                        |
191| ---------- | -------------------------------------------- |
192| boolean    | Returns **true** if the camera is muted; returns **false** otherwise.|
193
194**Example**
195
196```js
197let ismuted = cameraManager.isCameraMuted();
198```
199
200### isCameraMuteSupported
201
202isCameraMuteSupported(): boolean
203
204Checks whether the camera can be muted.
205
206This is a system API.
207
208**System capability**: SystemCapability.Multimedia.Camera.Core
209
210**Return value**
211
212| Type       | Description                         |
213| ---------- | ----------------------------- |
214| boolean    | Returns **true** if the camera can be muted; returns **false** otherwise.|
215
216**Example**
217
218```js
219let ismutesuppotred = cameraManager.isCameraMuteSupported();
220```
221
222### muteCamera
223
224muteCamera(mute: boolean): void
225
226Mutes or unmutes the camera.
227
228This is a system API.
229
230**System capability**: SystemCapability.Multimedia.Camera.Core
231
232**Parameters**
233
234| Name     | Type                             | Mandatory | Description       |
235| -------- | --------------------------------- | ---- | ---------- |
236| mute     | boolean                           |  Yes |  Whether to mute the camera. The value **true** means to mute the camera, and **false** means the opposite. |
237
238**Example**
239
240```js
241let mute = true;
242cameraManager.muteCamera(mute);
243```
244
245### createCameraInput
246
247createCameraInput(camera: CameraDevice): CameraInput
248
249Creates a **CameraInput** instance with the specified **CameraDevice** object. This API returns the result synchronously.
250
251**Required permissions**: ohos.permission.CAMERA
252
253**System capability**: SystemCapability.Multimedia.Camera.Core
254
255**Parameters**
256
257| Name    | Type                                        | Mandatory| Description                               |
258| -------- | ------------------------------------------- | ---- | --------------------------------- |
259| cameraDevice   | [CameraDevice](#cameradevice)         | Yes  | Target **CameraDevice** object, which is obtained through **getSupportedCameras**.  |
260
261**Return value**
262
263| Type       | Description                         |
264| ---------- | ----------------------------- |
265| [CameraInput](#camerainput)    | **CameraInput** instance created. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
266
267**Error codes**
268
269For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
270
271| ID        | Error Message       |
272| --------------- | --------------- |
273| 7400101                |  Parameter missing or parameter type incorrect               |
274
275**Example**
276
277```js
278let cameraDevice = cameras[0];
279let cameraInput;
280try {
281	cameraInput = cameraManager.createCameraInput(cameraDevice);
282} catch (error) {
283    // If the operation fails, error.code is returned and processed.
284    console.log(error.code);
285}
286```
287
288### createCameraInput
289
290createCameraInput(position: CameraPosition, type: CameraType): CameraInput
291
292Creates a **CameraInput** instance with the specified camera position and type. This API returns the result synchronously.
293
294**Required permissions**: ohos.permission.CAMERA
295
296**System capability**: SystemCapability.Multimedia.Camera.Core
297
298**Parameters**
299
300| Name    | Type                                       | Mandatory| Description                               |
301| -------- | ------------------------------------------- | ---- | --------------------------------- |
302| position | [CameraPosition](#cameraposition)           | Yes  | Camera position, which is obtained through **getSupportedCameras**. This API obtains a **CameraDevice** object, which contains the camera position information. |
303| type     | [CameraType](#cameratype)                   | Yes  | Camera type, which is obtained through **getSupportedCameras**. This API obtains a **CameraDevice** object, which contains the camera type information. |
304
305**Return value**
306
307| Type       | Description                         |
308| ---------- | ----------------------------- |
309| [CameraInput](#camerainput)    | **CameraInput** instance created. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
310
311**Error codes**
312
313For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
314
315| ID        | Error Message       |
316| --------------- | --------------- |
317| 7400101                |  Parameter missing or parameter type incorrect               |
318
319**Example**
320
321```js
322let cameraDevice = cameras[0];
323let position = cameraDevice.cameraPosition;
324let type = cameraDevice.cameraType;
325let cameraInput;
326try {
327    cameraInput = cameraManager.createCameraInput(position, type);
328} catch (error) {
329    // If the operation fails, error.code is returned and processed.
330    console.log(error.code);
331}
332```
333
334### createPreviewOutput
335
336createPreviewOutput(profile: Profile, surfaceId: string): PreviewOutput
337
338Creates a **PreviewOutput** instance. This API returns the result synchronously.
339
340**System capability**: SystemCapability.Multimedia.Camera.Core
341
342**Parameters**
343
344| Name    | Type                                            | Mandatory| Description                             |
345| -------- | ----------------------------------------------- | ---- | ------------------------------- |
346| profile  | [Profile](#profile)                             | Yes  | Supported preview profiles, which are obtained through **getSupportedOutputCapability**.|
347| surfaceId| string | Yes  | Surface ID, which is obtained from [XComponent](../arkui-ts/ts-basic-components-xcomponent.md) or [ImageReceiver](js-apis-image.md#imagereceiver9).|
348
349**Return value**
350
351| Type       | Description                         |
352| ---------- | ----------------------------- |
353| [PreviewOutput](#previewoutput)    | **PreviewOutput** instance created. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
354
355**Error codes**
356
357For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
358
359| ID        | Error Message       |
360| --------------- | --------------- |
361| 7400101                |  Parameter missing or parameter type incorrect               |
362
363**Example**
364
365```js
366let profile = cameraOutputCapability.previewProfiles[0];
367let previewOutput;
368try {
369    previewOutput = cameraManager.createPreviewOutput(profile, surfaceId);
370} catch (error) {
371    // If the operation fails, error.code is returned and processed.
372    console.log(error.code);
373}
374```
375
376### createPhotoOutput
377
378createPhotoOutput(profile: Profile, surfaceId: string): PhotoOutput
379
380Creates a **PhotoOutput** instance. This API returns the result synchronously.
381
382**System capability**: SystemCapability.Multimedia.Camera.Core
383
384**Parameters**
385
386| Name    | Type                                        | Mandatory| Description                                 |
387| -------- | ------------------------------------------- | ---- | ----------------------------------- |
388| profile  | [Profile](#profile)                         | Yes  | Supported shooting profiles, which are obtained through **getSupportedOutputCapability**.|
389| surfaceId| string            | Yes  | Surface ID, which is obtained from [ImageReceiver](js-apis-image.md#imagereceiver9).|
390
391**Return value**
392
393| Type       | Description                         |
394| ---------- | ----------------------------- |
395| [PhotoOutput](#photooutput)   | **PhotoOutput** instance created. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
396
397**Error codes**
398
399For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
400
401| ID        | Error Message       |
402| --------------- | --------------- |
403| 7400101                |  Parameter missing or parameter type incorrect               |
404
405**Example**
406
407```js
408let profile = cameraOutputCapability.photoProfiles[0];
409let photoOutput;
410try {
411    photoOutput = cameraManager.createPhotoOutput(profile, surfaceId);
412} catch (error) {
413    // If the operation fails, error.code is returned and processed.
414    console.log(error.code);
415}
416```
417
418### createVideoOutput
419
420createVideoOutput(profile: VideoProfile, surfaceId: string): VideoOutput
421
422Creates a **VideoOutput** instance. This API returns the result synchronously.
423
424**System capability**: SystemCapability.Multimedia.Camera.Core
425
426**Parameters**
427
428| Name    | Type                                       | Mandatory| Description                             |
429| -------- | ------------------------------------------- | ---- | ------------------------------ |
430| profile  | [VideoProfile](#videoprofile)               | Yes  | Supported video recording profiles, which are obtained through **getSupportedOutputCapability**.|
431| surfaceId| string          | Yes  | Surface ID, which is obtained from [VideoRecorder](js-apis-media.md#videorecorder9).|
432
433**Return value**
434
435| Type       | Description                         |
436| ---------- | ----------------------------- |
437| [VideoOutput](#videooutput)   | **VideoOutput** instance created. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
438
439**Error codes**
440
441For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
442
443| ID        | Error Message       |
444| --------------- | --------------- |
445| 7400101                |  Parameter missing or parameter type incorrect               |
446
447**Example**
448
449```js
450let profile = cameraOutputCapability.videoProfiles[0];
451let videoOutput;
452try {
453    videoOutput = cameraManager.createVideoOutput(profile, surfaceId);
454} catch (error) {
455    // If the operation fails, error.code is returned and processed.
456    console.log(error.code);
457}
458```
459
460### createMetadataOutput
461
462createMetadataOutput(metadataObjectTypes:Array<MetadataObjectType\>): MetadataOutput
463
464Creates a **MetadataOutput** instance. This API returns the result synchronously.
465
466**System capability**: SystemCapability.Multimedia.Camera.Core
467
468**Parameters**
469
470| Name                 | Type                                              | Mandatory| Description                         |
471| -------------------- | -------------------------------------------------- | --- | ---------------------------- |
472| metadataObjectTypes  | Array<[MetadataObjectType](#metadataobjecttype)\>  | Yes | Metadata object types, which are obtained through **getSupportedOutputCapability**.|
473
474**Return value**
475
476| Type       | Description                         |
477| ---------- | ----------------------------- |
478| [MetadataOutput](#metadataoutput)   | **MetadataOutput** instance created. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
479
480**Error codes**
481
482For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
483
484| ID        | Error Message       |
485| --------------- | --------------- |
486| 7400101                |  Parameter missing or parameter type incorrect               |
487
488**Example**
489
490```js
491let metadataObjectTypes = cameraOutputCapability.supportedMetadataObjectTypes;
492let metadataOutput;
493try {
494    metadataOutput = cameraManager.createMetadataOutput(metadataObjectTypes);
495} catch (error) {
496    // If the operation fails, error.code is returned and processed.
497    console.log(error.code);
498}
499```
500
501### createCaptureSession
502
503createCaptureSession(): CaptureSession
504
505Creates a **CaptureSession** instance. This API returns the result synchronously.
506
507**System capability**: SystemCapability.Multimedia.Camera.Core
508
509**Return value**
510
511| Type       | Description                         |
512| ---------- | ----------------------------- |
513| [CaptureSession](#capturesession)   | **CaptureSession** instance created. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
514
515**Error codes**
516
517For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
518
519| ID        | Error Message       |
520| --------------- | --------------- |
521| 7400201                |  Camera service fatal error.               |
522
523**Example**
524
525```js
526let captureSession;
527try {
528    captureSession = cameraManager.createCaptureSession();
529} catch (error) {
530    // If the operation fails, error.code is returned and processed.
531    console.log(error.code);
532}
533```
534
535### on('cameraStatus')
536
537on(type: 'cameraStatus', callback: AsyncCallback<CameraStatusInfo\>): void
538
539Listens for camera status changes. This API uses an asynchronous callback to return the result.
540
541**System capability**: SystemCapability.Multimedia.Camera.Core
542
543**Parameters**
544
545| Name    | Type           | Mandatory| Description      |
546| -------- | -----------------| ---- | --------- |
547| 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 device is enabled or disabled.|
548| callback | AsyncCallback<[CameraStatusInfo](#camerastatusinfo)\> | Yes  | Callback used to return the camera status change.|                 |
549
550**Example**
551
552```js
553cameraManager.on('cameraStatus', (cameraStatusInfo) => {
554    console.log(`camera : ${cameraStatusInfo.camera.cameraId}`);
555    console.log(`status: ${cameraStatusInfo.status}`);
556})
557```
558
559### on('cameraMute')
560
561on(type: 'cameraMute', callback: AsyncCallback<boolean\>): void
562
563Listens for camera mute status changes. This API uses an asynchronous callback to return the result.
564
565This is a system API.
566
567**System capability**: SystemCapability.Multimedia.Camera.Core
568
569**Parameters**
570
571| Name    | Type            | Mandatory| Description      |
572| -------- | --------------- | ---- | --------- |
573| type     | string          | Yes  | Event type. The value is fixed at **'cameraMute'**, indicating the camera mute status. The event can be listened for when a **CameraManager** instance is obtained. This event is triggered and the status is returned when the camera is enabled or disabled.|
574| callback | AsyncCallback\<boolean> | Yes  | Callback used to return the mute status. The value **true** means that the camera is enabled, and **false** means that the camera is disabled.              |
575
576**Example**
577
578```js
579cameraManager.on('cameraMute', (curMuetd) => {
580    let isMuted = curMuetd;
581})
582```
583
584## CameraStatusInfo
585
586Describes the camera status information.
587
588**System capability**: SystemCapability.Multimedia.Camera.Core
589
590| Name  | Type                           |     Mandatory    | Description      |
591| ------ | ----------------------------- | -------------- | ---------- |
592| camera | [CameraDevice](#cameradevice) |        Yes      | Camera object.|
593| status | [CameraStatus](#camerastatus) |        Yes       | Camera status.|
594
595## CameraPosition
596
597Enumerates the camera positions.
598
599**System capability**: SystemCapability.Multimedia.Camera.Core
600
601| Name                        | Value  | Description           |
602| --------------------------- | ---- | -------------- |
603| CAMERA_POSITION_UNSPECIFIED | 0    | Unspecified position. |
604| CAMERA_POSITION_BACK        | 1    | Rear camera.      |
605| CAMERA_POSITION_FRONT       | 2    | Front camera.      |
606
607## CameraType
608
609Enumerates the camera types.
610
611**System capability**: SystemCapability.Multimedia.Camera.Core
612
613| Name                    | Value  | Description           |
614| ----------------------- | ---- | -------------- |
615| CAMERA_TYPE_DEFAULT     | 0    | Unspecified camera type. |
616| CAMERA_TYPE_WIDE_ANGLE  | 1    | Wide camera.      |
617| CAMERA_TYPE_ULTRA_WIDE  | 2    | Ultra wide camera.    |
618| CAMERA_TYPE_TELEPHOTO   | 3    | Telephoto camera.      |
619| CAMERA_TYPE_TRUE_DEPTH  | 4    | Camera with depth of field information.|
620
621## ConnectionType
622
623Enumerates the camera connection types.
624
625**System capability**: SystemCapability.Multimedia.Camera.Core
626
627| Name                         | Value  | Description          |
628| ---------------------------- | ---- | ------------- |
629| CAMERA_CONNECTION_BUILT_IN   | 0    | Built-in camera.     |
630| CAMERA_CONNECTION_USB_PLUGIN | 1    | Camera connected using USB.|
631| CAMERA_CONNECTION_REMOTE     | 2    | Remote camera.|
632
633## CameraDevice
634
635Defines the camera device information.
636
637**System capability**: SystemCapability.Multimedia.Camera.Core
638
639| Name          | Type                               | Mandatory| Description       |
640| -------------- | --------------------------------- | ---- | ---------- |
641| cameraId       | string                            | Yes  | **CameraDevice** object.|
642| cameraPosition | [CameraPosition](#cameraposition) | Yes  | Camera position.   |
643| cameraType     | [CameraType](#cameratype)         | Yes  | Camera type.   |
644| connectionType | [ConnectionType](#connectiontype) | Yes  | Camera connection type.|
645
646## Size
647
648Enumerates the camera output capability.
649
650**System capability**: SystemCapability.Multimedia.Camera.Core
651
652| Name  | Type  | Readable| Writable| Description        |
653| ------ | ------ | ---- | ---- | ------------ |
654| height | number | Yes  | Yes  | Image height, in pixels.|
655| width  | number | Yes  | Yes  | Image width, in pixels.|
656
657## Point
658
659Enumerates the point coordinates, which are used for focus and exposure configuration.
660
661**System capability**: SystemCapability.Multimedia.Camera.Core
662
663| Name  | Type  | Mandatory  | Description        |
664| ------ | ------ | ---- | ------------ |
665| x      | number | Yes   | X coordinate of a point.  |
666| y      | number | Yes   | Y coordinate of a point.  |
667
668## CameraFormat
669
670Enumerates the camera output formats.
671
672**System capability**: SystemCapability.Multimedia.Camera.Core
673
674| Name                    | Value       | Description        |
675| ----------------------- | --------- | ------------ |
676| CAMERA_FORMAT_RGBA_8888 | 3         | RGB image.            |
677| CAMERA_FORMAT_YUV_420_SP| 1003      | YUV 420 SP image.     |
678| CAMERA_FORMAT_JPEG      | 2000      | JPEG image.           |
679
680## CameraInput
681
682Provides camera information used in **[CaptureSession](#capturesession)**.
683
684### open
685
686open\(callback: AsyncCallback<void\>\): void
687
688Opens this camera. This API uses an asynchronous callback to return the result.
689
690**System capability**: SystemCapability.Multimedia.Camera.Core
691
692**Parameters**
693
694| Name    | Type                 | Mandatory| Description                 |
695| -------- | -------------------- | ---- | ------------------- |
696| callback | AsyncCallback<void\> | Yes  | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
697
698**Error codes**
699
700For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
701
702| ID        | Error Message       |
703| --------------- | --------------- |
704| 7400107                |  Can not use camera cause of conflict.               |
705| 7400108                |  Camera disabled cause of security reason.                                  |
706| 7400201                |  Camera service fatal error.                                  |
707
708**Example**
709
710```js
711cameraInput.open((err) => {
712    if (err) {
713        console.error(`Failed to open the camera. ${err.code}`);
714        return;
715    }
716    console.log('Callback returned with camera opened.');
717})
718```
719
720### open
721
722open(): Promise<void\>
723
724Opens this camera. This API uses a promise to return the result.
725
726**System capability**: SystemCapability.Multimedia.Camera.Core
727
728**Return value**
729
730| Type          | Description                     |
731| -------------- | ----------------------- |
732| Promise<void\>| Promise used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
733
734**Error codes**
735
736For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
737
738| ID        | Error Message       |
739| --------------- | --------------- |
740| 7400107                |  Can not use camera cause of conflict.               |
741| 7400108                |  Camera disabled cause of security reason.                                  |
742| 7400201                |  Camera service fatal error.                                  |
743
744**Example**
745
746```js
747cameraInput.open().then(() => {
748    console.log('Promise returned with camera opened.');
749}).catch((err) => {
750    console.error(`Failed to open the camera. ${err.code}`);
751});
752```
753
754### close
755
756close\(callback: AsyncCallback<void\>\): void
757
758Closes this camera. This API uses an asynchronous callback to return the result.
759
760**System capability**: SystemCapability.Multimedia.Camera.Core
761
762**Parameters**
763
764| Name    | Type                  | Mandatory| Description                 |
765| -------- | -------------------- | ---- | -------------------- |
766| callback | AsyncCallback<void\> | Yes  | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
767
768**Error codes**
769
770For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
771
772| ID        | Error Message       |
773| --------------- | --------------- |
774| 7400201                |  Camera service fatal error.                                  |
775
776**Example**
777
778```js
779cameraInput.close((err) => {
780    if (err) {
781        console.error(`Failed to close the cameras. ${err.code}`);
782        return;
783    }
784    console.log('Callback returned with camera closed.');
785})
786```
787
788### close
789
790close(): Promise<void\>
791
792Closes this camera. This API uses a promise to return the result.
793
794**System capability**: SystemCapability.Multimedia.Camera.Core
795
796**Return value**
797
798| Type          | Description                     |
799| -------------- | ----------------------- |
800| Promise<void\>| Promise used to return the result.|
801
802**Error codes**
803
804For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
805
806| ID        | Error Message       |
807| --------------- | --------------- |
808| 7400201                |  Camera service fatal error.                                  |
809
810**Example**
811
812```js
813cameraInput.close().then(() => {
814    console.log('Promise returned with camera closed.');
815}).catch((err) => {
816    console.error(`Failed to close the cameras. ${err.code}`);
817});
818```
819
820### on('error')
821
822on(type: 'error', cameraDevice:CameraDevice, callback: ErrorCallback<BusinessError\>): void
823
824Listens for **CameraInput** errors. This API uses a callback to return the result.
825
826**System capability**: SystemCapability.Multimedia.Camera.Core
827
828**Parameters**
829
830| Name    | Type                             | Mandatory| Description                                         |
831| -------- | -------------------------------- | --- | ------------------------------------------- |
832| 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. For example, if the device is unavailable or a conflict occurs, the error information is returned.|
833| cameraDevice   | [CameraDevice](#cameradevice)    | Yes  | **CameraDevice** object.|
834| callback | ErrorCallback<BusinessError\> | Yes  | Callback used to return an error code defined in [CameraErrorCode](#cameraerrorcode).  |
835
836**Example**
837
838```js
839let cameraDevice = cameras[0];
840cameraInput.on('error', cameraDevice, (error) => {
841    console.log(`Camera input error code: ${error.code}`);
842})
843```
844
845## FlashMode
846
847Enumerates the flash modes.
848
849**System capability**: SystemCapability.Multimedia.Camera.Core
850
851| Name                   | Value  | Description       |
852| ---------------------- | ---- | ---------- |
853| FLASH_MODE_CLOSE       | 0    | The flash is off.|
854| FLASH_MODE_OPEN        | 1    | The flash is on.|
855| FLASH_MODE_AUTO        | 2    | The flash mode is auto, indicating that the flash fires automatically depending on the shooting conditions.|
856| FLASH_MODE_ALWAYS_OPEN | 3    | The flash is steady on.|
857
858## ExposureMode
859
860Enumerates the exposure modes.
861
862**System capability**: SystemCapability.Multimedia.Camera.Core
863
864| Name                          | Value  | Description        |
865| ----------------------------- | ---- | ----------- |
866| EXPOSURE_MODE_LOCKED          | 0    | Exposure locked.|
867| EXPOSURE_MODE_AUTO            | 1    | Auto exposure.|
868| EXPOSURE_MODE_CONTINUOUS_AUTO | 2    | Continuous auto exposure.|
869
870 ## FocusMode
871
872Enumerates the focus modes.
873
874**System capability**: SystemCapability.Multimedia.Camera.Core
875
876| Name                       | Value  | Description         |
877| -------------------------- | ---- | ------------ |
878| FOCUS_MODE_MANUAL          | 0    | Manual focus.    |
879| FOCUS_MODE_CONTINUOUS_AUTO | 1    | Continuous auto focus.|
880| FOCUS_MODE_AUTO            | 2    | Auto focus.    |
881| FOCUS_MODE_LOCKED          | 3    | Focus locked.    |
882
883## FocusState
884
885Enumerates the focus states.
886
887**System capability**: SystemCapability.Multimedia.Camera.Core
888
889| Name                  | Value  | Description      |
890| --------------------- | ---- | --------- |
891| FOCUS_STATE_SCAN      | 0    | Focusing. |
892| FOCUS_STATE_FOCUSED   | 1    | Focused. |
893| FOCUS_STATE_UNFOCUSED | 2    | Unfocused.|
894
895## VideoStabilizationMode
896
897Enumerates the video stabilization modes.
898
899**System capability**: SystemCapability.Multimedia.Camera.Core
900
901| Name      | Value  | Description        |
902| --------- | ---- | ------------ |
903| OFF       | 0    | Video stabilization is disabled.  |
904| LOW       | 1    | The basic video stabilization algorithm is used.  |
905| MIDDLE    | 2    | A video stabilization algorithm with a stabilization effect better than that of the **LOW** type is used.  |
906| HIGH      | 3    | A video stabilization algorithm with a stabilization effect better than that of the **MIDDLE** type is used.  |
907| AUTO      | 4    | Automatic video stabilization is used.  |
908
909## CaptureSession
910
911Implements a shooting 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.
912
913### beginConfig
914
915beginConfig(): void
916
917Starts configuration for the session.
918
919**System capability**: SystemCapability.Multimedia.Camera.Core
920
921**Return value**
922
923| Type       | Description                         |
924| ---------- | ----------------------------- |
925| [CameraErrorCode](#cameraerrorcode)    | If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
926
927**Error codes**
928
929For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
930
931| ID        | Error Message       |
932| --------------- | --------------- |
933| 7400105                |  Session config locked.               |
934
935**Example**
936
937```js
938try {
939    captureSession.beginConfig();
940} catch (error) {
941    // If the operation fails, error.code is returned and processed.
942    console.log(error.code);
943}
944```
945
946### commitConfig
947
948commitConfig(callback: AsyncCallback<void\>): void
949
950Commits the configuration for this **CaptureSession** instance. This API uses an asynchronous callback to return the result.
951
952**System capability**: SystemCapability.Multimedia.Camera.Core
953
954**Parameters**
955
956| Name    | Type                  | Mandatory| Description                 |
957| -------- | -------------------- | ---- | -------------------- |
958| callback | AsyncCallback<void\> | Yes  | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
959
960**Error codes**
961
962For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
963
964| ID        | Error Message       |
965| --------------- | --------------- |
966| 7400102                |  Operation not allow.                                  |
967| 7400201                |  Camera service fatal error.                           |
968
969**Example**
970
971```js
972captureSession.commitConfig((err) => {
973    if (err) {
974        console.log('Failed to commitConfig '+ err.code);
975        return;
976    }
977    console.log('Callback invoked to indicate the commit config success.');
978});
979```
980
981### commitConfig
982
983commitConfig(): Promise<void\>
984
985Commits the configuration for this **CaptureSession** instance. This API uses a promise to return the result.
986
987**System capability**: SystemCapability.Multimedia.Camera.Core
988
989**Return value**
990
991| Type           | Description                     |
992| -------------- | ------------------------ |
993| Promise<void\>| Promise used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
994
995**Error codes**
996
997For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
998
999| ID        | Error Message       |
1000| --------------- | --------------- |
1001| 7400102                |  Operation not allow.                                  |
1002| 7400201                |  Camera service fatal error.                           |
1003
1004**Example**
1005
1006```js
1007captureSession.commitConfig().then(() => {
1008    console.log('Promise returned to indicate the commit config success.');
1009}).catch((err) => {
1010    // If the operation fails, error.code is returned and processed.
1011    console.log('Failed to commitConfig '+ err.code);
1012});
1013```
1014
1015### addInput
1016
1017addInput(cameraInput: CameraInput): void
1018
1019Adds a [CameraInput](#camerainput) instance to the session.
1020
1021**System capability**: SystemCapability.Multimedia.Camera.Core
1022
1023**Parameters**
1024
1025| Name       | Type                         | Mandatory| Description                    |
1026| ----------- | --------------------------- | ---- | ------------------------ |
1027| cameraInput | [CameraInput](#camerainput) | Yes  | **CameraInput** instance to add.|
1028
1029**Return value**
1030
1031| Type       | Description                         |
1032| ---------- | ----------------------------- |
1033| [CameraErrorCode](#cameraerrorcode)    | If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
1034
1035**Error codes**
1036
1037For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
1038
1039| ID        | Error Message       |
1040| --------------- | --------------- |
1041| 7400101                |  Parameter missing or parameter type incorrect        |
1042| 7400102                |  Operation not allow.                                  |
1043
1044**Example**
1045
1046```js
1047try {
1048    captureSession.addInput(cameraInput);
1049} catch (error) {
1050    // If the operation fails, error.code is returned and processed.
1051    console.log(error.code);
1052}
1053```
1054
1055### removeInput
1056
1057removeInput(cameraInput: CameraInput): void
1058
1059Removes a [CameraInput](#camerainput) instance from the session.
1060
1061**System capability**: SystemCapability.Multimedia.Camera.Core
1062
1063**Parameters**
1064
1065| Name       | Type                         | Mandatory| Description                     |
1066| ----------- | --------------------------- | ---- | ------------------------ |
1067| cameraInput | [CameraInput](#camerainput) | Yes  | **CameraInput** instance to remove.|
1068
1069**Return value**
1070
1071| Type       | Description                         |
1072| ---------- | ----------------------------- |
1073| [CameraErrorCode](#cameraerrorcode)    | If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
1074
1075**Error codes**
1076
1077For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
1078
1079| ID        | Error Message       |
1080| --------------- | --------------- |
1081| 7400101                |  Parameter missing or parameter type incorrect        |
1082| 7400102                |  Operation not allow.                                  |
1083
1084**Example**
1085
1086```js
1087try {
1088    captureSession.removeInput(cameraInput);
1089} catch (error) {
1090    // If the operation fails, error.code is returned and processed.
1091    console.log(error.code);
1092}
1093```
1094
1095### addOutput
1096
1097addOutput(previewOutput: CameraOutput): void
1098
1099Adds a [CameraOutput](#cameraoutput) instance to the session.
1100
1101**System capability**: SystemCapability.Multimedia.Camera.Core
1102
1103**Parameters**
1104
1105| Name          | Type                            | Mandatory| Description                     |
1106| ------------- | ------------------------------- | ---- | ------------------------ |
1107| previewOutput  | [PreviewOutput](#previewoutput)   | Yes  | **PreviewOutput** instance to add.|
1108
1109**Return value**
1110
1111| Type       | Description                         |
1112| ---------- | ----------------------------- |
1113| [CameraErrorCode](#cameraerrorcode)    | If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
1114
1115**Error codes**
1116
1117For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
1118
1119| ID        | Error Message       |
1120| --------------- | --------------- |
1121| 7400101                |  Parameter missing or parameter type incorrect        |
1122| 7400102                |  Operation not allow.                                  |
1123
1124**Example**
1125
1126```js
1127try {
1128    captureSession.addOutput(previewOutput);
1129} catch (error) {
1130    // If the operation fails, error.code is returned and processed.
1131    console.log(error.code);
1132}
1133```
1134
1135### removeOutput
1136
1137removeOutput(previewOutput: CameraOutput): void
1138
1139Removes a [CameraOutput](#cameraoutput) instance from the session.
1140
1141**System capability**: SystemCapability.Multimedia.Camera.Core
1142
1143**Parameters**
1144
1145| Name          | Type                            | Mandatory| Description                     |
1146| ------------- | ------------------------------- | ---- | ------------------------ |
1147| previewOutput  | [PreviewOutput](#previewoutput)   | Yes  | **PreviewOutput** instance to remove.|
1148
1149**Return value**
1150
1151| Type       | Description                         |
1152| ---------- | ----------------------------- |
1153| [CameraErrorCode](#cameraerrorcode)    | If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
1154
1155**Error codes**
1156
1157For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
1158
1159| ID        | Error Message       |
1160| --------------- | --------------- |
1161| 7400101                |  Parameter missing or parameter type incorrect        |
1162| 7400102                |  Operation not allow.                                  |
1163
1164**Example**
1165
1166```js
1167try {
1168    captureSession.removeOutput(previewOutput);
1169} catch (error) {
1170    // If the operation fails, error.code is returned and processed.
1171    console.log(error.code);
1172}
1173```
1174
1175### start
1176
1177start\(callback: AsyncCallback<void\>\): void
1178
1179Starts this **CaptureSession**. This API uses an asynchronous callback to return the result.
1180
1181**System capability**: SystemCapability.Multimedia.Camera.Core
1182
1183**Parameters**
1184
1185| Name     | Type                 | Mandatory| Description                |
1186| -------- | -------------------- | ---- | -------------------- |
1187| callback | AsyncCallback<void\> | Yes  | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
1188
1189**Error codes**
1190
1191For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
1192
1193| ID        | Error Message       |
1194| --------------- | --------------- |
1195| 7400103                |  Session not config.                                   |
1196| 7400201                |  Camera service fatal error.                           |
1197
1198**Example**
1199
1200```js
1201captureSession.start((err) => {
1202    if (err) {
1203        console.error(`Failed to start the session ${err.code}`);
1204        return;
1205    }
1206    console.log('Callback invoked to indicate the session start success.');
1207});
1208```
1209
1210### start
1211
1212start\(\): Promise<void\>
1213
1214Starts this **CaptureSession**. This API uses a promise to return the result.
1215
1216**System capability**: SystemCapability.Multimedia.Camera.Core
1217
1218**Return value**
1219
1220| Type           | Description                    |
1221| -------------- | ------------------------ |
1222| Promise<void\>| Promise used to return the result.|
1223
1224**Error codes**
1225
1226For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
1227
1228| ID        | Error Message       |
1229| --------------- | --------------- |
1230| 7400103                |  Session not config.                                   |
1231| 7400201                |  Camera service fatal error.                           |
1232
1233**Example**
1234
1235```js
1236captureSession.start().then(() => {
1237    console.log('Promise returned to indicate the session start success.');
1238}).catch((err) => {
1239    console.error(`Failed to start the session ${err.code}`);
1240});
1241```
1242
1243### stop
1244
1245stop\(callback: AsyncCallback<void\>\): void
1246
1247Stops this **CaptureSession**. This API uses an asynchronous callback to return the result.
1248
1249**System capability**: SystemCapability.Multimedia.Camera.Core
1250
1251**Parameters**
1252
1253| Name     | Type                 | Mandatory| Description                |
1254| -------- | -------------------- | ---- | ------------------- |
1255| callback | AsyncCallback<void\> | Yes  | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
1256
1257**Error codes**
1258
1259For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
1260
1261| ID        | Error Message       |
1262| --------------- | --------------- |
1263| 7400201                |  Camera service fatal error.                           |
1264
1265**Example**
1266
1267```js
1268captureSession.stop((err) => {
1269    if (err) {
1270        console.error(`Failed to stop the session ${err.code}`);
1271        return;
1272    }
1273    console.log('Callback invoked to indicate the session stop success.');
1274});
1275```
1276
1277### stop
1278
1279stop(): Promise<void\>
1280
1281Stops this **CaptureSession**. This API uses a promise to return the result.
1282
1283**System capability**: SystemCapability.Multimedia.Camera.Core
1284
1285**Return value**
1286
1287| Type           | Description                    |
1288| -------------- | ----------------------- |
1289| Promise<void\>| Promise used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
1290
1291**Error codes**
1292
1293For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
1294
1295| ID        | Error Message       |
1296| --------------- | --------------- |
1297| 7400201                |  Camera service fatal error.                           |
1298
1299**Example**
1300
1301```js
1302captureSession.stop().then(() => {
1303    console.log('Promise returned to indicate the session stop success.');
1304}).catch((err) => {
1305    console.error(`Failed to stop the session ${err.code}`);
1306});
1307```
1308
1309### release
1310
1311release\(callback: AsyncCallback<void\>\): void
1312
1313Releases this **CaptureSession**. This API uses an asynchronous callback to return the result.
1314
1315**System capability**: SystemCapability.Multimedia.Camera.Core
1316
1317**Parameters**
1318
1319| Name     | Type                 | Mandatory| Description                |
1320| -------- | -------------------- | ---- | -------------------- |
1321| callback | AsyncCallback<void\> | Yes  | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
1322
1323**Error codes**
1324
1325For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
1326
1327| ID        | Error Message       |
1328| --------------- | --------------- |
1329| 7400201                |  Camera service fatal error.                           |
1330
1331**Example**
1332
1333```js
1334captureSession.release((err) => {
1335    if (err) {
1336        console.error(`Failed to release the CaptureSession instance ${err.code}`);
1337        return;
1338    }
1339    console.log('Callback invoked to indicate that the CaptureSession instance is released successfully.');
1340});
1341```
1342
1343### release
1344
1345release(): Promise<void\>
1346
1347Releases this **CaptureSession**. This API uses a promise to return the result.
1348
1349**System capability**: SystemCapability.Multimedia.Camera.Core
1350
1351**Return value**
1352
1353| Type           | Description                    |
1354| -------------- | ------------------------ |
1355| Promise<void\>| Promise used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
1356
1357**Error codes**
1358
1359For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
1360
1361| ID        | Error Message       |
1362| --------------- | --------------- |
1363| 7400201                |  Camera service fatal error.                           |
1364
1365**Example**
1366
1367```js
1368captureSession.release().then(() => {
1369    console.log('Promise returned to indicate that the CaptureSession instance is released successfully.');
1370}).catch((err) => {
1371    console.error(`Failed to release the CaptureSession instance ${err.code}`);
1372});
1373```
1374
1375### hasFlash
1376
1377hasFlash(): boolean
1378
1379Checks whether the device has flash. This API uses an asynchronous callback to return the result.
1380
1381**System capability**: SystemCapability.Multimedia.Camera.Core
1382
1383**Return value**
1384
1385| Type       | Description                         |
1386| ---------- | ----------------------------- |
1387| boolean    | Returns **true** if the device has flash; returns **false** otherwise. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
1388
1389**Error codes**
1390
1391For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
1392
1393| ID        | Error Message       |
1394| --------------- | --------------- |
1395| 7400103                |  Session not config.                                   |
1396
1397**Example**
1398
1399```js
1400try {
1401    let status = captureSession.hasFlash();
1402} catch (error) {
1403    // If the operation fails, error.code is returned and processed.
1404    console.log(error.code);
1405}
1406```
1407
1408### isFlashModeSupported
1409
1410isFlashModeSupported(flashMode: FlashMode): boolean
1411
1412Checks whether a flash mode is supported.
1413
1414**System capability**: SystemCapability.Multimedia.Camera.Core
1415
1416**Parameters**
1417
1418| Name      | Type                    | Mandatory| Description                              |
1419| --------- | ----------------------- | ---- | --------------------------------- |
1420| flashMode | [FlashMode](#flashmode) | Yes  | Flash mode.                    |
1421
1422**Return value**
1423
1424| Type       | Description                         |
1425| ---------- | ----------------------------- |
1426| boolean    | Returns **true** if the flash mode is supported; returns **false** otherwise. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
1427
1428**Error codes**
1429
1430For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
1431
1432| ID        | Error Message       |
1433| --------------- | --------------- |
1434| 7400103                |  Session not config.                                   |
1435
1436**Example**
1437
1438```js
1439try {
1440    let status = captureSession.isFlashModeSupported(camera.FlashMode.FLASH_MODE_AUTO);
1441} catch (error) {
1442    // If the operation fails, error.code is returned and processed.
1443    console.log(error.code);
1444}
1445```
1446
1447### setFlashMode
1448
1449setFlashMode(flashMode: FlashMode): void
1450
1451Sets a flash mode for the device.
1452
1453Before the setting, do the following checks:
1454
14551. Use **[hasFlash](#hasflash)** to check whether the device has flash.
14562. Use **[isFlashModeSupported](#isflashmodesupported)** to check whether the device supports the flash mode.
1457
1458**System capability**: SystemCapability.Multimedia.Camera.Core
1459
1460**Parameters**
1461
1462| Name      | Type                    | Mandatory| Description                 |
1463| --------- | ----------------------- | ---- | --------------------- |
1464| flashMode | [FlashMode](#flashmode) | Yes  | Flash mode.      |
1465
1466**Return value**
1467
1468| Type       | Description                         |
1469| ---------- | ----------------------------- |
1470| [CameraErrorCode](#cameraerrorcode)    | If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
1471
1472**Error codes**
1473
1474For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
1475
1476| ID        | Error Message       |
1477| --------------- | --------------- |
1478| 7400103                |  Session not config.                                   |
1479
1480**Example**
1481
1482```js
1483try {
1484    captureSession.setFlashMode(camera.FlashMode.FLASH_MODE_AUTO);
1485} catch (error) {
1486    // If the operation fails, error.code is returned and processed.
1487    console.log(error.code);
1488}
1489```
1490
1491### getFlashMode
1492
1493getFlashMode(): FlashMode
1494
1495Obtains the flash mode in use.
1496
1497**System capability**: SystemCapability.Multimedia.Camera.Core
1498
1499**Return value**
1500
1501| Type       | Description                         |
1502| ---------- | ----------------------------- |
1503| [FlashMode](#flashmode)    | Flash mode obtained. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
1504
1505**Error codes**
1506
1507For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
1508
1509| ID        | Error Message       |
1510| --------------- | --------------- |
1511| 7400103                |  Session not config.                                   |
1512
1513**Example**
1514
1515```js
1516try {
1517    let flashMode = captureSession.getFlashMode();
1518} catch (error) {
1519    // If the operation fails, error.code is returned and processed.
1520    console.log(error.code);
1521}
1522```
1523
1524### isExposureModeSupported
1525
1526isExposureModeSupported(aeMode: ExposureMode): boolean;
1527
1528Checks whether an exposure mode is supported.
1529
1530**System capability**: SystemCapability.Multimedia.Camera.Core
1531
1532**Parameters**
1533
1534| Name     | Type                          | Mandatory | Description                          |
1535| -------- | -------------------------------| ---- | ----------------------------- |
1536| aeMode   | [ExposureMode](#exposuremode)  | Yes  | Exposure mode.                     |
1537
1538**Return value**
1539
1540| Type       | Description                         |
1541| ---------- | ----------------------------- |
1542| boolean    | Returns **true** if the exposure mode is supported; returns **false** otherwise. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
1543
1544**Error codes**
1545
1546For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
1547
1548| ID        | Error Message       |
1549| --------------- | --------------- |
1550| 7400103                |  Session not config.                                   |
1551
1552**Example**
1553
1554```js
1555try {
1556    let isSupported = captureSession.isExposureModeSupported(camera.ExposureMode.EXPOSURE_MODE_LOCKED);
1557} catch (error) {
1558    // If the operation fails, error.code is returned and processed.
1559    console.log(error.code);
1560}
1561```
1562
1563### getExposureMode
1564
1565getExposureMode(): ExposureMode
1566
1567Obtains the exposure mode in use.
1568
1569**System capability**: SystemCapability.Multimedia.Camera.Core
1570
1571**Return value**
1572
1573| Type       | Description                         |
1574| ---------- | ----------------------------- |
1575| [ExposureMode](#exposuremode)    | Exposure mode obtained. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
1576
1577**Error codes**
1578
1579For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
1580
1581| ID        | Error Message       |
1582| --------------- | --------------- |
1583| 7400103                |  Session not config.                                   |
1584
1585**Example**
1586
1587```js
1588try {
1589    let exposureMode = captureSession.getExposureMode();
1590} catch (error) {
1591    // If the operation fails, error.code is returned and processed.
1592    console.log(error.code);
1593}
1594```
1595
1596### setExposureMode
1597
1598setExposureMode(aeMode: ExposureMode): void
1599
1600Sets an exposure mode for the device.
1601
1602**System capability**: SystemCapability.Multimedia.Camera.Core
1603
1604**Parameters**
1605
1606| Name     | Type                           | Mandatory| Description                   |
1607| -------- | -------------------------------| ---- | ----------------------- |
1608| aeMode   | [ExposureMode](#exposuremode)  | Yes  | Exposure mode.               |
1609
1610**Return value**
1611
1612| Type       | Description                         |
1613| ---------- | ----------------------------- |
1614| [CameraErrorCode](#cameraerrorcode)    | If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
1615
1616**Error codes**
1617
1618For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
1619
1620| ID        | Error Message       |
1621| --------------- | --------------- |
1622| 7400103                |  Session not config.                                   |
1623
1624**Example**
1625
1626```js
1627try {
1628    captureSession.setExposureMode(camera.ExposureMode.EXPOSURE_MODE_LOCKED);
1629} catch (error) {
1630    // If the operation fails, error.code is returned and processed.
1631    console.log(error.code);
1632}
1633```
1634
1635### getMeteringPoint
1636
1637getMeteringPoint(): Point
1638
1639Obtains the metering point of the device.
1640
1641**System capability**: SystemCapability.Multimedia.Camera.Core
1642
1643**Return value**
1644
1645| Type       | Description                         |
1646| ---------- | ----------------------------- |
1647| [Point](#point)    | Metering point obtained. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
1648
1649**Error codes**
1650
1651For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
1652
1653| ID        | Error Message       |
1654| --------------- | --------------- |
1655| 7400103                |  Session not config.                                   |
1656
1657**Example**
1658
1659```js
1660try {
1661    let exposurePoint = captureSession.getMeteringPoint();
1662} catch (error) {
1663    // If the operation fails, error.code is returned and processed.
1664    console.log(error.code);
1665}
1666```
1667
1668### setMeteringPoint
1669
1670setMeteringPoint(point: Point): void
1671
1672Sets the metering point, which is the center point of the metering rectangle.
1673
1674**System capability**: SystemCapability.Multimedia.Camera.Core
1675
1676**Parameters**
1677
1678| Name          | Type                           | Mandatory| Description                |
1679| ------------- | -------------------------------| ---- | ------------------- |
1680| exposurePoint | [Point](#point)                | Yes  | Exposure point.             |
1681
1682**Return value**
1683
1684| Type       | Description                         |
1685| ---------- | ----------------------------- |
1686| [CameraErrorCode](#cameraerrorcode)    | If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
1687
1688**Error codes**
1689
1690For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
1691
1692| ID        | Error Message       |
1693| --------------- | --------------- |
1694| 7400103                |  Session not config.                                   |
1695
1696**Example**
1697
1698```js
1699const exposurePoint = {x: 1, y: 1};
1700try {
1701    captureSession.setMeteringPoint(exposurePoint);
1702} catch (error) {
1703    // If the operation fails, error.code is returned and processed.
1704    console.log(error.code);
1705}
1706```
1707
1708### getExposureBiasRange
1709
1710getExposureBiasRange(): Array<number\>
1711
1712Obtains the exposure compensation values of the device.
1713
1714**System capability**: SystemCapability.Multimedia.Camera.Core
1715
1716**Return value**
1717
1718| Type       | Description                         |
1719| ---------- | ----------------------------- |
1720| Array<number\>   | An array of compensation values. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
1721
1722**Error codes**
1723
1724For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
1725
1726| ID        | Error Message       |
1727| --------------- | --------------- |
1728| 7400103                |  Session not config.                                   |
1729
1730**Example**
1731
1732```js
1733try {
1734    let biasRangeArray = captureSession.getExposureBiasRange();
1735} catch (error) {
1736    // If the operation fails, error.code is returned and processed.
1737    console.log(error.code);
1738}
1739```
1740
1741### setExposureBias
1742
1743setExposureBias(exposureBias: number): void
1744
1745Sets an exposure compensation value (EV).
1746
1747Before the setting, you are advised to use **[getExposureBiasRange](#getexposurebiasrange)** to obtain the supported values.
1748
1749**System capability**: SystemCapability.Multimedia.Camera.Core
1750
1751**Parameters**
1752
1753| Name    | Type                           | Mandatory| Description                |
1754| -------- | -------------------------------| ---- | ------------------- |
1755| exposureBias   | number                   | Yes  | Exposure bias to set, which must be within the range obtained by running **getExposureBiasRange** interface. If the API call fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
1756
1757**Error codes**
1758
1759For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
1760
1761| ID        | Error Message       |
1762| --------------- | --------------- |
1763| 7400103                |  Session not config.                                   |
1764
1765**Example**
1766
1767```js
1768let exposureBias = biasRangeArray[0];
1769try {
1770    captureSession.setExposureBias(exposureBias);
1771} catch (error) {
1772    // If the operation fails, error.code is returned and processed.
1773    console.log(error.code);
1774}
1775```
1776
1777### getExposureValue
1778
1779getExposureValue(): number
1780
1781Obtains the exposure value in use.
1782
1783**System capability**: SystemCapability.Multimedia.Camera.Core
1784
1785**Return value**
1786
1787| Type       | Description                         |
1788| ---------- | ----------------------------- |
1789| number    | Exposure value obtained. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
1790
1791**Error codes**
1792
1793For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
1794
1795| ID        | Error Message       |
1796| --------------- | --------------- |
1797| 7400103                |  Session not config.                                   |
1798
1799**Example**
1800
1801```js
1802try {
1803    let exposureValue = captureSession.getExposureValue();
1804} catch (error) {
1805    // If the operation fails, error.code is returned and processed.
1806    console.log(error.code);
1807}
1808```
1809
1810### isFocusModeSupported
1811
1812isFocusModeSupported(afMode: FocusMode): boolean
1813
1814Checks whether a focus mode is supported.
1815
1816**System capability**: SystemCapability.Multimedia.Camera.Core
1817
1818**Parameters**
1819
1820| Name     | Type                    | Mandatory| Description                             |
1821| -------- | ----------------------- | ---- | -------------------------------- |
1822| afMode   | [FocusMode](#focusmode) | Yes  | Focus mode.                   |
1823
1824**Return value**
1825
1826| Type       | Description                         |
1827| ---------- | ----------------------------- |
1828| boolean    | Returns **true** if the focus mode is supported; returns **false** otherwise. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
1829
1830**Error codes**
1831
1832For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
1833
1834| ID        | Error Message       |
1835| --------------- | --------------- |
1836| 7400103                |  Session not config.                                   |
1837
1838**Example**
1839
1840```js
1841try {
1842    let status = captureSession.isFocusModeSupported(camera.FocusMode.FOCUS_MODE_AUTO);
1843} catch (error) {
1844    // If the operation fails, error.code is returned and processed.
1845    console.log(error.code);
1846}
1847```
1848
1849### setFocusMode
1850
1851setFocusMode(afMode: FocusMode): void
1852
1853Sets a focus mode for the device.
1854
1855Before the setting, use **[isFocusModeSupported](#isfocusmodesupported)** to check whether the focus mode is supported.
1856
1857**System capability**: SystemCapability.Multimedia.Camera.Core
1858
1859**Parameters**
1860
1861| Name     | Type                    | Mandatory| Description                |
1862| -------- | ----------------------- | ---- | ------------------- |
1863| afMode   | [FocusMode](#focusmode) | Yes  | Focus mode.      |
1864
1865**Return value**
1866
1867| Type       | Description                         |
1868| ---------- | ----------------------------- |
1869| [CameraErrorCode](#cameraerrorcode)    | If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
1870
1871**Error codes**
1872
1873For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
1874
1875| ID        | Error Message       |
1876| --------------- | --------------- |
1877| 7400103                |  Session not config.                                   |
1878
1879**Example**
1880
1881```js
1882try {
1883    captureSession.setFocusMode(camera.FocusMode.FOCUS_MODE_AUTO);
1884} catch (error) {
1885    // If the operation fails, error.code is returned and processed.
1886    console.log(error.code);
1887}
1888```
1889
1890### getFocusMode
1891
1892getFocusMode(): FocusMode
1893
1894Obtains the focus mode in use.
1895
1896**System capability**: SystemCapability.Multimedia.Camera.Core
1897
1898**Return value**
1899
1900| Type       | Description                         |
1901| ---------- | ----------------------------- |
1902| [FocusMode](#focusmode)   | Focus mode obtained. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
1903
1904**Error codes**
1905
1906For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
1907
1908| ID        | Error Message       |
1909| --------------- | --------------- |
1910| 7400103                |  Session not config.                                   |
1911
1912**Example**
1913
1914```js
1915try {
1916    let afMode = captureSession.getFocusMode();
1917} catch (error) {
1918    // If the operation fails, error.code is returned and processed.
1919    console.log(error.code);
1920}
1921```
1922
1923### setFocusPoint
1924
1925setFocusPoint(point: Point): void
1926
1927Sets the focal point.
1928
1929**System capability**: SystemCapability.Multimedia.Camera.Core
1930
1931**Parameters**
1932
1933| Name     | Type                    | Mandatory| Description                |
1934| -------- | ----------------------- | ---- | ------------------- |
1935| Point1    | [Point](#point)         | Yes  | Focal point.               |
1936
1937**Return value**
1938
1939| Type       | Description                         |
1940| ---------- | ----------------------------- |
1941| [CameraErrorCode](#cameraerrorcode)    | If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
1942
1943**Error codes**
1944
1945For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
1946
1947| ID        | Error Message       |
1948| --------------- | --------------- |
1949| 7400103                |  Session not config.                                   |
1950
1951**Example**
1952
1953```js
1954const Point1 = {x: 1, y: 1};
1955try {
1956    captureSession.setFocusPoint(Point1);
1957} catch (error) {
1958    // If the operation fails, error.code is returned and processed.
1959    console.log(error.code);
1960}
1961```
1962
1963### getFocusPoint
1964
1965getFocusPoint(): Point
1966
1967Obtains the focal point of the device.
1968
1969**System capability**: SystemCapability.Multimedia.Camera.Core
1970
1971**Return value**
1972
1973| Type       | Description                         |
1974| ---------- | ----------------------------- |
1975| [Point](#point)    | Focal point obtained. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
1976
1977**Error codes**
1978
1979For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
1980
1981| ID        | Error Message       |
1982| --------------- | --------------- |
1983| 7400103                |  Session not config.                                   |
1984
1985**Example**
1986
1987```js
1988try {
1989    let point = captureSession.getFocusPoint();
1990} catch (error) {
1991    // If the operation fails, error.code is returned and processed.
1992    console.log(error.code);
1993}
1994```
1995
1996### getFocalLength
1997
1998getFocalLength(): number
1999
2000Obtains the focal length of the device.
2001
2002**System capability**: SystemCapability.Multimedia.Camera.Core
2003
2004**Return value**
2005
2006| Type       | Description                         |
2007| ---------- | ----------------------------- |
2008| number    | Focal length obtained. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
2009
2010**Error codes**
2011
2012For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
2013
2014| ID        | Error Message       |
2015| --------------- | --------------- |
2016| 7400103                |  Session not config.                                   |
2017
2018**Example**
2019
2020```js
2021try {
2022    let focalLength = captureSession.getFocalLength();
2023} catch (error) {
2024    // If the operation fails, error.code is returned and processed.
2025    console.log(error.code);
2026}
2027```
2028
2029### getZoomRatioRange
2030
2031getZoomRatioRange(): Array<number\>
2032
2033Obtains the supported zoom ratio range.
2034
2035**System capability**: SystemCapability.Multimedia.Camera.Core
2036
2037**Return value**
2038
2039| Type       | Description                         |
2040| ---------- | ----------------------------- |
2041| Array<number\>   | Callback used to return an array containing the minimum and maximum zoom ratios. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
2042
2043**Error codes**
2044
2045For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
2046
2047| ID        | Error Message       |
2048| --------------- | --------------- |
2049| 7400103                |  Session not config.                                   |
2050
2051**Example**
2052
2053```js
2054try {
2055    let zoomRatioRange = captureSession.getZoomRatioRange();
2056} catch (error) {
2057    // If the operation fails, error.code is returned and processed.
2058    console.log(error.code);
2059}
2060```
2061
2062### setZoomRatio
2063
2064setZoomRatio(zoomRatio: number): void
2065
2066Sets a zoom ratio.
2067
2068**System capability**: SystemCapability.Multimedia.Camera.Core
2069
2070**Parameters**
2071
2072| Name      | Type                 | Mandatory| Description                |
2073| --------- | -------------------- | ---- | ------------------- |
2074| zoomRatio | number               | Yes  | Zoom ratio. You can use **getZoomRatioRange** to obtain the supported values.|
2075
2076**Return value**
2077
2078| Type       | Description                         |
2079| ---------- | ----------------------------- |
2080| [CameraErrorCode](#cameraerrorcode)    | If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
2081
2082**Error codes**
2083
2084For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
2085
2086| ID        | Error Message       |
2087| --------------- | --------------- |
2088| 7400103                |  Session not config.                                   |
2089
2090**Example**
2091
2092```js
2093let zoomRatio = zoomRatioRange[0];
2094try {
2095    captureSession.setZoomRatio(zoomRatio);
2096} catch (error) {
2097    // If the operation fails, error.code is returned and processed.
2098    console.log(error.code);
2099}
2100```
2101
2102### getZoomRatio
2103
2104getZoomRatio(): number
2105
2106Obtains the zoom ratio in use.
2107
2108**System capability**: SystemCapability.Multimedia.Camera.Core
2109
2110**Return value**
2111
2112| Type       | Description                         |
2113| ---------- | ----------------------------- |
2114| number    | Zoom ratio obtained. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
2115
2116**Error codes**
2117
2118For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
2119
2120| ID        | Error Message       |
2121| --------------- | --------------- |
2122| 7400103                |  Session not config.                                   |
2123
2124**Example**
2125
2126```js
2127try {
2128    let zoomRatio = captureSession.getZoomRatio();
2129} catch (error) {
2130    // If the operation fails, error.code is returned and processed.
2131    console.log(error.code);
2132}
2133```
2134
2135### isVideoStabilizationModeSupported
2136
2137isVideoStabilizationModeSupported(vsMode: VideoStabilizationMode): boolean
2138
2139Checks whether the specified video stabilization mode is supported.
2140
2141**System capability**: SystemCapability.Multimedia.Camera.Core
2142
2143**Parameters**
2144
2145| Name     | Type                                             | Mandatory| Description                            |
2146| -------- | ------------------------------------------------- | ---- | ------------------------------ |
2147| vsMode   | [VideoStabilizationMode](#videostabilizationmode) | Yes  | Video stabilization mode.                   |
2148
2149**Return value**
2150
2151| Type       | Description                         |
2152| ---------- | ----------------------------- |
2153| boolean    | Returns **true** if the video stabilization mode is supported; returns **false** otherwise. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
2154
2155**Error codes**
2156
2157For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
2158
2159| ID        | Error Message       |
2160| --------------- | --------------- |
2161| 7400103                |  Session not config.                                   |
2162
2163**Example**
2164
2165```js
2166try {
2167    let isSupported = captureSession.isVideoStabilizationModeSupported(camera.VideoStabilizationMode.OFF);
2168} catch (error) {
2169    // If the operation fails, error.code is returned and processed.
2170    console.log(error.code);
2171}
2172```
2173
2174### getActiveVideoStabilizationMode
2175
2176getActiveVideoStabilizationMode(): VideoStabilizationMode
2177
2178Obtains the video stabilization mode in use.
2179
2180**System capability**: SystemCapability.Multimedia.Camera.Core
2181
2182**Return value**
2183
2184| Type       | Description                         |
2185| ---------- | ----------------------------- |
2186| VideoStabilizationMode    | Video stabilization mode obtained. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
2187
2188**Error codes**
2189
2190For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
2191
2192| ID        | Error Message       |
2193| --------------- | --------------- |
2194| 7400103                |  Session not config.                                   |
2195
2196**Example**
2197
2198```js
2199try {
2200    let vsMode = captureSession.getActiveVideoStabilizationMode();
2201} catch (error) {
2202    // If the operation fails, error.code is returned and processed.
2203    console.log(error.code);
2204}
2205```
2206
2207### setVideoStabilizationMode
2208
2209setVideoStabilizationMode(mode: VideoStabilizationMode): void
2210
2211Sets a video stabilization mode for the device.
2212
2213**System capability**: SystemCapability.Multimedia.Camera.Core
2214
2215**Parameters**
2216
2217| Name     | Type                                             | Mandatory| Description                   |
2218| -------- | ------------------------------------------------- | ---- | --------------------- |
2219| mode     | [VideoStabilizationMode](#videostabilizationmode) | Yes  | Video stabilization mode.  |
2220
2221**Return value**
2222
2223| Type       | Description                         |
2224| ---------- | ----------------------------- |
2225| [CameraErrorCode](#cameraerrorcode)    | If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
2226
2227**Error codes**
2228
2229For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
2230
2231| ID        | Error Message       |
2232| --------------- | --------------- |
2233| 7400103                |  Session not config.                                   |
2234
2235**Example**
2236
2237```js
2238try {
2239    captureSession.setVideoStabilizationMode(camera.VideoStabilizationMode.OFF);
2240} catch (error) {
2241    // If the operation fails, error.code is returned and processed.
2242    console.log(error.code);
2243}
2244```
2245
2246### on('focusStateChange')
2247
2248on(type: 'focusStateChange', callback: AsyncCallback<FocusState\>): void
2249
2250Listens for focus state changes. This API uses an asynchronous callback to return the result.
2251
2252**System capability**: SystemCapability.Multimedia.Camera.Core
2253
2254**Parameters**
2255
2256| Name    | Type                                     | Mandatory| Description                      |
2257| -------- | ----------------------------------------- | ---- | ------------------------ |
2258| 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.|
2259| callback | AsyncCallback<[FocusState](#focusstate)\> | Yes  | Callback used to return the focus state change. |
2260
2261**Example**
2262
2263```js
2264captureSession.on('focusStateChange', (focusState) => {
2265    console.log(`Focus state  : ${focusState}`);
2266})
2267```
2268
2269### on('error')
2270
2271on(type: 'error', callback: ErrorCallback<BusinessError\>): void
2272
2273Listens for **CaptureSession** errors. This API uses a callback to return the errors.
2274
2275**System capability**: SystemCapability.Multimedia.Camera.Core
2276
2277**Parameters**
2278
2279| Name    | Type                                                         | Mandatory| Description                          |
2280| -------- | ----------------------------------------------------------- | ---- | ------------------------------ |
2281| 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()**, **commitConfig()**, and **addInput**.|
2282| callback | ErrorCallback<BusinessError\> | Yes  | Callback used to return an error code defined in [CameraErrorCode](#cameraerrorcode).       |
2283
2284**Example**
2285
2286```js
2287captureSession.on('error', (error) => {
2288    console.log(`Capture session error code: ${error.code}`);
2289})
2290```
2291
2292## CameraOutput
2293
2294Implements output information used in a **[CaptureSession](#capturesession)**. It is the base class of **output**.
2295
2296## PreviewOutput
2297
2298Implements preview output. It inherits **[CameraOutput](#cameraoutput)**.
2299
2300### start
2301
2302start(callback: AsyncCallback<void\>): void
2303
2304Starts to output preview streams. This API uses an asynchronous callback to return the result.
2305
2306**System capability**: SystemCapability.Multimedia.Camera.Core
2307
2308**Parameters**
2309
2310| Name     | Type                 | Mandatory| Description                |
2311| -------- | -------------------- | ---- | -------------------- |
2312| callback | AsyncCallback<void\> | Yes  | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
2313
2314**Error codes**
2315
2316For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
2317
2318| ID        | Error Message       |
2319| --------------- | --------------- |
2320| 7400103                |  Session not config.                                   |
2321
2322**Example**
2323
2324```js
2325previewOutput.start((err) => {
2326    if (err) {
2327        console.error(`Failed to start the previewOutput. ${err.code}`);
2328        return;
2329    }
2330    console.log('Callback returned with previewOutput started.');
2331})
2332```
2333
2334### start
2335
2336start(): Promise<void\>
2337
2338Starts to output preview streams. This API uses a promise to return the result.
2339
2340**System capability**: SystemCapability.Multimedia.Camera.Core
2341
2342**Return value**
2343
2344| Type           | Description                    |
2345| -------------- | ----------------------- |
2346| Promise<void\>| Promise used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
2347
2348**Error codes**
2349
2350For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
2351
2352| ID        | Error Message       |
2353| --------------- | --------------- |
2354| 7400103                |  Session not config.                                   |
2355
2356**Example**
2357
2358```js
2359previewOutput.start().then(() => {
2360    console.log('Promise returned with previewOutput started.');
2361}).catch((err) => {
2362    console.log('Failed to previewOutput start '+ err.code);
2363});
2364```
2365
2366### stop
2367
2368stop(callback: AsyncCallback<void\>): void
2369
2370Stops outputting preview streams. This API uses an asynchronous callback to return the result.
2371
2372**System capability**: SystemCapability.Multimedia.Camera.Core
2373
2374**Parameters**
2375
2376| Name     | Type                 | Mandatory| Description                |
2377| -------- | -------------------- | ---- | -------------------- |
2378| callback | AsyncCallback<void\> | Yes  | Callback used to return the result.|
2379
2380**Example**
2381
2382```js
2383previewOutput.stop((err) => {
2384    if (err) {
2385        console.error(`Failed to stop the previewOutput. ${err.code}`);
2386        return;
2387    }
2388    console.log('Callback returned with previewOutput stopped.');
2389})
2390```
2391
2392### stop
2393
2394stop(): Promise<void\>
2395
2396Stops outputting preview streams. This API uses a promise to return the result.
2397
2398**System capability**: SystemCapability.Multimedia.Camera.Core
2399
2400**Return value**
2401
2402| Type           | Description                    |
2403| -------------- | ------------------------ |
2404| Promise<void\>| Promise used to return the result.|
2405
2406**Example**
2407
2408```js
2409previewOutput.stop().then(() => {
2410    console.log('Callback returned with previewOutput stopped.');
2411}).catch((err) => {
2412    console.log('Failed to previewOutput stop '+ err.code);
2413});
2414```
2415
2416### release
2417
2418release(callback: AsyncCallback<void\>): void
2419
2420Releases output resources. This API uses an asynchronous callback to return the result.
2421
2422**System capability**: SystemCapability.Multimedia.Camera.Core
2423
2424**Parameters**
2425
2426| Name     | Type                 | Mandatory| Description                |
2427| -------- | -------------------- | ---- | ------------------- |
2428| callback | AsyncCallback<void\> | Yes  | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
2429
2430**Error codes**
2431
2432For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
2433
2434| ID        | Error Message       |
2435| --------------- | --------------- |
2436| 7400201                |  Camera service fatal error.                           |
2437
2438**Example**
2439
2440```js
2441previewOutput.release((err) => {
2442    if (err) {
2443        console.error(`Failed to release the PreviewOutput instance ${err.code}`);
2444        return;
2445    }
2446    console.log('Callback invoked to indicate that the PreviewOutput instance is released successfully.');
2447});
2448```
2449
2450### release
2451
2452release(): Promise<void\>
2453
2454Releases output resources. This API uses a promise to return the result.
2455
2456**System capability**: SystemCapability.Multimedia.Camera.Core
2457
2458**Return value**
2459
2460| Type           | Description                    |
2461| -------------- | ----------------------- |
2462| Promise<void\>| Promise used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
2463
2464**Error codes**
2465
2466For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
2467
2468| ID        | Error Message       |
2469| --------------- | --------------- |
2470| 7400201                |  Camera service fatal error.                           |
2471
2472**Example**
2473
2474```js
2475previewOutput.release().then(() => {
2476    console.log('Promise returned to indicate that the PreviewOutput instance is released successfully.');
2477}).catch((err) => {
2478    console.log('Failed to previewOutput release '+ err.code);
2479});
2480```
2481
2482### on('frameStart')
2483
2484on(type: 'frameStart', callback: AsyncCallback<void\>): void
2485
2486Listens for preview frame start events. This API uses an asynchronous callback to return the result.
2487
2488**System capability**: SystemCapability.Multimedia.Camera.Core
2489
2490**Parameters**
2491
2492| Name     | Type                 | Mandatory| Description                                    |
2493| -------- | -------------------- | ---- | --------------------------------------- |
2494| 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.|
2495| callback | AsyncCallback<void\> | Yes  | Callback used to return the result. The preview starts as long as this event is returned.                    |
2496
2497**Example**
2498
2499```js
2500previewOutput.on('frameStart', () => {
2501    console.log('Preview frame started');
2502})
2503```
2504
2505### on('frameEnd')
2506
2507on(type: 'frameEnd', callback: AsyncCallback<void\>): void
2508
2509Listens for preview frame end events. This API uses an asynchronous callback to return the result.
2510
2511**System capability**: SystemCapability.Multimedia.Camera.Core
2512
2513**Parameters**
2514
2515| Name     | Type                 | Mandatory| Description                                 |
2516| -------- | -------------------- | ---- | ------------------------------------- |
2517| 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.|
2518| callback | AsyncCallback<void\> | Yes  | Callback used to return the result. The preview ends as long as this event is returned.                |
2519
2520**Example**
2521
2522```js
2523previewOutput.on('frameEnd', () => {
2524    console.log('Preview frame ended');
2525})
2526```
2527
2528### on('error')
2529
2530on(type: 'error', callback: ErrorCallback<BusinessError\>): void
2531
2532Listens for **PreviewOutput** errors. This API uses a callback to return the errors.
2533
2534**System capability**: SystemCapability.Multimedia.Camera.Core
2535
2536**Parameters**
2537
2538| Name    | Type        | Mandatory| Description                      |
2539| -------- | --------------| ---- | ------------------------ |
2540| 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 **start()** or **release()**.|
2541| callback | ErrorCallback<BusinessError\> | Yes  | Callback used to return an error code defined in [CameraErrorCode](#cameraerrorcode). |
2542
2543**Example**
2544
2545```js
2546previewOutput.on('error', (previewOutputError) => {
2547    console.log(`Preview output error code: ${previewOutputError.code}`);
2548})
2549```
2550
2551## ImageRotation
2552
2553Enumerates the image rotation angles.
2554
2555**System capability**: SystemCapability.Multimedia.Camera.Core
2556
2557| Name         | Value  | Description          |
2558| ------------ | ---- | ------------- |
2559| ROTATION_0   | 0    | The image rotates 0 degrees.  |
2560| ROTATION_90  | 90   | The image rotates 90 degrees. |
2561| ROTATION_180 | 180  | The image rotates 180 degrees.|
2562| ROTATION_270 | 270  | The image rotates 270 degrees.|
2563
2564## Location
2565
2566Defines geolocation information.
2567
2568**System capability**: SystemCapability.Multimedia.Camera.Core
2569
2570| Name         | Type  | Mandatory|Description        |
2571| ------------ | ------ | --- |------------ |
2572| latitude     | number | Yes |Latitude, in degrees.   |
2573| longitude    | number | Yes |Longitude, in degrees.   |
2574| altitude     | number | Yes |Altitude, in meters.   |
2575
2576## QualityLevel
2577
2578Enumerates the image quality levels.
2579
2580**System capability**: SystemCapability.Multimedia.Camera.Core
2581
2582| Name                 | Value  | Description        |
2583| -------------------- | ---- | ------------ |
2584| QUALITY_LEVEL_HIGH   | 0    | High image quality.  |
2585| QUALITY_LEVEL_MEDIUM | 1    | Medium image quality.|
2586| QUALITY_LEVEL_LOW    | 2    | Low image quality.  |
2587
2588
2589## PhotoCaptureSetting
2590
2591Defines the settings for photo capture.
2592
2593**System capability**: SystemCapability.Multimedia.Camera.Core
2594
2595| Name     | Type                           | Mandatory | Description             |
2596| -------- | ------------------------------- | ---- | -----------------|
2597| quality  | [QualityLevel](#qualitylevel)   | No  | Photo quality.        |
2598| rotation | [ImageRotation](#imagerotation) | No  | Rotation angle of the photo.     |
2599| location | [Location](#location)           | No  | Geolocation information of the photo.  |
2600| mirror   | boolean                         | No  |Whether mirroring is enabled. By default, mirroring is disabled.|
2601
2602## PhotoOutput
2603
2604Implements output information used in a shooting session. This class inherits from [CameraOutput](#cameraoutput).
2605
2606### capture
2607
2608capture(callback: AsyncCallback<void\>): void
2609
2610Captures a photo with the default shooting parameters. This API uses an asynchronous callback to return the result.
2611
2612**System capability**: SystemCapability.Multimedia.Camera.Core
2613
2614**Parameters**
2615
2616| Name     | Type                 | Mandatory| Description                |
2617| -------- | -------------------- | ---- | ------------------- |
2618| callback | AsyncCallback<void\> | Yes  | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
2619
2620**Error codes**
2621
2622For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
2623
2624| ID        | Error Message       |
2625| --------------- | --------------- |
2626| 7400104                |  Session not running.                                  |
2627| 7400201                |  Camera service fatal error.                           |
2628
2629**Example**
2630
2631```js
2632photoOutput.capture((err) => {
2633    if (err) {
2634        console.error(`Failed to capture the photo ${err.code}`);
2635        return;
2636    }
2637    console.log('Callback invoked to indicate the photo capture request success.');
2638});
2639```
2640
2641### capture
2642
2643capture(): Promise<void\>
2644
2645Captures a photo with the default shooting parameters. This API uses a promise to return the result.
2646
2647**System capability**: SystemCapability.Multimedia.Camera.Core
2648
2649**Return value**
2650
2651| Type           | Description                    |
2652| -------------- | ------------------------ |
2653| Promise<void\>| Promise used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
2654
2655**Error codes**
2656
2657For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
2658
2659| ID        | Error Message       |
2660| --------------- | --------------- |
2661| 7400104                |  Session not running.                                  |
2662| 7400201                |  Camera service fatal error.                           |
2663
2664**Example**
2665
2666```js
2667photoOutput.capture().then(() => {
2668    console.log('Promise returned to indicate that photo capture request success.');
2669}).catch((err) => {
2670    console.log('Failed to photoOutput capture '+ err.code);
2671});
2672```
2673
2674### capture
2675
2676capture(setting: PhotoCaptureSetting, callback: AsyncCallback<void\>): void
2677
2678Captures a photo with the specified shooting parameters. This API uses an asynchronous callback to return the result.
2679
2680**System capability**: SystemCapability.Multimedia.Camera.Core
2681
2682**Parameters**
2683
2684| Name     | Type                                        | Mandatory| Description                 |
2685| -------- | ------------------------------------------- | ---- | -------------------- |
2686| setting  | [PhotoCaptureSetting](#photocapturesetting) | Yes  | Shooting settings.            |
2687| callback | AsyncCallback<void\>                        | Yes  | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned. |
2688
2689**Error codes**
2690
2691For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
2692
2693| ID        | Error Message       |
2694| --------------- | --------------- |
2695| 7400101                |  Parameter missing or parameter type incorrect        |
2696| 7400104                |  Session not running.                                  |
2697| 7400201                |  Camera service fatal error.                           |
2698
2699**Example**
2700
2701```js
2702let captureLocation = {
2703  latitude: 0,
2704  longitude: 0,
2705  altitude: 0,
2706}
2707let settings = {
2708  quality: camera.QualityLevel.QUALITY_LEVEL_LOW,
2709  rotation: camera.ImageRotation.ROTATION_0,
2710  location: captureLocation,
2711  mirror: false
2712}
2713photoOutput.capture(settings, (err) => {
2714    if (err) {
2715        console.error(`Failed to capture the photo ${err.code}`);
2716        return;
2717    }
2718    console.log('Callback invoked to indicate the photo capture request success.');
2719});
2720```
2721
2722### capture
2723
2724capture(setting?: PhotoCaptureSetting): Promise<void\>
2725
2726Captures a photo with the specified shooting parameters. This API uses a promise to return the result.
2727
2728**System capability**: SystemCapability.Multimedia.Camera.Core
2729
2730**Parameters**
2731
2732| Name    | Type                                        | Mandatory| Description     |
2733| ------- | ------------------------------------------- | ---- | -------- |
2734| setting | [PhotoCaptureSetting](#photocapturesetting) | No  | Shooting settings.|
2735
2736**Return value**
2737
2738| Type           | Description                    |
2739| -------------- | ------------------------ |
2740| Promise<void\>| Promise used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
2741
2742**Error codes**
2743
2744For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
2745
2746| ID        | Error Message       |
2747| --------------- | --------------- |
2748| 7400101                |  Parameter missing or parameter type incorrect        |
2749| 7400104                |  Session not running.                                  |
2750| 7400201                |  Camera service fatal error.                           |
2751
2752**Example**
2753
2754```js
2755photoOutput.capture(settings).then(() => {
2756    console.log('Promise returned to indicate that photo capture request success.');
2757}).catch((err) => {
2758    console.log('Failed to photoOutput capture '+ err.code);
2759});
2760```
2761
2762### isMirrorSupported
2763
2764isMirrorSupported(): boolean
2765
2766Checks whether mirroring is supported.
2767
2768**System capability**: SystemCapability.Multimedia.Camera.Core
2769
2770**Return value**
2771
2772| Type           | Description                    |
2773| -------------- | ----------------------- |
2774| boolean | Returns **true** if mirroring is supported; returns **false** otherwise.|
2775
2776**Example**
2777
2778```js
2779let isSupported = photoOutput.isMirrorSupported();
2780```
2781
2782### release
2783
2784release(callback: AsyncCallback<void\>): void
2785
2786Releases output resources. This API uses an asynchronous callback to return the result.
2787
2788**System capability**: SystemCapability.Multimedia.Camera.Core
2789
2790**Parameters**
2791
2792| Name     | Type                 | Mandatory| Description                |
2793| -------- | -------------------- | ---- | ------------------- |
2794| callback | AsyncCallback<void\> | Yes  | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
2795
2796**Error codes**
2797
2798For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
2799
2800| ID        | Error Message       |
2801| --------------- | --------------- |
2802| 7400201                |  Camera service fatal error.                           |
2803
2804**Example**
2805
2806```js
2807photoOutput.release((err) => {
2808    if (err) {
2809        console.error(`Failed to release the PreviewOutput instance ${err.code}`);
2810        return;
2811    }
2812    console.log('Callback invoked to indicate that the PreviewOutput instance is released successfully.');
2813});
2814```
2815
2816### release
2817
2818release(): Promise<void\>
2819
2820Releases output resources. This API uses a promise to return the result.
2821
2822**System capability**: SystemCapability.Multimedia.Camera.Core
2823
2824**Return value**
2825
2826| Type           | Description                    |
2827| -------------- | ----------------------- |
2828| Promise<void\>| Promise used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
2829
2830**Error codes**
2831
2832For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
2833
2834| ID        | Error Message       |
2835| --------------- | --------------- |
2836| 7400201                |  Camera service fatal error.                           |
2837
2838**Example**
2839
2840```js
2841photoOutput.release().then(() => {
2842    console.log('Promise returned to indicate that the PreviewOutput instance is released successfully.');
2843}).catch((err) => {
2844    console.log('Failed to photoOutput release '+ err.code);
2845});
2846```
2847
2848### on('captureStart')
2849
2850on(type: 'captureStart', callback: AsyncCallback<number\>): void
2851
2852Listens for shooting start events. This API uses an asynchronous callback to return the capture ID.
2853
2854**System capability**: SystemCapability.Multimedia.Camera.Core
2855
2856**Parameters**
2857
2858| Name     | Type                   | Mandatory| Description                                      |
2859| -------- | ---------------------- | ---- | ------------------------------------------ |
2860| 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.|
2861| callback | AsyncCallback<number\> | Yes  | Callback used to return the capture ID.           |
2862
2863**Example**
2864
2865```js
2866photoOutput.on('captureStart', (captureId) => {
2867    console.log(`photo capture stated, captureId : ${captureId}`);
2868})
2869```
2870
2871### on('frameShutter')
2872
2873on(type: 'frameShutter', callback: AsyncCallback<FrameShutterInfo\>): void
2874
2875Listens for frame shutter events. This API uses an asynchronous callback to return the event information.
2876
2877**System capability**: SystemCapability.Multimedia.Camera.Core
2878
2879**Parameters**
2880
2881| Name    | Type     | Mandatory| Description                                 |
2882| -------- | ---------- | --- | ------------------------------------ |
2883| type     | string     | Yes  | Event type. The value is fixed at **'frameShutter'**. The event can be listened for when a **photoOutput** instance is created.|
2884| callback | AsyncCallback<[FrameShutterInfo](#frameshutterinfo)\> | Yes  | Callback used to return the result. A new photographing request can be delivered as long as this event is returned.            |
2885
2886**Example**
2887
2888```js
2889photoOutput.on('frameShutter', (frameShutterInfo) => {
2890    console.log(`photo capture end, captureId : ${frameShutterInfo.captureId}`);
2891    console.log(`Timestamp for frame : ${frameShutterInfo.timestamp}`);
2892})
2893```
2894
2895### on('captureEnd')
2896
2897on(type: 'captureEnd', callback: AsyncCallback<CaptureEndInfo\>): void
2898
2899Listens for shooting end events. This API uses an asynchronous callback to return the event information.
2900
2901**System capability**: SystemCapability.Multimedia.Camera.Core
2902
2903**Parameters**
2904
2905| Name    | Type          | Mandatory| Description                                      |
2906| -------- | --------------- | ---- | ---------------------------------------- |
2907| type     | string          | Yes  | Event type. The value is fixed at **'captureEnd'**. The event can be listened for when a **photoOutput** instance is created. This event is triggered and the corresponding information is returned when the photographing is complete.|
2908| callback | AsyncCallback<[CaptureEndInfo](#captureendinfo)\> | Yes  | Callback used to return the result.                 |
2909
2910**Example**
2911
2912```js
2913photoOutput.on('captureEnd', (captureEndInfo) => {
2914    console.log(`photo capture end, captureId : ${captureEndInfo.captureId}`);
2915    console.log(`frameCount : ${captureEndInfo.frameCount}`);
2916})
2917```
2918
2919### on('error')
2920
2921on(type: 'error', callback: ErrorCallback<BusinessError\>): void
2922
2923Listens for **PhotoOutput** errors. This API uses a callback to return the errors.
2924
2925**System capability**: SystemCapability.Multimedia.Camera.Core
2926
2927**Parameters**
2928
2929| Name    | Type        | Mandatory| Description                                |
2930| -------- | ------------- | ---- | ----------------------------------- |
2931| 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 photographing-related API.|
2932| callback | ErrorCallback<BusinessError\> | Yes  | Callback used to return an error code defined in [CameraErrorCode](#cameraerrorcode).            |
2933
2934**Example**
2935
2936```js
2937photoOutput.on('error', (error) => {
2938    console.log(`Photo output error code: ${error.code}`);
2939})
2940```
2941
2942## FrameShutterInfo
2943
2944Defines the frame shutter information.
2945
2946**System capability**: SystemCapability.Multimedia.Camera.Core
2947
2948| Name     | Type  | Mandatory| Description        |
2949| --------- | ------ | ---- | ---------- |
2950| captureId | number | Yes  | ID of this capture action. |
2951| timestamp | number | Yes  | Timestamp when the frame shutter event is triggered.|
2952
2953## CaptureEndInfo
2954
2955Defines the capture end information.
2956
2957**System capability**: SystemCapability.Multimedia.Camera.Core
2958
2959| Name      | Type  | Mandatory| Description      |
2960| ---------- | ------ | ---- | ---------|
2961| captureId  | number | Yes  | ID of this capture action.|
2962| frameCount | number | Yes  | Number of frames captured.   |
2963
2964## VideoOutput
2965
2966Implements output information used in a video recording session. This class inherits from [CameraOutput](#cameraoutput).
2967
2968### start
2969
2970start(callback: AsyncCallback<void\>): void
2971
2972Starts video recording. This API uses an asynchronous callback to return the result.
2973
2974**System capability**: SystemCapability.Multimedia.Camera.Core
2975
2976**Parameters**
2977
2978| Name     | Type                 | Mandatory| Description                |
2979| -------- | -------------------- | ---- | -------------------- |
2980| callback | AsyncCallback<void\> | Yes  | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
2981
2982**Error codes**
2983
2984For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
2985
2986| ID        | Error Message       |
2987| --------------- | --------------- |
2988| 7400103                |  Session not config.                                   |
2989| 7400201                |  Camera service fatal error.                           |
2990
2991**Example**
2992
2993```js
2994videoOutput.start((err) => {
2995    if (err) {
2996        console.error(`Failed to start the video output ${err.code}`);
2997        return;
2998    }
2999    console.log('Callback invoked to indicate the video output start success.');
3000});
3001```
3002
3003### start
3004
3005start(): Promise<void\>
3006
3007Starts video recording. This API uses a promise to return the result.
3008
3009**System capability**: SystemCapability.Multimedia.Camera.Core
3010
3011**Return value**
3012
3013| Type           | Description                    |
3014| -------------- | ----------------------- |
3015| Promise<void\>| Promise used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
3016
3017**Error codes**
3018
3019For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
3020
3021| ID        | Error Message       |
3022| --------------- | --------------- |
3023| 7400103                |  Session not config.                                   |
3024| 7400201                |  Camera service fatal error.                           |
3025
3026**Example**
3027
3028```js
3029videoOutput.start().then(() => {
3030    console.log('Promise returned to indicate that start method execution success.');
3031}).catch((err) => {
3032    console.log('Failed to videoOutput start '+ err.code);
3033});
3034```
3035
3036### stop
3037
3038stop(callback: AsyncCallback<void\>): void
3039
3040Stops video recording. This API uses an asynchronous callback to return the result.
3041
3042**System capability**: SystemCapability.Multimedia.Camera.Core
3043
3044**Parameters**
3045
3046| Name    | Type                | Mandatory| Description                    |
3047| -------- | -------------------- | ---- | ------------------------ |
3048| callback | AsyncCallback<void\> | Yes  | Callback used to return the result.|
3049
3050**Example**
3051
3052```js
3053videoOutput.stop((err) => {
3054    if (err) {
3055        console.error(`Failed to stop the video output ${err.code}`);
3056        return;
3057    }
3058    console.log('Callback invoked to indicate the video output stop success.');
3059});
3060```
3061
3062### stop
3063
3064stop(): Promise<void\>
3065
3066Stops video recording. This API uses a promise to return the result.
3067
3068**System capability**: SystemCapability.Multimedia.Camera.Core
3069
3070**Return value**
3071
3072| Type           | Description                    |
3073| -------------- | ----------------------- |
3074| Promise<void\>| Promise used to return the result.|
3075
3076**Example**
3077
3078```js
3079videoOutput.stop().then(() => {
3080    console.log('Promise returned to indicate that stop method execution success.');
3081}).catch((err) => {
3082    console.log('Failed to videoOutput stop '+ err.code);
3083});
3084```
3085
3086### release
3087
3088release(callback: AsyncCallback<void\>): void
3089
3090Releases output resources. This API uses an asynchronous callback to return the result.
3091
3092**System capability**: SystemCapability.Multimedia.Camera.Core
3093
3094**Parameters**
3095
3096| Name     | Type                 | Mandatory| Description                |
3097| -------- | -------------------- | ---- | ------------------- |
3098| callback | AsyncCallback<void\> | Yes  | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
3099
3100**Error codes**
3101
3102For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
3103
3104| ID        | Error Message       |
3105| --------------- | --------------- |
3106| 7400201                |  Camera service fatal error.                           |
3107
3108**Example**
3109
3110```js
3111videoOutput.release((err) => {
3112    if (err) {
3113        console.error(`Failed to release the PreviewOutput instance ${err.code}`);
3114        return;
3115    }
3116    console.log('Callback invoked to indicate that the PreviewOutput instance is released successfully.');
3117});
3118```
3119
3120### release
3121
3122release(): Promise<void\>
3123
3124Releases output resources. This API uses a promise to return the result.
3125
3126**System capability**: SystemCapability.Multimedia.Camera.Core
3127
3128**Return value**
3129
3130| Type           | Description                    |
3131| -------------- | ----------------------- |
3132| Promise<void\>| Promise used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
3133
3134**Error codes**
3135
3136For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
3137
3138| ID        | Error Message       |
3139| --------------- | --------------- |
3140| 7400201                |  Camera service fatal error.                           |
3141
3142**Example**
3143
3144```js
3145videoOutput.release().then(() => {
3146    console.log('Promise returned to indicate that the PreviewOutput instance is released successfully.');
3147}).catch((err) => {
3148    console.log('Failed to videoOutput release '+ err.code);
3149});
3150```
3151
3152### on('frameStart')
3153
3154on(type: 'frameStart', callback: AsyncCallback<void\>): void
3155
3156Listens for video recording start events. This API uses an asynchronous callback to return the result.
3157
3158**System capability**: SystemCapability.Multimedia.Camera.Core
3159
3160**Parameters**
3161
3162| Name     | Type                 | Mandatory| Description                                      |
3163| -------- | -------------------- | ---- | ----------------------------------------- |
3164| 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.|
3165| callback | AsyncCallback<void\> | Yes  | Callback used to return the result.  The recording starts as long as this event is returned.                    |
3166
3167**Example**
3168
3169```js
3170videoOutput.on('frameStart', () => {
3171    console.log('Video frame started');
3172})
3173```
3174
3175### on('frameEnd')
3176
3177on(type: 'frameEnd', callback: AsyncCallback<void\>): void
3178
3179Listens for video recording stop events. This API uses an asynchronous callback to return the result.
3180
3181**System capability**: SystemCapability.Multimedia.Camera.Core
3182
3183**Parameters**
3184
3185| Name     | Type                 | Mandatory| Description                                      |
3186| -------- | -------------------- | ---- | ------------------------------------------ |
3187| 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.|
3188| callback | AsyncCallback<void\> | Yes  | Callback used to return the result. The recording ends as long as this event is returned.                     |
3189
3190**Example**
3191
3192```js
3193videoOutput.on('frameEnd', () => {
3194    console.log('Video frame ended');
3195})
3196```
3197
3198### on('error')
3199
3200on(type: 'error', callback: ErrorCallback<BusinessError\>): void
3201
3202Listens for errors that occur during video recording. This API uses a callback to return the result.
3203
3204**System capability**: SystemCapability.Multimedia.Camera.Core
3205
3206**Parameters**
3207
3208| Name    | Type      | Mandatory| Description                                   |
3209| -------- | ----------- | ---- | -------------------------------------- |
3210| 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 calling of a recording-related API such as **start()** and **release()**.|
3211| callback | Callback<BusinessError\> | Yes  | Callback used to return an error code defined in [CameraErrorCode](#cameraerrorcode).                |
3212
3213**Example**
3214
3215```js
3216videoOutput.on('error', (error) => {
3217    console.log(`Video output error code: ${error.code}`);
3218})
3219```
3220
3221## MetadataOutput
3222
3223Implements metadata streams. It inherits **[CameraOutput](#cameraoutput)**.
3224
3225### start
3226
3227start(callback: AsyncCallback<void\>): void
3228
3229Starts to output metadata. This API uses an asynchronous callback to return the result.
3230
3231**System capability**: SystemCapability.Multimedia.Camera.Core
3232
3233**Parameters**
3234
3235| Name    | Type                                                        | Mandatory| Description                |
3236| -------- | -------------------------- | ---- | ------------------- |
3237| callback | AsyncCallback<void\>       | Yes  | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
3238
3239**Error codes**
3240
3241For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
3242
3243| ID        | Error Message       |
3244| --------------- | --------------- |
3245| 7400103                |  Session not config.                                   |
3246| 7400201                |  Camera service fatal error.                           |
3247
3248**Example**
3249
3250```js
3251metadataOutput.start((err) => {
3252    if (err) {
3253        console.error(`Failed to start metadataOutput. ${err.code}`);
3254        return;
3255    }
3256    console.log('Callback returned with metadataOutput started.');
3257})
3258```
3259
3260### start
3261
3262start(): Promise<void\>
3263
3264Starts to output metadata. This API uses a promise to return the result.
3265
3266**System capability**: SystemCapability.Multimedia.Camera.Core
3267
3268**Return value**
3269
3270| Type                    | Description                    |
3271| ----------------------  | ------------------------ |
3272| Promise<void\>         | Promise used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
3273
3274**Error codes**
3275
3276For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
3277
3278| ID        | Error Message       |
3279| --------------- | --------------- |
3280| 7400103                |  Session not config.                                   |
3281| 7400201                |  Camera service fatal error.                           |
3282
3283**Example**
3284
3285```js
3286metadataOutput.start().then(() => {
3287    console.log('Callback returned with metadataOutput started.');
3288}).catch((err) => {
3289    console.log('Failed to metadataOutput start '+ err.code);
3290});
3291```
3292
3293### stop
3294
3295stop(callback: AsyncCallback<void\>): void
3296
3297Stops outputting metadata. This API uses an asynchronous callback to return the result.
3298
3299**System capability**: SystemCapability.Multimedia.Camera.Core
3300
3301**Parameters**
3302
3303| Name    | Type                        | Mandatory| Description                 |
3304| -------- | -------------------------- | ---- | ------------------- |
3305| callback | AsyncCallback<void\>       | Yes  | Callback used to return the result.|
3306
3307**Example**
3308
3309```js
3310metadataOutput.stop((err) => {
3311    if (err) {
3312        console.error(`Failed to stop the metadataOutput. ${err.code}`);
3313        return;
3314    }
3315    console.log('Callback returned with metadataOutput stopped.');
3316})
3317```
3318
3319### stop
3320
3321stop(): Promise<void\>
3322
3323Stops outputting metadata. This API uses a promise to return the result.
3324
3325**System capability**: SystemCapability.Multimedia.Camera.Core
3326
3327**Return value**
3328
3329| Type                   | Description                       |
3330| ----------------------  | --------------------------- |
3331| Promise<void\>        | Promise used to return the result.|
3332
3333**Example**
3334
3335```js
3336metadataOutput.stop().then(() => {
3337    console.log('Callback returned with metadataOutput stopped.');
3338}).catch((err) => {
3339    console.log('Failed to metadataOutput stop '+ err.code);
3340});
3341```
3342
3343### on('metadataObjectsAvailable')
3344
3345on(type: 'metadataObjectsAvailable', callback: AsyncCallback<Array<MetadataObject\>\>): void
3346
3347Listens for metadata objects. This API uses an asynchronous callback to return the result.
3348
3349**System capability**: SystemCapability.Multimedia.Camera.Core
3350
3351**Parameters**
3352
3353| Name     | Type        | Mandatory| Description                                 |
3354| -------- | -------------- | ---- | ------------------------------------ |
3355| 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.|
3356| callback | Callback<Array<[MetadataObject](#metadataobject)\>\> | Yes  | Callback used to return the metadata.|
3357
3358**Example**
3359
3360```js
3361metadataOutput.on('metadataObjectsAvailable', (metadataObjectArr) => {
3362    console.log(`metadata output metadataObjectsAvailable`);
3363})
3364```
3365
3366### on('error')
3367
3368on(type: 'error', callback: ErrorCallback<BusinessError\>): void
3369
3370Listens for metadata errors. This API uses an asynchronous callback to return the result.
3371
3372**System capability**: SystemCapability.Multimedia.Camera.Core
3373
3374**Parameters**
3375
3376| Name    | Type        | Mandatory| Description                                    |
3377| -------- | ------------- | ---- | --------------------------------------- |
3378| 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 calling of a metadata-related API such as **start()** and **release()**.|
3379| callback | Callback<BusinessError\> | Yes  | Callback used to return an error code defined in [CameraErrorCode](#cameraerrorcode).           |
3380
3381**Example**
3382
3383```js
3384metadataOutput.on('error', (metadataOutputError) => {
3385    console.log(`Metadata output error code: ${metadataOutputError.code}`);
3386})
3387```
3388
3389## MetadataObjectType
3390
3391Enumerates the metadata object types.
3392
3393**System capability**: SystemCapability.Multimedia.Camera.Core
3394
3395| Name                      | Value  | Description             |
3396| ------------------------- | ---- | ----------------- |
3397| FACE_DETECTION            | 0    | Face detection.|
3398
3399## Rect
3400
3401Defines a rectangle.
3402
3403**System capability**: SystemCapability.Multimedia.Camera.Core
3404
3405| Name     | Type  |      Mandatory    |           Description                |
3406| -------- | ------ | --------------- | -------------------- |
3407| topLeftX | number |        Yes         | X-axis coordinate of the upper left corner of the rectangle.  |
3408| topLeftY | number |         Yes         | Y-axis coordinate of the upper left corner of the rectangle.  |
3409| width    | number |         Yes        | Width of the rectangle.             |
3410| height   | number |         Yes          |Height of the rectangle.             |
3411
3412## MetadataObject
3413
3414Implements camera metadata, which is the data source of [CameraInput](#camerainput). The metadata is obtained through metadataOutput.on('metadataObjectsAvailable').
3415
3416| Name     | Type                           | Mandatory | Description             |
3417| -------- | ------------------------------- | ---- | -----------------|
3418| type  | [MetadataObjectType](#metadataobjecttype)   | No  | Metadata data type. Only face recognition is supported.|
3419| timestamp | number | No  | Current timestamp, in milliseconds.|
3420| boundingBox | [Rect](#rect)           | No  | Metadata rectangle.|
3421