js-apis-camera.md 148.0 KB
Newer Older
W
wusongqing 已提交
1
# Camera Management
N
nikhilraut 已提交
2

W
wusongqing 已提交
3 4
> **NOTE**
>
5
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
W
wusongqing 已提交
6

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

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

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

W
wusongqing 已提交
15
getCameraManager(context: Context, callback: AsyncCallback<CameraManager\>): void
N
nikhilraut 已提交
16

W
wusongqing 已提交
17
Obtains a **CameraManager** instance. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
18

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

**Parameters**

W
wusongqing 已提交
23 24 25 26
| Name    | Type                                           | Mandatory| Description                              |
| -------- | ----------------------------------------------- | ---- | ---------------------------------- |
| context  | Context                                         | Yes  | Application context.                      |
| callback | AsyncCallback<[CameraManager](#cameramanager)\> | Yes  | Callback used to return the **CameraManager** instance.|
N
nikhilraut 已提交
27 28 29

**Example**

W
wusongqing 已提交
30
```js
N
nikhilraut 已提交
31 32
camera.getCameraManager(context, (err, cameraManager) => {
    if (err) {
33
        console.error(`Failed to get the CameraManager instance ${err.message}`);
N
nikhilraut 已提交
34 35 36 37 38 39
        return;
    }
    console.log('Callback returned with the CameraManager instance');
});
```

W
wusongqing 已提交
40
## camera.getCameraManager
N
nikhilraut 已提交
41

W
wusongqing 已提交
42
getCameraManager(context: Context): Promise<CameraManager\>
N
nikhilraut 已提交
43

W
wusongqing 已提交
44
Obtains a **CameraManager** instance. This API uses a promise to return the result.
N
nikhilraut 已提交
45

W
wusongqing 已提交
46
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
47 48 49

**Parameters**

W
wusongqing 已提交
50 51 52
| Name   | Type   | Mandatory| Description        |
| ------- | ------- | ---- | ------------ |
| context | Context | Yes  | Application context.|
N
nikhilraut 已提交
53

W
wusongqing 已提交
54
**Return value**
N
nikhilraut 已提交
55

W
wusongqing 已提交
56 57 58
| Type                                     | Description                                     |
| ----------------------------------------- | ----------------------------------------- |
| Promise<[CameraManager](#cameramanager)\> | Promise used to return the **CameraManager** instance.|
N
nikhilraut 已提交
59 60 61

**Example**

W
wusongqing 已提交
62
```js
W
wusongqing 已提交
63
camera.getCameraManager(context).then((cameraManager) => {
N
nikhilraut 已提交
64 65 66 67
    console.log('Promise returned with the CameraManager instance.');
})
```

W
wusongqing 已提交
68
## CameraStatus
N
nikhilraut 已提交
69

W
wusongqing 已提交
70
Enumerates the camera statuses.
N
nikhilraut 已提交
71

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

W
wusongqing 已提交
74 75 76 77 78 79
| Name                     | Value  | Description          |
| ------------------------- | ---- | -------------- |
| CAMERA_STATUS_APPEAR      | 0    | A camera appears.|
| CAMERA_STATUS_DISAPPEAR   | 1    | The camera disappears.  |
| CAMERA_STATUS_AVAILABLE   | 2    | The camera is available.    |
| CAMERA_STATUS_UNAVAILABLE | 3    | The camera is unavailable.  |
80

W
wusongqing 已提交
81
## Profile
N
nikhilraut 已提交
82

W
wusongqing 已提交
83
Defines the camera configuration.
N
nikhilraut 已提交
84

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

W
wusongqing 已提交
87 88 89 90
| Name  | Type                         | Read only| Description      |
| ------ | ----------------------------- | ---- | ---------- |
| format | [CameraFormat](#cameraformat) | Yes  | Output format.|
| size   | [Size](#size)                 | Yes  | Resolution.  |
N
nikhilraut 已提交
91

W
wusongqing 已提交
92
## FrameRateRange
N
nikhilraut 已提交
93

W
wusongqing 已提交
94
 Defines the frame rate range.
N
nikhilraut 已提交
95

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

W
wusongqing 已提交
98 99 100 101
| Name| Type  | Read only| Description             |
| ---- | ------ | ---- | ----------------- |
| min  | number | Yes  | Minimum rate, in fps.|
| max  | number | Yes  | Maximum rate, in fps.|
102

W
wusongqing 已提交
103
## VideoProfile
N
nikhilraut 已提交
104

W
wusongqing 已提交
105
Defines the video configuration.
N
nikhilraut 已提交
106

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

W
wusongqing 已提交
109 110 111
| Name           | Type                             | Read only| Description  |
| --------------- | --------------------------------- | ---- | ------ |
| frameRateRanges | [FrameRateRange](#frameraterange) | Yes  | Frame rate range.|
W
wusongqing 已提交
112

W
wusongqing 已提交
113
## CameraOutputCapability
W
wusongqing 已提交
114

W
wusongqing 已提交
115
Defines the camera output capability.
W
wusongqing 已提交
116 117

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

W
wusongqing 已提交
119 120 121 122 123 124
| Name                        | Type                                             | Read only| Description                      |
| ---------------------------- | ------------------------------------------------- | ---- | -------------------------- |
| previewProfiles              | Array<[Profile](#profile)\>                       | Yes  | Supported preview configurations.      |
| photoProfiles                | Array<[Profile](#profile)\>                       | Yes  | Supported shooting configurations.      |
| videoProfiles                | Array<[VideoProfile](#videoprofile)\>             | Yes  | Supported video recording configurations.      |
| supportedMetadataObjectTypes | Array<[MetadataObjectType](#metadataobjecttype)\> | Yes  | Supported metadata object types.|
N
nikhilraut 已提交
125

W
wusongqing 已提交
126
## CameraManager
N
nikhilraut 已提交
127

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

W
wusongqing 已提交
130
### getSupportedCameras
N
nikhilraut 已提交
131

W
wusongqing 已提交
132
getSupportedCameras(callback: AsyncCallback<Array<CameraDevice\>\>): void
N
nikhilraut 已提交
133

W
wusongqing 已提交
134
Obtains supported cameras. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
135

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

**Parameters**

W
wusongqing 已提交
140 141 142
| Name    | Type                                                 | Mandatory| Description                                |
| -------- | ----------------------------------------------------- | ---- | ------------------------------------ |
| callback | AsyncCallback<Array<[CameraDevice](#cameradevice)\>\> | Yes  | Callback used to return the array of supported cameras.|
N
nikhilraut 已提交
143 144 145

**Example**

W
wusongqing 已提交
146
```js
W
wusongqing 已提交
147
cameraManager.getSupportedCameras((err, cameras) => {
N
nikhilraut 已提交
148
    if (err) {
149
        console.error(`Failed to get the cameras. ${err.message}`);
N
nikhilraut 已提交
150 151
        return;
    }
152
    console.log(`Callback returned with an array of supported cameras: ${cameras.length}`);
N
nikhilraut 已提交
153 154 155
})
```

W
wusongqing 已提交
156
### getSupportedCameras
N
nikhilraut 已提交
157

W
wusongqing 已提交
158
getSupportedCameras(): Promise<Array<CameraDevice\>\>
N
nikhilraut 已提交
159

W
wusongqing 已提交
160
Obtains supported cameras. This API uses a promise to return the result.
N
nikhilraut 已提交
161

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

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

W
wusongqing 已提交
166 167 168
| Type                                           | Description                         |
| ----------------------------------------------- | ----------------------------- |
| Promise<Array<[CameraDevice](#cameradevice)\>\> | Promise used to return the array of supported cameras.|
N
nikhilraut 已提交
169 170 171 172


**Example**

W
wusongqing 已提交
173
```js
W
wusongqing 已提交
174
cameraManager.getSupportedCameras().then((cameraArray) => {
175
    console.log(`Promise returned with an array of supported cameras: ${cameraArray.length}`);
N
nikhilraut 已提交
176 177 178
})
```

W
wusongqing 已提交
179
### getSupportedOutputCapability
N
nikhilraut 已提交
180

W
wusongqing 已提交
181
getSupportedOutputCapability(camera:CameraDevice, callback: AsyncCallback<CameraOutputCapability\>): void
N
nikhilraut 已提交
182

W
wusongqing 已提交
183
Obtains the output capability supported by a camera. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
184

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

**Parameters**

W
wusongqing 已提交
189 190
| Name    | Type                                                        | Mandatory| Description                              |
| -------- | ------------------------------------------------------------ | ---- | ---------------------------------- |
J
jiangminyang 已提交
191
| camera   | [CameraDevice](#cameradevice)                                | Yes  | **CameraDevice** object.                |
W
wusongqing 已提交
192
| callback | AsyncCallback<[CameraOutputCapability](#cameraoutputcapability)\> | Yes  | Callback used to return the output capability.|
N
nikhilraut 已提交
193 194 195

**Example**

W
wusongqing 已提交
196
```js
W
wusongqing 已提交
197
cameraManager.getSupportedOutputCapability(cameraDevice, (err, cameras) => {
N
nikhilraut 已提交
198
    if (err) {
199
        console.error(`Failed to get the cameras. ${err.message}`);
N
nikhilraut 已提交
200 201
        return;
    }
W
wusongqing 已提交
202
    console.log('Callback returned with an array of supported outputCapability');
N
nikhilraut 已提交
203 204 205
})
```

W
wusongqing 已提交
206
### getSupportedOutputCapability
N
nikhilraut 已提交
207

W
wusongqing 已提交
208
getSupportedOutputCapability(camera:CameraDevice): Promise<CameraOutputCapability\>
N
nikhilraut 已提交
209

W
wusongqing 已提交
210
Obtains the output capability supported by a camera. This API uses a promise to return the result.
W
wusongqing 已提交
211

W
wusongqing 已提交
212
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
213 214 215

**Parameters**

W
wusongqing 已提交
216 217
| Name  | Type                         | Mandatory| Description              |
| ------ | ----------------------------- | ---- | ------------------ |
J
jiangminyang 已提交
218
| camera | [CameraDevice](#cameradevice) | Yes  | **CameraDevice** object.|
N
nikhilraut 已提交
219

W
wusongqing 已提交
220
**Return value**
N
nikhilraut 已提交
221

W
wusongqing 已提交
222 223 224 225
| Type                                                       | Description                                         |
| ----------------------------------------------------------- | --------------------------------------------- |
| Promise<[CameraOutputCapability](#cameraoutputcapability)\> | Promise used to return the output capability.|

N
nikhilraut 已提交
226 227 228

**Example**

W
wusongqing 已提交
229
```js
W
wusongqing 已提交
230 231
cameraManager.getSupportedOutputCapability(cameraDevice).then((cameraoutputcapability) => {
    console.log('Promise returned with an array of supported outputCapability');
N
nikhilraut 已提交
232 233 234
})
```

W
wusongqing 已提交
235
### getSupportedMetadataObjectType
N
nikhilraut 已提交
236

W
wusongqing 已提交
237
getSupportedMetadataObjectType(callback: AsyncCallback<Array<MetadataObjectType\>\>): void
N
nikhilraut 已提交
238

W
wusongqing 已提交
239
Obtains the metadata information supported by this camera. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
240

W
wusongqing 已提交
241
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
242 243 244

**Parameters**

W
wusongqing 已提交
245 246 247
| Name    | Type                                                        | Mandatory| Description                                        |
| -------- | ------------------------------------------------------------ | ---- | -------------------------------------------- |
| callback | AsyncCallback<Array<[MetadataObjectType](#metadataobject)\>\> | Yes  | Callback used to return the metadata information.|
N
nikhilraut 已提交
248 249 250

**Example**

W
wusongqing 已提交
251
```js
W
wusongqing 已提交
252
cameraManager.getSupportedMetadataObjectType((err, metadataobject) => {
N
nikhilraut 已提交
253
    if (err) {
254
        console.error(`Failed to get the supported metadataObjectType. ${err.message}`);
N
nikhilraut 已提交
255 256
        return;
    }
W
wusongqing 已提交
257
    console.log('Callback returned with an array of supported metadataObjectType.' );
N
nikhilraut 已提交
258 259 260
})
```

W
wusongqing 已提交
261
### getSupportedMetadataObjectType
N
nikhilraut 已提交
262

W
wusongqing 已提交
263
getSupportedMetadataObjectType(camera:CameraDevice): Promise<CameraOutputCapability\>
N
nikhilraut 已提交
264

W
wusongqing 已提交
265
Obtains the metadata information supported by this camera. This API uses a promise to return the result.
W
wusongqing 已提交
266

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

W
wusongqing 已提交
269
**Return value**
N
nikhilraut 已提交
270

W
wusongqing 已提交
271 272 273 274
| Type                                                   | Description                                                 |
| ------------------------------------------------------- | ----------------------------------------------------- |
| Promise<Array<[MetadataObjectType](#metadataobject)\>\> | Promise used to return the metadata information.|

N
nikhilraut 已提交
275 276 277

**Example**

W
wusongqing 已提交
278
```js
W
wusongqing 已提交
279 280
cameraManager.getSupportedMetadataObjectType().then((metadataobject) => {
    console.log('Promise returned with an array of supported metadataObjectType.' );
N
nikhilraut 已提交
281 282 283
})
```

W
wusongqing 已提交
284
### isCameraMuted
N
nikhilraut 已提交
285

W
wusongqing 已提交
286
isCameraMuted(callback: AsyncCallback<boolean\>): void
N
nikhilraut 已提交
287

W
wusongqing 已提交
288
Checks whether this camera is muted. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
289

W
wusongqing 已提交
290
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
291 292 293

**Parameters**

W
wusongqing 已提交
294 295 296
| Name    | Type                   | Mandatory| Description                                             |
| -------- | ----------------------- | ---- | ------------------------------------------------- |
| callback | AsyncCallback<boolean\> | Yes  | Callback used to return the result. The value **true** means that the camera is muted, and **false** means the opposite.|
N
nikhilraut 已提交
297 298 299

**Example**

W
wusongqing 已提交
300
```js
W
wusongqing 已提交
301
cameraManager.isCameraMuted((err, status) => {
302
    if (err) {
303
        console.error(`Failed to get the cameraMuted status. ${err.message}`);
304 305
        return;
    }
W
wusongqing 已提交
306
    console.log('Callback returned with cameraMuted status');
N
nikhilraut 已提交
307 308 309
})
```

W
wusongqing 已提交
310
### isCameraMuted
311

W
wusongqing 已提交
312 313 314
isCameraMuted(): Promise<boolean\>

Checks whether this camera is muted. This API uses a promise to return the result.
315

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

W
wusongqing 已提交
318 319 320 321 322 323
**Return value**

| Type             | Description                                               |
| ----------------- | --------------------------------------------------- |
| Promise<boolean\> | Promise used to return the result. The value **true** means that the camera is muted, and **false** means the opposite.|

N
nikhilraut 已提交
324

W
wusongqing 已提交
325
**Example**
N
nikhilraut 已提交
326

W
wusongqing 已提交
327
```js
W
wusongqing 已提交
328 329 330
cameraManager.isCameraMuted().then((status) => {
    console.log('Promise returned with the status whether camera is muted.');
})
N
nikhilraut 已提交
331 332
```

W
wusongqing 已提交
333
### isCameraMuteSupported
N
nikhilraut 已提交
334

W
wusongqing 已提交
335
isCameraMuteSupported(callback: AsyncCallback<boolean\>): void
N
nikhilraut 已提交
336

W
wusongqing 已提交
337
Checks whether this camera can be muted. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
338

W
wusongqing 已提交
339
This is a system API.
N
nikhilraut 已提交
340

W
wusongqing 已提交
341
**Required permissions**: ohos.permission.CAMERA
N
nikhilraut 已提交
342

W
wusongqing 已提交
343
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
344 345 346

**Parameters**

W
wusongqing 已提交
347 348 349
| Name    | Type                   | Mandatory| Description                                        |
| -------- | ----------------------- | ---- | -------------------------------------------- |
| callback | AsyncCallback<boolean\> | Yes  | Callback used to return the result. The value **true** means that the camera can be muted, and **false** means the opposite.|
W
wusongqing 已提交
350 351

**Example**
N
nikhilraut 已提交
352

W
wusongqing 已提交
353
```js
W
wusongqing 已提交
354
cameraManager.isCameraMuteSupported((err, status) => {
N
nikhilraut 已提交
355
    if (err) {
356
        console.error(`Failed to get the cameraMuteSupported. ${err.message}`);
N
nikhilraut 已提交
357 358
        return;
    }
W
wusongqing 已提交
359
    console.log('Callback returned with the status whether cameraMuteSupported.');
N
nikhilraut 已提交
360 361 362
})
```

W
wusongqing 已提交
363 364 365 366 367
### isCameraMuteSupported

isCameraMuteSupported(): Promise<boolean\>

Checks whether this camera can be muted. This API uses a promise to return the result.
N
nikhilraut 已提交
368

W
wusongqing 已提交
369
This is a system API.
N
nikhilraut 已提交
370

W
wusongqing 已提交
371
**Required permissions**: ohos.permission.CAMERA
N
nikhilraut 已提交
372

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

W
wusongqing 已提交
375
**Return value**
N
nikhilraut 已提交
376

W
wusongqing 已提交
377 378 379 380
| Type             | Description                                                   |
| ----------------- | ------------------------------------------------------- |
| Promise<boolean\> | Promise used to return the result. The value **true** means that the camera can be muted, and **false** means the opposite.|

N
nikhilraut 已提交
381 382 383

**Example**

W
wusongqing 已提交
384
```js
W
wusongqing 已提交
385 386
cameraManager.isCameraMuteSupported().then((status) => {
    console.log('Promise returned with the status whether cameraMuteSupported.');
N
nikhilraut 已提交
387 388 389
})
```

W
wusongqing 已提交
390
### muteCamera
N
nikhilraut 已提交
391

W
wusongqing 已提交
392
muteCamera(mute:boolean, callback: AsyncCallback<void\>): void
N
nikhilraut 已提交
393

W
wusongqing 已提交
394
Mutes this camera. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
395

W
wusongqing 已提交
396 397 398
This is a system API.

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

W
wusongqing 已提交
400
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
401 402 403

**Parameters**

W
wusongqing 已提交
404 405 406 407
| 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.                      |
| callback | AsyncCallback<void\> | Yes  | Callback used to return the result.|
N
nikhilraut 已提交
408 409 410

**Example**

W
wusongqing 已提交
411
```js
W
wusongqing 已提交
412
cameraManager.muteCamera(isMuted, (err) => {
N
nikhilraut 已提交
413
    if (err) {
414
        console.error(`Failed to mute the camera. ${err.message}`);
N
nikhilraut 已提交
415 416
        return;
    }
W
wusongqing 已提交
417
    console.log('Callback returned with the muteCamera.');
N
nikhilraut 已提交
418 419 420
})
```

W
wusongqing 已提交
421
### muteCamera
N
nikhilraut 已提交
422

W
wusongqing 已提交
423
muteCamera(mute:boolean): Promise<void\>
N
nikhilraut 已提交
424

W
wusongqing 已提交
425 426 427 428 429
Mutes this camera. This API uses a promise to return the result.

This is a system API.

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

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

W
wusongqing 已提交
433 434 435 436 437 438
**Parameters**

| 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.|

W
wusongqing 已提交
439
**Return value**
N
nikhilraut 已提交
440

W
wusongqing 已提交
441 442 443 444
| Type          | Description                                               |
| -------------- | --------------------------------------------------- |
| Promise<void\>| Promise used to return the result.|

N
nikhilraut 已提交
445 446 447

**Example**

W
wusongqing 已提交
448 449 450
```js 
cameraManager.muteCamera(isMuted).then(() => {
    console.log('Promise returned muteCamera.');
N
nikhilraut 已提交
451 452 453
})
```

W
wusongqing 已提交
454
### createCameraInput
N
nikhilraut 已提交
455

W
wusongqing 已提交
456
createCameraInput(camera: CameraDevice, callback: AsyncCallback<CameraInput\>): void
N
nikhilraut 已提交
457

W
wusongqing 已提交
458 459 460 461 462
Creates a **CameraInput** instance with the specified **CameraDevice** object. This API uses an asynchronous callback to return the result.

This is a system API.

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

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

**Parameters**

W
wusongqing 已提交
468 469
| Name    | Type                                       | Mandatory| Description                               |
| -------- | ------------------------------------------- | ---- | ----------------------------------- |
J
jiangminyang 已提交
470
| camera   | [CameraDevice](#cameradevice)               | Yes  | **CameraDevice** object.                 |
W
wusongqing 已提交
471
| callback | AsyncCallback<[CameraInput](#camerainput)\> | Yes  | Callback used to return the **CameraInput** instance.|
N
nikhilraut 已提交
472 473 474

**Example**

W
wusongqing 已提交
475
```js
W
wusongqing 已提交
476
cameraManager.createCameraInput(camera, (err, cameraInput) => {
N
nikhilraut 已提交
477
    if (err) {
478
        console.error(`Failed to create the CameraInput instance. ${err.message}`);
N
nikhilraut 已提交
479 480
        return;
    }
W
wusongqing 已提交
481
    console.log('Callback returned with the CameraInput instance.');
N
nikhilraut 已提交
482 483 484
})
```

W
wusongqing 已提交
485
### createCameraInput
N
nikhilraut 已提交
486

W
wusongqing 已提交
487
createCameraInput(camera: CameraDevice): Promise<CameraInput\>
N
nikhilraut 已提交
488

W
wusongqing 已提交
489 490 491 492 493
Creates a **CameraInput** instance with the specified **CameraDevice** object. This API uses a promise to return the result.

This is a system API.

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

W
wusongqing 已提交
495
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
496 497 498

**Parameters**

W
wusongqing 已提交
499 500
| Name  | Type                         | Mandatory| Description              |
| ------ | ----------------------------- | ---- | ------------------ |
J
jiangminyang 已提交
501
| camera | [CameraDevice](#cameradevice) | Yes  | **CameraDevice** object.|
N
nikhilraut 已提交
502

W
wusongqing 已提交
503
**Return value**
N
nikhilraut 已提交
504

W
wusongqing 已提交
505 506 507
| Type                                 | Description                                    |
| ------------------------------------- | ---------------------------------------- |
| Promise<[CameraInput](#camerainput)\> | Promise used to return the **CameraInput** instance.|
N
nikhilraut 已提交
508 509 510

**Example**

W
wusongqing 已提交
511
```js
W
wusongqing 已提交
512 513
cameraManager.createCameraInput(camera).then((cameraInput) => {
    console.log('Promise returned with the CameraInput instance');
N
nikhilraut 已提交
514 515 516
})
```

W
wusongqing 已提交
517
### createCameraInput
N
nikhilraut 已提交
518

W
wusongqing 已提交
519
createCameraInput(position: CameraPosition, type: CameraType, callback: AsyncCallback<CameraInput\>): void
N
nikhilraut 已提交
520

W
wusongqing 已提交
521
Creates a **CameraInput** instance with the specified camera position and type. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
522

W
wusongqing 已提交
523
This is a system API.
N
nikhilraut 已提交
524

W
wusongqing 已提交
525
**Required permissions**: ohos.permission.CAMERA
N
nikhilraut 已提交
526

W
wusongqing 已提交
527
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
528 529 530

**Parameters**

W
wusongqing 已提交
531 532 533 534 535
| Name    | Type                                       | Mandatory| Description                               |
| -------- | ------------------------------------------- | ---- | ----------------------------------- |
| position | [CameraPosition](#cameraposition)           | Yes  | Camera position.                         |
| type     | [CameraType](#cameratype)                   | Yes  | Camera type.                         |
| callback | AsyncCallback<[CameraInput](#camerainput)\> | Yes  | Callback used to return the **CameraInput** instance.|
N
nikhilraut 已提交
536 537 538

**Example**

W
wusongqing 已提交
539
```js
W
wusongqing 已提交
540
cameraManager.createCameraInput(camera.CameraPosition.CAMERA_POSITION_BACK, camera.CameraType.CAMERA_TYPE_UNSPECIFIED, (err, cameraInput) => {
N
nikhilraut 已提交
541
    if (err) {
542
        console.error(`Failed to create the CameraInput instance. ${err.message}`);
N
nikhilraut 已提交
543 544
        return;
    }
W
wusongqing 已提交
545
    console.log('Callback returned with the CameraInput instance');
N
nikhilraut 已提交
546 547 548
})
```

W
wusongqing 已提交
549
### createCameraInput
N
nikhilraut 已提交
550

W
wusongqing 已提交
551
createCameraInput(position: CameraPosition, type:CameraType ): Promise<CameraInput\>
N
nikhilraut 已提交
552

W
wusongqing 已提交
553
Creates a **CameraInput** instance with the specified camera position and type. This API uses a promise to return the result.
N
nikhilraut 已提交
554

W
wusongqing 已提交
555
This is a system API.
N
nikhilraut 已提交
556

W
wusongqing 已提交
557
**Required permissions**: ohos.permission.CAMERA
N
nikhilraut 已提交
558

W
wusongqing 已提交
559
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
560 561 562

**Parameters**

W
wusongqing 已提交
563 564 565 566
| Name    | Type                             | Mandatory| Description      |
| -------- | --------------------------------- | ---- | ---------- |
| position | [CameraPosition](#cameraposition) | Yes  | Camera position.|
| type     | [CameraType](#cameratype)         | Yes  | Camera type.|
N
nikhilraut 已提交
567

W
wusongqing 已提交
568
**Return value**
N
nikhilraut 已提交
569

W
wusongqing 已提交
570 571 572
| Type                                 | Description                                    |
| ------------------------------------- | ---------------------------------------- |
| Promise<[CameraInput](#camerainput)\> | Promise used to return the **CameraInput** instance.|
N
nikhilraut 已提交
573 574 575

**Example**

W
wusongqing 已提交
576
```js
W
wusongqing 已提交
577 578
cameraManager.createCameraInput(camera.CameraPosition.CAMERA_POSITION_BACK, camera.CameraType.CAMERA_TYPE_UNSPECIFIED).then((cameraInput) => {
    console.log('Promise returned with the CameraInput instance');
N
nikhilraut 已提交
579 580 581
})
```

W
wusongqing 已提交
582
### createPreviewOutput
N
nikhilraut 已提交
583

W
wusongqing 已提交
584
createPreviewOutput(profile: Profile, surfaceId: string, callback: AsyncCallback<PreviewOutput\>): void
N
nikhilraut 已提交
585

W
wusongqing 已提交
586
Creates a **PreviewOutput** instance. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
587

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

**Parameters**

W
wusongqing 已提交
592 593 594 595 596
| Name     | Type                                           | Mandatory| Description                                                        |
| --------- | ----------------------------------------------- | ---- | ------------------------------------------------------------ |
| profile   | [Profile](#profile)                             | Yes  | Supported preview configurations.                                        |
| surfaceId | string                                          | Yes  | Surface ID, which is obtained from **[XComponent](../arkui-ts/ts-basic-components-xcomponent.md)** or **[ImageReceiver](js-apis-image.md#imagereceiver9)**.|
| callback  | AsyncCallback<[PreviewOutput](#previewoutput)\> | Yes  | Callback used to return the **PreviewOutput** instance.                       |
N
nikhilraut 已提交
597 598 599

**Example**

W
wusongqing 已提交
600
```js
W
wusongqing 已提交
601
cameraManager.createPreviewOutput(profile, surfaceId, (err, previewoutput) => {
N
nikhilraut 已提交
602
    if (err) {
603
        console.error(`Failed to gcreate previewOutput. ${err.message}`);
N
nikhilraut 已提交
604 605
        return;
    }
W
wusongqing 已提交
606
    console.log('Callback returned with previewOutput created.');
N
nikhilraut 已提交
607 608 609
})
```

W
wusongqing 已提交
610
### createPreviewOutput
N
nikhilraut 已提交
611

W
wusongqing 已提交
612
createPreviewOutput(profile: Profile, surfaceId: string): Promise<PreviewOutput\>
N
nikhilraut 已提交
613

W
wusongqing 已提交
614
Creates a **PreviewOutput** instance. This API uses a promise to return the result.
N
nikhilraut 已提交
615

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

W
wusongqing 已提交
618 619 620 621 622 623 624
**Parameters**

| Name     | Type               | Mandatory| Description                                                        |
| --------- | ------------------- | ---- | ------------------------------------------------------------ |
| profile   | [Profile](#profile) | Yes  | Supported preview configurations.                                        |
| surfaceId | string              | Yes  | Surface ID, which is obtained from **[XComponent](../arkui-ts/ts-basic-components-xcomponent.md)** or **[ImageReceiver](js-apis-image.md#imagereceiver9)**.|

W
wusongqing 已提交
625
**Return value**
N
nikhilraut 已提交
626

W
wusongqing 已提交
627 628 629
| Type                                     | Description                                      |
| ----------------------------------------- | ------------------------------------------ |
| Promise<[PreviewOutput](#previewoutput)\> | Promise used to return the **PreviewOutput** instance.|
N
nikhilraut 已提交
630 631 632

**Example**

W
wusongqing 已提交
633
```js
W
wusongqing 已提交
634 635
cameraManager.createPreviewOutput(profile, survaceId).then((previewoutput) => {
    console.log('Promise returned with previewOutput created.');
N
nikhilraut 已提交
636 637 638
})
```

W
wusongqing 已提交
639
### createDeferredPreviewOutput
N
nikhilraut 已提交
640

W
wusongqing 已提交
641
createDeferredPreviewOutput(profile: Profile, callback: AsyncCallback<PreviewOutput\>): void
N
nikhilraut 已提交
642

W
wusongqing 已提交
643
Creates a **PreviewOutput** instance without a surface ID. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
644

W
wusongqing 已提交
645
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
646 647 648

**Parameters**

W
wusongqing 已提交
649 650 651 652
| Name    | Type                                           | Mandatory| Description                                 |
| -------- | ----------------------------------------------- | ---- | ------------------------------------- |
| profile  | [Profile](#profile)                             | Yes  | Supported preview configurations.                 |
| callback | AsyncCallback<[PreviewOutput](#previewoutput)\> | Yes  | Callback used to return the **PreviewOutput** instance.|
N
nikhilraut 已提交
653 654 655

**Example**

W
wusongqing 已提交
656
```js
W
wusongqing 已提交
657
cameraManager.createDeferredPreviewOutput(profile, (err, previewoutput) => {
N
nikhilraut 已提交
658
    if (err) {
659
        console.error(`Failed to create deferredPreviewOutput. ${err.message}`);
N
nikhilraut 已提交
660 661
        return;
    }
W
wusongqing 已提交
662
    console.log('Callback returned with deferredPreviewOutput created.');
N
nikhilraut 已提交
663
})
N
nikhilraut 已提交
664 665
```

W
wusongqing 已提交
666
### createDeferredPreviewOutput
N
nikhilraut 已提交
667

W
wusongqing 已提交
668
createDeferredPreviewOutput(profile: Profile): Promise<PreviewOutput\>
N
nikhilraut 已提交
669

W
wusongqing 已提交
670
Creates a **PreviewOutput** instance without a surface ID. This API uses a promise to return the result.
N
nikhilraut 已提交
671

W
wusongqing 已提交
672
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
673 674 675

**Parameters**

W
wusongqing 已提交
676 677 678
| Name   | Type               | Mandatory| Description                |
| ------- | ------------------- | ---- | -------------------- |
| profile | [Profile](#profile) | Yes  | Supported preview configurations.|
N
nikhilraut 已提交
679

W
wusongqing 已提交
680
**Return value**
N
nikhilraut 已提交
681

W
wusongqing 已提交
682 683 684
| Type                                     | Description                                      |
| ----------------------------------------- | ------------------------------------------ |
| Promise<[PreviewOutput](#previewoutput)\> | Promise used to return the **PreviewOutput** instance.|
N
nikhilraut 已提交
685 686 687

**Example**

W
wusongqing 已提交
688
```js
W
wusongqing 已提交
689 690
cameraManager.createDeferredPreviewOutput(profile).then((previewoutput) => {
    console.log('Promise returned with DefeerredPreviewOutput created.');
N
nikhilraut 已提交
691 692 693
})
```

W
wusongqing 已提交
694
### createPhotoOutput
N
nikhilraut 已提交
695

W
wusongqing 已提交
696
createPhotoOutput(profile: Profile, surfaceId: string, callback: AsyncCallback<PhotoOutput\>): void
N
nikhilraut 已提交
697

W
wusongqing 已提交
698
Creates a **PhotoOutput** instance. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
699

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

N
nikhilraut 已提交
702 703
**Parameters**

W
wusongqing 已提交
704 705 706 707 708
| Name     | Type                                       | Mandatory| Description                                                        |
| --------- | ------------------------------------------- | ---- | ------------------------------------------------------------ |
| profile   | [Profile](#profile)                         | Yes  | Supported shooting configurations.                                        |
| surfaceId | string                                      | Yes  | Surface ID, which is obtained from **[ImageReceiver](js-apis-image.md#imagereceiver9)**.|
| callback  | AsyncCallback<[PhotoOutput](#photooutput)\> | Yes  | Callback used to return the **PhotoOutput** instance.                         |
N
nikhilraut 已提交
709 710 711

**Example**

W
wusongqing 已提交
712
```js
W
wusongqing 已提交
713
cameraManager.createPhotoOutput(profile, surfaceId, (err, photooutput) => {
N
nikhilraut 已提交
714
    if (err) {
715
        console.error(`Failed to create photoOutput. ${err.message}`);
N
nikhilraut 已提交
716 717
        return;
    }
W
wusongqing 已提交
718
    console.log('Callback returned with photoOutput created.');
N
nikhilraut 已提交
719
})
N
nikhilraut 已提交
720 721
```

W
wusongqing 已提交
722
### createPhotoOutput
N
nikhilraut 已提交
723

W
wusongqing 已提交
724
createPhotoOutput(profile: Profile, surfaceId: string): Promise<PreviewOutput\>
N
nikhilraut 已提交
725

W
wusongqing 已提交
726
Creates a **PhotoOutput** instance. This API uses a promise to return the result.
N
nikhilraut 已提交
727

W
wusongqing 已提交
728
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
729 730 731

**Parameters**

W
wusongqing 已提交
732 733 734 735
| Name     | Type               | Mandatory| Description                                                        |
| --------- | ------------------- | ---- | ------------------------------------------------------------ |
| profile   | [Profile](#profile) | Yes  | Supported shooting configurations.                                        |
| surfaceId | string              | Yes  | Surface ID, which is obtained from **[ImageReceiver](js-apis-image.md#imagereceiver9)**.|
N
nikhilraut 已提交
736

W
wusongqing 已提交
737
**Return value**
N
nikhilraut 已提交
738

W
wusongqing 已提交
739 740 741
| Type                                 | Description                                    |
| ------------------------------------- | ---------------------------------------- |
| Promise<[PhotoOutput](#photooutput)\> | Promise used to return the **PhotoOutput** instance.|
N
nikhilraut 已提交
742 743 744

**Example**

W
wusongqing 已提交
745
```js
W
wusongqing 已提交
746 747
cameraManager.createPhotoOutput(profile, surfaceId).then((photooutput) => {
    console.log('Promise returned with photoOutput created.');
N
nikhilraut 已提交
748 749 750
})
```

W
wusongqing 已提交
751
### createVideoOutput
N
nikhilraut 已提交
752

W
wusongqing 已提交
753
createVideoOutput(profile: VideoProfile, surfaceId: string, callback: AsyncCallback<VideoOutput\>): void
N
nikhilraut 已提交
754

W
wusongqing 已提交
755
Creates a **VideoOutput** instance. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
756

W
wusongqing 已提交
757
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
758 759 760

**Parameters**

W
wusongqing 已提交
761 762 763 764 765
| Name     | Type                                       | Mandatory| Description                                                        |
| --------- | ------------------------------------------- | ---- | ------------------------------------------------------------ |
| profile   | [VideoProfile](#videoprofile)               | Yes  | Supported video recording configurations.                                        |
| surfaceId | string                                      | Yes  | Surface ID, which is obtained from **[VideoRecorder](js-apis-media.md#videorecorder9)**.|
| callback  | AsyncCallback<[VideoOutput](#videooutput)\> | Yes  | Callback used to return the **VideoOutput** instance.                         |
N
nikhilraut 已提交
766 767 768

**Example**

W
wusongqing 已提交
769
```js
W
wusongqing 已提交
770
cameraManager.createVideoOutput(profile, surfaceId, (err, videooutput) => {
N
nikhilraut 已提交
771
    if (err) {
772
        console.error(`Failed to create videoOutput. ${err.message}`);
N
nikhilraut 已提交
773 774
        return;
    }
W
wusongqing 已提交
775
    console.log('Callback returned with an array of supported outputCapability' );
N
nikhilraut 已提交
776
})
N
nikhilraut 已提交
777 778
```

W
wusongqing 已提交
779
### createVideoOutput
N
nikhilraut 已提交
780

W
wusongqing 已提交
781
createVideoOutput(profile: VideoProfile, surfaceId: string): Promise<VideoOutput\>
N
nikhilraut 已提交
782

W
wusongqing 已提交
783
Creates a **VideoOutput** instance. This API uses a promise to return the result.
N
nikhilraut 已提交
784

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

W
wusongqing 已提交
787 788 789 790 791 792 793
**Parameters**

| Name     | Type                         | Mandatory| Description                                                        |
| --------- | ----------------------------- | ---- | ------------------------------------------------------------ |
| profile   | [VideoProfile](#videoprofile) | Yes  | Supported video recording configurations.                                        |
| surfaceId | string                        | Yes  | Surface ID, which is obtained from **[VideoRecorder](js-apis-media.md#videorecorder9)**.|

W
wusongqing 已提交
794
**Return value**
N
nikhilraut 已提交
795

W
wusongqing 已提交
796 797 798
| Type                                 | Description                                    |
| ------------------------------------- | ---------------------------------------- |
| Promise<[VideoOutput](#videooutput)\> | Promise used to return the **VideoOutput** instance.|
N
nikhilraut 已提交
799 800 801

**Example**

W
wusongqing 已提交
802
```js
W
wusongqing 已提交
803 804
cameraManager.createVideoOutput(profile, surfaceId).then((videooutput) => {
    console.log('Promise returned with videoOutput created.');
N
nikhilraut 已提交
805 806 807
})
```

W
wusongqing 已提交
808
### createMetadataOutput
N
nikhilraut 已提交
809

W
wusongqing 已提交
810
createMetadataOutput(metadataObjectTypes: Array<MetadataObjectType\>, callback: AsyncCallback<MetadataOutput\>): void
N
nikhilraut 已提交
811

W
wusongqing 已提交
812
Creates a **MetadataOutput** instance. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
813

W
wusongqing 已提交
814
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
815 816 817

**Parameters**

W
wusongqing 已提交
818 819 820 821
| Name               | Type                                             | Mandatory| Description                                  |
| ------------------- | ------------------------------------------------- | ---- | -------------------------------------- |
| metadataObjectTypes | Array<[MetadataObjectType](#metadataobjecttype)\> | Yes  | Supported metadata object types.                      |
| callback            | AsyncCallback<[MetadataOutput](#metadataoutput)\> | Yes  | Callback used to return the **MetadataOutput** instance.|
N
nikhilraut 已提交
822 823 824

**Example**

W
wusongqing 已提交
825
```js
W
wusongqing 已提交
826
cameraManager.createMetadataOutput(metadataObjectTypes, (err, metadataoutput) => {
N
nikhilraut 已提交
827
    if (err) {
828
        console.error(`Failed to create metadataOutput. ${err.message}`);
N
nikhilraut 已提交
829 830
        return;
    }
W
wusongqing 已提交
831
    console.log('Callback returned with metadataOutput created.');
N
nikhilraut 已提交
832
})
N
nikhilraut 已提交
833 834
```

W
wusongqing 已提交
835
### createMetadataOutput
N
nikhilraut 已提交
836

W
wusongqing 已提交
837
createMetadataOutput(metadataObjectTypes: Array<MetadataObjectType\>): Promise<MetadataOutput>
N
nikhilraut 已提交
838

W
wusongqing 已提交
839
Creates a **MetadataOutput** instance. This API uses a promise to return the result.
N
nikhilraut 已提交
840

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

W
wusongqing 已提交
843 844 845 846 847 848
**Parameters**

| Name               | Type                                             | Mandatory| Description            |
| ------------------- | ------------------------------------------------- | ---- | ---------------- |
| metadataObjectTypes | Array<[MetadataObjectType](#metadataobjecttype)\> | Yes  | Supported metadata object types.|

W
wusongqing 已提交
849
**Return value**
N
nikhilraut 已提交
850

W
wusongqing 已提交
851 852 853
| Type                                       | Description                                       |
| ------------------------------------------- | ------------------------------------------- |
| Promise<[MetadataOutput](#metadataoutput)\> | Promise used to return the **MetadataOutput** instance.|
N
nikhilraut 已提交
854 855 856

**Example**

W
wusongqing 已提交
857
```js
W
wusongqing 已提交
858 859
cameraManager.createMetadataOutput(metadataObjectTypes).then((metadataoutput) => {
    console.log('Promise returned with metadataOutput created.');
N
nikhilraut 已提交
860 861 862
})
```

W
wusongqing 已提交
863
### createCaptureSession
N
nikhilraut 已提交
864

W
wusongqing 已提交
865
createCaptureSession(callback: AsyncCallback<CaptureSession\>): void
N
nikhilraut 已提交
866

W
wusongqing 已提交
867
Creates a **CaptureSession** instance. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
868

W
wusongqing 已提交
869
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
870 871 872

**Parameters**

W
wusongqing 已提交
873 874 875
| Name    | Type                                             | Mandatory| Description                            |
| -------- | ------------------------------------------------- | ---- | -------------------------------- |
| callback | AsyncCallback<[CaptureSession](#capturesession)\> | Yes  | Callback used to return the **CaptureSession** instance.|
N
nikhilraut 已提交
876 877 878

**Example**

W
wusongqing 已提交
879
```js
W
wusongqing 已提交
880
cameraManager.createCaptureSession((err, capturesession) => {
N
nikhilraut 已提交
881
    if (err) {
882
        console.error(`Failed to create captureSession. ${err.message}`);
N
nikhilraut 已提交
883 884
        return;
    }
W
wusongqing 已提交
885
    console.log('Callback returned with captureSession created.');
N
nikhilraut 已提交
886
})
N
nikhilraut 已提交
887 888
```

W
wusongqing 已提交
889
### createCaptureSession
N
nikhilraut 已提交
890

W
wusongqing 已提交
891
createCaptureSession(): Promise<CaptureSession\>
N
nikhilraut 已提交
892

W
wusongqing 已提交
893
Creates a **CaptureSession** instance. This API uses a promise to return the result.
N
nikhilraut 已提交
894

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

W
wusongqing 已提交
897
**Return value**
N
nikhilraut 已提交
898

W
wusongqing 已提交
899 900 901
| Type                                       | Description                                       |
| ------------------------------------------- | ------------------------------------------- |
| Promise<[CaptureSession](#capturesession)\> | Promise used to return the **CaptureSession** instance.|
N
nikhilraut 已提交
902 903 904

**Example**

W
wusongqing 已提交
905
```js
W
wusongqing 已提交
906 907
cameraManager.createCaptureSession().then((capturesession) => {
    console.log('Promise returned with captureSession created.');
N
nikhilraut 已提交
908 909 910
})
```

W
wusongqing 已提交
911
### on('cameraStatus')
N
nikhilraut 已提交
912

W
wusongqing 已提交
913
on(type: 'cameraStatus', callback: AsyncCallback<CameraStatusInfo\>): void
N
nikhilraut 已提交
914

W
wusongqing 已提交
915
Listens for camera status changes. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
916

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

**Parameters**

W
wusongqing 已提交
921 922 923 924
| Name    | Type                                                 | Mandatory| Description                                                |
| -------- | ----------------------------------------------------- | ---- | ---------------------------------------------------- |
| type     | string                                                | Yes  | Event type. The value is fixed at **cameraStatus**, indicating the camera status change event.|
| callback | AsyncCallback<[CameraStatusInfo](#camerastatusinfo)\> | Yes  | Callback used to return the camera status change.                |
N
nikhilraut 已提交
925 926 927

**Example**

W
wusongqing 已提交
928
```js
W
wusongqing 已提交
929
cameraManager.on('cameraStatus', (err, cameraStatusInfo) => {
N
nikhilraut 已提交
930
    if (err) {
931
        console.error(`Failed to get cameraStatus callback. ${err.message}`);
N
nikhilraut 已提交
932 933
        return;
    }
934 935
    console.log(`camera : ${cameraStatusInfo.camera.cameraId}`);
    console.log(`status: ${cameraStatusInfo.status}`);
N
nikhilraut 已提交
936
})
N
nikhilraut 已提交
937 938
```

W
wusongqing 已提交
939
### on('cameraMute') 
N
nikhilraut 已提交
940

W
wusongqing 已提交
941
on(type: 'cameraMute', callback: AsyncCallback<boolean\>): void
N
nikhilraut 已提交
942

W
wusongqing 已提交
943
Listens for camera mute status changes. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
944

W
wusongqing 已提交
945
This is a system API.
N
nikhilraut 已提交
946

W
wusongqing 已提交
947
**Required permissions**: ohos.permission.CAMERA
N
nikhilraut 已提交
948

W
wusongqing 已提交
949
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
950 951 952

**Parameters**

W
wusongqing 已提交
953 954 955 956
| Name    | Type                   | Mandatory| Description                                                  |
| -------- | ----------------------- | ---- | ------------------------------------------------------ |
| type     | string                  | Yes  | Event type. The value is fixed at **cameraMute**, indicating the camera mute status change event.|
| callback | AsyncCallback<boolean\> | Yes  | Callback used to return the camera mute status.                      |
N
nikhilraut 已提交
957 958 959

**Example**

W
wusongqing 已提交
960
```js
W
wusongqing 已提交
961
cameraManager.on('cameraMute', (err, status) => {
N
nikhilraut 已提交
962
    if (err) {
963
        console.error(`Failed to get cameraMute callback. ${err.message}`);
N
nikhilraut 已提交
964 965
        return;
    }
966
    console.log(`status: ${status}`);
W
wusongqing 已提交
967
})
N
nikhilraut 已提交
968 969
```

W
wusongqing 已提交
970
## CameraStatusInfo
N
nikhilraut 已提交
971

W
wusongqing 已提交
972
Describes the camera status information.
N
nikhilraut 已提交
973

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

W
wusongqing 已提交
976 977
| Name  | Type                         | Description      |
| ------ | ----------------------------- | ---------- |
J
jiangminyang 已提交
978
| camera | [CameraDevice](#cameradevice) | Camera object.|
W
wusongqing 已提交
979
| status | [CameraStatus](#camerastatus) | Camera status.|
N
nikhilraut 已提交
980

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

W
wusongqing 已提交
983
Enumerates the camera positions.
N
nikhilraut 已提交
984

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

W
wusongqing 已提交
987 988 989 990 991
| Name                       | Value  | Description            |
| --------------------------- | ---- | ---------------- |
| CAMERA_POSITION_UNSPECIFIED | 0    | Unspecified position.|
| CAMERA_POSITION_BACK        | 1    | Rear camera.      |
| CAMERA_POSITION_FRONT       | 2    | Front camera.      |
N
nikhilraut 已提交
992

W
wusongqing 已提交
993
## CameraType
N
nikhilraut 已提交
994

W
wusongqing 已提交
995
Enumerates the camera types.
N
nikhilraut 已提交
996

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

W
wusongqing 已提交
999 1000 1001 1002 1003 1004 1005
| Name                   | Value  | Description              |
| ----------------------- | ---- | ------------------ |
| CAMERA_TYPE_UNSPECIFIED | 0    | Unspecified camera type.  |
| 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.|
N
nikhilraut 已提交
1006

W
wusongqing 已提交
1007
## ConnectionType
N
nikhilraut 已提交
1008

W
wusongqing 已提交
1009
Enumerates the camera connection types.
N
nikhilraut 已提交
1010

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

W
wusongqing 已提交
1013 1014 1015 1016 1017
| 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.|
N
nikhilraut 已提交
1018

W
wusongqing 已提交
1019
## CameraDevice
N
nikhilraut 已提交
1020

W
wusongqing 已提交
1021
Defines the camera device information.
N
nikhilraut 已提交
1022

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

W
wusongqing 已提交
1025 1026 1027 1028 1029 1030
| Name          | Type                             | Read only| Description            |
| -------------- | --------------------------------- | ---- | ---------------- |
| 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 已提交
1031 1032 1033

**Example**

W
wusongqing 已提交
1034
```js
W
wusongqing 已提交
1035
async function getCameraInfo("cameraId") {
1036 1037 1038 1039 1040 1041 1042
    let cameraManager = await camera.getCameraManager(context);
    let cameras = await cameraManager.getSupportedCameras();
    let cameraObj = cameras[0];
    let cameraId = cameraObj.cameraId;
    let cameraPosition = cameraObj.cameraPosition;
    let cameraType = cameraObj.cameraType;
    let connectionType = cameraObj.connectionType;
W
wusongqing 已提交
1043
}
N
nikhilraut 已提交
1044 1045
```

W
wusongqing 已提交
1046
## Size
1047

W
wusongqing 已提交
1048
Enumerates the camera output capability.
1049 1050 1051

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

W
wusongqing 已提交
1052 1053 1054 1055
| Name  | Type  | Readable| Writable| Description              |
| ------ | ------ | ---- | ---- | ------------------ |
| height | number | Yes  | Yes  | Image height, in pixels.|
| width  | number | Yes  | Yes  | Image width, in pixel.|
N
nikhilraut 已提交
1056

W
wusongqing 已提交
1057
## Point
N
nikhilraut 已提交
1058

W
wusongqing 已提交
1059
Enumerates the point coordinates, which are used for focus and exposure configuration.
1060

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

W
wusongqing 已提交
1063 1064 1065 1066
| Name| Type  | Mandatory| Description       |
| ---- | ------ | ---- | ----------- |
| x    | number | Yes  | X coordinate of a point.|
| y    | number | Yes  | Y coordinate of a point.|
N
nikhilraut 已提交
1067

W
wusongqing 已提交
1068
## CameraFormat
N
nikhilraut 已提交
1069

W
wusongqing 已提交
1070
Enumerates the camera output format.
N
nikhilraut 已提交
1071

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

W
wusongqing 已提交
1074 1075 1076 1077
| Name                    | Default Value| Description                  |
| ------------------------ | ------ | ---------------------- |
| CAMERA_FORMAT_YUV_420_SP | 1003   | YUV 420 SP image.|
| CAMERA_FORMAT_JPEG       | 2000   | JPEG image.      |
N
nikhilraut 已提交
1078

W
wusongqing 已提交
1079
## CameraInput
N
nikhilraut 已提交
1080

W
wusongqing 已提交
1081
Provides camera information used in **[CaptureSession](#capturesession)**.
N
nikhilraut 已提交
1082

W
wusongqing 已提交
1083
### open
N
nikhilraut 已提交
1084

W
wusongqing 已提交
1085
open\(callback: AsyncCallback<void\>\): void
N
nikhilraut 已提交
1086

W
wusongqing 已提交
1087
Opens this camera. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
1088 1089

**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1090 1091 1092

**Parameters**

W
wusongqing 已提交
1093 1094 1095
| Name    | Type                | Mandatory| Description                    |
| -------- | -------------------- | ---- | ------------------------ |
| callback | AsyncCallback<void\> | Yes  | Callback used to return the result.|
N
nikhilraut 已提交
1096 1097 1098

**Example**

W
wusongqing 已提交
1099
```js
W
wusongqing 已提交
1100
cameraInput.open((err) => {
N
nikhilraut 已提交
1101
    if (err) {
1102
        console.error(`Failed to open the camera. ${err.message}`);
N
nikhilraut 已提交
1103 1104
        return;
    }
W
wusongqing 已提交
1105 1106
    console.log('Callback returned with camera opened.');
})
N
nikhilraut 已提交
1107 1108
```

W
wusongqing 已提交
1109
### open
N
nikhilraut 已提交
1110

W
wusongqing 已提交
1111
open(): Promise<void\>
N
nikhilraut 已提交
1112

W
wusongqing 已提交
1113
Opens this camera. This API uses a promise to return the result.
N
nikhilraut 已提交
1114

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

W
wusongqing 已提交
1117
**Return value**
N
nikhilraut 已提交
1118

W
wusongqing 已提交
1119 1120 1121
| Type          | Description                       |
| -------------- | --------------------------- |
| Promise<void\>| Promise used to return the result.|
N
nikhilraut 已提交
1122 1123 1124

**Example**

W
wusongqing 已提交
1125
```js
W
wusongqing 已提交
1126 1127
cameraInput.open().then(() => {
    console.log('Promise returned with camera opened.');
N
nikhilraut 已提交
1128 1129 1130
})
```

W
wusongqing 已提交
1131
### close
N
nikhilraut 已提交
1132

W
wusongqing 已提交
1133
close\(callback: AsyncCallback<void\>\): void
N
nikhilraut 已提交
1134

W
wusongqing 已提交
1135
Closes this camera. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
1136

W
wusongqing 已提交
1137
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1138 1139 1140

**Parameters**

W
wusongqing 已提交
1141 1142 1143
| Name    | Type                | Mandatory| Description                    |
| -------- | -------------------- | ---- | ------------------------ |
| callback | AsyncCallback<void\> | Yes  | Callback used to return the result.|
N
nikhilraut 已提交
1144 1145 1146

**Example**

W
wusongqing 已提交
1147
```js
W
wusongqing 已提交
1148
cameraInput.close((err) => {
N
nikhilraut 已提交
1149
    if (err) {
1150
        console.error(`Failed to close the cameras. ${err.message}`);
N
nikhilraut 已提交
1151 1152
        return;
    }
W
wusongqing 已提交
1153 1154
    console.log('Callback returned with camera closed.');
})
N
nikhilraut 已提交
1155 1156
```

W
wusongqing 已提交
1157
### close
N
nikhilraut 已提交
1158

W
wusongqing 已提交
1159
close(): Promise<void\>
N
nikhilraut 已提交
1160

W
wusongqing 已提交
1161
Closes this camera. This API uses a promise to return the result.
N
nikhilraut 已提交
1162

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

W
wusongqing 已提交
1165
**Return value**
N
nikhilraut 已提交
1166

W
wusongqing 已提交
1167 1168
| Type          | Description                       |
| -------------- | --------------------------- |
W
wusongqing 已提交
1169
| Promise<void\>| Promise used to return the result.|
N
nikhilraut 已提交
1170 1171 1172

**Example**

W
wusongqing 已提交
1173
```js
W
wusongqing 已提交
1174 1175
cameraInput.close().then(() => {
    console.log('Promise returned with camera closed.');
N
nikhilraut 已提交
1176 1177 1178
})
```

W
wusongqing 已提交
1179
### release
N
nikhilraut 已提交
1180

W
wusongqing 已提交
1181
release\(callback: AsyncCallback<void\>\): void
N
nikhilraut 已提交
1182

W
wusongqing 已提交
1183
Releases this camera. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
1184

W
wusongqing 已提交
1185
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1186 1187 1188

**Parameters**

W
wusongqing 已提交
1189 1190 1191
| Name    | Type                | Mandatory| Description                    |
| -------- | -------------------- | ---- | ------------------------ |
| callback | AsyncCallback<void\> | Yes  | Callback used to return the result.|
N
nikhilraut 已提交
1192 1193 1194

**Example**

W
wusongqing 已提交
1195
```js
W
wusongqing 已提交
1196
cameraInput.release((err) => {
N
nikhilraut 已提交
1197
    if (err) {
1198
        console.error(`Failed to release the CameraInput instance ${err.message}`);
N
nikhilraut 已提交
1199 1200
        return;
    }
W
wusongqing 已提交
1201
    console.log('Callback invoked to indicate that the CameraInput instance is released successfully.');
N
nikhilraut 已提交
1202 1203 1204
});
```

W
wusongqing 已提交
1205
### release
N
nikhilraut 已提交
1206

W
wusongqing 已提交
1207
release(): Promise<void\>
N
nikhilraut 已提交
1208

W
wusongqing 已提交
1209
Releases this camera. This API uses a promise to return the result.
N
nikhilraut 已提交
1210

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

W
wusongqing 已提交
1213
**Return value**
N
nikhilraut 已提交
1214

W
wusongqing 已提交
1215 1216
| Type          | Description                       |
| -------------- | --------------------------- |
W
wusongqing 已提交
1217
| Promise<void\>| Promise used to return the result.|
N
nikhilraut 已提交
1218 1219 1220

**Example**

W
wusongqing 已提交
1221
```js
W
wusongqing 已提交
1222 1223
cameraInput.release().then(() => {
    console.log('Promise returned to indicate that the CameraInput instance is released successfully.');
N
nikhilraut 已提交
1224 1225 1226
})
```

W
wusongqing 已提交
1227
### on('error')
N
nikhilraut 已提交
1228

W
wusongqing 已提交
1229
on(type: 'error', callback: ErrorCallback<CameraInputError\>): void
N
nikhilraut 已提交
1230

W
wusongqing 已提交
1231
Listens for **CameraInput** errors. This API uses a callback to return the result.
N
nikhilraut 已提交
1232

W
wusongqing 已提交
1233
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1234 1235 1236

**Parameters**

W
wusongqing 已提交
1237 1238 1239 1240
| Name    | Type                                                 | Mandatory| Description                                            |
| -------- | ----------------------------------------------------- | ---- | ------------------------------------------------ |
| type     | string                                                | Yes  | Event type. The value is fixed at **error**, indicating the camera input error event.|
| callback | ErrorCallback<[CameraInputError](#camerainputerror)\> | Yes  | Callback used to return the result.                        |
N
nikhilraut 已提交
1241 1242 1243

**Example**

W
wusongqing 已提交
1244
```js
W
wusongqing 已提交
1245
cameraInput.on('error', (cameraInputError) => {
1246
    console.log(`Camera input error code: ${cameraInputError.code}`);
W
wusongqing 已提交
1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372
})
```

## CameraInputErrorCode

Enumerates the error codes used for camera input.

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

| Name                     | Value  | Description          |
| ------------------------- | ---- | -------------- |
| ERROR_UNKNOWN             | -1   | Unknown error.    |
| ERROR_NO_PERMISSION       | 0    | You do not have the required permission.    |
| ERROR_DEVICE_PREEMPTED    | 1    | The camera is preempted.  |
| ERROR_DEVICE_DISCONNECTED | 2    | The camera is disconnected.|
| ERROR_DEVICE_IN_USE       | 3    | The camera is in use.|
| ERROR_DRIVER_ERROR        | 4    | Driver error.    |

## CameraInputError

Defines an error object used for **[CameraInput](#camerainput)**.

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

| Name| Type                                         | Description                   |
| ---- | --------------------------------------------- | ----------------------- |
| code | [CameraInputErrorCode](#camerainputerrorcode) | **CameraInput** error code.|


## FlashMode

Enumerates the flash modes.

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

| Name                  | Value  | Description        |
| ---------------------- | ---- | ------------ |
| 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.|

## ExposureMode

Enumerates the exposure modes.

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

| Name                         | Value  | Description          |
| ----------------------------- | ---- | -------------- |
| EXPOSURE_MODE_LOCKED          | 0    | Exposure locked.|
| EXPOSURE_MODE_AUTO            | 1    | Auto exposure.|
| EXPOSURE_MODE_CONTINUOUS_AUTO | 2    | Continuous auto exposure.|

## FocusMode

Enumerates the focus modes.

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

| Name                      | Value  | Description          |
| -------------------------- | ---- | -------------- |
| FOCUS_MODE_MANUAL          | 0    | Manual focus.    |
| FOCUS_MODE_CONTINUOUS_AUTO | 1    | Continuous auto focus.|
| FOCUS_MODE_AUTO            | 2    | Auto focus.    |
| FOCUS_MODE_LOCKED          | 3    | Focus locked.    |

## FocusState

Enumerates the focus states.

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

| Name                 | Value  | Description        |
| --------------------- | ---- | ------------ |
| FOCUS_STATE_SCAN      | 0    | Focusing.  |
| FOCUS_STATE_FOCUSED   | 1    | Focused.  |
| FOCUS_STATE_UNFOCUSED | 2    | Unfocused.|

## ExposureState

Enumerates the exposure states.

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

| Name                    | Value  | Description      |
| ------------------------ | ---- | ---------- |
| EXPOSURE_STATE_SCAN      | 0    | Exposing.  |
| EXPOSURE_STATE_CONVERGED | 1    | Exposure converged.|

## VideoStabilizationMode

Enumerates the video stabilization modes.

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

| 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.                                      |

## CaptureSession

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.

### beginConfig

beginConfig\(callback: AsyncCallback<void\>\): void

Starts configuration for this **CaptureSession** instance. This API uses an asynchronous callback to return the result.

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

**Parameters**

| Name    | Type                | Mandatory| Description                    |
| -------- | -------------------- | ---- | ------------------------ |
| callback | AsyncCallback<void\> | Yes  | Callback used to return the result.|

**Example**

```js
captureSession.beginConfig((err) => {
N
nikhilraut 已提交
1373
    if (err) {
1374
        console.error(`Failed to start the configuration. ${err.message}`);
N
nikhilraut 已提交
1375 1376
        return;
    }
W
wusongqing 已提交
1377
    console.log('Callback invoked to indicate the begin config success.');
N
nikhilraut 已提交
1378 1379 1380
});
```

W
wusongqing 已提交
1381
### beginConfig
N
nikhilraut 已提交
1382

W
wusongqing 已提交
1383
beginConfig\(\): Promise<void\>
N
nikhilraut 已提交
1384

W
wusongqing 已提交
1385
Starts configuration for this **CaptureSession** instance. This API uses a promise to return the result.
N
nikhilraut 已提交
1386

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

W
wusongqing 已提交
1389
**Return value**
N
nikhilraut 已提交
1390

W
wusongqing 已提交
1391 1392
| Type          | Description                       |
| -------------- | --------------------------- |
W
wusongqing 已提交
1393 1394
| Promise<void\>| Promise used to return the result.|

N
nikhilraut 已提交
1395 1396 1397

**Example**

W
wusongqing 已提交
1398
```js
W
wusongqing 已提交
1399 1400
captureSession.beginConfig().then(() => {
    console.log('Promise returned to indicate the begin config success.');
N
nikhilraut 已提交
1401 1402 1403
})
```

W
wusongqing 已提交
1404
### commitConfig
N
nikhilraut 已提交
1405

W
wusongqing 已提交
1406
commitConfig\(callback: AsyncCallback<void\>\): void
N
nikhilraut 已提交
1407

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

W
wusongqing 已提交
1410
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1411 1412 1413

**Parameters**

W
wusongqing 已提交
1414 1415 1416
| Name    | Type                | Mandatory| Description                    |
| -------- | -------------------- | ---- | ------------------------ |
| callback | AsyncCallback<void\> | Yes  | Callback used to return the result.|
N
nikhilraut 已提交
1417 1418 1419

**Example**

W
wusongqing 已提交
1420
```js
W
wusongqing 已提交
1421
captureSession.commitConfig((err) => {
N
nikhilraut 已提交
1422
    if (err) {
1423
        console.error(`Failed to commit the configuration. ${err.message}`);
N
nikhilraut 已提交
1424 1425
        return;
    }
W
wusongqing 已提交
1426
    console.log('Callback invoked to indicate the commit config success.');
N
nikhilraut 已提交
1427 1428 1429
});
```

W
wusongqing 已提交
1430
### commitConfig
N
nikhilraut 已提交
1431

W
wusongqing 已提交
1432
commitConfig\(\): Promise<void\>
N
nikhilraut 已提交
1433

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

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

W
wusongqing 已提交
1438
**Return value**
N
nikhilraut 已提交
1439

W
wusongqing 已提交
1440 1441
| Type          | Description                       |
| -------------- | --------------------------- |
W
wusongqing 已提交
1442
| Promise<void\>| Promise used to return the result.|
N
nikhilraut 已提交
1443 1444 1445

**Example**

W
wusongqing 已提交
1446
```js
W
wusongqing 已提交
1447 1448
captureSession.commitConfig().then(() => {
    console.log('Promise returned to indicate the commit config success.');
N
nikhilraut 已提交
1449 1450 1451
})
```

W
wusongqing 已提交
1452
### canAddInput
N
nikhilraut 已提交
1453

W
wusongqing 已提交
1454
canAddInput(cameraInput: CameraInput, callback: AsyncCallback<boolean\>): void
N
nikhilraut 已提交
1455

W
wusongqing 已提交
1456
Checks whether a **[CameraInput](#camerainput)** instance can be added to this **CaptureSession**. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
1457

W
wusongqing 已提交
1458
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1459 1460 1461

**Parameters**

W
wusongqing 已提交
1462 1463
| Name       | Type                       | Mandatory| Description                       |
| ----------- | --------------------------- | ---- | --------------------------- |
W
wusongqing 已提交
1464 1465
| cameraInput | [CameraInput](#camerainput) | Yes  | **CameraInput** instance to add.|
| callback    | AsyncCallback<boolean\>     | Yes  | Callback used to return the result.   |
N
nikhilraut 已提交
1466 1467 1468

**Example**

W
wusongqing 已提交
1469
```js
W
wusongqing 已提交
1470
captureSession.canAddInput(cameraInput, (err, status) => {
N
nikhilraut 已提交
1471
    if (err) {
1472
        console.error(`Can not add cameraInput. ${err.message}`);
N
nikhilraut 已提交
1473 1474
        return;
    }
W
wusongqing 已提交
1475 1476
    console.log('Callback returned with cameraInput can added.');
})
N
nikhilraut 已提交
1477 1478
```

W
wusongqing 已提交
1479
### canAddInput
N
nikhilraut 已提交
1480

W
wusongqing 已提交
1481
canAddInput(cameraInput: CameraInput): Promise<boolean\>
N
nikhilraut 已提交
1482

W
wusongqing 已提交
1483
Checks whether a **[CameraInput](#camerainput)** instance can be added to this **CaptureSession**. This API uses a promise to return the result.
N
nikhilraut 已提交
1484

W
wusongqing 已提交
1485
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1486 1487 1488

**Parameters**

W
wusongqing 已提交
1489 1490
| Name       | Type                       | Mandatory| Description                       |
| ----------- | --------------------------- | ---- | --------------------------- |
W
wusongqing 已提交
1491
| cameraInput | [CameraInput](#camerainput) | Yes  | **CameraInput** instance to add.|
N
nikhilraut 已提交
1492

W
wusongqing 已提交
1493
**Return value**
N
nikhilraut 已提交
1494

W
wusongqing 已提交
1495 1496 1497
| Type             | Description                       |
| ----------------- | --------------------------- |
| Promise<boolean\> | Promise used to return the result.|
N
nikhilraut 已提交
1498 1499 1500

**Example**

W
wusongqing 已提交
1501
```js
W
wusongqing 已提交
1502 1503
captureSession.canAddInput(cameraInput).then(() => {
    console.log('Promise returned with cameraInput can added.');
N
nikhilraut 已提交
1504 1505 1506
})
```

W
wusongqing 已提交
1507
### addInput
N
nikhilraut 已提交
1508

W
wusongqing 已提交
1509
addInput\(cameraInput: CameraInput, callback: AsyncCallback<void\>\): void
N
nikhilraut 已提交
1510

W
wusongqing 已提交
1511
Adds a **[CameraInput](#camerainput)** instance to this **CaptureSession**. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
1512

W
wusongqing 已提交
1513
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1514 1515 1516

**Parameters**

W
wusongqing 已提交
1517 1518
| Name       | Type                       | Mandatory| Description                       |
| ----------- | --------------------------- | ---- | --------------------------- |
W
wusongqing 已提交
1519
| cameraInput | [CameraInput](#camerainput) | Yes  | **CameraInput** instance to add.|
W
wusongqing 已提交
1520
| callback    | AsyncCallback<void\>        | Yes  | Callback used to return the result.   |
N
nikhilraut 已提交
1521 1522 1523

**Example**

W
wusongqing 已提交
1524
```js
W
wusongqing 已提交
1525
captureSession.addInput(cameraInput, (err) => {
N
nikhilraut 已提交
1526
    if (err) {
1527
        console.error(`Failed to add the CameraInput instance. ${err.message}`);
N
nikhilraut 已提交
1528 1529
        return;
    }
W
wusongqing 已提交
1530
    console.log('Callback invoked to indicate that the CameraInput instance is added.');
N
nikhilraut 已提交
1531 1532 1533
});
```

W
wusongqing 已提交
1534
### addInput
N
nikhilraut 已提交
1535

W
wusongqing 已提交
1536
addInput\(cameraInput: CameraInput\): Promise<void\>
N
nikhilraut 已提交
1537

W
wusongqing 已提交
1538
Adds a **[CameraInput](#camerainput)** instance to this **CaptureSession**. This API uses a promise to return the result.
N
nikhilraut 已提交
1539

W
wusongqing 已提交
1540
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1541 1542 1543

**Parameters**

W
wusongqing 已提交
1544 1545
| Name       | Type                       | Mandatory| Description                       |
| ----------- | --------------------------- | ---- | --------------------------- |
W
wusongqing 已提交
1546
| cameraInput | [CameraInput](#camerainput) | Yes  | **CameraInput** instance to add.|
N
nikhilraut 已提交
1547

W
wusongqing 已提交
1548
**Return value**
N
nikhilraut 已提交
1549

W
wusongqing 已提交
1550 1551
| Type          | Description                       |
| -------------- | --------------------------- |
W
wusongqing 已提交
1552
| Promise<void\>| Promise used to return the result.|
N
nikhilraut 已提交
1553 1554 1555

**Example**

W
wusongqing 已提交
1556
```js
W
wusongqing 已提交
1557 1558
captureSession.addInput(cameraInput).then(() => {
    console.log('Promise used to indicate that the CameraInput instance is added.');
N
nikhilraut 已提交
1559 1560 1561
})
```

W
wusongqing 已提交
1562
### removeInput
N
nikhilraut 已提交
1563

W
wusongqing 已提交
1564
removeInput\(cameraInput: CameraInput, callback: AsyncCallback<void\>\): void
N
nikhilraut 已提交
1565

W
wusongqing 已提交
1566
Removes a **[CameraInput](#camerainput)** instance from this **CaptureSession**. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
1567

W
wusongqing 已提交
1568
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1569 1570 1571

**Parameters**

W
wusongqing 已提交
1572 1573 1574 1575
| Name       | Type                       | Mandatory| Description                       |
| ----------- | --------------------------- | ---- | --------------------------- |
| cameraInput | [CameraInput](#camerainput) | Yes  | **CameraInput** instance to remove.|
| callback    | AsyncCallback<void\>        | Yes  | Callback used to return the result.   |
N
nikhilraut 已提交
1576 1577 1578

**Example**

W
wusongqing 已提交
1579
```js
N
nikhilraut 已提交
1580
captureSession.removeInput(cameraInput, (err) => {
N
nikhilraut 已提交
1581
    if (err) {
1582
        console.error(`Failed to remove the CameraInput instance. ${err.message}`);
N
nikhilraut 已提交
1583 1584 1585 1586 1587 1588
        return;
    }
    console.log('Callback invoked to indicate that the cameraInput instance is removed.');
});
```

W
wusongqing 已提交
1589
### removeInput
N
nikhilraut 已提交
1590

W
wusongqing 已提交
1591
removeInput\(cameraInput: CameraInput\): Promise<void\>
N
nikhilraut 已提交
1592

W
wusongqing 已提交
1593
Removes a **[CameraInput](#camerainput)** instance from this **CaptureSession**. This API uses a promise to return the result.
N
nikhilraut 已提交
1594

W
wusongqing 已提交
1595
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1596 1597 1598

**Parameters**

W
wusongqing 已提交
1599 1600 1601
| Name       | Type                       | Mandatory| Description                       |
| ----------- | --------------------------- | ---- | --------------------------- |
| cameraInput | [CameraInput](#camerainput) | Yes  | **CameraInput** instance to remove.|
N
nikhilraut 已提交
1602

W
wusongqing 已提交
1603
**Return value**
N
nikhilraut 已提交
1604

W
wusongqing 已提交
1605 1606 1607
| Type           | Description                       |
| --------------- | --------------------------- |
| Promise\<void\> | Promise used to return the result.|
N
nikhilraut 已提交
1608 1609 1610

**Example**

W
wusongqing 已提交
1611
```js
N
nikhilraut 已提交
1612
captureSession.removeInput(cameraInput).then(() => {
N
nikhilraut 已提交
1613 1614 1615 1616
    console.log('Promise returned to indicate that the cameraInput instance is removed.');
})
```

W
wusongqing 已提交
1617
### canAddOutput
N
nikhilraut 已提交
1618

W
wusongqing 已提交
1619
canAddOutput(cameraOutput: CameraOutput, callback: AsyncCallback<boolean\>\): void
N
nikhilraut 已提交
1620

W
wusongqing 已提交
1621
Checks whether a **[CameraOutput](#cameraoutput)** instance can be added to this **CaptureSession**. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
1622

W
wusongqing 已提交
1623
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1624 1625 1626

**Parameters**

W
wusongqing 已提交
1627 1628
| Name        | Type                         | Mandatory| Description                        |
| ------------ | ----------------------------- | ---- | ---------------------------- |
J
jiangminyang 已提交
1629
| cameraOutput | [CameraOutput](#cameraoutput) | Yes  | **CameraOutput** instance to add.|
W
wusongqing 已提交
1630
| callback     | AsyncCallback<boolean\>       | Yes  | Callback used to return the result.    |
N
nikhilraut 已提交
1631 1632 1633

**Example**

W
wusongqing 已提交
1634
```js
W
wusongqing 已提交
1635
captureSession.canAddOutput(cameraOutput, (err, status) => {
N
nikhilraut 已提交
1636
    if (err) {
1637
        console.error(`Can not add cameraOutput. ${err.message}`);
N
nikhilraut 已提交
1638 1639
        return;
    }
W
wusongqing 已提交
1640 1641
    console.log('Callback returned with cameraOutput can added.');
})
N
nikhilraut 已提交
1642 1643
```

W
wusongqing 已提交
1644
### canAddOutput
N
nikhilraut 已提交
1645

W
wusongqing 已提交
1646
canAddOutput(cameraOutput: CameraOutput): Promise<boolean\>
N
nikhilraut 已提交
1647

W
wusongqing 已提交
1648
Checks whether a **[CameraOutput](#cameraoutput)** instance can be added to this **CaptureSession**. This API uses a promise to return the result.
N
nikhilraut 已提交
1649

W
wusongqing 已提交
1650
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1651 1652 1653

**Parameters**

W
wusongqing 已提交
1654 1655
| Name        | Type                         | Mandatory| Description                        |
| ------------ | ----------------------------- | ---- | ---------------------------- |
J
jiangminyang 已提交
1656
| cameraOutput | [CameraOutput](#cameraoutput) | Yes  | **CameraOutput** instance to add.|
N
nikhilraut 已提交
1657 1658


W
wusongqing 已提交
1659
**Return value**
N
nikhilraut 已提交
1660

W
wusongqing 已提交
1661 1662 1663
| Type             | Description                       |
| ----------------- | --------------------------- |
| Promise<boolean\> | Promise used to return the result.|
N
nikhilraut 已提交
1664 1665 1666 1667


**Example**

W
wusongqing 已提交
1668
```js
W
wusongqing 已提交
1669 1670
captureSession.canAddOutput(cameraOutput).then(() => {
    console.log('Promise returned with cameraOutput can added.');
N
nikhilraut 已提交
1671 1672 1673
})
```

W
wusongqing 已提交
1674
### addOutput
N
nikhilraut 已提交
1675

W
wusongqing 已提交
1676
addOutput\(cameraOutput: CameraOutput, callback: AsyncCallback<void\>\): void
N
nikhilraut 已提交
1677

W
wusongqing 已提交
1678
Adds a **[CameraOutput](#cameraoutput)** instance to this **CaptureSession**. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
1679

W
wusongqing 已提交
1680
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1681 1682 1683

**Parameters**

W
wusongqing 已提交
1684 1685
| Name        | Type                         | Mandatory| Description                        |
| ------------ | ----------------------------- | ---- | ---------------------------- |
J
jiangminyang 已提交
1686
| cameraOutput | [CameraOutput](#cameraoutput) | Yes  | **CameraOutput** instance to add.|
W
wusongqing 已提交
1687
| callback     | AsyncCallback<void\>          | Yes  | Callback used to return the result.    |
N
nikhilraut 已提交
1688 1689 1690

**Example**

W
wusongqing 已提交
1691
```js
W
wusongqing 已提交
1692
captureSession.addOutput(cameraOutput, (err) => {
N
nikhilraut 已提交
1693
    if (err) {
1694
        console.error(`Failed to add output. ${err.message}`);
N
nikhilraut 已提交
1695 1696
        return;
    }
W
wusongqing 已提交
1697 1698
    console.log('Callback returned with output added.');
})
N
nikhilraut 已提交
1699 1700
```

W
wusongqing 已提交
1701
### addOutput
N
nikhilraut 已提交
1702

W
wusongqing 已提交
1703
addOutput\(cameraOutput: CameraOutput\): Promise<void\>
N
nikhilraut 已提交
1704

W
wusongqing 已提交
1705
Adds a **[CameraOutput](#cameraoutput)** instance to this **CaptureSession**. This API uses a promise to return the result.
N
nikhilraut 已提交
1706

W
wusongqing 已提交
1707
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1708 1709 1710

**Parameters**

W
wusongqing 已提交
1711 1712
| Name        | Type                         | Mandatory| Description                        |
| ------------ | ----------------------------- | ---- | ---------------------------- |
J
jiangminyang 已提交
1713
| cameraOutput | [CameraOutput](#cameraoutput) | Yes  | **CameraOutput** instance to add.|
N
nikhilraut 已提交
1714

W
wusongqing 已提交
1715
**Return value**
N
nikhilraut 已提交
1716

W
wusongqing 已提交
1717 1718
| Type          | Description                       |
| -------------- | --------------------------- |
W
wusongqing 已提交
1719
| Promise<void\>| Promise used to return the result.|
N
nikhilraut 已提交
1720 1721 1722

**Example**

W
wusongqing 已提交
1723
```js
W
wusongqing 已提交
1724 1725
captureSession.addOutput(cameraOutput).then(() => {
    console.log('Promise returned with cameraOutput added.');
N
nikhilraut 已提交
1726 1727 1728
})
```

W
wusongqing 已提交
1729
### removeOutput
N
nikhilraut 已提交
1730

W
wusongqing 已提交
1731
removeOutput\(cameraOutput: CameraOutput, callback: AsyncCallback<void\>\): void
N
nikhilraut 已提交
1732

W
wusongqing 已提交
1733
Removes a **[CameraOutput](#cameraoutput)** instance from this **CaptureSession**. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
1734

W
wusongqing 已提交
1735
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1736 1737 1738

**Parameters**

W
wusongqing 已提交
1739 1740
| Name        | Type                         | Mandatory| Description                        |
| ------------ | ----------------------------- | ---- | ---------------------------- |
J
jiangminyang 已提交
1741
| cameraOutput | [CameraOutput](#cameraoutput) | Yes  | **CameraOutput** instance to remove.|
W
wusongqing 已提交
1742
| callback     | AsyncCallback<void\>          | Yes  | Callback used to return the result.    |
N
nikhilraut 已提交
1743 1744 1745

**Example**

W
wusongqing 已提交
1746
```js
W
wusongqing 已提交
1747
captureSession.removeOutput(cameraOutput, (err) => {
N
nikhilraut 已提交
1748
    if (err) {
1749
        console.error(`Failed to remove the CameraOutput instance. ${err.message}`);
N
nikhilraut 已提交
1750 1751
        return;
    }
W
wusongqing 已提交
1752
    console.log('Callback invoked to indicate that the CameraOutput instance is removed.');
N
nikhilraut 已提交
1753 1754 1755
});
```

W
wusongqing 已提交
1756
### removeOutput
N
nikhilraut 已提交
1757

W
wusongqing 已提交
1758
removeOutput(cameraOutput: CameraOutput): Promise<void\>
N
nikhilraut 已提交
1759

W
wusongqing 已提交
1760
Removes a **[CameraOutput](#cameraoutput)** instance from this **CaptureSession**. This API uses a promise to return the result.
N
nikhilraut 已提交
1761

W
wusongqing 已提交
1762
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1763 1764 1765

**Parameters**

W
wusongqing 已提交
1766 1767
| Name        | Type                         | Mandatory| Description                        |
| ------------ | ----------------------------- | ---- | ---------------------------- |
J
jiangminyang 已提交
1768
| cameraOutput | [CameraOutput](#cameraoutput) | Yes  | **CameraOutput** instance to remove.|
N
nikhilraut 已提交
1769 1770


W
wusongqing 已提交
1771
**Return value**
N
nikhilraut 已提交
1772

W
wusongqing 已提交
1773 1774
| Type          | Description                       |
| -------------- | --------------------------- |
W
wusongqing 已提交
1775
| Promise<void\>| Promise used to return the result.|
N
nikhilraut 已提交
1776 1777 1778 1779


**Example**

W
wusongqing 已提交
1780
```js
W
wusongqing 已提交
1781 1782
captureSession.removeOutput(cameraOutput).then(() => {
    console.log('Promise returned to indicate that the CameraOutput instance is removed.');
N
nikhilraut 已提交
1783 1784 1785
})
```

W
wusongqing 已提交
1786
### start
N
nikhilraut 已提交
1787

W
wusongqing 已提交
1788
start\(callback: AsyncCallback<void\>\): void
N
nikhilraut 已提交
1789

W
wusongqing 已提交
1790
Starts this **CaptureSession**. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
1791

W
wusongqing 已提交
1792
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1793 1794 1795

**Parameters**

W
wusongqing 已提交
1796 1797 1798
| Name    | Type                | Mandatory| Description                    |
| -------- | -------------------- | ---- | ------------------------ |
| callback | AsyncCallback<void\> | Yes  | Callback used to return the result.|
N
nikhilraut 已提交
1799 1800 1801

**Example**

W
wusongqing 已提交
1802
```js
N
nikhilraut 已提交
1803
captureSession.start((err) => {
N
nikhilraut 已提交
1804
    if (err) {
1805
        console.error(`Failed to start the session ${err.message}`);
N
nikhilraut 已提交
1806 1807 1808 1809 1810 1811
        return;
    }
    console.log('Callback invoked to indicate the session start success.');
});
```

W
wusongqing 已提交
1812
### start
N
nikhilraut 已提交
1813

W
wusongqing 已提交
1814
start\(\): Promise<void\>
N
nikhilraut 已提交
1815

W
wusongqing 已提交
1816
Starts this **CaptureSession**. This API uses a promise to return the result.
N
nikhilraut 已提交
1817

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

W
wusongqing 已提交
1820
**Return value**
N
nikhilraut 已提交
1821

W
wusongqing 已提交
1822 1823
| Type          | Description                       |
| -------------- | --------------------------- |
W
wusongqing 已提交
1824
| Promise<void\>| Promise used to return the result.|
N
nikhilraut 已提交
1825 1826 1827

**Example**

W
wusongqing 已提交
1828
```js
N
nikhilraut 已提交
1829
captureSession.start().then(() => {
N
nikhilraut 已提交
1830 1831 1832 1833
    console.log('Promise returned to indicate the session start success.');
})
```

W
wusongqing 已提交
1834
### stop
N
nikhilraut 已提交
1835

W
wusongqing 已提交
1836
stop\(callback: AsyncCallback<void\>\): void
N
nikhilraut 已提交
1837

W
wusongqing 已提交
1838
Stops this **CaptureSession**. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
1839

W
wusongqing 已提交
1840
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1841 1842 1843

**Parameters**

W
wusongqing 已提交
1844 1845 1846
| Name    | Type                | Mandatory| Description                    |
| -------- | -------------------- | ---- | ------------------------ |
| callback | AsyncCallback<void\> | Yes  | Callback used to return the result.|
N
nikhilraut 已提交
1847 1848 1849

**Example**

W
wusongqing 已提交
1850
```js
N
nikhilraut 已提交
1851
captureSession.stop((err) => {
N
nikhilraut 已提交
1852
    if (err) {
1853
        console.error(`Failed to stop the session ${err.message}`);
N
nikhilraut 已提交
1854 1855 1856 1857 1858 1859
        return;
    }
    console.log('Callback invoked to indicate the session stop success.');
});
```

W
wusongqing 已提交
1860
### stop
N
nikhilraut 已提交
1861

W
wusongqing 已提交
1862
stop(): Promise<void\>
N
nikhilraut 已提交
1863

W
wusongqing 已提交
1864
Stops this **CaptureSession**. This API uses a promise to return the result.
N
nikhilraut 已提交
1865

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

W
wusongqing 已提交
1868
**Return value**
N
nikhilraut 已提交
1869

W
wusongqing 已提交
1870 1871
| Type          | Description                       |
| -------------- | --------------------------- |
W
wusongqing 已提交
1872
| Promise<void\>| Promise used to return the result.|
N
nikhilraut 已提交
1873 1874 1875

**Example**

W
wusongqing 已提交
1876
```js
N
nikhilraut 已提交
1877
captureSession.stop().then(() => {
N
nikhilraut 已提交
1878 1879 1880 1881
    console.log('Promise returned to indicate the session stop success.');
})
```

W
wusongqing 已提交
1882
### lockForControl
N
nikhilraut 已提交
1883

W
wusongqing 已提交
1884
lockForControl(callback: AsyncCallback<void\>): void
N
nikhilraut 已提交
1885

W
wusongqing 已提交
1886
Requests to exclusively control the hardware attributes **[CameraInput](#camerainput)** of the camera device. This API uses an asynchronous callback to return the result. After the exclusive control is complete, you must call **[unlockForControl](#unlockforcontrol)** to release the lock.
N
nikhilraut 已提交
1887

W
wusongqing 已提交
1888
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1889 1890 1891

**Parameters**

W
wusongqing 已提交
1892 1893 1894
| Name    | Type                | Mandatory| Description                    |
| -------- | -------------------- | ---- | ------------------------ |
| callback | AsyncCallback<void\> | Yes  | Callback used to return the result.|
N
nikhilraut 已提交
1895 1896 1897

**Example**

W
wusongqing 已提交
1898
```js
W
wusongqing 已提交
1899
captureSession.lockForControl((err) => {
N
nikhilraut 已提交
1900
    if (err) {
1901
        console.error(`Failed to lock. ${err.message}`);
N
nikhilraut 已提交
1902 1903
        return;
    }
W
wusongqing 已提交
1904 1905
    console.log('Locked.');
})
N
nikhilraut 已提交
1906 1907
```

W
wusongqing 已提交
1908
### lockForControl
N
nikhilraut 已提交
1909

W
wusongqing 已提交
1910
lockForControl(): Promise<void\>
N
nikhilraut 已提交
1911

W
wusongqing 已提交
1912
Requests to exclusively control the hardware attributes **[CameraInput](#camerainput)** of the camera device. This API uses a promise to return the result. After the exclusive control is complete, you must call **[unlockForControl](#unlockforcontrol)** to release the lock.
N
nikhilraut 已提交
1913

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

W
wusongqing 已提交
1916
**Return value**
N
nikhilraut 已提交
1917

W
wusongqing 已提交
1918 1919
| Type          | Description                       |
| -------------- | --------------------------- |
W
wusongqing 已提交
1920
| Promise<void\>| Promise used to return the result.|
N
nikhilraut 已提交
1921 1922 1923

**Example**

W
wusongqing 已提交
1924
```js
W
wusongqing 已提交
1925 1926
captureSession.lockForControl().then(() => {
    console.log('Locked.');
N
nikhilraut 已提交
1927 1928 1929
})
```

W
wusongqing 已提交
1930
### unlockForControl
N
nikhilraut 已提交
1931

W
wusongqing 已提交
1932
unlockForControl(callback: AsyncCallback<void\>): void
N
nikhilraut 已提交
1933

W
wusongqing 已提交
1934
Releases the exclusive control on the device configuration. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
1935

W
wusongqing 已提交
1936
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1937 1938 1939

**Parameters**

W
wusongqing 已提交
1940 1941 1942
| Name    | Type                | Mandatory| Description                    |
| -------- | -------------------- | ---- | ------------------------ |
| callback | AsyncCallback<void\> | Yes  | Callback used to return the result.|
N
nikhilraut 已提交
1943 1944 1945

**Example**

W
wusongqing 已提交
1946
```js
W
wusongqing 已提交
1947
captureSession.unlockForControl((err) => {
N
nikhilraut 已提交
1948
    if (err) {
1949
        console.error(`Failed to unlock. ${err.message}`);
N
nikhilraut 已提交
1950 1951
        return;
    }
W
wusongqing 已提交
1952 1953
    console.log('Unlocked.');
})
W
wusongqing 已提交
1954
```
N
nikhilraut 已提交
1955

W
wusongqing 已提交
1956
### unlockForControl
N
nikhilraut 已提交
1957

W
wusongqing 已提交
1958
unlockForControl(): Promise<void\>
N
nikhilraut 已提交
1959

W
wusongqing 已提交
1960
Releases the exclusive control on the device configuration. This API uses a promise to return the result.
N
nikhilraut 已提交
1961

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

W
wusongqing 已提交
1964
**Return value**
N
nikhilraut 已提交
1965

W
wusongqing 已提交
1966 1967 1968
| Type          | Description                       |
| -------------- | --------------------------- |
| Promise<void\>| Promise used to return the result.|
N
nikhilraut 已提交
1969 1970 1971

**Example**

W
wusongqing 已提交
1972
```js
W
wusongqing 已提交
1973 1974
captureSession.unlockForControl().then(() => {
    console.log('Unlocked.');
N
nikhilraut 已提交
1975 1976 1977
})
```

W
wusongqing 已提交
1978
### release
N
nikhilraut 已提交
1979

W
wusongqing 已提交
1980
release\(callback: AsyncCallback<void\>\): void
N
nikhilraut 已提交
1981

W
wusongqing 已提交
1982
Releases this **CaptureSession**. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
1983

W
wusongqing 已提交
1984
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
1985 1986 1987

**Parameters**

W
wusongqing 已提交
1988 1989 1990
| Name    | Type                | Mandatory| Description                    |
| -------- | -------------------- | ---- | ------------------------ |
| callback | AsyncCallback<void\> | Yes  | Callback used to return the result.|
N
nikhilraut 已提交
1991 1992 1993

**Example**

W
wusongqing 已提交
1994
```js
W
wusongqing 已提交
1995
captureSession.release((err) => {
N
nikhilraut 已提交
1996
    if (err) {
1997
        console.error(`Failed to release the CaptureSession instance ${err.message}`);
N
nikhilraut 已提交
1998 1999
        return;
    }
W
wusongqing 已提交
2000
    console.log('Callback invoked to indicate that the CaptureSession instance is released successfully.');
N
nikhilraut 已提交
2001 2002 2003
});
```

W
wusongqing 已提交
2004
### release
N
nikhilraut 已提交
2005

W
wusongqing 已提交
2006
release(): Promise<void\>
N
nikhilraut 已提交
2007

W
wusongqing 已提交
2008
Releases this **CaptureSession**. This API uses a promise to return the result.
N
nikhilraut 已提交
2009

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

W
wusongqing 已提交
2012
**Return value**
N
nikhilraut 已提交
2013

W
wusongqing 已提交
2014 2015
| Type          | Description                       |
| -------------- | --------------------------- |
W
wusongqing 已提交
2016
| Promise<void\>| Promise used to return the result.|
N
nikhilraut 已提交
2017 2018 2019

**Example**

W
wusongqing 已提交
2020
```js
W
wusongqing 已提交
2021 2022
captureSession.release().then(() => {
    console.log('Promise returned to indicate that the CaptureSession instance is released successfully.');
N
nikhilraut 已提交
2023 2024 2025
})
```

W
wusongqing 已提交
2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044
### hasFlash

hasFlash(callback: AsyncCallback<boolean\>): void

Checks whether the device has flash light. This API uses an asynchronous callback to return the result.

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

**Parameters**

| Name    | Type                   | Mandatory| Description                                  |
| -------- | ----------------------- | ---- | -------------------------------------- |
| callback | AsyncCallback<boolean\> | Yes  | Callback used to return the flash light support status. The value **true** means that the device has flash light.|

**Example**

```js
cameraInput.hasFlash((err, status) => {
    if (err) {
2045
        console.error(`Failed to check whether the device has flash light. ${err.message}`);
W
wusongqing 已提交
2046 2047
        return;
    }
2048
    console.log(`Callback returned with flash light support status: ${status}`);
W
wusongqing 已提交
2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069
})
```

### hasFlash

hasFlash(): Promise<boolean\>

Checks whether the device has flash light. This API uses a promise to return the result.

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

**Return value**

| Type             | Description                                                   |
| ----------------- | ------------------------------------------------------- |
| Promise<boolean\> | Promise used to return the flash light support status. The value **true** means that the device has flash light.|

**Example**

```js
cameraInput.hasFlash().then((status) => {
2070
    console.log(`Promise returned with the flash light support status: ${status}`);
W
wusongqing 已提交
2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093
})
```

### isFlashModeSupported

isFlashModeSupported(flashMode: FlashMode, callback: AsyncCallback<boolean\>): void

Checks whether a specified flash mode is supported. This API uses an asynchronous callback to return the result.

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

**Parameters**

| Name     | Type                   | Mandatory| Description                                    |
| --------- | ----------------------- | ---- | ---------------------------------------- |
| flashMode | [FlashMode](#flashmode) | Yes  | Flash mode.                        |
| callback  | AsyncCallback<boolean\> | Yes  | Callback used to return the flash mode support status. The value **true** means that the flash mode is supported, and **false** means the opposite.|

**Example**

```js
cameraInput.isFlashModeSupported(camera.FlashMode.FLASH_MODE_AUTO, (err, status) => {
    if (err) {
2094
        console.error(`Failed to check whether the flash mode is supported. ${err.message}`);
W
wusongqing 已提交
2095 2096
        return;
    }
2097
    console.log(`Callback returned with the flash mode support status: ${status}`);
W
wusongqing 已提交
2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124
})
```

### isFlashModeSupported

isFlashModeSupported(flashMode: FlashMode): Promise<boolean\>

Checks whether a specified flash mode is supported. This API uses a promise to return the result.

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

**Parameters**

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

**Return value**

| Type             | Description                                                        |
| ----------------- | ------------------------------------------------------------ |
| Promise<boolean\> | Promise used to return the flash mode support status. The value **true** means that the flash mode is supported, and **false** means the opposite.|

**Example**

```js
cameraInput.isFlashModeSupported(camera.FlashMode.FLASH_MODE_AUTO).then((status) => {
2125
    console.log(`Promise returned with flash mode support status.${status}`);
W
wusongqing 已提交
2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153
})
```

### setFlashMode

setFlashMode(flashMode: FlashMode, callback: AsyncCallback<void\>): void

Sets the flash mode. This API uses an asynchronous callback to return the result.

Before the setting, do the following checks:

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

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

**Parameters**

| Name     | Type                   | Mandatory| Description                    |
| --------- | ----------------------- | ---- | ------------------------ |
| flashMode | [FlashMode](#flashmode) | Yes  | Flash mode.        |
| callback  | AsyncCallback<void\>    | Yes  | Callback used to return the result.|

**Example**

```js
cameraInput.setFlashMode(camera.FlashMode.FLASH_MODE_AUTO, (err) => {
    if (err) {
2154
        console.error(`Failed to set the flash mode  ${err.message}`);
W
wusongqing 已提交
2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212
        return;
    }
    console.log('Callback returned with the successful execution of setFlashMode.');
})
```

### setFlashMode

setFlashMode(flashMode: FlashMode): Promise<void\>

Sets a flash mode. This API uses a promise to return the result.

Before the setting, do the following checks:

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

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

**Parameters**

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

**Return value**

| Type          | Description                       |
| -------------- | --------------------------- |
| Promise<void\>| Promise used to return the result.|

**Example**

```js
cameraInput.setFlashMode(camera.FlashMode.FLASH_MODE_AUTO).then(() => {
    console.log('Promise returned with the successful execution of setFlashMode.');
})
```

### getFlashMode

getFlashMode(callback: AsyncCallback<FlashMode\>): void

Obtains the flash mode in use. This API uses an asynchronous callback to return the result.

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

**Parameters**

| Name    | Type                                   | Mandatory| Description                                    |
| -------- | --------------------------------------- | ---- | ---------------------------------------- |
| callback | AsyncCallback<[FlashMode](#flashmode)\> | Yes  | Callback used to return the flash mode.|

**Example**

```js
cameraInput.getFlashMode((err, flashMode) => {
    if (err) {
2213
        console.error(`Failed to get the flash mode  ${err.message}`);
W
wusongqing 已提交
2214 2215
        return;
    }
2216
    console.log(`Callback returned with current flash mode: ${flashMode}`);
W
wusongqing 已提交
2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237
})
```

### getFlashMode

getFlashMode(): Promise<FlashMode\>

Obtains the flash mode in use. This API uses a promise to return the result.

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

**Return value**

| Type                             | Description                                   |
| --------------------------------- | --------------------------------------- |
| Promise<[FlashMode](#flashmode)\> | Promise used to return the flash mode.|

**Example**

```js
cameraInput.getFlashMode().then((flashMode) => {
2238
    console.log(`Promise returned with current flash mode : ${flashMode}`);
W
wusongqing 已提交
2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261
})
```

### isExposureModeSupported

isExposureModeSupported(aeMode: ExposureMode, callback: AsyncCallback<boolean\>): void;

Checks whether a specified exposure mode is supported. This API uses an asynchronous callback to return the result.

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

**Parameters**

| Name    | Type                         | Mandatory| Description                                |
| -------- | ----------------------------- | ---- | ------------------------------------ |
| aeMode   | [ExposureMode](#exposuremode) | Yes  | Exposure mode.                          |
| callback | AsyncCallback<boolean\>       | Yes  | Callback used to return the exposure mode support status. The value **true** means that the exposure mode is supported, and **false** means the opposite.|

**Example**

```js
cameraInput.isExposureModeSupported(camera.ExposureMode.EXPOSURE_MODE_LOCKEN,(err) => {
    if (err) {
2262
        console.log(`Failed to check exposure mode supported ${err.message}`);
W
wusongqing 已提交
2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292
        return ;
    }
    console.log('Callback returned with the successful excution of isExposureModeSupported');
})
```

### isExposureModeSupported

isExposureModeSupported(aeMode: ExposureMode): Promise<boolean\>

Checks whether a specified exposure mode is supported. This API uses a promise to return the result.

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

**Parameters**

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

**Return value**

| Name             | Description                                 |
| ----------------- | ------------------------------------- |
| Promise<boolean\> | Promise used to return the exposure mode support status. The value **true** means that the exposure mode is supported, and **false** means the opposite.|

**Example**

```js
cameraInput.isExposureModeSupported(camera.ExposureMode.EXPOSURE_MODE_LOCKED).then((isSupported) => {
2293
    console.log(`Promise returned with exposure mode supported : ${isSupported}`);
W
wusongqing 已提交
2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315
})
```

### getExposureMode

getExposureMode(callback: AsyncCallback<ExposureMode\>): void

Obtains the exposure mode in use. This API uses an asynchronous callback to return the result.

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

**Parameters**

| Name    | Type                                         | Mandatory| Description                            |
| -------- | --------------------------------------------- | ---- | -------------------------------- |
| callback | AsyncCallback<[ExposureMode](#exposuremode)\> | Yes  | Callback used to return the exposure mode.|

**Example**

```js
cameraInput.getExposureMode((err, exposureMode) => {
    if (err) {
2316
        console.log(`Failed to get the exposure mode ${err.message}`);
W
wusongqing 已提交
2317 2318
        return ;
    }
2319
    console.log(`Callback returned with current exposure mode: ${exposureMode}`);
W
wusongqing 已提交
2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340
})
```

### getExposureMode

getExposureMode(): Promise<ExposureMode\>

Obtains the exposure mode in use. This API uses a promise to return the result.

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

**Return value**

| Name                                   | Description                               |
| --------------------------------------- | ----------------------------------- |
| Promise<[ExposureMode](#exposuremode)\> | Promise used to return the exposure mode.|

**Example**

```js
cameraInput.getExposureMode().then((exposureMode) => {
2341
    console.log(`Promise returned with current exposure mode : ${exposureMode}`);
W
wusongqing 已提交
2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364
})
```

### setExposureMode

setExposureMode(aeMode: ExposureMode, callback: AsyncCallback<void\>): void

Sets an exposure mode. This API uses an asynchronous callback to return the result.

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

**Parameters**

| Name    | Type                         | Mandatory| Description                        |
| -------- | ----------------------------- | ---- | ---------------------------- |
| aeMode   | [ExposureMode](#exposuremode) | Yes  | Exposure mode.                  |
| callback | AsyncCallback<void\>          | Yes  | Callback used to return the result.|

**Example**

```js
cameraInput.setExposureMode(camera.ExposureMode.EXPOSURE_MODE_LOCKEN,(err) => {
    if (err) {
2365
        console.log(`Failed to set the exposure mode ${err.message}`);
W
wusongqing 已提交
2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412
        return ;
    }
    console.log('Callback returned with the successful excution of setExposureMode');
})
```

### setExposureMode

setExposureMode(aeMode: ExposureMode): Promise<void\>

Sets an exposure mode. This API uses a promise to return the result.

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

**Return value**

| Name          | Description                           |
| -------------- | ------------------------------- |
| Promise<void\>| Promise used to return the result.|

**Example**

```js
cameraInput.setExposureMode(camera.ExposureMode.EXPOSURE_MODE_LOCKED).then(() => {
    console.log('Promise returned with the successful execution of setExposureMode.');
})
```

### getMeteringPoint

getMeteringPoint(callback: AsyncCallback<Point\>): void

Obtains the center of the metering area. This API uses an asynchronous callback to return the result.

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

**Parameters**

| Name    | Type                           | Mandatory| Description                          |
| -------- | ------------------------------- | ---- | ------------------------------ |
| callback | AsyncCallback<[Point](#point)\> | Yes  | Callback used to return the center of the metering area.|

**Example**

```js
cameraInput.getMeteringPoint((err, exposurePoint) => {
    if (err) {
2413
        console.log(`Failed to get the current exposure point ${err.message}`);
W
wusongqing 已提交
2414 2415
        return ;
    }
2416
    console.log(`Callback returned with current exposure point: ${exposurePoint}`);
W
wusongqing 已提交
2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437
})
```

### getMeteringPoint

getMeteringPoint(): Promise<Point\>

Obtains the center of the metering area. This API uses a promise to return the result.

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

**Return value**

| Name                     | Description                             |
| ------------------------- | --------------------------------- |
| Promise<[Point](#point)\> | Promise used to return the center of the metering area.|

**Example**

```js
cameraInput.getMeteringPoint().then((exposurePoint) => {
2438
    console.log(`Promise returned with current exposure point : ${exposurePoint}`);
W
wusongqing 已提交
2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459
})
```

### setMeteringPoint

setMeteringPoint(point: Point, callback: AsyncCallback<point\>): void

Sets the center of the metering area. This API uses an asynchronous callback to return the result.

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

**Parameters**

| Name         | Type                | Mandatory| Description                    |
| ------------- | -------------------- | ---- | ------------------------ |
| exposurePoint | [Point](#point)      | Yes  | Exposure point.                |
| callback      | AsyncCallback<void\> | Yes  | Callback used to return the result.|

**Example**

```js
2460
const Point1 = {x: 1, y: 1};
W
wusongqing 已提交
2461 2462 2463

cameraInput.setMeteringPoint(Point1,(err) => {
    if (err) {
2464
        console.log(`Failed to set the exposure point ${err.message}`);
W
wusongqing 已提交
2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493
        return ;
    }
    console.log('Callback returned with the successful excution of setMeteringPoint');
})
```

### setMeteringPoint

setMeteringPoint(point: Point): Promise<void\>

Sets the center of the metering area. This API uses a promise to return the result.

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

**Parameters**

| Name         | Type           | Mandatory| Description    |
| ------------- | --------------- | ---- | -------- |
| exposurePoint | [Point](#point) | Yes  | Exposure point.|

**Return value**

| Name          | Description                       |
| -------------- | --------------------------- |
| Promise<void\>| Promise used to return the center of the metering area.|

**Example**

```js
2494
const Point2 = {x: 2, y: 2};
W
wusongqing 已提交
2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519

cameraInput.setMeteringPoint(Point2).then(() => {
    console.log('Promise returned with the successful execution of setMeteringPoint');
})
```

### getExposureBiasRange

getExposureBiasRange(callback: AsyncCallback<Array<number\>\>): void

Obtains the exposure compensation values. This API uses an asynchronous callback to return the result.

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

**Parameters**

| Name    | Type                          | Mandatory| Description                              |
| -------- | ------------------------------ | ---- | ---------------------------------- |
| callback | AsyncCallback<Array<number\>\> | Yes  | Callback used to return the array of compensation values.|

**Example**

```js
cameraInput.getExposureBiasRange((err, biasRangeArray) => {
    if (err) {
2520
        console.log(`Failed to get the array of compenstation range ${err.message}`);
W
wusongqing 已提交
2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544
        return ;
    }
    console.log('Callback returned with the array of compenstation range: ' + JSON.stringify(biasRangeArray));
})
```

### getExposureBiasRange

getExposureBiasRange(): Promise<Array<number\>\>

Obtains the exposure compensation values. This API uses a promise to return the result.

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

**Return value**

| Name                    | Description                               |
| ------------------------ | ----------------------------------- |
| Promise<Array<number\>\> | Promise used to return the array of compensation values.|

**Example**

```js
cameraInput.isExposureModeSupported(camera.ExposureMode.EXPOSURE_MODE_LOCKED).then((isSupported) => {
2545
    console.log(`Promise returned with exposure mode supported : ${isSupported}`);
W
wusongqing 已提交
2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570
})
```

### setExposureBias

setExposureBias(exposureBias: number, callback: AsyncCallback<void\>): void

Sets an exposure compensation value. This API uses an asynchronous callback to return the result.

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                    |
| ------------ | -------------------- | ---- | ------------------------ |
| exposureBias | number               | Yes  | Compensation value.              |
| callback     | AsyncCallback<void\> | Yes  | Callback used to return the result.|

**Example**

```js
cameraInput.setExposureBias(-4,(err) => {
    if (err) {
2571
        console.log(`Failed to set the exposure bias ${err.message}`);
W
wusongqing 已提交
2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626
        return ;
    }
    console.log('Callback returned with the successful excution of setExposureBias');
})
```

### setExposureBias

setExposureBias(exposureBias: number): Promise<void\>

Sets an exposure compensation value. This API uses a promise to return the result.

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      |
| ------------ | ------ | ---- | ---------- |
| exposureBias | number | Yes  | Compensation value.|

**Return value**

| Name          | Description                       |
| -------------- | --------------------------- |
| Promise<void\>| Promise used to return the result.|

**Example**

```js
cameraInput.setExposureBias(-4).then(() => {
    console.log('Promise returned with the successful execution of setExposureBias.');
})
```

### getExposureValue

getExposureValue(callback: AsyncCallback<number\>): void

Obtains the exposure value in use. This API uses an asynchronous callback to return the result.

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

**Parameters**

| Name    | Type                  | Mandatory| Description                      |
| -------- | ---------------------- | ---- | -------------------------- |
| callback | AsyncCallback<number\> | Yes  | Callback used to the exposure value.|

**Example**

```js
cameraInput.getExposureValue((err, exposureValue) => {
    if (err) {
2627
        console.log(`Failed to get the exposure value ${err.message}`);
W
wusongqing 已提交
2628 2629
        return ;
    }
2630
    console.log(`Callback returned with the exposure value: ${exposureValue}`);
W
wusongqing 已提交
2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651
})
```

### getExposureValue

getExposureValue(): Promise<number\>

Obtains the exposure value in use. This API uses a promise to return the result.

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

**Return value**

| Name            | Description                         |
| ---------------- | ----------------------------- |
| Promise<number\> | Promise used to the exposure value.|

**Example**

```js
cameraInput.getExposureValue().then((exposureValue) => {
2652
    console.log(`Promise returned with exposure value: ${exposureValude}`);
W
wusongqing 已提交
2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675
})
```

### isFocusModeSupported

isFocusModeSupported(afMode: FocusMode, callback: AsyncCallback<boolean\>): void

Checks whether a specified focus mode is supported. This API uses an asynchronous callback to return the result.

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

**Parameters**

| Name    | Type                   | Mandatory| Description                                  |
| -------- | ----------------------- | ---- | -------------------------------------- |
| afMode   | [FocusMode](#focusmode) | Yes  | Focus mode.                      |
| callback | AsyncCallback<boolean\> | Yes  | Callback used to return the focus mode support status. The value **true** means that the focus mode is supported, and **false** means the opposite.|

**Example**

```js
cameraInput.isFocusModeSupported(camera.FocusMode.FOCUS_MODE_AUTO, (err, status) => {
    if (err) {
2676
        console.error(`Failed to check whether the focus mode is supported. ${err.message}`);
W
wusongqing 已提交
2677 2678
        return;
    }
2679
    console.log(`Callback returned with the focus mode support status: ${status}`);
W
wusongqing 已提交
2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706
})
```

### isFocusModeSupported

isFocusModeSupported(afMode: FocusMode): Promise<boolean\>

Checks whether a specified focus mode is supported. This API uses a promise to return the result.

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

**Parameters**

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

**Return value**

| Type             | Description                                                       |
| ----------------- | ----------------------------------------------------------- |
| Promise<boolean\> | Promise used to return the focus mode support status. The value **true** means that the focus mode is supported, and **false** means the opposite.|

**Example**

```js
cameraInput.isFocusModeSupported(camera.FocusMode.FOCUS_MODE_AUTO).then((status) => {
2707
    console.log(`Promise returned with focus mode support status ${status}.`);
W
wusongqing 已提交
2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732
})
```

### setFocusMode

setFocusMode(afMode: FocusMode, callback: AsyncCallback<void\>): void

Sets a focus mode. This API uses an asynchronous callback to return the result.

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.        |
| callback | AsyncCallback<void\>    | Yes  | Callback used to return the result.|

**Example**

```js
cameraInput.setFocusMode(camera.FocusMode.FOCUS_MODE_AUTO, (err) => {
    if (err) {
2733
        console.error(`Failed to set the focus mode  ${err.message}`);
W
wusongqing 已提交
2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788
        return;
    }
    console.log('Callback returned with the successful execution of setFocusMode.');
})
```

### setFocusMode

setFocusMode(afMode: FocusMode): Promise<void\>

Sets a focus mode. This API uses a promise to return the result.

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**

| Type          | Description                       |
| -------------- | --------------------------- |
| Promise<void\>| Promise used to return the result.|

**Example**

```js
cameraInput.setFocusMode(camera.FocusMode.FOCUS_MODE_AUTO).then(() => {
    console.log('Promise returned with the successful execution of setFocusMode.');
})
```

### getFocusMode

getFocusMode(callback: AsyncCallback<FocusMode\>): void

Obtains the focus mode in use. This API uses an asynchronous callback to return the result.

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

**Parameters**

| Name    | Type                                   | Mandatory| Description                                  |
| -------- | --------------------------------------- | ---- | -------------------------------------- |
| callback | AsyncCallback<[FocusMode](#focusmode)\> | Yes  | Callback used to return the focus mode.|

**Example**

```js
cameraInput.getFocusMode((err, afMode) => {
    if (err) {
2789
        console.error(`Failed to get the focus mode  ${err.message}`);
W
wusongqing 已提交
2790 2791
        return;
    }
2792
    console.log(`Callback returned with current focus mode: ${afMode}`);
W
wusongqing 已提交
2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813
})
```

### getFocusMode

getFocusMode(): Promise<FocusMode\>

Obtains the focus mode in use. This API uses a promise to return the result.

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

**Return value**

| Type               | Description                                 |
| ------------------- | ------------------------------------- |
| Promise<FocusMode\> | Promise used to return the focus mode.|

**Example**

```js
cameraInput.getFocusMode().then((afMode) => {
2814
    console.log(`Promise returned with current focus mode : ${afMode}`);
W
wusongqing 已提交
2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829
})
```

### setFocusPoint

setFocusPoint(point: Point, callback: AsyncCallback<void\>): void

Sets a focus point. This API uses an asynchronous callback to return the result.

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

**Parameters**

| Name    | Type                | Mandatory| Description                    |
| -------- | -------------------- | ---- | ------------------------ |
J
jiangminyang 已提交
2830
| point    | [Point](#point)      | Yes  | Focus point.                  |
W
wusongqing 已提交
2831 2832 2833 2834 2835
| callback | AsyncCallback<void\> | Yes  | Callback used to return the result.|

**Example**

```js
2836
const Point1 = {x: 1, y: 1};
W
wusongqing 已提交
2837 2838 2839

cameraInput.setFocusPoint(Point1, (err) => {
    if (err) {
2840
        console.error(`Failed to set the focus point  ${err.message}`);
W
wusongqing 已提交
2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858
        return;
    }
    console.log('Callback returned with the successful execution of setFocusPoint.');
})
```

### setFocusPoint

setFocusPoint(point: Point): Promise<void\>

Sets a focus point. This API uses a promise to return the result.

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

**Parameters**

| Name | Type           | Mandatory| Description  |
| ----- | --------------- | ---- | ------ |
J
jiangminyang 已提交
2859
| point | [Point](#point) | Yes  | Focus point.|
W
wusongqing 已提交
2860 2861 2862 2863 2864 2865 2866 2867 2868 2869

**Return value**

| Type          | Description                       |
| -------------- | --------------------------- |
| Promise<void\>| Promise used to return the result.|

**Example**

```js
2870
const Point2 = {x: 2, y: 2};
W
wusongqing 已提交
2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895

cameraInput.setFocusPoint(Point2).then(() => {
    console.log('Promise returned with the successful execution of setFocusPoint.');
})
```

### getFocusPoint

getFocusPoint(callback: AsyncCallback<Point\>): void

Obtains the focus point. This API uses an asynchronous callback to return the result.

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

**Parameters**

| Name    | Type                           | Mandatory| Description                        |
| -------- | ------------------------------- | ---- | ---------------------------- |
| callback | AsyncCallback<[Point](#point)\> | Yes  | Callback used to return the focus point.|

**Example**

```js
cameraInput.getFocusPoint((err, point) => {
    if (err) {
2896
        console.error(`Failed to get the current focus point ${err.message}`);
W
wusongqing 已提交
2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943
        return;
    }
    console.log('Callback returned with the current focus point: ' + JSON.stringify(point));
})
```

### getFocusPoint

getFocusPoint(): Promise<Point\>

Obtains the focus point. This API uses a promise to return the result.

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

**Return value**

| Type           | Description                           |
| --------------- | ------------------------------- |
| Promise<Point\> | Promise used to return the focus point.|

**Example**

```js
cameraInput.getFocusPoint().then((point) => {
    console.log('Promise returned with the current focus point: ' + JSON.stringify(point));
})
```

### getFocalLength

getFocalLength(callback: AsyncCallback<number\>): void

Obtains the focal length. This API uses an asynchronous callback to return the result.

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

**Parameters**

| Name    | Type                  | Mandatory| Description                        |
| -------- | ---------------------- | ---- | ---------------------------- |
| callback | AsyncCallback<number\> | Yes  | Callback used to return the focal length.|

**Example**

```js
cameraInput.getFocalLength((err, focalLength) => {
    if (err) {
2944
        console.error(`Failed to get the current focal length  ${err.message}`);
W
wusongqing 已提交
2945 2946
        return;
    }
2947
    console.log(`Callback returned with the current focal length: ${focalLength}`);
W
wusongqing 已提交
2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968
})
```

### getFocalLength

getFocalLength(): Promise<number\>

Obtains the focal length. This API uses a promise to return the result.

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

**Return value**

| Type            | Description                       |
| ---------------- | --------------------------- |
| Promise<number\> | Promise used to return the focal length.|

**Example**

```js
cameraInput.getFocalLength().then((focalLength) => {
2969
    console.log(`Promise returned with the current focal length: ${focalLength}`);
W
wusongqing 已提交
2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991
})
```

### getZoomRatioRange

getZoomRatioRange\(callback: AsyncCallback<Array<number\>\>\): void

Obtains the zoom range. This API uses an asynchronous callback to return the result.

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

**Parameters**

| Name    | Type                          | Mandatory| Description                    |
| -------- | ------------------------------ | ---- | ------------------------ |
| callback | AsyncCallback<Array<number\>\> | Yes  | Callback used to return the zoom range.|

**Example**

```js
cameraInput.getZoomRatioRange((err, zoomRatioRange) => {
    if (err) {
2992
        console.error(`Failed to get the zoom ratio range. ${err.message}`);
W
wusongqing 已提交
2993 2994
        return;
    }
2995
    console.log(`Callback returned with zoom ratio range: ${zoomRatioRange.length}`);
W
wusongqing 已提交
2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016
})
```

### getZoomRatioRange

getZoomRatioRange\(\): Promise<Array<number\>\>

Obtains the zoom range. This API uses a promise to return the result.

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

**Return value**

| Type                    | Description                           |
| ------------------------ | ------------------------------- |
| Promise<Array<number\>\> | Promise used to return the zoom range.|

**Example**

```js
cameraInput.getZoomRatioRange().then((zoomRatioRange) => {
3017
    console.log(`Promise returned with zoom ratio range: ${zoomRatioRange.length}`);
W
wusongqing 已提交
3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040
})
```

### setZoomRatio

setZoomRatio(zoomRatio: number, callback: AsyncCallback<void\>): void

Sets a zoom ratio. This API uses an asynchronous callback to return the result.

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

**Parameters**

| Name     | Type                | Mandatory| Description                    |
| --------- | -------------------- | ---- | ------------------------ |
| zoomRatio | number               | Yes  | Zoom ratio.            |
| callback  | AsyncCallback<void\> | Yes  | Callback used to return the result.|

**Example**

```js
cameraInput.setZoomRatio(1, (err) => {
    if (err) {
3041
        console.error(`Failed to set the zoom ratio value ${err.message}`);
W
wusongqing 已提交
3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094
        return;
    }
    console.log('Callback returned with the successful execution of setZoomRatio.');
})
```

### setZoomRatio

setZoomRatio(zoomRatio: number): Promise<void\>

Sets a zoom ratio. This API uses a promise to return the result.

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

**Parameters**

| Name     | Type  | Mandatory| Description        |
| --------- | ------ | ---- | ------------ |
| zoomRatio | number | Yes  | Zoom ratio.|

**Return value**

| Type          | Description                       |
| -------------- | --------------------------- |
| Promise<void\>| Promise used to return the result.|

**Example**

```js
cameraInput.setZoomRatio(1).then(() => {
    console.log('Promise returned with the successful execution of setZoomRatio.');
})
```

### getZoomRatio

getZoomRatio(callback: AsyncCallback<number\>): void

Obtains the zoom ratio in use. This API uses an asynchronous callback to return the result.

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

**Parameters**

| Name    | Type                  | Mandatory| Description                    |
| -------- | ---------------------- | ---- | ------------------------ |
| callback | AsyncCallback<number\> | Yes  | Callback used to return the result.|

**Example**

```js
cameraInput.getZoomRatio((err, zoomRatio) => {
    if (err) {
3095
        console.error(`Failed to get the zoom ratio ${err.message}`);
W
wusongqing 已提交
3096 3097
        return;
    }
3098
    console.log(`Callback returned with current zoom ratio: ${zoomRatio}`);
W
wusongqing 已提交
3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119
})
```

### getZoomRatio

getZoomRatio(): Promise<number\>

Obtains the zoom ratio in use. This API uses a promise to return the result.

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

**Return value**

| Type            | Description                       |
| ---------------- | --------------------------- |
| Promise<number\> | Promise used to return the zoom ratio.|

**Example**

```js
cameraInput.getZoomRatio().then((zoomRatio) => {
3120
    console.log(`Promise returned with current zoom ratio : ${zoomRatio}`);
W
wusongqing 已提交
3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135
})
```

### isVideoStablizationModeSupported

isVideoStablizationModeSupported(vsMode: VideoStabilizationMode, callback: AsyncCallback<boolean\>): void

Checks whether a specified video stabilization mode is supported. This API uses an asynchronous callback to return the result.

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

**Parameters**

| Name    | Type                                             | Mandatory| Description                                |
| -------- | ------------------------------------------------- | ---- | ------------------------------------ |
J
jiangminyang 已提交
3136
| vsMode   | [VideoStabilizationMode](#videostabilizationmode) | Yes  | Video stabilization mode.                      |
W
wusongqing 已提交
3137 3138 3139 3140 3141 3142 3143
| callback | AsyncCallback<boolean\>                           | Yes  | Callback used to return whether the video stabilization mode is supported. The value **true** means that the video stabilization mode is supported, and **false** means the opposite.|

**Example**

```js
captureSession.isVideoStablizationModeSupported(camera.VideoStabilizationMode.OFF, (err, isSupported) => {
    if (err) {
3144
        console.error(`Failed to check whether video stabilization mode supported. ${err.message}`);
W
wusongqing 已提交
3145 3146
        return;
    }
3147
    console.log(`Callback returned with the successful execution of isVideoStabilizationModeSupported: ${status}`);
W
wusongqing 已提交
3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168
})
```

### isVideoStablizationModeSupported

isVideoStablizationModeSupported(vsMode: VideoStabilizationMode): Promise<boolean\>

Checks whether a specified video stabilization mode is supported. This API uses a promise to return the result.

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

**Return value**

| Type             | Description                                                 |
| ----------------- | ----------------------------------------------------- |
| Promise<boolean\> | Promise used to return whether the video stabilization mode is supported. The value **true** means that the video stabilization mode is supported, and **false** means the opposite.|

**Example**

```js
captureSession.isVideoStablizationModeSupported(camera.VideoStabilizationMode.OFF).then((isSupported) => {
3169
    console.log(`Promise returned with video stabilization mode supported: ${isSupported}`);
W
wusongqing 已提交
3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191
})
```

### getActiveVideoStabilizationMode

getActiveVideoStabilizationMode(callback: AsyncCallback<VideoStabilizationMode\>): void

Obtains the video stabilization mode in use. This API uses an asynchronous callback to return the result.

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

**Parameters**

| Name    | Type                                  | Mandatory| Description                                |
| -------- | -------------------------------------- | ---- | ------------------------------------ |
| callback | AsyncCallback<VideoStabilizationMode\> | Yes  | Callback used to return the video stabilization mode.|

**Example**

```js
captureSession.getActiveVideoStabilizationMode((err, vsMode) => {
    if (err) {
3192
        console.error(`Failed to get active video stabilization mode ${err.message}`);
W
wusongqing 已提交
3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216
        return;
    }
    console.log('Callback returned with the successful execution of getActiveVideoStabilizationMode.');
})
```

### getActiveVideoStabilizationMode

getActiveVideoStabilizationMode(): Promise<VideoStabilizationMode\>

Obtains the video stabilization mode in use. This API uses a promise to return the result.

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

**Return value**

| Type                            | Description                                                     |
| -------------------------------- | --------------------------------------------------------- |
| Promise<VideoStabilizationMode\> | Promise used to return the video stabilization mode.|

**Example**

```js
captureSession.getActiveVideoStabilizationMode().then((vsMode) => {
3217
    console.log(`Promise returned with the current video stabilization mode: ${vsMode}`);
W
wusongqing 已提交
3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240
})
```

### setVideoStabilizationMode

setVideoStabilizationMode(mode: VideoStabilizationMode, callback: AsyncCallback<void\>): void

Sets a video stabilization mode. This API uses an asynchronous callback to return the result.

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

**Parameters**

| Name    | Type                                             | Mandatory| Description                    |
| -------- | ------------------------------------------------- | ---- | ------------------------ |
| mode     | [VideoStabilizationMode](#videostabilizationmode) | Yes  | Video stabilization mode.|
| callback | AsyncCallback<void\>                              | Yes  | Callback used to return the result.              |

**Example**

```js
captureSession.setVideoStabilizationMode(camera.VideoStabilizationMode.OFF, (err) => {
    if (err) {
3241
        console.error(`Failed to set the video stabilization mode ${err.message}`);
W
wusongqing 已提交
3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294
        return;
    }
    console.log('Callback returned with the successful execution of setVideoStabilizationMode.');
})
```

### setVideoStabilizationMode

setVideoStabilizationMode(mode: VideoStabilizationMode): Promise<void\>

Sets a video stabilization mode. This API uses a promise to return the result.

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

**Parameters**

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

**Return value**

| Type          | Description                                                     |
| -------------- | --------------------------------------------------------- |
| Promise<void\>| Promise used to return the result.|

**Example**

```js
captureSession.setVideoStabilizationMode(camera.VideoStabilizationMode.OFF).then(() => {
    console.log('Promise returned with the successful execution of setVideoStabilizationMode.');
})
```

### on('focusStateChange')

on(type: 'focusStateChange', callback: AsyncCallback<FocusState\>): void

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                                                    |
| -------- | ----------------------------------------- | ---- | -------------------------------------------------------- |
| type     | string                                    | Yes  | Event type. The value is fixed at **focusStateChange**, indicating the focus state change event.|
| callback | AsyncCallback<[FocusState](#focusstate)\> | Yes  | Callback used to return the focus state change.                            |

**Example**

```js
cameraInput.on('focusStateChange', (focusState) => {
3295
    console.log(`Focus state  : ${focusState}`);
W
wusongqing 已提交
3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311
})
```

### on('exposureStateChange')

on(type: 'exposureStateChange', callback: AsyncCallback<ExposureState\>): void

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

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

**Parameters**

| Name    | Type                                           | Mandatory| Description                                                       |
| -------- | ----------------------------------------------- | ---- | ----------------------------------------------------------- |
| type     | string                                          | Yes  | Event type. The value is fixed at **'exposureStateChange'**, indicating the exposure state change event.|
J
jiangminyang 已提交
3312
| callback | AsyncCallback<[ExposureState](#exposurestate)\> | Yes  | Callback used to return the exposure state change.                               |
W
wusongqing 已提交
3313 3314 3315 3316 3317

**Example**

```js
cameraInput.on('exposureStateChange', (exposureState) => {
3318
    console.log(`Exposuer state  : ${exposureState}`);
W
wusongqing 已提交
3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340
})
```

### on('error')

on(type: 'error', callback: ErrorCallback<CaptureSessionError\>): void

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

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

**Parameters**

| Name    | Type                                                       | Mandatory| Description                                         |
| -------- | ----------------------------------------------------------- | ---- | --------------------------------------------- |
| type     | string                                                      | Yes  | Event type. The value is fixed at **error**, indicating the capture session error event.|
| callback | ErrorCallback<[CaptureSessionError](#capturesessionerror)\> | Yes  | Callback used to return the error information.                 |

**Example**

```js
captureSession.on('error', (captureSessionError) => {
3341
    console.log(`Capture session error code: ${captureSessionError.code}`);
W
wusongqing 已提交
3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389
})
```

## CaptureSessionErrorCode

Enumerates the error codes used in a **CaptureSession**.

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

| Name                        | Value  | Description      |
| ---------------------------- | ---- | ---------- |
| ERROR_UNKNOWN                | -1   | Unknown error.|
| ERROR_INSUFFICIENT_RESOURCES | 0    | Insufficient resources.|
| ERROR_TIMEOUT                | 1    | Timeout.    |

## CaptureSessionError

Defines a capture session error.

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

| Name| Type                                       | Description                      |
| ---- | ------------------------------------------- | -------------------------- |
| code | [CaptureSessionError](#capturesessionerror) | **CaptureSession** error code.|

## CameraOutput

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

### release

release(callback: AsyncCallback<void\>): void

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

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

**Parameters**

| Name    | Type                | Mandatory| Description                    |
| -------- | -------------------- | ---- | ------------------------ |
| callback | AsyncCallback<void\> | Yes  | Callback used to return the result.|

**Example**

```js
previewOutput.release((err) => {
    if (err) {
3390
        console.error(`Failed to release the PreviewOutput instance ${err.message}`);
W
wusongqing 已提交
3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442
        return;
    }
    console.log('Callback invoked to indicate that the PreviewOutput instance is released successfully.');
});
```

### release

release(): Promise<void\>

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

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

**Return value**

| Type          | Description                       |
| -------------- | --------------------------- |
| Promise<void\>| Promise used to return the result.|

**Example**

```js
previewOutput.release().then(() => {
    console.log('Promise returned to indicate that the PreviewOutput instance is released successfully.');
})
```

## PreviewOutput

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

### addDeferredSurface

addDeferredSurface(surfaceId: string, callback: AsyncCallback<void\>): void

Adds a surface after a **PreviewOutput** instance is created. This API uses an asynchronous callback to return the result.

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

**Parameters**

| Name     | Type                | Mandatory| Description                                                        |
| --------- | -------------------- | ---- | ------------------------------------------------------------ |
| surfaceId | string               | Yes  | Surface ID, which is obtained from **[XComponent](../arkui-ts/ts-basic-components-xcomponent.md)**.|
| callback  | AsyncCallback<void\> | Yes  | Callback used to return the result.                                    |

**Example**

```js
previewOutput.addDeferredSurface('surfaceId', (err) => {
    if (err) {
3443
        console.error(`Failed to add deferredSurface. ${err.message}`);
W
wusongqing 已提交
3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496
        return;
    }
    console.log('Callback returned with deferredSurface added.');
})
```

### addDeferredSurface

addDeferredSurface(surfaceId: string): Promise<void\>

Adds a surface after a **PreviewOutput** instance is created. This API uses a promise to return the result.

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

**Parameters**

| Name     | Type  | Mandatory| Description                                                        |
| --------- | ------ | ---- | ------------------------------------------------------------ |
| surfaceId | string | Yes  | Surface ID, which is obtained from **[XComponent](../arkui-ts/ts-basic-components-xcomponent.md)**.|

**Return value**

| Type          | Description                       |
| -------------- | --------------------------- |
| Promise<void\>| Promise used to return the result.|

**Example**

```js
previewOutput.addDeferredSurface('surfaceId').then(() => {
    console.log('Promise returned with deferredSurface added.');
})
```

### start

start(callback: AsyncCallback<void\>): void

Starts to output preview streams. This API uses an asynchronous callback to return the result.

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

**Parameters**

| Name    | Type                | Mandatory| Description                    |
| -------- | -------------------- | ---- | ------------------------ |
| callback | AsyncCallback<void\> | Yes  | Callback used to return the result.|

**Example**

```js
previewOutput.start((err) => {
    if (err) {
3497
        console.error(`Failed to start the previewOutput. ${err.message}`);
W
wusongqing 已提交
3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544
        return;
    }
    console.log('Callback returned with previewOutput started.');
})
```

### start

start(): Promise<void\>

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

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

**Return value**

| Type          | Description                       |
| -------------- | --------------------------- |
| Promise<void\>| Promise used to return the result.|

**Example**

```js
previewOutput.start().then(() => {
    console.log('Promise returned with previewOutput started.');
})
```

### stop

stop(callback: AsyncCallback<void\>): void

Stops outputting preview streams. This API uses an asynchronous callback to return the result.

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

**Parameters**

| Name    | Type                | Mandatory| Description                    |
| -------- | -------------------- | ---- | ------------------------ |
| callback | AsyncCallback<void\> | Yes  | Callback used to return the result.|

**Example**

```js
previewOutput.stop((err) => {
    if (err) {
3545
        console.error(`Failed to stop the previewOutput. ${err.message}`);
W
wusongqing 已提交
3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574
        return;
    }
    console.log('Callback returned with previewOutput stoped.');
})
```

### stop

stop(): Promise<void\>

Stops outputting preview streams. This API uses a promise to return the result.

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

**Return value**

| Type          | Description                       |
| -------------- | --------------------------- |
| Promise<void\>| Promise used to return the result.|

**Example**

```js
previewOutput.stop().then(() => {
    console.log('Callback returned with previewOutput stoped.');
})
```

### on('frameStart')
N
nikhilraut 已提交
3575

W
wusongqing 已提交
3576
on(type: 'frameStart', callback: AsyncCallback<void\>): void
N
nikhilraut 已提交
3577

W
wusongqing 已提交
3578
Listens for preview frame start events. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
3579

W
wusongqing 已提交
3580
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
3581 3582 3583

**Parameters**

W
wusongqing 已提交
3584
| Name    | Type                | Mandatory| Description                                        |
W
wusongqing 已提交
3585 3586
| -------- | -------------------- | ---- | -------------------------------------------- |
| type     | string               | Yes  | Event type. The value is fixed at **frameStart**, indicating the preview frame start event.|
W
wusongqing 已提交
3587
| callback | AsyncCallback<void\> | Yes  | Callback used to return the result.                    |
N
nikhilraut 已提交
3588 3589 3590

**Example**

W
wusongqing 已提交
3591
```js
N
nikhilraut 已提交
3592 3593 3594 3595 3596
previewOutput.on('frameStart', () => {
    console.log('Preview frame started');
})
```

W
wusongqing 已提交
3597
### on('frameEnd')
N
nikhilraut 已提交
3598

W
wusongqing 已提交
3599
on(type: 'frameEnd', callback: AsyncCallback<void\>): void
N
nikhilraut 已提交
3600

W
wusongqing 已提交
3601
Listens for preview frame end events. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
3602

W
wusongqing 已提交
3603
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
3604 3605 3606

**Parameters**

W
wusongqing 已提交
3607
| Name    | Type                | Mandatory| Description                                      |
W
wusongqing 已提交
3608 3609
| -------- | -------------------- | ---- | ------------------------------------------ |
| type     | string               | Yes  | Event type. The value is fixed at **frameEnd**, indicating the preview frame end event.|
W
wusongqing 已提交
3610
| callback | AsyncCallback<void\> | Yes  | Callback used to return the result.                  |
N
nikhilraut 已提交
3611 3612 3613

**Example**

W
wusongqing 已提交
3614
```js
N
nikhilraut 已提交
3615 3616 3617 3618 3619
previewOutput.on('frameEnd', () => {
    console.log('Preview frame ended');
})
```

W
wusongqing 已提交
3620
### on('error')
N
nikhilraut 已提交
3621

W
wusongqing 已提交
3622
on(type: 'error', callback: ErrorCallback<PreviewOutputError\>): void
N
nikhilraut 已提交
3623

W
wusongqing 已提交
3624
Listens for **PreviewOutput** errors. This API uses a callback to return the errors.
N
nikhilraut 已提交
3625

W
wusongqing 已提交
3626
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
3627 3628 3629

**Parameters**

W
wusongqing 已提交
3630
| Name    | Type                                                        | Mandatory| Description                                         |
W
wusongqing 已提交
3631 3632
| -------- | ------------------------------------------------------------ | ---- | --------------------------------------------- |
| type     | string                                                       | Yes  | Event type. The value is fixed at **error**, indicating the preview output error event.|
W
wusongqing 已提交
3633
| callback | ErrorCallback<[PreviewOutputErrorCode](#previewoutputerrorcode)\> | Yes  | Callback used to return the error information.                 |
N
nikhilraut 已提交
3634 3635 3636

**Example**

W
wusongqing 已提交
3637
```js
N
nikhilraut 已提交
3638
previewOutput.on('error', (previewOutputError) => {
3639
    console.log(`Preview output error code: ${previewOutputError.code}`);
N
nikhilraut 已提交
3640 3641 3642
})
```

3643 3644
## PreviewOutputErrorCode

W
wusongqing 已提交
3645
Enumerates the error codes used for preview output.
3646 3647 3648

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

W
wusongqing 已提交
3649 3650 3651
| Name         | Value  | Description      |
| ------------- | ---- | ---------- |
| ERROR_UNKNOWN | -1   | Unknown error.|
3652

W
wusongqing 已提交
3653
## PreviewOutputError
3654

W
wusongqing 已提交
3655
Defines the preview output error.
3656 3657 3658

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

W
wusongqing 已提交
3659 3660
| Name| Type                                             | Description                     |
| ---- | ------------------------------------------------- | ------------------------- |
W
wusongqing 已提交
3661
| code | [PreviewOutputErrorCode](#previewoutputerrorcode) | **PreviewOutput** error code.|
3662

W
wusongqing 已提交
3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736
## ImageRotation

Enumerates the image rotation angles.

**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.

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

| Name     | Type  | Mandatory| Description      |
| --------- | ------ | ---- | ---------- |
| latitude  | number | Yes  | Latitude, in degree.|
| longitude | number | Yes  | Longitude, in degree.|
| altitude  | number | Yes  | Altitude, in meter.|

## QualityLevel

Enumerates the image quality levels.

**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.  |


## PhotoCaptureSetting

Defines the settings for photo capture.

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

| Name    | Type                           | Mandatory| Default Value            | Description                  |
| -------- | ------------------------------- | ---- | ------------------ | ---------------------- |
| quality  | [QualityLevel](#qualitylevel)   | No  | QUALITY_LEVEL_HIGH | Photo quality.            |
| rotation | [ImageRotation](#imagerotation) | No  | ROTATION_0         | Rotation angle of the photo.        |
| location | [Location](#location)           | No  | (0,0,0)            | Geolocation information of the photo.    |
| mirror   | boolean                         | No  | false              | Whether mirroring is enabled. By default, mirroring is disabled.|

## PhotoOutput

Implements output information used in a **CaptureSession**.

### getDefaultCaptureSetting

getDefaultCaptureSetting(callback: AsyncCallback<PhotoCaptureSetting\>): void

Obtains the default shooting parameters. This API uses an asynchronous callback to return the result.

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

**Parameters**

| Name    | Type                                                       | Mandatory| Description                    |
| -------- | ----------------------------------------------------------- | ---- | ------------------------ |
| callback | AsyncCallback<[PhotoCaptureSetting](#photocapturesetting)\> | Yes  | Callback used to return the result.|

**Example**

```js
photoOutput.getDefaultCaptureSetting((err, photocapturesetting) => {
    if (err) {
3737
        console.error(`Failed to get the defaultCaptureSetting. ${err.message}`);
W
wusongqing 已提交
3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784
        return;
    }
    console.log('Callback returned with an array of defaultCaptureSetting.');
})
```

### getDefaultCaptureSetting

getDefaultCaptureSetting(): Promise<PhotoCaptureSetting\>

Obtains the default shooting parameters. This API uses a promise to return the result.

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

**Return value**

| Type                                                 | Description                       |
| ----------------------------------------------------- | --------------------------- |
| Promise<[PhotoCaptureSetting](#photocapturesetting)\> | Promise used to return the result.|

**Example**

```js
photoOutput.getDefaultCaptureSetting().then((photocapturesetting) => {
    console.log('Callback returned with an array of defaultCaptureSetting.');
})
```

### capture

capture(callback: AsyncCallback<void\>): void

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

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

**Parameters**

| Name    | Type                | Mandatory| Description                    |
| -------- | -------------------- | ---- | ------------------------ |
| callback | AsyncCallback<void\> | Yes  | Callback used to return the result.|

**Example**

```js
photoOutput.capture((err) => {
    if (err) {
3785
        console.error(`Failed to capture the photo ${err.message}`);
W
wusongqing 已提交
3786 3787 3788 3789 3790 3791 3792
        return;
    }
    console.log('Callback invoked to indicate the photo capture request success.');
});
```

### capture
N
nikhilraut 已提交
3793

W
wusongqing 已提交
3794
capture(setting: PhotoCaptureSetting, callback: AsyncCallback<void\>): void
N
nikhilraut 已提交
3795

W
wusongqing 已提交
3796
Captures a photo with the specified shooting parameters. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
3797

W
wusongqing 已提交
3798
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
3799 3800 3801

**Parameters**

W
wusongqing 已提交
3802 3803 3804 3805
| Name    | Type                                       | Mandatory| Description                    |
| -------- | ------------------------------------------- | ---- | ------------------------ |
| setting  | [PhotoCaptureSetting](#photocapturesetting) | Yes  | Shooting settings.              |
| callback | AsyncCallback<void\>                        | Yes  | Callback used to return the result.|
N
nikhilraut 已提交
3806 3807 3808

**Example**

W
wusongqing 已提交
3809
```js
W
wusongqing 已提交
3810 3811 3812 3813 3814
let settings:PhotoCaptureSetting = {
    quality = 1,
    rotation = 0
}
photoOutput.capture(settings, (err) => {
N
nikhilraut 已提交
3815
    if (err) {
3816
        console.error(`Failed to capture the photo ${err.message}`);
N
nikhilraut 已提交
3817 3818
        return;
    }
W
wusongqing 已提交
3819
    console.log('Callback invoked to indicate the photo capture request success.');
N
nikhilraut 已提交
3820
});
W
wusongqing 已提交
3821
```
N
nikhilraut 已提交
3822

W
wusongqing 已提交
3823
### capture
N
nikhilraut 已提交
3824

W
wusongqing 已提交
3825
capture(setting?: PhotoCaptureSetting): Promise<void\>
N
nikhilraut 已提交
3826

W
wusongqing 已提交
3827
Captures a photo with the specified shooting parameters. This API uses a promise to return the result.
N
nikhilraut 已提交
3828

W
wusongqing 已提交
3829
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
3830 3831 3832

**Parameters**

W
wusongqing 已提交
3833 3834 3835
| Name   | Type                                       | Mandatory| Description      |
| ------- | ------------------------------------------- | ---- | ---------- |
| setting | [PhotoCaptureSetting](#photocapturesetting) | No  | Shooting settings.|
N
nikhilraut 已提交
3836

W
wusongqing 已提交
3837
**Return value**
N
nikhilraut 已提交
3838

W
wusongqing 已提交
3839 3840 3841 3842
| Type          | Description                       |
| -------------- | --------------------------- |
| Promise<void\>| Promise used to return the result.|

N
nikhilraut 已提交
3843 3844 3845

**Example**

W
wusongqing 已提交
3846
```js
W
wusongqing 已提交
3847 3848
photoOutput.capture().then(() => {
    console.log('Promise returned to indicate that photo capture request success.');
N
nikhilraut 已提交
3849 3850 3851
})
```

W
wusongqing 已提交
3852 3853 3854 3855 3856
### isMirrorSupported

isMirrorSupported(callback: AsyncCallback<boolean\>): void

Checks whether mirroring is supported. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
3857

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

W
wusongqing 已提交
3860
**Parameters**
N
nikhilraut 已提交
3861

W
wusongqing 已提交
3862 3863 3864
| Name    | Type                   | Mandatory| Description                           |
| -------- | ----------------------- | ---- | ------------------------------- |
| callback | AsyncCallback<boolean\> | Yes  | Callback used to return the mirroring support status. The value **true** means that mirroring is supported, and **false** means the opposite.|
N
nikhilraut 已提交
3865

W
wusongqing 已提交
3866 3867 3868 3869 3870
**Example**

```js
captureSession.isMirrorSupported((err, isSupported) => {
    if (err) {
3871
        console.error(`Failed to check mirror is supported ${err.message}`);
W
wusongqing 已提交
3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882
        return;
    }
    console.log('Callback returned with the successful execution of isMirrorSupported.');
})
```

### isMirrorSupported

isMirrorSupported(): Promise<boolean\>

Checks whether mirroring is supported. This API uses a promise to return the result.
N
nikhilraut 已提交
3883

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

W
wusongqing 已提交
3886 3887 3888 3889 3890 3891 3892 3893 3894 3895
**Return value**

| Type             | Description                                             |
| ----------------- | ------------------------------------------------- |
| Promise<boolean\> | Promise used to return the mirroring support status. The value **true** means that mirroring is supported, and **false** means the opposite.|

**Example**

```js
captureSession.isMirrorSupported().then((isSupported) => {
3896
    console.log(`Promise returned with mirror supported: ${isSupported}`);
W
wusongqing 已提交
3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918
})
```

### on('captureStart')

on(type: 'captureStart', callback: AsyncCallback<number\>): void

Listens for shooting start events. This API uses an asynchronous callback to return the capture ID.

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

**Parameters**

| Name    | Type                  | Mandatory| Description                                            |
| -------- | ---------------------- | ---- | ------------------------------------------------ |
| type     | string                 | Yes  | Event type. The value is fixed at **captureStart**, indicating the shooting start event.|
| callback | AsyncCallback<number\> | Yes  | Callback used to return the capture ID.              |

**Example**

```js
photoOutput.on('captureStart', (err, captureId) => {
3919
    console.log(`photo capture stated, captureId : ${captureId}`);
W
wusongqing 已提交
3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941
})
```

### on('frameShutter')

on(type: 'frameShutter', callback: AsyncCallback<FrameShutterInfo\>): void

Listens for frame shutter events. This API uses an asynchronous callback to return the event information.

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

**Parameters**

| Name    | Type                                                 | Mandatory| Description                                          |
| -------- | ----------------------------------------------------- | ---- | ---------------------------------------------- |
| type     | string                                                | Yes  | Event type. The value is fixed at **frameShutter**, indicating the frame shutter event.|
| callback | AsyncCallback<[FrameShutterInfo](#frameshutterinfo)\> | Yes  | Callback used to return the result.                  |

**Example**

```js
photoOutput.on('frameShutter', (err, frameShutterInfo) => {
3942 3943
    console.log(`photo capture end, captureId : ${frameShutterInfo.captureId}`);
    console.log(`Timestamp for frame : ${frameShutterInfo.timestamp}`);
W
wusongqing 已提交
3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965
})
```

### on('captureEnd')

on(type: 'captureEnd', callback: AsyncCallback<CaptureEndInfo\>): void

Listens for shooting end events. This API uses an asynchronous callback to return the event information.

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

**Parameters**

| Name    | Type                                             | Mandatory| Description                                          |
| -------- | ------------------------------------------------- | ---- | ---------------------------------------------- |
| type     | string                                            | Yes  | Event type. The value is fixed at **captureEnd**, indicating the shooting end event.|
| callback | AsyncCallback<[CaptureEndInfo](#captureendinfo)\> | Yes  | Callback used to return the result.                  |

**Example**

```js
photoOutput.on('captureEnd', (err, captureEndInfo) => {
3966 3967
    console.log(`photo capture end, captureId : ${captureEndInfo.captureId}`);
    console.log(`frameCount : ${captureEndInfo.frameCount}`);
W
wusongqing 已提交
3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989
})
```

### on('error')

on(type: 'error', callback: ErrorCallback<PhotoOutputError\>): void

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

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

**Parameters**

| Name    | Type                                                 | Mandatory| Description                                     |
| -------- | ----------------------------------------------------- | ---- | ----------------------------------------- |
| type     | string                                                | Yes  | Event type. The value is fixed at **error**, indicating the photo output error event.|
| callback | ErrorCallback<[PhotoOutputError](#photooutputerror)\> | Yes  | Callback used to return the error information.             |

**Example**

```js
photoOutput.on('error', (err, photoOutputError) => {
3990
    console.log(`Photo output error code: ${photoOutputError.code}`);
W
wusongqing 已提交
3991 3992 3993 3994 3995 3996 3997 3998
})
```

## FrameShutterInfo

Defines the frame shutter information.

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

W
wusongqing 已提交
4000 4001 4002 4003
| 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 已提交
4004

W
wusongqing 已提交
4005
## CaptureEndInfo
N
nikhilraut 已提交
4006

W
wusongqing 已提交
4007
Defines the capture end information.
N
nikhilraut 已提交
4008

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

W
wusongqing 已提交
4011 4012 4013 4014
| Name      | Type  | Mandatory| Description      |
| ---------- | ------ | ---- | ---------- |
| captureId  | number | Yes  | ID of this capture action.|
| frameCount | number | Yes  | Number of frames captured.    |
N
nikhilraut 已提交
4015

W
wusongqing 已提交
4016
## PhotoOutputErrorCode
N
nikhilraut 已提交
4017

W
wusongqing 已提交
4018
Enumerates the error codes used for photo output.
N
nikhilraut 已提交
4019

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

W
wusongqing 已提交
4022 4023 4024 4025 4026 4027
| Name                        | Value  | Description              |
| ---------------------------- | ---- | ------------------ |
| ERROR_UNKNOWN                | -1   | Unknown error.        |
| ERROR_DRIVER_ERROR           | 0    | The driver or hardware is faulty.|
| ERROR_INSUFFICIENT_RESOURCES | 1    | Insufficient resources.        |
| ERROR_TIMEOUT                | 2    | Timeout.            |
N
nikhilraut 已提交
4028

W
wusongqing 已提交
4029
## PhotoOutputError
N
nikhilraut 已提交
4030

W
wusongqing 已提交
4031
Defines a photo output error.
N
nikhilraut 已提交
4032

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

W
wusongqing 已提交
4035 4036 4037
| Name| Type                                 | Description                   |
| ---- | ------------------------------------- | ----------------------- |
| code | [PhotoOutputError](#photooutputerror) | **PhotoOutput** error code.|
N
nikhilraut 已提交
4038

W
wusongqing 已提交
4039
## VideoOutput
N
nikhilraut 已提交
4040

W
wusongqing 已提交
4041
Implements output information used in a video recording session.
N
nikhilraut 已提交
4042

W
wusongqing 已提交
4043
### start
N
nikhilraut 已提交
4044

W
wusongqing 已提交
4045
start(callback: AsyncCallback<void\>): void
N
nikhilraut 已提交
4046

W
wusongqing 已提交
4047
Starts video recording. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
4048

W
wusongqing 已提交
4049
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
4050 4051 4052

**Parameters**

W
wusongqing 已提交
4053 4054 4055
| Name    | Type                | Mandatory| Description                    |
| -------- | -------------------- | ---- | ------------------------ |
| callback | AsyncCallback<void\> | Yes  | Callback used to return the result.|
N
nikhilraut 已提交
4056 4057 4058

**Example**

W
wusongqing 已提交
4059
```js
W
wusongqing 已提交
4060
videoOutput.start((err) => {
N
nikhilraut 已提交
4061
    if (err) {
4062
        console.error(`Failed to start the video output ${err.message}`);
N
nikhilraut 已提交
4063 4064
        return;
    }
W
wusongqing 已提交
4065
    console.log('Callback invoked to indicate the video output start success.');
N
nikhilraut 已提交
4066 4067 4068
});
```

W
wusongqing 已提交
4069
### start
N
nikhilraut 已提交
4070

W
wusongqing 已提交
4071
start(): Promise<void\>
N
nikhilraut 已提交
4072

W
wusongqing 已提交
4073
Starts video recording. This API uses a promise to return the result.
N
nikhilraut 已提交
4074

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

W
wusongqing 已提交
4077
**Return value**
N
nikhilraut 已提交
4078

W
wusongqing 已提交
4079 4080
| Type          | Description                       |
| -------------- | --------------------------- |
W
wusongqing 已提交
4081
| Promise<void\>| Promise used to return the result.|
N
nikhilraut 已提交
4082 4083 4084 4085


**Example**

W
wusongqing 已提交
4086
```js
W
wusongqing 已提交
4087 4088
videoOutput.start().then(() => {
    console.log('Promise returned to indicate that start method execution success.');
N
nikhilraut 已提交
4089 4090 4091
})
```

W
wusongqing 已提交
4092
### stop
N
nikhilraut 已提交
4093

W
wusongqing 已提交
4094
stop(callback: AsyncCallback<void\>): void
N
nikhilraut 已提交
4095

W
wusongqing 已提交
4096
Stops video recording. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
4097

W
wusongqing 已提交
4098
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
4099 4100 4101

**Parameters**

W
wusongqing 已提交
4102 4103 4104
| Name    | Type                | Mandatory| Description                    |
| -------- | -------------------- | ---- | ------------------------ |
| callback | AsyncCallback<void\> | Yes  | Callback used to return the result.|
N
nikhilraut 已提交
4105 4106 4107

**Example**

W
wusongqing 已提交
4108
```js
W
wusongqing 已提交
4109
videoOutput.stop((err) => {
N
nikhilraut 已提交
4110
    if (err) {
4111
        console.error(`Failed to stop the video output ${err.message}`);
N
nikhilraut 已提交
4112 4113
        return;
    }
W
wusongqing 已提交
4114
    console.log('Callback invoked to indicate the video output stop success.');
N
nikhilraut 已提交
4115 4116 4117
});
```

W
wusongqing 已提交
4118
### stop
N
nikhilraut 已提交
4119

W
wusongqing 已提交
4120
stop(): Promise<void\>
N
nikhilraut 已提交
4121

W
wusongqing 已提交
4122
Stops video recording. This API uses a promise to return the result.
N
nikhilraut 已提交
4123

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

W
wusongqing 已提交
4126
**Return value**
N
nikhilraut 已提交
4127

W
wusongqing 已提交
4128 4129
| Type          | Description                       |
| -------------- | --------------------------- |
W
wusongqing 已提交
4130
| Promise<void\>| Promise used to return the result.|
N
nikhilraut 已提交
4131 4132 4133

**Example**

W
wusongqing 已提交
4134
```js
W
wusongqing 已提交
4135 4136
videoOutput.stop().then(() => {
    console.log('Promise returned to indicate that stop method execution success.');
N
nikhilraut 已提交
4137 4138 4139
})
```

W
wusongqing 已提交
4140
### on('frameStart')
N
nikhilraut 已提交
4141

W
wusongqing 已提交
4142
on(type: 'frameStart', callback: AsyncCallback<void\>): void
N
nikhilraut 已提交
4143

W
wusongqing 已提交
4144
Listens for video recording start events. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
4145

W
wusongqing 已提交
4146
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
4147 4148 4149

**Parameters**

W
wusongqing 已提交
4150 4151 4152 4153
| Name    | Type                | Mandatory| Description                                            |
| -------- | -------------------- | ---- | ------------------------------------------------ |
| type     | string               | Yes  | Event type. The value is fixed at **frameStart**, indicating the video recording start event.|
| callback | AsyncCallback<void\> | Yes  | Callback used to return the result.                        |
N
nikhilraut 已提交
4154 4155 4156

**Example**

W
wusongqing 已提交
4157
```js
W
wusongqing 已提交
4158 4159
videoOutput.on('frameStart', () => {
    console.log('Video frame started');
N
nikhilraut 已提交
4160 4161 4162
})
```

W
wusongqing 已提交
4163
### on('frameEnd')
N
nikhilraut 已提交
4164

W
wusongqing 已提交
4165
on(type: 'frameEnd', callback: AsyncCallback<void\>): void
N
nikhilraut 已提交
4166

W
wusongqing 已提交
4167
Listens for video recording stop events. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
4168

W
wusongqing 已提交
4169
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
4170 4171 4172

**Parameters**

W
wusongqing 已提交
4173 4174 4175 4176
| Name    | Type                | Mandatory| Description                                            |
| -------- | -------------------- | ---- | ------------------------------------------------ |
| type     | string               | Yes  | Event type. The value is fixed at **'frameEnd'**, indicating the video recording stop event.|
| callback | AsyncCallback<void\> | Yes  | Callback used to return the result.                        |
N
nikhilraut 已提交
4177 4178 4179

**Example**

W
wusongqing 已提交
4180
```js
W
wusongqing 已提交
4181 4182
videoOutput.on('frameEnd', () => {
    console.log('Video frame ended');
N
nikhilraut 已提交
4183 4184 4185
})
```

W
wusongqing 已提交
4186
### on('error')
N
nikhilraut 已提交
4187

W
wusongqing 已提交
4188
on(type: 'error', callback: ErrorCallback<VideoOutputError\>): void
N
nikhilraut 已提交
4189

W
wusongqing 已提交
4190
Listens for errors that occur during video recording. This API uses a callback to return the result.
N
nikhilraut 已提交
4191

W
wusongqing 已提交
4192
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
4193 4194 4195

**Parameters**

W
wusongqing 已提交
4196 4197 4198 4199
| Name    | Type                                            | Mandatory| Description                                         |
| -------- | ------------------------------------------------ | ---- | --------------------------------------------- |
| type     | string                                           | Yes  | Event type. The value is fixed at **error**, indicating the video output error event.|
| callback | Callback<[VideoOutputError](#videooutputerror)\> | Yes  | Callback used to return the error information.                 |
N
nikhilraut 已提交
4200 4201 4202

**Example**

W
wusongqing 已提交
4203
```js
W
wusongqing 已提交
4204
videoOutput.on('error', (VideoOutputError) => {
4205
    console.log(`Video output error code: ${VideoOutputError.code}`);
N
nikhilraut 已提交
4206 4207 4208
})
```

W
wusongqing 已提交
4209
## VideoOutputErrorCode
N
nikhilraut 已提交
4210

W
wusongqing 已提交
4211
Enumerates the error codes used for video recording.
N
nikhilraut 已提交
4212

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

W
wusongqing 已提交
4215 4216 4217 4218
| Name              | Value  | Description              |
| ------------------ | ---- | ------------------ |
| ERROR_UNKNOWN      | -1   | Unknown error.        |
| ERROR_DRIVER_ERROR | 0    | The driver or hardware is faulty.|
N
nikhilraut 已提交
4219

W
wusongqing 已提交
4220
## VideoOutputError
4221

W
wusongqing 已提交
4222
Defines a video output error.
4223

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

W
wusongqing 已提交
4226 4227 4228
| Name| Type                                 | Description                   |
| ---- | ------------------------------------- | ----------------------- |
| code | [PhotoOutputError](#photooutputerror) | **VideoOutput** error code.|
4229

W
wusongqing 已提交
4230
## MetadataObjectType
4231

W
wusongqing 已提交
4232
Enumerates metadata streams.
4233

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

W
wusongqing 已提交
4236 4237 4238
| Name          | Value  | Description              |
| -------------- | ---- | ------------------ |
| FACE_DETECTION | 0    | Metadata object type.|
4239

W
wusongqing 已提交
4240
## Rect
4241

W
wusongqing 已提交
4242
Defines a rectangle.
4243 4244 4245

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

W
wusongqing 已提交
4246 4247 4248 4249 4250 4251
| Name    | Type  | Description                 |
| -------- | ------ | --------------------- |
| topLeftX | number | X-axis coordinate of the upper left corner of the rectangle.|
| topLeftY | number | Y-axis coordinate of the upper left corner of the rectangle.|
| width    | number | Width of the rectangle.             |
| height   | number | Height of the rectangle.             |
4252

W
wusongqing 已提交
4253
## MetadataObject
4254

W
wusongqing 已提交
4255
Implements camera metadata, which is the data source of **[CameraInput](#camerainput)**.
4256

W
wusongqing 已提交
4257
### getType
N
nikhilraut 已提交
4258

W
wusongqing 已提交
4259
getType(callback: AsyncCallback<MetadataObjectType\>): void
N
nikhilraut 已提交
4260

W
wusongqing 已提交
4261
Obtains the metadata object type. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
4262

W
wusongqing 已提交
4263
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
4264 4265 4266

**Parameters**

W
wusongqing 已提交
4267 4268
| Name    | Type                                                     | Mandatory| Description                    |
| -------- | --------------------------------------------------------- | ---- | ------------------------ |
J
jiangminyang 已提交
4269
| callback | AsyncCallback<[MetadataObjectType](#metadataobjecttype)\> | Yes  | Callback used to return the result.|
N
nikhilraut 已提交
4270 4271 4272

**Example**

W
wusongqing 已提交
4273
```js
W
wusongqing 已提交
4274
metadataObject.getType((err, metadataObjectType) => {
N
nikhilraut 已提交
4275
    if (err) {
4276
        console.error(`Failed to get type. ${err.message}`);
N
nikhilraut 已提交
4277 4278
        return;
    }
W
wusongqing 已提交
4279 4280
    console.log('Callback returned with an array of metadataObjectType.');
})
W
wusongqing 已提交
4281
```
N
nikhilraut 已提交
4282

W
wusongqing 已提交
4283
### getType
N
nikhilraut 已提交
4284

W
wusongqing 已提交
4285
getType(): Promise<MetadataObjectType\>
N
nikhilraut 已提交
4286

W
wusongqing 已提交
4287
Obtains the metadata object type. This API uses a promise to return the result.
N
nikhilraut 已提交
4288

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

W
wusongqing 已提交
4291
**Return value**
N
nikhilraut 已提交
4292

W
wusongqing 已提交
4293 4294
| Type                                               | Description                       |
| --------------------------------------------------- | --------------------------- |
J
jiangminyang 已提交
4295
| Promise<[MetadataObjectType](#metadataobjecttype)\> | Promise used to return the result.|
N
nikhilraut 已提交
4296 4297 4298

**Example**

W
wusongqing 已提交
4299
```js
W
wusongqing 已提交
4300 4301
metadataObject.getType().then((metadataObjectType) => {
    console.log('Callback returned with an array of metadataObjectType.');
N
nikhilraut 已提交
4302 4303
})
```
W
wusongqing 已提交
4304

W
wusongqing 已提交
4305
### getTimestamp
N
nikhilraut 已提交
4306

W
wusongqing 已提交
4307
getTimestamp(callback: AsyncCallback<number\>): void
N
nikhilraut 已提交
4308

W
wusongqing 已提交
4309
Obtains the metadata timestamp. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
4310

W
wusongqing 已提交
4311
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
4312 4313 4314

**Parameters**

W
wusongqing 已提交
4315 4316 4317
| Name    | Type                  | Mandatory| Description                    |
| -------- | ---------------------- | ---- | ------------------------ |
| callback | AsyncCallback<number\> | Yes  | Callback used to return the result.|
N
nikhilraut 已提交
4318 4319 4320

**Example**

W
wusongqing 已提交
4321
```js
W
wusongqing 已提交
4322
metadataObject.getTimestamp((err) => {
N
nikhilraut 已提交
4323
    if (err) {
4324
        console.error(`Failed to get timestamp. ${err.message}`);
N
nikhilraut 已提交
4325 4326
        return;
    }
W
wusongqing 已提交
4327 4328
    console.log('Callback returned with timestamp getted.');
})
N
nikhilraut 已提交
4329 4330
```

W
wusongqing 已提交
4331
### getTimestamp
N
nikhilraut 已提交
4332

W
wusongqing 已提交
4333
getTimestamp(): Promise<number\>
N
nikhilraut 已提交
4334

W
wusongqing 已提交
4335
Obtains the metadata timestamp. This API uses a promise to return the result.
N
nikhilraut 已提交
4336

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

W
wusongqing 已提交
4339
**Return value**
N
nikhilraut 已提交
4340

W
wusongqing 已提交
4341 4342 4343
| Type             | Description                       |
| ----------------- | --------------------------- |
| Promise<number)\> | Promise used to return the result.|
N
nikhilraut 已提交
4344 4345 4346

**Example**

W
wusongqing 已提交
4347
```js
W
wusongqing 已提交
4348 4349
metadataObject.getTimestamp().then(() => {
    console.log('Callback returned with timestamp getted.');
N
nikhilraut 已提交
4350 4351 4352
})
```

W
wusongqing 已提交
4353
### getBoundingBox
N
nikhilraut 已提交
4354

W
wusongqing 已提交
4355
getBoundingBox(callback: AsyncCallback<Rect\>): void
N
nikhilraut 已提交
4356

W
wusongqing 已提交
4357
Obtains the bounding box of metadata. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
4358

W
wusongqing 已提交
4359
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
4360 4361 4362

**Parameters**

W
wusongqing 已提交
4363 4364 4365
| Name    | Type                         | Mandatory| Description                    |
| -------- | ----------------------------- | ---- | ------------------------ |
| callback | AsyncCallback<[Rect](#rect)\> | Yes  | Callback used to return the result.|
N
nikhilraut 已提交
4366 4367 4368

**Example**

W
wusongqing 已提交
4369
```js
W
wusongqing 已提交
4370
metadataObject.getBoundingBox((err, rect) => {
N
nikhilraut 已提交
4371
    if (err) {
4372
        console.error(`Failed to get boundingBox. ${err.message}`);
N
nikhilraut 已提交
4373 4374
        return;
    }
W
wusongqing 已提交
4375 4376
    console.log('Callback returned with boundingBox getted.');
})
N
nikhilraut 已提交
4377 4378
```

W
wusongqing 已提交
4379
### getBoundingBox
N
nikhilraut 已提交
4380

W
wusongqing 已提交
4381
getBoundingBox(): Promise<Rect\>
N
nikhilraut 已提交
4382

W
wusongqing 已提交
4383
Obtains the bounding box of metadata. This API uses a promise to return the result.
N
nikhilraut 已提交
4384

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

W
wusongqing 已提交
4387
**Return value**
N
nikhilraut 已提交
4388

W
wusongqing 已提交
4389 4390 4391
| Type                   | Description                       |
| ----------------------- | --------------------------- |
| Promise<[Rect](#rect)\> | Promise used to return the result.|
N
nikhilraut 已提交
4392 4393 4394

**Example**

W
wusongqing 已提交
4395
```js
W
wusongqing 已提交
4396 4397
metadataObject.getBoundingBox().then((rect) => {
    console.log('Callback returned with boundingBox getted.');
N
nikhilraut 已提交
4398 4399 4400
})
```

W
wusongqing 已提交
4401
## MetadataFaceObject
N
nikhilraut 已提交
4402

W
wusongqing 已提交
4403 4404 4405 4406 4407 4408 4409 4410 4411
Implements the face object of metadata. It inherits **[MetadataObject](#metadataobject)**.

## MetadataOutput

Implements metadata stream. It inherits **[CameraOutput](#cameraoutput)**.

### start

start(callback: AsyncCallback<void\>): void
N
nikhilraut 已提交
4412

W
wusongqing 已提交
4413
Starts to output metadata. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
4414

W
wusongqing 已提交
4415
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
4416 4417 4418

**Parameters**

W
wusongqing 已提交
4419 4420 4421
| Name    | Type                | Mandatory| Description                    |
| -------- | -------------------- | ---- | ------------------------ |
| callback | AsyncCallback<void\> | Yes  | Callback used to return the result.|
N
nikhilraut 已提交
4422 4423 4424

**Example**

W
wusongqing 已提交
4425
```js
W
wusongqing 已提交
4426
metadataOutput.start((err) => {
N
nikhilraut 已提交
4427
    if (err) {
4428
        console.error(`Failed to start metadataOutput. ${err.message}`);
N
nikhilraut 已提交
4429 4430
        return;
    }
W
wusongqing 已提交
4431 4432
    console.log('Callback returned with metadataOutput started.');
})
N
nikhilraut 已提交
4433 4434
```

W
wusongqing 已提交
4435
### start
N
nikhilraut 已提交
4436

W
wusongqing 已提交
4437
start(): Promise<void\>
N
nikhilraut 已提交
4438

W
wusongqing 已提交
4439
Starts to output metadata. This API uses a promise to return the result.
N
nikhilraut 已提交
4440

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

W
wusongqing 已提交
4443
**Return value**
N
nikhilraut 已提交
4444

W
wusongqing 已提交
4445 4446
| Type          | Description                       |
| -------------- | --------------------------- |
W
wusongqing 已提交
4447
| Promise<void\>| Promise used to return the result.|
N
nikhilraut 已提交
4448 4449 4450

**Example**

W
wusongqing 已提交
4451
```js
W
wusongqing 已提交
4452 4453
metadataOutput.start().then(() => {
    console.log('Callback returned with metadataOutput started.');
N
nikhilraut 已提交
4454
})
N
nikhilraut 已提交
4455 4456
```

W
wusongqing 已提交
4457
### stop
N
nikhilraut 已提交
4458

W
wusongqing 已提交
4459
stop(callback: AsyncCallback<void\>): void
N
nikhilraut 已提交
4460

W
wusongqing 已提交
4461
Stops outputting metadata. This API uses an asynchronous callback to return the result.
N
nikhilraut 已提交
4462

W
wusongqing 已提交
4463
**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
4464 4465 4466

**Parameters**

W
wusongqing 已提交
4467 4468 4469
| Name    | Type                | Mandatory| Description                    |
| -------- | -------------------- | ---- | ------------------------ |
| callback | AsyncCallback<void\> | Yes  | Callback used to return the result.|
N
nikhilraut 已提交
4470 4471 4472

**Example**

W
wusongqing 已提交
4473
```js
W
wusongqing 已提交
4474 4475
metadataOutput.stop((err) => {
    if (err) {
4476
        console.error(`Failed to stop the metadataOutput. ${err.message}`);
W
wusongqing 已提交
4477 4478 4479
        return;
    }
    console.log('Callback returned with metadataOutput stoped.');
N
nikhilraut 已提交
4480 4481 4482
})
```

W
wusongqing 已提交
4483
### stop
W
wusongqing 已提交
4484

W
wusongqing 已提交
4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503
stop(): Promise<void\>

Stops outputting metadata. This API uses a promise to return the result.

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

**Return value**

| Type          | Description                       |
| -------------- | --------------------------- |
| Promise<void\>| Promise used to return the result.|

**Example**

```js
metadataOutput.stop().then(() => {
    console.log('Callback returned with metadataOutput stoped.');
})
```
N
nikhilraut 已提交
4504

W
wusongqing 已提交
4505 4506 4507 4508 4509
### on('metadataObjectsAvailable')

on(type: 'metadataObjectsAvailable', callback: AsyncCallback<Array<MetadataObject\>\>): void

Listens for metadata objects. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
4510 4511

**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
4512 4513 4514

**Parameters**

W
wusongqing 已提交
4515 4516 4517
| Name    | Type                                                | Mandatory| Description                                                        |
| -------- | ---------------------------------------------------- | ---- | ------------------------------------------------------------ |
| type     | string                                               | Yes  | Event type. The value is fixed at **'metadataObjectsAvailable'**, that is, the metadata object.|
J
jiangminyang 已提交
4518
| callback | Callback<Array<[MetadataObject](#metadataobject)\>\> | Yes  | Callback used to return the error information.                                |
N
nikhilraut 已提交
4519 4520 4521

**Example**

W
wusongqing 已提交
4522
```js
W
wusongqing 已提交
4523
metadataOutput.on('metadataObjectsAvailable', (metadataObject) => {
4524
    console.log(`metadata output error code: ${metadataObject.code}`);
N
nikhilraut 已提交
4525 4526 4527
})
```

W
wusongqing 已提交
4528 4529
### on('error')

W
wusongqing 已提交
4530
on(tuype: 'error', callback: ErrorCallback<MetadataOutputError\>): void
N
nikhilraut 已提交
4531

W
wusongqing 已提交
4532
Listens for metadata errors. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
4533 4534

**System capability**: SystemCapability.Multimedia.Camera.Core
N
nikhilraut 已提交
4535 4536 4537

**Parameters**

W
wusongqing 已提交
4538 4539 4540
| Name    | Type                                                  | Mandatory| Description                                         |
| -------- | ------------------------------------------------------ | ---- | --------------------------------------------- |
| type     | string                                                 | Yes  | Event type. The value is fixed at **'error'**, that is, the metadata error.|
J
jiangminyang 已提交
4541
| callback | Callback<[MetadataOutputError](#metadataoutputerror)\> | Yes  | Callback used to return the error information.                 |
N
nikhilraut 已提交
4542 4543 4544

**Example**

W
wusongqing 已提交
4545
```js
W
wusongqing 已提交
4546
metadataOutput.on('error', (metadataOutputError) => {
4547
    console.log(`Metadata output error code: ${metadataOutputError.code}`);
N
nikhilraut 已提交
4548
})
W
wusongqing 已提交
4549
```
4550

W
wusongqing 已提交
4551
## MetadataOutputErrorCode
4552

W
wusongqing 已提交
4553
Enumerates the error codes used for metadata output.
4554 4555 4556

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

W
wusongqing 已提交
4557 4558 4559 4560
| Name                        | Value  | Description      |
| ---------------------------- | ---- | ---------- |
| ERROR_UNKNOWN                | -1   | Unknown error.|
| ERROR_INSUFFICIENT_RESOURCES | 0    | Insufficient resources.|
4561

W
wusongqing 已提交
4562
## MetadataOutputError
4563

W
wusongqing 已提交
4564
Defines a metadata output error.
4565 4566 4567

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

W
wusongqing 已提交
4568 4569
| Name| Type                                               | Description                      |
| ---- | --------------------------------------------------- | -------------------------- |
J
jiangminyang 已提交
4570
| code | [MetadataOutputErrorCode](#metadataoutputerrorcode) | **MetadataOutput** error code.|