js-apis-camera.md 114.4 KB
Newer Older
G
Gloria 已提交
1
# @ohos.multimedia.camera (Camera Management)
N
nikhilraut 已提交
2

W
wusongqing 已提交
3 4
> **NOTE**
>
G
Gloria 已提交
5 6
> - 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.
> - The APIs provided by this module are system APIs.
W
wusongqing 已提交
7

N
nikhilraut 已提交
8 9
## Modules to Import

W
wusongqing 已提交
10
```js
N
nikhilraut 已提交
11 12 13
import camera from '@ohos.multimedia.camera';
```

W
wusongqing 已提交
14
## camera.getCameraManager
N
nikhilraut 已提交
15

G
Gloria 已提交
16
getCameraManager(context: Context): CameraManager
N
nikhilraut 已提交
17

G
Gloria 已提交
18
Obtains a **CameraManager** instance. This API returns the result synchronously.
N
nikhilraut 已提交
19

W
wusongqing 已提交
20
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
21 22 23

**Parameters**

24 25
| Name    | Type                                            | Mandatory| Description                          |
| -------- | ----------------------------------------------- | ---- | ---------------------------- |
G
Gloria 已提交
26
| context  | [Context](js-apis-inner-app-context.md)      | Yes  | Application context.                  |
N
nikhilraut 已提交
27

W
wusongqing 已提交
28
**Return value**
N
nikhilraut 已提交
29

G
Gloria 已提交
30 31 32
| Type                                            | Description                          |
| ----------------------------------------------- | ---------------------------- |
| [CameraManager](#cameramanager)           | **CameraManager** instance obtained.                  |
N
nikhilraut 已提交
33

G
Gloria 已提交
34 35 36 37 38 39 40 41 42
**Error codes**

For details about the error codes, see [CameraErrorCode](#cameraerrorcode).

| ID        | Error Message       |
| --------------- | --------------- |
| 7400101                |  Parameter missing or parameter type incorrect               |
| 7400201                |  Camera service fatal error.                                  |

N
nikhilraut 已提交
43 44
**Example**

W
wusongqing 已提交
45
```js
G
Gloria 已提交
46
let cameraManager = camera.getCameraManager(context);
N
nikhilraut 已提交
47 48
```

W
wusongqing 已提交
49
## CameraStatus
N
nikhilraut 已提交
50

W
wusongqing 已提交
51
Enumerates the camera statuses.
N
nikhilraut 已提交
52

W
wusongqing 已提交
53
**System capability**: SystemCapability.Multimedia.Camera.Core
54

G
Gloria 已提交
55 56
| Name                      | Value  | Description           |
| ------------------------- | ---- | ------------    |
G
Gloria 已提交
57
| CAMERA_STATUS_APPEAR      | 0    | A camera appears.  |
G
Gloria 已提交
58 59 60
| CAMERA_STATUS_DISAPPEAR   | 1    | The camera disappears.    |
| CAMERA_STATUS_AVAILABLE   | 2    | The camera is available.      |
| CAMERA_STATUS_UNAVAILABLE | 3    | The camera is unavailable.    |
61

62
## Profile
N
nikhilraut 已提交
63

64
Defines the camera profile.
N
nikhilraut 已提交
65

W
wusongqing 已提交
66
**System capability**: SystemCapability.Multimedia.Camera.Core
67

68
| Name     | Type                          | Mandatory| Description        |
69 70 71
| -------- | ----------------------------- |---- | ------------- |
| format   | [CameraFormat](#cameraformat) | Yes | Output format.     |
| size     | [Size](#size)                 | Yes | Resolution.      |
N
nikhilraut 已提交
72

73
## FrameRateRange
N
nikhilraut 已提交
74

75
Defines the frame rate range.
N
nikhilraut 已提交
76

W
wusongqing 已提交
77
**System capability**: SystemCapability.Multimedia.Camera.Core
78

79
| Name     | Type                          | Mandatory| Description        |
80 81 82
| -------- | ----------------------------- |---- | ------------- |
| min      | number                        | Yes | Minimum frame rate.     |
| max      | number                        | Yes | Maximum frame rate.     |
83

84
## VideoProfile
N
nikhilraut 已提交
85

86
Defines the video profile.
N
nikhilraut 已提交
87

W
wusongqing 已提交
88
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
89

90
| Name                      | Type                                     | Mandatory| Description       |
91 92
| ------------------------- | ----------------------------------------- | --- |----------- |
| frameRateRange            | [FrameRateRange](#frameraterange)         | Yes | Frame rate range.  |
W
wusongqing 已提交
93

94
## CameraOutputCapability
W
wusongqing 已提交
95

96
Defines the camera output capability.
W
wusongqing 已提交
97 98

**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
99

100
| Name                          | Type                                              | Mandatory| Description               |
101
| ----------------------------- | -------------------------------------------------- | --- |------------------- |
G
Gloria 已提交
102 103 104 105
| previewProfiles               | Array\<[Profile](#profile)\>                        | Yes | Supported preview profiles.   |
| photoProfiles                 | Array\<[Profile](#profile)\>                        | Yes | Supported shooting profiles.   |
| videoProfiles                 | Array\<[VideoProfile](#videoprofile)\>              | Yes | Supported video recording profiles.   |
| supportedMetadataObjectTypes  | Array\<[MetadataObjectType](#metadataobjecttype)\>  | Yes | Supported metadata object types.|
N
nikhilraut 已提交
106

G
Gloria 已提交
107
## CameraErrorCode
N
nikhilraut 已提交
108

G
Gloria 已提交
109
Enumerates 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.
N
nikhilraut 已提交
110

W
wusongqing 已提交
111
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
112

G
Gloria 已提交
113 114 115 116 117 118 119 120 121 122 123
| Name                      | Value  | Description           |
| ------------------------- | ---- | ------------    |
| INVALID_ARGUMENT       | 7400101    | A parameter is missing or the parameter type is incorrect.  |
| OPERATION_NOT_ALLOWED    | 7400102    | The operation is not allowed.    |
| SESSION_NOT_CONFIG    | 7400103    | The session is not configured.      |
| SESSION_NOT_RUNNING  | 7400104    | The session is not running.   |
| SESSION_CONFIG_LOCKED  | 7400105    | The session configuration is locked.    |
| DEVICE_SETTING_LOCKED  | 7400106    | The device setting is locked.    |
| CONFILICT_CAMERA  | 7400107    | The device is already started.    |
| DEVICE_DISABLED  | 7400108    | The camera is disabled for security reasons.    |
| SERVICE_FATAL_ERROR  | 7400201    | An error occurs in the camera service.    |
N
nikhilraut 已提交
124

G
Gloria 已提交
125
## CameraManager
N
nikhilraut 已提交
126

G
Gloria 已提交
127
Implements camera management. Before calling any API in **CameraManager**, you must use **getCameraManager** to obtain a **CameraManager** instance.
N
nikhilraut 已提交
128

129
### getSupportedCameras
N
nikhilraut 已提交
130

G
Gloria 已提交
131
getSupportedCameras(): Array\<CameraDevice\>
N
nikhilraut 已提交
132

G
Gloria 已提交
133
Obtains supported cameras. This API returns the result synchronously.
N
nikhilraut 已提交
134

W
wusongqing 已提交
135
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
136

W
wusongqing 已提交
137
**Return value**
N
nikhilraut 已提交
138

G
Gloria 已提交
139 140
| Type                                            | Description                          |
| ----------------------------------------------- | ---------------------------- |
G
Gloria 已提交
141
|  Array\<[CameraDevice](#cameradevice)>            | An array of supported cameras.                  |
N
nikhilraut 已提交
142 143 144

**Example**

W
wusongqing 已提交
145
```js
G
Gloria 已提交
146 147
let cameras = cameraManager.getSupportedCameras();

N
nikhilraut 已提交
148 149
```

150
### getSupportedOutputCapability
N
nikhilraut 已提交
151

G
Gloria 已提交
152
getSupportedOutputCapability(camera:CameraDevice): CameraOutputCapability
N
nikhilraut 已提交
153

G
Gloria 已提交
154
Obtains the output capability supported by a camera. This API returns the result synchronously.
W
wusongqing 已提交
155

W
wusongqing 已提交
156
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
157 158 159

**Parameters**

160 161
| Name        | Type                                                           | Mandatory| Description                     |
| ------------ |--------------------------------------------------------------- | -- | -------------------------- |
162
| cameraDevice | [CameraDevice](#cameradevice)                              | Yes| Target camera, which is obtained through **getSupportedCameras**.      |
N
nikhilraut 已提交
163

W
wusongqing 已提交
164
**Return value**
N
nikhilraut 已提交
165

G
Gloria 已提交
166 167 168
| Type                                            | Description                          |
| ----------------------------------------------- | ---------------------------- |
| [CameraOutputCapability](#cameraoutputcapability)            | Camera output capability obtained.                  |
N
nikhilraut 已提交
169 170 171

**Example**

W
wusongqing 已提交
172
```js
G
Gloria 已提交
173 174 175
let cameraDevice = cameras[0];
let cameraOutputCapability = cameraManager.getSupportedOutputCapability(cameraDevice);

N
nikhilraut 已提交
176 177
```

178
### isCameraMuted
179

180
isCameraMuted(): boolean
N
nikhilraut 已提交
181

182
Checks whether the camera is muted.
N
nikhilraut 已提交
183

184
Before calling the API, ensure that the camera can be muted. You can use [isCameraMuteSupported](#iscameramutesupported) to check whether the camera can be muted.
W
wusongqing 已提交
185

W
wusongqing 已提交
186
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
187

188
**Return value**
N
nikhilraut 已提交
189

190 191 192
| Type       | Description                                        |
| ---------- | -------------------------------------------- |
| boolean    | Returns **true** if the camera is muted; returns **false** otherwise.|
N
nikhilraut 已提交
193 194 195

**Example**

W
wusongqing 已提交
196
```js
197
let ismuted = cameraManager.isCameraMuted();
N
nikhilraut 已提交
198 199
```

200
### isCameraMuteSupported
N
nikhilraut 已提交
201

202
isCameraMuteSupported(): boolean
N
nikhilraut 已提交
203

204
Checks whether the camera can be muted.
W
wusongqing 已提交
205

206 207
This is a system API.

W
wusongqing 已提交
208
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
209

210
**Return value**
W
wusongqing 已提交
211

212 213 214
| Type       | Description                         |
| ---------- | ----------------------------- |
| boolean    | Returns **true** if the camera can be muted; returns **false** otherwise.|
N
nikhilraut 已提交
215 216 217

**Example**

W
wusongqing 已提交
218
```js
219
let ismutesuppotred = cameraManager.isCameraMuteSupported();
N
nikhilraut 已提交
220 221
```

222
### muteCamera
N
nikhilraut 已提交
223

224
muteCamera(mute: boolean): void
N
nikhilraut 已提交
225

226
Mutes or unmutes the camera.
N
nikhilraut 已提交
227

228 229
This is a system API.

W
wusongqing 已提交
230
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
231 232 233

**Parameters**

234 235 236
| Name     | Type                             | Mandatory | Description       |
| -------- | --------------------------------- | ---- | ---------- |
| mute     | boolean                           |  Yes |  Whether to mute the camera. The value **true** means to mute the camera, and **false** means the opposite. |
N
nikhilraut 已提交
237

W
wusongqing 已提交
238
**Example**
N
nikhilraut 已提交
239

W
wusongqing 已提交
240
```js
241
let mute = true;
242
cameraManager.muteCamera(mute);
N
nikhilraut 已提交
243 244
```

245
### createCameraInput
N
nikhilraut 已提交
246

G
Gloria 已提交
247
createCameraInput(camera: CameraDevice): CameraInput
248

G
Gloria 已提交
249
Creates a **CameraInput** instance with the specified **CameraDevice** object. This API returns the result synchronously.
250

251
**Required permissions**: ohos.permission.CAMERA
N
nikhilraut 已提交
252

W
wusongqing 已提交
253
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
254 255 256

**Parameters**

257 258
| Name    | Type                                        | Mandatory| Description                               |
| -------- | ------------------------------------------- | ---- | --------------------------------- |
G
Gloria 已提交
259
| cameraDevice   | [CameraDevice](#cameradevice)         | Yes  | Target **CameraDevice** object, which is obtained through **getSupportedCameras**.  |
260

W
wusongqing 已提交
261
**Return value**
N
nikhilraut 已提交
262

G
Gloria 已提交
263 264 265
| Type       | Description                         |
| ---------- | ----------------------------- |
| [CameraInput](#camerainput)    | **CameraInput** instance created. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
N
nikhilraut 已提交
266

G
Gloria 已提交
267 268 269 270 271 272 273 274
**Error codes**

For details about the error codes, see [CameraErrorCode](#cameraerrorcode).

| ID        | Error Message       |
| --------------- | --------------- |
| 7400101                |  Parameter missing or parameter type incorrect               |

N
nikhilraut 已提交
275 276
**Example**

W
wusongqing 已提交
277
```js
278
let cameraDevice = cameras[0];
G
Gloria 已提交
279 280 281 282 283 284 285
let cameraInput;
try {
	cameraInput = cameraManager.createCameraInput(cameraDevice);
} catch (error) {
    // If the operation fails, error.code is returned and processed.
    console.log(error.code);
}
N
nikhilraut 已提交
286 287
```

288
### createCameraInput
N
nikhilraut 已提交
289

G
Gloria 已提交
290
createCameraInput(position: CameraPosition, type: CameraType): CameraInput
N
nikhilraut 已提交
291

G
Gloria 已提交
292
Creates a **CameraInput** instance with the specified camera position and type. This API returns the result synchronously.
W
wusongqing 已提交
293

294
**Required permissions**: ohos.permission.CAMERA
N
nikhilraut 已提交
295

W
wusongqing 已提交
296
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
297 298 299

**Parameters**

300 301
| Name    | Type                                       | Mandatory| Description                               |
| -------- | ------------------------------------------- | ---- | --------------------------------- |
302 303
| position | [CameraPosition](#cameraposition)           | Yes  | Camera position, which is obtained through **getSupportedCameras**. This API obtains a **CameraDevice** object, which contains the camera position information. |
| type     | [CameraType](#cameratype)                   | Yes  | Camera type, which is obtained through **getSupportedCameras**. This API obtains a **CameraDevice** object, which contains the camera type information. |
304

W
wusongqing 已提交
305
**Return value**
N
nikhilraut 已提交
306

G
Gloria 已提交
307 308 309
| Type       | Description                         |
| ---------- | ----------------------------- |
| [CameraInput](#camerainput)    | **CameraInput** instance created. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
N
nikhilraut 已提交
310

G
Gloria 已提交
311 312 313 314 315 316 317 318
**Error codes**

For details about the error codes, see [CameraErrorCode](#cameraerrorcode).

| ID        | Error Message       |
| --------------- | --------------- |
| 7400101                |  Parameter missing or parameter type incorrect               |

N
nikhilraut 已提交
319 320
**Example**

321
```js
322 323 324
let cameraDevice = cameras[0];
let position = cameraDevice.cameraPosition;
let type = cameraDevice.cameraType;
G
Gloria 已提交
325 326 327 328 329 330 331
let cameraInput;
try {
    cameraInput = cameraManager.createCameraInput(position, type);
} catch (error) {
    // If the operation fails, error.code is returned and processed.
    console.log(error.code);
}
N
nikhilraut 已提交
332 333
```

334
### createPreviewOutput
W
wusongqing 已提交
335

G
Gloria 已提交
336
createPreviewOutput(profile: Profile, surfaceId: string): PreviewOutput
W
wusongqing 已提交
337

G
Gloria 已提交
338
Creates a **PreviewOutput** instance. This API returns the result synchronously.
N
nikhilraut 已提交
339

W
wusongqing 已提交
340
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
341 342 343

**Parameters**

344 345
| Name    | Type                                            | Mandatory| Description                             |
| -------- | ----------------------------------------------- | ---- | ------------------------------- |
346 347
| profile  | [Profile](#profile)                             | Yes  | Supported preview profiles, which are obtained through **getSupportedOutputCapability**.|
| surfaceId| string | Yes  | Surface ID, which is obtained from [XComponent](../arkui-ts/ts-basic-components-xcomponent.md) or [ImageReceiver](js-apis-image.md#imagereceiver9).|
N
nikhilraut 已提交
348

W
wusongqing 已提交
349
**Return value**
N
nikhilraut 已提交
350

G
Gloria 已提交
351 352 353
| Type       | Description                         |
| ---------- | ----------------------------- |
| [PreviewOutput](#previewoutput)    | **PreviewOutput** instance created. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
N
nikhilraut 已提交
354

G
Gloria 已提交
355 356 357 358 359 360 361 362
**Error codes**

For details about the error codes, see [CameraErrorCode](#cameraerrorcode).

| ID        | Error Message       |
| --------------- | --------------- |
| 7400101                |  Parameter missing or parameter type incorrect               |

N
nikhilraut 已提交
363 364
**Example**

W
wusongqing 已提交
365
```js
G
Gloria 已提交
366 367 368 369 370 371 372 373
let profile = cameraOutputCapability.previewProfiles[0];
let previewOutput;
try {
    previewOutput = cameraManager.createPreviewOutput(profile, surfaceId);
} catch (error) {
    // If the operation fails, error.code is returned and processed.
    console.log(error.code);
}
N
nikhilraut 已提交
374 375
```

376
### createPhotoOutput
N
nikhilraut 已提交
377

G
Gloria 已提交
378
createPhotoOutput(profile: Profile, surfaceId: string): PhotoOutput
N
nikhilraut 已提交
379

G
Gloria 已提交
380
Creates a **PhotoOutput** instance. This API returns the result synchronously.
N
nikhilraut 已提交
381

W
wusongqing 已提交
382
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
383 384 385

**Parameters**

386 387
| Name    | Type                                        | Mandatory| Description                                 |
| -------- | ------------------------------------------- | ---- | ----------------------------------- |
388 389
| profile  | [Profile](#profile)                         | Yes  | Supported shooting profiles, which are obtained through **getSupportedOutputCapability**.|
| surfaceId| string            | Yes  | Surface ID, which is obtained from [ImageReceiver](js-apis-image.md#imagereceiver9).|
N
nikhilraut 已提交
390

W
wusongqing 已提交
391
**Return value**
N
nikhilraut 已提交
392

G
Gloria 已提交
393 394 395
| Type       | Description                         |
| ---------- | ----------------------------- |
| [PhotoOutput](#photooutput)   | **PhotoOutput** instance created. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
N
nikhilraut 已提交
396

G
Gloria 已提交
397 398 399 400 401 402 403 404
**Error codes**

For details about the error codes, see [CameraErrorCode](#cameraerrorcode).

| ID        | Error Message       |
| --------------- | --------------- |
| 7400101                |  Parameter missing or parameter type incorrect               |

N
nikhilraut 已提交
405 406
**Example**

W
wusongqing 已提交
407
```js
G
Gloria 已提交
408 409 410 411 412 413 414 415
let profile = cameraOutputCapability.photoProfiles[0];
let photoOutput;
try {
    photoOutput = cameraManager.createPhotoOutput(profile, surfaceId);
} catch (error) {
    // If the operation fails, error.code is returned and processed.
    console.log(error.code);
}
N
nikhilraut 已提交
416 417
```

418
### createVideoOutput
N
nikhilraut 已提交
419

G
Gloria 已提交
420
createVideoOutput(profile: VideoProfile, surfaceId: string): VideoOutput
N
nikhilraut 已提交
421

G
Gloria 已提交
422
Creates a **VideoOutput** instance. This API returns the result synchronously.
N
nikhilraut 已提交
423

W
wusongqing 已提交
424
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
425 426 427

**Parameters**

428 429
| Name    | Type                                       | Mandatory| Description                             |
| -------- | ------------------------------------------- | ---- | ------------------------------ |
430 431
| profile  | [VideoProfile](#videoprofile)               | Yes  | Supported video recording profiles, which are obtained through **getSupportedOutputCapability**.|
| surfaceId| string          | Yes  | Surface ID, which is obtained from [VideoRecorder](js-apis-media.md#videorecorder9).|
432

W
wusongqing 已提交
433
**Return value**
N
nikhilraut 已提交
434

G
Gloria 已提交
435 436 437
| Type       | Description                         |
| ---------- | ----------------------------- |
| [VideoOutput](#videooutput)   | **VideoOutput** instance created. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
N
nikhilraut 已提交
438

G
Gloria 已提交
439 440 441 442 443 444 445 446
**Error codes**

For details about the error codes, see [CameraErrorCode](#cameraerrorcode).

| ID        | Error Message       |
| --------------- | --------------- |
| 7400101                |  Parameter missing or parameter type incorrect               |

N
nikhilraut 已提交
447 448
**Example**

W
wusongqing 已提交
449
```js
G
Gloria 已提交
450 451 452 453 454 455 456 457
let profile = cameraOutputCapability.videoProfiles[0];
let videoOutput;
try {
    videoOutput = cameraManager.createVideoOutput(profile, surfaceId);
} catch (error) {
    // If the operation fails, error.code is returned and processed.
    console.log(error.code);
}
N
nikhilraut 已提交
458 459
```

460
### createMetadataOutput
N
nikhilraut 已提交
461

G
Gloria 已提交
462
createMetadataOutput(metadataObjectTypes:Array\<MetadataObjectType\>): MetadataOutput
N
nikhilraut 已提交
463

G
Gloria 已提交
464
Creates a **MetadataOutput** instance. This API returns the result synchronously.
N
nikhilraut 已提交
465

W
wusongqing 已提交
466
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
467 468 469

**Parameters**

470 471
| Name                 | Type                                              | Mandatory| Description                         |
| -------------------- | -------------------------------------------------- | --- | ---------------------------- |
G
Gloria 已提交
472
| metadataObjectTypes  | Array\<[MetadataObjectType](#metadataobjecttype)\>  | Yes | Metadata object types, which are obtained through **getSupportedOutputCapability**.|
N
nikhilraut 已提交
473

W
wusongqing 已提交
474
**Return value**
N
nikhilraut 已提交
475

G
Gloria 已提交
476 477 478
| Type       | Description                         |
| ---------- | ----------------------------- |
| [MetadataOutput](#metadataoutput)   | **MetadataOutput** instance created. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
N
nikhilraut 已提交
479

G
Gloria 已提交
480 481 482 483 484 485 486 487
**Error codes**

For details about the error codes, see [CameraErrorCode](#cameraerrorcode).

| ID        | Error Message       |
| --------------- | --------------- |
| 7400101                |  Parameter missing or parameter type incorrect               |

N
nikhilraut 已提交
488 489
**Example**

W
wusongqing 已提交
490
```js
G
Gloria 已提交
491 492 493 494 495 496 497 498
let metadataObjectTypes = cameraOutputCapability.supportedMetadataObjectTypes;
let metadataOutput;
try {
    metadataOutput = cameraManager.createMetadataOutput(metadataObjectTypes);
} catch (error) {
    // If the operation fails, error.code is returned and processed.
    console.log(error.code);
}
N
nikhilraut 已提交
499 500
```

501
### createCaptureSession
N
nikhilraut 已提交
502

G
Gloria 已提交
503
createCaptureSession(): CaptureSession
N
nikhilraut 已提交
504

G
Gloria 已提交
505
Creates a **CaptureSession** instance. This API returns the result synchronously.
N
nikhilraut 已提交
506

W
wusongqing 已提交
507
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
508

W
wusongqing 已提交
509
**Return value**
N
nikhilraut 已提交
510

G
Gloria 已提交
511 512 513
| Type       | Description                         |
| ---------- | ----------------------------- |
| [CaptureSession](#capturesession)   | **CaptureSession** instance created. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
N
nikhilraut 已提交
514

G
Gloria 已提交
515 516 517 518 519 520 521 522
**Error codes**

For details about the error codes, see [CameraErrorCode](#cameraerrorcode).

| ID        | Error Message       |
| --------------- | --------------- |
| 7400201                |  Camera service fatal error.               |

N
nikhilraut 已提交
523 524
**Example**

W
wusongqing 已提交
525
```js
G
Gloria 已提交
526 527 528 529 530 531 532
let captureSession;
try {
    captureSession = cameraManager.createCaptureSession();
} catch (error) {
    // If the operation fails, error.code is returned and processed.
    console.log(error.code);
}
N
nikhilraut 已提交
533 534
```

535
### on('cameraStatus')
N
nikhilraut 已提交
536

G
Gloria 已提交
537
on(type: 'cameraStatus', callback: AsyncCallback\<CameraStatusInfo\>): void
N
nikhilraut 已提交
538

539
Listens for camera status changes. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
540

W
wusongqing 已提交
541
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
542 543 544

**Parameters**

G
Gloria 已提交
545 546 547
| Name    | Type           | Mandatory| Description      |
| -------- | -----------------| ---- | --------- |
| 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.|
G
Gloria 已提交
548
| callback | AsyncCallback\<[CameraStatusInfo](#camerastatusinfo)\> | Yes  | Callback used to return the camera status change.|                 |
N
nikhilraut 已提交
549 550 551

**Example**

W
wusongqing 已提交
552
```js
553
cameraManager.on('cameraStatus', (err, cameraStatusInfo) => {
554 555
    console.log(`camera : ${cameraStatusInfo.camera.cameraId}`);
    console.log(`status: ${cameraStatusInfo.status}`);
N
nikhilraut 已提交
556 557 558
})
```

559
### on('cameraMute')
N
nikhilraut 已提交
560

G
Gloria 已提交
561
on(type: 'cameraMute', callback: AsyncCallback\<boolean\>): void
N
nikhilraut 已提交
562

563
Listens for camera mute status changes. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
564

565 566
This is a system API.

W
wusongqing 已提交
567
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
568 569 570

**Parameters**

571 572
| Name    | Type            | Mandatory| Description      |
| -------- | --------------- | ---- | --------- |
G
Gloria 已提交
573 574
| 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.|
| 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.              |
N
nikhilraut 已提交
575 576 577

**Example**

W
wusongqing 已提交
578
```js
G
Gloria 已提交
579 580
cameraManager.on('cameraMute', (curMuetd) => {
    let isMuted = curMuetd;
N
nikhilraut 已提交
581
})
N
nikhilraut 已提交
582 583
```

584
## CameraStatusInfo
N
nikhilraut 已提交
585

586
Describes the camera status information.
N
nikhilraut 已提交
587

W
wusongqing 已提交
588
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
589

590 591 592 593
| Name  | Type                           |     Mandatory    | Description      |
| ------ | ----------------------------- | -------------- | ---------- |
| camera | [CameraDevice](#cameradevice) |        Yes      | Camera object.|
| status | [CameraStatus](#camerastatus) |        Yes       | Camera status.|
594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614

## CameraPosition

Enumerates the camera positions.

**System capability**: SystemCapability.Multimedia.Camera.Core

| Name                        | Value  | Description           |
| --------------------------- | ---- | -------------- |
| CAMERA_POSITION_UNSPECIFIED | 0    | Unspecified position. |
| CAMERA_POSITION_BACK        | 1    | Rear camera.      |
| CAMERA_POSITION_FRONT       | 2    | Front camera.      |

## CameraType

Enumerates the camera types.

**System capability**: SystemCapability.Multimedia.Camera.Core

| Name                    | Value  | Description           |
| ----------------------- | ---- | -------------- |
G
Gloria 已提交
615
| CAMERA_TYPE_DEFAULT     | 0    | Unspecified camera type. |
616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638
| CAMERA_TYPE_WIDE_ANGLE  | 1    | Wide camera.      |
| CAMERA_TYPE_ULTRA_WIDE  | 2    | Ultra wide camera.    |
| CAMERA_TYPE_TELEPHOTO   | 3    | Telephoto camera.      |
| CAMERA_TYPE_TRUE_DEPTH  | 4    | Camera with depth of field information.|

## ConnectionType

Enumerates the camera connection types.

**System capability**: SystemCapability.Multimedia.Camera.Core

| Name                         | Value  | Description          |
| ---------------------------- | ---- | ------------- |
| CAMERA_CONNECTION_BUILT_IN   | 0    | Built-in camera.     |
| CAMERA_CONNECTION_USB_PLUGIN | 1    | Camera connected using USB.|
| CAMERA_CONNECTION_REMOTE     | 2    | Remote camera.|

## CameraDevice

Defines the camera device information.

**System capability**: SystemCapability.Multimedia.Camera.Core

639
| Name          | Type                               | Mandatory| Description       |
640 641 642 643 644
| -------------- | --------------------------------- | ---- | ---------- |
| cameraId       | string                            | Yes  | **CameraDevice** object.|
| cameraPosition | [CameraPosition](#cameraposition) | Yes  | Camera position.   |
| cameraType     | [CameraType](#cameratype)         | Yes  | Camera type.   |
| connectionType | [ConnectionType](#connectiontype) | Yes  | Camera connection type.|
N
nikhilraut 已提交
645

646
## Size
N
nikhilraut 已提交
647

648
Enumerates the camera output capability.
N
nikhilraut 已提交
649

650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673
**System capability**: SystemCapability.Multimedia.Camera.Core

| Name  | Type  | Readable| Writable| Description        |
| ------ | ------ | ---- | ---- | ------------ |
| height | number | Yes  | Yes  | Image height, in pixels.|
| width  | number | Yes  | Yes  | Image width, in pixels.|

## Point

Enumerates the point coordinates, which are used for focus and exposure configuration.

**System capability**: SystemCapability.Multimedia.Camera.Core

| Name  | Type  | Mandatory  | Description        |
| ------ | ------ | ---- | ------------ |
| x      | number | Yes   | X coordinate of a point.  |
| y      | number | Yes   | Y coordinate of a point.  |

## CameraFormat

Enumerates the camera output formats.

**System capability**: SystemCapability.Multimedia.Camera.Core

674
| Name                    | Value       | Description        |
675 676 677 678 679 680 681 682 683 684 685
| ----------------------- | --------- | ------------ |
| CAMERA_FORMAT_RGBA_8888 | 3         | RGB image.            |
| CAMERA_FORMAT_YUV_420_SP| 1003      | YUV 420 SP image.     |
| CAMERA_FORMAT_JPEG      | 2000      | JPEG image.           |

## CameraInput

Provides camera information used in **[CaptureSession](#capturesession)**.

### open

G
Gloria 已提交
686
open\(callback: AsyncCallback\<void\>\): void
687 688

Opens this camera. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
689

W
wusongqing 已提交
690
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
691 692 693

**Parameters**

694 695
| Name    | Type                 | Mandatory| Description                 |
| -------- | -------------------- | ---- | ------------------- |
G
Gloria 已提交
696
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
N
nikhilraut 已提交
697

G
Gloria 已提交
698 699 700 701 702 703 704 705 706 707
**Error codes**

For details about the error codes, see [CameraErrorCode](#cameraerrorcode).

| ID        | Error Message       |
| --------------- | --------------- |
| 7400107                |  Can not use camera cause of conflict.               |
| 7400108                |  Camera disabled cause of security reason.                                  |
| 7400201                |  Camera service fatal error.                                  |

N
nikhilraut 已提交
708 709
**Example**

W
wusongqing 已提交
710
```js
711
cameraInput.open((err) => {
N
nikhilraut 已提交
712
    if (err) {
G
Gloria 已提交
713
        console.error(`Failed to open the camera. ${err.code}`);
N
nikhilraut 已提交
714 715
        return;
    }
716
    console.log('Callback returned with camera opened.');
N
nikhilraut 已提交
717 718 719
})
```

720
### open
N
nikhilraut 已提交
721

G
Gloria 已提交
722
open(): Promise\<void\>
N
nikhilraut 已提交
723

724
Opens this camera. This API uses a promise to return the result.
N
nikhilraut 已提交
725

W
wusongqing 已提交
726
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
727

728
**Return value**
N
nikhilraut 已提交
729

730 731
| Type          | Description                     |
| -------------- | ----------------------- |
G
Gloria 已提交
732
| Promise\<void\> | Promise used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
N
nikhilraut 已提交
733

G
Gloria 已提交
734 735 736 737 738 739 740 741 742 743
**Error codes**

For details about the error codes, see [CameraErrorCode](#cameraerrorcode).

| ID        | Error Message       |
| --------------- | --------------- |
| 7400107                |  Can not use camera cause of conflict.               |
| 7400108                |  Camera disabled cause of security reason.                                  |
| 7400201                |  Camera service fatal error.                                  |

N
nikhilraut 已提交
744 745
**Example**

W
wusongqing 已提交
746
```js
747 748
cameraInput.open().then(() => {
    console.log('Promise returned with camera opened.');
G
Gloria 已提交
749 750 751
}).catch((err) => {
    console.error(`Failed to open the camera. ${err.code}`);
});
N
nikhilraut 已提交
752 753
```

754
### close
N
nikhilraut 已提交
755

G
Gloria 已提交
756
close\(callback: AsyncCallback\<void\>\): void
N
nikhilraut 已提交
757

758
Closes this camera. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
759 760

**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
761 762 763

**Parameters**

764 765
| Name    | Type                  | Mandatory| Description                 |
| -------- | -------------------- | ---- | -------------------- |
G
Gloria 已提交
766
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
N
nikhilraut 已提交
767

G
Gloria 已提交
768 769 770 771 772 773 774 775
**Error codes**

For details about the error codes, see [CameraErrorCode](#cameraerrorcode).

| ID        | Error Message       |
| --------------- | --------------- |
| 7400201                |  Camera service fatal error.                                  |

N
nikhilraut 已提交
776 777
**Example**

W
wusongqing 已提交
778
```js
779
cameraInput.close((err) => {
N
nikhilraut 已提交
780
    if (err) {
G
Gloria 已提交
781
        console.error(`Failed to close the cameras. ${err.code}`);
N
nikhilraut 已提交
782 783
        return;
    }
784
    console.log('Callback returned with camera closed.');
W
wusongqing 已提交
785
})
N
nikhilraut 已提交
786 787
```

788
### close
N
nikhilraut 已提交
789

G
Gloria 已提交
790
close(): Promise\<void\>
N
nikhilraut 已提交
791

792
Closes this camera. This API uses a promise to return the result.
N
nikhilraut 已提交
793

W
wusongqing 已提交
794
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
795

W
wusongqing 已提交
796
**Return value**
N
nikhilraut 已提交
797

798 799
| Type          | Description                     |
| -------------- | ----------------------- |
G
Gloria 已提交
800
| Promise\<void\> | Promise used to return the result.|
N
nikhilraut 已提交
801

G
Gloria 已提交
802 803 804 805 806 807 808 809
**Error codes**

For details about the error codes, see [CameraErrorCode](#cameraerrorcode).

| ID        | Error Message       |
| --------------- | --------------- |
| 7400201                |  Camera service fatal error.                                  |

N
nikhilraut 已提交
810 811
**Example**

W
wusongqing 已提交
812
```js
813 814
cameraInput.close().then(() => {
    console.log('Promise returned with camera closed.');
G
Gloria 已提交
815 816 817
}).catch((err) => {
    console.error(`Failed to close the cameras. ${err.code}`);
});
N
nikhilraut 已提交
818 819
```

G
Gloria 已提交
820
### on('error')
N
nikhilraut 已提交
821

G
Gloria 已提交
822
on(type: 'error', camera:CameraDevice, callback: ErrorCallback\<BusinessError\>): void
N
nikhilraut 已提交
823

G
Gloria 已提交
824
Listens for **CameraInput** errors. This API uses a callback to return the result.
N
nikhilraut 已提交
825

W
wusongqing 已提交
826
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
827 828 829

**Parameters**

G
Gloria 已提交
830 831
| Name    | Type                             | Mandatory| Description                                         |
| -------- | -------------------------------- | --- | ------------------------------------------- |
G
Gloria 已提交
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.|
G
Gloria 已提交
833
| cameraDevice   | [CameraDevice](#cameradevice)    | Yes  | **CameraDevice** object.|
G
Gloria 已提交
834
| callback | ErrorCallback\<BusinessError\> | Yes  | Callback used to return an error code defined in [CameraErrorCode](#cameraerrorcode).  |
N
nikhilraut 已提交
835 836 837

**Example**

W
wusongqing 已提交
838
```js
G
Gloria 已提交
839 840 841 842
let cameraDevice = cameras[0];
cameraInput.on('error', cameraDevice, (error) => {
    console.log(`Camera input error code: ${error.code}`);
})
N
nikhilraut 已提交
843 844
```

G
Gloria 已提交
845
## FlashMode
N
nikhilraut 已提交
846

G
Gloria 已提交
847
Enumerates the flash modes.
W
wusongqing 已提交
848 849 850

**System capability**: SystemCapability.Multimedia.Camera.Core

851 852
| Name                   | Value  | Description       |
| ---------------------- | ---- | ---------- |
W
wusongqing 已提交
853 854 855 856 857
| FLASH_MODE_CLOSE       | 0    | The flash is off.|
| FLASH_MODE_OPEN        | 1    | The flash is on.|
| FLASH_MODE_AUTO        | 2    | The flash mode is auto, indicating that the flash fires automatically depending on the shooting conditions.|
| FLASH_MODE_ALWAYS_OPEN | 3    | The flash is steady on.|

858 859 860 861 862 863 864 865
## ExposureMode

Enumerates the exposure modes.

**System capability**: SystemCapability.Multimedia.Camera.Core

| Name                          | Value  | Description        |
| ----------------------------- | ---- | ----------- |
G
Gloria 已提交
866 867 868
| EXPOSURE_MODE_LOCKED          | 0    | Exposure locked. The metering point cannot be set.|
| EXPOSURE_MODE_AUTO            | 1    | Auto exposure. The metering point can be set by calling [setMeteringPoint](#setmeteringpoint).|
| EXPOSURE_MODE_CONTINUOUS_AUTO | 2    | Continuous auto exposure. The metering point cannot be set.|
869 870

 ## FocusMode
W
wusongqing 已提交
871 872 873 874 875

Enumerates the focus modes.

**System capability**: SystemCapability.Multimedia.Camera.Core

876 877
| Name                       | Value  | Description         |
| -------------------------- | ---- | ------------ |
G
Gloria 已提交
878
| FOCUS_MODE_MANUAL          | 0    | Manual focus. The focal length of the camera can be manually set to change the focus position. However, the focal point cannot be set.    |
G
Gloria 已提交
879 880 881
| FOCUS_MODE_CONTINUOUS_AUTO | 1    | Continuous auto focus. The focal point cannot be set.|
| FOCUS_MODE_AUTO            | 2    | Auto focus. The focal point can be set by calling [setFocusPoint](#setfocuspoint), and auto focus is performed once based on the focal point. After the auto focus operation is complete (regardless of whether the focus is successful or fails), the focus mode is locked. To enable the camera to initiate another auto focus, the application must call **CONTINUOUS_AUTO** again.   |
| FOCUS_MODE_LOCKED          | 3    | Focus locked. The focal point cannot be set.    |
W
wusongqing 已提交
882 883 884 885 886 887 888

## FocusState

Enumerates the focus states.

**System capability**: SystemCapability.Multimedia.Camera.Core

889 890 891 892
| Name                  | Value  | Description      |
| --------------------- | ---- | --------- |
| FOCUS_STATE_SCAN      | 0    | Focusing. |
| FOCUS_STATE_FOCUSED   | 1    | Focused. |
W
wusongqing 已提交
893 894
| FOCUS_STATE_UNFOCUSED | 2    | Unfocused.|

895
## VideoStabilizationMode
W
wusongqing 已提交
896

897
Enumerates the video stabilization modes.
W
wusongqing 已提交
898 899 900

**System capability**: SystemCapability.Multimedia.Camera.Core

901 902 903 904 905 906 907
| Name      | Value  | Description        |
| --------- | ---- | ------------ |
| OFF       | 0    | Video stabilization is disabled.  |
| LOW       | 1    | The basic video stabilization algorithm is used.  |
| MIDDLE    | 2    | A video stabilization algorithm with a stabilization effect better than that of the **LOW** type is used.  |
| HIGH      | 3    | A video stabilization algorithm with a stabilization effect better than that of the **MIDDLE** type is used.  |
| AUTO      | 4    | Automatic video stabilization is used.  |
W
wusongqing 已提交
908 909 910

## CaptureSession

911
Implements 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.
W
wusongqing 已提交
912 913 914

### beginConfig

G
Gloria 已提交
915
beginConfig(): void
N
nikhilraut 已提交
916

G
Gloria 已提交
917
Starts configuration for the session.
N
nikhilraut 已提交
918

W
wusongqing 已提交
919
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
920

W
wusongqing 已提交
921
**Return value**
N
nikhilraut 已提交
922

G
Gloria 已提交
923 924 925
| Type       | Description                         |
| ---------- | ----------------------------- |
| [CameraErrorCode](#cameraerrorcode)    | If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
N
nikhilraut 已提交
926

G
Gloria 已提交
927 928 929 930 931 932 933 934
**Error codes**

For details about the error codes, see [CameraErrorCode](#cameraerrorcode).

| ID        | Error Message       |
| --------------- | --------------- |
| 7400105                |  Session config locked.               |

N
nikhilraut 已提交
935 936
**Example**

W
wusongqing 已提交
937
```js
G
Gloria 已提交
938 939 940 941 942 943
try {
    captureSession.beginConfig();
} catch (error) {
    // If the operation fails, error.code is returned and processed.
    console.log(error.code);
}
N
nikhilraut 已提交
944 945
```

W
wusongqing 已提交
946
### commitConfig
N
nikhilraut 已提交
947

G
Gloria 已提交
948
commitConfig(callback: AsyncCallback\<void\>): void
N
nikhilraut 已提交
949

W
wusongqing 已提交
950
Commits the configuration for this **CaptureSession** instance. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
951

W
wusongqing 已提交
952
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
953 954 955

**Parameters**

956 957
| Name    | Type                  | Mandatory| Description                 |
| -------- | -------------------- | ---- | -------------------- |
G
Gloria 已提交
958
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
N
nikhilraut 已提交
959

G
Gloria 已提交
960 961 962 963 964 965 966 967 968
**Error codes**

For details about the error codes, see [CameraErrorCode](#cameraerrorcode).

| ID        | Error Message       |
| --------------- | --------------- |
| 7400102                |  Operation not allow.                                  |
| 7400201                |  Camera service fatal error.                           |

N
nikhilraut 已提交
969 970
**Example**

W
wusongqing 已提交
971
```js
W
wusongqing 已提交
972
captureSession.commitConfig((err) => {
N
nikhilraut 已提交
973
    if (err) {
G
Gloria 已提交
974
        console.log('Failed to commitConfig '+ err.code);
N
nikhilraut 已提交
975 976
        return;
    }
W
wusongqing 已提交
977
    console.log('Callback invoked to indicate the commit config success.');
N
nikhilraut 已提交
978 979 980
});
```

W
wusongqing 已提交
981
### commitConfig
N
nikhilraut 已提交
982

G
Gloria 已提交
983
commitConfig(): Promise\<void\>
N
nikhilraut 已提交
984

W
wusongqing 已提交
985
Commits the configuration for this **CaptureSession** instance. This API uses a promise to return the result.
N
nikhilraut 已提交
986

W
wusongqing 已提交
987
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
988

W
wusongqing 已提交
989
**Return value**
N
nikhilraut 已提交
990

991 992
| Type           | Description                     |
| -------------- | ------------------------ |
G
Gloria 已提交
993
| Promise\<void\> | Promise used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
N
nikhilraut 已提交
994

G
Gloria 已提交
995 996 997 998 999 1000 1001 1002 1003
**Error codes**

For details about the error codes, see [CameraErrorCode](#cameraerrorcode).

| ID        | Error Message       |
| --------------- | --------------- |
| 7400102                |  Operation not allow.                                  |
| 7400201                |  Camera service fatal error.                           |

N
nikhilraut 已提交
1004 1005
**Example**

W
wusongqing 已提交
1006
```js
W
wusongqing 已提交
1007 1008
captureSession.commitConfig().then(() => {
    console.log('Promise returned to indicate the commit config success.');
G
Gloria 已提交
1009 1010 1011
}).catch((err) => {
    // If the operation fails, error.code is returned and processed.
    console.log('Failed to commitConfig '+ err.code);
1012
});
N
nikhilraut 已提交
1013 1014
```

1015
### addInput
N
nikhilraut 已提交
1016

G
Gloria 已提交
1017
addInput(cameraInput: CameraInput): void
N
nikhilraut 已提交
1018

G
Gloria 已提交
1019
Adds a [CameraInput](#camerainput) instance to the session.
N
nikhilraut 已提交
1020

W
wusongqing 已提交
1021
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1022 1023 1024

**Parameters**

1025 1026
| Name       | Type                         | Mandatory| Description                    |
| ----------- | --------------------------- | ---- | ------------------------ |
W
wusongqing 已提交
1027
| cameraInput | [CameraInput](#camerainput) | Yes  | **CameraInput** instance to add.|
N
nikhilraut 已提交
1028

W
wusongqing 已提交
1029
**Return value**
N
nikhilraut 已提交
1030

G
Gloria 已提交
1031 1032 1033
| Type       | Description                         |
| ---------- | ----------------------------- |
| [CameraErrorCode](#cameraerrorcode)    | If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
N
nikhilraut 已提交
1034

G
Gloria 已提交
1035 1036 1037 1038 1039 1040 1041 1042 1043
**Error codes**

For details about the error codes, see [CameraErrorCode](#cameraerrorcode).

| ID        | Error Message       |
| --------------- | --------------- |
| 7400101                |  Parameter missing or parameter type incorrect        |
| 7400102                |  Operation not allow.                                  |

N
nikhilraut 已提交
1044 1045
**Example**

W
wusongqing 已提交
1046
```js
G
Gloria 已提交
1047 1048 1049 1050 1051 1052
try {
    captureSession.addInput(cameraInput);
} catch (error) {
    // If the operation fails, error.code is returned and processed.
    console.log(error.code);
}
N
nikhilraut 已提交
1053 1054
```

1055
### removeInput
N
nikhilraut 已提交
1056

G
Gloria 已提交
1057
removeInput(cameraInput: CameraInput): void
N
nikhilraut 已提交
1058

G
Gloria 已提交
1059
Removes a [CameraInput](#camerainput) instance from the session.
N
nikhilraut 已提交
1060

W
wusongqing 已提交
1061
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1062 1063 1064

**Parameters**

1065 1066 1067
| Name       | Type                         | Mandatory| Description                     |
| ----------- | --------------------------- | ---- | ------------------------ |
| cameraInput | [CameraInput](#camerainput) | Yes  | **CameraInput** instance to remove.|
N
nikhilraut 已提交
1068

W
wusongqing 已提交
1069
**Return value**
N
nikhilraut 已提交
1070

G
Gloria 已提交
1071 1072 1073
| Type       | Description                         |
| ---------- | ----------------------------- |
| [CameraErrorCode](#cameraerrorcode)    | If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
N
nikhilraut 已提交
1074

G
Gloria 已提交
1075 1076 1077 1078 1079 1080 1081 1082 1083
**Error codes**

For details about the error codes, see [CameraErrorCode](#cameraerrorcode).

| ID        | Error Message       |
| --------------- | --------------- |
| 7400101                |  Parameter missing or parameter type incorrect        |
| 7400102                |  Operation not allow.                                  |

N
nikhilraut 已提交
1084 1085
**Example**

W
wusongqing 已提交
1086
```js
G
Gloria 已提交
1087 1088 1089 1090 1091 1092
try {
    captureSession.removeInput(cameraInput);
} catch (error) {
    // If the operation fails, error.code is returned and processed.
    console.log(error.code);
}
N
nikhilraut 已提交
1093 1094
```

1095
### addOutput
N
nikhilraut 已提交
1096

G
Gloria 已提交
1097
addOutput(cameraOutput: CameraOutput): void
N
nikhilraut 已提交
1098

G
Gloria 已提交
1099
Adds a [CameraOutput](#cameraoutput) instance to the session.
N
nikhilraut 已提交
1100

W
wusongqing 已提交
1101
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1102 1103 1104

**Parameters**

1105 1106
| Name          | Type                            | Mandatory| Description                     |
| ------------- | ------------------------------- | ---- | ------------------------ |
G
Gloria 已提交
1107
| cameraOutput  | [CameraOutput](#cameraoutput)   | Yes  | **CameraOutput** instance to add.|
N
nikhilraut 已提交
1108

W
wusongqing 已提交
1109
**Return value**
N
nikhilraut 已提交
1110

G
Gloria 已提交
1111 1112 1113
| Type       | Description                         |
| ---------- | ----------------------------- |
| [CameraErrorCode](#cameraerrorcode)    | If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
N
nikhilraut 已提交
1114

G
Gloria 已提交
1115 1116 1117 1118 1119 1120 1121 1122 1123
**Error codes**

For details about the error codes, see [CameraErrorCode](#cameraerrorcode).

| ID        | Error Message       |
| --------------- | --------------- |
| 7400101                |  Parameter missing or parameter type incorrect        |
| 7400102                |  Operation not allow.                                  |

N
nikhilraut 已提交
1124 1125
**Example**

W
wusongqing 已提交
1126
```js
G
Gloria 已提交
1127
try {
G
Gloria 已提交
1128
    captureSession.addOutput(cameraOutput);
G
Gloria 已提交
1129 1130 1131 1132
} catch (error) {
    // If the operation fails, error.code is returned and processed.
    console.log(error.code);
}
N
nikhilraut 已提交
1133 1134
```

1135
### removeOutput
N
nikhilraut 已提交
1136

G
Gloria 已提交
1137
removeOutput(cameraOutput: CameraOutput): void
N
nikhilraut 已提交
1138

G
Gloria 已提交
1139
Removes a [CameraOutput](#cameraoutput) instance from the session.
N
nikhilraut 已提交
1140

W
wusongqing 已提交
1141
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1142 1143 1144

**Parameters**

1145 1146
| Name          | Type                            | Mandatory| Description                     |
| ------------- | ------------------------------- | ---- | ------------------------ |
G
Gloria 已提交
1147
| cameraOutput  | [CameraOutput](#cameraoutput)   | Yes  | **CameraOutput** instance to remove.|
N
nikhilraut 已提交
1148

W
wusongqing 已提交
1149
**Return value**
N
nikhilraut 已提交
1150

G
Gloria 已提交
1151 1152 1153
| Type       | Description                         |
| ---------- | ----------------------------- |
| [CameraErrorCode](#cameraerrorcode)    | If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
N
nikhilraut 已提交
1154

G
Gloria 已提交
1155 1156 1157 1158 1159 1160 1161 1162 1163
**Error codes**

For details about the error codes, see [CameraErrorCode](#cameraerrorcode).

| ID        | Error Message       |
| --------------- | --------------- |
| 7400101                |  Parameter missing or parameter type incorrect        |
| 7400102                |  Operation not allow.                                  |

N
nikhilraut 已提交
1164 1165
**Example**

W
wusongqing 已提交
1166
```js
G
Gloria 已提交
1167 1168 1169 1170 1171 1172
try {
    captureSession.removeOutput(previewOutput);
} catch (error) {
    // If the operation fails, error.code is returned and processed.
    console.log(error.code);
}
N
nikhilraut 已提交
1173 1174
```

1175
### start
N
nikhilraut 已提交
1176

G
Gloria 已提交
1177
start\(callback: AsyncCallback\<void\>\): void
N
nikhilraut 已提交
1178

1179
Starts this **CaptureSession**. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
1180

W
wusongqing 已提交
1181
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1182 1183 1184

**Parameters**

1185 1186
| Name     | Type                 | Mandatory| Description                |
| -------- | -------------------- | ---- | -------------------- |
G
Gloria 已提交
1187
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
N
nikhilraut 已提交
1188

G
Gloria 已提交
1189 1190 1191 1192 1193 1194 1195 1196 1197
**Error codes**

For details about the error codes, see [CameraErrorCode](#cameraerrorcode).

| ID        | Error Message       |
| --------------- | --------------- |
| 7400103                |  Session not config.                                   |
| 7400201                |  Camera service fatal error.                           |

N
nikhilraut 已提交
1198 1199
**Example**

W
wusongqing 已提交
1200
```js
1201
captureSession.start((err) => {
N
nikhilraut 已提交
1202
    if (err) {
G
Gloria 已提交
1203
        console.error(`Failed to start the session ${err.code}`);
N
nikhilraut 已提交
1204 1205
        return;
    }
1206
    console.log('Callback invoked to indicate the session start success.');
1207
});
N
nikhilraut 已提交
1208 1209
```

1210
### start
N
nikhilraut 已提交
1211

G
Gloria 已提交
1212
start\(\): Promise\<void\>
N
nikhilraut 已提交
1213

1214
Starts this **CaptureSession**. This API uses a promise to return the result.
N
nikhilraut 已提交
1215

W
wusongqing 已提交
1216
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1217

W
wusongqing 已提交
1218
**Return value**
N
nikhilraut 已提交
1219

1220 1221
| Type           | Description                    |
| -------------- | ------------------------ |
G
Gloria 已提交
1222
| Promise\<void\> | Promise used to return the result.|
N
nikhilraut 已提交
1223

G
Gloria 已提交
1224 1225 1226 1227 1228 1229 1230 1231 1232
**Error codes**

For details about the error codes, see [CameraErrorCode](#cameraerrorcode).

| ID        | Error Message       |
| --------------- | --------------- |
| 7400103                |  Session not config.                                   |
| 7400201                |  Camera service fatal error.                           |

N
nikhilraut 已提交
1233 1234
**Example**

W
wusongqing 已提交
1235
```js
1236 1237
captureSession.start().then(() => {
    console.log('Promise returned to indicate the session start success.');
G
Gloria 已提交
1238 1239 1240
}).catch((err) => {
    console.error(`Failed to start the session ${err.code}`);
});
N
nikhilraut 已提交
1241 1242
```

1243
### stop
N
nikhilraut 已提交
1244

G
Gloria 已提交
1245
stop\(callback: AsyncCallback\<void\>\): void
N
nikhilraut 已提交
1246

1247
Stops this **CaptureSession**. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
1248

W
wusongqing 已提交
1249
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1250 1251 1252

**Parameters**

1253 1254
| Name     | Type                 | Mandatory| Description                |
| -------- | -------------------- | ---- | ------------------- |
G
Gloria 已提交
1255
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
N
nikhilraut 已提交
1256

G
Gloria 已提交
1257 1258 1259 1260 1261 1262 1263 1264
**Error codes**

For details about the error codes, see [CameraErrorCode](#cameraerrorcode).

| ID        | Error Message       |
| --------------- | --------------- |
| 7400201                |  Camera service fatal error.                           |

N
nikhilraut 已提交
1265 1266
**Example**

W
wusongqing 已提交
1267
```js
1268
captureSession.stop((err) => {
N
nikhilraut 已提交
1269
    if (err) {
G
Gloria 已提交
1270
        console.error(`Failed to stop the session ${err.code}`);
N
nikhilraut 已提交
1271 1272
        return;
    }
1273
    console.log('Callback invoked to indicate the session stop success.');
N
nikhilraut 已提交
1274 1275 1276
});
```

1277
### stop
N
nikhilraut 已提交
1278

G
Gloria 已提交
1279
stop(): Promise\<void\>
N
nikhilraut 已提交
1280

1281
Stops this **CaptureSession**. This API uses a promise to return the result.
N
nikhilraut 已提交
1282

W
wusongqing 已提交
1283
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1284

W
wusongqing 已提交
1285
**Return value**
N
nikhilraut 已提交
1286

1287 1288
| Type           | Description                    |
| -------------- | ----------------------- |
G
Gloria 已提交
1289
| Promise\<void\> | Promise used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
N
nikhilraut 已提交
1290

G
Gloria 已提交
1291 1292 1293 1294 1295 1296 1297 1298
**Error codes**

For details about the error codes, see [CameraErrorCode](#cameraerrorcode).

| ID        | Error Message       |
| --------------- | --------------- |
| 7400201                |  Camera service fatal error.                           |

N
nikhilraut 已提交
1299 1300
**Example**

W
wusongqing 已提交
1301
```js
1302 1303
captureSession.stop().then(() => {
    console.log('Promise returned to indicate the session stop success.');
G
Gloria 已提交
1304 1305 1306
}).catch((err) => {
    console.error(`Failed to stop the session ${err.code}`);
});
N
nikhilraut 已提交
1307 1308
```

1309
### release
N
nikhilraut 已提交
1310

G
Gloria 已提交
1311
release\(callback: AsyncCallback\<void\>\): void
N
nikhilraut 已提交
1312

1313
Releases this **CaptureSession**. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
1314

W
wusongqing 已提交
1315
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1316 1317 1318

**Parameters**

1319 1320
| Name     | Type                 | Mandatory| Description                |
| -------- | -------------------- | ---- | -------------------- |
G
Gloria 已提交
1321
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
N
nikhilraut 已提交
1322

G
Gloria 已提交
1323 1324 1325 1326 1327 1328 1329 1330
**Error codes**

For details about the error codes, see [CameraErrorCode](#cameraerrorcode).

| ID        | Error Message       |
| --------------- | --------------- |
| 7400201                |  Camera service fatal error.                           |

N
nikhilraut 已提交
1331 1332
**Example**

W
wusongqing 已提交
1333
```js
1334
captureSession.release((err) => {
N
nikhilraut 已提交
1335
    if (err) {
G
Gloria 已提交
1336
        console.error(`Failed to release the CaptureSession instance ${err.code}`);
N
nikhilraut 已提交
1337 1338
        return;
    }
1339
    console.log('Callback invoked to indicate that the CaptureSession instance is released successfully.');
N
nikhilraut 已提交
1340 1341 1342
});
```

1343
### release
N
nikhilraut 已提交
1344

G
Gloria 已提交
1345
release(): Promise\<void\>
N
nikhilraut 已提交
1346

1347
Releases this **CaptureSession**. This API uses a promise to return the result.
N
nikhilraut 已提交
1348

W
wusongqing 已提交
1349
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1350

W
wusongqing 已提交
1351
**Return value**
N
nikhilraut 已提交
1352

1353 1354
| Type           | Description                    |
| -------------- | ------------------------ |
G
Gloria 已提交
1355
| Promise\<void\> | Promise used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
N
nikhilraut 已提交
1356

G
Gloria 已提交
1357 1358 1359 1360 1361 1362 1363 1364
**Error codes**

For details about the error codes, see [CameraErrorCode](#cameraerrorcode).

| ID        | Error Message       |
| --------------- | --------------- |
| 7400201                |  Camera service fatal error.                           |

N
nikhilraut 已提交
1365 1366
**Example**

W
wusongqing 已提交
1367
```js
1368 1369
captureSession.release().then(() => {
    console.log('Promise returned to indicate that the CaptureSession instance is released successfully.');
G
Gloria 已提交
1370 1371 1372
}).catch((err) => {
    console.error(`Failed to release the CaptureSession instance ${err.code}`);
});
N
nikhilraut 已提交
1373 1374
```

1375
### hasFlash
N
nikhilraut 已提交
1376

G
Gloria 已提交
1377
hasFlash(): boolean
N
nikhilraut 已提交
1378

1379
Checks whether the device has flash. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
1380

W
wusongqing 已提交
1381
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1382

1383
**Return value**
1384

G
Gloria 已提交
1385 1386 1387
| Type       | Description                         |
| ---------- | ----------------------------- |
| 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

G
Gloria 已提交
1389 1390 1391 1392 1393 1394 1395 1396
**Error codes**

For details about the error codes, see [CameraErrorCode](#cameraerrorcode).

| ID        | Error Message       |
| --------------- | --------------- |
| 7400103                |  Session not config.                                   |

1397 1398 1399
**Example**

```js
G
Gloria 已提交
1400 1401 1402 1403 1404 1405
try {
    let status = captureSession.hasFlash();
} catch (error) {
    // If the operation fails, error.code is returned and processed.
    console.log(error.code);
}
1406 1407 1408 1409
```

### isFlashModeSupported

G
Gloria 已提交
1410
isFlashModeSupported(flashMode: FlashMode): boolean
1411

G
Gloria 已提交
1412
Checks whether a flash mode is supported.
1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423

**System capability**: SystemCapability.Multimedia.Camera.Core

**Parameters**

| Name      | Type                    | Mandatory| Description                              |
| --------- | ----------------------- | ---- | --------------------------------- |
| flashMode | [FlashMode](#flashmode) | Yes  | Flash mode.                    |

**Return value**

G
Gloria 已提交
1424 1425 1426
| Type       | Description                         |
| ---------- | ----------------------------- |
| 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

G
Gloria 已提交
1428 1429 1430 1431 1432 1433 1434 1435
**Error codes**

For details about the error codes, see [CameraErrorCode](#cameraerrorcode).

| ID        | Error Message       |
| --------------- | --------------- |
| 7400103                |  Session not config.                                   |

1436 1437 1438
**Example**

```js
G
Gloria 已提交
1439 1440 1441 1442 1443 1444
try {
    let status = captureSession.isFlashModeSupported(camera.FlashMode.FLASH_MODE_AUTO);
} catch (error) {
    // If the operation fails, error.code is returned and processed.
    console.log(error.code);
}
1445 1446 1447 1448
```

### setFlashMode

G
Gloria 已提交
1449
setFlashMode(flashMode: FlashMode): void
1450

G
Gloria 已提交
1451
Sets a flash mode for the device.
1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463

Before the setting, do the following checks:

1. Use **[hasFlash](#hasflash)** to check whether the device has flash.
2. Use **[isFlashModeSupported](#isflashmodesupported)** to check whether the device supports the flash mode.

**System capability**: SystemCapability.Multimedia.Camera.Core

**Parameters**

| Name      | Type                    | Mandatory| Description                 |
| --------- | ----------------------- | ---- | --------------------- |
G
Gloria 已提交
1464 1465 1466 1467 1468 1469 1470
| flashMode | [FlashMode](#flashmode) | Yes  | Flash mode.      |

**Return value**

| Type       | Description                         |
| ---------- | ----------------------------- |
| [CameraErrorCode](#cameraerrorcode)    | If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
1471

G
Gloria 已提交
1472 1473 1474 1475 1476 1477 1478 1479
**Error codes**

For details about the error codes, see [CameraErrorCode](#cameraerrorcode).

| ID        | Error Message       |
| --------------- | --------------- |
| 7400103                |  Session not config.                                   |

1480 1481 1482
**Example**

```js
G
Gloria 已提交
1483 1484 1485 1486 1487 1488
try {
    captureSession.setFlashMode(camera.FlashMode.FLASH_MODE_AUTO);
} catch (error) {
    // If the operation fails, error.code is returned and processed.
    console.log(error.code);
}
1489 1490
```

G
Gloria 已提交
1491
### getFlashMode
1492

G
Gloria 已提交
1493
getFlashMode(): FlashMode
1494

G
Gloria 已提交
1495
Obtains the flash mode in use.
1496 1497 1498 1499 1500

**System capability**: SystemCapability.Multimedia.Camera.Core

**Return value**

G
Gloria 已提交
1501 1502 1503
| Type       | Description                         |
| ---------- | ----------------------------- |
| [FlashMode](#flashmode)    | Flash mode obtained. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
1504

G
Gloria 已提交
1505 1506 1507 1508 1509 1510 1511 1512
**Error codes**

For details about the error codes, see [CameraErrorCode](#cameraerrorcode).

| ID        | Error Message       |
| --------------- | --------------- |
| 7400103                |  Session not config.                                   |

1513 1514 1515
**Example**

```js
G
Gloria 已提交
1516 1517 1518 1519 1520 1521
try {
    let flashMode = captureSession.getFlashMode();
} catch (error) {
    // If the operation fails, error.code is returned and processed.
    console.log(error.code);
}
1522 1523 1524 1525
```

### isExposureModeSupported

G
Gloria 已提交
1526
isExposureModeSupported(aeMode: ExposureMode): boolean;
1527

G
Gloria 已提交
1528
Checks whether an exposure mode is supported.
1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539

**System capability**: SystemCapability.Multimedia.Camera.Core

**Parameters**

| Name     | Type                          | Mandatory | Description                          |
| -------- | -------------------------------| ---- | ----------------------------- |
| aeMode   | [ExposureMode](#exposuremode)  | Yes  | Exposure mode.                     |

**Return value**

G
Gloria 已提交
1540 1541 1542
| Type       | Description                         |
| ---------- | ----------------------------- |
| 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

G
Gloria 已提交
1544 1545 1546 1547 1548 1549 1550 1551
**Error codes**

For details about the error codes, see [CameraErrorCode](#cameraerrorcode).

| ID        | Error Message       |
| --------------- | --------------- |
| 7400103                |  Session not config.                                   |

1552 1553 1554
**Example**

```js
G
Gloria 已提交
1555 1556 1557 1558 1559 1560
try {
    let isSupported = captureSession.isExposureModeSupported(camera.ExposureMode.EXPOSURE_MODE_LOCKED);
} catch (error) {
    // If the operation fails, error.code is returned and processed.
    console.log(error.code);
}
1561 1562 1563 1564
```

### getExposureMode

G
Gloria 已提交
1565
getExposureMode(): ExposureMode
1566

G
Gloria 已提交
1567
Obtains the exposure mode in use.
1568 1569 1570 1571 1572

**System capability**: SystemCapability.Multimedia.Camera.Core

**Return value**

G
Gloria 已提交
1573 1574 1575
| Type       | Description                         |
| ---------- | ----------------------------- |
| [ExposureMode](#exposuremode)    | Exposure mode obtained. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
1576

G
Gloria 已提交
1577 1578 1579 1580 1581 1582 1583 1584
**Error codes**

For details about the error codes, see [CameraErrorCode](#cameraerrorcode).

| ID        | Error Message       |
| --------------- | --------------- |
| 7400103                |  Session not config.                                   |

1585 1586 1587
**Example**

```js
G
Gloria 已提交
1588 1589 1590 1591 1592 1593
try {
    let exposureMode = captureSession.getExposureMode();
} catch (error) {
    // If the operation fails, error.code is returned and processed.
    console.log(error.code);
}
1594 1595 1596 1597
```

### setExposureMode

G
Gloria 已提交
1598
setExposureMode(aeMode: ExposureMode): void
1599

G
Gloria 已提交
1600
Sets an exposure mode for the device.
1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611

**System capability**: SystemCapability.Multimedia.Camera.Core

**Parameters**

| Name     | Type                           | Mandatory| Description                   |
| -------- | -------------------------------| ---- | ----------------------- |
| aeMode   | [ExposureMode](#exposuremode)  | Yes  | Exposure mode.               |

**Return value**

G
Gloria 已提交
1612 1613 1614
| Type       | Description                         |
| ---------- | ----------------------------- |
| [CameraErrorCode](#cameraerrorcode)    | If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
1615

G
Gloria 已提交
1616 1617 1618 1619 1620 1621 1622 1623
**Error codes**

For details about the error codes, see [CameraErrorCode](#cameraerrorcode).

| ID        | Error Message       |
| --------------- | --------------- |
| 7400103                |  Session not config.                                   |

1624 1625 1626
**Example**

```js
G
Gloria 已提交
1627 1628 1629 1630 1631 1632
try {
    captureSession.setExposureMode(camera.ExposureMode.EXPOSURE_MODE_LOCKED);
} catch (error) {
    // If the operation fails, error.code is returned and processed.
    console.log(error.code);
}
1633 1634 1635 1636
```

### getMeteringPoint

G
Gloria 已提交
1637
getMeteringPoint(): Point
1638

G
Gloria 已提交
1639
Obtains the metering point of the device.  
1640 1641 1642 1643 1644

**System capability**: SystemCapability.Multimedia.Camera.Core

**Return value**

G
Gloria 已提交
1645 1646 1647
| Type       | Description                         |
| ---------- | ----------------------------- |
| [Point](#point)    | Metering point obtained. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
1648

G
Gloria 已提交
1649 1650 1651 1652 1653 1654 1655 1656
**Error codes**

For details about the error codes, see [CameraErrorCode](#cameraerrorcode).

| ID        | Error Message       |
| --------------- | --------------- |
| 7400103                |  Session not config.                                   |

1657 1658 1659
**Example**

```js
G
Gloria 已提交
1660 1661 1662 1663 1664 1665
try {
    let exposurePoint = captureSession.getMeteringPoint();
} catch (error) {
    // If the operation fails, error.code is returned and processed.
    console.log(error.code);
}
1666 1667 1668 1669
```

### setMeteringPoint

G
Gloria 已提交
1670
setMeteringPoint(point: Point): void
1671

G
Gloria 已提交
1672 1673 1674
Sets the metering point, which is the center point of the metering rectangle. The metering point must be in the coordinate system (0-1), where the upper left corner is {0, 0} and the lower right corner is {1, 1}.

The coordinate system is based on the horizontal device direction with the device's charging port on the right. If the layout of the preview screen of an application is based on the vertical direction with the charging port on the lower side, the layout width and height are {w, h}, and the touch point is {x, y}, then the coordinate point after conversion is {y/h, 1-x/w}.
1675 1676 1677 1678 1679 1680 1681

**System capability**: SystemCapability.Multimedia.Camera.Core

**Parameters**

| Name          | Type                           | Mandatory| Description                |
| ------------- | -------------------------------| ---- | ------------------- |
1682
| exposurePoint | [Point](#point)                | Yes  | Metering point. The value range of x and y must be within [0,1]. If a value less than 0 is passed, the value **0** is used. If a value greater than **1** is passed, the value **1** is used.            |
1683 1684 1685

**Return value**

G
Gloria 已提交
1686 1687 1688
| Type       | Description                         |
| ---------- | ----------------------------- |
| [CameraErrorCode](#cameraerrorcode)    | If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
1689

G
Gloria 已提交
1690 1691 1692 1693 1694 1695 1696 1697
**Error codes**

For details about the error codes, see [CameraErrorCode](#cameraerrorcode).

| ID        | Error Message       |
| --------------- | --------------- |
| 7400103                |  Session not config.                                   |

1698 1699 1700
**Example**

```js
G
Gloria 已提交
1701 1702 1703 1704 1705 1706 1707
const exposurePoint = {x: 1, y: 1};
try {
    captureSession.setMeteringPoint(exposurePoint);
} catch (error) {
    // If the operation fails, error.code is returned and processed.
    console.log(error.code);
}
1708 1709 1710 1711
```

### getExposureBiasRange

G
Gloria 已提交
1712
getExposureBiasRange(): Array\<number\>
1713

G
Gloria 已提交
1714
Obtains the exposure compensation values of the device.
1715 1716 1717 1718 1719

**System capability**: SystemCapability.Multimedia.Camera.Core

**Return value**

G
Gloria 已提交
1720 1721
| Type       | Description                         |
| ---------- | ----------------------------- |
G
Gloria 已提交
1722
| Array\<number\>   | An array of compensation values. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
1723

G
Gloria 已提交
1724 1725 1726 1727 1728 1729 1730 1731
**Error codes**

For details about the error codes, see [CameraErrorCode](#cameraerrorcode).

| ID        | Error Message       |
| --------------- | --------------- |
| 7400103                |  Session not config.                                   |

1732 1733 1734
**Example**

```js
G
Gloria 已提交
1735 1736 1737 1738 1739 1740
try {
    let biasRangeArray = captureSession.getExposureBiasRange();
} catch (error) {
    // If the operation fails, error.code is returned and processed.
    console.log(error.code);
}
1741 1742 1743 1744
```

### setExposureBias

G
Gloria 已提交
1745
setExposureBias(exposureBias: number): void
1746

G
Gloria 已提交
1747
Sets an exposure compensation value (EV).
1748 1749 1750 1751 1752 1753 1754 1755 1756

Before the setting, you are advised to use **[getExposureBiasRange](#getexposurebiasrange)** to obtain the supported values.

**System capability**: SystemCapability.Multimedia.Camera.Core

**Parameters**

| Name    | Type                           | Mandatory| Description                |
| -------- | -------------------------------| ---- | ------------------- |
1757
| exposureBias   | number                   | Yes  | EV. The supported EV range can be obtained by calling **getExposureBiasRange**. If calling the API fails, an error code defined in [CameraErrorCode](#cameraerrorcode) will be returned. If the value passed is not within the supported range, the nearest critical point is used.|
1758

G
Gloria 已提交
1759 1760 1761 1762 1763 1764 1765 1766
**Error codes**

For details about the error codes, see [CameraErrorCode](#cameraerrorcode).

| ID        | Error Message       |
| --------------- | --------------- |
| 7400103                |  Session not config.                                   |

1767 1768 1769
**Example**

```js
1770
let exposureBias = biasRangeArray[0];
G
Gloria 已提交
1771 1772 1773 1774 1775 1776
try {
    captureSession.setExposureBias(exposureBias);
} catch (error) {
    // If the operation fails, error.code is returned and processed.
    console.log(error.code);
}
1777 1778 1779 1780
```

### getExposureValue

G
Gloria 已提交
1781
getExposureValue(): number
1782

G
Gloria 已提交
1783
Obtains the exposure value in use.
1784 1785 1786 1787 1788

**System capability**: SystemCapability.Multimedia.Camera.Core

**Return value**

G
Gloria 已提交
1789 1790 1791
| Type       | Description                         |
| ---------- | ----------------------------- |
| number    | Exposure value obtained. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
1792

G
Gloria 已提交
1793 1794 1795 1796 1797 1798 1799 1800
**Error codes**

For details about the error codes, see [CameraErrorCode](#cameraerrorcode).

| ID        | Error Message       |
| --------------- | --------------- |
| 7400103                |  Session not config.                                   |

1801 1802 1803
**Example**

```js
G
Gloria 已提交
1804 1805 1806 1807 1808 1809
try {
    let exposureValue = captureSession.getExposureValue();
} catch (error) {
    // If the operation fails, error.code is returned and processed.
    console.log(error.code);
}
1810 1811 1812 1813
```

### isFocusModeSupported

G
Gloria 已提交
1814
isFocusModeSupported(afMode: FocusMode): boolean
1815

G
Gloria 已提交
1816
Checks whether a focus mode is supported.
1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827

**System capability**: SystemCapability.Multimedia.Camera.Core

**Parameters**

| Name     | Type                    | Mandatory| Description                             |
| -------- | ----------------------- | ---- | -------------------------------- |
| afMode   | [FocusMode](#focusmode) | Yes  | Focus mode.                   |

**Return value**

G
Gloria 已提交
1828 1829 1830
| Type       | Description                         |
| ---------- | ----------------------------- |
| 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.|
1831

G
Gloria 已提交
1832 1833 1834 1835 1836 1837 1838 1839
**Error codes**

For details about the error codes, see [CameraErrorCode](#cameraerrorcode).

| ID        | Error Message       |
| --------------- | --------------- |
| 7400103                |  Session not config.                                   |

1840 1841 1842
**Example**

```js
G
Gloria 已提交
1843 1844 1845 1846 1847 1848
try {
    let status = captureSession.isFocusModeSupported(camera.FocusMode.FOCUS_MODE_AUTO);
} catch (error) {
    // If the operation fails, error.code is returned and processed.
    console.log(error.code);
}
1849 1850 1851 1852
```

### setFocusMode

G
Gloria 已提交
1853
setFocusMode(afMode: FocusMode): void
1854

G
Gloria 已提交
1855
Sets a focus mode for the device.
1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868

Before the setting, use **[isFocusModeSupported](#isfocusmodesupported)** to check whether the focus mode is supported.

**System capability**: SystemCapability.Multimedia.Camera.Core

**Parameters**

| Name     | Type                    | Mandatory| Description                |
| -------- | ----------------------- | ---- | ------------------- |
| afMode   | [FocusMode](#focusmode) | Yes  | Focus mode.      |

**Return value**

G
Gloria 已提交
1869 1870 1871
| Type       | Description                         |
| ---------- | ----------------------------- |
| [CameraErrorCode](#cameraerrorcode)    | If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
1872

G
Gloria 已提交
1873 1874 1875 1876 1877 1878 1879 1880
**Error codes**

For details about the error codes, see [CameraErrorCode](#cameraerrorcode).

| ID        | Error Message       |
| --------------- | --------------- |
| 7400103                |  Session not config.                                   |

1881 1882 1883
**Example**

```js
G
Gloria 已提交
1884 1885 1886 1887 1888 1889
try {
    captureSession.setFocusMode(camera.FocusMode.FOCUS_MODE_AUTO);
} catch (error) {
    // If the operation fails, error.code is returned and processed.
    console.log(error.code);
}
1890 1891 1892 1893
```

### getFocusMode

G
Gloria 已提交
1894
getFocusMode(): FocusMode
1895

G
Gloria 已提交
1896
Obtains the focus mode in use.
1897 1898 1899 1900 1901

**System capability**: SystemCapability.Multimedia.Camera.Core

**Return value**

G
Gloria 已提交
1902 1903 1904
| Type       | Description                         |
| ---------- | ----------------------------- |
| [FocusMode](#focusmode)   | Focus mode obtained. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
1905

G
Gloria 已提交
1906 1907 1908 1909 1910 1911 1912 1913
**Error codes**

For details about the error codes, see [CameraErrorCode](#cameraerrorcode).

| ID        | Error Message       |
| --------------- | --------------- |
| 7400103                |  Session not config.                                   |

1914 1915 1916
**Example**

```js
G
Gloria 已提交
1917 1918 1919 1920 1921 1922
try {
    let afMode = captureSession.getFocusMode();
} catch (error) {
    // If the operation fails, error.code is returned and processed.
    console.log(error.code);
}
1923 1924 1925 1926
```

### setFocusPoint

G
Gloria 已提交
1927
setFocusPoint(point: Point): void
1928

G
Gloria 已提交
1929 1930 1931
Sets the focal point. The focal point must be in the coordinate system (0-1), where the upper left corner is {0, 0} and the lower right corner is {1, 1}.

The coordinate system is based on the horizontal device direction with the device's charging port on the right. If the layout of the preview screen of an application is based on the vertical direction with the charging port on the lower side, the layout width and height are {w, h}, and the touch point is {x, y}, then the coordinate point after conversion is {y/h, 1-x/w}.
1932 1933 1934 1935 1936 1937 1938

**System capability**: SystemCapability.Multimedia.Camera.Core

**Parameters**

| Name     | Type                    | Mandatory| Description                |
| -------- | ----------------------- | ---- | ------------------- |
1939
| Point1    | [Point](#point)         | Yes  | Focal point. The value range of x and y must be within [0,1]. If a value less than 0 is passed, the value **0** is used. If a value greater than **1** is passed, the value **1** is used.  |
1940 1941 1942

**Return value**

G
Gloria 已提交
1943 1944 1945
| Type       | Description                         |
| ---------- | ----------------------------- |
| [CameraErrorCode](#cameraerrorcode)    | If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
1946

G
Gloria 已提交
1947 1948 1949 1950 1951 1952 1953 1954
**Error codes**

For details about the error codes, see [CameraErrorCode](#cameraerrorcode).

| ID        | Error Message       |
| --------------- | --------------- |
| 7400103                |  Session not config.                                   |

1955 1956 1957
**Example**

```js
G
Gloria 已提交
1958 1959 1960 1961 1962 1963 1964
const Point1 = {x: 1, y: 1};
try {
    captureSession.setFocusPoint(Point1);
} catch (error) {
    // If the operation fails, error.code is returned and processed.
    console.log(error.code);
}
1965 1966 1967 1968
```

### getFocusPoint

G
Gloria 已提交
1969
getFocusPoint(): Point
1970

G
Gloria 已提交
1971
Obtains the focal point of the device.
1972 1973 1974 1975 1976

**System capability**: SystemCapability.Multimedia.Camera.Core

**Return value**

G
Gloria 已提交
1977 1978 1979
| Type       | Description                         |
| ---------- | ----------------------------- |
| [Point](#point)    | Focal point obtained. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
1980

G
Gloria 已提交
1981 1982 1983 1984 1985 1986 1987 1988
**Error codes**

For details about the error codes, see [CameraErrorCode](#cameraerrorcode).

| ID        | Error Message       |
| --------------- | --------------- |
| 7400103                |  Session not config.                                   |

1989 1990 1991
**Example**

```js
G
Gloria 已提交
1992 1993 1994 1995 1996 1997
try {
    let point = captureSession.getFocusPoint();
} catch (error) {
    // If the operation fails, error.code is returned and processed.
    console.log(error.code);
}
1998 1999 2000 2001
```

### getFocalLength

G
Gloria 已提交
2002
getFocalLength(): number
2003

G
Gloria 已提交
2004
Obtains the focal length of the device.
2005 2006 2007 2008 2009

**System capability**: SystemCapability.Multimedia.Camera.Core

**Return value**

G
Gloria 已提交
2010 2011 2012
| Type       | Description                         |
| ---------- | ----------------------------- |
| number    | Focal length obtained. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
2013

G
Gloria 已提交
2014 2015 2016 2017 2018 2019 2020 2021
**Error codes**

For details about the error codes, see [CameraErrorCode](#cameraerrorcode).

| ID        | Error Message       |
| --------------- | --------------- |
| 7400103                |  Session not config.                                   |

2022 2023 2024
**Example**

```js
G
Gloria 已提交
2025 2026 2027 2028 2029 2030
try {
    let focalLength = captureSession.getFocalLength();
} catch (error) {
    // If the operation fails, error.code is returned and processed.
    console.log(error.code);
}
2031 2032 2033 2034
```

### getZoomRatioRange

G
Gloria 已提交
2035
getZoomRatioRange(): Array\<number\>
2036

G
Gloria 已提交
2037
Obtains the supported zoom ratio range.
2038 2039 2040 2041 2042

**System capability**: SystemCapability.Multimedia.Camera.Core

**Return value**

G
Gloria 已提交
2043 2044
| Type       | Description                         |
| ---------- | ----------------------------- |
G
Gloria 已提交
2045
| 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.|
2046

G
Gloria 已提交
2047 2048 2049 2050 2051 2052 2053 2054
**Error codes**

For details about the error codes, see [CameraErrorCode](#cameraerrorcode).

| ID        | Error Message       |
| --------------- | --------------- |
| 7400103                |  Session not config.                                   |

2055 2056 2057
**Example**

```js
G
Gloria 已提交
2058 2059 2060 2061 2062 2063
try {
    let zoomRatioRange = captureSession.getZoomRatioRange();
} catch (error) {
    // If the operation fails, error.code is returned and processed.
    console.log(error.code);
}
2064 2065 2066 2067
```

### setZoomRatio

G
Gloria 已提交
2068
setZoomRatio(zoomRatio: number): void
2069

G
Gloria 已提交
2070
Sets a zoom ratio, with a maximum precision of two decimal places.
2071 2072 2073 2074 2075 2076 2077

**System capability**: SystemCapability.Multimedia.Camera.Core

**Parameters**

| Name      | Type                 | Mandatory| Description                |
| --------- | -------------------- | ---- | ------------------- |
2078
| zoomRatio | number               | Yes  | Zoom ratio. The supported zoom ratio range can be obtained by calling **getZoomRatioRange**. If the value passed is not within the supported range, the nearest critical point is used.|
2079 2080 2081

**Return value**

G
Gloria 已提交
2082 2083 2084
| Type       | Description                         |
| ---------- | ----------------------------- |
| [CameraErrorCode](#cameraerrorcode)    | If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
2085

G
Gloria 已提交
2086 2087 2088 2089 2090 2091 2092 2093
**Error codes**

For details about the error codes, see [CameraErrorCode](#cameraerrorcode).

| ID        | Error Message       |
| --------------- | --------------- |
| 7400103                |  Session not config.                                   |

2094 2095 2096
**Example**

```js
2097
let zoomRatio = zoomRatioRange[0];
G
Gloria 已提交
2098 2099 2100 2101 2102 2103
try {
    captureSession.setZoomRatio(zoomRatio);
} catch (error) {
    // If the operation fails, error.code is returned and processed.
    console.log(error.code);
}
2104 2105 2106 2107
```

### getZoomRatio

G
Gloria 已提交
2108
getZoomRatio(): number
2109

G
Gloria 已提交
2110
Obtains the zoom ratio in use.
2111 2112 2113 2114 2115

**System capability**: SystemCapability.Multimedia.Camera.Core

**Return value**

G
Gloria 已提交
2116 2117 2118
| Type       | Description                         |
| ---------- | ----------------------------- |
| number    | Zoom ratio obtained. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
2119

G
Gloria 已提交
2120 2121 2122 2123 2124 2125 2126 2127
**Error codes**

For details about the error codes, see [CameraErrorCode](#cameraerrorcode).

| ID        | Error Message       |
| --------------- | --------------- |
| 7400103                |  Session not config.                                   |

2128 2129 2130
**Example**

```js
G
Gloria 已提交
2131 2132 2133 2134 2135 2136
try {
    let zoomRatio = captureSession.getZoomRatio();
} catch (error) {
    // If the operation fails, error.code is returned and processed.
    console.log(error.code);
}
2137 2138
```

G
Gloria 已提交
2139
### isVideoStabilizationModeSupported
2140

G
Gloria 已提交
2141
isVideoStabilizationModeSupported(vsMode: VideoStabilizationMode): boolean
2142

G
Gloria 已提交
2143
Checks whether the specified video stabilization mode is supported. 
2144 2145 2146

**System capability**: SystemCapability.Multimedia.Camera.Core

G
Gloria 已提交
2147 2148 2149 2150 2151 2152
**Parameters**

| Name     | Type                                             | Mandatory| Description                            |
| -------- | ------------------------------------------------- | ---- | ------------------------------ |
| vsMode   | [VideoStabilizationMode](#videostabilizationmode) | Yes  | Video stabilization mode.                   |

2153 2154
**Return value**

G
Gloria 已提交
2155 2156 2157
| Type       | Description                         |
| ---------- | ----------------------------- |
| 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.|
2158

G
Gloria 已提交
2159 2160 2161 2162 2163 2164 2165 2166
**Error codes**

For details about the error codes, see [CameraErrorCode](#cameraerrorcode).

| ID        | Error Message       |
| --------------- | --------------- |
| 7400103                |  Session not config.                                   |

2167 2168 2169
**Example**

```js
G
Gloria 已提交
2170 2171 2172 2173 2174 2175
try {
    let isSupported = captureSession.isVideoStabilizationModeSupported(camera.VideoStabilizationMode.OFF);
} catch (error) {
    // If the operation fails, error.code is returned and processed.
    console.log(error.code);
}
2176 2177
```

G
Gloria 已提交
2178
### getActiveVideoStabilizationMode
2179

G
Gloria 已提交
2180
getActiveVideoStabilizationMode(): VideoStabilizationMode
2181

G
Gloria 已提交
2182
Obtains the video stabilization mode in use.
2183 2184 2185

**System capability**: SystemCapability.Multimedia.Camera.Core

G
Gloria 已提交
2186
**Return value**
2187

G
Gloria 已提交
2188 2189 2190
| Type       | Description                         |
| ---------- | ----------------------------- |
| VideoStabilizationMode    | Video stabilization mode obtained. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
2191

G
Gloria 已提交
2192 2193 2194 2195 2196 2197 2198 2199
**Error codes**

For details about the error codes, see [CameraErrorCode](#cameraerrorcode).

| ID        | Error Message       |
| --------------- | --------------- |
| 7400103                |  Session not config.                                   |

2200 2201 2202
**Example**

```js
G
Gloria 已提交
2203 2204 2205 2206 2207 2208
try {
    let vsMode = captureSession.getActiveVideoStabilizationMode();
} catch (error) {
    // If the operation fails, error.code is returned and processed.
    console.log(error.code);
}
2209 2210 2211 2212
```

### setVideoStabilizationMode

G
Gloria 已提交
2213
setVideoStabilizationMode(mode: VideoStabilizationMode): void
2214

G
Gloria 已提交
2215
Sets a video stabilization mode for the device.
2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226

**System capability**: SystemCapability.Multimedia.Camera.Core

**Parameters**

| Name     | Type                                             | Mandatory| Description                   |
| -------- | ------------------------------------------------- | ---- | --------------------- |
| mode     | [VideoStabilizationMode](#videostabilizationmode) | Yes  | Video stabilization mode.  |

**Return value**

G
Gloria 已提交
2227 2228 2229
| Type       | Description                         |
| ---------- | ----------------------------- |
| [CameraErrorCode](#cameraerrorcode)    | If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
2230

G
Gloria 已提交
2231 2232 2233 2234 2235 2236 2237 2238
**Error codes**

For details about the error codes, see [CameraErrorCode](#cameraerrorcode).

| ID        | Error Message       |
| --------------- | --------------- |
| 7400103                |  Session not config.                                   |

2239 2240 2241
**Example**

```js
G
Gloria 已提交
2242 2243 2244 2245 2246 2247
try {
    captureSession.setVideoStabilizationMode(camera.VideoStabilizationMode.OFF);
} catch (error) {
    // If the operation fails, error.code is returned and processed.
    console.log(error.code);
}
2248 2249 2250 2251
```

### on('focusStateChange')

G
Gloria 已提交
2252
on(type: 'focusStateChange', callback: AsyncCallback\<FocusState\>): void
2253 2254 2255 2256 2257 2258 2259 2260 2261

Listens for focus state changes. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Multimedia.Camera.Core

**Parameters**

| Name    | Type                                     | Mandatory| Description                      |
| -------- | ----------------------------------------- | ---- | ------------------------ |
G
Gloria 已提交
2262
| 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.|
G
Gloria 已提交
2263
| callback | AsyncCallback\<[FocusState](#focusstate)\> | Yes  | Callback used to return the focus state change. |
2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274

**Example**

```js
captureSession.on('focusStateChange', (focusState) => {
    console.log(`Focus state  : ${focusState}`);
})
```

### on('error')

G
Gloria 已提交
2275
on(type: 'error', callback: ErrorCallback\<BusinessError\>): void
2276 2277 2278 2279 2280 2281 2282 2283 2284

Listens for **CaptureSession** errors. This API uses a callback to return the errors.

**System capability**: SystemCapability.Multimedia.Camera.Core

**Parameters**

| Name    | Type                                                         | Mandatory| Description                          |
| -------- | ----------------------------------------------------------- | ---- | ------------------------------ |
G
Gloria 已提交
2285
| 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**.|
G
Gloria 已提交
2286
| callback | ErrorCallback\<BusinessError\> | Yes  | Callback used to return an error code defined in [CameraErrorCode](#cameraerrorcode).       |
2287 2288 2289 2290

**Example**

```js
G
Gloria 已提交
2291 2292
captureSession.on('error', (error) => {
    console.log(`Capture session error code: ${error.code}`);
2293 2294 2295 2296 2297 2298 2299
})
```

## CameraOutput

Implements output information used in a **[CaptureSession](#capturesession)**. It is the base class of **output**.

2300
## PreviewOutput
2301

2302
Implements preview output. It inherits **[CameraOutput](#cameraoutput)**.
2303

2304 2305
### start

G
Gloria 已提交
2306
start(callback: AsyncCallback\<void\>): void
2307 2308

Starts to output preview streams. This API uses an asynchronous callback to return the result.
2309 2310 2311 2312 2313 2314

**System capability**: SystemCapability.Multimedia.Camera.Core

**Parameters**

| Name     | Type                 | Mandatory| Description                |
2315
| -------- | -------------------- | ---- | -------------------- |
G
Gloria 已提交
2316
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
2317

G
Gloria 已提交
2318 2319 2320 2321 2322 2323 2324 2325
**Error codes**

For details about the error codes, see [CameraErrorCode](#cameraerrorcode).

| ID        | Error Message       |
| --------------- | --------------- |
| 7400103                |  Session not config.                                   |

2326 2327 2328
**Example**

```js
2329
previewOutput.start((err) => {
2330
    if (err) {
G
Gloria 已提交
2331
        console.error(`Failed to start the previewOutput. ${err.code}`);
2332 2333
        return;
    }
2334 2335
    console.log('Callback returned with previewOutput started.');
})
2336 2337
```

2338
### start
2339

G
Gloria 已提交
2340
start(): Promise\<void\>
2341

2342
Starts to output preview streams. This API uses a promise to return the result.
2343 2344

**System capability**: SystemCapability.Multimedia.Camera.Core
2345

W
wusongqing 已提交
2346
**Return value**
N
nikhilraut 已提交
2347

2348 2349
| Type           | Description                    |
| -------------- | ----------------------- |
G
Gloria 已提交
2350
| Promise\<void\> | Promise used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
N
nikhilraut 已提交
2351

G
Gloria 已提交
2352 2353 2354 2355 2356 2357 2358 2359
**Error codes**

For details about the error codes, see [CameraErrorCode](#cameraerrorcode).

| ID        | Error Message       |
| --------------- | --------------- |
| 7400103                |  Session not config.                                   |

N
nikhilraut 已提交
2360 2361
**Example**

W
wusongqing 已提交
2362
```js
2363 2364
previewOutput.start().then(() => {
    console.log('Promise returned with previewOutput started.');
G
Gloria 已提交
2365 2366 2367
}).catch((err) => {
    console.log('Failed to previewOutput start '+ err.code);
});
N
nikhilraut 已提交
2368 2369
```

2370
### stop
N
nikhilraut 已提交
2371

G
Gloria 已提交
2372
stop(callback: AsyncCallback\<void\>): void
N
nikhilraut 已提交
2373

2374
Stops outputting preview streams. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
2375

W
wusongqing 已提交
2376
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
2377 2378 2379

**Parameters**

2380 2381
| Name     | Type                 | Mandatory| Description                |
| -------- | -------------------- | ---- | -------------------- |
G
Gloria 已提交
2382
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
N
nikhilraut 已提交
2383 2384 2385

**Example**

W
wusongqing 已提交
2386
```js
2387
previewOutput.stop((err) => {
N
nikhilraut 已提交
2388
    if (err) {
G
Gloria 已提交
2389
        console.error(`Failed to stop the previewOutput. ${err.code}`);
N
nikhilraut 已提交
2390 2391
        return;
    }
2392
    console.log('Callback returned with previewOutput stopped.');
2393
})
N
nikhilraut 已提交
2394 2395
```

2396
### stop
N
nikhilraut 已提交
2397

G
Gloria 已提交
2398
stop(): Promise\<void\>
N
nikhilraut 已提交
2399

2400
Stops outputting preview streams. This API uses a promise to return the result.
N
nikhilraut 已提交
2401

W
wusongqing 已提交
2402
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
2403

W
wusongqing 已提交
2404
**Return value**
N
nikhilraut 已提交
2405

2406
| Type           | Description                    |
2407
| -------------- | ------------------------ |
G
Gloria 已提交
2408
| Promise\<void\> | Promise used to return the result.|
N
nikhilraut 已提交
2409 2410 2411

**Example**

W
wusongqing 已提交
2412
```js
2413 2414
previewOutput.stop().then(() => {
    console.log('Callback returned with previewOutput stopped.');
G
Gloria 已提交
2415 2416 2417
}).catch((err) => {
    console.log('Failed to previewOutput stop '+ err.code);
});
N
nikhilraut 已提交
2418 2419
```

2420
### release
N
nikhilraut 已提交
2421

G
Gloria 已提交
2422
release(callback: AsyncCallback\<void\>): void
N
nikhilraut 已提交
2423

2424
Releases output resources. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
2425

W
wusongqing 已提交
2426
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
2427 2428 2429

**Parameters**

2430
| Name     | Type                 | Mandatory| Description                |
2431
| -------- | -------------------- | ---- | ------------------- |
G
Gloria 已提交
2432
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
N
nikhilraut 已提交
2433

G
Gloria 已提交
2434 2435 2436 2437 2438 2439 2440 2441
**Error codes**

For details about the error codes, see [CameraErrorCode](#cameraerrorcode).

| ID        | Error Message       |
| --------------- | --------------- |
| 7400201                |  Camera service fatal error.                           |

N
nikhilraut 已提交
2442 2443
**Example**

W
wusongqing 已提交
2444
```js
2445
previewOutput.release((err) => {
N
nikhilraut 已提交
2446
    if (err) {
G
Gloria 已提交
2447
        console.error(`Failed to release the PreviewOutput instance ${err.code}`);
N
nikhilraut 已提交
2448 2449
        return;
    }
2450 2451
    console.log('Callback invoked to indicate that the PreviewOutput instance is released successfully.');
});
W
wusongqing 已提交
2452
```
N
nikhilraut 已提交
2453

2454
### release
N
nikhilraut 已提交
2455

G
Gloria 已提交
2456
release(): Promise\<void\>
N
nikhilraut 已提交
2457

2458
Releases output resources. This API uses a promise to return the result.
N
nikhilraut 已提交
2459

W
wusongqing 已提交
2460
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
2461

W
wusongqing 已提交
2462
**Return value**
N
nikhilraut 已提交
2463

2464
| Type           | Description                    |
2465
| -------------- | ----------------------- |
G
Gloria 已提交
2466
| Promise\<void\> | Promise used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
N
nikhilraut 已提交
2467

G
Gloria 已提交
2468 2469 2470 2471 2472 2473 2474 2475
**Error codes**

For details about the error codes, see [CameraErrorCode](#cameraerrorcode).

| ID        | Error Message       |
| --------------- | --------------- |
| 7400201                |  Camera service fatal error.                           |

N
nikhilraut 已提交
2476 2477
**Example**

W
wusongqing 已提交
2478
```js
2479 2480
previewOutput.release().then(() => {
    console.log('Promise returned to indicate that the PreviewOutput instance is released successfully.');
G
Gloria 已提交
2481 2482 2483
}).catch((err) => {
    console.log('Failed to previewOutput release '+ err.code);
});
N
nikhilraut 已提交
2484 2485
```

2486
### on('frameStart')
N
nikhilraut 已提交
2487

G
Gloria 已提交
2488
on(type: 'frameStart', callback: AsyncCallback\<void\>): void
N
nikhilraut 已提交
2489

2490
Listens for preview frame start events. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
2491

W
wusongqing 已提交
2492
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
2493 2494 2495

**Parameters**

2496 2497
| Name     | Type                 | Mandatory| Description                                    |
| -------- | -------------------- | ---- | --------------------------------------- |
G
Gloria 已提交
2498
| 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.|
G
Gloria 已提交
2499
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result. The preview starts as long as this event is returned.                    |
N
nikhilraut 已提交
2500 2501 2502

**Example**

W
wusongqing 已提交
2503
```js
2504 2505 2506
previewOutput.on('frameStart', () => {
    console.log('Preview frame started');
})
N
nikhilraut 已提交
2507 2508
```

2509
### on('frameEnd')
N
nikhilraut 已提交
2510

G
Gloria 已提交
2511
on(type: 'frameEnd', callback: AsyncCallback\<void\>): void
N
nikhilraut 已提交
2512

2513
Listens for preview frame end events. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
2514

W
wusongqing 已提交
2515
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
2516

2517
**Parameters**
N
nikhilraut 已提交
2518

2519 2520
| Name     | Type                 | Mandatory| Description                                 |
| -------- | -------------------- | ---- | ------------------------------------- |
G
Gloria 已提交
2521
| 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.|
G
Gloria 已提交
2522
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result. The preview ends as long as this event is returned.                |
N
nikhilraut 已提交
2523 2524 2525

**Example**

W
wusongqing 已提交
2526
```js
2527 2528
previewOutput.on('frameEnd', () => {
    console.log('Preview frame ended');
N
nikhilraut 已提交
2529 2530 2531
})
```

2532
### on('error')
W
wusongqing 已提交
2533

G
Gloria 已提交
2534
on(type: 'error', callback: ErrorCallback\<BusinessError\>): void
W
wusongqing 已提交
2535

2536
Listens for **PreviewOutput** errors. This API uses a callback to return the errors.
W
wusongqing 已提交
2537 2538 2539 2540 2541

**System capability**: SystemCapability.Multimedia.Camera.Core

**Parameters**

G
Gloria 已提交
2542 2543 2544
| Name    | Type        | Mandatory| Description                      |
| -------- | --------------| ---- | ------------------------ |
| 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()**.|
G
Gloria 已提交
2545
| callback | ErrorCallback\<BusinessError\> | Yes  | Callback used to return an error code defined in [CameraErrorCode](#cameraerrorcode). |
W
wusongqing 已提交
2546 2547 2548 2549

**Example**

```js
2550 2551
previewOutput.on('error', (previewOutputError) => {
    console.log(`Preview output error code: ${previewOutputError.code}`);
W
wusongqing 已提交
2552 2553 2554
})
```

2555
## ImageRotation
W
wusongqing 已提交
2556

2557
Enumerates the image rotation angles.
2558

2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570
**System capability**: SystemCapability.Multimedia.Camera.Core

| Name         | Value  | Description          |
| ------------ | ---- | ------------- |
| ROTATION_0   | 0    | The image rotates 0 degrees.  |
| ROTATION_90  | 90   | The image rotates 90 degrees. |
| ROTATION_180 | 180  | The image rotates 180 degrees.|
| ROTATION_270 | 270  | The image rotates 270 degrees.|

## Location

Defines geolocation information.
W
wusongqing 已提交
2571 2572 2573

**System capability**: SystemCapability.Multimedia.Camera.Core

2574 2575 2576 2577 2578
| Name         | Type  | Mandatory|Description        |
| ------------ | ------ | --- |------------ |
| latitude     | number | Yes |Latitude, in degrees.   |
| longitude    | number | Yes |Longitude, in degrees.   |
| altitude     | number | Yes |Altitude, in meters.   |
W
wusongqing 已提交
2579

2580
## QualityLevel
W
wusongqing 已提交
2581

2582
Enumerates the image quality levels.
W
wusongqing 已提交
2583

2584 2585 2586 2587 2588 2589 2590
**System capability**: SystemCapability.Multimedia.Camera.Core

| Name                 | Value  | Description        |
| -------------------- | ---- | ------------ |
| QUALITY_LEVEL_HIGH   | 0    | High image quality.  |
| QUALITY_LEVEL_MEDIUM | 1    | Medium image quality.|
| QUALITY_LEVEL_LOW    | 2    | Low image quality.  |
W
wusongqing 已提交
2591 2592


2593
## PhotoCaptureSetting
W
wusongqing 已提交
2594

2595
Defines the settings for photo capture.
W
wusongqing 已提交
2596 2597 2598

**System capability**: SystemCapability.Multimedia.Camera.Core

2599 2600 2601 2602 2603 2604
| Name     | Type                           | Mandatory | Description             |
| -------- | ------------------------------- | ---- | -----------------|
| quality  | [QualityLevel](#qualitylevel)   | No  | Photo quality.        |
| rotation | [ImageRotation](#imagerotation) | No  | Rotation angle of the photo.     |
| location | [Location](#location)           | No  | Geolocation information of the photo.  |
| mirror   | boolean                         | No  |Whether mirroring is enabled. By default, mirroring is disabled.|
2605 2606

## PhotoOutput
W
wusongqing 已提交
2607

2608
Implements output information used in a shooting session. This class inherits from [CameraOutput](#cameraoutput).
W
wusongqing 已提交
2609

2610 2611
### capture

G
Gloria 已提交
2612
capture(callback: AsyncCallback\<void\>): void
2613 2614 2615 2616

Captures a photo with the default shooting parameters. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Multimedia.Camera.Core
W
wusongqing 已提交
2617

2618 2619 2620 2621
**Parameters**

| Name     | Type                 | Mandatory| Description                |
| -------- | -------------------- | ---- | ------------------- |
G
Gloria 已提交
2622
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
W
wusongqing 已提交
2623

G
Gloria 已提交
2624 2625 2626 2627 2628 2629 2630 2631 2632
**Error codes**

For details about the error codes, see [CameraErrorCode](#cameraerrorcode).

| ID        | Error Message       |
| --------------- | --------------- |
| 7400104                |  Session not running.                                  |
| 7400201                |  Camera service fatal error.                           |

W
wusongqing 已提交
2633 2634 2635
**Example**

```js
2636 2637
photoOutput.capture((err) => {
    if (err) {
G
Gloria 已提交
2638
        console.error(`Failed to capture the photo ${err.code}`);
2639 2640 2641 2642
        return;
    }
    console.log('Callback invoked to indicate the photo capture request success.');
});
W
wusongqing 已提交
2643 2644
```

2645
### capture
W
wusongqing 已提交
2646

G
Gloria 已提交
2647
capture(): Promise\<void\>
G
Gloria 已提交
2648 2649 2650 2651 2652 2653 2654 2655 2656

Captures a photo with the default shooting parameters. This API uses a promise to return the result.

**System capability**: SystemCapability.Multimedia.Camera.Core

**Return value**

| Type           | Description                    |
| -------------- | ------------------------ |
G
Gloria 已提交
2657
| Promise\<void\> | Promise used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
G
Gloria 已提交
2658

G
Gloria 已提交
2659 2660 2661 2662 2663 2664 2665 2666 2667
**Error codes**

For details about the error codes, see [CameraErrorCode](#cameraerrorcode).

| ID        | Error Message       |
| --------------- | --------------- |
| 7400104                |  Session not running.                                  |
| 7400201                |  Camera service fatal error.                           |

G
Gloria 已提交
2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679
**Example**

```js
photoOutput.capture().then(() => {
    console.log('Promise returned to indicate that photo capture request success.');
}).catch((err) => {
    console.log('Failed to photoOutput capture '+ err.code);
});
```

### capture

G
Gloria 已提交
2680
capture(setting: PhotoCaptureSetting, callback: AsyncCallback\<void\>): void
W
wusongqing 已提交
2681

2682
Captures a photo with the specified shooting parameters. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
2683 2684 2685 2686 2687

**System capability**: SystemCapability.Multimedia.Camera.Core

**Parameters**

2688 2689 2690
| Name     | Type                                        | Mandatory| Description                 |
| -------- | ------------------------------------------- | ---- | -------------------- |
| setting  | [PhotoCaptureSetting](#photocapturesetting) | Yes  | Shooting settings.            |
G
Gloria 已提交
2691
| callback | AsyncCallback\<void\>                        | Yes  | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned. |
W
wusongqing 已提交
2692

G
Gloria 已提交
2693 2694 2695 2696 2697 2698 2699 2700 2701 2702
**Error codes**

For details about the error codes, see [CameraErrorCode](#cameraerrorcode).

| ID        | Error Message       |
| --------------- | --------------- |
| 7400101                |  Parameter missing or parameter type incorrect        |
| 7400104                |  Session not running.                                  |
| 7400201                |  Camera service fatal error.                           |

W
wusongqing 已提交
2703 2704 2705
**Example**

```js
2706 2707 2708 2709 2710 2711 2712 2713 2714 2715
let captureLocation = {
  latitude: 0,
  longitude: 0,
  altitude: 0,
}
let settings = {
  quality: camera.QualityLevel.QUALITY_LEVEL_LOW,
  rotation: camera.ImageRotation.ROTATION_0,
  location: captureLocation,
  mirror: false
2716 2717
}
photoOutput.capture(settings, (err) => {
W
wusongqing 已提交
2718
    if (err) {
G
Gloria 已提交
2719
        console.error(`Failed to capture the photo ${err.code}`);
W
wusongqing 已提交
2720 2721
        return;
    }
2722
    console.log('Callback invoked to indicate the photo capture request success.');
2723
});
W
wusongqing 已提交
2724 2725
```

2726
### capture
W
wusongqing 已提交
2727

G
Gloria 已提交
2728
capture(setting?: PhotoCaptureSetting): Promise\<void\>
W
wusongqing 已提交
2729

2730
Captures a photo with the specified shooting parameters. This API uses a promise to return the result.
W
wusongqing 已提交
2731 2732 2733

**System capability**: SystemCapability.Multimedia.Camera.Core

2734 2735 2736 2737
**Parameters**

| Name    | Type                                        | Mandatory| Description     |
| ------- | ------------------------------------------- | ---- | -------- |
2738
| setting | [PhotoCaptureSetting](#photocapturesetting) | No  | Shooting parameters. The input of **undefined** is processed as if no parameters were passed.|
2739

W
wusongqing 已提交
2740 2741
**Return value**

2742 2743
| Type           | Description                    |
| -------------- | ------------------------ |
G
Gloria 已提交
2744
| Promise\<void\> | Promise used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
W
wusongqing 已提交
2745

G
Gloria 已提交
2746 2747 2748 2749 2750 2751 2752 2753 2754
**Error codes**

For details about the error codes, see [CameraErrorCode](#cameraerrorcode).

| ID        | Error Message       |
| --------------- | --------------- |
| 7400101                |  Parameter missing or parameter type incorrect        |
| 7400104                |  Session not running.                                  |
| 7400201                |  Camera service fatal error.                           |
2755

W
wusongqing 已提交
2756 2757 2758
**Example**

```js
G
Gloria 已提交
2759
photoOutput.capture(settings).then(() => {
2760
    console.log('Promise returned to indicate that photo capture request success.');
G
Gloria 已提交
2761 2762 2763
}).catch((err) => {
    console.log('Failed to photoOutput capture '+ err.code);
});
W
wusongqing 已提交
2764 2765
```

2766
### isMirrorSupported
W
wusongqing 已提交
2767

G
Gloria 已提交
2768
isMirrorSupported(): boolean
W
wusongqing 已提交
2769

G
Gloria 已提交
2770
Checks whether mirroring is supported.
W
wusongqing 已提交
2771 2772 2773

**System capability**: SystemCapability.Multimedia.Camera.Core

G
Gloria 已提交
2774
**Return value**
W
wusongqing 已提交
2775

G
Gloria 已提交
2776 2777 2778
| Type           | Description                    |
| -------------- | ----------------------- |
| boolean | Returns **true** if mirroring is supported; returns **false** otherwise.|
W
wusongqing 已提交
2779 2780 2781 2782

**Example**

```js
G
Gloria 已提交
2783
let isSupported = photoOutput.isMirrorSupported();
W
wusongqing 已提交
2784 2785
```

2786 2787
### release

G
Gloria 已提交
2788
release(callback: AsyncCallback\<void\>): void
2789 2790 2791 2792 2793 2794 2795 2796 2797

Releases output resources. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Multimedia.Camera.Core

**Parameters**

| Name     | Type                 | Mandatory| Description                |
| -------- | -------------------- | ---- | ------------------- |
G
Gloria 已提交
2798
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
2799

G
Gloria 已提交
2800 2801 2802 2803 2804 2805 2806 2807
**Error codes**

For details about the error codes, see [CameraErrorCode](#cameraerrorcode).

| ID        | Error Message       |
| --------------- | --------------- |
| 7400201                |  Camera service fatal error.                           |

2808 2809 2810 2811 2812
**Example**

```js
photoOutput.release((err) => {
    if (err) {
G
Gloria 已提交
2813
        console.error(`Failed to release the PreviewOutput instance ${err.code}`);
2814 2815 2816 2817 2818 2819 2820 2821
        return;
    }
    console.log('Callback invoked to indicate that the PreviewOutput instance is released successfully.');
});
```

### release

G
Gloria 已提交
2822
release(): Promise\<void\>
2823 2824 2825 2826 2827 2828 2829 2830 2831

Releases output resources. This API uses a promise to return the result.

**System capability**: SystemCapability.Multimedia.Camera.Core

**Return value**

| Type           | Description                    |
| -------------- | ----------------------- |
G
Gloria 已提交
2832
| Promise\<void\> | Promise used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
2833

G
Gloria 已提交
2834 2835 2836 2837 2838 2839 2840 2841
**Error codes**

For details about the error codes, see [CameraErrorCode](#cameraerrorcode).

| ID        | Error Message       |
| --------------- | --------------- |
| 7400201                |  Camera service fatal error.                           |

2842 2843 2844 2845 2846
**Example**

```js
photoOutput.release().then(() => {
    console.log('Promise returned to indicate that the PreviewOutput instance is released successfully.');
G
Gloria 已提交
2847 2848 2849
}).catch((err) => {
    console.log('Failed to photoOutput release '+ err.code);
});
W
wusongqing 已提交
2850 2851
```

2852
### on('captureStart')
W
wusongqing 已提交
2853

G
Gloria 已提交
2854
on(type: 'captureStart', callback: AsyncCallback\<number\>): void
W
wusongqing 已提交
2855

2856
Listens for shooting start events. This API uses an asynchronous callback to return the capture ID.
W
wusongqing 已提交
2857 2858 2859 2860 2861

**System capability**: SystemCapability.Multimedia.Camera.Core

**Parameters**

2862 2863
| Name     | Type                   | Mandatory| Description                                      |
| -------- | ---------------------- | ---- | ------------------------------------------ |
G
Gloria 已提交
2864
| 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.|
G
Gloria 已提交
2865
| callback | AsyncCallback\<number\> | Yes  | Callback used to return the capture ID.           |
W
wusongqing 已提交
2866 2867 2868 2869

**Example**

```js
G
Gloria 已提交
2870
photoOutput.on('captureStart', (captureId) => {
2871
    console.log(`photo capture stated, captureId : ${captureId}`);
W
wusongqing 已提交
2872 2873 2874
})
```

2875
### on('frameShutter')
W
wusongqing 已提交
2876

G
Gloria 已提交
2877
on(type: 'frameShutter', callback: AsyncCallback\<FrameShutterInfo\>): void
W
wusongqing 已提交
2878

2879
Listens for frame shutter events. This API uses an asynchronous callback to return the event information.
W
wusongqing 已提交
2880

2881
**System capability**: SystemCapability.Multimedia.Camera.Core
W
wusongqing 已提交
2882

2883
**Parameters**
W
wusongqing 已提交
2884

G
Gloria 已提交
2885 2886 2887
| Name    | Type     | Mandatory| Description                                 |
| -------- | ---------- | --- | ------------------------------------ |
| type     | string     | Yes  | Event type. The value is fixed at **'frameShutter'**. The event can be listened for when a **photoOutput** instance is created.|
G
Gloria 已提交
2888
| 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.            |
W
wusongqing 已提交
2889

2890
**Example**
W
wusongqing 已提交
2891

2892
```js
G
Gloria 已提交
2893
photoOutput.on('frameShutter', (frameShutterInfo) => {
2894 2895 2896 2897
    console.log(`photo capture end, captureId : ${frameShutterInfo.captureId}`);
    console.log(`Timestamp for frame : ${frameShutterInfo.timestamp}`);
})
```
W
wusongqing 已提交
2898

2899
### on('captureEnd')
W
wusongqing 已提交
2900

G
Gloria 已提交
2901
on(type: 'captureEnd', callback: AsyncCallback\<CaptureEndInfo\>): void
W
wusongqing 已提交
2902

2903
Listens for shooting end events. This API uses an asynchronous callback to return the event information.
W
wusongqing 已提交
2904 2905 2906 2907 2908

**System capability**: SystemCapability.Multimedia.Camera.Core

**Parameters**

G
Gloria 已提交
2909 2910 2911
| Name    | Type          | Mandatory| Description                                      |
| -------- | --------------- | ---- | ---------------------------------------- |
| 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.|
G
Gloria 已提交
2912
| callback | AsyncCallback\<[CaptureEndInfo](#captureendinfo)\> | Yes  | Callback used to return the result.                 |
W
wusongqing 已提交
2913 2914 2915 2916

**Example**

```js
G
Gloria 已提交
2917
photoOutput.on('captureEnd', (captureEndInfo) => {
2918 2919 2920
    console.log(`photo capture end, captureId : ${captureEndInfo.captureId}`);
    console.log(`frameCount : ${captureEndInfo.frameCount}`);
})
W
wusongqing 已提交
2921 2922
```

2923
### on('error')
W
wusongqing 已提交
2924

G
Gloria 已提交
2925
on(type: 'error', callback: ErrorCallback\<BusinessError\>): void
W
wusongqing 已提交
2926

2927
Listens for **PhotoOutput** errors. This API uses a callback to return the errors.
W
wusongqing 已提交
2928 2929 2930

**System capability**: SystemCapability.Multimedia.Camera.Core

2931 2932
**Parameters**

G
Gloria 已提交
2933 2934 2935
| Name    | Type        | Mandatory| Description                                |
| -------- | ------------- | ---- | ----------------------------------- |
| 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.|
G
Gloria 已提交
2936
| callback | ErrorCallback\<BusinessError\> | Yes  | Callback used to return an error code defined in [CameraErrorCode](#cameraerrorcode).            |
2937

W
wusongqing 已提交
2938 2939 2940
**Example**

```js
G
Gloria 已提交
2941 2942
photoOutput.on('error', (error) => {
    console.log(`Photo output error code: ${error.code}`);
W
wusongqing 已提交
2943 2944 2945
})
```

2946
## FrameShutterInfo
2947

2948
Defines the frame shutter information.
W
wusongqing 已提交
2949 2950

**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
2951

2952 2953 2954 2955
| Name     | Type  | Mandatory| Description        |
| --------- | ------ | ---- | ---------- |
| captureId | number | Yes  | ID of this capture action. |
| timestamp | number | Yes  | Timestamp when the frame shutter event is triggered.|
N
nikhilraut 已提交
2956

2957
## CaptureEndInfo
2958

2959
Defines the capture end information.
N
nikhilraut 已提交
2960

W
wusongqing 已提交
2961
**System capability**: SystemCapability.Multimedia.Camera.Core
2962

2963 2964 2965 2966
| Name      | Type  | Mandatory| Description      |
| ---------- | ------ | ---- | ---------|
| captureId  | number | Yes  | ID of this capture action.|
| frameCount | number | Yes  | Number of frames captured.   |
N
nikhilraut 已提交
2967

2968
## VideoOutput
N
nikhilraut 已提交
2969

2970
Implements output information used in a video recording session. This class inherits from [CameraOutput](#cameraoutput).
N
nikhilraut 已提交
2971

2972
### start
N
nikhilraut 已提交
2973

G
Gloria 已提交
2974
start(callback: AsyncCallback\<void\>): void
2975

2976
Starts video recording. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
2977

W
wusongqing 已提交
2978
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
2979 2980 2981

**Parameters**

2982 2983
| Name     | Type                 | Mandatory| Description                |
| -------- | -------------------- | ---- | -------------------- |
G
Gloria 已提交
2984
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
N
nikhilraut 已提交
2985

G
Gloria 已提交
2986 2987 2988 2989 2990 2991 2992 2993 2994
**Error codes**

For details about the error codes, see [CameraErrorCode](#cameraerrorcode).

| ID        | Error Message       |
| --------------- | --------------- |
| 7400103                |  Session not config.                                   |
| 7400201                |  Camera service fatal error.                           |

N
nikhilraut 已提交
2995 2996
**Example**

W
wusongqing 已提交
2997
```js
2998
videoOutput.start((err) => {
N
nikhilraut 已提交
2999
    if (err) {
G
Gloria 已提交
3000
        console.error(`Failed to start the video output ${err.code}`);
N
nikhilraut 已提交
3001 3002
        return;
    }
3003
    console.log('Callback invoked to indicate the video output start success.');
N
nikhilraut 已提交
3004 3005 3006
});
```

3007
### start
N
nikhilraut 已提交
3008

G
Gloria 已提交
3009
start(): Promise\<void\>
N
nikhilraut 已提交
3010

3011
Starts video recording. This API uses a promise to return the result.
N
nikhilraut 已提交
3012

W
wusongqing 已提交
3013
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
3014

W
wusongqing 已提交
3015
**Return value**
N
nikhilraut 已提交
3016

3017 3018
| Type           | Description                    |
| -------------- | ----------------------- |
G
Gloria 已提交
3019
| Promise\<void\> | Promise used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
N
nikhilraut 已提交
3020

G
Gloria 已提交
3021 3022 3023 3024 3025 3026 3027 3028
**Error codes**

For details about the error codes, see [CameraErrorCode](#cameraerrorcode).

| ID        | Error Message       |
| --------------- | --------------- |
| 7400103                |  Session not config.                                   |
| 7400201                |  Camera service fatal error.                           |
N
nikhilraut 已提交
3029 3030 3031

**Example**

W
wusongqing 已提交
3032
```js
3033 3034
videoOutput.start().then(() => {
    console.log('Promise returned to indicate that start method execution success.');
G
Gloria 已提交
3035 3036 3037
}).catch((err) => {
    console.log('Failed to videoOutput start '+ err.code);
});
N
nikhilraut 已提交
3038 3039
```

3040
### stop
N
nikhilraut 已提交
3041

G
Gloria 已提交
3042
stop(callback: AsyncCallback\<void\>): void
N
nikhilraut 已提交
3043

3044
Stops video recording. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
3045

W
wusongqing 已提交
3046
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
3047 3048 3049

**Parameters**

W
wusongqing 已提交
3050 3051
| Name    | Type                | Mandatory| Description                    |
| -------- | -------------------- | ---- | ------------------------ |
G
Gloria 已提交
3052
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
N
nikhilraut 已提交
3053 3054 3055

**Example**

W
wusongqing 已提交
3056
```js
3057
videoOutput.stop((err) => {
N
nikhilraut 已提交
3058
    if (err) {
G
Gloria 已提交
3059
        console.error(`Failed to stop the video output ${err.code}`);
N
nikhilraut 已提交
3060 3061
        return;
    }
3062
    console.log('Callback invoked to indicate the video output stop success.');
N
nikhilraut 已提交
3063 3064 3065
});
```

3066
### stop
N
nikhilraut 已提交
3067

G
Gloria 已提交
3068
stop(): Promise\<void\>
N
nikhilraut 已提交
3069

3070
Stops video recording. This API uses a promise to return the result.
N
nikhilraut 已提交
3071

W
wusongqing 已提交
3072
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
3073

W
wusongqing 已提交
3074
**Return value**
N
nikhilraut 已提交
3075

3076 3077
| Type           | Description                    |
| -------------- | ----------------------- |
G
Gloria 已提交
3078
| Promise\<void\> | Promise used to return the result.|
N
nikhilraut 已提交
3079 3080 3081

**Example**

W
wusongqing 已提交
3082
```js
3083 3084
videoOutput.stop().then(() => {
    console.log('Promise returned to indicate that stop method execution success.');
G
Gloria 已提交
3085 3086 3087 3088
}).catch((err) => {
    console.log('Failed to videoOutput stop '+ err.code);
});
```
N
nikhilraut 已提交
3089

3090 3091
### release

G
Gloria 已提交
3092
release(callback: AsyncCallback\<void\>): void
3093 3094 3095 3096 3097 3098 3099 3100 3101

Releases output resources. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Multimedia.Camera.Core

**Parameters**

| Name     | Type                 | Mandatory| Description                |
| -------- | -------------------- | ---- | ------------------- |
G
Gloria 已提交
3102
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
3103

G
Gloria 已提交
3104 3105 3106 3107 3108 3109 3110 3111
**Error codes**

For details about the error codes, see [CameraErrorCode](#cameraerrorcode).

| ID        | Error Message       |
| --------------- | --------------- |
| 7400201                |  Camera service fatal error.                           |

3112 3113 3114 3115 3116
**Example**

```js
videoOutput.release((err) => {
    if (err) {
G
Gloria 已提交
3117
        console.error(`Failed to release the PreviewOutput instance ${err.code}`);
3118 3119 3120 3121 3122 3123 3124 3125
        return;
    }
    console.log('Callback invoked to indicate that the PreviewOutput instance is released successfully.');
});
```

### release

G
Gloria 已提交
3126
release(): Promise\<void\>
3127 3128 3129 3130 3131 3132 3133 3134 3135

Releases output resources. This API uses a promise to return the result.

**System capability**: SystemCapability.Multimedia.Camera.Core

**Return value**

| Type           | Description                    |
| -------------- | ----------------------- |
G
Gloria 已提交
3136
| Promise\<void\> | Promise used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
3137

G
Gloria 已提交
3138 3139 3140 3141 3142 3143 3144 3145
**Error codes**

For details about the error codes, see [CameraErrorCode](#cameraerrorcode).

| ID        | Error Message       |
| --------------- | --------------- |
| 7400201                |  Camera service fatal error.                           |

3146 3147 3148 3149 3150
**Example**

```js
videoOutput.release().then(() => {
    console.log('Promise returned to indicate that the PreviewOutput instance is released successfully.');
G
Gloria 已提交
3151 3152 3153
}).catch((err) => {
    console.log('Failed to videoOutput release '+ err.code);
});
3154 3155
```

3156
### on('frameStart')
N
nikhilraut 已提交
3157

G
Gloria 已提交
3158
on(type: 'frameStart', callback: AsyncCallback\<void\>): void
N
nikhilraut 已提交
3159

3160
Listens for video recording start events. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
3161

W
wusongqing 已提交
3162
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
3163 3164 3165

**Parameters**

3166 3167
| Name     | Type                 | Mandatory| Description                                      |
| -------- | -------------------- | ---- | ----------------------------------------- |
G
Gloria 已提交
3168
| 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.|
G
Gloria 已提交
3169
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.  The recording starts as long as this event is returned.                    |
N
nikhilraut 已提交
3170 3171 3172

**Example**

W
wusongqing 已提交
3173
```js
3174 3175
videoOutput.on('frameStart', () => {
    console.log('Video frame started');
N
nikhilraut 已提交
3176 3177 3178
})
```

3179
### on('frameEnd')
N
nikhilraut 已提交
3180

G
Gloria 已提交
3181
on(type: 'frameEnd', callback: AsyncCallback\<void\>): void
N
nikhilraut 已提交
3182

3183
Listens for video recording stop events. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
3184

W
wusongqing 已提交
3185
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
3186 3187 3188

**Parameters**

3189 3190
| Name     | Type                 | Mandatory| Description                                      |
| -------- | -------------------- | ---- | ------------------------------------------ |
G
Gloria 已提交
3191
| 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.|
G
Gloria 已提交
3192
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result. The recording ends as long as this event is returned.                     |
N
nikhilraut 已提交
3193 3194 3195

**Example**

W
wusongqing 已提交
3196
```js
3197 3198
videoOutput.on('frameEnd', () => {
    console.log('Video frame ended');
N
nikhilraut 已提交
3199 3200 3201
})
```

3202
### on('error')
N
nikhilraut 已提交
3203

G
Gloria 已提交
3204
on(type: 'error', callback: ErrorCallback\<BusinessError\>): void
N
nikhilraut 已提交
3205

3206
Listens for errors that occur during video recording. This API uses a callback to return the result.
N
nikhilraut 已提交
3207

W
wusongqing 已提交
3208
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
3209 3210 3211

**Parameters**

G
Gloria 已提交
3212 3213 3214
| Name    | Type      | Mandatory| Description                                   |
| -------- | ----------- | ---- | -------------------------------------- |
| 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()**.|
G
Gloria 已提交
3215
| callback | Callback\<BusinessError\> | Yes  | Callback used to return an error code defined in [CameraErrorCode](#cameraerrorcode).                |
N
nikhilraut 已提交
3216 3217 3218

**Example**

W
wusongqing 已提交
3219
```js
G
Gloria 已提交
3220 3221
videoOutput.on('error', (error) => {
    console.log(`Video output error code: ${error.code}`);
N
nikhilraut 已提交
3222 3223 3224
})
```

3225
## MetadataOutput
3226

3227
Implements metadata streams. It inherits **[CameraOutput](#cameraoutput)**.
3228

3229
### start
N
nikhilraut 已提交
3230

G
Gloria 已提交
3231
start(callback: AsyncCallback\<void\>): void
N
nikhilraut 已提交
3232

3233
Starts to output metadata. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
3234

W
wusongqing 已提交
3235
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
3236 3237 3238

**Parameters**

3239
| Name    | Type                                                        | Mandatory| Description                |
G
Gloria 已提交
3240
| -------- | -------------------------- | ---- | ------------------- |
G
Gloria 已提交
3241
| callback | AsyncCallback\<void\>       | Yes  | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
N
nikhilraut 已提交
3242

G
Gloria 已提交
3243 3244 3245 3246 3247 3248 3249 3250 3251
**Error codes**

For details about the error codes, see [CameraErrorCode](#cameraerrorcode).

| ID        | Error Message       |
| --------------- | --------------- |
| 7400103                |  Session not config.                                   |
| 7400201                |  Camera service fatal error.                           |

N
nikhilraut 已提交
3252 3253
**Example**

W
wusongqing 已提交
3254
```js
3255
metadataOutput.start((err) => {
N
nikhilraut 已提交
3256
    if (err) {
G
Gloria 已提交
3257
        console.error(`Failed to start metadataOutput. ${err.code}`);
N
nikhilraut 已提交
3258 3259
        return;
    }
3260
    console.log('Callback returned with metadataOutput started.');
3261
})
W
wusongqing 已提交
3262
```
N
nikhilraut 已提交
3263

3264
### start
N
nikhilraut 已提交
3265

G
Gloria 已提交
3266
start(): Promise\<void\>
N
nikhilraut 已提交
3267

3268
Starts to output metadata. This API uses a promise to return the result.
N
nikhilraut 已提交
3269

W
wusongqing 已提交
3270
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
3271

W
wusongqing 已提交
3272
**Return value**
N
nikhilraut 已提交
3273

3274 3275
| Type                    | Description                    |
| ----------------------  | ------------------------ |
G
Gloria 已提交
3276
| Promise\<void\>          | Promise used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
N
nikhilraut 已提交
3277

G
Gloria 已提交
3278 3279 3280 3281 3282 3283 3284 3285 3286
**Error codes**

For details about the error codes, see [CameraErrorCode](#cameraerrorcode).

| ID        | Error Message       |
| --------------- | --------------- |
| 7400103                |  Session not config.                                   |
| 7400201                |  Camera service fatal error.                           |

N
nikhilraut 已提交
3287 3288
**Example**

W
wusongqing 已提交
3289
```js
3290 3291
metadataOutput.start().then(() => {
    console.log('Callback returned with metadataOutput started.');
G
Gloria 已提交
3292 3293 3294
}).catch((err) => {
    console.log('Failed to metadataOutput start '+ err.code);
});
N
nikhilraut 已提交
3295
```
W
wusongqing 已提交
3296

3297
### stop
N
nikhilraut 已提交
3298

G
Gloria 已提交
3299
stop(callback: AsyncCallback\<void\>): void
N
nikhilraut 已提交
3300

3301
Stops outputting metadata. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
3302

W
wusongqing 已提交
3303
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
3304 3305 3306

**Parameters**

3307 3308
| Name    | Type                        | Mandatory| Description                 |
| -------- | -------------------------- | ---- | ------------------- |
G
Gloria 已提交
3309
| callback | AsyncCallback\<void\>       | Yes  | Callback used to return the result.|
N
nikhilraut 已提交
3310 3311 3312

**Example**

W
wusongqing 已提交
3313
```js
3314
metadataOutput.stop((err) => {
N
nikhilraut 已提交
3315
    if (err) {
G
Gloria 已提交
3316
        console.error(`Failed to stop the metadataOutput. ${err.code}`);
N
nikhilraut 已提交
3317 3318
        return;
    }
3319
    console.log('Callback returned with metadataOutput stopped.');
3320
})
N
nikhilraut 已提交
3321 3322
```

3323
### stop
N
nikhilraut 已提交
3324

G
Gloria 已提交
3325
stop(): Promise\<void\>
N
nikhilraut 已提交
3326

3327
Stops outputting metadata. This API uses a promise to return the result.
N
nikhilraut 已提交
3328

W
wusongqing 已提交
3329
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
3330

W
wusongqing 已提交
3331
**Return value**
N
nikhilraut 已提交
3332

3333 3334
| Type                   | Description                       |
| ----------------------  | --------------------------- |
G
Gloria 已提交
3335
| Promise\<void\>         | Promise used to return the result.|
N
nikhilraut 已提交
3336 3337 3338

**Example**

W
wusongqing 已提交
3339
```js
3340 3341
metadataOutput.stop().then(() => {
    console.log('Callback returned with metadataOutput stopped.');
G
Gloria 已提交
3342 3343 3344
}).catch((err) => {
    console.log('Failed to metadataOutput stop '+ err.code);
});
N
nikhilraut 已提交
3345 3346
```

3347
### on('metadataObjectsAvailable')
N
nikhilraut 已提交
3348

G
Gloria 已提交
3349
on(type: 'metadataObjectsAvailable', callback: AsyncCallback\<Array\<MetadataObject\>\>): void
N
nikhilraut 已提交
3350

3351
Listens for metadata objects. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
3352

W
wusongqing 已提交
3353
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
3354 3355 3356

**Parameters**

G
Gloria 已提交
3357 3358 3359
| Name     | Type        | Mandatory| Description                                 |
| -------- | -------------- | ---- | ------------------------------------ |
| 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.|
G
Gloria 已提交
3360
| callback | Callback\<Array\<[MetadataObject](#metadataobject)\>\> | Yes  | Callback used to return the metadata.|
N
nikhilraut 已提交
3361 3362 3363

**Example**

W
wusongqing 已提交
3364
```js
3365 3366
metadataOutput.on('metadataObjectsAvailable', (metadataObjectArr) => {
    console.log(`metadata output metadataObjectsAvailable`);
3367
})
N
nikhilraut 已提交
3368 3369
```

3370
### on('error')
N
nikhilraut 已提交
3371

G
Gloria 已提交
3372
on(type: 'error', callback: ErrorCallback\<BusinessError\>): void
N
nikhilraut 已提交
3373

3374
Listens for metadata errors. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
3375

W
wusongqing 已提交
3376
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
3377

3378
**Parameters**
N
nikhilraut 已提交
3379

G
Gloria 已提交
3380 3381 3382
| Name    | Type        | Mandatory| Description                                    |
| -------- | ------------- | ---- | --------------------------------------- |
| 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()**.|
G
Gloria 已提交
3383
| callback | Callback\<BusinessError\> | Yes  | Callback used to return an error code defined in [CameraErrorCode](#cameraerrorcode).           |
N
nikhilraut 已提交
3384 3385 3386

**Example**

W
wusongqing 已提交
3387
```js
3388 3389
metadataOutput.on('error', (metadataOutputError) => {
    console.log(`Metadata output error code: ${metadataOutputError.code}`);
N
nikhilraut 已提交
3390 3391 3392
})
```

3393 3394
## MetadataObjectType

G
Gloria 已提交
3395
Enumerates the metadata object types.
3396 3397 3398 3399 3400

**System capability**: SystemCapability.Multimedia.Camera.Core

| Name                      | Value  | Description             |
| ------------------------- | ---- | ----------------- |
G
Gloria 已提交
3401
| FACE_DETECTION            | 0    | Face detection. The detection point must be in the coordinate system (0-1), where the upper left corner is {0, 0} and the lower right corner is {1, 1}.<br> The coordinate system is based on the horizontal device direction with the device's charging port on the right.<br> If the layout of a preview screen of an application is based on the vertical direction with the charging port on the lower side,<br> the layout width and height are {w, h} and the return point is {x, y}, then the coordinate point after conversion is {1-y, x}.|
3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419

## Rect

Defines a rectangle.

**System capability**: SystemCapability.Multimedia.Camera.Core

| Name     | Type  |      Mandatory    |           Description                |
| -------- | ------ | --------------- | -------------------- |
| topLeftX | number |        Yes         | X-axis coordinate of the upper left corner of the rectangle.  |
| topLeftY | number |         Yes         | Y-axis coordinate of the upper left corner of the rectangle.  |
| width    | number |         Yes        | Width of the rectangle.             |
| height   | number |         Yes          |Height of the rectangle.             |

## MetadataObject

Implements camera metadata, which is the data source of [CameraInput](#camerainput). The metadata is obtained through metadataOutput.on('metadataObjectsAvailable').

G
Gloria 已提交
3420 3421
**System capability**: SystemCapability.Multimedia.Camera.Core

G
Gloria 已提交
3422 3423 3424 3425 3426
| Name     | Type                           | Mandatory | Description             |
| -------- | ------------------------------- | ---- | -----------------|
| type  | [MetadataObjectType](#metadataobjecttype)   | No  | Metadata data type. Only face recognition is supported.|
| timestamp | number | No  | Current timestamp, in milliseconds.|
| boundingBox | [Rect](#rect)           | No  | Metadata rectangle.|