• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.multimedia.camera (相机管理)
2
3本模块为开发者提供了一套简单易懂的相机服务接口。通过调用这些接口,开发者可以开发相机应用,访问和操作相机硬件,实现基础功能如预览、拍照和录像。此外,还可以通过接口组合完成更多操作,如控制闪光灯、曝光时间和对焦等。
4
5> **说明:**
6>
7> 本模块首批接口从API version 10开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
8
9## 导入模块
10
11```ts
12import { camera } from '@kit.CameraKit';
13```
14
15## camera.getCameraManager
16
17getCameraManager(context: Context): CameraManager
18
19获取相机管理器实例,同步返回结果。
20
21**系统能力:** SystemCapability.Multimedia.Camera.Core
22
23**参数:**
24
25| 参数名     | 类型                                             | 必填 | 说明                           |
26| -------- | ----------------------------------------------- | ---- | ---------------------------- |
27| context  | [Context](../apis-ability-kit/js-apis-inner-application-baseContext.md)      | 是   | 应用上下文。                   |
28
29**返回值:**
30
31| 类型                                             | 说明                           |
32| ----------------------------------------------- | ---------------------------- |
33| [CameraManager](#cameramanager)           | 相机管理器。                   |
34
35**错误码:**
36
37以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
38
39| 错误码ID         | 错误信息        |
40| --------------- | --------------- |
41| 7400101                |  Parameter missing or parameter type incorrect.               |
42| 7400201                |  Camera service fatal error.                                  |
43
44**示例:**
45
46```ts
47import { common } from '@kit.AbilityKit';
48import { BusinessError } from '@kit.BasicServicesKit';
49
50function getCameraManager(context: common.BaseContext): camera.CameraManager | undefined {
51  let cameraManager: camera.CameraManager | undefined = undefined;
52  try {
53    cameraManager = camera.getCameraManager(context);
54  } catch (error) {
55    let err = error as BusinessError;
56    console.error(`The getCameraManager call failed. error code: ${err.code}`);
57  }
58  return cameraManager;
59}
60```
61
62## CameraDevice
63
64相机设备信息。
65
66**系统能力:** SystemCapability.Multimedia.Camera.Core
67
68| 名称                              | 类型                                  | 只读 | 可选 | 说明        |
69|---------------------------------|-------------------------------------| ---- |----|---------- |
70| cameraId                        | string                              | 是   | 否  | 相机ID。|
71| cameraPosition                  | [CameraPosition](#cameraposition)   | 是   | 否  | 相机位置。    |
72| cameraType                      | [CameraType](#cameratype)           | 是   | 否  | 相机类型。    |
73| connectionType                  | [ConnectionType](#connectiontype)   | 是   | 否  | 相机连接类型。 |
74| cameraOrientation<sup>12+</sup> | number                              | 是   | 否  | 相机安装角度,不会随着屏幕旋转而改变,取值范围为0°-360°,单位:度。 |
75| hostDeviceName<sup>15+</sup>    | string                              | 是   | 否  | 远端设备名称。 |
76| hostDeviceType<sup>15+</sup>    | [HostDeviceType](#hostdevicetype15) | 是   | 否  | 远端设备类型。 |
77
78## CameraPosition
79
80枚举,相机位置。
81
82**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
83
84**系统能力:** SystemCapability.Multimedia.Camera.Core
85
86| 名称                         | 值   | 说明                                                              |
87| --------------------------- | ---- |-----------------------------------------------------------------|
88| CAMERA_POSITION_UNSPECIFIED | 0    | 相对于设备屏幕没有固定的朝向的相机。                                                        |
89| CAMERA_POSITION_BACK        | 1    | 后置相机。                                                           |
90| CAMERA_POSITION_FRONT       | 2    | 前置相机。                                                           |
91| CAMERA_POSITION_FOLD_INNER<sup>(deprecated)</sup>  | 3    | 折叠态相机。<br/> 从API version 11开始支持,从API version 12开始废弃。 |
92
93## CameraType
94
95枚举,相机类型。
96
97**系统能力:** SystemCapability.Multimedia.Camera.Core
98
99| 名称                     | 值   | 说明            |
100| ----------------------- | ---- | -------------- |
101| CAMERA_TYPE_DEFAULT     | 0    | 相机类型未指定。  |
102| CAMERA_TYPE_WIDE_ANGLE  | 1    | 广角相机。       |
103| CAMERA_TYPE_ULTRA_WIDE  | 2    | 超广角相机。     |
104| CAMERA_TYPE_TELEPHOTO   | 3    | 长焦相机。       |
105| CAMERA_TYPE_TRUE_DEPTH  | 4    | 带景深信息的相机。 |
106
107## ConnectionType
108
109枚举,相机连接类型。
110
111**系统能力:** SystemCapability.Multimedia.Camera.Core
112
113| 名称                          | 值   | 说明           |
114| ---------------------------- | ---- | ------------- |
115| CAMERA_CONNECTION_BUILT_IN   | 0    | 内置相机。      |
116| CAMERA_CONNECTION_USB_PLUGIN | 1    | USB连接的相机。 |
117| CAMERA_CONNECTION_REMOTE     | 2    | 远程连接的相机。 |
118
119## HostDeviceType<sup>15+</sup>
120
121枚举,远端相机设备类型。
122
123**系统能力:** SystemCapability.Multimedia.Camera.Core
124
125| 名称                          | 值       | 说明      |
126| ---------------------------- | ----     |---------|
127| UNKNOWN_TYPE                 | 0        | 未知设备类型。 |
128| PHONE                        | 0x0E     | 手机设备。   |
129| TABLET                       | 0x11     | 平板设备。   |
130
131## CameraStatus
132
133枚举,相机状态。
134
135**系统能力:** SystemCapability.Multimedia.Camera.Core
136
137| 名称                       | 值   | 说明            |
138| ------------------------- | ---- | ------------    |
139| CAMERA_STATUS_APPEAR      | 0    | 新的相机出现。   |
140| CAMERA_STATUS_DISAPPEAR   | 1    | 相机被移除。     |
141| CAMERA_STATUS_AVAILABLE   | 2    | 相机可用。       |
142| CAMERA_STATUS_UNAVAILABLE | 3    | 相机不可用。     |
143
144## FoldStatus<sup>12+</sup>
145
146枚举,折叠机折叠状态。
147
148**系统能力:** SystemCapability.Multimedia.Camera.Core
149
150| 名称                       | 值   | 说明            |
151| ------------------------- | ---- | ------------    |
152| NON_FOLDABLE      | 0    | 表示当前设备不可折叠。   |
153| EXPANDED   | 1    | 表示当前设备折叠状态为完全展开。 |
154| FOLDED   | 2    | 表示当前设备折叠状态为折叠。       |
155
156## CameraStatusInfo
157
158相机管理器回调返回的接口实例,该实例表示相机状态信息。
159
160**系统能力:** SystemCapability.Multimedia.Camera.Core
161
162| 名称   | 类型                           |    只读   |     可选     | 说明       |
163| ------ | ----------------------------- | --------- |------------ | ---------- |
164| camera | [CameraDevice](#cameradevice) |     否    |       否     | 相机信息。 |
165| status | [CameraStatus](#camerastatus) |     否    |       否     | 相机状态。 |
166
167## FoldStatusInfo<sup>12+</sup>
168
169相机管理器回调返回的接口实例,表示折叠机折叠状态信息。
170
171**系统能力:** SystemCapability.Multimedia.Camera.Core
172
173| 名称   | 类型                           |    只读   |     可选     | 说明       |
174| ------ | ----------------------------- | --------- |------------ | ---------- |
175| supportedCameras | [Array<CameraDevice\>](#cameradevice) |     否    |       否     | 当前折叠状态所支持的相机信息列表。 |
176| foldStatus | [FoldStatus](#foldstatus12) |     否    |       否     | 折叠屏折叠状态。 |
177
178## Profile
179
180相机配置信息项。
181
182**系统能力:** SystemCapability.Multimedia.Camera.Core
183
184| 名称      | 类型                          | 只读 | 可选 | 说明         |
185| -------- | ----------------------------- |---- | ---- | ------------- |
186| format   | [CameraFormat](#cameraformat) | 是  |  否  | 输出格式。      |
187| size     | [Size](#size)                 | 是  |  否  | 分辨率。<br>设置的是相机的分辨率宽度和高度,而非实际输出图像的宽度和高度。  |
188
189## FrameRateRange
190
191帧率范围。
192
193**系统能力:** SystemCapability.Multimedia.Camera.Core
194
195| 名称      | 类型                          | 只读 | 可选 | 说明            |
196| -------- | ----------------------------- |----- |---| -------------- |
197| min      | number                        |  是  | 否 | 最小帧率。      |
198| max      | number                        |  是  | 否 | 最大帧率。      |
199
200## VideoProfile
201
202视频配置信息项,继承[Profile](#profile)。
203
204**系统能力:** SystemCapability.Multimedia.Camera.Core
205
206| 名称                       | 类型                                      | 只读 | 可选 | 说明        |
207| ------------------------- | ----------------------------------------- | --- | ---- |----------- |
208| frameRateRange            | [FrameRateRange](#frameraterange)         | 是  |  否  | 帧率范围,单位:fps(frames per second)。 |
209
210## CameraOutputCapability
211
212相机输出能力项。
213
214**系统能力:** SystemCapability.Multimedia.Camera.Core
215
216| 名称                           | 类型                                                | 只读 | 可选 | 说明                |
217| ----------------------------- | --------------------------------------------------- | ---- | ---- |-------------------|
218| previewProfiles               | Array\<[Profile](#profile)\>                        |  是  | 否 | 支持的预览配置信息集合。      |
219| photoProfiles                 | Array\<[Profile](#profile)\>                        |  是  | 否 | 支持的拍照配置信息集合。        |
220| videoProfiles                 | Array\<[VideoProfile](#videoprofile)\>              |  是  | 否 | 支持的录像配置信息集合。        |
221| supportedMetadataObjectTypes  | Array\<[MetadataObjectType](#metadataobjecttype)\>  |  是  | 否 | 支持的metadata流类型信息集合。 |
222
223## SceneMode<sup>11+</sup>
224
225枚举,相机模式。
226
227**系统能力:** SystemCapability.Multimedia.Camera.Core
228
229| 名称                         | 值       | 说明                                          |
230|----------------------------|---------|---------------------------------------------|
231| NORMAL_PHOTO               | 1       | 普通拍照模式。详情见[PhotoSession](#photosession11)   |
232| NORMAL_VIDEO               | 2       | 普通录像模式。详情见[VideoSession](#videosession11)   |
233| SECURE_PHOTO<sup>12+</sup> | 12      | 安全相机模式。详情见[SecureSession](#securesession12) |
234
235## CameraErrorCode
236
237相机错误码。
238
239接口使用不正确以及on接口监听error状态返回。
240
241**系统能力:** SystemCapability.Multimedia.Camera.Core
242
243| 名称                       | 值          | 说明            |
244| -------------------------  | ----       | ------------    |
245| INVALID_ARGUMENT           | 7400101    | 参数缺失或者参数类型不对。   |
246| OPERATION_NOT_ALLOWED      | 7400102    | 操作流程不对,不允许。     |
247| SESSION_NOT_CONFIG         | 7400103    | session 未配置返回。       |
248| SESSION_NOT_RUNNING        | 7400104    | session 未运行返回。    |
249| SESSION_CONFIG_LOCKED      | 7400105    | session 配置已锁定返回。     |
250| DEVICE_SETTING_LOCKED      | 7400106    | 设备设置已锁定返回。     |
251| CONFLICT_CAMERA            | 7400107    | 设备重复打开返回。     |
252| DEVICE_DISABLED            | 7400108    | 安全原因相机被禁用。     |
253| DEVICE_PREEMPTED           | 7400109    | 相机被抢占导致无法使用。     |
254| UNRESOLVED_CONFLICTS_WITH_CURRENT_CONFIGURATIONS<sup>12+</sup> | 7400110   | 与当前配置存在冲突。     |
255| SERVICE_FATAL_ERROR        | 7400201    | 相机服务错误返回。     |
256
257## CameraManager
258
259相机管理器类,使用前需要通过[getCameraManager](#cameragetcameramanager)接口获取相机管理实例。
260
261### getSupportedCameras
262
263getSupportedCameras(): Array\<CameraDevice\>
264
265获取支持的相机设备对象,同步返回结果。
266
267**系统能力:** SystemCapability.Multimedia.Camera.Core
268
269**返回值:**
270
271| 类型                                             | 说明                           |
272| ----------------------------------------------- | ---------------------------- |
273|  Array\<[CameraDevice](#cameradevice)>            | 相机设备列表。                   |
274
275**示例:**
276
277```ts
278import { BusinessError } from '@kit.BasicServicesKit';
279
280function getSupportedCameras(cameraManager: camera.CameraManager): Array<camera.CameraDevice> {
281  let cameras: Array<camera.CameraDevice> = [];
282  try {
283    cameras = cameraManager.getSupportedCameras();
284  } catch (error) {
285    let err = error as BusinessError;
286    console.error(`The getSupportedCameras call failed. error code: ${err.code}`);
287  }
288  return cameras;
289}
290```
291
292### getSupportedSceneModes<sup>11+</sup>
293
294getSupportedSceneModes(camera: CameraDevice): Array\<SceneMode\>
295
296获取指定的相机设备对象支持的模式,同步返回结果。
297
298**系统能力:** SystemCapability.Multimedia.Camera.Core
299
300**参数:**
301
302| 参数名         | 类型                                                            | 必填 | 说明                      |
303| ------------ |--------------------------------------------------------------- | -- | -------------------------- |
304| camera | [CameraDevice](#cameradevice)                              | 是 | 相机设备,通过 [getSupportedCameras](#getsupportedcameras) 接口获取。传参异常时,会返回错误码。       |
305
306**返回值:**
307
308| 类型                                             | 说明                           |
309| ----------------------------------------------- | ---------------------------- |
310|  Array\<[SceneMode](#scenemode11)>            | 相机支持的模式列表。                   |
311
312**示例:**
313
314```ts
315import { BusinessError } from '@kit.BasicServicesKit';
316
317function getSupportedSceneModes(cameraManager: camera.CameraManager, camera: camera.CameraDevice): Array<camera.SceneMode> {
318  let modes: Array<camera.SceneMode> = [];
319  try {
320    modes = cameraManager.getSupportedSceneModes(camera);
321  } catch (error) {
322    let err = error as BusinessError;
323    console.error(`The getSupportedSceneModes call failed. error code: ${err.code}`);
324  }
325  return modes;
326}
327```
328
329### getSupportedOutputCapability<sup>(deprecated)</sup>
330
331getSupportedOutputCapability(camera: CameraDevice): CameraOutputCapability
332
333查询相机设备支持的输出能力,同步返回结果。
334
335> **说明:**
336> 从 API version 10开始支持,从API version 11开始废弃。建议使用[getSupportedOutputCapability](#getsupportedoutputcapability11)替代。
337
338**系统能力:** SystemCapability.Multimedia.Camera.Core
339
340**参数:**
341
342| 参数名         | 类型                                                            | 必填 | 说明                      |
343| ------------ |--------------------------------------------------------------- | -- | -------------------------- |
344| camera | [CameraDevice](#cameradevice)                              | 是 | 相机设备,通过 [getSupportedCameras](#getsupportedcameras) 接口获取。传参异常时,会返回错误码。      |
345
346**返回值:**
347
348| 类型                                             | 说明                           |
349| ----------------------------------------------- | ---------------------------- |
350| [CameraOutputCapability](#cameraoutputcapability)            | 相机输出能力。                   |
351
352**示例:**
353
354```ts
355function getSupportedOutputCapability(camera: camera.CameraDevice, cameraManager: camera.CameraManager): camera.CameraOutputCapability {
356  let cameraOutputCapability: camera.CameraOutputCapability = cameraManager.getSupportedOutputCapability(camera);
357  return cameraOutputCapability;
358}
359```
360
361### getSupportedOutputCapability<sup>11+</sup>
362
363getSupportedOutputCapability(camera: CameraDevice, mode: SceneMode): CameraOutputCapability
364
365查询相机设备在指定模式下支持的输出能力,同步返回结果。
366
367**系统能力:** SystemCapability.Multimedia.Camera.Core
368
369**参数:**
370
371| 参数名         | 类型                                                            | 必填 | 说明                      |
372| ------------ |--------------------------------------------------------------- | -- | -------------------------- |
373| camera | [CameraDevice](#cameradevice)                              | 是 | 相机设备,通过 [getSupportedCameras](#getsupportedcameras) 接口获取。       |
374| mode | [SceneMode](#scenemode11)                              | 是 | 相机模式,通过 [getSupportedSceneModes](#getsupportedscenemodes11) 接口获取。       |
375
376**返回值:**
377
378| 类型                                             | 说明                           |
379| ----------------------------------------------- | ---------------------------- |
380| [CameraOutputCapability](#cameraoutputcapability)            | 相机输出能力。                   |
381
382**示例:**
383
384```ts
385function getSupportedOutputCapability(camera: camera.CameraDevice, cameraManager: camera.CameraManager, sceneMode: camera.SceneMode): camera.CameraOutputCapability {
386  let cameraOutputCapability: camera.CameraOutputCapability = cameraManager.getSupportedOutputCapability(camera, sceneMode);
387  return cameraOutputCapability;
388}
389```
390
391### isCameraMuted
392
393isCameraMuted(): boolean
394
395查询当前相机是否禁用。
396
397**系统能力:** SystemCapability.Multimedia.Camera.Core
398
399**返回值:**
400
401| 类型        | 说明                                         |
402| ---------- | -------------------------------------------- |
403| boolean    | 返回true表示相机被禁用,返回false表示相机未被禁用。 |
404
405**示例:**
406
407```ts
408function isCameraMuted(cameraManager: camera.CameraManager): boolean {
409  let isMuted: boolean = cameraManager.isCameraMuted();
410  return isMuted;
411}
412```
413
414### createCameraInput
415
416createCameraInput(camera: CameraDevice): CameraInput
417
418使用CameraDevice对象创建CameraInput实例,同步返回结果。
419
420**需要权限:** ohos.permission.CAMERA
421
422**系统能力:** SystemCapability.Multimedia.Camera.Core
423
424**参数:**
425
426| 参数名     | 类型                                         | 必填 | 说明                                               |
427| -------- | ------------------------------------------- | ---- |--------------------------------------------------|
428| camera  | [CameraDevice](#cameradevice)         | 是   | CameraDevice对象,通过 [getSupportedCameras](#getsupportedcameras) 接口获取。 |
429
430**返回值:**
431
432| 类型        | 说明                          |
433| ---------- | ----------------------------- |
434| [CameraInput](#camerainput)    | 返回CameraInput实例。接口调用失败会返回相应错误码,错误码类型为[CameraErrorCode](#cameraerrorcode)。 |
435
436**错误码:**
437
438以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
439
440| 错误码ID         | 错误信息        |
441| --------------- | --------------- |
442| 7400101                |  Parameter missing or parameter type incorrect.               |
443| 7400102                |  Operation not allowed.               |
444| 7400201                |  Camera service fatal error.               |
445
446**示例:**
447
448```ts
449import { BusinessError } from '@kit.BasicServicesKit';
450
451function createCameraInput(camera: camera.CameraDevice, cameraManager: camera.CameraManager): camera.CameraInput | undefined {
452  let cameraInput: camera.CameraInput | undefined = undefined;
453  try {
454    cameraInput = cameraManager.createCameraInput(camera);
455  } catch (error) {
456    // 失败返回错误码error.code并处理。
457    let err = error as BusinessError;
458    console.error(`The createCameraInput call failed. error code: ${err.code}`);
459  }
460  return cameraInput;
461}
462```
463
464### createCameraInput
465
466createCameraInput(position: CameraPosition, type: CameraType): CameraInput
467
468根据相机位置和类型创建CameraInput实例,同步返回结果。
469
470**需要权限:** ohos.permission.CAMERA
471
472**系统能力:** SystemCapability.Multimedia.Camera.Core
473
474**参数:**
475
476| 参数名     | 类型                                        | 必填 | 说明                                |
477| -------- | ------------------------------------------- | ---- | --------------------------------- |
478| position | [CameraPosition](#cameraposition)           | 是   | 相机位置,首先通过 [getSupportedCameras](#getsupportedcameras) 接口获取支持的相机设备对象,然后根据返回的相机设备对象获取设备位置信息。  |
479| type     | [CameraType](#cameratype)                   | 是   | 相机类型,首先通过 [getSupportedCameras](#getsupportedcameras) 接口获取支持的相机设备对象,然后根据返回的相机设备对象获取设备类型信息。 |
480
481**返回值:**
482
483| 类型        | 说明                          |
484| ---------- | ----------------------------- |
485| [CameraInput](#camerainput)    | 返回CameraInput实例。接口调用失败会返回相应错误码,错误码类型为[CameraErrorCode](#cameraerrorcode)。 |
486
487**错误码:**
488
489以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
490
491| 错误码ID         | 错误信息        |
492| --------------- | --------------- |
493| 7400101                |  Parameter missing or parameter type incorrect.               |
494| 7400102                |  Operation not allowed.               |
495| 7400201                |  Camera service fatal error.               |
496
497**示例:**
498
499```ts
500import { BusinessError } from '@kit.BasicServicesKit';
501
502function createCameraInput(camera: camera.CameraDevice, cameraManager: camera.CameraManager): camera.CameraInput | undefined {
503  let position: camera.CameraPosition = camera.cameraPosition;
504  let type: camera.CameraType = camera.cameraType;
505  let cameraInput: camera.CameraInput | undefined = undefined;
506  try {
507    cameraInput = cameraManager.createCameraInput(position, type);
508  } catch (error) {
509    // 失败返回错误码error.code并处理。
510    let err = error as BusinessError;
511    console.error(`The createCameraInput call failed. error code: ${err.code}`);
512  }
513  return cameraInput;
514}
515```
516
517### createPreviewOutput
518
519createPreviewOutput(profile: Profile, surfaceId: string): PreviewOutput
520
521创建预览输出对象,同步返回结果。
522
523**系统能力:** SystemCapability.Multimedia.Camera.Core
524
525**参数:**
526
527| 参数名     | 类型                                             | 必填 | 说明                              |
528| -------- | ----------------------------------------------- | ---- | ------------------------------- |
529| profile  | [Profile](#profile)                             | 是   | 支持的预览配置信息,通过[getSupportedOutputCapability](#getsupportedoutputcapability11)接口获取。|
530| surfaceId| string | 是   | 从[XComponent](../apis-arkui/arkui-ts/ts-basic-components-xcomponent.md)或者[ImageReceiver](../apis-image-kit/js-apis-image.md#imagereceiver9)组件获取的surfaceId。|
531
532**返回值:**
533
534| 类型        | 说明                          |
535| ---------- | ----------------------------- |
536| [PreviewOutput](#previewoutput)    | PreviewOutput实例。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode)。 |
537
538**错误码:**
539
540以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
541
542| 错误码ID         | 错误信息        |
543| --------------- | --------------- |
544| 7400101                |  Parameter missing or parameter type incorrect.               |
545| 7400201                |  Camera service fatal error.               |
546
547**示例:**
548
549```ts
550import { BusinessError } from '@kit.BasicServicesKit';
551
552function createPreviewOutput(cameraOutputCapability: camera.CameraOutputCapability, cameraManager: camera.CameraManager, surfaceId: string): camera.PreviewOutput | undefined {
553  let profile: camera.Profile = cameraOutputCapability.previewProfiles[0];
554  let previewOutput: camera.PreviewOutput | undefined = undefined;
555  try {
556    previewOutput = cameraManager.createPreviewOutput(profile, surfaceId);
557  } catch (error) {
558    // 失败返回错误码error.code并处理。
559    let err = error as BusinessError;
560    console.error(`The createPreviewOutput call failed. error code: ${err.code}`);
561  }
562  return previewOutput;
563}
564```
565
566### createPreviewOutput<sup>12+</sup>
567
568createPreviewOutput(surfaceId: string): PreviewOutput
569
570创建无配置信息的预览输出对象,同步返回结果。该接口需配合[preconfig](#preconfig12)一起使用。
571
572**系统能力:** SystemCapability.Multimedia.Camera.Core
573
574**参数:**
575
576| 参数名     | 类型                                             | 必填 | 说明                              |
577| -------- | ----------------------------------------------- | ---- | ------------------------------- |
578| surfaceId| string | 是   | 从[XComponent](../apis-arkui/arkui-ts/ts-basic-components-xcomponent.md)或者[ImageReceiver](../apis-image-kit/js-apis-image.md#imagereceiver9)组件获取的surfaceId。|
579
580**返回值:**
581
582| 类型        | 说明                          |
583| ---------- | ----------------------------- |
584| [PreviewOutput](#previewoutput)    | PreviewOutput实例。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode)。 |
585
586**错误码:**
587
588以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
589
590| 错误码ID   | 错误信息                                           |
591|---------|------------------------------------------------|
592| 7400101 | Parameter missing or parameter type incorrect. |
593| 7400201 | Camera service fatal error.                    |
594
595**示例:**
596
597```ts
598import { BusinessError } from '@kit.BasicServicesKit';
599
600function createPreviewOutput(cameraManager: camera.CameraManager, surfaceId: string): camera.PreviewOutput | undefined {
601  let previewOutput: camera.PreviewOutput | undefined = undefined;
602  try {
603    previewOutput = cameraManager.createPreviewOutput(surfaceId);
604  } catch (error) {
605    // 失败返回错误码error.code并处理。
606    let err = error as BusinessError;
607    console.error(`The createPreviewOutput call failed. error code: ${err.code}`);
608  }
609  return previewOutput;
610}
611```
612
613### createPhotoOutput<sup>(deprecated)</sup>
614
615createPhotoOutput(profile: Profile, surfaceId: string): PhotoOutput
616
617创建拍照输出对象,同步返回结果。
618
619> **说明:**
620> 从 API version 10开始支持,从API version 11开始废弃。建议使用[createPhotoOutput](#createphotooutput11)替代。
621
622**系统能力:** SystemCapability.Multimedia.Camera.Core
623
624**参数:**
625
626| 参数名     | 类型                                         | 必填 | 说明                                  |
627| -------- | ------------------------------------------- | ---- | ----------------------------------- |
628| profile  | [Profile](#profile)                         | 是   | 支持的拍照配置信息,通过[getSupportedOutputCapability](#getsupportedoutputcapability11)接口获取。|
629| surfaceId| string            | 是   | 从[ImageReceiver](../apis-image-kit/js-apis-image.md#imagereceiver9)获取的surfaceId。|
630
631**返回值:**
632
633| 类型        | 说明                          |
634| ---------- | ----------------------------- |
635| [PhotoOutput](#photooutput)   | PhotoOutput实例。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode)。 |
636
637**错误码:**
638
639以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
640
641| 错误码ID         | 错误信息        |
642| --------------- | --------------- |
643| 7400101                |  Parameter missing or parameter type incorrect.               |
644
645```ts
646import { BusinessError } from '@kit.BasicServicesKit';
647
648function createPhotoOutput(cameraOutputCapability: camera.CameraOutputCapability, cameraManager: camera.CameraManager, surfaceId: string): camera.PhotoOutput | undefined {
649  let profile: camera.Profile = cameraOutputCapability.photoProfiles[0];
650  let photoOutput: camera.PhotoOutput | undefined = undefined;
651  try {
652    photoOutput = cameraManager.createPhotoOutput(profile, surfaceId);
653  } catch (error) {
654    // 失败返回错误码error.code并处理。
655    let err = error as BusinessError;
656    console.error(`The createPhotoOutput call failed. error code: ${err.code}`);
657  }
658  return photoOutput;
659}
660```
661
662### createPhotoOutput<sup>11+</sup>
663
664createPhotoOutput(profile?: Profile): PhotoOutput
665
666创建拍照输出对象,同步返回结果。
667
668**系统能力:** SystemCapability.Multimedia.Camera.Core
669
670**参数:**
671
672| 参数名     | 类型                                         | 必填 | 说明                                  |
673| -------- | ------------------------------------------- |----| ----------------------------------- |
674| profile  | [Profile](#profile)                         | 否  | 支持的拍照配置信息,通过[getSupportedOutputCapability](#getsupportedoutputcapability11)接口获取。<br>API 11时,该参数必填;从API version 12开始,如果使用[preconfig](#preconfig12)进行预配置,传入profile参数会覆盖preconfig的预配置参数。|
675
676**返回值:**
677
678| 类型        | 说明                          |
679| ---------- | ----------------------------- |
680| [PhotoOutput](#photooutput)   | PhotoOutput实例。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode)。 |
681
682**错误码:**
683
684以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
685
686| 错误码ID    | 错误信息                                           |
687|----------|------------------------------------------------|
688| 7400101  | Parameter missing or parameter type incorrect. |
689| 7400201  | Camera service fatal error.                    |
690
691**示例:**
692
693```ts
694import { BusinessError } from '@kit.BasicServicesKit';
695
696function createPhotoOutput(cameraOutputCapability: camera.CameraOutputCapability, cameraManager: camera.CameraManager): camera.PhotoOutput | undefined {
697  let profile: camera.Profile = cameraOutputCapability.photoProfiles[0];
698  let photoOutput: camera.PhotoOutput | undefined = undefined;
699  try {
700    photoOutput = cameraManager.createPhotoOutput(profile);
701  } catch (error) {
702    // 失败返回错误码error.code并处理。
703    let err = error as BusinessError;
704    console.error(`The createPhotoOutput call failed. error code: ${err.code}`);
705  }
706  return photoOutput;
707}
708```
709
710### createVideoOutput
711
712createVideoOutput(profile: VideoProfile, surfaceId: string): VideoOutput
713
714创建录像输出对象,同步返回结果。
715
716**系统能力:** SystemCapability.Multimedia.Camera.Core
717
718**参数:**
719
720| 参数名     | 类型                                        | 必填 | 说明                              |
721| -------- | ------------------------------------------- | ---- | ------------------------------ |
722| profile  | [VideoProfile](#videoprofile)               | 是   | 支持的录像配置信息,通过[getSupportedOutputCapability](#getsupportedoutputcapability11)接口获取。 |
723| surfaceId| string          | 是   | 从[AVRecorder](../apis-media-kit/js-apis-media.md#avrecorder9)获取的surfaceId。|
724
725**返回值:**
726
727| 类型        | 说明                          |
728| ---------- | ----------------------------- |
729| [VideoOutput](#videooutput)   | VideoOutput实例。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode)。 |
730
731**错误码:**
732
733以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
734
735| 错误码ID         | 错误信息        |
736| --------------- | --------------- |
737| 7400101                |  Parameter missing or parameter type incorrect.               |
738| 7400201                |  Camera service fatal error.               |
739
740**示例:**
741
742```ts
743import { BusinessError } from '@kit.BasicServicesKit';
744
745function createVideoOutput(cameraOutputCapability: camera.CameraOutputCapability, cameraManager: camera.CameraManager, surfaceId: string): camera.VideoOutput | undefined {
746  let profile: camera.VideoProfile = cameraOutputCapability.videoProfiles[0];
747  let videoOutput: camera.VideoOutput | undefined = undefined;
748  try {
749    videoOutput = cameraManager.createVideoOutput(profile, surfaceId);
750  } catch (error) {
751    // 失败返回错误码error.code并处理。
752    let err = error as BusinessError;
753    console.error(`The createVideoOutput call failed. error code: ${err.code}`);
754  }
755  return videoOutput;
756}
757```
758
759### createVideoOutput<sup>12+</sup>
760
761createVideoOutput(surfaceId: string): VideoOutput
762
763创建无配置信息的录像输出对象,同步返回结果。该接口需配合[preconfig](#preconfig12-1)功能一起使用。
764
765**系统能力:** SystemCapability.Multimedia.Camera.Core
766
767**参数:**
768
769| 参数名       | 类型     | 必填    | 说明                                                                         |
770|-----------|--------|-------|----------------------------------------------------------------------------|
771| surfaceId | string | 是     | 从[AVRecorder](../apis-media-kit/js-apis-media.md#avrecorder9)获取的surfaceId。 |
772
773**返回值:**
774
775| 类型        | 说明                          |
776| ---------- | ----------------------------- |
777| [VideoOutput](#videooutput)   | VideoOutput实例。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode)。 |
778
779**错误码:**
780
781以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
782
783| 错误码ID    | 错误信息                                           |
784|----------|------------------------------------------------|
785| 7400101  | Parameter missing or parameter type incorrect. |
786| 7400201  | Camera service fatal error.                    |
787
788**示例:**
789
790```ts
791import { BusinessError } from '@kit.BasicServicesKit';
792
793function createVideoOutput(cameraManager: camera.CameraManager, surfaceId: string): camera.VideoOutput | undefined {
794  let videoOutput: camera.VideoOutput | undefined = undefined;
795  try {
796    videoOutput = cameraManager.createVideoOutput(surfaceId);
797  } catch (error) {
798    // 失败返回错误码error.code并处理。
799    let err = error as BusinessError;
800    console.error(`The createVideoOutput call failed. error code: ${err.code}`);
801  }
802  return videoOutput;
803}
804```
805
806### createMetadataOutput
807
808createMetadataOutput(metadataObjectTypes: Array\<MetadataObjectType\>): MetadataOutput
809
810创建metadata流输出对象,同步返回结果。
811
812**系统能力:** SystemCapability.Multimedia.Camera.Core
813
814**参数:**
815
816| 参数名                  | 类型                                               | 必填 | 说明                          |
817| -------------------- | -------------------------------------------------- | --- | ---------------------------- |
818| metadataObjectTypes  | Array\<[MetadataObjectType](#metadataobjecttype)\>  | 是  | metadata流类型信息,通过[getSupportedOutputCapability](#getsupportedoutputcapability11)接口获取。 |
819
820**返回值:**
821
822| 类型        | 说明                          |
823| ---------- | ----------------------------- |
824| [MetadataOutput](#metadataoutput)   | MetadataOutput实例。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode)。 |
825
826**错误码:**
827
828以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
829
830| 错误码ID         | 错误信息        |
831| --------------- | --------------- |
832| 7400101                |  Parameter missing or parameter type incorrect.               |
833| 7400201                |  Camera service fatal error.               |
834
835**示例:**
836
837```ts
838import { BusinessError } from '@kit.BasicServicesKit';
839
840function createMetadataOutput(cameraManager: camera.CameraManager, cameraOutputCapability: camera.CameraOutputCapability): void {
841  let metadataObjectTypes: Array<camera.MetadataObjectType> = cameraOutputCapability.supportedMetadataObjectTypes;
842  let metadataOutput: camera.MetadataOutput | undefined = undefined;
843  try {
844    metadataOutput = cameraManager.createMetadataOutput(metadataObjectTypes);
845  } catch (error) {
846    // 失败返回错误码error.code并处理。
847    let err = error as BusinessError;
848    console.error(`createMetadataOutput error. error code: ${err.code}`);
849  }
850}
851```
852
853### createCaptureSession<sup>(deprecated)</sup>
854
855createCaptureSession(): CaptureSession
856
857创建CaptureSession实例,同步返回结果。
858
859> **说明:**
860>从 API version 10开始支持,从API version 11开始废弃。建议使用[createSession](#createsession11)替代。
861
862**系统能力:** SystemCapability.Multimedia.Camera.Core
863
864**返回值:**
865
866| 类型        | 说明                          |
867| ---------- | ----------------------------- |
868| [CaptureSession](#capturesessiondeprecated)   | CaptureSession实例。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode)。 |
869
870**错误码:**
871
872以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
873
874| 错误码ID         | 错误信息        |
875| --------------- | --------------- |
876| 7400201                |  Camera service fatal error.               |
877
878**示例:**
879
880```ts
881import { BusinessError } from '@kit.BasicServicesKit';
882
883function createCaptureSession(cameraManager: camera.CameraManager): camera.CaptureSession | undefined {
884  let captureSession: camera.CaptureSession | undefined = undefined;
885  try {
886    captureSession = cameraManager.createCaptureSession();
887  } catch (error) {
888    // 失败返回错误码error.code并处理。
889    let err = error as BusinessError;
890    console.error(`createCaptureSession error. error code: ${err.code}`);
891  }
892  return captureSession;
893}
894```
895
896### createSession<sup>11+</sup>
897
898createSession\<T extends Session\>(mode: SceneMode): T
899
900创建指定SceneMode的Session实例,同步返回结果。
901
902**系统能力:** SystemCapability.Multimedia.Camera.Core
903
904**参数:**
905
906| 参数名   | 类型              | 必填 | 说明       |
907| -------- | -----------------| ---- | --------- |
908| mode     | [SceneMode](#scenemode11)     | 是   | 相机支持的模式。传参异常(如超出范围、传入null、未定义等),实际接口不会生效。 |
909
910**返回值:**
911
912| 类型        | 说明                          |
913| ---------- | ----------------------------- |
914| [T extends Session](#session11)   | Session实例。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode)。 |
915
916**错误码:**
917
918以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
919
920| 错误码ID         | 错误信息                                                                                                                                           |
921| --------------- |------------------------------------------------------------------------------------------------------------------------------------------------|
922| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3.Parameter verification failed. |
923| 7400201                | Camera service fatal error.                                                                                                                    |
924
925**示例:**
926
927```ts
928import { BusinessError } from '@kit.BasicServicesKit';
929
930function createSession(cameraManager: camera.CameraManager, mode: camera.SceneMode): camera.Session | undefined {
931  let photoSession: camera.PhotoSession | undefined = undefined;
932  try {
933    photoSession = cameraManager.createSession(mode) as camera.PhotoSession;
934  } catch (error) {
935    // 失败返回错误码error.code并处理。
936    let err = error as BusinessError;
937    console.error(`createCaptureSession error. error code: ${err.code}`);
938  }
939  return photoSession;
940}
941```
942
943### on('cameraStatus')
944
945on(type: 'cameraStatus', callback: AsyncCallback\<CameraStatusInfo\>): void
946
947相机设备状态回调,通过注册回调函数获取相机的状态变化。使用callback异步回调。
948
949> **说明:**
950>
951> 当前注册监听接口,不支持在on监听的回调方法里,调用off注销回调。
952
953**系统能力:** SystemCapability.Multimedia.Camera.Core
954
955**参数:**
956
957| 参数名     | 类型            | 必填 | 说明       |
958| -------- | -----------------| ---- | --------- |
959| type     | string           | 是   | 监听事件,固定为'cameraStatus'。cameraManager对象获取成功后可监听。目前只支持对设备打开或者关闭会触发该事件并返回对应信息。 |
960| callback | AsyncCallback\<[CameraStatusInfo](#camerastatusinfo)\> | 是   | 回调函数,用于获取镜头状态变化信息。 |                 |
961
962**示例:**
963
964```ts
965import { BusinessError } from '@kit.BasicServicesKit';
966
967function callback(err: BusinessError, cameraStatusInfo: camera.CameraStatusInfo): void {
968  if (err !== undefined && err.code !== 0) {
969    console.error('cameraStatus with errorCode = ' + err.code);
970    return;
971  }
972  console.info(`camera : ${cameraStatusInfo.camera.cameraId}`);
973  console.info(`status: ${cameraStatusInfo.status}`);
974}
975
976function registerCameraStatus(cameraManager: camera.CameraManager): void {
977  cameraManager.on('cameraStatus', callback);
978}
979```
980
981### off('cameraStatus')
982
983off(type: 'cameraStatus', callback?: AsyncCallback\<CameraStatusInfo\>): void
984
985相机设备状态注销回调,通过注销回调函数取消获取相机的状态变化。
986
987**系统能力:** SystemCapability.Multimedia.Camera.Core
988
989**参数:**
990
991| 参数名     | 类型            | 必填 | 说明       |
992| -------- | -----------------| ---- | --------- |
993| type     | string           | 是   | 监听事件,固定为'cameraStatus'。cameraManager对象获取成功后可监听。 |
994| callback | AsyncCallback\<[CameraStatusInfo](#camerastatusinfo)\> | 否   | 回调函数,如果指定参数则取消对应callback(callback对象不可是匿名函数),否则取消所有callback。 |
995
996**示例:**
997
998```ts
999function unregisterCameraStatus(cameraManager: camera.CameraManager): void {
1000  cameraManager.off('cameraStatus');
1001}
1002```
1003
1004### on('foldStatusChange')<sup>12+</sup>
1005
1006on(type: 'foldStatusChange', callback: AsyncCallback\<FoldStatusInfo\>): void
1007
1008开启折叠设备折叠状态变化的监听。使用callback异步回调。
1009
1010> **说明:**
1011>
1012> 当前注册监听接口,不支持在on监听的回调方法里,调用off注销回调。
1013
1014**系统能力:** SystemCapability.Multimedia.Camera.Core
1015
1016**参数:**
1017
1018| 参数名     | 类型            | 必填 | 说明       |
1019| -------- | -----------------| ---- | --------- |
1020| type     | string           | 是   | 监听事件,固定为'foldStatusChange'。表示折叠设备折叠状态发生变化。 |
1021| callback | AsyncCallback\<[FoldStatusInfo](#foldstatusinfo12)\> | 是   | 回调函数。返回折叠设备折叠信息。 |
1022
1023**示例:**
1024
1025```ts
1026import { BusinessError } from '@kit.BasicServicesKit';
1027
1028function callback(err: BusinessError, foldStatusInfo: camera.FoldStatusInfo): void {
1029  if (err !== undefined && err.code !== 0) {
1030    console.error('foldStatusChange with errorCode = ' + err.code);
1031    return;
1032  }
1033  console.info(`camera length: ${foldStatusInfo.supportedCameras.length}`);
1034  console.info(`foldStatus: ${foldStatusInfo.foldStatus}`);
1035}
1036
1037function registerFoldStatusChange(cameraManager: camera.CameraManager): void {
1038  cameraManager.on('foldStatusChange', callback);
1039}
1040```
1041
1042### off('foldStatusChange')<sup>12+</sup>
1043
1044off(type: 'foldStatusChange', callback?: AsyncCallback\<FoldStatusInfo\>): void
1045
1046关闭折叠设备折叠状态变化的监听。
1047
1048**系统能力:** SystemCapability.Multimedia.Camera.Core
1049
1050**参数:**
1051
1052| 参数名     | 类型            | 必填 | 说明       |
1053| -------- | -----------------| ---- | --------- |
1054| type     | string           | 是   | 监听事件,固定为'foldStatusChange'。表示折叠设备折叠状态发生变化。 |
1055| callback | AsyncCallback\<[FoldStatusInfo](#foldstatusinfo12)\> | 否   | 回调函数,返回折叠设备折叠信息。如果指定参数则取消对应callback(callback对象不可是匿名函数),否则取消所有callback。 |
1056
1057**示例:**
1058
1059```ts
1060function unregisterFoldStatusChange(cameraManager: camera.CameraManager): void {
1061  cameraManager.off('foldStatusChange');
1062}
1063```
1064
1065### isTorchSupported<sup>11+</sup>
1066
1067isTorchSupported(): boolean
1068
1069检测设备是否支持手电筒。
1070
1071**系统能力:** SystemCapability.Multimedia.Camera.Core
1072
1073**返回值:**
1074
1075| 类型        | 说明                          |
1076| ---------- | ----------------------------- |
1077| boolean    | 返回true表示设备支持手电筒,返回false表示设备不支持手电。 |
1078
1079**示例:**
1080
1081```ts
1082function isTorchSupported(cameraManager: camera.CameraManager): boolean {
1083  let isSupported = cameraManager.isTorchSupported();
1084  return isSupported;
1085}
1086```
1087
1088### isTorchModeSupported<sup>11+</sup>
1089
1090isTorchModeSupported(mode: TorchMode): boolean
1091
1092检测是否支持设置的手电筒模式。
1093
1094**系统能力:** SystemCapability.Multimedia.Camera.Core
1095
1096**参数:**
1097
1098| 参数名     | 类型             | 必填 | 说明       |
1099| -------- | --------------- | ---- | --------- |
1100| mode | [TorchMode](#torchmode11) | 是 | 手电筒模式。传参为null或者undefined,作为0处理,手电筒关闭。 |
1101
1102**返回值:**
1103
1104| 类型        | 说明                          |
1105| ---------- | ----------------------------- |
1106| boolean    | 返回true表示设备支持设置的手电筒模式,返回false表示设备不支持的手电筒模式。 |
1107
1108**示例:**
1109
1110```ts
1111function isTorchModeSupported(cameraManager: camera.CameraManager, torchMode: camera.TorchMode): boolean {
1112  let isSupported = cameraManager.isTorchModeSupported(torchMode);
1113  return isSupported;
1114}
1115```
1116
1117### getTorchMode<sup>11+</sup>
1118
1119getTorchMode(): TorchMode
1120
1121获取当前设备手电筒模式。
1122
1123**系统能力:** SystemCapability.Multimedia.Camera.Core
1124
1125**返回值:**
1126
1127| 类型        | 说明                          |
1128| ---------- | ----------------------------- |
1129| [TorchMode](#torchmode11)    | 返回设备当前手电筒模式。 |
1130
1131**示例:**
1132
1133```ts
1134function getTorchMode(cameraManager: camera.CameraManager): camera.TorchMode | undefined {
1135  let torchMode: camera.TorchMode | undefined = undefined;
1136  torchMode = cameraManager.getTorchMode();
1137  return torchMode;
1138}
1139```
1140
1141### setTorchMode<sup>11+</sup>
1142
1143setTorchMode(mode: TorchMode): void
1144
1145设置设备手电筒模式。
1146
1147**系统能力:** SystemCapability.Multimedia.Camera.Core
1148
1149**参数:**
1150
1151| 参数名     | 类型             | 必填 | 说明       |
1152| -------- | --------------- | ---- | --------- |
1153| mode | [TorchMode](#torchmode11) | 是 | 手电筒模式。传参为null或者undefined,作为0处理,手电筒关闭。 |
1154
1155**错误码:**
1156
1157以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
1158
1159| 错误码ID         | 错误信息        |
1160| --------------- | --------------- |
1161| 7400102 | Operation not allowed. |
1162| 7400201 | Camera service fatal error. |
1163
1164**示例:**
1165
1166```ts
1167import { BusinessError } from '@kit.BasicServicesKit';
1168
1169function setTorchMode(cameraManager: camera.CameraManager, torchMode: camera.TorchMode): void {
1170  try {
1171    cameraManager.setTorchMode(torchMode);
1172  } catch (error) {
1173    // 失败返回错误码error.code并处理。
1174    let err = error as BusinessError;
1175    console.error(`The setTorchMode call failed. error code: ${err.code}`);
1176  }
1177}
1178```
1179
1180### on('torchStatusChange')<sup>11+</sup>
1181
1182on(type: 'torchStatusChange', callback: AsyncCallback\<TorchStatusInfo\>): void
1183
1184手电筒状态变化回调,通过注册回调函数获取手电筒状态变化。使用callback异步回调。
1185
1186> **说明:**
1187>
1188> 当前注册监听接口,不支持在on监听的回调方法里,调用off注销回调。
1189
1190**系统能力:** SystemCapability.Multimedia.Camera.Core
1191
1192**参数:**
1193
1194| 参数名     | 类型             | 必填 | 说明       |
1195| -------- | --------------- | ---- | --------- |
1196| type     | string          | 是   | 监听事件,固定为'torchStatusChange'。cameraManager对象获取成功后可监听。目前只支持手电筒打开,手电筒关闭,手电筒不可用,手电筒恢复可用会触发该事件并返回对应信息。 |
1197| callback | AsyncCallback\<TorchStatusInfo> | 是   | 回调函数,用于获取手电筒状态变化信息。               |
1198
1199**示例:**
1200
1201```ts
1202import { BusinessError } from '@kit.BasicServicesKit';
1203
1204function callback(err: BusinessError, torchStatusInfo: camera.TorchStatusInfo): void {
1205  if (err !== undefined && err.code !== 0) {
1206    console.error(`Callback Error, errorCode: ${err.code}`);
1207    return;
1208  }
1209  console.info(`onTorchStatusChange, isTorchAvailable: ${torchStatusInfo.isTorchAvailable}, isTorchActive: ${torchStatusInfo.isTorchActive}, level: ${torchStatusInfo.torchLevel}`);
1210}
1211
1212function registerTorchStatusChange(cameraManager: camera.CameraManager): void {
1213  cameraManager.on('torchStatusChange', callback);
1214}
1215```
1216
1217### off('torchStatusChange')<sup>11+</sup>
1218
1219off(type: 'torchStatusChange', callback?: AsyncCallback\<TorchStatusInfo\>): void
1220
1221手电筒状态变化注销回调,通过注销回调函数取消获取手电筒状态变化。
1222
1223**系统能力:** SystemCapability.Multimedia.Camera.Core
1224
1225**参数:**
1226
1227| 参数名     | 类型             | 必填 | 说明       |
1228| -------- | --------------- | ---- | --------- |
1229| type     | string          | 是   | 监听事件,固定为'torchStatusChange'。cameraManager对象获取成功后可监听。 |
1230| callback | AsyncCallback\<TorchStatusInfo> | 否   | 回调函数,如果指定参数则取消对应callback(callback对象不可是匿名函数),否则取消所有callback。 |
1231
1232**示例:**
1233
1234```ts
1235function unregisterTorchStatusChange(cameraManager: camera.CameraManager): void {
1236  cameraManager.off('torchStatusChange');
1237}
1238```
1239
1240### getCameraDevice<sup>18+</sup>
1241
1242getCameraDevice(position:CameraPosition, type: CameraType): CameraDevice
1243
1244根据相机位置和相机类型查询对应相机。
1245
1246**系统能力:** SystemCapability.Multimedia.Camera.Core
1247
1248**参数:**
1249
1250| 参数名     | 类型             | 必填 | 说明       |
1251| -------- | --------------- | ---- | --------- |
1252| position | [CameraPosition](#cameraposition)   | 是   | 需要得到的CameraDevice对象对应的CameraPosition条件。 |
1253| type     | [CameraType](#cameratype)   | 是   | 需要得到的CameraDevice对象对应的CameraType条件。 |
1254
1255**返回值:**
1256
1257| 类型             | 说明                     |
1258| -----------------| ------------------------ |
1259|  [CameraDevice](#cameradevice)     | 根据相机位置和相机类型查询的对应相机。      |
1260
1261**错误码:**
1262
1263以下错误码的详细介绍请参见[通用错误码说明文档](../errorcode-universal.md)和[Camera错误码](errorcode-camera.md)。
1264
1265| 错误码ID         | 错误信息        |
1266| --------------- | --------------- |
1267| 7400201 | Camera service fatal error. |
1268
1269**示例:**
1270
1271```ts
1272import { camera } from '@kit.CameraKit';
1273
1274function getCameraDevice(cameraManager: camera.CameraManager, position: camera.CameraPosition, type: camera.CameraType): void {
1275  try {
1276    let curCameraDev: camera.CameraDevice | undefined = undefined;
1277    curCameraDev = cameraManager.getCameraDevice(position, type);
1278  } catch (error) {
1279    // 失败返回错误码并处理。
1280    let err = error as BusinessError;
1281    console.error(`The getCameraDevice call failed. error code: ${err.code}`);
1282  }
1283}
1284```
1285
1286### getCameraConcurrentInfos<sup>18+</sup>
1287
1288getCameraConcurrentInfos(cameras: Array\<CameraDevice\>): Array\<CameraConcurrentInfo\>
1289
1290获取指定相机设备的并发信息。返回空表示不支持并发。
1291
1292**系统能力:** SystemCapability.Multimedia.Camera.Core
1293
1294**参数:**
1295
1296| 参数名     | 类型             | 必填 | 说明       |
1297| -------- | --------------- | ---- | --------- |
1298| cameras | Array\<[CameraDevice](#cameradevice)\>  | 是   | 一组CameraDevice对象,并得到与这一组CamraDevice对应的并发信息。 |
1299
1300**返回值:**
1301
1302| 类型             | 说明                     |
1303| -----------------| ------------------------ |
1304|  Array\<[CameraConcurrentInfo](#cameraconcurrentinfo18)\>    |  一组CameraDevice对象对应的并发信息,与CameraDevice一一对应。      |
1305
1306**错误码:**
1307
1308以下错误码的详细介绍请参见[通用错误码说明文档](../errorcode-universal.md)和[Camera错误码](errorcode-camera.md)。
1309
1310| 错误码ID         | 错误信息        |
1311| --------------- | --------------- |
1312| 7400201 | Camera service fatal error. |
1313
1314**示例:**
1315
1316```ts
1317import { camera } from '@kit.CameraKit';
1318
1319function getCameraConcurrentInfos(cameraManager: camera.CameraManager, cameraDeviceArray: Array<camera.CameraDevice>): void {
1320  try {
1321    let cameraconcurrentinfos: Array<camera.CameraConcurrentInfo> = [];
1322    cameraconcurrentinfos = cameraManager.getCameraConcurrentInfos(cameraDeviceArray);
1323  } catch (error) {
1324    // 失败返回错误码并处理。
1325    let err = error as BusinessError;
1326    console.error(`The getCameraConcurrentInfos call failed. error code: ${err.code}`);
1327  }
1328}
1329```
1330
1331## TorchMode<sup>11+</sup>
1332
1333枚举,手电筒模式。
1334
1335**系统能力:** SystemCapability.Multimedia.Camera.Core
1336
1337| 名称                          | 值   | 说明           |
1338| ---------------------------- | ---- | ------------- |
1339| OFF    | 0    | 常关模式。      |
1340| ON  | 1    | 常开模式。 |
1341| AUTO      | 2    | 自动模式,系统根据环境自动调节手电筒亮度。|
1342
1343## TorchStatusInfo<sup>11+</sup>
1344
1345手电筒回调返回的接口实例,表示手电筒状态信息。
1346
1347**系统能力:** SystemCapability.Multimedia.Camera.Core
1348
1349| 名称              | 类型       | 只读 | 可选 | 说明        |
1350| ---------------- | ---------- | ---- | ---- | ----------- |
1351| isTorchAvailable | boolean    | 是   | 否   | 手电筒是否可用。|
1352| isTorchActive    | boolean    | 是   | 否   | 手电筒是否被激活。    |
1353| torchLevel       | number     | 是   | 否   | 手电筒亮度等级。取值范围为[0,1],越靠近1,亮度越大。    |
1354
1355## Size
1356
1357输出能力查询。
1358
1359**系统能力:** SystemCapability.Multimedia.Camera.Core
1360
1361| 名称   | 类型    | 只读 | 可选  | 说明         |
1362| ------ | ------ | ---- |-----| ------------ |
1363| height | number | 否   | 否   | 图像尺寸高(像素)。 |
1364| width  | number | 否   | 否   | 图像尺寸宽(像素)。 |
1365
1366## Point
1367
1368点坐标用于对焦、曝光配置。
1369
1370**系统能力:** SystemCapability.Multimedia.Camera.Core
1371
1372| 名称    | 类型   | 只读   | 可选   | 说明         |
1373| ------ | ------ | ------ | ------ | ------------ |
1374| x      | number | 否     | 否     | 点的x坐标。   |
1375| y      | number | 否     | 否     | 点的y坐标。   |
1376
1377## CameraFormat
1378
1379枚举,输出格式。
1380
1381**系统能力:** SystemCapability.Multimedia.Camera.Core
1382
1383| 名称                     | 值        | 说明         |
1384| ----------------------- | --------- | ------------ |
1385| CAMERA_FORMAT_RGBA_8888 | 3         | RGBA_8888格式的图片。        |
1386| CAMERA_FORMAT_YUV_420_SP| 1003      | YUV_420_SP格式的图片。      |
1387| CAMERA_FORMAT_JPEG      | 2000      | JPEG格式的图片。            |
1388| CAMERA_FORMAT_YCBCR_P010<sup>11+</sup> |   2001    | YCBCR_P010格式的图片。      |
1389| CAMERA_FORMAT_YCRCB_P010<sup>11+</sup> |   2002    | YCRCB_P010格式的图片。      |
1390| CAMERA_FORMAT_HEIC<sup>13+</sup>       |   2003    | HEIF格式的图片。            |
1391
1392## VideoCodecType<sup>13+</sup>
1393
1394枚举,视频编码类型。
1395
1396**系统能力:** SystemCapability.Multimedia.Camera.Core
1397
1398| 名称   | 值    | 说明          |
1399|------|------|-------------|
1400| AVC  | 0    | 视频编码类型AVC。  |
1401| HEVC | 1 | 视频编码类型HEVC。 |
1402
1403## CameraConcurrentType<sup>18+</sup>
1404
1405枚举,镜头并发类型。
1406
1407**系统能力:** SystemCapability.Multimedia.Camera.Core
1408
1409| 名称   | 值    | 说明          |
1410|------|------|-------------|
1411| CAMERA_LIMITED_CAPABILITY  | 0 | 镜头受限能力并发。  |
1412| CAMERA_FULL_CAPABILITY     | 1 | 镜头全量能力并发。 |
1413
1414## CameraConcurrentInfo<sup>18+</sup>
1415
1416相机的输出并发能力信息。
1417
1418**系统能力:** SystemCapability.Multimedia.Camera.Core
1419
1420| 名称   | 类型    | 只读 | 可选  | 说明         |
1421| ------ | ------ | ---- |-----| ------------ |
1422| device              | [CameraDevice](#cameradevice)   | 否   | 否   | 相机并发设备。 |
1423| type                | [CameraConcurrentType](#cameraconcurrenttype18)  | 否   | 否   | 镜头并发类型。 |
1424| modes               | Array\<[SceneMode](#scenemode11) \>              | 否   | 否   | 相机支持的模式。 |
1425| outputCapabilities  | Array\<[CameraOutputCapability](#cameraoutputcapability) \> | 否   | 否   | 相机对应模式的输出能力集。 |
1426
1427## CameraInput
1428
1429相机设备输入对象。
1430
1431会话中[Session](#session11)使用的相机信息。
1432
1433### open
1434
1435open(callback: AsyncCallback\<void\>): void
1436
1437打开相机,通过注册回调函数获取状态。使用callback异步回调。
1438
1439**系统能力:** SystemCapability.Multimedia.Camera.Core
1440
1441**参数:**
1442
1443| 参数名     | 类型                  | 必填 | 说明                  |
1444| -------- | -------------------- | ---- | ------------------- |
1445| callback | AsyncCallback\<void\> | 是   | 回调函数,用于获取结果。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode)。 |
1446
1447**错误码:**
1448
1449以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
1450
1451| 错误码ID         | 错误信息        |
1452| --------------- | --------------- |
1453| 7400107                |  Can not use camera cause of conflict.               |
1454| 7400108                |  Camera disabled cause of security reason.                                  |
1455| 7400201                |  Camera service fatal error.                                  |
1456
1457**示例:**
1458
1459```ts
1460import { BusinessError } from '@kit.BasicServicesKit';
1461
1462function openCameraInput(cameraInput: camera.CameraInput): void {
1463  cameraInput.open((err: BusinessError) => {
1464    if (err) {
1465      console.error(`Failed to open the camera, error code: ${err.code}.`);
1466      return;
1467    }
1468    console.info('Callback returned with camera opened.');
1469  });
1470}
1471```
1472
1473### open
1474
1475open(): Promise\<void\>
1476
1477打开相机,通过Promise获取相机的状态。
1478
1479**系统能力:** SystemCapability.Multimedia.Camera.Core
1480
1481**返回值:**
1482
1483| 类型           | 说明                      |
1484| -------------- | ----------------------- |
1485| Promise\<void\> | 无返回结果的Promise对象。 |
1486
1487**错误码:**
1488
1489以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
1490
1491| 错误码ID   | 错误信息                                      |
1492|---------|-------------------------------------------|
1493| 7400102 | Operation not allowed.                    |
1494| 7400107 | Can not use camera cause of conflict.     |
1495| 7400108 | Camera disabled cause of security reason. |
1496| 7400201 | Camera service fatal error.               |
1497
1498**示例:**
1499
1500```ts
1501import { BusinessError } from '@kit.BasicServicesKit';
1502
1503function openCameraInput(cameraInput: camera.CameraInput): void {
1504  cameraInput.open().then(() => {
1505    console.info('Promise returned with camera opened.');
1506  }).catch((error: BusinessError) => {
1507    console.error(`Failed to open the camera, error code: ${error.code}.`);
1508  });
1509}
1510```
1511
1512### open<sup>12+</sup>
1513
1514open(isSecureEnabled: boolean): Promise\<bigint\>
1515
1516打开相机,获取安全相机的句柄。
1517
1518**系统能力:** SystemCapability.Multimedia.Camera.Core
1519
1520**参数:**
1521
1522| 参数名     | 类型                  | 必填 | 说明                                                                      |
1523| -------- | -------------------- | ---- |-------------------------------------------------------------------------|
1524| isSecureEnabled | boolean | 是   | 返回true为使能以安全的方式打开相机,返回false则反之。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode)。 |
1525
1526**返回值:**
1527
1528| 类型           | 说明                      |
1529| -------------- | ----------------------- |
1530| Promise\<bigint\> | 使用Promise的方式获取打开相机句柄。 |
1531
1532**错误码:**
1533
1534以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
1535
1536| 错误码ID         | 错误信息        |
1537| --------------- | --------------- |
1538| 7400107                |  Can not use camera cause of conflict.               |
1539| 7400108                |  Camera disabled cause of security reason.                                  |
1540| 7400201                |  Camera service fatal error.                                  |
1541
1542**示例:**
1543
1544```ts
1545import { BusinessError } from '@kit.BasicServicesKit';
1546
1547function openCameraInput(cameraInput: camera.CameraInput): void {
1548  cameraInput.open(true).then(() => {
1549    console.info('Promise returned with camera opened.');
1550  }).catch((error: BusinessError) => {
1551    console.error(`Failed to open the camera, error code: ${error.code}.`);
1552  });
1553}
1554```
1555
1556### open<sup>18+</sup>
1557
1558open(type: CameraConcurrentType): Promise\<void\>
1559
1560以指定的并发类型打开相机。
1561
1562**系统能力:** SystemCapability.Multimedia.Camera.Core
1563
1564**参数:**
1565
1566| 参数名     | 类型                  | 必填 | 说明                                                                      |
1567| -------- | -------------------- | ---- |-------------------------------------------------------------------------|
1568| type | [CameraConcurrentType](#cameraconcurrenttype18) | 是   | 以指定的并发类型打开相机。接口调用失败会返回相应错误码。|
1569
1570**返回值:**
1571
1572| 类型           | 说明                      |
1573| -------------- | ----------------------- |
1574| Promise\<void\> | Promise对象。无返回结果的Promise对象。 |
1575
1576**错误码:**
1577
1578以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
1579
1580| 错误码ID   | 错误信息                                      |
1581|---------|-------------------------------------------|
1582| 7400102 | Operation not allowed.                    |
1583| 7400107 | Can not use camera cause of conflict.     |
1584| 7400108 | Camera disabled cause of security reason. |
1585| 7400201 | Camera service fatal error.               |
1586
1587**示例:**
1588
1589```ts
1590import { BusinessError } from '@kit.BasicServicesKit';
1591
1592function openCameraInput(cameraInput: camera.CameraInput): void {
1593  cameraInput.open(0).then(() => {
1594    console.info('Promise returned with camera opened.');
1595  }).catch((error: BusinessError) => {
1596    console.error(`Failed to open the camera, error code: ${error.code}.`);
1597  });
1598}
1599```
1600
1601### close
1602
1603close(callback: AsyncCallback\<void\>\): void
1604
1605关闭相机,通过注册回调函数获取状态。使用callback异步回调。
1606
1607**系统能力:** SystemCapability.Multimedia.Camera.Core
1608
1609**参数:**
1610
1611| 参数名     | 类型                   | 必填 | 说明                  |
1612| -------- | -------------------- | ---- | -------------------- |
1613| callback | AsyncCallback\<void\> | 是   | 回调函数,用于获取结果。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode)。 |
1614
1615**错误码:**
1616
1617以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
1618
1619| 错误码ID         | 错误信息        |
1620| --------------- | --------------- |
1621| 7400201                |  Camera service fatal error.                                  |
1622
1623**示例:**
1624
1625```ts
1626import { BusinessError } from '@kit.BasicServicesKit';
1627
1628function closeCameraInput(cameraInput: camera.CameraInput): void {
1629  cameraInput.close((err: BusinessError) => {
1630    if (err) {
1631      console.error(`Failed to close the cameras, error code: ${err.code}.`);
1632      return;
1633    }
1634    console.info('Callback returned with camera closed.');
1635  });
1636}
1637```
1638
1639### close
1640
1641close(): Promise\<void\>
1642
1643关闭相机,通过Promise获取状态。
1644
1645**系统能力:** SystemCapability.Multimedia.Camera.Core
1646
1647**返回值:**
1648
1649| 类型           | 说明                      |
1650| -------------- | ----------------------- |
1651| Promise\<void\> | 无返回结果的Promise对象。 |
1652
1653**错误码:**
1654
1655以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
1656
1657| 错误码ID         | 错误信息        |
1658| --------------- | --------------- |
1659| 7400201                |  Camera service fatal error.                                  |
1660
1661**示例:**
1662
1663```ts
1664import { BusinessError } from '@kit.BasicServicesKit';
1665
1666function closeCameraInput(cameraInput: camera.CameraInput): void {
1667  cameraInput.close().then(() => {
1668    console.info('Promise returned with camera closed.');
1669  }).catch((error: BusinessError) => {
1670    console.error(`Failed to close the cameras, error code: ${error.code}.`);
1671  });
1672}
1673```
1674
1675### on('error')
1676
1677on(type: 'error', camera: CameraDevice, callback: ErrorCallback): void
1678
1679监听CameraInput的错误事件,通过注册回调函数获取结果。使用callback异步回调。
1680
1681> **说明:**
1682>
1683> 当前注册监听接口,不支持在on监听的回调方法里,调用off注销回调。
1684
1685**系统能力:** SystemCapability.Multimedia.Camera.Core
1686
1687**参数:**
1688
1689| 参数名     | 类型                              | 必填 | 说明                                          |
1690| -------- | -------------------------------- | --- | ------------------------------------------- |
1691| type     | string                           | 是   | 监听事件,固定为'error',CameraInput对象创建成功可监听。相机设备出错情况下可触发该事件并返回结果,比如设备不可用或者冲突等返回对应错误信息。 |
1692| camera   | [CameraDevice](#cameradevice)    | 是   | CameraDevice对象。 |
1693| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback) | 是   | 回调函数,用于获取结果。返回错误码,错误码类型[CameraErrorCode](#cameraerrorcode)。  |
1694
1695**示例:**
1696
1697```ts
1698import { BusinessError } from '@kit.BasicServicesKit';
1699
1700function callback(err: BusinessError): void {
1701  console.error(`Camera input error code: ${err.code}`);
1702}
1703
1704function registerCameraInputError(cameraInput: camera.CameraInput, camera: camera.CameraDevice): void {
1705  cameraInput.on('error', camera, callback);
1706}
1707```
1708
1709### off('error')
1710
1711off(type: 'error', camera: CameraDevice, callback?: ErrorCallback): void
1712
1713注销监听CameraInput的错误事件。
1714
1715**系统能力:** SystemCapability.Multimedia.Camera.Core
1716
1717**参数:**
1718
1719| 参数名     | 类型                              | 必填 | 说明                                          |
1720| -------- | -------------------------------- | --- | ------------------------------------------- |
1721| type     | string                           | 是   | 监听事件,固定为'error',CameraInput对象创建成功可监听。相机设备出错情况下可触发该事件并返回结果,比如设备不可用或者冲突等返回对应错误信息。 |
1722| camera   | [CameraDevice](#cameradevice)    | 是   | CameraDevice对象。 |
1723| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback) | 否   | 回调函数,如果指定参数则取消对应callback(callback对象不可是匿名函数),否则取消所有callback。 |
1724
1725**示例:**
1726
1727```ts
1728function unregisterCameraInputError(cameraInput: camera.CameraInput, camera: camera.CameraDevice): void {
1729  cameraInput.off('error', camera);
1730}
1731```
1732
1733## CameraOutput
1734
1735会话中[Session](#session11)使用的输出信息,output的基类。
1736
1737### release
1738
1739release(callback: AsyncCallback\<void\>): void
1740
1741释放输出资源,通过注册回调函数获取结果。使用callback异步回调。
1742
1743**系统能力:** SystemCapability.Multimedia.Camera.Core
1744
1745**参数:**
1746
1747| 参数名      | 类型                  | 必填 | 说明                 |
1748| -------- | -------------------- | ---- | ------------------- |
1749| callback | AsyncCallback\<void\> | 是   | 回调函数,用于获取结果。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode)。 |
1750
1751**错误码:**
1752
1753以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
1754
1755| 错误码ID         | 错误信息        |
1756| --------------- | --------------- |
1757| 7400201                |  Camera service fatal error.                           |
1758
1759**示例:**
1760
1761```ts
1762import { BusinessError } from '@kit.BasicServicesKit';
1763
1764function releasePreviewOutput(previewOutput: camera.PreviewOutput): void {
1765  previewOutput.release((err: BusinessError) => {
1766    if (err) {
1767      console.error(`Failed to release the Preview output instance ${err.code}`);
1768      return;
1769    }
1770    console.info('Callback invoked to indicate that the preview output instance is released successfully.');
1771  });
1772}
1773
1774function releaseVideoOutput(videoOutput: camera.VideoOutput): void {
1775  videoOutput.release((err: BusinessError) => {
1776    if (err) {
1777      console.error(`Failed to release the video output instance ${err.code}`);
1778      return;
1779    }
1780    console.info('Callback invoked to indicate that the video output instance is released successfully.');
1781  });
1782}
1783```
1784
1785### release
1786
1787release(): Promise\<void\>
1788
1789释放输出资源,通过Promise获取结果。
1790
1791**系统能力:** SystemCapability.Multimedia.Camera.Core
1792
1793**返回值:**
1794
1795| 类型            | 说明                     |
1796| -------------- | ----------------------- |
1797| Promise\<void\> | 无返回结果的Promise对象。 |
1798
1799**错误码:**
1800
1801以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
1802
1803| 错误码ID         | 错误信息        |
1804| --------------- | --------------- |
1805| 7400201                |  Camera service fatal error.                           |
1806
1807**示例:**
1808
1809```ts
1810import { BusinessError } from '@kit.BasicServicesKit';
1811
1812function releasePreviewOutput(previewOutput: camera.PreviewOutput): void {
1813  previewOutput.release().then(() => {
1814    console.info('Promise returned to indicate that the preview output instance is released successfully.');
1815  }).catch((error: BusinessError) => {
1816    console.error(`Failed to preview output release, error code: ${error.code}`);
1817  });
1818}
1819
1820function releaseVideoOutput(videoOutput: camera.VideoOutput): void {
1821  videoOutput.release().then(() => {
1822    console.info('Promise returned to indicate that the video output instance is released successfully.');
1823  }).catch((error: BusinessError) => {
1824    console.error(`Failed to video output release, error code: ${error.code}`);
1825  });
1826}
1827```
1828
1829## PreviewOutput
1830
1831预览输出类。继承[CameraOutput](#cameraoutput)。
1832
1833### start<sup>(deprecated)</sup>
1834
1835start(callback: AsyncCallback\<void\>): void
1836
1837开始输出预览流,通过注册回调函数获取结果。使用callback异步回调。
1838
1839> **说明:**
1840>从 API version 10开始支持,从API version 11开始废弃。建议使用[Session.start](#start11)替代。
1841
1842**系统能力:** SystemCapability.Multimedia.Camera.Core
1843
1844**参数:**
1845
1846| 参数名      | 类型                  | 必填 | 说明                 |
1847| -------- | -------------------- | ---- | -------------------- |
1848| callback | AsyncCallback\<void\> | 是   | 回调函数,用于获取结果。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode)。 |
1849
1850**错误码:**
1851
1852以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
1853
1854| 错误码ID         | 错误信息        |
1855| --------------- | --------------- |
1856| 7400103                |  Session not config.                                   |
1857
1858**示例:**
1859
1860```ts
1861import { BusinessError } from '@kit.BasicServicesKit';
1862
1863function startPreviewOutput(previewOutput: camera.PreviewOutput): void {
1864  previewOutput.start((err: BusinessError) => {
1865    if (err) {
1866      console.error(`Failed to start the preview output, error code: ${err.code}.`);
1867      return;
1868    }
1869    console.info('Callback returned with preview output started.');
1870  });
1871}
1872```
1873
1874### start<sup>(deprecated)</sup>
1875
1876start(): Promise\<void\>
1877
1878开始输出预览流,通过Promise获取结果。
1879
1880> **说明:**
1881>从 API version 10开始支持,从API version 11开始废弃。建议使用[Session.start](#start11-1)替代。
1882
1883**系统能力:** SystemCapability.Multimedia.Camera.Core
1884
1885**返回值:**
1886
1887| 类型            | 说明                |
1888| -------------- |-------------------|
1889| Promise\<void\> | 无返回结果的Promise对象。  |
1890
1891**错误码:**
1892
1893以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
1894
1895| 错误码ID         | 错误信息        |
1896| --------------- | --------------- |
1897| 7400103                |  Session not config.                                   |
1898
1899**示例:**
1900
1901```ts
1902import { BusinessError } from '@kit.BasicServicesKit';
1903
1904function startPreviewOutput(previewOutput: camera.PreviewOutput): void {
1905  previewOutput.start().then(() => {
1906    console.info('Promise returned with preview output started.');
1907  }).catch((error: BusinessError) => {
1908    console.error(`Failed to preview output start, error code: ${error.code}.`);
1909  });
1910}
1911```
1912
1913### stop<sup>(deprecated)</sup>
1914
1915stop(callback: AsyncCallback\<void\>): void
1916
1917停止输出预览流,通过注册回调函数获取结果。使用callback异步回调。
1918
1919> **说明:**
1920>从 API version 10开始支持,从API version 11开始废弃。建议使用[Session.stop](#stop11)替代。
1921
1922**系统能力:** SystemCapability.Multimedia.Camera.Core
1923
1924**参数:**
1925
1926| 参数名      | 类型                  | 必填 | 说明                 |
1927| -------- | -------------------- | ---- | -------------------- |
1928| callback | AsyncCallback\<void\> | 是   | 回调函数,用于获取结果。 |
1929
1930**示例:**
1931
1932```ts
1933import { BusinessError } from '@kit.BasicServicesKit';
1934
1935function stopPreviewOutput(previewOutput: camera.PreviewOutput): void {
1936  previewOutput.stop((err: BusinessError) => {
1937    if (err) {
1938      console.error(`Failed to stop the preview output, error code: ${err.code}.`);
1939      return;
1940    }
1941    console.info('Returned with preview output stopped.');
1942  })
1943}
1944```
1945
1946### stop<sup>(deprecated)</sup>
1947
1948stop(): Promise\<void\>
1949
1950停止输出预览流,通过Promise获取结果。
1951
1952> **说明:**
1953>从 API version 10开始支持,从API version 11开始废弃。建议使用[Session.stop](#stop11-1)替代。
1954
1955**系统能力:** SystemCapability.Multimedia.Camera.Core
1956
1957**返回值:**
1958
1959| 类型            | 说明                     |
1960| -------------- | ------------------------ |
1961| Promise\<void\> | 无返回结果的Promise对象。 |
1962
1963**示例:**
1964
1965```ts
1966import { BusinessError } from '@kit.BasicServicesKit';
1967
1968function stopPreviewOutput(previewOutput: camera.PreviewOutput): void {
1969  previewOutput.stop().then(() => {
1970    console.info('Callback returned with preview output stopped.');
1971  }).catch((error: BusinessError) => {
1972    console.error(`Failed to preview output stop, error code: ${error.code}.`);
1973  });
1974}
1975```
1976
1977### on('frameStart')
1978
1979on(type: 'frameStart', callback: AsyncCallback\<void\>): void
1980
1981监听预览帧启动,通过注册回调函数获取结果。使用callback异步回调。
1982
1983> **说明:**
1984>
1985> 当前注册监听接口,不支持在on监听的回调方法里,调用off注销回调。
1986
1987**系统能力:** SystemCapability.Multimedia.Camera.Core
1988
1989**参数:**
1990
1991| 参数名      | 类型                  | 必填 | 说明                                     |
1992| -------- | -------------------- | ---- | --------------------------------------- |
1993| type     | string               | 是   | 监听事件,固定为'frameStart',previewOutput创建成功可监听。底层第一次开始曝光时触发该事件并返回。 |
1994| callback | AsyncCallback\<void\> | 是   | 回调函数,用于获取结果。只要有该事件返回就证明预览开始。                    |
1995
1996**示例:**
1997
1998```ts
1999import { BusinessError } from '@kit.BasicServicesKit';
2000
2001function callback(err: BusinessError): void {
2002  if (err !== undefined && err.code !== 0) {
2003    console.error(`Callback Error, errorCode: ${err.code}`);
2004    return;
2005  }
2006  console.info('Preview frame started');
2007}
2008
2009function registerPreviewOutputFrameStart(previewOutput: camera.PreviewOutput): void {
2010  previewOutput.on('frameStart', callback);
2011}
2012```
2013
2014### off('frameStart')
2015
2016off(type: 'frameStart', callback?: AsyncCallback\<void\>): void
2017
2018注销监听预览帧启动。
2019
2020**系统能力:** SystemCapability.Multimedia.Camera.Core
2021
2022**参数:**
2023
2024| 参数名      | 类型                  | 必填 | 说明                                     |
2025| -------- | -------------------- | ---- | --------------------------------------- |
2026| type     | string               | 是   | 监听事件,固定为'frameStart',previewOutput创建成功可监听。 |
2027| callback | AsyncCallback\<void\> | 否   | 回调函数,如果指定参数则取消对应callback(callback对象不可是匿名函数),否则取消所有callback。 |
2028
2029**示例:**
2030
2031```ts
2032function unregisterPreviewOutputFrameStart(previewOutput: camera.PreviewOutput): void {
2033  previewOutput.off('frameStart');
2034}
2035```
2036
2037### on('frameEnd')
2038
2039on(type: 'frameEnd', callback: AsyncCallback\<void\>): void
2040
2041监听预览帧结束,通过注册回调函数获取结果。使用callback异步回调。
2042
2043> **说明:**
2044>
2045> 当前注册监听接口,不支持在on监听的回调方法里,调用off注销回调。
2046
2047**系统能力:** SystemCapability.Multimedia.Camera.Core
2048
2049**参数:**
2050
2051| 参数名      | 类型                  | 必填 | 说明                                  |
2052| -------- | -------------------- | ---- | ------------------------------------- |
2053| type     | string               | 是   | 监听事件,固定为'frameEnd',previewOutput创建成功可监听。预览完全结束最后一帧时触发该事件并返回。 |
2054| callback | AsyncCallback\<void\> | 是   | 回调函数,用于获取结果。只要有该事件返回就证明预览结束。                |
2055
2056**示例:**
2057
2058```ts
2059import { BusinessError } from '@kit.BasicServicesKit';
2060
2061function callback(err: BusinessError): void {
2062  if (err !== undefined && err.code !== 0) {
2063    console.error(`Callback Error, errorCode: ${err.code}`);
2064    return;
2065  }
2066  console.info('Preview frame ended');
2067}
2068
2069function registerPreviewOutputFrameEnd(previewOutput: camera.PreviewOutput): void {
2070  previewOutput.on('frameEnd', callback);
2071}
2072```
2073
2074### off('frameEnd')
2075
2076off(type: 'frameEnd', callback?: AsyncCallback\<void\>): void
2077
2078注销监听预览帧结束。
2079
2080**系统能力:** SystemCapability.Multimedia.Camera.Core
2081
2082**参数:**
2083
2084| 参数名      | 类型                  | 必填 | 说明                                  |
2085| -------- | -------------------- | ---- | ------------------------------------- |
2086| type     | string               | 是   | 监听事件,固定为'frameEnd',previewOutput创建成功可监听。 |
2087| callback | AsyncCallback\<void\> | 否   | 回调函数,如果指定参数则取消对应callback(callback对象不可是匿名函数),否则取消所有callback。 |
2088
2089**示例:**
2090
2091```ts
2092function unregisterPreviewOutputFrameEnd(previewOutput: camera.PreviewOutput): void {
2093  previewOutput.off('frameEnd');
2094}
2095```
2096
2097### on('error')
2098
2099on(type: 'error', callback: ErrorCallback): void
2100
2101监听预览输出的错误事件,通过注册回调函数获取结果。使用callback异步回调。
2102
2103> **说明:**
2104>
2105> 当前注册监听接口,不支持在on监听的回调方法里,调用off注销回调。
2106
2107**系统能力:** SystemCapability.Multimedia.Camera.Core
2108
2109**参数:**
2110
2111| 参数名     | 类型         | 必填 | 说明                       |
2112| -------- | --------------| ---- | ------------------------ |
2113| type     | string        | 是   | 监听事件,固定为'error',previewOutput创建成功可监听。预览接口使用错误时触发该事件,比如调用[Session.start](#start11-1),[CameraOutput.release](#release-1)等接口发生错误时返回对应错误信息。 |
2114| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback) | 是   | 回调函数,用于获取错误信息。返回错误码,错误码类型[CameraErrorCode](#cameraerrorcode)。  |
2115
2116**示例:**
2117
2118```ts
2119import { BusinessError } from '@kit.BasicServicesKit';
2120
2121function callback(previewOutputError: BusinessError): void {
2122  console.error(`Preview output error code: ${previewOutputError.code}`);
2123}
2124
2125function registerPreviewOutputError(previewOutput: camera.PreviewOutput): void {
2126  previewOutput.on('error', callback)
2127}
2128```
2129
2130### off('error')
2131
2132off(type: 'error', callback?: ErrorCallback): void
2133
2134注销监听预览输出的错误事件。
2135
2136**系统能力:** SystemCapability.Multimedia.Camera.Core
2137
2138**参数:**
2139
2140| 参数名     | 类型         | 必填 | 说明                       |
2141| -------- | --------------| ---- | ------------------------ |
2142| type     | string        | 是   | 监听事件,固定为'error',previewOutput创建成功可监听。 |
2143| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback) | 否   | 回调函数,如果指定参数则取消对应callback(callback对象不可是匿名函数),否则取消所有callback。 |
2144
2145**示例:**
2146
2147```ts
2148function unregisterPreviewOutputError(previewOutput: camera.PreviewOutput): void {
2149  previewOutput.off('error');
2150}
2151```
2152
2153### getSupportedFrameRates<sup>12+</sup>
2154
2155 getSupportedFrameRates(): Array\<FrameRateRange\>
2156
2157查询支持的帧率范围。
2158
2159**系统能力:** SystemCapability.Multimedia.Camera.Core
2160
2161**返回值:**
2162|      类型      |     说明     |
2163| -------------  | ------------ |
2164| Array<[FrameRateRange](#frameraterange)> | 支持的帧率范围列表 |
2165
2166**示例:**
2167
2168```ts
2169function getSupportedFrameRates(previewOutput: camera.PreviewOutput): Array<camera.FrameRateRange> {
2170  let supportedFrameRatesArray: Array<camera.FrameRateRange> = previewOutput.getSupportedFrameRates();
2171  return supportedFrameRatesArray;
2172}
2173```
2174
2175### setFrameRate<sup>12+</sup>
2176
2177setFrameRate(minFps: number, maxFps: number): void
2178
2179设置预览流帧率范围,设置的范围必须在支持的帧率范围内。
2180进行设置前,可通过[getSupportedFrameRates](#getsupportedframerates12)查询支持的帧率范围。
2181
2182> **说明:**
2183> 仅在[PhotoSession](#photosession11)或[VideoSession](#videosession11)模式下支持。
2184
2185**系统能力:** SystemCapability.Multimedia.Camera.Core
2186
2187**参数:**
2188
2189| 参数名     | 类型         | 必填 | 说明                       |
2190| -------- | --------------| ---- | ------------------------ |
2191| minFps   | number        | 是   | 最小帧率(单位:fps)。 |
2192| maxFps   | number        | 是   | 最大帧率(单位:fps),当传入的最小值大于最大值时,传参异常,接口不生效。|
2193
2194**错误码:**
2195
2196以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
2197
2198| 错误码ID        | 错误信息        |
2199| --------------- | --------------- |
2200| 7400101                |  Parameter missing or parameter type incorrect.        |
2201| 7400110                |  Unresolved conflicts with current configurations.     |
2202
2203**示例:**
2204
2205```ts
2206function setFrameRateRange(previewOutput: camera.PreviewOutput, frameRateRange: Array<number>): void {
2207  previewOutput.setFrameRate(frameRateRange[0], frameRateRange[1]);
2208}
2209```
2210
2211### getActiveFrameRate<sup>12+</sup>
2212
2213getActiveFrameRate(): FrameRateRange
2214
2215获取已设置的帧率范围。
2216
2217使用[setFrameRate](#setframerate12)对预览流设置过帧率后可查询。
2218
2219**系统能力:** SystemCapability.Multimedia.Camera.Core
2220
2221**返回值:**
2222
2223|      类型      |     说明     |
2224| -------------  | ------------ |
2225| [FrameRateRange](#frameraterange) | 帧率范围 |
2226
2227**示例:**
2228
2229```ts
2230function getActiveFrameRate(previewOutput: camera.PreviewOutput): camera.FrameRateRange {
2231  let activeFrameRate: camera.FrameRateRange = previewOutput.getActiveFrameRate();
2232  return activeFrameRate;
2233}
2234```
2235
2236### getActiveProfile<sup>12+</sup>
2237
2238getActiveProfile(): Profile
2239
2240获取当前生效的配置信息。
2241
2242**系统能力:** SystemCapability.Multimedia.Camera.Core
2243
2244**返回值:**
2245
2246|      类型      | 说明        |
2247| -------------  |-----------|
2248| [Profile](#profile) | 当前生效的配置信息 |
2249
2250**错误码:**
2251
2252以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
2253
2254| 错误码ID   | 错误信息                         |
2255|---------|------------------------------|
2256| 7400201 | Camera service fatal error.  |
2257
2258**示例:**
2259
2260```ts
2261function testGetActiveProfile(previewOutput: camera.PreviewOutput): camera.Profile | undefined {
2262  let activeProfile: camera.Profile | undefined = undefined;
2263  try {
2264    activeProfile = previewOutput.getActiveProfile();
2265  } catch (error) {
2266    // 失败返回错误码error.code并处理。
2267    let err = error as BusinessError;
2268    console.error(`The previewOutput.getActiveProfile call failed. error code: ${err.code}`);
2269  }
2270  return activeProfile;
2271}
2272```
2273
2274### getPreviewRotation<sup>12+</sup>
2275
2276getPreviewRotation(displayRotation: number): ImageRotation
2277
2278获取预览旋转角度。
2279
2280- 设备自然方向:设备默认使用方向,手机为竖屏(充电口向下)。
2281- 相机镜头角度:值等于相机图像顺时针旋转到设备自然方向的角度,手机后置相机传感器是横屏安装的,所以需要顺时针旋转90度到设备自然方向。
2282- 屏幕显示方向:需要屏幕显示的图片左上角为第一个像素点为坐标原点。锁屏时与自然方向一致。
2283
2284**系统能力:** SystemCapability.Multimedia.Camera.Core
2285
2286**参数:**
2287
2288| 参数名     | 类型         | 必填 | 说明                       |
2289| -------- | --------------| ---- | ------------------------ |
2290| displayRotation | number  | 是   | 显示设备的屏幕旋转角度,通过[display.getDefaultDisplaySync](../apis-arkui/js-apis-display.md#displaygetdefaultdisplaysync9)获得。 |
2291
2292**返回值:**
2293
2294|      类型      | 说明        |
2295| -------------  |-----------|
2296| [ImageRotation](#imagerotation) | 获取预览旋转角度。 |
2297
2298**错误码:**
2299
2300以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
2301
2302| 错误码ID   | 错误信息                         |
2303|---------|------------------------------|
2304| 7400101 | Parameter missing or parameter type incorrect.  |
2305| 7400201 | Camera service fatal error.  |
2306
2307**示例:**
2308
2309```ts
2310function testGetPreviewRotation(previewOutput: camera.PreviewOutput, imageRotation : camera.ImageRotation): camera.ImageRotation {
2311  let previewRotation: camera.ImageRotation = camera.ImageRotation.ROTATION_0;
2312  try {
2313    previewRotation = previewOutput.getPreviewRotation(imageRotation);
2314    console.log(`Preview rotation is: ${previewRotation}`);
2315  } catch (error) {
2316    // 失败返回错误码error.code并处理。
2317    let err = error as BusinessError;
2318    console.error(`The previewOutput.getPreviewRotation call failed. error code: ${err.code}`);
2319  }
2320  return previewRotation;
2321}
2322```
2323### setPreviewRotation<sup>12+</sup>
2324setPreviewRotation(previewRotation: ImageRotation, isDisplayLocked?: boolean): void
2325
2326设置预览旋转角度。
2327
2328**系统能力:** SystemCapability.Multimedia.Camera.Core
2329
2330**参数:**
2331
2332| 参数名     | 类型         | 必填 | 说明                       |
2333| -------- | --------------| ---- | ------------------------ |
2334| previewRotation | [ImageRotation](#imagerotation)  | 是   | 预览旋转角度 |
2335| isDisplayLocked | boolean  | 否   | 是否旋转锁定 |
2336
2337**错误码:**
2338
2339以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
2340
2341| 错误码ID   | 错误信息                         |
2342|---------|------------------------------|
2343| 7400101 | Parameter missing or parameter type incorrect.  |
2344| 7400201 | Camera service fatal error.  |
2345
2346**示例:**
2347
2348```ts
2349function testSetPreviewRotation(previewOutput: camera.PreviewOutput, previewRotation : camera.ImageRotation, isDisplayLocked: boolean): void {
2350  try {
2351    previewOutput.setPreviewRotation(previewRotation, isDisplayLocked);
2352  } catch (error) {
2353    // 失败返回错误码error.code并处理。
2354    let err = error as BusinessError;
2355    console.error(`The previewOutput.setPreviewRotation call failed. error code: ${err.code}`);
2356  }
2357  return;
2358}
2359```
2360## ImageRotation
2361
2362枚举,图片旋转角度。
2363
2364**系统能力:** SystemCapability.Multimedia.Camera.Core
2365
2366| 名称          | 值   | 说明           |
2367| ------------ | ---- | ------------- |
2368| ROTATION_0   | 0    | 图片旋转0度。   |
2369| ROTATION_90  | 90   | 图片旋转90度。  |
2370| ROTATION_180 | 180  | 图片旋转180度。 |
2371| ROTATION_270 | 270  | 图片旋转270度。 |
2372
2373## Location
2374
2375图片地理位置信息。
2376
2377**系统能力:** SystemCapability.Multimedia.Camera.Core
2378
2379| 名称          | 类型   | 只读 | 可选  |说明         |
2380| ------------ | ------ | ---- |-----|------------ |
2381| latitude     | number |  否  | 否   |纬度(度)。    |
2382| longitude    | number |  否  | 否   |经度(度)。    |
2383| altitude     | number |  否  | 否   |海拔(米)。    |
2384
2385## QualityLevel
2386
2387枚举,图片质量。
2388
2389**系统能力:** SystemCapability.Multimedia.Camera.Core
2390
2391| 名称                  | 值   | 说明         |
2392| -------------------- | ---- | ------------ |
2393| QUALITY_LEVEL_HIGH   | 0    | 图片质量高。   |
2394| QUALITY_LEVEL_MEDIUM | 1    | 图片质量中等。 |
2395| QUALITY_LEVEL_LOW    | 2    | 图片质量差。   |
2396
2397
2398## PhotoCaptureSetting
2399
2400拍摄照片的设置。
2401
2402**系统能力:** SystemCapability.Multimedia.Camera.Core
2403
2404| 名称      | 类型                            | 只读 | 可选 | 说明                                                                   |
2405| -------- | ------------------------------- | ---- | ---- |----------------------------------------------------------------------|
2406| quality  | [QualityLevel](#qualitylevel)   | 否   | 是   | 图片质量(默认低)。                                                           |
2407| rotation | [ImageRotation](#imagerotation) | 否   | 是   | 图片旋转角度(默认0度,顺时针旋转)。                                                  |
2408| location | [Location](#location)           | 否   | 是   | 图片地理位置信息(默认以设备硬件信息为准)。                                               |
2409| mirror   | boolean                         | 否   | 是   | 镜像使能开关(默认关)。使用之前需要使用[isMirrorSupported](#ismirrorsupported)进行判断是否支持。 |
2410
2411## Photo<sup>11+</sup>
2412
2413全质量图对象。
2414
2415### 属性
2416
2417**系统能力:** SystemCapability.Multimedia.Camera.Core
2418
2419| 名称   | 类型                            |     必填     | 说明       |
2420| ------ | ----------------------------- | -------------- | ---------- |
2421| main<sup>11+</sup> | [image.Image](../apis-image-kit/js-apis-image.md#image9) |        是       | 全质量图Image。 |
2422
2423### release<sup>11+</sup>
2424
2425release(): Promise\<void\>
2426
2427释放输出资源,通过Promise获取结果。
2428
2429**系统能力:** SystemCapability.Multimedia.Camera.Core
2430
2431**返回值:**
2432
2433| 类型            | 说明                     |
2434| -------------- | ----------------------- |
2435| Promise\<void\> | 无返回结果的Promise对象。 |
2436
2437**示例:**
2438
2439```ts
2440async function releasePhoto(photo: camera.Photo): Promise<void> {
2441  await photo.release();
2442}
2443```
2444
2445## PhotoOutput
2446
2447拍照会话中使用的输出信息,继承[CameraOutput](#cameraoutput)。
2448
2449### capture
2450
2451capture(callback: AsyncCallback\<void\>): void
2452
2453以默认设置触发一次拍照,通过注册回调函数获取结果。使用callback异步回调。
2454
2455**系统能力:** SystemCapability.Multimedia.Camera.Core
2456
2457**参数:**
2458
2459| 参数名      | 类型                  | 必填 | 说明                 |
2460| -------- | -------------------- | ---- | ------------------- |
2461| callback | AsyncCallback\<void\> | 是   | 回调函数,用于获取结果。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode)。 |
2462
2463**错误码:**
2464
2465以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
2466
2467| 错误码ID         | 错误信息        |
2468| --------------- | --------------- |
2469| 7400104                |  Session not running.                                  |
2470| 7400201                |  Camera service fatal error.                           |
2471
2472**示例:**
2473
2474```ts
2475import { BusinessError } from '@kit.BasicServicesKit';
2476
2477function capture(photoOutput: camera.PhotoOutput): void {
2478  photoOutput.capture((err: BusinessError) => {
2479    if (err) {
2480      console.error(`Failed to capture the photo, error code: ${err.code}.`);
2481      return;
2482    }
2483    console.info('Callback invoked to indicate the photo capture request success.');
2484  });
2485}
2486```
2487
2488### capture
2489
2490capture(): Promise\<void\>
2491
2492以默认设置触发一次拍照,通过Promise获取结果。
2493
2494**系统能力:** SystemCapability.Multimedia.Camera.Core
2495
2496**返回值:**
2497
2498| 类型            | 说明                     |
2499| -------------- | ------------------------ |
2500| Promise\<void\> | 无返回结果的Promise对象。 |
2501
2502**错误码:**
2503
2504以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
2505
2506| 错误码ID         | 错误信息        |
2507| --------------- | --------------- |
2508| 7400104                |  Session not running.                                  |
2509| 7400201                |  Camera service fatal error.                           |
2510
2511**示例:**
2512
2513```ts
2514import { BusinessError } from '@kit.BasicServicesKit';
2515
2516function capture(photoOutput: camera.PhotoOutput): void {
2517  photoOutput.capture().then(() => {
2518    console.info('Promise returned to indicate that photo capture request success.');
2519  }).catch((error: BusinessError) => {
2520    console.error(`Failed to photo output capture, error code: ${error.code}.`);
2521  });
2522}
2523```
2524
2525### capture
2526
2527capture(setting: PhotoCaptureSetting, callback: AsyncCallback\<void\>): void
2528
2529以指定参数触发一次拍照,通过注册回调函数获取结果。使用callback异步回调。
2530
2531**系统能力:** SystemCapability.Multimedia.Camera.Core
2532
2533**参数:**
2534
2535| 参数名      | 类型                                         | 必填 | 说明                  |
2536| -------- | ------------------------------------------- | ---- | -------------------- |
2537| setting  | [PhotoCaptureSetting](#photocapturesetting) | 是   | 拍照设置。             |
2538| callback | AsyncCallback\<void\>                        | 是   | 回调函数,用于获取结果。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode)。  |
2539
2540**错误码:**
2541
2542以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
2543
2544| 错误码ID         | 错误信息        |
2545| --------------- | --------------- |
2546| 7400101                |  Parameter missing or parameter type incorrect.        |
2547| 7400104                |  Session not running.                                  |
2548| 7400201                |  Camera service fatal error.                           |
2549
2550**示例:**
2551
2552```ts
2553import { BusinessError } from '@kit.BasicServicesKit';
2554
2555function capture(photoOutput: camera.PhotoOutput): void {
2556  let captureLocation: camera.Location = {
2557    latitude: 0,
2558    longitude: 0,
2559    altitude: 0
2560  }
2561  let settings: camera.PhotoCaptureSetting = {
2562    quality: camera.QualityLevel.QUALITY_LEVEL_LOW,
2563    rotation: camera.ImageRotation.ROTATION_0,
2564    location: captureLocation,
2565    mirror: false
2566  }
2567  photoOutput.capture(settings, (err: BusinessError) => {
2568    if (err) {
2569      console.error(`Failed to capture the photo, error code: ${err.code}.`);
2570      return;
2571    }
2572    console.info('Callback invoked to indicate the photo capture request success.');
2573  });
2574}
2575```
2576
2577### capture
2578
2579capture(setting: PhotoCaptureSetting): Promise\<void\>
2580
2581以指定参数触发一次拍照,通过Promise获取结果。
2582
2583**系统能力:** SystemCapability.Multimedia.Camera.Core
2584
2585**参数:**
2586
2587| 参数名     | 类型                                         | 必填 | 说明      |
2588| ------- | ------------------------------------------- | ---- | -------- |
2589| setting | [PhotoCaptureSetting](#photocapturesetting) | 是   | 拍照设置,传入undefined类型数据按默认无参处理。 |
2590
2591**返回值:**
2592
2593| 类型            | 说明                     |
2594| -------------- | ------------------------ |
2595| Promise\<void\> | 无返回结果的Promise对象。 |
2596
2597**错误码:**
2598
2599以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
2600
2601| 错误码ID         | 错误信息        |
2602| --------------- | --------------- |
2603| 7400101                |  Parameter missing or parameter type incorrect.        |
2604| 7400104                |  Session not running.                                  |
2605| 7400201                |  Camera service fatal error.                           |
2606
2607**示例:**
2608
2609```ts
2610import { BusinessError } from '@kit.BasicServicesKit';
2611
2612function capture(photoOutput: camera.PhotoOutput): void {
2613  let captureLocation: camera.Location = {
2614    latitude: 0,
2615    longitude: 0,
2616    altitude: 0
2617  }
2618  let settings: camera.PhotoCaptureSetting = {
2619    quality: camera.QualityLevel.QUALITY_LEVEL_LOW,
2620    rotation: camera.ImageRotation.ROTATION_0,
2621    location: captureLocation,
2622    mirror: false
2623  }
2624  photoOutput.capture(settings).then(() => {
2625    console.info('Promise returned to indicate that photo capture request success.');
2626  }).catch((error: BusinessError) => {
2627    console.error(`Failed to photo output capture, error code: ${error.code}.`);
2628  });
2629}
2630```
2631
2632### on('photoAvailable')<sup>11+</sup>
2633
2634on(type: 'photoAvailable', callback: AsyncCallback\<Photo\>): void
2635
2636注册监听全质量图上报。使用callback异步回调。
2637
2638> **说明:**
2639>
2640> 当前注册监听接口,不支持在on监听的回调方法里,调用off注销回调。
2641
2642**系统能力:** SystemCapability.Multimedia.Camera.Core
2643
2644**参数:**
2645
2646| 参数名     | 类型      | 必填 | 说明                                  |
2647| -------- | ---------- | --- | ------------------------------------ |
2648| type     | string     | 是   | 监听事件,固定为'photoAvailable',photoOutput创建成功后可监听。 |
2649| callback | AsyncCallback\<[Photo](#photo11)\> | 是   | 回调函数,用于监听全质量图上报。 |
2650
2651**示例:**
2652
2653```ts
2654import { BusinessError } from '@kit.BasicServicesKit';
2655import { image } from '@kit.ImageKit';
2656
2657function callback(err: BusinessError, photo: camera.Photo): void {
2658  if (err !== undefined && err.code !== 0) {
2659    console.error(`Callback Error, errorCode: ${err.code}`);
2660    return;
2661  }
2662  let mainImage: image.Image = photo.main;
2663}
2664
2665function registerPhotoOutputPhotoAvailable(photoOutput: camera.PhotoOutput): void {
2666  photoOutput.on('photoAvailable', callback);
2667}
2668```
2669
2670### off('photoAvailable')<sup>11+</sup>
2671
2672off(type: 'photoAvailable', callback?: AsyncCallback\<Photo\>): void
2673
2674注销监听全质量图上报。
2675
2676**系统能力:** SystemCapability.Multimedia.Camera.Core
2677
2678**参数:**
2679
2680| 参数名      | 类型                    | 必填 | 说明                                       |
2681| -------- | ---------------------- | ---- | ------------------------------------------ |
2682| type     | string                 | 是   | 监听事件,固定为'photoAvailable',photoOutput创建成功后可监听。 |
2683| callback | AsyncCallback\<[Photo](#photo11)\> | 否   | 回调函数,如果指定参数则取消对应callback(callback对象不可是匿名函数),否则取消所有callback。 |
2684
2685**示例:**
2686
2687```ts
2688import { BusinessError } from '@kit.BasicServicesKit';
2689import { image } from '@kit.ImageKit';
2690
2691function callback(err: BusinessError, photo: camera.Photo): void {
2692  if (err !== undefined && err.code !== 0) {
2693    console.error(`Callback Error, errorCode: ${err.code}`);
2694    return;
2695  }
2696  let mainImage: image.Image = photo.main;
2697}
2698
2699function unRegisterPhotoOutputPhotoAvailable(photoOutput: camera.PhotoOutput): void {
2700  photoOutput.off('photoAvailable', callback);
2701}
2702```
2703
2704### on('captureStartWithInfo')<sup>11+</sup>
2705
2706on(type: 'captureStartWithInfo', callback: AsyncCallback\<CaptureStartInfo\>): void
2707
2708监听拍照开始,通过注册回调函数获取[CaptureStartInfo](#capturestartinfo11)。使用callback异步回调。
2709
2710> **说明:**
2711>
2712> 当前注册监听接口,不支持在on监听的回调方法里,调用off注销回调。
2713
2714**系统能力:** SystemCapability.Multimedia.Camera.Core
2715
2716**参数:**
2717
2718| 参数名     | 类型      | 必填 | 说明                                  |
2719| -------- | ---------- | --- | ------------------------------------ |
2720| type     | string     | 是   | 监听事件,固定为'captureStartWithInfo',photoOutput创建成功后可监听。 |
2721| callback | AsyncCallback\<[CaptureStartInfo](#capturestartinfo11)\> | 是   | 使用callback的方式获取Capture ID。|
2722
2723**示例:**
2724
2725```ts
2726import { BusinessError } from '@kit.BasicServicesKit';
2727
2728function callback(err: BusinessError, captureStartInfo: camera.CaptureStartInfo): void {
2729  if (err !== undefined && err.code !== 0) {
2730    console.error(`Callback Error, errorCode: ${err.code}`);
2731    return;
2732  }
2733  console.info(`photo capture started, captureStartInfo : ${captureStartInfo}`);
2734}
2735
2736function registerCaptureStartWithInfo(photoOutput: camera.PhotoOutput): void {
2737  photoOutput.on('captureStartWithInfo', callback);
2738}
2739```
2740
2741### off('captureStartWithInfo')<sup>11+</sup>
2742
2743off(type: 'captureStartWithInfo', callback?: AsyncCallback\<CaptureStartInfo\>): void
2744
2745注销监听拍照。
2746
2747**系统能力:** SystemCapability.Multimedia.Camera.Core
2748
2749**参数:**
2750
2751| 参数名      | 类型                    | 必填 | 说明                                       |
2752| -------- | ---------------------- | ---- | ------------------------------------------ |
2753| type     | string                 | 是   | 监听事件,固定为'captureStartWithInfo',photoOutput创建成功后可监听。 |
2754| callback | AsyncCallback\<[CaptureStartInfo](#capturestartinfo11)\> | 否   | 回调函数,如果指定参数则取消对应callback(callback对象不可是匿名函数),否则取消所有callback。 |
2755
2756**示例:**
2757
2758```ts
2759import { BusinessError } from '@kit.BasicServicesKit';
2760
2761function unRegisterCaptureStartWithInfo(photoOutput: camera.PhotoOutput): void {
2762  photoOutput.off('captureStartWithInfo');
2763}
2764```
2765
2766### isMovingPhotoSupported<sup>12+</sup>
2767
2768isMovingPhotoSupported(): boolean
2769
2770查询是否支持动态照片拍摄。
2771
2772**系统能力:** SystemCapability.Multimedia.Camera.Core
2773
2774**返回值:**
2775
2776| 类型            | 说明                     |
2777| -------------- | ----------------------- |
2778| boolean | 返回是否支持动态照片拍照,true表示支持,false表示不支持。 |
2779
2780**错误码:**
2781
2782以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
2783
2784| 错误码ID       | 错误信息       |
2785| -------------- | --------------- |
2786| 7400201 |  Camera service fatal error. |
2787
2788**示例:**
2789
2790```ts
2791import { BusinessError } from '@kit.BasicServicesKit';
2792
2793function isMovingPhotoSupported(photoOutput: camera.PhotoOutput): boolean {
2794  let isSupported: boolean = false;
2795  try {
2796    isSupported = photoOutput.isMovingPhotoSupported();
2797  } catch (error) {
2798    // 失败返回错误码error.code并处理。
2799    let err = error as BusinessError;
2800    console.error(`The isMovingPhotoSupported call failed. error code: ${err.code}`);
2801  }
2802  return isSupported;
2803}
2804```
2805
2806### enableMovingPhoto<sup>12+</sup>
2807
2808enableMovingPhoto(enabled: boolean): void
2809
2810使能动态照片拍照。
2811
2812**需要权限:** ohos.permission.MICROPHONE
2813
2814**系统能力:** SystemCapability.Multimedia.Camera.Core
2815
2816**参数:**
2817
2818| 参数名      | 类型                    | 必填 | 说明                                       |
2819| -------- | ---------------------- | ---- | ------------------------------------------ |
2820| enabled  | boolean                | 是   | true为开启动态照片,false为关闭动态照片。     |
2821
2822**错误码:**
2823
2824以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
2825
2826| 错误码ID    | 错误信息                                           |
2827| -------- |------------------------------------------------|
2828| 201      | permission denied.                             |
2829| 7400101  | Parameter missing or parameter type incorrect. |
2830| 7400201  | Camera service fatal error.                    |
2831
2832**示例:**
2833
2834```ts
2835import { BusinessError } from '@kit.BasicServicesKit';
2836
2837function enableMovingPhoto(photoOutput: camera.PhotoOutput): void {
2838  try {
2839    photoOutput.enableMovingPhoto(true);
2840  } catch (error) {
2841    // 失败返回错误码error.code并处理。
2842    let err = error as BusinessError;
2843    console.error(`The enableMovingPhoto call failed. error code: ${err.code}`);
2844  }
2845}
2846```
2847
2848### on('photoAssetAvailable')<sup>12+</sup>
2849
2850on(type: 'photoAssetAvailable', callback: AsyncCallback\<photoAccessHelper.PhotoAsset\>): void
2851
2852注册监听photoAsset上报。使用callback异步回调。
2853
2854> **说明:**
2855>
2856> 当前注册监听接口,不支持在on监听的回调方法里,调用off注销回调。
2857
2858**系统能力:** SystemCapability.Multimedia.Camera.Core
2859
2860**参数:**
2861
2862| 参数名     | 类型      | 必填 | 说明                                  |
2863| -------- | ---------- | --- | ------------------------------------ |
2864| type     | string     | 是   | 监听事件,固定为'photoAssetAvailable',photoOutput创建成功后可监听。 |
2865| callback | AsyncCallback\<[photoAccessHelper.PhotoAsset](../apis-media-library-kit/js-apis-photoAccessHelper.md#photoasset)\> | 是   | 回调函数,用于监听photoAsset上报。 |
2866
2867**示例:**
2868
2869```ts
2870import { BusinessError } from '@kit.BasicServicesKit';
2871import { photoAccessHelper } from '@kit.MediaLibraryKit';
2872
2873function photoAssetAvailableCallback(err: BusinessError, photoAsset: photoAccessHelper.PhotoAsset): void {
2874  if (err) {
2875    console.info(`photoAssetAvailable error: ${JSON.stringify(err)}.`);
2876    return;
2877  }
2878  console.info('photoOutPutCallBack photoAssetAvailable');
2879  // 开发者可通过photoAsset获取图片相关信息。
2880}
2881
2882function onPhotoOutputPhotoAssetAvailable(photoOutput: camera.PhotoOutput): void {
2883  photoOutput.on('photoAssetAvailable', photoAssetAvailableCallback);
2884}
2885```
2886
2887### off('photoAssetAvailable')<sup>12+</sup>
2888
2889off(type: 'photoAssetAvailable', callback?: AsyncCallback\<photoAccessHelper.PhotoAsset\>): void
2890
2891解注册photoAsset上报。
2892
2893**系统能力:** SystemCapability.Multimedia.Camera.Core
2894
2895**参数:**
2896
2897| 参数名     | 类型      | 必填  | 说明                                                                         |
2898| -------- | ---------- |-----|----------------------------------------------------------------------------|
2899| type     | string     | 是   | 监听事件,固定为'photoAssetAvailable',photoOutput创建成功后可监听。                         |
2900| callback | AsyncCallback\<[photoAccessHelper.PhotoAsset](../apis-media-library-kit/js-apis-photoAccessHelper.md#photoasset)\> | 否   | 需要解监听的回调方法。如果callback不为空且与此对应的监听方法一致,不为匿名方法,则解注册该方法;如果callback为空,则解监听所有回调。 |
2901
2902**示例:**
2903
2904```ts
2905function offPhotoOutputPhotoAssetAvailable(photoOutput: camera.PhotoOutput): void {
2906  photoOutput.off('photoAssetAvailable');
2907}
2908```
2909
2910### isMirrorSupported
2911
2912isMirrorSupported(): boolean
2913
2914查询是否支持镜像拍照。
2915
2916**系统能力:** SystemCapability.Multimedia.Camera.Core
2917
2918**返回值:**
2919
2920| 类型            | 说明                     |
2921| -------------- | ----------------------- |
2922| boolean | 返回是否支持镜像拍照,true表示支持,false表示不支持。 |
2923
2924**示例:**
2925
2926```ts
2927function isMirrorSupported(photoOutput: camera.PhotoOutput): boolean {
2928  let isSupported: boolean = photoOutput.isMirrorSupported();
2929  return isSupported;
2930}
2931```
2932
2933### enableMirror<sup>13+</sup>
2934
2935enableMirror(enabled: boolean): void
2936
2937是否启用动态照片镜像拍照。
2938
2939调用该接口前,需要通过[isMovingPhotoSupported](#ismovingphotosupported12)查询是否支持动态照片拍摄功能以及通过[isMirrorSupported](#ismirrorsupported)查询是否支持镜像拍照功能。
2940
2941**系统能力:** SystemCapability.Multimedia.Camera.Core
2942
2943**参数:**
2944
2945| 参数名      | 类型                    | 必填 | 说明                        |
2946|----------| ---------------------- | ---- |---------------------------|
2947| enabled | boolean                | 是   | true为开启动态照片镜像拍照,false为关闭动态照片镜像拍照。 |
2948
2949**错误码:**
2950
2951以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
2952
2953| 错误码ID    | 错误信息                                           |
2954| -------- |------------------------------------------------|
2955| 7400101  | Parameter missing or parameter type incorrect. |
2956| 7400103  | Session not config.                    |
2957| 7400201  | Camera service fatal error.            |
2958
2959
2960**示例:**
2961
2962```ts
2963import { BusinessError } from '@kit.BasicServicesKit';
2964
2965function enableMirror(photoOutput: camera.PhotoOutput): void {
2966  try {
2967    photoOutput.enableMirror(true);
2968  } catch (error) {
2969    // 失败返回错误码error.code并处理。
2970    let err = error as BusinessError;
2971    console.error(`The enableMirror call failed. error code: ${err.code}`);
2972  }
2973}
2974```
2975
2976### getSupportedMovingPhotoVideoCodecTypes<sup>13+</sup>
2977
2978getSupportedMovingPhotoVideoCodecTypes(): Array\<VideoCodecType\>
2979
2980查询支持的动态照片短视频编码类型。
2981
2982**系统能力:** SystemCapability.Multimedia.Camera.Core
2983
2984**返回值:**
2985
2986| 类型            | 说明                |
2987| -------------- |-------------------|
2988| Array\<[VideoCodecType](#videocodectype13)\> | 支持的动态照片短视频编码类型列表。 |
2989
2990**错误码:**
2991
2992以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
2993
2994| 错误码ID        | 错误信息                      |
2995| --------------- | ---------------               |
2996| 7400201         |  Camera service fatal error.  |
2997
2998**示例:**
2999
3000```ts
3001function getSupportedMovingPhotoVideoCodecType(photoOutput: camera.PhotoOutput): Array<camera.VideoCodecType> {
3002  let supportedVideoCodecTypesArray: Array<camera.VideoCodecType> = photoOutput.getSupportedMovingPhotoVideoCodecTypes();
3003  return supportedVideoCodecTypesArray;
3004}
3005```
3006
3007### setMovingPhotoVideoCodecType<sup>13+</sup>
3008
3009setMovingPhotoVideoCodecType(codecType: VideoCodecType): void
3010
3011设置动态照片短视频编码类型。
3012
3013**系统能力:** SystemCapability.Multimedia.Camera.Core
3014
3015**参数:**
3016
3017| 参数名        | 类型                                  | 必填 |  说明                |
3018| ------------- |-------------------------------------|-------| ------------        |
3019| codecType     | [VideoCodecType](#videocodectype13) |  是    |获取动态照片短视频编码类型。  |
3020
3021**错误码:**
3022
3023以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
3024
3025| 错误码ID        | 错误信息                      |
3026| --------------- | ---------------               |
3027| 7400201         |  Camera service fatal error.  |
3028
3029**示例:**
3030
3031```ts
3032function setMovingPhotoVideoCodecTypes(photoOutput: camera.PhotoOutput, videoCodecType: camera.VideoCodecType): void {
3033   photoOutput.setMovingPhotoVideoCodecType(videoCodecType);
3034}
3035```
3036
3037### on('captureStart')<sup>(deprecated)</sup>
3038
3039on(type: 'captureStart', callback: AsyncCallback\<number\>): void
3040
3041监听拍照开始,通过注册回调函数获取Capture ID。使用callback异步回调。
3042
3043> **说明:**
3044> 从 API version 10开始支持,从API version 11开始废弃。建议使用[on('captureStartWithInfo')](#oncapturestartwithinfo11)替代。
3045>
3046> 当前注册监听接口,不支持在on监听的回调方法里,调用off注销回调。
3047
3048**系统能力:** SystemCapability.Multimedia.Camera.Core
3049
3050**参数:**
3051
3052| 参数名      | 类型                    | 必填 | 说明                                       |
3053| -------- | ---------------------- | ---- | ------------------------------------------ |
3054| type     | string                 | 是   | 监听事件,固定为'captureStart',photoOutput创建成功后可监听。每次拍照,底层开始曝光时触发该事件并返回。 |
3055| callback | AsyncCallback\<number\> | 是   | 使用callback的方式获取Capture ID。            |
3056
3057**示例:**
3058
3059```ts
3060import { BusinessError } from '@kit.BasicServicesKit';
3061
3062function callback(err: BusinessError, captureId: number): void {
3063  if (err !== undefined && err.code !== 0) {
3064    console.error(`Callback Error, errorCode: ${err.code}`);
3065    return;
3066  }
3067  console.info(`photo capture started, captureId : ${captureId}`);
3068}
3069
3070function registerPhotoOutputCaptureStart(photoOutput: camera.PhotoOutput): void {
3071  photoOutput.on('captureStart', callback);
3072}
3073```
3074
3075### off('captureStart')<sup>(deprecated)</sup>
3076
3077off(type: 'captureStart', callback?: AsyncCallback\<number\>): void
3078
3079注销监听拍照开始。
3080
3081> **说明:**
3082> 从 API version 10开始支持,从API version 11开始废弃。建议使用[off('captureStartWithInfo')](#offcapturestartwithinfo11)替代。
3083>
3084> 当前注册监听接口,不支持在on监听的回调方法里,调用off注销回调。
3085
3086**系统能力:** SystemCapability.Multimedia.Camera.Core
3087
3088**参数:**
3089
3090| 参数名      | 类型                    | 必填 | 说明                                       |
3091| -------- | ---------------------- | ---- | ------------------------------------------ |
3092| type     | string                 | 是   | 监听事件,固定为'captureStart',photoOutput创建成功后可监听。 |
3093| callback | AsyncCallback\<number\> | 否   | 回调函数,如果指定参数则取消对应callback(callback对象不可是匿名函数),否则取消所有callback。 |
3094
3095**示例:**
3096
3097```ts
3098function unregisterPhotoOutputCaptureStart(photoOutput: camera.PhotoOutput): void {
3099  photoOutput.off('captureStart');
3100}
3101```
3102
3103### on('frameShutter')
3104
3105on(type: 'frameShutter', callback: AsyncCallback\<FrameShutterInfo\>): void
3106
3107监听拍照帧输出捕获,通过注册回调函数获取结果。使用callback异步回调。
3108
3109**系统能力:** SystemCapability.Multimedia.Camera.Core
3110
3111**参数:**
3112
3113| 参数名     | 类型      | 必填 | 说明                                  |
3114| -------- | ---------- | --- | ------------------------------------ |
3115| type     | string     | 是   | 监听事件,固定为'frameShutter',photoOutput创建成功后可监听。 |
3116| callback | AsyncCallback\<[FrameShutterInfo](#frameshutterinfo)\> | 是   | 回调函数,用于获取相关信息。该回调返回意味着可以再次下发拍照请求。             |
3117
3118**示例:**
3119
3120```ts
3121import { BusinessError } from '@kit.BasicServicesKit';
3122
3123function callback(err: BusinessError, frameShutterInfo: camera.FrameShutterInfo): void {
3124  if (err !== undefined && err.code !== 0) {
3125    console.error(`Callback Error, errorCode: ${err.code}`);
3126    return;
3127  }
3128  console.info(`CaptureId for frame : ${frameShutterInfo.captureId}`);
3129  console.info(`Timestamp for frame : ${frameShutterInfo.timestamp}`);
3130}
3131
3132function registerPhotoOutputFrameShutter(photoOutput: camera.PhotoOutput): void {
3133  photoOutput.on('frameShutter', callback);
3134}
3135```
3136
3137### off('frameShutter')
3138
3139off(type: 'frameShutter', callback?: AsyncCallback\<FrameShutterInfo\>): void
3140
3141注销监听拍照帧输出捕获。
3142
3143**系统能力:** SystemCapability.Multimedia.Camera.Core
3144
3145**参数:**
3146
3147| 参数名     | 类型      | 必填 | 说明                                  |
3148| -------- | ---------- | --- | ------------------------------------ |
3149| type     | string     | 是   | 监听事件,固定为'frameShutter',photoOutput创建成功后可监听。 |
3150| callback | AsyncCallback\<[FrameShutterInfo](#frameshutterinfo)\> | 否   | 回调函数,如果指定参数则取消对应callback(callback对象不可是匿名函数),否则取消所有callback。 |
3151
3152**示例:**
3153
3154```ts
3155function unregisterPhotoOutputFrameShutter(photoOutput: camera.PhotoOutput): void {
3156  photoOutput.off('frameShutter');
3157}
3158```
3159
3160### on('captureEnd')
3161
3162on(type: 'captureEnd', callback: AsyncCallback\<CaptureEndInfo\>): void
3163
3164监听拍照结束,通过注册回调函数获取结果。使用callback异步回调。
3165
3166> **说明:**
3167>
3168> 当前注册监听接口,不支持在on监听的回调方法里,调用off注销回调。
3169
3170**系统能力:** SystemCapability.Multimedia.Camera.Core
3171
3172**参数:**
3173
3174| 参数名     | 类型           | 必填 | 说明                                       |
3175| -------- | --------------- | ---- | ---------------------------------------- |
3176| type     | string          | 是   | 监听事件,固定为'captureEnd',photoOutput创建成功后可监听。拍照完全结束可触发该事件发生并返回相应信息。 |
3177| callback | AsyncCallback\<[CaptureEndInfo](#captureendinfo)\> | 是   | 回调函数,用于获取相关信息。                  |
3178
3179**示例:**
3180
3181```ts
3182import { BusinessError } from '@kit.BasicServicesKit';
3183
3184function callback(err: BusinessError, captureEndInfo: camera.CaptureEndInfo): void {
3185  if (err !== undefined && err.code !== 0) {
3186    console.error(`Callback Error, errorCode: ${err.code}`);
3187    return;
3188  }
3189  console.info(`photo capture end, captureId : ${captureEndInfo.captureId}`);
3190  console.info(`frameCount : ${captureEndInfo.frameCount}`);
3191}
3192
3193function registerPhotoOutputCaptureEnd(photoOutput: camera.PhotoOutput): void {
3194  photoOutput.on('captureEnd', callback);
3195}
3196```
3197
3198### off('captureEnd')
3199
3200off(type: 'captureEnd', callback?: AsyncCallback\<CaptureEndInfo\>): void
3201
3202注销监听拍照结束。
3203
3204**系统能力:** SystemCapability.Multimedia.Camera.Core
3205
3206**参数:**
3207
3208| 参数名     | 类型           | 必填 | 说明                                       |
3209| -------- | --------------- | ---- | ---------------------------------------- |
3210| type     | string          | 是   | 监听事件,固定为'captureEnd',photoOutput创建成功后可监听。 |
3211| callback | AsyncCallback\<[CaptureEndInfo](#captureendinfo)\> | 否   | 回调函数,如果指定参数则取消对应callback(callback对象不可是匿名函数),否则取消所有callback。 |
3212
3213**示例:**
3214
3215```ts
3216function unregisterPhotoOutputCaptureEnd(photoOutput: camera.PhotoOutput): void {
3217  photoOutput.off('captureEnd');
3218}
3219```
3220
3221### on('frameShutterEnd')<sup>12+</sup>
3222
3223on(type: 'frameShutterEnd', callback: AsyncCallback\<FrameShutterEndInfo\>): void
3224
3225监听拍照曝光结束捕获,通过注册回调函数获取结果。使用callback异步回调。
3226
3227> **说明:**
3228>
3229> 当前注册监听接口,不支持在on监听的回调方法里,调用off注销回调。
3230
3231**系统能力:** SystemCapability.Multimedia.Camera.Core
3232
3233**参数:**
3234
3235| 参数名   | 类型                                                         | 必填 | 说明                                                         |
3236| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
3237| type     | string                                                       | 是   | 监听事件,固定为'frameShutterEnd',photoOutput创建成功后可监听。 |
3238| callback | AsyncCallback\<[FrameShutterEndInfo](#frameshutterendinfo12)\> | 是   | 回调函数,用于获取相关信息。该回调返回表示拍照曝光结束。   |
3239
3240**示例:**
3241
3242```ts
3243import { BusinessError } from '@kit.BasicServicesKit';
3244
3245function callback(err: BusinessError, frameShutterEndInfo: camera.FrameShutterEndInfo): void {
3246  if (err !== undefined && err.code !== 0) {
3247    console.error(`Callback Error, errorCode: ${err.code}`);
3248    return;
3249  }
3250  console.info(`CaptureId for frame : ${frameShutterEndInfo.captureId}`);
3251}
3252
3253function registerPhotoOutputFrameShutterEnd(photoOutput: camera.PhotoOutput): void {
3254  photoOutput.on('frameShutterEnd', callback);
3255}
3256```
3257
3258### off('frameShutterEnd')<sup>12+</sup>
3259
3260off(type: 'frameShutterEnd', callback?: AsyncCallback\<FrameShutterEndInfo\>): void
3261
3262注销监听拍照帧输出捕获。
3263
3264**系统能力:** SystemCapability.Multimedia.Camera.Core
3265
3266**参数:**
3267
3268| 参数名   | 类型                                                         | 必填 | 说明                                                         |
3269| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
3270| type     | string                                                       | 是   | 监听事件,固定为'frameShutterEnd',photoOutput创建成功后可监听。 |
3271| callback | AsyncCallback\<[FrameShutterEndInfo](#frameshutterendinfo12)\> | 否   | 回调函数,如果指定参数则取消对应callback(callback对象不可是匿名函数),否则取消所有callback。 |
3272
3273**示例:**
3274
3275```ts
3276function unregisterPhotoOutputFrameShutterEnd(photoOutput: camera.PhotoOutput): void {
3277  photoOutput.off('frameShutterEnd');
3278}
3279```
3280
3281### on('captureReady')<sup>12+</sup>
3282
3283on(type: 'captureReady', callback: AsyncCallback\<void\>): void
3284
3285监听可拍下一张,通过注册回调函数获取结果。使用callback异步回调。
3286
3287> **说明:**
3288>
3289> 当前注册监听接口,不支持在on监听的回调方法里,调用off注销回调。
3290
3291**系统能力:** SystemCapability.Multimedia.Camera.Core
3292
3293**参数:**
3294
3295| 参数名   | 类型                  | 必填 | 说明                                                         |
3296| -------- | --------------------- | ---- | ------------------------------------------------------------ |
3297| type     | string                | 是   | 监听事件,固定为'captureReady',photoOutput创建成功后可监听。当下一张可拍时可触发该事件发生并返回相应信息。 |
3298| callback | AsyncCallback\<void\> | 是   | 回调函数,用于获取相关信息。                                 |
3299
3300**示例:**
3301
3302```ts
3303import { BusinessError } from '@kit.BasicServicesKit';
3304
3305function callback(err: BusinessError): void {
3306  if (err !== undefined && err.code !== 0) {
3307    console.error(`Callback Error, errorCode: ${err.code}`);
3308    return;
3309  }
3310  console.info(`photo capture ready`);
3311}
3312
3313function registerPhotoOutputCaptureReady(photoOutput: camera.PhotoOutput): void {
3314  photoOutput.on('captureReady', callback);
3315}
3316```
3317
3318### off('captureReady')<sup>12+</sup>
3319
3320off(type: 'captureReady', callback?: AsyncCallback\<void\>): void
3321
3322注销监听可拍下一张。
3323
3324**系统能力:** SystemCapability.Multimedia.Camera.Core
3325
3326**参数:**
3327
3328| 参数名   | 类型                                                 | 必填 | 说明                                                         |
3329| -------- | ---------------------------------------------------- | ---- | ------------------------------------------------------------ |
3330| type     | string                                               | 是   | 监听事件,固定为'captureReady',photoOutput创建成功后可监听。 |
3331| callback | AsyncCallback\<[CaptureReadyInfo](#captureendinfo)\> | 否   | 回调函数,如果指定参数则取消对应callback(callback对象不可是匿名函数),否则取消所有callback。 |
3332
3333**示例:**
3334
3335```ts
3336function unregisterPhotoOutputCaptureReady(photoOutput: camera.PhotoOutput): void {
3337  photoOutput.off('captureReady');
3338}
3339```
3340
3341### on('estimatedCaptureDuration')<sup>12+</sup>
3342
3343on(type: 'estimatedCaptureDuration', callback: AsyncCallback\<number\>): void
3344
3345监听预估的拍照时间,通过注册回调函数获取结果。使用callback异步回调。
3346
3347> **说明:**
3348>
3349> 当前注册监听接口,不支持在on监听的回调方法里,调用off注销回调。
3350
3351**系统能力:** SystemCapability.Multimedia.Camera.Core
3352
3353**参数:**
3354
3355| 参数名   | 类型                   | 必填 | 说明                                                         |
3356| -------- | ---------------------- | ---- | ------------------------------------------------------------ |
3357| type     | string                 | 是   | 监听事件,固定为'estimatedCaptureDuration',photoOutput创建成功后可监听。拍照完全结束可触发该事件发生并返回相应信息。 |
3358| callback | AsyncCallback\<number> | 是   | 回调函数,用于获取预估的单次拍照底层出sensor采集帧时间,如果上报-1,代表没有预估时间。                                 |
3359
3360**示例:**
3361
3362```ts
3363import { BusinessError } from '@kit.BasicServicesKit';
3364
3365function callback(err: BusinessError, duration: number): void {
3366  if (err !== undefined && err.code !== 0) {
3367    console.error(`Callback Error, errorCode: ${err.code}`);
3368    return;
3369  }
3370  console.info(`photo estimated capture duration : ${duration}`);
3371}
3372
3373function registerPhotoOutputEstimatedCaptureDuration(photoOutput: camera.PhotoOutput): void {
3374  photoOutput.on('estimatedCaptureDuration', callback);
3375}
3376```
3377
3378### off('estimatedCaptureDuration')<sup>12+</sup>
3379
3380off(type: 'estimatedCaptureDuration', callback?: AsyncCallback\<number\>): void
3381
3382注销监听预估的拍照时间。
3383
3384**系统能力:** SystemCapability.Multimedia.Camera.Core
3385
3386**参数:**
3387
3388| 参数名   | 类型                    | 必填 | 说明                                                         |
3389| -------- | ----------------------- | ---- | ------------------------------------------------------------ |
3390| type     | string                  | 是   | 监听事件,固定为'estimatedCaptureDuration',photoOutput创建成功后可监听。 |
3391| callback | AsyncCallback\<number\> | 否   | 回调函数,如果指定参数则取消对应callback(callback对象不可是匿名函数),否则取消所有callback。 |
3392
3393**示例:**
3394
3395```ts
3396function unregisterPhotoOutputEstimatedCaptureDuration(photoOutput: camera.PhotoOutput): void {
3397  photoOutput.off('estimatedCaptureDuration');
3398}
3399```
3400
3401### on('error')
3402
3403on(type: 'error', callback: ErrorCallback): void
3404
3405监听拍照输出发生错误,通过注册回调函数获取结果。使用callback异步回调。
3406
3407> **说明:**
3408>
3409> 当前注册监听接口,不支持在on监听的回调方法里,调用off注销回调。
3410
3411**系统能力:** SystemCapability.Multimedia.Camera.Core
3412
3413**参数:**
3414
3415| 参数名     | 类型         | 必填 | 说明                                 |
3416| -------- | ------------- | ---- | ----------------------------------- |
3417| type     | string       | 是   | 监听事件,固定为'error',photoOutput创建成功后可监听。拍照接口调用时出现错误触发该事件并返回错误信息。 |
3418| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback) | 是   | 回调函数,用于获取错误信息。返回错误码,错误码类型[CameraErrorCode](#cameraerrorcode)。             |
3419
3420**示例:**
3421
3422```ts
3423import { BusinessError } from '@kit.BasicServicesKit';
3424
3425function callback(err: BusinessError): void {
3426  console.error(`Photo output error code: ${err.code}`);
3427}
3428
3429function registerPhotoOutputError(photoOutput: camera.PhotoOutput): void {
3430  photoOutput.on('error', callback);
3431}
3432```
3433
3434### off('error')
3435
3436off(type: 'error', callback?: ErrorCallback): void
3437
3438注销监听拍照输出发生错误。
3439
3440**系统能力:** SystemCapability.Multimedia.Camera.Core
3441
3442**参数:**
3443
3444| 参数名     | 类型         | 必填 | 说明                                 |
3445| -------- | ------------- | ---- | ----------------------------------- |
3446| type     | string       | 是   | 监听事件,固定为'error',photoOutput创建成功后可监听。 |
3447| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback) | 否   | 回调函数,如果指定参数则取消对应callback(callback对象不可是匿名函数),否则取消所有callback。 |
3448
3449**示例:**
3450
3451```ts
3452function unregisterPhotoOutputError(photoOutput: camera.PhotoOutput): void {
3453  photoOutput.off('error');
3454}
3455```
3456
3457### getActiveProfile<sup>12+</sup>
3458
3459getActiveProfile(): Profile
3460
3461获取当前生效的配置信息。
3462
3463**系统能力:** SystemCapability.Multimedia.Camera.Core
3464
3465**返回值:**
3466
3467|      类型      | 说明        |
3468| -------------  |-----------|
3469| [Profile](#profile) | 当前生效的配置信息 |
3470
3471**错误码:**
3472
3473以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
3474
3475| 错误码ID   | 错误信息                         |
3476|---------|------------------------------|
3477| 7400201 | Camera service fatal error.  |
3478
3479**示例:**
3480
3481```ts
3482function testGetActiveProfile(photoOutput: camera.PhotoOutput): camera.Profile | undefined {
3483  let activeProfile: camera.Profile | undefined = undefined;
3484  try {
3485    activeProfile = photoOutput.getActiveProfile();
3486  } catch (error) {
3487    // 失败返回错误码error.code并处理。
3488    let err = error as BusinessError;
3489    console.error(`The photoOutput.getActiveProfile call failed. error code: ${err.code}`);
3490  }
3491  return activeProfile;
3492}
3493```
3494### getPhotoRotation<sup>12+</sup>
3495
3496getPhotoRotation(deviceDegree: number): ImageRotation
3497
3498获取拍照旋转角度。
3499
3500- 设备自然方向:设备默认使用方向,手机为竖屏(充电口向下)。
3501- 相机镜头角度:值等于相机图像顺时针旋转到设备自然方向的角度,手机后置相机传感器是横屏安装的,所以需要顺时针旋转90度到设备自然方向。
3502- 屏幕显示方向:需要屏幕显示的图片左上角为第一个像素点为坐标原点。锁屏时与自然方向一致。
3503
3504**系统能力:** SystemCapability.Multimedia.Camera.Core
3505
3506**参数:**
3507
3508| 参数名     | 类型         | 必填 | 说明                       |
3509| -------- | --------------| ---- | ------------------------ |
3510| deviceDegree | number | 是   | 设备旋转角度 |
3511
3512**返回值:**
3513
3514|      类型      | 说明        |
3515| -------------  |-----------|
3516| [ImageRotation](#imagerotation) | 获取拍照旋转角度。 |
3517
3518**错误码:**
3519
3520以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
3521
3522| 错误码ID   | 错误信息                         |
3523|---------|------------------------------|
3524| 7400101 | Parameter missing or parameter type incorrect.  |
3525| 7400201 | Camera service fatal error.  |
3526
3527**示例:**
3528
3529```ts
3530function testGetPhotoRotation(photoOutput: camera.PhotoOutput, deviceDegree : number): camera.ImageRotation {
3531  let photoRotation: camera.ImageRotation = camera.ImageRotation.ROTATION_0;
3532  try {
3533    photoRotation = photoOutput.getPhotoRotation(deviceDegree);
3534    console.log(`Photo rotation is: ${photoRotation}`);
3535  } catch (error) {
3536    // 失败返回错误码error.code并处理。
3537    let err = error as BusinessError;
3538    console.error(`The photoOutput.getPhotoRotation call failed. error code: ${err.code}`);
3539  }
3540  return photoRotation;
3541}
3542```
3543
3544## FrameShutterInfo
3545
3546拍照帧输出信息。
3547
3548**系统能力:** SystemCapability.Multimedia.Camera.Core
3549
3550| 名称       | 类型   | 只读 | 可选 | 说明        |
3551| --------- | ------ | ---- | ---- | ---------- |
3552| captureId | number | 否   | 否   | 拍照的ID。  |
3553| timestamp | number | 否   | 否   | 快门时间戳。 |
3554
3555## FrameShutterEndInfo<sup>12+</sup>
3556
3557拍照曝光结束信息。
3558
3559**系统能力:** SystemCapability.Multimedia.Camera.Core
3560
3561| 名称      | 类型   | 只读 | 可选 | 说明       |
3562| --------- | ------ | ---- | ---- | ---------- |
3563| captureId | number | 否   | 否   | 拍照的ID。 |
3564
3565## CaptureStartInfo<sup>11+</sup>
3566
3567拍照开始信息。
3568
3569**系统能力:** SystemCapability.Multimedia.Camera.Core
3570
3571| 名称       | 类型    | 只读 | 可选 | 说明       |
3572| ---------- | ------ | ---- | ---- | --------- |
3573| captureId  | number | 否   | 否   | 拍照的ID。 |
3574| time       | number | 否   | 否   | 预估的单次拍照底层出sensor采集帧时间,如果上报-1,代表没有预估时间。    |
3575
3576## CaptureEndInfo
3577
3578拍照停止信息。
3579
3580**系统能力:** SystemCapability.Multimedia.Camera.Core
3581
3582| 名称       | 类型    | 只读 | 可选 | 说明       |
3583| ---------- | ------ | ---- | ---- | ---------|
3584| captureId  | number | 否   | 否   | 拍照的ID。 |
3585| frameCount | number | 否   | 否   | 帧数。    |
3586
3587## AutoDeviceSwitchStatus<sup>13+</sup>
3588
3589自动切换镜头状态信息。
3590
3591**系统能力:** SystemCapability.Multimedia.Camera.Core
3592
3593| 名称       | 类型      | 只读 | 可选 | 说明                      |
3594| ---------- |---------| ---- | ---- |-------------------------|
3595| isDeviceSwitched  | boolean | 否   | 否   | 自动切换镜头是否成功。             |
3596| isDeviceCapabilityChanged | boolean  | 否   | 否   | 自动切换镜头成功后,其镜头能力值是否发生改变。 |
3597
3598## VideoOutput
3599
3600录像会话中使用的输出信息,继承[CameraOutput](#cameraoutput)。
3601
3602### start
3603
3604start(callback: AsyncCallback\<void\>): void
3605
3606启动录制,通过注册回调函数获取结果。使用callback异步回调。
3607
3608**系统能力:** SystemCapability.Multimedia.Camera.Core
3609
3610**参数:**
3611
3612| 参数名      | 类型                  | 必填 | 说明                 |
3613| -------- | -------------------- | ---- | -------------------- |
3614| callback | AsyncCallback\<void\> | 是   | 回调函数,用于获取结果。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode)。 |
3615
3616**错误码:**
3617
3618以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
3619
3620| 错误码ID         | 错误信息        |
3621| --------------- | --------------- |
3622| 7400103                |  Session not config.                                   |
3623| 7400201                |  Camera service fatal error.                           |
3624
3625**示例:**
3626
3627```ts
3628import { BusinessError } from '@kit.BasicServicesKit';
3629
3630function startVideoOutput(videoOutput: camera.VideoOutput): void {
3631  videoOutput.start((err: BusinessError) => {
3632    if (err) {
3633      console.error(`Failed to start the video output, error code: ${err.code}.`);
3634      return;
3635    }
3636    console.info('Callback invoked to indicate the video output start success.');
3637  });
3638}
3639```
3640
3641### start
3642
3643start(): Promise\<void\>
3644
3645启动录制,通过Promise获取结果。
3646
3647**系统能力:** SystemCapability.Multimedia.Camera.Core
3648
3649**返回值:**
3650
3651| 类型            | 说明                     |
3652| -------------- | ----------------------- |
3653| Promise\<void\> | 无返回结果的Promise对象。 |
3654
3655**错误码:**
3656
3657以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
3658
3659| 错误码ID         | 错误信息        |
3660| --------------- | --------------- |
3661| 7400103                |  Session not config.                                   |
3662| 7400201                |  Camera service fatal error.                           |
3663
3664**示例:**
3665
3666```ts
3667import { BusinessError } from '@kit.BasicServicesKit';
3668
3669function startVideoOutput(videoOutput: camera.VideoOutput): void {
3670  videoOutput.start().then(() => {
3671    console.info('Promise returned to indicate that start method execution success.');
3672  }).catch((error: BusinessError) => {
3673    console.error(`Failed to video output start, error code: ${error.code}.`);
3674  });
3675}
3676```
3677
3678### stop
3679
3680stop(callback: AsyncCallback\<void\>): void
3681
3682结束录制,通过注册回调函数获取结果。使用callback异步回调。
3683
3684**系统能力:** SystemCapability.Multimedia.Camera.Core
3685
3686**参数:**
3687
3688| 参数名     | 类型                 | 必填 | 说明                     |
3689| -------- | -------------------- | ---- | ------------------------ |
3690| callback | AsyncCallback\<void\> | 是   | 回调函数,用于获取结果。 |
3691
3692**示例:**
3693
3694```ts
3695import { BusinessError } from '@kit.BasicServicesKit';
3696
3697function stopVideoOutput(videoOutput: camera.VideoOutput): void {
3698  videoOutput.stop((err: BusinessError) => {
3699    if (err) {
3700      console.error(`Failed to stop the video output, error code: ${err.code}.`);
3701      return;
3702    }
3703    console.info('Callback invoked to indicate the video output stop success.');
3704  });
3705}
3706```
3707
3708### stop
3709
3710stop(): Promise\<void\>
3711
3712结束录制,通过Promise获取结果。
3713
3714**系统能力:** SystemCapability.Multimedia.Camera.Core
3715
3716**返回值:**
3717
3718| 类型            | 说明                     |
3719| -------------- | ----------------------- |
3720| Promise\<void\> | 无返回结果的Promise对象。 |
3721
3722**示例:**
3723
3724```ts
3725import { BusinessError } from '@kit.BasicServicesKit';
3726
3727function stopVideoOutput(videoOutput: camera.VideoOutput): void {
3728  videoOutput.stop().then(() => {
3729    console.info('Promise returned to indicate that stop method execution success.');
3730  }).catch((error: BusinessError) => {
3731    console.error(`Failed to video output stop, error code: ${error.code}.`);
3732  });
3733}
3734```
3735
3736### on('frameStart')
3737
3738on(type: 'frameStart', callback: AsyncCallback\<void\>): void
3739
3740监听录像开始,通过注册回调函数获取结果。使用callback异步回调。
3741
3742> **说明:**
3743>
3744> 当前注册监听接口,不支持在on监听的回调方法里,调用off注销回调。
3745
3746**系统能力:** SystemCapability.Multimedia.Camera.Core
3747
3748**参数:**
3749
3750| 参数名      | 类型                  | 必填 | 说明                                       |
3751| -------- | -------------------- | ---- | ----------------------------------------- |
3752| type     | string               | 是   | 监听事件,固定为'frameStart',videoOutput创建成功后可监听。底层第一次曝光时触发该事件并返回。 |
3753| callback | AsyncCallback\<void\> | 是   | 回调函数,用于获取结果。  只要有该事件返回就证明录像开始。                     |
3754
3755**示例:**
3756
3757```ts
3758import { BusinessError } from '@kit.BasicServicesKit';
3759
3760function callback(err: BusinessError): void {
3761  if (err !== undefined && err.code !== 0) {
3762    console.error(`Callback Error, errorCode: ${err.code}`);
3763    return;
3764  }
3765  console.info('Video frame started');
3766}
3767
3768function registerVideoOutputFrameStart(videoOutput: camera.VideoOutput): void {
3769  videoOutput.on('frameStart', callback);
3770}
3771```
3772
3773### off('frameStart')
3774
3775off(type: 'frameStart', callback?: AsyncCallback\<void\>): void
3776
3777注销监听录像开始。
3778
3779> **说明:**
3780>
3781> 当前注册监听接口,不支持在on监听的回调方法里,调用off注销回调。
3782
3783**系统能力:** SystemCapability.Multimedia.Camera.Core
3784
3785**参数:**
3786
3787| 参数名      | 类型                  | 必填 | 说明                                       |
3788| -------- | -------------------- | ---- | ----------------------------------------- |
3789| type     | string               | 是   | 监听事件,固定为'frameStart',videoOutput创建成功后可监听。 |
3790| callback | AsyncCallback\<void\> | 否   | 回调函数,如果指定参数则取消对应callback(callback对象不可是匿名函数),否则取消所有callback。 |
3791
3792**示例:**
3793
3794```ts
3795function unregisterVideoOutputFrameStart(videoOutput: camera.VideoOutput): void {
3796  videoOutput.off('frameStart');
3797}
3798
3799```
3800
3801### on('frameEnd')
3802
3803on(type: 'frameEnd', callback: AsyncCallback\<void\>): void
3804
3805监听录像结束,通过注册回调函数获取结果。使用callback异步回调。
3806
3807**系统能力:** SystemCapability.Multimedia.Camera.Core
3808
3809**参数:**
3810
3811| 参数名      | 类型                  | 必填 | 说明                                       |
3812| -------- | -------------------- | ---- | ------------------------------------------ |
3813| type     | string               | 是   | 监听事件,固定为'frameEnd',videoOutput创建成功后可监听。录像完全结束最后一帧时触发该事件并返回。 |
3814| callback | AsyncCallback\<void\> | 是   | 回调函数,用于获取结果。 只要有该事件返回就证明录像结束。                      |
3815
3816**示例:**
3817
3818```ts
3819import { BusinessError } from '@kit.BasicServicesKit';
3820
3821function callback(err: BusinessError): void {
3822  if (err !== undefined && err.code !== 0) {
3823    console.error(`Callback Error, errorCode: ${err.code}`);
3824    return;
3825  }
3826  console.info('Video frame ended');
3827}
3828
3829function registerVideoOutputFrameEnd(videoOutput: camera.VideoOutput): void {
3830  videoOutput.on('frameEnd', callback);
3831}
3832```
3833
3834### off('frameEnd')
3835
3836off(type: 'frameEnd', callback?: AsyncCallback\<void\>): void
3837
3838注销监听录像结束。
3839
3840**系统能力:** SystemCapability.Multimedia.Camera.Core
3841
3842**参数:**
3843
3844| 参数名      | 类型                  | 必填 | 说明                                       |
3845| -------- | -------------------- | ---- | ------------------------------------------ |
3846| type     | string               | 是   | 监听事件,固定为'frameEnd',videoOutput创建成功后可监听。 |
3847| callback | AsyncCallback\<void\> | 否   | 回调函数,如果指定参数则取消对应callback(callback对象不可是匿名函数),否则取消所有callback。 |
3848
3849**示例:**
3850
3851```ts
3852function unregisterVideoOutputFrameEnd(videoOutput: camera.VideoOutput): void {
3853  videoOutput.off('frameEnd');
3854}
3855```
3856
3857### on('error')
3858
3859on(type: 'error', callback: ErrorCallback): void
3860
3861监听录像输出发生错误,通过注册回调函数获取结果。使用callback异步回调。
3862
3863> **说明:**
3864>
3865> 当前注册监听接口,不支持在on监听的回调方法里,调用off注销回调。
3866
3867**系统能力:** SystemCapability.Multimedia.Camera.Core
3868
3869**参数:**
3870
3871| 参数名     | 类型       | 必填 | 说明                                    |
3872| -------- | ----------- | ---- | -------------------------------------- |
3873| type     | string      | 是   | 监听事件,固定为'error',videoOutput创建成功后可监听。录像接口调用出现错误时触发该事件并返回对应错误码,比如调用[start](#start-1),[CameraOutput.release](#release-1)接口时出现错误返回对应错误信息。 |
3874| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback) | 是   | 回调函数,用于获取错误信息。返回错误码,错误码类型[CameraErrorCode](#cameraerrorcode)。                 |
3875
3876**示例:**
3877
3878```ts
3879import { BusinessError } from '@kit.BasicServicesKit';
3880
3881function callback(err: BusinessError): void {
3882  console.error(`Video output error code: ${err.code}`);
3883}
3884
3885function registerVideoOutputError(videoOutput: camera.VideoOutput): void {
3886  videoOutput.on('error', callback);
3887}
3888```
3889
3890### off('error')
3891
3892off(type: 'error', callback?: ErrorCallback): void
3893
3894注销监听录像输出发生错误。
3895
3896**系统能力:** SystemCapability.Multimedia.Camera.Core
3897
3898**参数:**
3899
3900| 参数名     | 类型         | 必填 | 说明                                 |
3901| -------- | ------------- | ---- | ----------------------------------- |
3902| type     | string       | 是   | 监听事件,固定为'error',photoOutput创建成功后可监听。 |
3903| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback) | 否   | 回调函数,如果指定参数则取消对应callback(callback对象不可是匿名函数),否则取消所有callback。 |
3904
3905**示例:**
3906
3907```ts
3908function unregisterVideoOutputError(videoOutput: camera.VideoOutput): void {
3909  videoOutput.off('error');
3910}
3911```
3912
3913### getSupportedFrameRates<sup>12+</sup>
3914
3915getSupportedFrameRates(): Array\<FrameRateRange\>
3916
3917查询支持的帧率范围。
3918
3919**系统能力:** SystemCapability.Multimedia.Camera.Core
3920
3921**返回值:**
3922
3923|      类型      |     说明     |
3924| -------------  | ------------ |
3925| Array<[FrameRateRange](#frameraterange)> | 支持的帧率范围列表 |
3926
3927**示例:**
3928
3929```ts
3930function getSupportedFrameRates(videoOutput: camera.VideoOutput): Array<camera.FrameRateRange> {
3931  let supportedFrameRatesArray: Array<camera.FrameRateRange> = videoOutput.getSupportedFrameRates();
3932  return supportedFrameRatesArray;
3933}
3934```
3935
3936### setFrameRate<sup>12+</sup>
3937
3938setFrameRate(minFps: number, maxFps: number): void
3939
3940设置录像流帧率范围,设置的范围必须在支持的帧率范围内。
3941
3942进行设置前,可通过[getSupportedFrameRates](#getsupportedframerates12-1)查询支持的帧率范围。
3943
3944> **说明:**
3945> 仅在[PhotoSession](#photosession11)或[VideoSession](#videosession11)模式下支持。
3946
3947**系统能力:** SystemCapability.Multimedia.Camera.Core
3948
3949**参数:**
3950
3951| 参数名     | 类型         | 必填 | 说明                       |
3952| -------- | --------------| ---- | ------------------------ |
3953| minFps   | number        | 是   | 最小帧率。 |
3954| maxFps   | number        | 是   | 最大帧率。当传入的最小值大于最大值时,传参异常,接口不生效。 |
3955
3956**错误码:**
3957
3958以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
3959
3960| 错误码ID        | 错误信息        |
3961| --------------- | --------------- |
3962| 7400101                |  Parameter missing or parameter type incorrect.        |
3963| 7400110                |  Unresolved conflicts with current configurations.     |
3964
3965**示例:**
3966
3967```ts
3968function setFrameRateRange(videoOutput: camera.VideoOutput, frameRateRange: Array<number>): void {
3969  videoOutput.setFrameRate(frameRateRange[0], frameRateRange[1]);
3970}
3971```
3972
3973### getActiveFrameRate<sup>12+</sup>
3974
3975getActiveFrameRate(): FrameRateRange
3976
3977获取已设置的帧率范围。
3978
3979使用[setFrameRate](#setframerate12-1)对录像流设置过帧率后可查询。
3980
3981**系统能力:** SystemCapability.Multimedia.Camera.Core
3982
3983**返回值:**
3984
3985|      类型      |     说明     |
3986| -------------  | ------------ |
3987| [FrameRateRange](#frameraterange) | 帧率范围 |
3988
3989**示例:**
3990
3991```ts
3992function getActiveFrameRate(videoOutput: camera.VideoOutput): camera.FrameRateRange {
3993  let activeFrameRate: camera.FrameRateRange = videoOutput.getActiveFrameRate();
3994  return activeFrameRate;
3995}
3996```
3997
3998### getActiveProfile<sup>12+</sup>
3999
4000getActiveProfile(): VideoProfile
4001
4002获取当前生效的配置信息。
4003
4004**系统能力:** SystemCapability.Multimedia.Camera.Core
4005
4006**返回值:**
4007
4008|      类型      | 说明        |
4009| -------------  |-----------|
4010| [VideoProfile](#videoprofile) | 当前生效的配置信息 |
4011
4012**错误码:**
4013
4014以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
4015
4016| 错误码ID   | 错误信息                         |
4017|---------|------------------------------|
4018| 7400201 | Camera service fatal error.  |
4019
4020**示例:**
4021
4022```ts
4023function testGetActiveProfile(videoOutput: camera.VideoOutput): camera.Profile | undefined {
4024  let activeProfile: camera.VideoProfile | undefined = undefined;
4025  try {
4026    activeProfile = videoOutput.getActiveProfile();
4027  } catch (error) {
4028    // 失败返回错误码error.code并处理。
4029    let err = error as BusinessError;
4030    console.error(`The videoOutput.getActiveProfile call failed. error code: ${err.code}`);
4031  }
4032  return activeProfile;
4033}
4034```
4035### isMirrorSupported<sup>15+</sup>
4036
4037isMirrorSupported(): boolean
4038
4039查询是否支持镜像录像。
4040
4041**系统能力:** SystemCapability.Multimedia.Camera.Core
4042
4043**返回值:**
4044
4045| 类型            | 说明                              |
4046| -------------- |---------------------------------|
4047| boolean | 返回是否支持镜像录像,true表示支持,false表示不支持。 |
4048
4049**示例:**
4050
4051```ts
4052function testIsMirrorSupported(videoOutput: camera.VideoOutput): boolean {
4053  let isSupported: boolean = videoOutput.isMirrorSupported();
4054  return isSupported;
4055}
4056```
4057### enableMirror<sup>15+</sup>
4058
4059enableMirror(enabled: boolean): void
4060
4061启用/关闭镜像录像。
4062- 调用该接口前,需要通过[isMirrorSupported](#ismirrorsupported15)查询是否支录像镜像功能。
4063
4064- 启用/关闭录像镜像后,需要通过[getVideoRotation](#getvideorotation12)以及[updateRotation](../apis-media-kit/js-apis-media.md#updaterotation12)更新旋转角度。
4065
4066**系统能力:** SystemCapability.Multimedia.Camera.Core
4067
4068**参数:**
4069
4070| 参数名      | 类型                    | 必填 | 说明                        |
4071|----------| ---------------------- | ---- |---------------------------|
4072| enabled | boolean                | 是   | true为开启镜像录像,false为关闭镜像录像。 |
4073
4074**错误码:**
4075
4076以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
4077
4078| 错误码ID    | 错误信息                                           |
4079| -------- |------------------------------------------------|
4080| 7400101  | Parameter missing or parameter type incorrect. |
4081| 7400103  | Session not config.                    |
4082
4083
4084**示例:**
4085
4086```ts
4087import { camera } from '@kit.CameraKit';
4088import { media } from '@kit.MediaKit';
4089import { BusinessError } from '@kit.BasicServicesKit';
4090
4091function enableMirror(videoOutput: camera.VideoOutput, mirrorMode: boolean, aVRecorder: media.AVRecorder, deviceDegree : number): void {
4092    try {
4093        videoOutput.enableMirror(mirrorMode);
4094        aVRecorder.updateRotation(videoOutput.getVideoRotation(deviceDegree));
4095    } catch (error) {
4096        let err = error as BusinessError;
4097    }
4098}
4099```
4100
4101### getVideoRotation<sup>12+</sup>
4102
4103getVideoRotation(deviceDegree: number): ImageRotation
4104
4105获取录像旋转角度。
4106
4107- 设备自然方向:设备默认使用方向,手机为竖屏(充电口向下)。
4108- 相机镜头角度:值等于相机图像顺时针旋转到设备自然方向的角度,手机后置相机传感器是横屏安装的,所以需要顺时针旋转90度到设备自然方向。
4109- 屏幕显示方向:需要屏幕显示的图片左上角为第一个像素点为坐标原点。锁屏时与自然方向一致。
4110
4111**系统能力:** SystemCapability.Multimedia.Camera.Core
4112
4113**参数:**
4114
4115| 参数名     | 类型         | 必填 | 说明                       |
4116| -------- | --------------| ---- | ------------------------ |
4117| deviceDegree | number | 是   | 设备旋转角度(单位:度)。 |
4118
4119**返回值:**
4120
4121|      类型      | 说明        |
4122| -------------  |-----------|
4123| [ImageRotation](#imagerotation) | 获取录像旋转角度。 |
4124
4125**错误码:**
4126
4127以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
4128
4129| 错误码ID   | 错误信息                         |
4130|---------|------------------------------|
4131| 7400101 | Parameter missing or parameter type incorrect.  |
4132| 7400201 | Camera service fatal error.  |
4133
4134**示例:**
4135
4136```ts
4137import { camera } from '@kit.CameraKit';
4138import { Decimal } from '@kit.ArkTS';
4139import { sensor } from '@kit.SensorServiceKit';
4140import { BusinessError } from '@kit.BasicServicesKit';
4141
4142function getVideoRotation(videoOutput: camera.VideoOutput): camera.ImageRotation {
4143    let videoRotation: camera.ImageRotation = camera.ImageRotation.ROTATION_0;
4144    try {
4145        videoRotation = videoOutput.getVideoRotation(getDeviceDegree());
4146    } catch (error) {
4147        let err = error as BusinessError;
4148    }
4149    return videoRotation;
4150}
4151
4152//获取deviceDegree。
4153function getDeviceDegree(): number {
4154    let deviceDegree: number = -1;
4155    try {
4156        sensor.once(sensor.SensorId.GRAVITY, (data: sensor.GravityResponse) => {
4157            console.info('Succeeded in invoking once. X-coordinate component: ' + data.x);
4158            console.info('Succeeded in invoking once. Y-coordinate component: ' + data.y);
4159            console.info('Succeeded in invoking once. Z-coordinate component: ' + data.z);
4160            let x = data.x;
4161            let y = data.y;
4162            let z = data.z;
4163            if ((x * x + y * y) * 3 < z * z) {
4164                deviceDegree = -1;
4165            } else {
4166                let sd: Decimal = Decimal.atan2(y, -x);
4167                let sc: Decimal = Decimal.round(Number(sd) / 3.141592653589 * 180)
4168                deviceDegree = 90 - Number(sc);
4169                deviceDegree = deviceDegree >= 0 ? deviceDegree% 360 : deviceDegree% 360 + 360;
4170            }
4171        });
4172    } catch (error) {
4173        let err: BusinessError = error as BusinessError;
4174    }
4175    return deviceDegree;
4176}
4177```
4178
4179## MetadataOutput
4180
4181metadata流。继承[CameraOutput](#cameraoutput)。
4182
4183### start
4184
4185start(callback: AsyncCallback\<void\>): void
4186
4187开始输出metadata,通过注册回调函数获取结果。使用callback异步回调。
4188
4189**系统能力:** SystemCapability.Multimedia.Camera.Core
4190
4191**参数:**
4192
4193| 参数名     | 类型                                                         | 必填 | 说明                 |
4194| -------- | -------------------------- | ---- | ------------------- |
4195| callback | AsyncCallback\<void\>       | 是   | 回调函数,用于获取结果。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode)。 |
4196
4197**错误码:**
4198
4199以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
4200
4201| 错误码ID         | 错误信息        |
4202| --------------- | --------------- |
4203| 7400103                |  Session not config.                                   |
4204| 7400201                |  Camera service fatal error.                           |
4205
4206**示例:**
4207
4208```ts
4209import { BusinessError } from '@kit.BasicServicesKit';
4210
4211function startMetadataOutput(metadataOutput: camera.MetadataOutput): void {
4212  metadataOutput.start((err: BusinessError) => {
4213    if (err) {
4214      console.error(`Failed to start metadata output, error code: ${err.code}.`);
4215      return;
4216    }
4217    console.info('Callback returned with metadata output started.');
4218  });
4219}
4220```
4221
4222### start
4223
4224start(): Promise\<void\>
4225
4226开始输出metadata,通过Promise获取结果。
4227
4228**系统能力:** SystemCapability.Multimedia.Camera.Core
4229
4230**返回值:**
4231
4232| 类型                     | 说明                     |
4233| ----------------------  | ------------------------ |
4234| Promise\<void\>          | 无返回结果的Promise对象。 |
4235
4236**错误码:**
4237
4238以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
4239
4240| 错误码ID         | 错误信息        |
4241| --------------- | --------------- |
4242| 7400103                |  Session not config.                                   |
4243| 7400201                |  Camera service fatal error.                           |
4244
4245**示例:**
4246
4247```ts
4248import { BusinessError } from '@kit.BasicServicesKit';
4249
4250function startMetadataOutput(metadataOutput: camera.MetadataOutput): void {
4251  metadataOutput.start().then(() => {
4252    console.info('Callback returned with metadata output started.');
4253  }).catch((error: BusinessError) => {
4254    console.error(`Failed to metadata output stop, error code: ${error.code}`);
4255  });
4256}
4257```
4258
4259### stop
4260
4261stop(callback: AsyncCallback\<void\>): void
4262
4263停止输出metadata,通过注册回调函数获取结果。使用callback异步回调。
4264
4265**系统能力:** SystemCapability.Multimedia.Camera.Core
4266
4267**参数:**
4268
4269| 参数名     | 类型                         | 必填 | 说明                  |
4270| -------- | -------------------------- | ---- | ------------------- |
4271| callback | AsyncCallback\<void\>       | 是   | 回调函数,用于获取结果。 |
4272
4273**示例:**
4274
4275```ts
4276import { BusinessError } from '@kit.BasicServicesKit';
4277
4278function stopMetadataOutput(metadataOutput: camera.MetadataOutput): void {
4279  metadataOutput.stop((err: BusinessError) => {
4280    if (err) {
4281      console.error(`Failed to stop the metadata output, error code: ${err.code}.`);
4282      return;
4283    }
4284    console.info('Callback returned with metadata output stopped.');
4285  })
4286}
4287```
4288
4289### stop
4290
4291stop(): Promise\<void\>
4292
4293停止输出metadata,通过Promise获取结果。
4294
4295**系统能力:** SystemCapability.Multimedia.Camera.Core
4296
4297**返回值:**
4298
4299| 类型                    | 说明                        |
4300| ----------------------  | --------------------------- |
4301| Promise\<void\>         | 无返回结果的Promise对象。 |
4302
4303**示例:**
4304
4305```ts
4306import { BusinessError } from '@kit.BasicServicesKit';
4307
4308function stopMetadataOutput(metadataOutput: camera.MetadataOutput): void {
4309  metadataOutput.stop().then(() => {
4310    console.info('Callback returned with metadata output stopped.');
4311  }).catch((error: BusinessError) => {
4312    console.error(`Failed to metadata output stop, error code: ${error.code}`);
4313  });
4314}
4315```
4316
4317### on('metadataObjectsAvailable')
4318
4319on(type: 'metadataObjectsAvailable', callback: AsyncCallback\<Array\<MetadataObject\>\>): void
4320
4321监听检测到的metadata对象,通过注册回调函数获取结果。使用callback异步回调。
4322
4323> **说明:**
4324>
4325> 当前注册监听接口,不支持在on监听的回调方法里,调用off注销回调。
4326
4327**系统能力:** SystemCapability.Multimedia.Camera.Core
4328
4329**参数:**
4330
4331| 参数名      | 类型         | 必填 | 说明                                  |
4332| -------- | -------------- | ---- | ------------------------------------ |
4333| type     | string         | 是   | 监听事件,固定为'metadataObjectsAvailable',metadataOutput创建成功后可监听。检测到有效的metadata数据时触发该事件发生并返回相应的metadata数据。 |
4334| callback | AsyncCallback\<Array\<[MetadataObject](#metadataobject)\>\> | 是   | 回调函数,用于获取metadata数据。 |
4335
4336**示例:**
4337
4338```ts
4339import { BusinessError } from '@kit.BasicServicesKit';
4340
4341function callback(err: BusinessError, metadataObjectArr: Array<camera.MetadataObject>): void {
4342  if (err !== undefined && err.code !== 0) {
4343    console.error(`Callback Error, errorCode: ${err.code}`);
4344    return;
4345  }
4346  console.info('metadata output metadataObjectsAvailable');
4347}
4348
4349function registerMetadataObjectsAvailable(metadataOutput: camera.MetadataOutput): void {
4350  metadataOutput.on('metadataObjectsAvailable', callback);
4351}
4352```
4353
4354### off('metadataObjectsAvailable')
4355
4356off(type: 'metadataObjectsAvailable', callback?: AsyncCallback\<Array\<MetadataObject\>\>): void
4357
4358注销监听检测到的metadata对象。
4359
4360**系统能力:** SystemCapability.Multimedia.Camera.Core
4361
4362**参数:**
4363
4364| 参数名      | 类型         | 必填 | 说明                                  |
4365| -------- | -------------- | ---- | ------------------------------------ |
4366| type     | string         | 是   | 监听事件,固定为'metadataObjectsAvailable',metadataOutput创建成功后可监听。 |
4367| callback | AsyncCallback\<Array\<[MetadataObject](#metadataobject)\>\> | 否   | 回调函数,如果指定参数则取消对应callback(callback对象不可是匿名函数),否则取消所有callback。 |
4368
4369**示例:**
4370
4371```ts
4372function unregisterMetadataObjectsAvailable(metadataOutput: camera.MetadataOutput): void {
4373  metadataOutput.off('metadataObjectsAvailable');
4374}
4375```
4376
4377### on('error')
4378
4379on(type: 'error', callback: ErrorCallback): void
4380
4381监听metadata流的错误,通过注册回调函数获取结果。使用callback异步回调。
4382
4383> **说明:**
4384>
4385> 当前注册监听接口,不支持在on监听的回调方法里,调用off注销回调。
4386
4387**系统能力:** SystemCapability.Multimedia.Camera.Core
4388
4389**参数:**
4390
4391| 参数名     | 类型         | 必填 | 说明                                     |
4392| -------- | ------------- | ---- | --------------------------------------- |
4393| type     | string        | 是   | 监听事件,固定为'error',metadataOutput创建成功后可监听。metadata接口使用错误时触发该事件并返回对应错误码,比如调用[start](#start-3),[CameraOutput.release](#release-1)接口时发生错误返回对应错误信息。 |
4394| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback) | 是   | 回调函数,用于获取错误信息。返回错误码,错误码类型[CameraErrorCode](#cameraerrorcode)。            |
4395
4396**示例:**
4397
4398```ts
4399import { BusinessError } from '@kit.BasicServicesKit';
4400
4401function callback(metadataOutputError: BusinessError): void {
4402  console.error(`Metadata output error code: ${metadataOutputError.code}`);
4403}
4404
4405function registerMetadataOutputError(metadataOutput: camera.MetadataOutput): void {
4406  metadataOutput.on('error', callback);
4407}
4408```
4409
4410### off('error')
4411
4412off(type: 'error', callback?: ErrorCallback): void
4413
4414注销监听metadata流的错误。
4415
4416**系统能力:** SystemCapability.Multimedia.Camera.Core
4417
4418**参数:**
4419
4420| 参数名     | 类型         | 必填 | 说明                                     |
4421| -------- | ------------- | ---- | --------------------------------------- |
4422| type     | string        | 是   | 监听事件,固定为'error',metadataOutput创建成功后可监听。 |
4423| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback) | 否   | 回调函数,如果指定参数则取消对应callback(callback对象不可是匿名函数),否则取消所有callback。 |
4424
4425**示例:**
4426
4427```ts
4428function unregisterMetadataOutputError(metadataOutput: camera.MetadataOutput): void {
4429  metadataOutput.off('error');
4430}
4431```
4432
4433## MetadataObjectType
4434
4435枚举,metadata流。
4436
4437**系统能力:** SystemCapability.Multimedia.Camera.Core
4438
4439| 名称                       | 值   | 说明              |
4440| ------------------------- | ---- | ----------------- |
4441| FACE_DETECTION            | 0    | metadata对象类型,用于人脸检测。<br> 检测点应在0-1坐标系内,该坐标系左上角为(0,0),右下角为(1,1)。<br> 此坐标系以设备充电口在右侧时的横向设备方向为基准。<br>例如应用的预览界面布局以设备充电口在下侧时的竖向方向为基准,<br>布局宽高为(w,h), 返回点为(x,y),则转换后的坐标点为(1-y,x)。 |
4442
4443## Rect
4444
4445矩形定义。
4446
4447**系统能力:** SystemCapability.Multimedia.Camera.Core
4448
4449| 名称      | 类型   |  只读  | 可选  |           说明         |
4450| -------- | ------ | ------ |-----| --------------------- |
4451| topLeftX | number |   否   | 否   | 矩形区域左上角x坐标。   |
4452| topLeftY | number |   否   | 否   | 矩形区域左上角y坐标。   |
4453| width    | number |   否   | 否   | 矩形宽,相对值,范围[0, 1]。  |
4454| height   | number |   否   | 否   | 矩形高,相对值,范围[0, 1]。  |
4455
4456## MetadataObject
4457
4458相机元能力信息,[CameraInput](#camerainput)相机信息中的数据来源,通过metadataOutput.on('metadataObjectsAvailable')接口获取。
4459
4460**系统能力:** SystemCapability.Multimedia.Camera.Core
4461
4462| 名称         | 类型                                        | 只读 | 可选 |说明                |
4463| ----------- | ------------------------------------------- | ---- | ---- | ----------------- |
4464| type        | [MetadataObjectType](#metadataobjecttype)   |  是  |  否  | metadata 类型。    |
4465| timestamp   | number                                      |  是  |  否  | 当前时间戳(毫秒)。|
4466| boundingBox | [Rect](#rect)                               |  是  |  否  | metadata 区域框。  |
4467
4468## FlashMode
4469
4470枚举,闪光灯模式。
4471
4472**系统能力:** SystemCapability.Multimedia.Camera.Core
4473
4474| 名称                    | 值   | 说明        |
4475| ---------------------- | ---- | ---------- |
4476| FLASH_MODE_CLOSE       | 0    | 闪光灯关闭。 |
4477| FLASH_MODE_OPEN        | 1    | 闪光灯打开。 |
4478| FLASH_MODE_AUTO        | 2    | 自动闪光灯。 |
4479| FLASH_MODE_ALWAYS_OPEN | 3    | 闪光灯常亮。 |
4480
4481## ExposureMode
4482
4483枚举,曝光模式。
4484
4485**系统能力:** SystemCapability.Multimedia.Camera.Core
4486
4487| 名称                           | 值   | 说明         |
4488| ----------------------------- | ---- | ----------- |
4489| EXPOSURE_MODE_LOCKED          | 0    | 锁定曝光模式。不支持曝光区域中心点设置。 |
4490| EXPOSURE_MODE_AUTO            | 1    | 自动曝光模式。支持曝光区域中心点设置,可以使用[AutoExposure.setMeteringPoint](#setmeteringpoint11)接口设置曝光区域中心点。 |
4491| EXPOSURE_MODE_CONTINUOUS_AUTO | 2    | 连续自动曝光。不支持曝光区域中心点设置。 |
4492
4493## FocusMode
4494
4495枚举,焦距模式。
4496
4497**系统能力:** SystemCapability.Multimedia.Camera.Core
4498
4499| 名称                        | 值   | 说明          |
4500| -------------------------- | ---- | ------------ |
4501| FOCUS_MODE_MANUAL          | 0    | 手动对焦。通过手动修改相机焦距来改变对焦位置,不支持对焦点设置。     |
4502| FOCUS_MODE_CONTINUOUS_AUTO | 1    | 连续自动对焦。不支持对焦点设置。 |
4503| FOCUS_MODE_AUTO            | 2    | 自动对焦。支持对焦点设置,可以使用[Focus.setFocusPoint](#setfocuspoint11)设置对焦点,根据对焦点执行一次自动对焦。    |
4504| FOCUS_MODE_LOCKED          | 3    | 对焦锁定。不支持对焦点设置。     |
4505
4506## FocusState
4507
4508枚举,焦距状态。
4509
4510**系统能力:** SystemCapability.Multimedia.Camera.Core
4511
4512| 名称                   | 值   | 说明       |
4513| --------------------- | ---- | --------- |
4514| FOCUS_STATE_SCAN      | 0    | 触发对焦。  |
4515| FOCUS_STATE_FOCUSED   | 1    | 对焦成功。  |
4516| FOCUS_STATE_UNFOCUSED | 2    | 未完成对焦。 |
4517
4518## VideoStabilizationMode
4519
4520枚举,视频防抖模式。
4521
4522**系统能力:** SystemCapability.Multimedia.Camera.Core
4523
4524| 名称       | 值   | 说明         |
4525| --------- | ---- | ------------ |
4526| OFF       | 0    | 关闭视频防抖功能。   |
4527| LOW       | 1    | 使用基础防抖算法。   |
4528| MIDDLE    | 2    | 使用防抖效果一般的防抖算法,防抖效果优于LOW类型。   |
4529| HIGH      | 3    | 使用防抖效果最好的防抖算法,防抖效果优于MIDDLE类型。   |
4530| AUTO      | 4    | 自动进行选择防抖算法。   |
4531
4532## Session<sup>11+</sup>
4533
4534会话类,保存一次相机运行所需要的所有资源[CameraInput](#camerainput)、[CameraOutput](#cameraoutput),并向相机设备申请完成相机功能(录像,拍照)。
4535
4536### beginConfig<sup>11+</sup>
4537
4538beginConfig(): void
4539
4540开始配置会话。
4541
4542**系统能力:** SystemCapability.Multimedia.Camera.Core
4543
4544**错误码:**
4545
4546以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
4547
4548| 错误码ID         | 错误信息        |
4549| --------------- | --------------- |
4550| 7400105                |  Session config locked.               |
4551| 7400201                |  Camera service fatal error.               |
4552
4553**示例:**
4554
4555```ts
4556import { BusinessError } from '@kit.BasicServicesKit';
4557
4558function beginConfig(session: camera.Session): void {
4559  try {
4560    session.beginConfig();
4561  } catch (error) {
4562    // 失败返回错误码error.code并处理。
4563    let err = error as BusinessError;
4564    console.error(`The beginConfig call failed. error code: ${err.code}`);
4565  }
4566}
4567```
4568
4569### commitConfig<sup>11+</sup>
4570
4571commitConfig(callback: AsyncCallback\<void\>): void
4572
4573提交配置信息,通过注册回调函数获取结果。使用callback异步回调。
4574
4575**系统能力:** SystemCapability.Multimedia.Camera.Core
4576
4577**参数:**
4578
4579| 参数名     | 类型                   | 必填 | 说明                  |
4580| -------- | -------------------- | ---- | -------------------- |
4581| callback | AsyncCallback\<void\> | 是   | 回调函数,用于获取结果。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode),比如预览流与录像输出流的分辨率的宽高比不一致,会返回7400201。 |
4582
4583**错误码:**
4584
4585以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
4586
4587| 错误码ID         | 错误信息        |
4588| --------------- | --------------- |
4589| 7400102                |  Operation not allowed.                                  |
4590| 7400201                |  Camera service fatal error.                           |
4591
4592**示例:**
4593
4594```ts
4595import { BusinessError } from '@kit.BasicServicesKit';
4596
4597function commitConfig(session: camera.Session): void {
4598  session.commitConfig((err: BusinessError) => {
4599    if (err) {
4600      console.error(`The commitConfig call failed. error code: ${err.code}`);
4601      return;
4602    }
4603    console.info('Callback invoked to indicate the commit config success.');
4604  });
4605}
4606```
4607
4608### commitConfig<sup>11+</sup>
4609
4610commitConfig(): Promise\<void\>
4611
4612提交配置信息,通过Promise获取结果。
4613
4614**系统能力:** SystemCapability.Multimedia.Camera.Core
4615
4616**返回值:**
4617
4618| 类型            | 说明                     |
4619| -------------- | ------------------------ |
4620| Promise\<void\> | 无返回结果的Promise对象。 |
4621
4622**错误码:**
4623
4624以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
4625
4626| 错误码ID         | 错误信息        |
4627| --------------- | --------------- |
4628| 7400102                |  Operation not allowed.                                  |
4629| 7400201                |  Camera service fatal error.                           |
4630
4631**示例:**
4632
4633```ts
4634import { BusinessError } from '@kit.BasicServicesKit';
4635
4636function commitConfig(session: camera.Session): void {
4637  session.commitConfig().then(() => {
4638    console.info('Promise returned to indicate the commit config success.');
4639  }).catch((error: BusinessError) => {
4640    // 失败返回错误码error.code并处理。
4641    console.error(`The commitConfig call failed. error code: ${error.code}`);
4642  });
4643}
4644```
4645
4646### canAddInput<sup>11+</sup>
4647
4648canAddInput(cameraInput: CameraInput): boolean
4649
4650判断当前cameraInput是否可以添加到session中。当前函数需要在[beginConfig](#beginconfig11)和[commitConfig](#commitconfig11-1)之间生效。
4651
4652**系统能力:** SystemCapability.Multimedia.Camera.Core
4653
4654**参数:**
4655
4656| 参数名        | 类型                          | 必填 | 说明                     |
4657| ----------- | --------------------------- | ---- | ------------------------ |
4658| cameraInput | [CameraInput](#camerainput) | 是   | 需要添加的CameraInput实例。传参异常(如超出范围、传入null、未定义等),实际接口不会生效。 |
4659
4660**返回值:**
4661
4662| 类型            | 说明                     |
4663| -------------- | ------------------------ |
4664| boolean | 返回true表示支持添加当前cameraInput,返回false表示不支持添加。 |
4665
4666**示例:**
4667
4668```ts
4669import { BusinessError } from '@kit.BasicServicesKit';
4670
4671function canAddInput(session: camera.Session, cameraInput: camera.CameraInput): void {
4672  let canAdd: boolean = session.canAddInput(cameraInput);
4673  console.info(`The input canAddInput: ${canAdd}`);
4674}
4675```
4676
4677### addInput<sup>11+</sup>
4678
4679addInput(cameraInput: CameraInput): void
4680
4681把[CameraInput](#camerainput)加入到会话。
4682
4683**系统能力:** SystemCapability.Multimedia.Camera.Core
4684
4685**参数:**
4686
4687| 参数名        | 类型                          | 必填 | 说明                     |
4688| ----------- | --------------------------- | ---- | ------------------------ |
4689| cameraInput | [CameraInput](#camerainput) | 是   | 需要添加的CameraInput实例。 |
4690
4691**错误码:**
4692
4693以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
4694
4695| 错误码ID         | 错误信息        |
4696| --------------- | --------------- |
4697| 7400101                |  Parameter missing or parameter type incorrect.        |
4698| 7400102                |  Operation not allowed.                                  |
4699| 7400201                |  Camera service fatal error.                                   |
4700
4701**示例:**
4702
4703```ts
4704import { BusinessError } from '@kit.BasicServicesKit';
4705
4706function addInput(session: camera.Session, cameraInput: camera.CameraInput): void {
4707  try {
4708    session.addInput(cameraInput);
4709  } catch (error) {
4710    // 失败返回错误码error.code并处理。
4711    let err = error as BusinessError;
4712    console.error(`The addInput call failed. error code: ${err.code}`);
4713  }
4714}
4715```
4716
4717### removeInput<sup>11+</sup>
4718
4719removeInput(cameraInput: CameraInput): void
4720
4721移除[CameraInput](#camerainput)。当前函数需要在[beginConfig](#beginconfig11)和[commitConfig](#commitconfig11-1)之间生效。
4722
4723**系统能力:** SystemCapability.Multimedia.Camera.Core
4724
4725**参数:**
4726
4727| 参数名        | 类型                          | 必填 | 说明                      |
4728| ----------- | --------------------------- | ---- | ------------------------ |
4729| cameraInput | [CameraInput](#camerainput) | 是   | 需要移除的CameraInput实例。 |
4730
4731**错误码:**
4732
4733以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
4734
4735| 错误码ID         | 错误信息        |
4736| --------------- | --------------- |
4737| 7400101                |  Parameter missing or parameter type incorrect.        |
4738| 7400102                |  Operation not allowed.                                  |
4739| 7400201                |  Camera service fatal error.                                   |
4740
4741**示例:**
4742
4743```ts
4744import { BusinessError } from '@kit.BasicServicesKit';
4745
4746function removeInput(session: camera.Session, cameraInput: camera.CameraInput): void {
4747  try {
4748    session.removeInput(cameraInput);
4749  } catch (error) {
4750    // 失败返回错误码error.code并处理。
4751    let err = error as BusinessError;
4752    console.error(`The removeInput call failed. error code: ${err.code}`);
4753  }
4754}
4755```
4756
4757### canAddOutput<sup>11+</sup>
4758
4759canAddOutput(cameraOutput: CameraOutput): boolean
4760
4761判断当前cameraOutput是否可以添加到session中。当前函数需要在[addInput](#addinput11)和[commitConfig](#commitconfig11-1)之间生效。
4762
4763**系统能力:** SystemCapability.Multimedia.Camera.Core
4764
4765**参数:**
4766
4767| 参数名        | 类型                          | 必填 | 说明                     |
4768| ----------- | --------------------------- | ---- | ------------------------ |
4769| cameraOutput | [CameraOutput](#cameraoutput) | 是   | 需要添加的CameraOutput实例。传参异常(如超出范围、传入null、未定义等),实际接口不会生效。 |
4770
4771**返回值:**
4772
4773| 类型            | 说明                     |
4774| -------------- | ------------------------ |
4775| boolean | 是否可以添加当前cameraOutput到session中,true为可添加,false为不可添加。 |
4776
4777**示例:**
4778
4779```ts
4780import { BusinessError } from '@kit.BasicServicesKit';
4781
4782function canAddOutput(session: camera.Session, cameraOutput: camera.CameraOutput): void {
4783  let canAdd: boolean = session.canAddOutput(cameraOutput);
4784  console.info(`This addOutput can add: ${canAdd}`);
4785}
4786```
4787
4788### addOutput<sup>11+</sup>
4789
4790addOutput(cameraOutput: CameraOutput): void
4791
4792把[CameraOutput](#cameraoutput)加入到会话。
4793
4794**系统能力:** SystemCapability.Multimedia.Camera.Core
4795
4796**参数:**
4797
4798| 参数名           | 类型                             | 必填 | 说明                      |
4799| ------------- | ------------------------------- | ---- | ------------------------ |
4800| cameraOutput  | [CameraOutput](#cameraoutput)   | 是   | 需要添加的CameraOutput实例。 |
4801
4802**错误码:**
4803
4804以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
4805
4806| 错误码ID         | 错误信息        |
4807| --------------- | --------------- |
4808| 7400101                |  Parameter missing or parameter type incorrect.        |
4809| 7400102                |  Operation not allowed.                                  |
4810| 7400201                |  Camera service fatal error.                                   |
4811
4812**示例:**
4813
4814```ts
4815import { BusinessError } from '@kit.BasicServicesKit';
4816
4817function addOutput(session: camera.Session, cameraOutput: camera.CameraOutput): void {
4818  try {
4819    session.addOutput(cameraOutput);
4820  } catch (error) {
4821    // 失败返回错误码error.code并处理。
4822    let err = error as BusinessError;
4823    console.error(`The addOutput call failed. error code: ${err.code}`);
4824  }
4825}
4826```
4827
4828### removeOutput<sup>11+</sup>
4829
4830removeOutput(cameraOutput: CameraOutput): void
4831
4832从会话中移除[CameraOutput](#cameraoutput)。
4833
4834**系统能力:** SystemCapability.Multimedia.Camera.Core
4835
4836**参数:**
4837
4838| 参数名           | 类型                             | 必填 | 说明                      |
4839| ------------- | ------------------------------- | ---- | ------------------------ |
4840| cameraOutput  | [CameraOutput](#cameraoutput)   | 是   | 需要移除的CameraOutput实例。 |
4841
4842**错误码:**
4843
4844以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
4845
4846| 错误码ID         | 错误信息        |
4847| --------------- | --------------- |
4848| 7400101                |  Parameter missing or parameter type incorrect.        |
4849| 7400102                |  Operation not allowed.                                  |
4850| 7400201                |  Camera service fatal error.                                   |
4851
4852**示例:**
4853
4854```ts
4855import { BusinessError } from '@kit.BasicServicesKit';
4856
4857function removeOutput(session: camera.Session, previewOutput: camera.PreviewOutput): void {
4858  try {
4859    session.removeOutput(previewOutput);
4860  } catch (error) {
4861    // 失败返回错误码error.code并处理。
4862    let err = error as BusinessError;
4863    console.error(`The removeOutput call failed. error code: ${err.code}`);
4864  }
4865}
4866```
4867
4868### start<sup>11+</sup>
4869
4870start(callback: AsyncCallback\<void\>): void
4871
4872开始会话工作,通过注册回调函数获取结果。使用callback异步回调。
4873
4874**系统能力:** SystemCapability.Multimedia.Camera.Core
4875
4876**参数:**
4877
4878| 参数名      | 类型                  | 必填 | 说明                 |
4879| -------- | -------------------- | ---- | -------------------- |
4880| callback | AsyncCallback\<void\> | 是   | 回调函数,用于获取结果。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode)。 |
4881
4882**错误码:**
4883
4884以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
4885
4886| 错误码ID         | 错误信息        |
4887| --------------- | --------------- |
4888| 7400102                |  Operation not allowed.                                |
4889| 7400103                |  Session not config.                                   |
4890| 7400201                |  Camera service fatal error.                           |
4891
4892**示例:**
4893
4894```ts
4895import { BusinessError } from '@kit.BasicServicesKit';
4896
4897function startCaptureSession(session: camera.Session): void {
4898  session.start((err: BusinessError) => {
4899    if (err) {
4900      console.error(`Failed to start the session, error code: ${err.code}.`);
4901      return;
4902    }
4903    console.info('Callback invoked to indicate the session start success.');
4904  });
4905}
4906```
4907
4908### start<sup>11+</sup>
4909
4910start(): Promise\<void\>
4911
4912开始会话工作,通过Promise获取结果。
4913
4914**系统能力:** SystemCapability.Multimedia.Camera.Core
4915
4916**返回值:**
4917
4918| 类型            | 说明                     |
4919| -------------- | ------------------------ |
4920| Promise\<void\> | 无返回结果的Promise对象。 |
4921
4922**错误码:**
4923
4924以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
4925
4926| 错误码ID         | 错误信息        |
4927| --------------- | --------------- |
4928| 7400102                |  Operation not allowed.                                |
4929| 7400103                |  Session not config.                                   |
4930| 7400201                |  Camera service fatal error.                           |
4931
4932**示例:**
4933
4934```ts
4935import { BusinessError } from '@kit.BasicServicesKit';
4936
4937function startCaptureSession(session: camera.Session): void {
4938  session.start().then(() => {
4939    console.info('Promise returned to indicate the session start success.');
4940  }).catch((error: BusinessError) => {
4941    console.error(`Failed to start the session, error code: ${error.code}.`);
4942  });
4943}
4944```
4945
4946### stop<sup>11+</sup>
4947
4948stop(callback: AsyncCallback\<void\>): void
4949
4950停止会话工作,通过注册回调函数获取结果。使用callback异步回调。
4951
4952**系统能力:** SystemCapability.Multimedia.Camera.Core
4953
4954**参数:**
4955
4956| 参数名      | 类型                  | 必填 | 说明                 |
4957| -------- | -------------------- | ---- | ------------------- |
4958| callback | AsyncCallback\<void\> | 是   | 回调函数,用于获取结果。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode)。 |
4959
4960**错误码:**
4961
4962以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
4963
4964| 错误码ID         | 错误信息        |
4965| --------------- | --------------- |
4966| 7400201                |  Camera service fatal error.                           |
4967
4968**示例:**
4969
4970```ts
4971import { BusinessError } from '@kit.BasicServicesKit';
4972
4973function stopCaptureSession(session: camera.Session): void {
4974  session.stop((err: BusinessError) => {
4975    if (err) {
4976      console.error(`Failed to stop the session, error code: ${err.code}.`);
4977      return;
4978    }
4979    console.info('Callback invoked to indicate the session stop success.');
4980  });
4981}
4982```
4983
4984### stop<sup>11+</sup>
4985
4986stop(): Promise\<void\>
4987
4988停止会话工作,通过Promise获取结果。
4989
4990**系统能力:** SystemCapability.Multimedia.Camera.Core
4991
4992**返回值:**
4993
4994| 类型            | 说明                |
4995| -------------- |-------------------|
4996| Promise\<void\> | 无返回结果的Promise对象。  |
4997
4998**错误码:**
4999
5000以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
5001
5002| 错误码ID         | 错误信息        |
5003| --------------- | --------------- |
5004| 7400201                |  Camera service fatal error.                           |
5005
5006**示例:**
5007
5008```ts
5009import { BusinessError } from '@kit.BasicServicesKit';
5010
5011function stopCaptureSession(session: camera.Session): void {
5012  session.stop().then(() => {
5013    console.info('Promise returned to indicate the session stop success.');
5014  }).catch((error: BusinessError) => {
5015    console.error(`Failed to stop the session, error code: ${error.code}.`);
5016  });
5017}
5018```
5019
5020### release<sup>11+</sup>
5021
5022release(callback: AsyncCallback\<void\>): void
5023
5024释放会话资源,通过注册回调函数获取结果。使用callback异步回调。
5025
5026**系统能力:** SystemCapability.Multimedia.Camera.Core
5027
5028**参数:**
5029
5030| 参数名      | 类型                  | 必填 | 说明                 |
5031| -------- | -------------------- | ---- | -------------------- |
5032| callback | AsyncCallback\<void\> | 是   | 回调函数,用于获取结果。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode)。 |
5033
5034**错误码:**
5035
5036以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
5037
5038| 错误码ID         | 错误信息        |
5039| --------------- | --------------- |
5040| 7400201                |  Camera service fatal error.                           |
5041
5042**示例:**
5043
5044```ts
5045import { BusinessError } from '@kit.BasicServicesKit';
5046
5047function releaseCaptureSession(session: camera.Session): void {
5048  session.release((err: BusinessError) => {
5049    if (err) {
5050      console.error(`Failed to release the session instance, error code: ${err.code}.`);
5051      return;
5052    }
5053    console.info('Callback invoked to indicate that the session instance is released successfully.');
5054  });
5055}
5056```
5057
5058### release<sup>11+</sup>
5059
5060release(): Promise\<void\>
5061
5062释放会话资源,通过Promise获取结果。
5063
5064**系统能力:** SystemCapability.Multimedia.Camera.Core
5065
5066**返回值:**
5067
5068| 类型            | 说明                     |
5069| -------------- | ------------------------ |
5070| Promise\<void\> | 无返回结果的Promise对象。 |
5071
5072**错误码:**
5073
5074以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
5075
5076| 错误码ID         | 错误信息        |
5077| --------------- | --------------- |
5078| 7400201                |  Camera service fatal error.                           |
5079
5080**示例:**
5081
5082```ts
5083import { BusinessError } from '@kit.BasicServicesKit';
5084
5085function releaseCaptureSession(session: camera.Session): void {
5086  session.release().then(() => {
5087    console.info('Promise returned to indicate that the session instance is released successfully.');
5088  }).catch((error: BusinessError) => {
5089    console.error(`Failed to release the session instance, error code: ${error.code}.`);
5090  });
5091}
5092```
5093
5094## Flash<sup>11+</sup>
5095
5096Flash extends [FlashQuery](#flashquery12)
5097
5098闪光灯类,对设备闪光灯操作。
5099
5100### setFlashMode<sup>11+</sup>
5101
5102setFlashMode(flashMode: FlashMode): void
5103
5104设置闪光灯模式。
5105
5106进行设置之前,需要先检查:
5107
51081. 设备是否支持闪光灯,可使用方法[hasFlash](#hasflash11)。
51092. 设备是否支持指定的闪光灯模式,可使用方法[isFlashModeSupported](#isflashmodesupported11)。
5110
5111**系统能力:** SystemCapability.Multimedia.Camera.Core
5112
5113**参数:**
5114
5115| 参数名       | 类型                     | 必填 | 说明                  |
5116| --------- | ----------------------- | ---- | --------------------- |
5117| flashMode | [FlashMode](#flashmode) | 是   | 指定闪光灯模式。传参为null或者undefined,作为0处理,闪光灯关闭。       |
5118
5119**错误码:**
5120
5121以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
5122
5123| 错误码ID         | 错误信息        |
5124| --------------- | --------------- |
5125| 7400103                |  Session not config.                                   |
5126
5127**示例:**
5128
5129```ts
5130import { BusinessError } from '@kit.BasicServicesKit';
5131
5132function setFlashMode(photoSession: camera.PhotoSession): void {
5133  try {
5134    photoSession.setFlashMode(camera.FlashMode.FLASH_MODE_AUTO);
5135  } catch (error) {
5136    // 失败返回错误码error.code并处理。
5137    let err = error as BusinessError;
5138    console.error(`The setFlashMode call failed. error code: ${err.code}`);
5139  }
5140}
5141```
5142
5143### getFlashMode<sup>11+</sup>
5144
5145getFlashMode(): FlashMode
5146
5147获取当前设备的闪光灯模式。
5148
5149**系统能力:** SystemCapability.Multimedia.Camera.Core
5150
5151**返回值:**
5152
5153| 类型        | 说明                          |
5154| ---------- | ----------------------------- |
5155| [FlashMode](#flashmode)    | 获取当前设备的闪光灯模式。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode)。 |
5156
5157**错误码:**
5158
5159以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
5160
5161| 错误码ID         | 错误信息        |
5162| --------------- | --------------- |
5163| 7400103                |  Session not config.                                   |
5164
5165**示例:**
5166
5167```ts
5168import { BusinessError } from '@kit.BasicServicesKit';
5169
5170function getFlashMode(photoSession: camera.PhotoSession): camera.FlashMode | undefined {
5171  let flashMode: camera.FlashMode | undefined = undefined;
5172  try {
5173    flashMode = photoSession.getFlashMode();
5174  } catch (error) {
5175    // 失败返回错误码error.code并处理。
5176    let err = error as BusinessError;
5177    console.error(`The getFlashMode call failed.error code: ${err.code}`);
5178  }
5179  return flashMode;
5180}
5181```
5182
5183## FlashQuery<sup>12+</sup>
5184
5185提供了查询设备的闪光灯状态和模式的能力。
5186
5187### hasFlash<sup>11+</sup>
5188
5189hasFlash(): boolean
5190
5191检测是否有闪光灯,通过注册回调函数获取结果。
5192
5193**系统能力:** SystemCapability.Multimedia.Camera.Core
5194
5195**返回值:**
5196
5197| 类型        | 说明                          |
5198| ---------- | ----------------------------- |
5199| boolean    | 返回true表示设备支持闪光灯,false表示不支持。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode)。 |
5200
5201**错误码:**
5202
5203以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
5204
5205| 错误码ID         | 错误信息        |
5206| --------------- | --------------- |
5207| 7400103                |  Session not config, only throw in session usage.       |
5208
5209**示例:**
5210
5211```ts
5212import { BusinessError } from '@kit.BasicServicesKit';
5213
5214function hasFlash(photoSession: camera.PhotoSession): boolean {
5215  let status: boolean = false;
5216  try {
5217    status = photoSession.hasFlash();
5218  } catch (error) {
5219    // 失败返回错误码error.code并处理。
5220    let err = error as BusinessError;
5221    console.error(`The hasFlash call failed. error code: ${err.code}`);
5222  }
5223  return status;
5224}
5225```
5226
5227### isFlashModeSupported<sup>11+</sup>
5228
5229isFlashModeSupported(flashMode: FlashMode): boolean
5230
5231检测闪光灯模式是否支持。
5232
5233**系统能力:** SystemCapability.Multimedia.Camera.Core
5234
5235**参数:**
5236
5237| 参数名       | 类型                     | 必填 | 说明                               |
5238| --------- | ----------------------- | ---- | --------------------------------- |
5239| flashMode | [FlashMode](#flashmode) | 是   | 指定闪光灯模式。传参为null或者undefined,作为0处理,闪光灯关闭。             |
5240
5241**返回值:**
5242
5243| 类型        | 说明                          |
5244| ---------- | ----------------------------- |
5245| boolean    | 返回true表示支持该闪光灯模式,false表示不支持。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode)。 |
5246
5247**错误码:**
5248
5249以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
5250
5251| 错误码ID         | 错误信息        |
5252| --------------- | --------------- |
5253| 7400103                |  Session not config, only throw in session usage.             |
5254
5255**示例:**
5256
5257```ts
5258import { BusinessError } from '@kit.BasicServicesKit';
5259
5260function isFlashModeSupported(photoSession: camera.PhotoSession): boolean {
5261  let status: boolean = false;
5262  try {
5263    status = photoSession.isFlashModeSupported(camera.FlashMode.FLASH_MODE_AUTO);
5264  } catch (error) {
5265    // 失败返回错误码error.code并处理。
5266    let err = error as BusinessError;
5267    console.error(`The isFlashModeSupported call failed. error code: ${err.code}`);
5268  }
5269  return status;
5270}
5271```
5272
5273## AutoExposure<sup>11+</sup>
5274
5275AutoExposure extends [AutoExposureQuery](#autoexposurequery12)
5276
5277自动曝光类,对设备自动曝光(AE)操作。
5278
5279### getExposureMode<sup>11+</sup>
5280
5281getExposureMode(): ExposureMode
5282
5283获取当前曝光模式。
5284
5285**系统能力:** SystemCapability.Multimedia.Camera.Core
5286
5287**返回值:**
5288
5289| 类型        | 说明                          |
5290| ---------- | ----------------------------- |
5291| [ExposureMode](#exposuremode)    | 获取当前曝光模式。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode)。 |
5292
5293**错误码:**
5294
5295以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
5296
5297| 错误码ID         | 错误信息        |
5298| --------------- | --------------- |
5299| 7400103                |  Session not config.                                   |
5300
5301**示例:**
5302
5303```ts
5304import { BusinessError } from '@kit.BasicServicesKit';
5305
5306function getExposureMode(photoSession: camera.PhotoSession): camera.ExposureMode | undefined {
5307  let exposureMode: camera.ExposureMode | undefined = undefined;
5308  try {
5309    exposureMode = photoSession.getExposureMode();
5310  } catch (error) {
5311    // 失败返回错误码error.code并处理。
5312    let err = error as BusinessError;
5313    console.error(`The getExposureMode call failed. error code: ${err.code}`);
5314  }
5315  return exposureMode;
5316}
5317```
5318
5319### setExposureMode<sup>11+</sup>
5320
5321setExposureMode(aeMode: ExposureMode): void
5322
5323设置曝光模式。进行设置之前,需要先检查设备是否支持指定的曝光模式,可使用方法[isExposureModeSupported](#isexposuremodesupported11)。
5324
5325**系统能力:** SystemCapability.Multimedia.Camera.Core
5326
5327**参数:**
5328
5329| 参数名      | 类型                            | 必填 | 说明                    |
5330| -------- | -------------------------------| ---- | ----------------------- |
5331| aeMode   | [ExposureMode](#exposuremode)  | 是   | 曝光模式。传参为null或者undefined,作为0处理,曝光锁定。                |
5332
5333**错误码:**
5334
5335以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
5336
5337| 错误码ID         | 错误信息        |
5338| --------------- | --------------- |
5339| 7400103                |  Session not config.                                   |
5340
5341**示例:**
5342
5343```ts
5344import { BusinessError } from '@kit.BasicServicesKit';
5345
5346function setExposureMode(photoSession: camera.PhotoSession): void {
5347  try {
5348    photoSession.setExposureMode(camera.ExposureMode.EXPOSURE_MODE_LOCKED);
5349  } catch (error) {
5350    // 失败返回错误码error.code并处理。
5351    let err = error as BusinessError;
5352    console.error(`The setExposureMode call failed. error code: ${err.code}`);
5353  }
5354}
5355```
5356
5357### getMeteringPoint<sup>11+</sup>
5358
5359getMeteringPoint(): Point
5360
5361查询曝光区域中心点。
5362
5363**系统能力:** SystemCapability.Multimedia.Camera.Core
5364
5365**返回值:**
5366
5367| 类型        | 说明                          |
5368| ---------- | ----------------------------- |
5369| [Point](#point)    | 获取当前曝光点。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode)。 |
5370
5371**错误码:**
5372
5373以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
5374
5375| 错误码ID         | 错误信息        |
5376| --------------- | --------------- |
5377| 7400103                |  Session not config.                                   |
5378
5379**示例:**
5380
5381```ts
5382import { BusinessError } from '@kit.BasicServicesKit';
5383
5384function getMeteringPoint(photoSession: camera.PhotoSession): camera.Point | undefined {
5385  let exposurePoint: camera.Point | undefined = undefined;
5386  try {
5387    exposurePoint = photoSession.getMeteringPoint();
5388  } catch (error) {
5389    // 失败返回错误码error.code并处理。
5390    let err = error as BusinessError;
5391    console.error(`The getMeteringPoint call failed. error code: ${err.code}`);
5392  }
5393  return exposurePoint;
5394}
5395```
5396
5397### setMeteringPoint<sup>11+</sup>
5398
5399setMeteringPoint(point: Point): void
5400
5401设置曝光区域中心点,曝光点应在0-1坐标系内,该坐标系左上角为{0,0},右下角为{1,1}。<br>此坐标系是以设备充电口在右侧时的横向设备方向为基准的,例如应用的预览界面布局以<br>设备充电口在下侧时的竖向方向为基准,布局宽高为{w,h},且触碰点为{x,y},<br>则转换后的坐标点为{y/h,1-x/w}。
5402
5403**系统能力:** SystemCapability.Multimedia.Camera.Core
5404
5405**参数:**
5406
5407| 参数名           | 类型                            | 必填 | 说明                 |
5408| ------------- | -------------------------------| ---- | ------------------- |
5409| point | [Point](#point)                | 是   | 曝光点,x、y设置范围应在[0,1]之内,超过范围,如果小于0设置0,大于1设置1。             |
5410
5411**错误码:**
5412
5413以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
5414
5415| 错误码ID         | 错误信息        |
5416| --------------- | --------------- |
5417| 7400103                |  Session not config.                                   |
5418
5419**示例:**
5420
5421```ts
5422import { BusinessError } from '@kit.BasicServicesKit';
5423
5424function setMeteringPoint(photoSession: camera.PhotoSession): void {
5425  const point: camera.Point = {x: 1, y: 1};
5426  try {
5427    photoSession.setMeteringPoint(point);
5428  } catch (error) {
5429    // 失败返回错误码error.code并处理。
5430    let err = error as BusinessError;
5431    console.error(`The setMeteringPoint call failed. error code: ${err.code}`);
5432  }
5433}
5434```
5435
5436### getExposureBiasRange<sup>11+</sup>
5437
5438getExposureBiasRange(): Array\<number\>
5439
5440查询曝光补偿范围。
5441
5442**系统能力:** SystemCapability.Multimedia.Camera.Core
5443
5444**返回值:**
5445
5446| 类型        | 说明                          |
5447| ---------- | ----------------------------- |
5448| Array\<number\>   | 获取补偿范围的数组。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode)。 |
5449
5450**错误码:**
5451
5452以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
5453
5454| 错误码ID         | 错误信息        |
5455| --------------- | --------------- |
5456| 7400103                |  Session not config.   |
5457
5458**示例:**
5459
5460```ts
5461import { BusinessError } from '@kit.BasicServicesKit';
5462
5463function getExposureBiasRange(photoSession: camera.PhotoSession): Array<number> {
5464  let biasRangeArray: Array<number> = [];
5465  try {
5466    biasRangeArray = photoSession.getExposureBiasRange();
5467  } catch (error) {
5468    // 失败返回错误码error.code并处理。
5469    let err = error as BusinessError;
5470    console.error(`The getExposureBiasRange call failed. error code: ${err.code}`);
5471  }
5472  return biasRangeArray;
5473}
5474```
5475
5476### setExposureBias<sup>11+</sup>
5477
5478setExposureBias(exposureBias: number): void
5479
5480设置曝光补偿,曝光补偿值(EV)。
5481
5482进行设置之前,建议先通过方法[getExposureBiasRange](#getexposurebiasrange11)查询支持的范围。
5483
5484**系统能力:** SystemCapability.Multimedia.Camera.Core
5485
5486**参数:**
5487
5488| 参数名     | 类型                            | 必填 | 说明                                                                                                                                                                                            |
5489| -------- | -------------------------------| ---- |-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
5490| exposureBias   | number                   | 是   | 曝光补偿,[getExposureBiasRange](#getexposurebiasrange11)查询支持的范围,如果设置超过支持范围的值,自动匹配到就近临界点。<br>曝光补偿存在步长,如步长为0.5。则设置1.2时,获取到实际生效曝光补偿为1.0。<br>接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode)。 |
5491
5492**错误码:**
5493
5494以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
5495
5496| 错误码ID         | 错误信息        |
5497| --------------- | --------------- |
5498| 7400102                |  Operation not allowed.                                |
5499| 7400103                |  Session not config.                                   |
5500
5501**示例:**
5502
5503```ts
5504import { BusinessError } from '@kit.BasicServicesKit';
5505
5506function setExposureBias(photoSession: camera.PhotoSession, biasRangeArray: Array<number>): void {
5507  if (biasRangeArray && biasRangeArray.length > 0) {
5508    let exposureBias = biasRangeArray[0];
5509    try {
5510      photoSession.setExposureBias(exposureBias);
5511    } catch (error) {
5512      // 失败返回错误码error.code并处理。
5513      let err = error as BusinessError;
5514      console.error(`The setExposureBias call failed. error code: ${err.code}`);
5515    }
5516  }
5517}
5518```
5519
5520### getExposureValue<sup>11+</sup>
5521
5522getExposureValue(): number
5523
5524查询当前曝光值。
5525
5526**系统能力:** SystemCapability.Multimedia.Camera.Core
5527
5528**返回值:**
5529
5530| 类型        | 说明                          |
5531| ---------- | ----------------------------- |
5532| number    | 获取曝光值。曝光补偿存在步长,如步长为0.5。则设置1.2时,获取到实际生效曝光补偿为1.0。<br>接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode)。 |
5533
5534**错误码:**
5535
5536以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
5537
5538| 错误码ID         | 错误信息        |
5539| --------------- | --------------- |
5540| 7400103                |  Session not config.                                   |
5541
5542**示例:**
5543
5544```ts
5545import { BusinessError } from '@kit.BasicServicesKit';
5546
5547function getExposureValue(photoSession: camera.PhotoSession): number {
5548  const invalidValue: number = -1;
5549  let exposureValue: number = invalidValue;
5550  try {
5551    exposureValue = photoSession.getExposureValue();
5552  } catch (error) {
5553    // 失败返回错误码error.code并处理。
5554    let err = error as BusinessError;
5555    console.error(`The getExposureValue call failed. error code: ${err.code}`);
5556  }
5557  return exposureValue;
5558}
5559```
5560
5561## AutoExposureQuery<sup>12+</sup>
5562
5563提供了针对设备的自动曝光特性提供了一系列查询功能。
5564
5565### isExposureModeSupported<sup>11+</sup>
5566
5567isExposureModeSupported(aeMode: ExposureMode): boolean
5568
5569检测曝光模式是否支持。
5570
5571**系统能力:** SystemCapability.Multimedia.Camera.Core
5572
5573**参数:**
5574
5575| 参数名      | 类型                           | 必填  | 说明                           |
5576| -------- | -------------------------------| ---- | ----------------------------- |
5577| aeMode   | [ExposureMode](#exposuremode)  | 是   | 曝光模式。传参为null或者undefined,作为0处理,曝光锁定。                 |
5578
5579**返回值:**
5580
5581| 类型        | 说明                          |
5582| ---------- | ----------------------------- |
5583| boolean    | 获取是否支持曝光模式,true为支持,false为不支持。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode)。 |
5584
5585**错误码:**
5586
5587以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
5588
5589| 错误码ID         | 错误信息        |
5590| --------------- | --------------- |
5591| 7400103                |  Session not config, only throw in session usage.          |
5592
5593**示例:**
5594
5595```ts
5596import { BusinessError } from '@kit.BasicServicesKit';
5597
5598function isExposureModeSupported(photoSession: camera.PhotoSession): boolean {
5599  let isSupported: boolean = false;
5600  try {
5601    isSupported = photoSession.isExposureModeSupported(camera.ExposureMode.EXPOSURE_MODE_LOCKED);
5602  } catch (error) {
5603    // 失败返回错误码error.code并处理。
5604    let err = error as BusinessError;
5605    console.error(`The isExposureModeSupported call failed. error code: ${err.code}`);
5606  }
5607  return isSupported;
5608}
5609```
5610
5611### getExposureBiasRange<sup>11+</sup>
5612
5613getExposureBiasRange(): Array\<number\>
5614
5615查询曝光补偿范围。
5616
5617**系统能力:** SystemCapability.Multimedia.Camera.Core
5618
5619**返回值:**
5620
5621| 类型        | 说明                          |
5622| ---------- | ----------------------------- |
5623| Array\<number\>   | 获取补偿范围的数组。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode)。 |
5624
5625**错误码:**
5626
5627以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
5628
5629| 错误码ID         | 错误信息        |
5630| --------------- | --------------- |
5631| 7400103                |  Session not config, only throw in session usage.               |
5632
5633**示例:**
5634
5635```ts
5636import { BusinessError } from '@kit.BasicServicesKit';
5637
5638function getExposureBiasRange(photoSession: camera.PhotoSession): Array<number> {
5639  let biasRangeArray: Array<number> = [];
5640  try {
5641    biasRangeArray = photoSession.getExposureBiasRange();
5642  } catch (error) {
5643    // 失败返回错误码error.code并处理。
5644    let err = error as BusinessError;
5645    console.error(`The getExposureBiasRange call failed. error code: ${err.code}`);
5646  }
5647  return biasRangeArray;
5648}
5649```
5650
5651## Focus<sup>11+</sup>
5652
5653Focus extends [FocusQuery](#focusquery12)
5654
5655对焦类,对设备对焦操作。
5656
5657### setFocusMode<sup>11+</sup>
5658
5659setFocusMode(afMode: FocusMode): void
5660
5661设置对焦模式。
5662
5663进行设置之前,需要先检查设备是否支持指定的焦距模式,可使用方法[isFocusModeSupported](#isfocusmodesupported11)。
5664
5665**系统能力:** SystemCapability.Multimedia.Camera.Core
5666
5667**参数:**
5668
5669| 参数名      | 类型                     | 必填 | 说明                 |
5670| -------- | ----------------------- | ---- | ------------------- |
5671| afMode   | [FocusMode](#focusmode) | 是   | 指定的焦距模式。传参为null或者undefined,作为0处理,手动对焦模式。       |
5672
5673**错误码:**
5674
5675以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
5676
5677| 错误码ID         | 错误信息        |
5678| --------------- | --------------- |
5679| 7400103                |  Session not config.                                   |
5680
5681**示例:**
5682
5683```ts
5684import { BusinessError } from '@kit.BasicServicesKit';
5685
5686function setFocusMode(photoSession: camera.PhotoSession): void {
5687  try {
5688    photoSession.setFocusMode(camera.FocusMode.FOCUS_MODE_AUTO);
5689  } catch (error) {
5690    // 失败返回错误码error.code并处理。
5691    let err = error as BusinessError;
5692    console.error(`The setFocusMode call failed. error code: ${err.code}`);
5693  }
5694}
5695```
5696
5697### getFocusMode<sup>11+</sup>
5698
5699getFocusMode(): FocusMode
5700
5701获取当前的对焦模式。
5702
5703**系统能力:** SystemCapability.Multimedia.Camera.Core
5704
5705**返回值:**
5706
5707| 类型        | 说明                          |
5708| ---------- | ----------------------------- |
5709| [FocusMode](#focusmode)   | 获取当前设备的焦距模式。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode)。 |
5710
5711**错误码:**
5712
5713以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
5714
5715| 错误码ID         | 错误信息        |
5716| --------------- | --------------- |
5717| 7400103                |  Session not config.                                   |
5718
5719**示例:**
5720
5721```ts
5722import { BusinessError } from '@kit.BasicServicesKit';
5723
5724function getFocusMode(photoSession: camera.PhotoSession): camera.FocusMode | undefined {
5725  let afMode: camera.FocusMode | undefined = undefined;
5726  try {
5727    afMode = photoSession.getFocusMode();
5728  } catch (error) {
5729    // 失败返回错误码error.code并处理。
5730    let err = error as BusinessError;
5731    console.error(`The getFocusMode call failed. error code: ${err.code}`);
5732  }
5733  return afMode;
5734}
5735```
5736
5737### setFocusPoint<sup>11+</sup>
5738
5739setFocusPoint(point: Point): void
5740
5741设置焦点,焦点应在0-1坐标系内,该坐标系左上角为{0,0},右下角为{1,1}。<br>此坐标系是以设备充电口在右侧时的横向设备方向为基准的,例如应用的预览界面布局以<br>设备充电口在下侧时的竖向方向为基准,布局宽高为{w,h},且触碰点为{x,y},<br>则转换后的坐标点为{y/h,1-x/w}。
5742
5743**系统能力:** SystemCapability.Multimedia.Camera.Core
5744
5745**参数:**
5746
5747| 参数名      | 类型                     | 必填 | 说明                 |
5748| -------- | ----------------------- | ---- | ------------------- |
5749| point    | [Point](#point)         | 是   | 焦点。x、y设置范围应在[0,1]之内,超过范围,如果小于0设置0,大于1设置1。   |
5750
5751**错误码:**
5752
5753以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
5754
5755| 错误码ID         | 错误信息        |
5756| --------------- | --------------- |
5757| 7400103                |  Session not config.                                   |
5758
5759**示例:**
5760
5761```ts
5762import { BusinessError } from '@kit.BasicServicesKit';
5763
5764function setFocusPoint(photoSession: camera.PhotoSession): void {
5765  const focusPoint: camera.Point = {x: 1, y: 1};
5766  try {
5767    photoSession.setFocusPoint(focusPoint);
5768  } catch (error) {
5769    // 失败返回错误码error.code并处理。
5770    let err = error as BusinessError;
5771    console.error(`The setFocusPoint call failed. error code: ${err.code}`);
5772  }
5773}
5774```
5775
5776### getFocusPoint<sup>11+</sup>
5777
5778getFocusPoint(): Point
5779
5780查询焦点。
5781
5782**系统能力:** SystemCapability.Multimedia.Camera.Core
5783
5784**返回值:**
5785
5786| 类型        | 说明                          |
5787| ---------- | ----------------------------- |
5788| [Point](#point)    | 用于获取当前焦点。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode)。 |
5789
5790**错误码:**
5791
5792以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
5793
5794| 错误码ID         | 错误信息        |
5795| --------------- | --------------- |
5796| 7400103                |  Session not config.                                   |
5797
5798**示例:**
5799
5800```ts
5801import { BusinessError } from '@kit.BasicServicesKit';
5802
5803function getFocusPoint(photoSession: camera.PhotoSession): camera.Point | undefined {
5804  let point: camera.Point | undefined = undefined;
5805  try {
5806    point = photoSession.getFocusPoint();
5807  } catch (error) {
5808    // 失败返回错误码error.code并处理。
5809    let err = error as BusinessError;
5810    console.error(`The getFocusPoint call failed. error code: ${err.code}`);
5811  }
5812  return point;
5813}
5814```
5815
5816### getFocalLength<sup>11+</sup>
5817
5818getFocalLength(): number
5819
5820查询焦距值。
5821
5822**系统能力:** SystemCapability.Multimedia.Camera.Core
5823
5824**返回值:**
5825
5826| 类型        | 说明                          |
5827| ---------- | ----------------------------- |
5828| number    | 用于获取当前焦距,单位mm。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode)。 |
5829
5830**错误码:**
5831
5832以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
5833
5834| 错误码ID         | 错误信息        |
5835| --------------- | --------------- |
5836| 7400103                |  Session not config.                                   |
5837
5838**示例:**
5839
5840```ts
5841import { BusinessError } from '@kit.BasicServicesKit';
5842
5843function getFocalLength(photoSession: camera.PhotoSession): number {
5844  const invalidValue: number = -1;
5845  let focalLength: number = invalidValue;
5846  try {
5847    focalLength = photoSession.getFocalLength();
5848  } catch (error) {
5849    // 失败返回错误码error.code并处理。
5850    let err = error as BusinessError;
5851    console.error(`The getFocalLength call failed. error code: ${err.code}`);
5852  }
5853  return focalLength;
5854}
5855```
5856
5857## FocusQuery<sup>12+</sup>
5858
5859提供了查询是否支持当前对焦模式的方法。
5860
5861### isFocusModeSupported<sup>11+</sup>
5862
5863isFocusModeSupported(afMode: FocusMode): boolean
5864
5865检测对焦模式是否支持。
5866
5867**系统能力:** SystemCapability.Multimedia.Camera.Core
5868
5869**参数:**
5870
5871| 参数名      | 类型                     | 必填 | 说明                              |
5872| -------- | ----------------------- | ---- | -------------------------------- |
5873| afMode   | [FocusMode](#focusmode) | 是   | 指定的焦距模式。传参为null或者undefined,作为0处理,手动对焦模式。                    |
5874
5875**返回值:**
5876
5877| 类型        | 说明                          |
5878| ---------- | ----------------------------- |
5879| boolean    | 返回true表示支持该焦距模式,false表示不支持。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode)。 |
5880
5881**错误码:**
5882
5883以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
5884
5885| 错误码ID         | 错误信息        |
5886| --------------- | --------------- |
5887| 7400103                |  Session not config, only throw in session usage.          |
5888
5889**示例:**
5890
5891```ts
5892import { BusinessError } from '@kit.BasicServicesKit';
5893
5894function isFocusModeSupported(photoSession: camera.PhotoSession): boolean {
5895  let status: boolean = false;
5896  try {
5897    status = photoSession.isFocusModeSupported(camera.FocusMode.FOCUS_MODE_AUTO);
5898  } catch (error) {
5899    // 失败返回错误码error.code并处理。
5900    let err = error as BusinessError;
5901    console.error(`The isFocusModeSupported call failed. error code: ${err.code}`);
5902  }
5903  return status;
5904}
5905```
5906
5907## SmoothZoomMode<sup>11+</sup>
5908
5909平滑变焦模式。
5910
5911**系统能力:** SystemCapability.Multimedia.Camera.Core
5912
5913| 名称         | 值   | 说明            |
5914| ------------ | ---- | -------------- |
5915| NORMAL       | 0    | 贝塞尔曲线模式。  |
5916
5917## SmoothZoomInfo<sup>11+</sup>
5918
5919平滑变焦参数信息。
5920
5921**系统能力:** SystemCapability.Multimedia.Camera.Core
5922
5923| 名称     | 类型        |   只读   |   可选   | 说明       |
5924| -------- | ---------- | -------- | -------- | ---------- |
5925| duration |   number   |   否     |    否    | 平滑变焦总时长,单位ms。 |
5926
5927## Zoom<sup>11+</sup>
5928
5929Zoom extends [ZoomQuery](#zoomquery12)
5930
5931变焦类,对设备变焦操作。
5932
5933### setZoomRatio<sup>11+</sup>
5934
5935setZoomRatio(zoomRatio: number): void
5936
5937设置变焦比,变焦精度最高为小数点后两位,如果设置超过支持的精度范围,则只保留精度范围内数值。
5938
5939**系统能力:** SystemCapability.Multimedia.Camera.Core
5940
5941**参数:**
5942
5943| 参数名       | 类型                  | 必填 | 说明                                                                                                                              |
5944| --------- | -------------------- | ---- |---------------------------------------------------------------------------------------------------------------------------------|
5945| zoomRatio | number               | 是   | 可变焦距比,通过[getZoomRatioRange](#getzoomratiorange11)获取支持的变焦范围,如果设置超过支持范围的值,则只保留精度范围内数值。<br>设置可变焦距比到底层生效需要一定时间,获取正确设置的可变焦距比需要等待1~2帧的时间。 |
5946
5947**错误码:**
5948
5949以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
5950
5951| 错误码ID         | 错误信息        |
5952| --------------- | --------------- |
5953| 7400103                |  Session not config.                                   |
5954
5955**示例:**
5956
5957```ts
5958import { BusinessError } from '@kit.BasicServicesKit';
5959
5960function setZoomRatio(photoSession: camera.PhotoSession, zoomRatioRange: Array<number>): void {
5961  if (zoomRatioRange === undefined || zoomRatioRange.length <= 0) {
5962    return;
5963  }
5964  let zoomRatio = zoomRatioRange[0];
5965  try {
5966    photoSession.setZoomRatio(zoomRatio);
5967  } catch (error) {
5968    // 失败返回错误码error.code并处理。
5969    let err = error as BusinessError;
5970    console.error(`The setZoomRatio call failed. error code: ${err.code}`);
5971  }
5972}
5973```
5974
5975### getZoomRatio<sup>11+</sup>
5976
5977getZoomRatio(): number
5978
5979获取当前的变焦比。
5980
5981**系统能力:** SystemCapability.Multimedia.Camera.Core
5982
5983**返回值:**
5984
5985| 类型        | 说明                          |
5986| ---------- | ----------------------------- |
5987| number    | 获取当前的变焦比结果。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode)。 |
5988
5989**错误码:**
5990
5991以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
5992
5993| 错误码ID         | 错误信息        |
5994| --------------- | --------------- |
5995| 7400103                |  Session not config.                                   |
5996| 7400201                |  Camera service fatal error.                           |
5997
5998**示例:**
5999
6000```ts
6001import { BusinessError } from '@kit.BasicServicesKit';
6002
6003function getZoomRatio(photoSession: camera.PhotoSession): number {
6004  const invalidValue: number = -1;
6005  let zoomRatio: number = invalidValue;
6006  try {
6007    zoomRatio = photoSession.getZoomRatio();
6008  } catch (error) {
6009    // 失败返回错误码error.code并处理。
6010    let err = error as BusinessError;
6011    console.error(`The getZoomRatio call failed. error code: ${err.code}`);
6012  }
6013  return zoomRatio;
6014}
6015```
6016
6017### setSmoothZoom<sup>11+</sup>
6018
6019setSmoothZoom(targetRatio: number, mode?: SmoothZoomMode): void
6020
6021触发平滑变焦。
6022
6023**系统能力:** SystemCapability.Multimedia.Camera.Core
6024
6025**参数:**
6026
6027| 参数名       | 类型            | 必填 | 说明               |
6028| ------------ | -------------- | ---- | ----------------- |
6029| targetRatio  | number         | 是   | 目标值。      |
6030| mode         | [SmoothZoomMode](#smoothzoommode11) | 否   | 模式。      |
6031
6032**示例:**
6033
6034```ts
6035import { BusinessError } from '@kit.BasicServicesKit';
6036
6037function setSmoothZoom(sessionExtendsZoom: camera.Zoom, targetZoomRatio: number, mode: camera.SmoothZoomMode): void {
6038  sessionExtendsZoom.setSmoothZoom(targetZoomRatio, mode);
6039}
6040```
6041
6042## ZoomQuery<sup>12+</sup>
6043
6044提供了与设备的缩放相关的查询功能,包括获取支持的缩放比例范围。
6045
6046### getZoomRatioRange<sup>11+</sup>
6047
6048getZoomRatioRange(): Array\<number\>
6049
6050获取支持的变焦范围。
6051
6052**系统能力:** SystemCapability.Multimedia.Camera.Core
6053
6054**返回值:**
6055
6056| 类型        | 说明                          |
6057| ---------- | ----------------------------- |
6058| Array\<number\>   | 用于获取可变焦距比范围,返回的数组包括其最小值和最大值。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode)。 |
6059
6060**错误码:**
6061
6062以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
6063
6064| 错误码ID         | 错误信息        |
6065| --------------- | --------------- |
6066| 7400103                |  Session not config, only throw in session usage.            |
6067
6068**示例:**
6069
6070```ts
6071import { BusinessError } from '@kit.BasicServicesKit';
6072
6073function getZoomRatioRange(photoSession: camera.PhotoSession): Array<number> {
6074  let zoomRatioRange: Array<number> = [];
6075  try {
6076    zoomRatioRange = photoSession.getZoomRatioRange();
6077  } catch (error) {
6078    // 失败返回错误码error.code并处理。
6079    let err = error as BusinessError;
6080    console.error(`The getZoomRatioRange call failed. error code: ${err.code}`);
6081  }
6082  return zoomRatioRange;
6083}
6084```
6085
6086## Stabilization<sup>11+</sup>
6087
6088Stabilization extends [StabilizationQuery](#stabilizationquery12)
6089
6090提供设备在录像模式下设置视频防抖的操作。
6091
6092 > **说明:**
6093 >
6094 > 需要会话中有录像流([VideoOutput](#videooutput))的前提下,才可以对视频进行防抖设置,
6095 > 其中[VideoStabilizationMode](#videostabilizationmode)中的枚举HIGH需要在[Profile](#profile)的分辨率为1920*1080的场景下生效。
6096
6097### getActiveVideoStabilizationMode<sup>11+</sup>
6098
6099getActiveVideoStabilizationMode(): VideoStabilizationMode
6100
6101查询当前正在使用的视频防抖模式。
6102
6103**系统能力:** SystemCapability.Multimedia.Camera.Core
6104
6105**返回值:**
6106
6107| 类型        | 说明          |
6108| ---------- |-------------|
6109| [VideoStabilizationMode](#videostabilizationmode)    | 视频防抖是否正在使用。 |
6110
6111**错误码:**
6112
6113以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
6114
6115| 错误码ID         | 错误信息        |
6116| --------------- | --------------- |
6117| 7400103                |  Session not config.                                   |
6118
6119**示例:**
6120
6121```ts
6122import { BusinessError } from '@kit.BasicServicesKit';
6123
6124function getActiveVideoStabilizationMode(videoSession: camera.VideoSession): camera.VideoStabilizationMode | undefined {
6125  let vsMode: camera.VideoStabilizationMode | undefined = undefined;
6126  try {
6127    vsMode = videoSession.getActiveVideoStabilizationMode();
6128  } catch (error) {
6129    // 失败返回错误码error.code并处理。
6130    let err = error as BusinessError;
6131    console.error(`The getActiveVideoStabilizationMode call failed. error code: ${err.code}`);
6132  }
6133  return vsMode;
6134}
6135```
6136
6137### setVideoStabilizationMode<sup>11+</sup>
6138
6139setVideoStabilizationMode(mode: VideoStabilizationMode): void
6140
6141设置视频防抖模式。需要先检查设备是否支持对应的防抖模式,可以通过[isVideoStabilizationModeSupported](#isvideostabilizationmodesupported11)方法判断所设置的模式是否支持。
6142
6143**系统能力:** SystemCapability.Multimedia.Camera.Core
6144
6145**参数:**
6146
6147| 参数名      | 类型                                              | 必填 | 说明                    |
6148| -------- | ------------------------------------------------- | ---- | --------------------- |
6149| mode     | [VideoStabilizationMode](#videostabilizationmode) | 是   | 需要设置的视频防抖模式。   |
6150
6151**错误码:**
6152
6153以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
6154
6155| 错误码ID         | 错误信息        |
6156| --------------- | --------------- |
6157| 7400103                |  Session not config.                                   |
6158
6159**示例:**
6160
6161```ts
6162import { BusinessError } from '@kit.BasicServicesKit';
6163
6164function setVideoStabilizationMode(videoSession: camera.VideoSession): void {
6165  try {
6166    videoSession.setVideoStabilizationMode(camera.VideoStabilizationMode.OFF);
6167  } catch (error) {
6168    // 失败返回错误码error.code并处理。
6169    let err = error as BusinessError;
6170    console.error(`The setVideoStabilizationMode call failed. error code: ${err.code}`);
6171  }
6172}
6173```
6174
6175## StabilizationQuery<sup>12+</sup>
6176
6177提供了查询设备在录像模式下是否支持对应的视频防抖模式的能力。
6178
6179### isVideoStabilizationModeSupported<sup>11+</sup>
6180
6181isVideoStabilizationModeSupported(vsMode: VideoStabilizationMode): boolean
6182
6183查询是否支持指定的视频防抖模式。
6184
6185**系统能力:** SystemCapability.Multimedia.Camera.Core
6186
6187**参数:**
6188
6189| 参数名      | 类型                                              | 必填 | 说明                             |
6190| -------- | ------------------------------------------------- | ---- | ------------------------------ |
6191| vsMode   | [VideoStabilizationMode](#videostabilizationmode) | 是   | 视频防抖模式。                    |
6192
6193**返回值:**
6194
6195| 类型        | 说明                          |
6196| ---------- | ----------------------------- |
6197| boolean    | 返回视频防抖模式是否支持,true表示支持,false表示不支持。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode)。 |
6198
6199**错误码:**
6200
6201以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
6202
6203| 错误码ID         | 错误信息        |
6204| --------------- | --------------- |
6205| 7400103                |  Session not config, only throw in session usage.             |
6206
6207**示例:**
6208
6209```ts
6210import { BusinessError } from '@kit.BasicServicesKit';
6211
6212function isVideoStabilizationModeSupported(videoSession: camera.VideoSession): boolean {
6213  let isSupported: boolean = false;
6214  try {
6215    isSupported = videoSession.isVideoStabilizationModeSupported(camera.VideoStabilizationMode.OFF);
6216  } catch (error) {
6217    // 失败返回错误码error.code并处理。
6218    let err = error as BusinessError;
6219    console.error(`The isVideoStabilizationModeSupported call failed. error code: ${err.code}`);
6220  }
6221  return isSupported;
6222}
6223```
6224
6225## CaptureSession<sup>(deprecated)</sup>
6226
6227拍照会话类,保存一次相机运行所需要的所有资源[CameraInput](#camerainput)、[CameraOutput](#cameraoutput),并向相机设备申请完成相机功能(录像,拍照)。
6228
6229> **说明:**
6230>从 API version 10开始支持,从API version 11开始废弃。建议使用[PhotoSession](#photosession11)、[VideoSession](#videosession11)替代。
6231
6232### beginConfig<sup>(deprecated)</sup>
6233
6234beginConfig(): void
6235
6236开始配置会话。
6237
6238> **说明:**
6239>从 API version 10开始支持,从API version 11开始废弃。建议使用[Session.beginConfig](#beginconfig11)替代。
6240
6241**系统能力:** SystemCapability.Multimedia.Camera.Core
6242
6243**错误码:**
6244
6245以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
6246
6247| 错误码ID         | 错误信息        |
6248| --------------- | --------------- |
6249| 7400105         |  Session config locked.               |
6250
6251**示例:**
6252
6253```ts
6254import { BusinessError } from '@kit.BasicServicesKit';
6255
6256function beginConfig(captureSession: camera.CaptureSession): void {
6257  try {
6258    captureSession.beginConfig();
6259  } catch (error) {
6260    // 失败返回错误码error.code并处理。
6261    let err = error as BusinessError;
6262    console.error(`The beginConfig call failed. error code: ${err.code}`);
6263  }
6264}
6265```
6266
6267### commitConfig<sup>(deprecated)</sup>
6268
6269commitConfig(callback: AsyncCallback\<void\>): void
6270
6271提交配置信息,通过注册回调函数获取结果。使用callback异步回调。
6272
6273> **说明:**
6274>从 API version 10开始支持,从API version 11开始废弃。建议使用[Session.commitConfig](#commitconfig11)替代。
6275
6276**系统能力:** SystemCapability.Multimedia.Camera.Core
6277
6278**参数:**
6279
6280| 参数名     | 类型                   | 必填 | 说明                  |
6281| -------- | -------------------- | ---- | -------------------- |
6282| callback | AsyncCallback\<void\> | 是   | 回调函数,用于获取结果。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) |
6283
6284**错误码:**
6285
6286以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
6287
6288| 错误码ID         | 错误信息        |
6289| --------------- | --------------- |
6290| 7400102                |  Operation not allowed.                                  |
6291| 7400201                |  Camera service fatal error.                           |
6292
6293**示例:**
6294
6295```ts
6296import { BusinessError } from '@kit.BasicServicesKit';
6297
6298function commitConfig(captureSession: camera.CaptureSession): void {
6299  captureSession.commitConfig((err: BusinessError) => {
6300    if (err) {
6301      console.error(`The commitConfig call failed. error code: ${err.code}`);
6302      return;
6303    }
6304    console.info('Callback invoked to indicate the commit config success.');
6305  });
6306}
6307```
6308
6309### commitConfig<sup>(deprecated)</sup>
6310
6311commitConfig(): Promise\<void\>
6312
6313提交配置信息,通过Promise获取结果。
6314
6315> **说明:**
6316>从 API version 10开始支持,从API version 11开始废弃。建议使用[Session.commitConfig](#commitconfig11-1)替代。
6317
6318**系统能力:** SystemCapability.Multimedia.Camera.Core
6319
6320**返回值:**
6321
6322| 类型            | 说明                |
6323| -------------- |-------------------|
6324| Promise\<void\> | 无返回结果的Promise对象。 |
6325
6326**错误码:**
6327
6328以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
6329
6330| 错误码ID         | 错误信息        |
6331| --------------- | --------------- |
6332| 7400102                |  Operation not allowed.                                  |
6333| 7400201                |  Camera service fatal error.                           |
6334
6335**示例:**
6336
6337```ts
6338import { BusinessError } from '@kit.BasicServicesKit';
6339
6340function commitConfig(captureSession: camera.CaptureSession): void {
6341  captureSession.commitConfig().then(() => {
6342    console.info('Promise returned to indicate the commit config success.');
6343  }).catch((error: BusinessError) => {
6344    // 失败返回错误码error.code并处理。
6345    console.error(`The commitConfig call failed. error code: ${error.code}`);
6346  });
6347}
6348```
6349
6350### addInput<sup>(deprecated)</sup>
6351
6352addInput(cameraInput: CameraInput): void
6353
6354把[CameraInput](#camerainput)加入到会话。
6355
6356> **说明:**
6357>从 API version 10开始支持,从API version 11开始废弃。建议使用[Session.addInput](#addinput11)替代。
6358
6359**系统能力:** SystemCapability.Multimedia.Camera.Core
6360
6361**参数:**
6362
6363| 参数名        | 类型                          | 必填 | 说明                     |
6364| ----------- | --------------------------- | ---- | ------------------------ |
6365| cameraInput | [CameraInput](#camerainput) | 是   | 需要添加的CameraInput实例。 |
6366
6367**错误码:**
6368
6369以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
6370
6371| 错误码ID   | 错误信息                                          |
6372|---------|-----------------------------------------------|
6373| 7400101 | Parameter missing or parameter type incorrect. |
6374| 7400102 | Operation not allowed.                           |
6375
6376**示例:**
6377
6378```ts
6379import { BusinessError } from '@kit.BasicServicesKit';
6380
6381function addInput(captureSession: camera.CaptureSession, cameraInput: camera.CameraInput): void {
6382  try {
6383    captureSession.addInput(cameraInput);
6384  } catch (error) {
6385    // 失败返回错误码error.code并处理。
6386    let err = error as BusinessError;
6387    console.error(`The addInput call failed. error code: ${err.code}`);
6388  }
6389}
6390```
6391
6392### removeInput<sup>(deprecated)</sup>
6393
6394removeInput(cameraInput: CameraInput): void
6395
6396移除[CameraInput](#camerainput)。
6397
6398> **说明:**
6399>从 API version 10开始支持,从API version 11开始废弃。建议使用[Session.removeInput](#removeinput11)替代。
6400
6401**系统能力:** SystemCapability.Multimedia.Camera.Core
6402
6403**参数:**
6404
6405| 参数名        | 类型                          | 必填 | 说明                      |
6406| ----------- | --------------------------- | ---- | ------------------------ |
6407| cameraInput | [CameraInput](#camerainput) | 是   | 需要移除的CameraInput实例。 |
6408
6409**错误码:**
6410
6411以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
6412
6413| 错误码ID         | 错误信息        |
6414| --------------- | --------------- |
6415| 7400101                |  Parameter missing or parameter type incorrect.        |
6416| 7400102                |  Operation not allowed.                                  |
6417
6418**示例:**
6419
6420```ts
6421import { BusinessError } from '@kit.BasicServicesKit';
6422
6423function removeInput(captureSession: camera.CaptureSession, cameraInput: camera.CameraInput): void {
6424  try {
6425    captureSession.removeInput(cameraInput);
6426  } catch (error) {
6427    // 失败返回错误码error.code并处理。
6428    let err = error as BusinessError;
6429    console.error(`The removeInput call failed. error code: ${err.code}`);
6430  }
6431}
6432```
6433
6434### addOutput<sup>(deprecated)</sup>
6435
6436addOutput(cameraOutput: CameraOutput): void
6437
6438把[CameraOutput](#cameraoutput)加入到会话。
6439
6440> **说明:**
6441>从 API version 10开始支持,从API version 11开始废弃。建议使用[Session.addOutput](#addoutput11)替代。
6442
6443**系统能力:** SystemCapability.Multimedia.Camera.Core
6444
6445**参数:**
6446
6447| 参数名           | 类型                             | 必填 | 说明                      |
6448| ------------- | ------------------------------- | ---- | ------------------------ |
6449| cameraOutput  | [CameraOutput](#cameraoutput)   | 是   | 需要添加的CameraOutput实例。 |
6450
6451**错误码:**
6452
6453以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
6454
6455| 错误码ID         | 错误信息        |
6456| --------------- | --------------- |
6457| 7400101                |  Parameter missing or parameter type incorrect.        |
6458| 7400102                |  Operation not allowed.                                  |
6459
6460**示例:**
6461
6462```ts
6463import { BusinessError } from '@kit.BasicServicesKit';
6464
6465function addOutput(captureSession: camera.CaptureSession, cameraOutput: camera.CameraOutput): void {
6466  try {
6467    captureSession.addOutput(cameraOutput);
6468  } catch (error) {
6469    // 失败返回错误码error.code并处理。
6470    let err = error as BusinessError;
6471    console.error(`The addOutput call failed. error code: ${err.code}`);
6472  }
6473}
6474```
6475
6476### removeOutput<sup>(deprecated)</sup>
6477
6478removeOutput(cameraOutput: CameraOutput): void
6479
6480从会话中移除[CameraOutput](#cameraoutput)。
6481
6482> **说明:**
6483>从 API version 10开始支持,从API version 11开始废弃。建议使用[Session.removeOutput](#removeoutput11)替代。
6484
6485**系统能力:** SystemCapability.Multimedia.Camera.Core
6486
6487**参数:**
6488
6489| 参数名           | 类型                             | 必填 | 说明                      |
6490| ------------- | ------------------------------- | ---- | ------------------------ |
6491| cameraOutput  | [CameraOutput](#cameraoutput)   | 是   | 需要移除的CameraOutput实例。 |
6492
6493**错误码:**
6494
6495以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
6496
6497| 错误码ID         | 错误信息        |
6498| --------------- | --------------- |
6499| 7400101                |  Parameter missing or parameter type incorrect.        |
6500| 7400102                |  Operation not allowed.                                  |
6501
6502**示例:**
6503
6504```ts
6505import { BusinessError } from '@kit.BasicServicesKit';
6506
6507function removeOutput(captureSession: camera.CaptureSession, previewOutput: camera.PreviewOutput): void {
6508  try {
6509    captureSession.removeOutput(previewOutput);
6510  } catch (error) {
6511    // 失败返回错误码error.code并处理。
6512    let err = error as BusinessError;
6513    console.error(`The removeOutput call failed. error code: ${err.code}`);
6514  }
6515}
6516```
6517
6518### start<sup>(deprecated)</sup>
6519
6520start(callback: AsyncCallback\<void\>): void
6521
6522开始会话工作,通过注册回调函数获取结果。使用callback异步回调。
6523
6524> **说明:**
6525>从 API version 10开始支持,从API version 11开始废弃。建议使用[Session.start](#start11)替代。
6526
6527**系统能力:** SystemCapability.Multimedia.Camera.Core
6528
6529**参数:**
6530
6531| 参数名      | 类型                  | 必填 | 说明                 |
6532| -------- | -------------------- | ---- | -------------------- |
6533| callback | AsyncCallback\<void\> | 是   | 回调函数,用于获取结果。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode)。 |
6534
6535**错误码:**
6536
6537以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
6538
6539| 错误码ID         | 错误信息        |
6540| --------------- | --------------- |
6541| 7400103                |  Session not config.                                   |
6542| 7400201                |  Camera service fatal error.                           |
6543
6544**示例:**
6545
6546```ts
6547import { BusinessError } from '@kit.BasicServicesKit';
6548
6549function startCaptureSession(captureSession: camera.CaptureSession): void {
6550  captureSession.start((err: BusinessError) => {
6551    if (err) {
6552      console.error(`Failed to start the session, error code: ${err.code}.`);
6553      return;
6554    }
6555    console.info('Callback invoked to indicate the session start success.');
6556  });
6557}
6558```
6559
6560### start<sup>(deprecated)</sup>
6561
6562start(): Promise\<void\>
6563
6564开始会话工作,通过Promise获取结果。
6565
6566> **说明:**
6567>从 API version 10开始支持,从API version 11开始废弃。建议使用[Session.start](#start11-1)替代。
6568
6569**系统能力:** SystemCapability.Multimedia.Camera.Core
6570
6571**返回值:**
6572
6573| 类型            | 说明                     |
6574| -------------- | ------------------------ |
6575| Promise\<void\> | 无返回结果的Promise对象。 |
6576
6577**错误码:**
6578
6579以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
6580
6581| 错误码ID         | 错误信息        |
6582| --------------- | --------------- |
6583| 7400103                |  Session not config.                                   |
6584| 7400201                |  Camera service fatal error.                           |
6585
6586**示例:**
6587
6588```ts
6589import { BusinessError } from '@kit.BasicServicesKit';
6590
6591function startCaptureSession(captureSession: camera.CaptureSession): void {
6592  captureSession.start().then(() => {
6593    console.info('Promise returned to indicate the session start success.');
6594  }).catch((err: BusinessError) => {
6595    console.error(`Failed to start the session, error code: ${err.code}.`);
6596  });
6597}
6598```
6599
6600### stop<sup>(deprecated)</sup>
6601
6602stop(callback: AsyncCallback\<void\>): void
6603
6604停止会话工作,通过注册回调函数获取结果。使用callback异步回调。
6605
6606> **说明:**
6607>从 API version 10开始支持,从API version 11开始废弃。建议使用[Session.stop](#stop11)替代。
6608
6609**系统能力:** SystemCapability.Multimedia.Camera.Core
6610
6611**参数:**
6612
6613| 参数名      | 类型                  | 必填 | 说明                 |
6614| -------- | -------------------- | ---- | ------------------- |
6615| callback | AsyncCallback\<void\> | 是   | 回调函数,用于获取结果。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode)。 |
6616
6617**错误码:**
6618
6619以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
6620
6621| 错误码ID         | 错误信息        |
6622| --------------- | --------------- |
6623| 7400201                |  Camera service fatal error.                           |
6624
6625**示例:**
6626
6627```ts
6628import { BusinessError } from '@kit.BasicServicesKit';
6629
6630function stopCaptureSession(captureSession: camera.CaptureSession): void {
6631  captureSession.stop((err: BusinessError) => {
6632    if (err) {
6633      console.error(`Failed to stop the session, error code: ${err.code}.`);
6634      return;
6635    }
6636    console.info('Callback invoked to indicate the session stop success.');
6637  });
6638}
6639```
6640
6641### stop<sup>(deprecated)</sup>
6642
6643stop(): Promise\<void\>
6644
6645停止会话工作,通过Promise获取结果。
6646
6647> **说明:**
6648>从 API version 10开始支持,从API version 11开始废弃。建议使用[Session.stop](#stop11-1)替代。
6649
6650**系统能力:** SystemCapability.Multimedia.Camera.Core
6651
6652**返回值:**
6653
6654| 类型            | 说明                     |
6655| -------------- | ----------------------- |
6656| Promise\<void\> | 无返回结果的Promise对象。。 |
6657
6658**错误码:**
6659
6660以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
6661
6662| 错误码ID         | 错误信息        |
6663| --------------- | --------------- |
6664| 7400201                |  Camera service fatal error.                           |
6665
6666**示例:**
6667
6668```ts
6669import { BusinessError } from '@kit.BasicServicesKit';
6670
6671function stopCaptureSession(captureSession: camera.CaptureSession): void {
6672  captureSession.stop().then(() => {
6673    console.info('Promise returned to indicate the session stop success.');
6674  }).catch((err: BusinessError) => {
6675    console.error(`Failed to stop the session, error code: ${err.code}.`);
6676  });
6677}
6678```
6679
6680### release<sup>(deprecated)</sup>
6681
6682release(callback: AsyncCallback\<void\>): void
6683
6684释放会话资源,通过注册回调函数获取结果。使用callback异步回调。
6685
6686> **说明:**
6687>从 API version 10开始支持,从API version 11开始废弃。建议使用[Session.release](#release11-1)替代。
6688
6689**系统能力:** SystemCapability.Multimedia.Camera.Core
6690
6691**参数:**
6692
6693| 参数名      | 类型                  | 必填 | 说明                 |
6694| -------- | -------------------- | ---- | -------------------- |
6695| callback | AsyncCallback\<void\> | 是   | 回调函数,用于获取结果。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode)。 |
6696
6697**错误码:**
6698
6699以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
6700
6701| 错误码ID         | 错误信息        |
6702| --------------- | --------------- |
6703| 7400201                |  Camera service fatal error.                           |
6704
6705**示例:**
6706
6707```ts
6708import { BusinessError } from '@kit.BasicServicesKit';
6709
6710function releaseCaptureSession(captureSession: camera.CaptureSession): void {
6711  captureSession.release((err: BusinessError) => {
6712    if (err) {
6713      console.error(`Failed to release the CaptureSession instance, error code: ${err.code}.`);
6714      return;
6715    }
6716    console.info('Callback invoked to indicate that the CaptureSession instance is released successfully.');
6717  });
6718}
6719```
6720
6721### release<sup>(deprecated)</sup>
6722
6723release(): Promise\<void\>
6724
6725释放会话资源,通过Promise获取结果。
6726
6727> **说明:**
6728>从 API version 10开始支持,从API version 11开始废弃。建议使用[Session.release](#release11-2)替代。
6729
6730**系统能力:** SystemCapability.Multimedia.Camera.Core
6731
6732**返回值:**
6733
6734| 类型            | 说明                     |
6735| -------------- | ------------------------ |
6736| Promise\<void\> | 无返回结果的Promise对象。 |
6737
6738**错误码:**
6739
6740以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
6741
6742| 错误码ID         | 错误信息        |
6743| --------------- | --------------- |
6744| 7400201                |  Camera service fatal error.                           |
6745
6746**示例:**
6747
6748```ts
6749import { BusinessError } from '@kit.BasicServicesKit';
6750
6751function releaseCaptureSession(captureSession: camera.CaptureSession): void {
6752  captureSession.release().then(() => {
6753    console.info('Promise returned to indicate that the CaptureSession instance is released successfully.');
6754  }).catch((err: BusinessError) => {
6755    console.error(`Failed to release the CaptureSession instance, error code: ${err.code}.`);
6756  });
6757}
6758```
6759
6760### hasFlash<sup>(deprecated)</sup>
6761
6762hasFlash(): boolean
6763
6764检测是否有闪光灯。
6765
6766> **说明:**
6767>从 API version 10开始支持,从API version 11开始废弃。建议使用[Flash.hasFlash](#hasflash11)替代。
6768
6769**系统能力:** SystemCapability.Multimedia.Camera.Core
6770
6771**返回值:**
6772
6773| 类型        | 说明                          |
6774| ---------- | ----------------------------- |
6775| boolean    | 返回true表示设备支持闪光灯,false表示不支持。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode)。 |
6776
6777**错误码:**
6778
6779以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
6780
6781| 错误码ID         | 错误信息        |
6782| --------------- | --------------- |
6783| 7400103                |  Session not config.                                   |
6784
6785**示例:**
6786
6787```ts
6788import { BusinessError } from '@kit.BasicServicesKit';
6789
6790function hasFlash(captureSession: camera.CaptureSession): boolean {
6791  let status: boolean = false;
6792  try {
6793    status = captureSession.hasFlash();
6794  } catch (error) {
6795    // 失败返回错误码error.code并处理。
6796    let err = error as BusinessError;
6797    console.error(`The hasFlash call failed. error code: ${err.code}`);
6798  }
6799  return status;
6800}
6801```
6802
6803### isFlashModeSupported<sup>(deprecated)</sup>
6804
6805isFlashModeSupported(flashMode: FlashMode): boolean
6806
6807检测闪光灯模式是否支持。
6808
6809> **说明:**
6810>从 API version 10开始支持,从API version 11开始废弃。建议使用[Flash.isFlashModeSupported](#isflashmodesupported11)替代。
6811
6812**系统能力:** SystemCapability.Multimedia.Camera.Core
6813
6814**参数:**
6815
6816| 参数名       | 类型                     | 必填 | 说明                               |
6817| --------- | ----------------------- | ---- | --------------------------------- |
6818| flashMode | [FlashMode](#flashmode) | 是   | 指定闪光灯模式。                     |
6819
6820**返回值:**
6821
6822| 类型        | 说明                          |
6823| ---------- | ----------------------------- |
6824| boolean    | 返回true表示支持该闪光灯模式,false表示不支持。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode)。 |
6825
6826**错误码:**
6827
6828以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
6829
6830| 错误码ID         | 错误信息        |
6831| --------------- | --------------- |
6832| 7400103                |  Session not config.                                   |
6833
6834**示例:**
6835
6836```ts
6837import { BusinessError } from '@kit.BasicServicesKit';
6838
6839function isFlashModeSupported(captureSession: camera.CaptureSession): boolean {
6840  let status: boolean = false;
6841  try {
6842    status = captureSession.isFlashModeSupported(camera.FlashMode.FLASH_MODE_AUTO);
6843  } catch (error) {
6844    // 失败返回错误码error.code并处理。
6845    let err = error as BusinessError;
6846    console.error(`The isFlashModeSupported call failed. error code: ${err.code}`);
6847  }
6848  return status;
6849}
6850```
6851
6852### setFlashMode<sup>(deprecated)</sup>
6853
6854setFlashMode(flashMode: FlashMode): void
6855
6856设置闪光灯模式。
6857
6858进行设置之前,需要先检查:
6859
68601. 设备是否支持闪光灯,可使用方法[hasFlash](#hasflashdeprecated)。
68612. 设备是否支持指定的闪光灯模式,可使用方法[isFlashModeSupported](#isflashmodesupporteddeprecated)。
6862
6863> **说明:**
6864>从 API version 10开始支持,从API version 11开始废弃。建议使用[Flash.setFlashMode](#setflashmode11)替代。
6865
6866**系统能力:** SystemCapability.Multimedia.Camera.Core
6867
6868**参数:**
6869
6870| 参数名     | 类型                    | 必填 | 说明                 |
6871| --------- | ----------------------- | ---- | -------------------- |
6872| flashMode | [FlashMode](#flashmode) | 是   | 指定闪光灯模式。       |
6873
6874**错误码:**
6875
6876以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
6877
6878| 错误码ID         | 错误信息        |
6879| --------------- | --------------- |
6880| 7400103                |  Session not config.                                   |
6881
6882**示例:**
6883
6884```ts
6885import { BusinessError } from '@kit.BasicServicesKit';
6886
6887function setFlashMode(captureSession: camera.CaptureSession): void {
6888  try {
6889    captureSession.setFlashMode(camera.FlashMode.FLASH_MODE_AUTO);
6890  } catch (error) {
6891    // 失败返回错误码error.code并处理。
6892    let err = error as BusinessError;
6893    console.error(`The setFlashMode call failed. error code: ${err.code}`);
6894  }
6895}
6896```
6897
6898### getFlashMode<sup>(deprecated)</sup>
6899
6900getFlashMode(): FlashMode
6901
6902获取当前设备的闪光灯模式。
6903
6904> **说明:**
6905>从 API version 10开始支持,从API version 11开始废弃。建议使用[Flash.getFlashMode](#getflashmode11)替代。
6906
6907**系统能力:** SystemCapability.Multimedia.Camera.Core
6908
6909**返回值:**
6910
6911| 类型        | 说明                          |
6912| ---------- | ----------------------------- |
6913| [FlashMode](#flashmode)    | 获取当前设备的闪光灯模式。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode)。 |
6914
6915**错误码:**
6916
6917以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
6918
6919| 错误码ID         | 错误信息        |
6920| --------------- | --------------- |
6921| 7400103                |  Session not config.                                   |
6922
6923**示例:**
6924
6925```ts
6926import { BusinessError } from '@kit.BasicServicesKit';
6927
6928function getFlashMode(captureSession: camera.CaptureSession): camera.FlashMode | undefined {
6929  let flashMode: camera.FlashMode | undefined = undefined;
6930  try {
6931    flashMode = captureSession.getFlashMode();
6932  } catch (error) {
6933    // 失败返回错误码error.code并处理。
6934    let err = error as BusinessError;
6935    console.error(`The getFlashMode call failed.error code: ${err.code}`);
6936  }
6937  return flashMode;
6938}
6939```
6940
6941### isExposureModeSupported<sup>(deprecated)</sup>
6942
6943isExposureModeSupported(aeMode: ExposureMode): boolean
6944
6945查询曝光模式是否支持。
6946
6947> **说明:**
6948>从 API version 10开始支持,从API version 11开始废弃。建议使用[AutoExposure.isExposureModeSupported](#isexposuremodesupported11)替代。
6949
6950**系统能力:** SystemCapability.Multimedia.Camera.Core
6951
6952**参数:**
6953
6954| 参数名      | 类型                           | 必填  | 说明                           |
6955| -------- | -------------------------------| ---- | ----------------------------- |
6956| aeMode   | [ExposureMode](#exposuremode)  | 是   | 曝光模式。                      |
6957
6958**返回值:**
6959
6960| 类型        | 说明                          |
6961| ---------- | ----------------------------- |
6962| boolean    | 获取是否支持曝光模式。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode)。 |
6963
6964**错误码:**
6965
6966以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
6967
6968| 错误码ID         | 错误信息        |
6969| --------------- | --------------- |
6970| 7400103                |  Session not config.                                   |
6971
6972**示例:**
6973
6974```ts
6975import { BusinessError } from '@kit.BasicServicesKit';
6976
6977function isExposureModeSupported(captureSession: camera.CaptureSession): boolean {
6978  let isSupported: boolean = false;
6979  try {
6980    isSupported = captureSession.isExposureModeSupported(camera.ExposureMode.EXPOSURE_MODE_LOCKED);
6981  } catch (error) {
6982    // 失败返回错误码error.code并处理。
6983    let err = error as BusinessError;
6984    console.error(`The isExposureModeSupported call failed. error code: ${err.code}`);
6985  }
6986  return isSupported;
6987}
6988```
6989
6990### getExposureMode<sup>(deprecated)</sup>
6991
6992getExposureMode(): ExposureMode
6993
6994获取当前曝光模式。
6995
6996> **说明:**
6997>从 API version 10开始支持,从API version 11开始废弃。建议使用[AutoExposure.getExposureMode](#getexposuremode11)替代。
6998
6999**系统能力:** SystemCapability.Multimedia.Camera.Core
7000
7001**返回值:**
7002
7003| 类型        | 说明                          |
7004| ---------- | ----------------------------- |
7005| [ExposureMode](#exposuremode)    | 获取当前曝光模式。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode)。 |
7006
7007**错误码:**
7008
7009以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
7010
7011| 错误码ID         | 错误信息        |
7012| --------------- | --------------- |
7013| 7400103                |  Session not config.                                   |
7014
7015**示例:**
7016
7017```ts
7018import { BusinessError } from '@kit.BasicServicesKit';
7019
7020function getExposureMode(captureSession: camera.CaptureSession): camera.ExposureMode | undefined {
7021  let exposureMode: camera.ExposureMode | undefined = undefined;
7022  try {
7023    exposureMode = captureSession.getExposureMode();
7024  } catch (error) {
7025    // 失败返回错误码error.code并处理。
7026    let err = error as BusinessError;
7027    console.error(`The getExposureMode call failed. error code: ${err.code}`);
7028  }
7029  return exposureMode;
7030}
7031```
7032
7033### setExposureMode<sup>(deprecated)</sup>
7034
7035setExposureMode(aeMode: ExposureMode): void
7036
7037设置曝光模式。进行设置之前,需要先检查设备是否支持指定的曝光模式,可使用方法[isExposureModeSupported](#isexposuremodesupporteddeprecated)。
7038
7039> **说明:**
7040>从 API version 10开始支持,从API version 11开始废弃。建议使用[AutoExposure.setExposureMode](#setexposuremode11)替代。
7041
7042**系统能力:** SystemCapability.Multimedia.Camera.Core
7043
7044**参数:**
7045
7046| 参数名      | 类型                            | 必填 | 说明                    |
7047| -------- | -------------------------------| ---- | ----------------------- |
7048| aeMode   | [ExposureMode](#exposuremode)  | 是   | 曝光模式。                |
7049
7050**错误码:**
7051
7052以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
7053
7054| 错误码ID         | 错误信息        |
7055| --------------- | --------------- |
7056| 7400103                |  Session not config.                                   |
7057
7058**示例:**
7059
7060```ts
7061import { BusinessError } from '@kit.BasicServicesKit';
7062
7063function setExposureMode(captureSession: camera.CaptureSession): void {
7064  try {
7065    captureSession.setExposureMode(camera.ExposureMode.EXPOSURE_MODE_LOCKED);
7066  } catch (error) {
7067    // 失败返回错误码error.code并处理。
7068    let err = error as BusinessError;
7069    console.error(`The setExposureMode call failed. error code: ${err.code}`);
7070  }
7071}
7072```
7073
7074### getMeteringPoint<sup>(deprecated)</sup>
7075
7076getMeteringPoint(): Point
7077
7078查询曝光区域中心点。
7079
7080> **说明:**
7081>从 API version 10开始支持,从API version 11开始废弃。建议使用[AutoExposure.getMeteringPoint](#getmeteringpoint11)替代。
7082
7083**系统能力:** SystemCapability.Multimedia.Camera.Core
7084
7085**返回值:**
7086
7087| 类型        | 说明                          |
7088| ---------- | ----------------------------- |
7089| [Point](#point)    | 获取当前曝光点。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode)。 |
7090
7091**错误码:**
7092
7093以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
7094
7095| 错误码ID         | 错误信息        |
7096| --------------- | --------------- |
7097| 7400103                |  Session not config.                                   |
7098
7099**示例:**
7100
7101```ts
7102import { BusinessError } from '@kit.BasicServicesKit';
7103
7104function getMeteringPoint(captureSession: camera.CaptureSession): camera.Point | undefined {
7105  let exposurePoint: camera.Point | undefined = undefined;
7106  try {
7107    exposurePoint = captureSession.getMeteringPoint();
7108  } catch (error) {
7109    // 失败返回错误码error.code并处理。
7110    let err = error as BusinessError;
7111    console.error(`The getMeteringPoint call failed. error code: ${err.code}`);
7112  }
7113  return exposurePoint;
7114}
7115```
7116
7117### setMeteringPoint<sup>(deprecated)</sup>
7118
7119setMeteringPoint(point: Point): void
7120
7121设置曝光区域中心点,曝光点应在0-1坐标系内,该坐标系左上角为{0,0},右下角为{1,1}。
7122此坐标系是以设备充电口在右侧时的横向设备方向为基准的,例如应用的预览界面布局以
7123设备充电口在下侧时的竖向方向为基准,布局宽高为{w,h},且触碰点为{x,y},
7124则转换后的坐标点为{y/h,1-x/w}。
7125
7126> **说明:**
7127>从 API version 10开始支持,从API version 11开始废弃。建议使用[AutoExposure.setMeteringPoint](#setmeteringpoint11)替代。
7128
7129**系统能力:** SystemCapability.Multimedia.Camera.Core
7130
7131**参数:**
7132
7133| 参数名           | 类型                            | 必填 | 说明                 |
7134| ------------- | -------------------------------| ---- | ------------------- |
7135| point | [Point](#point)                | 是   | 曝光点,x,y设置范围应在[0,1]之内,超过范围,如果小于0设置0,大于1设置1。             |
7136
7137**错误码:**
7138
7139以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
7140
7141| 错误码ID         | 错误信息        |
7142| --------------- | --------------- |
7143| 7400103                |  Session not config.                                   |
7144
7145**示例:**
7146
7147```ts
7148import { BusinessError } from '@kit.BasicServicesKit';
7149
7150function setMeteringPoint(captureSession: camera.CaptureSession): void {
7151  const point: camera.Point = {x: 1, y: 1};
7152  try {
7153    captureSession.setMeteringPoint(point);
7154  } catch (error) {
7155    // 失败返回错误码error.code并处理。
7156    let err = error as BusinessError;
7157    console.error(`The setMeteringPoint call failed. error code: ${err.code}`);
7158  }
7159}
7160```
7161
7162### getExposureBiasRange<sup>(deprecated)</sup>
7163
7164getExposureBiasRange(): Array\<number\>
7165
7166查询曝光补偿范围。
7167
7168> **说明:**
7169>从 API version 10开始支持,从API version 11开始废弃。建议使用[AutoExposure.getExposureBiasRange](#getexposurebiasrange11)替代。
7170
7171**系统能力:** SystemCapability.Multimedia.Camera.Core
7172
7173**返回值:**
7174
7175| 类型        | 说明                          |
7176| ---------- | ----------------------------- |
7177| Array\<number\>   | 获取补偿范围的数组。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode)。 |
7178
7179**错误码:**
7180
7181以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
7182
7183| 错误码ID         | 错误信息        |
7184| --------------- | --------------- |
7185| 7400103                |  Session not config.                                   |
7186
7187**示例:**
7188
7189```ts
7190import { BusinessError } from '@kit.BasicServicesKit';
7191
7192function getExposureBiasRange(captureSession: camera.CaptureSession): Array<number> {
7193  let biasRangeArray: Array<number> = [];
7194  try {
7195    biasRangeArray = captureSession.getExposureBiasRange();
7196  } catch (error) {
7197    // 失败返回错误码error.code并处理。
7198    let err = error as BusinessError;
7199    console.error(`The getExposureBiasRange call failed. error code: ${err.code}`);
7200  }
7201  return biasRangeArray;
7202}
7203```
7204
7205### setExposureBias<sup>(deprecated)</sup>
7206
7207setExposureBias(exposureBias: number): void
7208
7209设置曝光补偿,曝光补偿值(EV)。
7210
7211进行设置之前,建议先通过方法[getExposureBiasRange](#getexposurebiasrangedeprecated)查询支持的范围。
7212
7213> **说明:**
7214>从 API version 10开始支持,从API version 11开始废弃。建议使用[AutoExposure.setExposureBias](#setexposurebias11)替代。
7215
7216**系统能力:** SystemCapability.Multimedia.Camera.Core
7217
7218**参数:**
7219
7220| 参数名     | 类型                            | 必填  | 说明                                                                                                                                                                                    |
7221| -------- | -------------------------------|-----|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
7222| exposureBias   | number                   | 是  | 曝光补偿,[getExposureBiasRange](#getexposurebiasrange11)查询支持的范围,如果设置超过支持范围的值,自动匹配到就近临界点。曝光补偿存在步长,如步长为0.5。则设置1.2时,获取到实际生效曝光补偿为1.0。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode)。传参为null或者undefined,作为0处理,曝光补偿设置0。 |
7223
7224**错误码:**
7225
7226以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
7227
7228| 错误码ID         | 错误信息        |
7229| --------------- | --------------- |
7230| 7400103                |  Session not config.                                   |
7231
7232**示例:**
7233
7234```ts
7235import { BusinessError } from '@kit.BasicServicesKit';
7236
7237function setExposureBias(captureSession: camera.CaptureSession, biasRangeArray: Array<number>): void {
7238  if (biasRangeArray && biasRangeArray.length > 0) {
7239    let exposureBias = biasRangeArray[0];
7240    try {
7241      captureSession.setExposureBias(exposureBias);
7242    } catch (error) {
7243      // 失败返回错误码error.code并处理。
7244      let err = error as BusinessError;
7245      console.error(`The setExposureBias call failed. error code: ${err.code}`);
7246    }
7247  }
7248}
7249```
7250
7251### getExposureValue<sup>(deprecated)</sup>
7252
7253getExposureValue(): number
7254
7255查询当前曝光值。
7256
7257> **说明:**
7258>从 API version 10开始支持,从API version 11开始废弃。建议使用[AutoExposure.getExposureValue](#getexposurevalue11)替代。
7259
7260**系统能力:** SystemCapability.Multimedia.Camera.Core
7261
7262**返回值:**
7263
7264| 类型        | 说明                          |
7265| ---------- | ----------------------------- |
7266| number    | 获取曝光值。曝光补偿存在步长,如步长为0.5。则设置1.2时,获取到实际生效曝光补偿为1.0。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode)。 |
7267
7268**错误码:**
7269
7270以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
7271
7272| 错误码ID         | 错误信息        |
7273| --------------- | --------------- |
7274| 7400103                |  Session not config.                                   |
7275
7276**示例:**
7277
7278```ts
7279import { BusinessError } from '@kit.BasicServicesKit';
7280
7281function getExposureValue(captureSession: camera.CaptureSession): number {
7282  const invalidValue: number = -1;
7283  let exposureValue: number = invalidValue;
7284  try {
7285    exposureValue = captureSession.getExposureValue();
7286  } catch (error) {
7287    // 失败返回错误码error.code并处理。
7288    let err = error as BusinessError;
7289    console.error(`The getExposureValue call failed. error code: ${err.code}`);
7290  }
7291  return exposureValue;
7292}
7293```
7294
7295### isFocusModeSupported<sup>(deprecated)</sup>
7296
7297isFocusModeSupported(afMode: FocusMode): boolean
7298
7299检测对焦模式是否支持。
7300
7301> **说明:**
7302>从 API version 10开始支持,从API version 11开始废弃。建议使用[Focus.isFocusModeSupported](#isfocusmodesupported11)替代。
7303
7304**系统能力:** SystemCapability.Multimedia.Camera.Core
7305
7306**参数:**
7307
7308| 参数名      | 类型                     | 必填 | 说明                              |
7309| -------- | ----------------------- | ---- | -------------------------------- |
7310| afMode   | [FocusMode](#focusmode) | 是   | 指定的焦距模式。                    |
7311
7312**返回值:**
7313
7314| 类型        | 说明                          |
7315| ---------- | ----------------------------- |
7316| boolean    | 返回true表示支持该焦距模式,false表示不支持。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode)。 |
7317
7318**错误码:**
7319
7320以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
7321
7322| 错误码ID         | 错误信息        |
7323| --------------- | --------------- |
7324| 7400103                |  Session not config.                                   |
7325
7326**示例:**
7327
7328```ts
7329import { BusinessError } from '@kit.BasicServicesKit';
7330
7331function isFocusModeSupported(captureSession: camera.CaptureSession): boolean {
7332  let status: boolean = false;
7333  try {
7334    status = captureSession.isFocusModeSupported(camera.FocusMode.FOCUS_MODE_AUTO);
7335  } catch (error) {
7336    // 失败返回错误码error.code并处理。
7337    let err = error as BusinessError;
7338    console.error(`The isFocusModeSupported call failed. error code: ${err.code}`);
7339  }
7340  return status;
7341}
7342```
7343
7344### setFocusMode<sup>(deprecated)</sup>
7345
7346setFocusMode(afMode: FocusMode): void
7347
7348设置对焦模式。
7349
7350进行设置之前,需要先检查设备是否支持指定的焦距模式,可使用方法[isFocusModeSupported](#isfocusmodesupporteddeprecated)。
7351
7352> **说明:**
7353>从 API version 10开始支持,从API version 11开始废弃。建议使用[Focus.setFocusMode](#setfocusmode11)替代。
7354
7355**系统能力:** SystemCapability.Multimedia.Camera.Core
7356
7357**参数:**
7358
7359| 参数名      | 类型                     | 必填 | 说明                 |
7360| -------- | ----------------------- | ---- | ------------------- |
7361| afMode   | [FocusMode](#focusmode) | 是   | 指定的焦距模式。       |
7362
7363**错误码:**
7364
7365以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
7366
7367| 错误码ID         | 错误信息        |
7368| --------------- | --------------- |
7369| 7400103                |  Session not config.                                   |
7370
7371**示例:**
7372
7373```ts
7374import { BusinessError } from '@kit.BasicServicesKit';
7375
7376function setFocusMode(captureSession: camera.CaptureSession): void {
7377  try {
7378    captureSession.setFocusMode(camera.FocusMode.FOCUS_MODE_AUTO);
7379  } catch (error) {
7380    // 失败返回错误码error.code并处理。
7381    let err = error as BusinessError;
7382    console.error(`The setFocusMode call failed. error code: ${err.code}`);
7383  }
7384}
7385```
7386
7387### getFocusMode<sup>(deprecated)</sup>
7388
7389getFocusMode(): FocusMode
7390
7391获取当前的对焦模式。
7392
7393> **说明:**
7394>从 API version 10开始支持,从API version 11开始废弃。建议使用[Focus.getFocusMode](#getfocusmode11)替代。
7395
7396**系统能力:** SystemCapability.Multimedia.Camera.Core
7397
7398**返回值:**
7399
7400| 类型        | 说明                          |
7401| ---------- | ----------------------------- |
7402| [FocusMode](#focusmode)   | 获取当前设备的焦距模式。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode)。 |
7403
7404**错误码:**
7405
7406以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
7407
7408| 错误码ID         | 错误信息        |
7409| --------------- | --------------- |
7410| 7400103                |  Session not config.                                   |
7411
7412**示例:**
7413
7414```ts
7415import { BusinessError } from '@kit.BasicServicesKit';
7416
7417function getFocusMode(captureSession: camera.CaptureSession): camera.FocusMode | undefined {
7418  let afMode: camera.FocusMode | undefined = undefined;
7419  try {
7420    afMode = captureSession.getFocusMode();
7421  } catch (error) {
7422    // 失败返回错误码error.code并处理。
7423    let err = error as BusinessError;
7424    console.error(`The getFocusMode call failed. error code: ${err.code}`);
7425  }
7426  return afMode;
7427}
7428```
7429
7430### setFocusPoint<sup>(deprecated)</sup>
7431
7432setFocusPoint(point: Point): void
7433
7434设置焦点,焦点应在0-1坐标系内,该坐标系左上角为{0,0},右下角为{1,1}。
7435此坐标系是以设备充电口在右侧时的横向设备方向为基准的,例如应用的预览界面布局以
7436设备充电口在下侧时的竖向方向为基准,布局宽高为{w,h},且触碰点为{x,y},
7437则转换后的坐标点为{y/h,1-x/w}。
7438
7439> **说明:**
7440>从 API version 10开始支持,从API version 11开始废弃。建议使用[Focus.setFocusPoint](#setfocuspoint11)替代。
7441
7442**系统能力:** SystemCapability.Multimedia.Camera.Core
7443
7444**参数:**
7445
7446| 参数名   | 类型                     | 必填  | 说明                 |
7447|-------| ----------------------- |-----| ------------------- |
7448| point | [Point](#point)         | 是  | 焦点。x,y设置范围应在[0,1]之内,超过范围,如果小于0设置0,大于1设置1。   |
7449
7450**错误码:**
7451
7452以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
7453
7454| 错误码ID         | 错误信息        |
7455| --------------- | --------------- |
7456| 7400103                |  Session not config.                                   |
7457
7458**示例:**
7459
7460```ts
7461import { BusinessError } from '@kit.BasicServicesKit';
7462
7463function setFocusPoint(captureSession: camera.CaptureSession): void {
7464  const focusPoint: camera.Point = {x: 1, y: 1};
7465  try {
7466    captureSession.setFocusPoint(focusPoint);
7467  } catch (error) {
7468    // 失败返回错误码error.code并处理。
7469    let err = error as BusinessError;
7470    console.error(`The setFocusPoint call failed. error code: ${err.code}`);
7471  }
7472}
7473```
7474
7475### getFocusPoint<sup>(deprecated)</sup>
7476
7477getFocusPoint(): Point
7478
7479查询焦点。
7480
7481> **说明:**
7482>从 API version 10开始支持,从API version 11开始废弃。建议使用[Focus.getFocusPoint](#getfocuspoint11)替代。
7483
7484**系统能力:** SystemCapability.Multimedia.Camera.Core
7485
7486**返回值:**
7487
7488| 类型        | 说明                          |
7489| ---------- | ----------------------------- |
7490| [Point](#point)    | 用于获取当前焦点。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode)。 |
7491
7492**错误码:**
7493
7494以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
7495
7496| 错误码ID         | 错误信息        |
7497| --------------- | --------------- |
7498| 7400103                |  Session not config.                                   |
7499
7500**示例:**
7501
7502```ts
7503import { BusinessError } from '@kit.BasicServicesKit';
7504
7505function getFocusPoint(captureSession: camera.CaptureSession): camera.Point | undefined {
7506  let point: camera.Point | undefined = undefined;
7507  try {
7508    point = captureSession.getFocusPoint();
7509  } catch (error) {
7510    // 失败返回错误码error.code并处理。
7511    let err = error as BusinessError;
7512    console.error(`The getFocusPoint call failed. error code: ${err.code}`);
7513  }
7514  return point;
7515}
7516```
7517
7518### getFocalLength<sup>(deprecated)</sup>
7519
7520getFocalLength(): number
7521
7522查询焦距值。
7523
7524> **说明:**
7525>从 API version 10开始支持,从API version 11开始废弃。建议使用[Focus.getFocalLength](#getfocallength11)替代。
7526
7527**系统能力:** SystemCapability.Multimedia.Camera.Core
7528
7529**返回值:**
7530
7531| 类型        | 说明                          |
7532| ---------- | ----------------------------- |
7533| number    | 用于获取当前焦距。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode)。 |
7534
7535**错误码:**
7536
7537以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
7538
7539| 错误码ID         | 错误信息        |
7540| --------------- | --------------- |
7541| 7400103                |  Session not config.                                   |
7542
7543**示例:**
7544
7545```ts
7546import { BusinessError } from '@kit.BasicServicesKit';
7547
7548function getFocalLength(captureSession: camera.CaptureSession): number {
7549  const invalidValue: number = -1;
7550  let focalLength: number = invalidValue;
7551  try {
7552    focalLength = captureSession.getFocalLength();
7553  } catch (error) {
7554    // 失败返回错误码error.code并处理。
7555    let err = error as BusinessError;
7556    console.error(`The getFocalLength call failed. error code: ${err.code}`);
7557  }
7558  return focalLength;
7559}
7560```
7561
7562### getZoomRatioRange<sup>(deprecated)</sup>
7563
7564getZoomRatioRange(): Array\<number\>
7565
7566获取支持的变焦范围。
7567
7568> **说明:**
7569>从 API version 10开始支持,从API version 11开始废弃。建议使用[Zoom.getZoomRatioRange](#getzoomratiorange11)替代。
7570
7571**系统能力:** SystemCapability.Multimedia.Camera.Core
7572
7573**返回值:**
7574
7575| 类型        | 说明                          |
7576| ---------- | ----------------------------- |
7577| Array\<number\>   | 用于获取可变焦距比范围,返回的数组包括其最小值和最大值。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode)。 |
7578
7579**错误码:**
7580
7581以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
7582
7583| 错误码ID         | 错误信息        |
7584| --------------- | --------------- |
7585| 7400103                |  Session not config.                                   |
7586
7587**示例:**
7588
7589```ts
7590import { BusinessError } from '@kit.BasicServicesKit';
7591
7592function getZoomRatioRange(captureSession: camera.CaptureSession): Array<number> {
7593  let zoomRatioRange: Array<number> = [];
7594  try {
7595    zoomRatioRange = captureSession.getZoomRatioRange();
7596  } catch (error) {
7597    // 失败返回错误码error.code并处理。
7598    let err = error as BusinessError;
7599    console.error(`The getZoomRatioRange call failed. error code: ${err.code}`);
7600  }
7601  return zoomRatioRange;
7602}
7603```
7604
7605### setZoomRatio<sup>(deprecated)</sup>
7606
7607setZoomRatio(zoomRatio: number): void
7608
7609设置变焦比,变焦精度最高为小数点后两位,如果设置超过支持的精度范围,则只保留精度范围内数值。
7610
7611> **说明:**
7612>从 API version 10开始支持,从API version 11开始废弃。建议使用[Zoom.setZoomRatio](#setzoomratio11)替代。
7613
7614**系统能力:** SystemCapability.Multimedia.Camera.Core
7615
7616**参数:**
7617
7618| 参数名       | 类型                  | 必填  | 说明                 |
7619| --------- | -------------------- |-----| ------------------- |
7620| zoomRatio | number               | 是  | 可变焦距比,通过[getZoomRatioRange](#getzoomratiorange11)获取支持的变焦范围,如果设置超过支持范围的值,则只保留精度范围内数值。传参为null或者undefined,作为0处理,变焦设置最小值。 |
7621
7622**错误码:**
7623
7624以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
7625
7626| 错误码ID         | 错误信息        |
7627| --------------- | --------------- |
7628| 7400103                |  Session not config.                                   |
7629
7630**示例:**
7631
7632```ts
7633import { BusinessError } from '@kit.BasicServicesKit';
7634
7635function setZoomRatio(captureSession: camera.CaptureSession, zoomRatioRange: Array<number>): void {
7636  if (zoomRatioRange === undefined || zoomRatioRange.length <= 0) {
7637    return;
7638  }
7639  let zoomRatio = zoomRatioRange[0];
7640  try {
7641    captureSession.setZoomRatio(zoomRatio);
7642  } catch (error) {
7643    // 失败返回错误码error.code并处理。
7644    let err = error as BusinessError;
7645    console.error(`The setZoomRatio call failed. error code: ${err.code}`);
7646  }
7647}
7648```
7649
7650### getZoomRatio<sup>(deprecated)</sup>
7651
7652getZoomRatio(): number
7653
7654获取当前的变焦比。
7655
7656> **说明:**
7657>从 API version 10开始支持,从API version 11开始废弃。建议使用[Zoom.getZoomRatio](#getzoomratio11)替代。
7658
7659**系统能力:** SystemCapability.Multimedia.Camera.Core
7660
7661**返回值:**
7662
7663| 类型        | 说明                          |
7664| ---------- | ----------------------------- |
7665| number    | 获取当前的变焦比结果。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode)。 |
7666
7667**错误码:**
7668
7669以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
7670
7671| 错误码ID         | 错误信息        |
7672| --------------- | --------------- |
7673| 7400103                |  Session not config.                                   |
7674
7675**示例:**
7676
7677```ts
7678import { BusinessError } from '@kit.BasicServicesKit';
7679
7680function getZoomRatio(captureSession: camera.CaptureSession): number {
7681  const invalidValue: number = -1;
7682  let zoomRatio: number = invalidValue;
7683  try {
7684    zoomRatio = captureSession.getZoomRatio();
7685  } catch (error) {
7686    // 失败返回错误码error.code并处理。
7687    let err = error as BusinessError;
7688    console.error(`The getZoomRatio call failed. error code: ${err.code}`);
7689  }
7690  return zoomRatio;
7691}
7692```
7693
7694### isVideoStabilizationModeSupported<sup>(deprecated)</sup>
7695
7696isVideoStabilizationModeSupported(vsMode: VideoStabilizationMode): boolean
7697
7698查询是否支持指定的视频防抖模式。
7699
7700> **说明:**
7701>从 API version 10开始支持,从API version 11开始废弃。建议使用[Stabilization.isVideoStabilizationModeSupported](#isvideostabilizationmodesupported11)替代。
7702
7703**系统能力:** SystemCapability.Multimedia.Camera.Core
7704
7705**参数:**
7706
7707| 参数名      | 类型                                              | 必填 | 说明                             |
7708| -------- | ------------------------------------------------- | ---- | ------------------------------ |
7709| vsMode   | [VideoStabilizationMode](#videostabilizationmode) | 是   | 视频防抖模式。传参为null或者undefined,作为0处理,超级防抖模式关闭。              |
7710
7711**返回值:**
7712
7713| 类型        | 说明                          |
7714| ---------- | ----------------------------- |
7715| boolean    | 返回视频防抖模式是否支持,true表示支持,false表示不支持。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode)。 |
7716
7717**错误码:**
7718
7719以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
7720
7721| 错误码ID         | 错误信息        |
7722| --------------- | --------------- |
7723| 7400103                |  Session not config.                                   |
7724
7725**示例:**
7726
7727```ts
7728import { BusinessError } from '@kit.BasicServicesKit';
7729
7730function isVideoStabilizationModeSupported(captureSession: camera.CaptureSession): boolean {
7731  let isSupported: boolean = false;
7732  try {
7733    isSupported = captureSession.isVideoStabilizationModeSupported(camera.VideoStabilizationMode.OFF);
7734  } catch (error) {
7735    // 失败返回错误码error.code并处理。
7736    let err = error as BusinessError;
7737    console.error(`The isVideoStabilizationModeSupported call failed. error code: ${err.code}`);
7738  }
7739  return isSupported;
7740}
7741```
7742
7743### getActiveVideoStabilizationMode<sup>(deprecated)</sup>
7744
7745getActiveVideoStabilizationMode(): VideoStabilizationMode
7746
7747查询当前正在使用的视频防抖模式。
7748
7749> **说明:**
7750>从 API version 10开始支持,从API version 11开始废弃。建议使用[Stabilization.getActiveVideoStabilizationMode](#getactivevideostabilizationmode11)替代。
7751
7752**系统能力:** SystemCapability.Multimedia.Camera.Core
7753
7754**返回值:**
7755
7756| 类型        | 说明                          |
7757| ---------- | ----------------------------- |
7758| [VideoStabilizationMode](#videostabilizationmode)    | 视频防抖是否正在使用。接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode)。 |
7759
7760**错误码:**
7761
7762以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
7763
7764| 错误码ID         | 错误信息        |
7765| --------------- | --------------- |
7766| 7400103                |  Session not config.                                   |
7767
7768**示例:**
7769
7770```ts
7771import { BusinessError } from '@kit.BasicServicesKit';
7772
7773function getActiveVideoStabilizationMode(captureSession: camera.CaptureSession): camera.VideoStabilizationMode | undefined {
7774  let vsMode: camera.VideoStabilizationMode | undefined = undefined;
7775  try {
7776    vsMode = captureSession.getActiveVideoStabilizationMode();
7777  } catch (error) {
7778    // 失败返回错误码error.code并处理。
7779    let err = error as BusinessError;
7780    console.error(`The getActiveVideoStabilizationMode call failed. error code: ${err.code}`);
7781  }
7782  return vsMode;
7783}
7784```
7785
7786### setVideoStabilizationMode<sup>(deprecated)</sup>
7787
7788setVideoStabilizationMode(mode: VideoStabilizationMode): void
7789
7790设置视频防抖模式。需要先检查设备是否支持对应的防抖模式,可以通过[isVideoStabilizationModeSupported](#isvideostabilizationmodesupporteddeprecated)方法判断所设置的模式是否支持。
7791
7792> **说明:**
7793>从 API version 10开始支持,从API version 11开始废弃。建议使用[Stabilization.setVideoStabilizationMode](#setvideostabilizationmode11)替代。
7794
7795**系统能力:** SystemCapability.Multimedia.Camera.Core
7796
7797**参数:**
7798
7799| 参数名      | 类型                                              | 必填 | 说明                    |
7800| -------- | ------------------------------------------------- | ---- | --------------------- |
7801| mode     | [VideoStabilizationMode](#videostabilizationmode) | 是   | 需要设置的视频防抖模式。传参为null或者undefined,作为0处理,超级防抖模式关闭。   |
7802
7803**错误码:**
7804
7805以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
7806
7807| 错误码ID         | 错误信息        |
7808| --------------- | --------------- |
7809| 7400103                |  Session not config.                                   |
7810
7811**示例:**
7812
7813```ts
7814import { BusinessError } from '@kit.BasicServicesKit';
7815
7816function setVideoStabilizationMode(captureSession: camera.CaptureSession): void {
7817  try {
7818    captureSession.setVideoStabilizationMode(camera.VideoStabilizationMode.OFF);
7819  } catch (error) {
7820    // 失败返回错误码error.code并处理。
7821    let err = error as BusinessError;
7822    console.error(`The setVideoStabilizationMode call failed. error code: ${err.code}`);
7823  }
7824}
7825```
7826
7827### on('focusStateChange')<sup>(deprecated)</sup>
7828
7829on(type: 'focusStateChange', callback: AsyncCallback\<FocusState\>): void
7830
7831监听相机聚焦的状态变化,通过注册回调函数获取结果。使用callback异步回调。
7832
7833> **说明:**
7834> 从 API version 10开始支持,从API version 11开始废弃。建议使用[VideoSession.on('focusStateChange')](#onfocusstatechange11-1)替代。
7835>
7836> 当前注册监听接口,不支持在on监听的回调方法里,调用off注销回调。
7837
7838**系统能力:** SystemCapability.Multimedia.Camera.Core
7839
7840**参数:**
7841
7842| 参数名     | 类型                                      | 必填 | 说明                       |
7843| -------- | ----------------------------------------- | ---- | ------------------------ |
7844| type     | string                                    | 是   | 监听事件,固定为'focusStateChange',session 创建成功可监听。仅当自动对焦模式时,且相机对焦状态发生改变时可触发该事件。 |
7845| callback | AsyncCallback\<[FocusState](#focusstate)\> | 是   | 回调函数,用于获取当前对焦状态。  |
7846
7847**示例:**
7848
7849```ts
7850import { BusinessError } from '@kit.BasicServicesKit';
7851
7852function registerFocusStateChange(captureSession: camera.CaptureSession): void {
7853  captureSession.on('focusStateChange', (err: BusinessError, focusState: camera.FocusState) => {
7854    if (err !== undefined && err.code !== 0) {
7855      console.error(`Callback Error, errorCode: ${err.code}`);
7856      return;
7857    }
7858    console.info(`Focus state: ${focusState}`);
7859  });
7860}
7861```
7862
7863### off('focusStateChange')<sup>(deprecated)</sup>
7864
7865off(type: 'focusStateChange', callback?: AsyncCallback\<FocusState\>): void
7866
7867注销监听相机聚焦的状态变化。
7868
7869> **说明:**
7870>从 API version 10开始支持,从API version 11开始废弃。建议使用[VideoSession.off('focusStateChange')](#offfocusstatechange11-1)替代。
7871
7872**系统能力:** SystemCapability.Multimedia.Camera.Core
7873
7874**参数:**
7875
7876| 参数名     | 类型                                      | 必填 | 说明                       |
7877| -------- | ----------------------------------------- | ---- | ------------------------ |
7878| type     | string                                    | 是   | 监听事件,固定为'focusStateChange',session 创建成功可监听。|
7879| callback | AsyncCallback\<[FocusState](#focusstate)\> | 否   | 回调函数,如果指定参数则取消对应callback(callback对象不可是匿名函数),否则取消所有callback。 |
7880
7881**示例:**
7882
7883```ts
7884function unregisterFocusStateChange(captureSession: camera.CaptureSession): void {
7885  captureSession.off('focusStateChange');
7886}
7887```
7888
7889### on('error')<sup>(deprecated)</sup>
7890
7891on(type: 'error', callback: ErrorCallback): void
7892
7893监听拍照会话的错误事件,通过注册回调函数获取结果。使用callback异步回调。
7894
7895> **说明:**
7896>
7897> 当前注册监听接口,不支持在on监听的回调方法里,调用off注销回调。
7898
7899> **说明:**
7900>从 API version 10开始支持,从API version 11开始废弃。建议使用[VideoSession.on('error')](#onerror11-1)替代。
7901
7902**系统能力:** SystemCapability.Multimedia.Camera.Core
7903
7904**参数:**
7905
7906| 参数名     | 类型                                                                       | 必填 | 说明                           |
7907| -------- |--------------------------------------------------------------------------| ---- | ------------------------------ |
7908| type     | string                                                                   | 是   | 监听事件,固定为'error',session创建成功之后可监听该接口。session调用相关接口出现错误时会触发该事件,比如调用[beginConfig](#beginconfigdeprecated),[commitConfig](#commitconfigdeprecated-1),[addInput](#addinputdeprecated)等接口发生错误时返回错误信息。 |
7909| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback) | 是   | 回调函数,用于获取错误信息。返回错误码,错误码类型[CameraErrorCode](#cameraerrorcode)。        |
7910
7911**示例:**
7912
7913```ts
7914import { BusinessError } from '@kit.BasicServicesKit';
7915
7916function registerCaptureSessionError(captureSession: camera.CaptureSession): void {
7917  captureSession.on('error', (error: BusinessError) => {
7918    console.error(`Capture session error code: ${error.code}`);
7919  });
7920}
7921```
7922
7923### off('error')<sup>(deprecated)</sup>
7924
7925off(type: 'error', callback?: ErrorCallback): void
7926
7927注销监听拍照会话的错误事件,通过注册回调函数获取结果。
7928
7929> **说明:**
7930>从 API version 10开始支持,从API version 11开始废弃。建议使用[VideoSession.off('error')](#offerror11-1)替代。
7931
7932**系统能力:** SystemCapability.Multimedia.Camera.Core
7933
7934**参数:**
7935
7936| 参数名     | 类型                                                          | 必填 | 说明                           |
7937| -------- | ----------------------------------------------------------- | ---- | ------------------------------ |
7938| type     | string                                                      | 是   | 监听事件,固定为'error',session创建成功之后可监听该接口。 |
7939| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| 否   | 回调函数,如果指定参数则取消对应callback(callback对象不可是匿名函数),否则取消所有callback。 |
7940
7941**示例:**
7942
7943```ts
7944function unregisterCaptureSessionError(captureSession: camera.CaptureSession): void {
7945  captureSession.off('error');
7946}
7947```
7948## ColorManagementQuery<sup>12+</sup>
7949
7950色彩管理类,用于查询色彩空间参数。
7951
7952### getSupportedColorSpaces<sup>12+</sup>
7953
7954getSupportedColorSpaces(): Array\<colorSpaceManager.ColorSpace\>
7955
7956获取支持的色彩空间列表。
7957
7958**系统能力:** SystemCapability.Multimedia.Camera.Core
7959
7960**返回值:**
7961
7962| 类型                                             | 说明                           |
7963| ----------------------------------------------- | ---------------------------- |
7964| Array<[colorSpaceManager.ColorSpace](../apis-arkgraphics2d/js-apis-colorSpaceManager.md#colorspace)>| 支持的色彩空间列表。     |
7965
7966**示例:**
7967
7968```ts
7969import { BusinessError } from '@kit.BasicServicesKit';
7970import { colorSpaceManager } from '@kit.ArkGraphics2D';
7971
7972function getSupportedColorSpaces(session: camera.PhotoSession): Array<colorSpaceManager.ColorSpace> {
7973  let colorSpaces: Array<colorSpaceManager.ColorSpace> = [];
7974  colorSpaces = session.getSupportedColorSpaces();
7975  return colorSpaces;
7976}
7977```
7978## ColorManagement<sup>12+</sup>
7979
7980ColorManagement extends [ColorManagementQuery](#colormanagementquery12)
7981
7982色彩管理类,继承自[ColorManagementQuery](#colormanagementquery12),用于设置色彩空间参数。
7983
7984### setColorSpace<sup>12+</sup>
7985
7986setColorSpace(colorSpace: colorSpaceManager.ColorSpace): void
7987
7988设置色彩空间。可以先通过[getSupportedColorSpaces](#getsupportedcolorspaces12)获取当前设备所支持的ColorSpaces。
7989
7990**P3广色域与HDR高动态范围成像**
7991
7992应用可以下发不同的色彩空间(ColorSpace)参数来支持P3广色域以及HDR的功能。
7993当应用不主动设置色彩空间时,拍照模式默认为SDR拍摄效果。
7994在拍照模式下设置HDR高显效果可直接支持P3色域。
7995应用针对不同模式使能HDR效果以及设置的色彩空间可参考下表。
7996
7997**录像模式:**
7998
7999| SDR/HRD拍摄         | CameraFormat             | ColorSpace       |
8000|--------------------|--------------------------|------------------|
8001| SDR                | CAMERA_FORMAT_YUV_420_SP | BT709_LIMIT      |
8002| HDR_VIVID          | CAMERA_FORMAT_YCRCB_P010 | BT2020_HLG_LIMIT |
8003
8004**拍照模式:**
8005
8006| SDR/HRD拍摄        | ColorSpace |
8007|--------------------|------------|
8008| SDR(Default)       | SRGB       |
8009| HDR                | DISPLAY_P3 |
8010
8011**系统能力:** SystemCapability.Multimedia.Camera.Core
8012
8013**参数:**
8014
8015| 参数名         | 类型                 | 必填 | 说明                      |
8016| ------------ |---------------------- | -- | -------------------------- |
8017| colorSpace | [colorSpaceManager.ColorSpace](../apis-arkgraphics2d/js-apis-colorSpaceManager.md#colorspace)  | 是 | 色彩空间,通过[getSupportedColorSpaces](#getsupportedcolorspaces12)接口获取。   |
8018
8019**错误码:**
8020
8021以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
8022
8023| 错误码ID         | 错误信息        |
8024| --------------- | --------------- |
8025| 7400101         |  Parameter missing or parameter type incorrect.     |
8026| 7400102         |  The colorSpace does not match the format.     |
8027| 7400103         |  Session not config.                           |
8028| 7400201         |  Camera service fatal error.                   |
8029
8030**示例:**
8031
8032```ts
8033import { BusinessError } from '@kit.BasicServicesKit';
8034import { colorSpaceManager } from '@kit.ArkGraphics2D';
8035
8036function setColorSpace(session: camera.PhotoSession, colorSpaces: Array<colorSpaceManager.ColorSpace>): void {
8037  if (colorSpaces === undefined || colorSpaces.length <= 0) {
8038    return;
8039  }
8040  try {
8041    session.setColorSpace(colorSpaces[0]);
8042  } catch (error) {
8043    let err = error as BusinessError;
8044    console.error(`The setColorSpace call failed, error code: ${err.code}`);
8045  }
8046}
8047```
8048
8049### getActiveColorSpace<sup>12+</sup>
8050
8051getActiveColorSpace(): colorSpaceManager.ColorSpace
8052
8053获取当前设置的色彩空间。
8054
8055**系统能力:** SystemCapability.Multimedia.Camera.Core
8056
8057**返回值:**
8058
8059| 类型                                             | 说明                           |
8060| ----------------------------------------------- | ---------------------------- |
8061| [colorSpaceManager.ColorSpace](../apis-arkgraphics2d/js-apis-colorSpaceManager.md#colorspace)               | 当前设置的色彩空间。                |
8062
8063**错误码:**
8064
8065以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
8066
8067| 错误码ID         | 错误信息        |
8068| --------------- | --------------- |
8069| 7400103                |  Session not config.                                   |
8070
8071**示例:**
8072
8073```ts
8074import { BusinessError } from '@kit.BasicServicesKit';
8075import { colorSpaceManager } from '@kit.ArkGraphics2D';
8076
8077function getActiveColorSpace(session: camera.PhotoSession): colorSpaceManager.ColorSpace | undefined {
8078  let colorSpace: colorSpaceManager.ColorSpace | undefined = undefined;
8079  try {
8080    colorSpace = session.getActiveColorSpace();
8081  } catch (error) {
8082    let err = error as BusinessError;
8083    console.error(`The getActiveColorSpace call failed. error code: ${err.code}`);
8084  }
8085  return colorSpace;
8086}
8087```
8088
8089## AutoDeviceSwitchQuery<sup>13+</sup>
8090
8091自动切换镜头查询类,用于查询设备是否支持自动切换镜头。
8092
8093### isAutoDeviceSwitchSupported<sup>13+</sup>
8094
8095isAutoDeviceSwitchSupported(): boolean
8096
8097查询设备是否支持自动切换镜头能力。
8098
8099**系统能力:** SystemCapability.Multimedia.Camera.Core
8100
8101**返回值:**
8102
8103| 类型                                             | 说明          |
8104| ----------------------------------------------- |-------------|
8105| boolean               | 是否支持自动切换镜头,true为支持,false为不支持。 |
8106
8107**示例:**
8108
8109```ts
8110import { BusinessError } from '@kit.BasicServicesKit';
8111
8112function isAutoDeviceSwitchSupported(session: camera.PhotoSession): boolean {
8113  let isSupported = false;
8114  isSupported = session.isAutoDeviceSwitchSupported();
8115  return isSupported;
8116}
8117```
8118
8119## AutoDeviceSwitch<sup>13+</sup>
8120
8121AutoDeviceSwitch extends [AutoDeviceSwitchQuery](#autodeviceswitchquery13)
8122
8123自动切换镜头类,继承自[AutoDeviceSwitchQuery](#autodeviceswitchquery13),用于使能或去使能自动切换镜头。
8124
8125使用建议:自动切换镜头功能由系统自动完成输入设备切换、会话配置和参数接续,
8126如系统发现镜头切换时,两颗镜头的变焦范围不一致,则会通过[AutoDeviceSwitchStatus](#autodeviceswitchstatus13)中的isDeviceCapabilityChanged字段告知应用,
8127但仍需要应用自己处理UX的变更(如变焦范围的调整,需要重新通过[getZoomRatioRange](#getzoomratiorange11)接口获取数据并更新UX),
8128因此更适用于极简UX交换的场景。
8129
8130### enableAutoDeviceSwitch<sup>13+</sup>
8131
8132enableAutoDeviceSwitch(enabled: boolean): void
8133
8134使能或去使能自动切换镜头。可以先通过[isAutoDeviceSwitchSupported](#isautodeviceswitchsupported13)获取当前设备是否支持自动切换镜头。
8135
8136> **说明:**
8137> 该接口仅用于有多个前置镜头的折叠设备,在不同的折叠状态下可自动切换到当前可使用的前置镜头。无法实现前后置镜头的切换。
8138
8139**系统能力:** SystemCapability.Multimedia.Camera.Core
8140
8141**参数:**
8142
8143| 参数名         | 类型  | 必填 | 说明  |
8144| ----------- |---------------------- |---| -------------------------- |
8145| enabled | boolean  | 是 | 使能或去使能自动切换镜头。   |
8146
8147**错误码:**
8148
8149以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
8150
8151| 错误码ID   | 错误信息                                                                                                                                       |
8152|----------|------------------------------------------------------------------------------------------------------------------------------------------------|
8153| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameters verification failed. |
8154| 7400102  | Operation not allowed.                                                                                                                         |
8155| 7400103  | Session not config.                                                                                                                            |
8156| 7400201  | Camera service fatal error.                                                                                                                    |
8157
8158**示例:**
8159
8160```ts
8161import { BusinessError } from '@kit.BasicServicesKit';
8162
8163function enableAutoDeviceSwitch(session: camera.PhotoSession, isEnable: boolean): void {
8164  try {
8165    session.enableAutoDeviceSwitch(isEnable);
8166  } catch (error) {
8167    let err = error as BusinessError;
8168    console.error(`The enableAutoDeviceSwitch call failed, error code: ${err.code}`);
8169  }
8170}
8171```
8172
8173## PreconfigType<sup>12+</sup>
8174
8175枚举,提供预配置的类型。
8176
8177**系统能力:** SystemCapability.Multimedia.Camera.Core
8178
8179| 名称                      | 值 | 说明         |
8180|-------------------------|---|------------|
8181| PRECONFIG_720P          | 0 | 720P预配置。   |
8182| PRECONFIG_1080P         | 1 | 1080P预配置。  |
8183| PRECONFIG_4K            | 2 | 4K预配置。     |
8184| PRECONFIG_HIGH_QUALITY  | 3 | 高质量预配置。    |
8185
8186## PreconfigRatio<sup>12+</sup>
8187
8188枚举,提供预配置的分辨率比例。
8189
8190**系统能力:** SystemCapability.Multimedia.Camera.Core
8191
8192| 名称                       | 值 | 说明      |
8193|--------------------------|---|---------|
8194| PRECONFIG_RATIO_1_1      | 0 | 1:1画幅。  |
8195| PRECONFIG_RATIO_4_3      | 1 | 4:3画幅。  |
8196| PRECONFIG_RATIO_16_9     | 2 | 16:9画幅。 |
8197
8198## PhotoSession<sup>11+</sup>
8199
8200PhotoSession extends [Session](#session11), [Flash](#flash11), [AutoExposure](#autoexposure11), [Focus](#focus11), [Zoom](#zoom11), [ColorManagement](#colormanagement12), [AutoDeviceSwitch](#autodeviceswitch13)
8201
8202普通拍照模式会话类,提供了对闪光灯、曝光、对焦、变焦、色彩空间的操作。
8203
8204> **说明:**
8205>
8206> 默认的拍照模式,用于拍摄标准照片。支持多种照片格式和分辨率,适合大多数日常拍摄场景。
8207
8208### canPreconfig<sup>12+</sup>
8209
8210canPreconfig(preconfigType: PreconfigType, preconfigRatio?: PreconfigRatio): boolean
8211
8212查询当前Session是否支持指定的预配置类型。
8213
8214**系统能力:** SystemCapability.Multimedia.Camera.Core
8215
8216**参数:**
8217
8218| 参数名            | 类型                                  | 必填  | 说明              |
8219|----------------|-------------------------------------|-----|-----------------|
8220| preconfigType  | [PreconfigType](#preconfigtype12)   | 是   | 指定配置预期分辨率。      |
8221| preconfigRatio | [PreconfigRatio](#preconfigratio12) | 否   | 可选画幅比例,默认为4:3。  |
8222
8223**返回值:**
8224
8225| 类型      | 说明                                      |
8226|---------|-----------------------------------------|
8227| boolean | true: 支持指定预配值类型。<br/>false: 不支持指定预配值类型。 |
8228
8229**错误码:**
8230
8231以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
8232
8233| 错误码ID   | 错误信息                        |
8234|---------|-----------------------------|
8235| 7400201 | Camera service fatal error. |
8236
8237**示例:**
8238
8239```ts
8240function testCanPreconfig(photoSession: camera.PhotoSession, preconfigType: camera.PreconfigType,
8241  preconfigRatio: camera.PreconfigRatio): void {
8242  try {
8243    let result = photoSession.canPreconfig(preconfigType, preconfigRatio);
8244    console.info(`canPreconfig ${preconfigType} ${preconfigRatio} result is : ${result}`);
8245  } catch (error) {
8246    let err = error as BusinessError;
8247    console.error(`The canPreconfig call failed. error code: ${err.code}`);
8248  }
8249}
8250```
8251
8252### preconfig<sup>12+</sup>
8253
8254preconfig(preconfigType: PreconfigType, preconfigRatio?: PreconfigRatio): void
8255
8256对当前Session进行预配置。
8257
8258**系统能力:** SystemCapability.Multimedia.Camera.Core
8259
8260**参数:**
8261
8262| 参数名            | 类型                                  | 必填  | 说明              |
8263|----------------|-------------------------------------|-----|-----------------|
8264| preconfigType  | [PreconfigType](#preconfigtype12)   | 是   | 指定配置预期分辨率。      |
8265| preconfigRatio | [PreconfigRatio](#preconfigratio12) | 否   | 可选画幅比例,默认为4:3。  |
8266
8267**错误码:**
8268
8269以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
8270
8271| 错误码ID   | 错误信息                        |
8272|---------|-----------------------------|
8273| 7400201 | Camera service fatal error. |
8274
8275**示例:**
8276
8277```ts
8278function testPreconfig(photoSession: camera.PhotoSession, preconfigType: camera.PreconfigType,
8279  preconfigRatio: camera.PreconfigRatio): void {
8280  try {
8281    photoSession.preconfig(preconfigType, preconfigRatio);
8282    console.info(`preconfig ${preconfigType} ${preconfigRatio} success`);
8283  } catch (error) {
8284    let err = error as BusinessError;
8285    console.error(`The preconfig call failed. error code: ${err.code}`);
8286  }
8287}
8288```
8289
8290### on('error')<sup>11+</sup>
8291
8292on(type: 'error', callback: ErrorCallback): void
8293
8294监听普通拍照会话的错误事件,通过注册回调函数获取结果。使用callback异步回调。
8295
8296> **说明:**
8297>
8298> 当前注册监听接口,不支持在on监听的回调方法里,调用off注销回调。
8299
8300**系统能力:** SystemCapability.Multimedia.Camera.Core
8301
8302**参数:**
8303
8304| 参数名     | 类型                                                          | 必填 | 说明                           |
8305| -------- | ----------------------------------------------------------- | ---- | ------------------------------ |
8306| type     | string                                                      | 是   | 监听事件,固定为'error',session创建成功之后可监听该接口。session调用相关接口出现错误时会触发该事件,比如调用[beginConfig](#beginconfig11),[commitConfig](#commitconfig11-1),[addInput](#addinput11)等接口发生错误时返回错误信息。 |
8307| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| 是   | 回调函数,用于获取错误信息。返回错误码,错误码类型[CameraErrorCode](#cameraerrorcode)。        |
8308
8309**示例:**
8310
8311```ts
8312import { BusinessError } from '@kit.BasicServicesKit';
8313
8314function callback(err: BusinessError): void {
8315  console.error(`Photo session error code: ${err.code}`);
8316}
8317
8318function registerSessionError(photoSession: camera.PhotoSession): void {
8319  photoSession.on('error', callback);
8320}
8321```
8322
8323### off('error')<sup>11+</sup>
8324
8325off(type: 'error', callback?: ErrorCallback): void
8326
8327注销监听普通拍照会话的错误事件,通过注册回调函数获取结果。
8328
8329**系统能力:** SystemCapability.Multimedia.Camera.Core
8330
8331**参数:**
8332
8333| 参数名     | 类型                            | 必填 | 说明                           |
8334| -------- | -------------------------------- | ---- | ------------------------------ |
8335| type     | string                           | 是   | 监听事件,固定为'error',session创建成功之后可监听该接口。 |
8336| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| 否   | 回调函数,如果指定参数则取消对应callback(callback对象不可是匿名函数),否则取消所有callback。 |
8337
8338**示例:**
8339
8340```ts
8341function unregisterSessionError(photoSession: camera.PhotoSession): void {
8342  photoSession.off('error');
8343}
8344```
8345
8346### on('focusStateChange')<sup>11+</sup>
8347
8348on(type: 'focusStateChange', callback: AsyncCallback\<FocusState\>): void
8349
8350监听相机聚焦的状态变化,通过注册回调函数获取结果。使用callback异步回调。
8351
8352> **说明:**
8353>
8354> 当前注册监听接口,不支持在on监听的回调方法里,调用off注销回调。
8355
8356**系统能力:** SystemCapability.Multimedia.Camera.Core
8357
8358**参数:**
8359
8360| 参数名     | 类型                    | 必填 | 说明                       |
8361| -------- | ---------------- | ---- | ------------------------ |
8362| type     | string                                    | 是   | 监听事件,固定为'focusStateChange',session创建成功可监听。仅当自动对焦模式时,且相机对焦状态发生改变时可触发该事件。 |
8363| callback | AsyncCallback\<[FocusState](#focusstate)\> | 是   | 回调函数,用于获取当前对焦状态。  |
8364
8365**示例:**
8366
8367```ts
8368import { BusinessError } from '@kit.BasicServicesKit';
8369
8370function callback(err: BusinessError, focusState: camera.FocusState): void {
8371  if (err !== undefined && err.code !== 0) {
8372    console.error(`Callback Error, errorCode: ${err.code}`);
8373    return;
8374  }
8375  console.info(`Focus state: ${focusState}`);
8376}
8377
8378function registerFocusStateChange(photoSession: camera.PhotoSession): void {
8379  photoSession.on('focusStateChange', callback);
8380}
8381```
8382
8383### off('focusStateChange')<sup>11+</sup>
8384
8385off(type: 'focusStateChange', callback?: AsyncCallback\<FocusState\>): void
8386
8387注销监听相机聚焦的状态变化。
8388
8389**系统能力:** SystemCapability.Multimedia.Camera.Core
8390
8391**参数:**
8392
8393| 参数名     | 类型                                      | 必填 | 说明                       |
8394| -------- | ----------------------------------------- | ---- | ------------------------ |
8395| type     | string                                    | 是   | 监听事件,固定为'focusStateChange',session创建成功可监听。 |
8396| callback | AsyncCallback\<[FocusState](#focusstate)\> | 否   | 回调函数,如果指定参数则取消对应callback(callback对象不可是匿名函数),否则取消所有callback。 |
8397
8398**示例:**
8399
8400```ts
8401function unregisterFocusStateChange(photoSession: camera.PhotoSession): void {
8402  photoSession.off('focusStateChange');
8403}
8404```
8405
8406### on('smoothZoomInfoAvailable')<sup>11+</sup>
8407
8408on(type: 'smoothZoomInfoAvailable', callback: AsyncCallback\<SmoothZoomInfo\>): void
8409
8410监听相机平滑变焦的状态变化,通过注册回调函数获取结果。使用callback异步回调。
8411
8412> **说明:**
8413>
8414> 当前注册监听接口,不支持在on监听的回调方法里,调用off注销回调。
8415
8416**系统能力:** SystemCapability.Multimedia.Camera.Core
8417
8418**参数:**
8419
8420| 参数名     | 类型                   | 必填 | 说明                       |
8421| -------- | ----------------------- | ---- | ------------------------ |
8422| type     | string                  | 是   | 监听事件,固定为'smoothZoomInfoAvailable',session创建成功可监听。|
8423| callback | AsyncCallback\<[SmoothZoomInfo](#smoothzoominfo11)\> | 是   | 回调函数,用于获取当前平滑变焦状态。  |
8424
8425**示例:**
8426
8427```ts
8428import { BusinessError } from '@kit.BasicServicesKit';
8429
8430function callback(err: BusinessError, smoothZoomInfo: camera.SmoothZoomInfo): void {
8431  if (err !== undefined && err.code !== 0) {
8432    console.error(`Callback Error, errorCode: ${err.code}`);
8433    return;
8434  }
8435  console.info(`The duration of smooth zoom: ${smoothZoomInfo.duration}`);
8436}
8437
8438function registerSmoothZoomInfo(photoSession: camera.PhotoSession): void {
8439  photoSession.on('smoothZoomInfoAvailable', callback);
8440}
8441```
8442
8443### off('smoothZoomInfoAvailable')<sup>11+</sup>
8444
8445off(type: 'smoothZoomInfoAvailable', callback?: AsyncCallback\<SmoothZoomInfo\>): void
8446
8447注销监听相机平滑变焦的状态变化。
8448
8449**系统能力:** SystemCapability.Multimedia.Camera.Core
8450
8451**参数:**
8452
8453| 参数名     | 类型                                      | 必填 | 说明                       |
8454| -------- | ----------------------------------------- | ---- | ------------------------ |
8455| type     | string              | 是   | 监听事件,固定为'smoothZoomInfoAvailable',session创建成功可监听。|
8456| callback | AsyncCallback\<[SmoothZoomInfo](#smoothzoominfo11)\> | 否   | 回调函数,如果指定参数则取消对应callback(callback对象不可是匿名函数),否则取消所有callback。 |
8457
8458**示例:**
8459
8460```ts
8461function unregisterSmoothZoomInfo(photoSession: camera.PhotoSession): void {
8462  photoSession.off('smoothZoomInfoAvailable');
8463}
8464```
8465
8466### on('autoDeviceSwitchStatusChange')<sup>13+</sup>
8467
8468on(type: 'autoDeviceSwitchStatusChange', callback: AsyncCallback\<AutoDeviceSwitchStatus\>): void
8469
8470监听相机自动切换镜头状态变化,通过注册回调函数获取结果。使用callback异步回调。
8471
8472> **说明:**
8473>
8474> 当前注册监听接口,不支持在on监听的回调方法里,调用off注销回调。
8475
8476**系统能力:** SystemCapability.Multimedia.Camera.Core
8477
8478**参数:**
8479
8480| 参数名     | 类型                                                                   | 必填 | 说明                                                     |
8481| -------- |----------------------------------------------------------------------| ---- |--------------------------------------------------------|
8482| type     | string                                                               | 是   | 监听事件,固定为'autoDeviceSwitchStatusChange',session创建成功可监听。 |
8483| callback | AsyncCallback\<[AutoDeviceSwitchStatus](#autodeviceswitchstatus13)\> | 是   | 回调函数,用于获取当前自动切换镜头的状态。                                  |
8484
8485**示例:**
8486
8487```ts
8488import { BusinessError } from '@kit.BasicServicesKit';
8489
8490function callback(err: BusinessError, autoDeviceSwitchStatus: camera.AutoDeviceSwitchStatus): void {
8491  if (err !== undefined && err.code !== 0) {
8492    console.error(`Callback Error, errorCode: ${err.code}`);
8493    return;
8494  }
8495  console.info(`isDeviceSwitched: ${autoDeviceSwitchStatus.isDeviceSwitched}, isDeviceCapabilityChanged: ${autoDeviceSwitchStatus.isDeviceCapabilityChanged}`);
8496}
8497
8498function registerAutoDeviceSwitchStatus(photoSession: camera.PhotoSession): void {
8499  photoSession.on('autoDeviceSwitchStatusChange', callback);
8500}
8501```
8502
8503### off('autoDeviceSwitchStatusChange')<sup>13+</sup>
8504
8505off(type: 'autoDeviceSwitchStatusChange', callback?: AsyncCallback\<AutoDeviceSwitchStatus\>): void
8506
8507注销监听相机自动切换镜头状态变化。
8508
8509**系统能力:** SystemCapability.Multimedia.Camera.Core
8510
8511**参数:**
8512
8513| 参数名     | 类型                                           | 必填 | 说明                       |
8514| -------- |----------------------------------------------| ---- | ------------------------ |
8515| type     | string                                       | 是   | 监听事件,固定为'autoDeviceSwitchStatusChange',session创建成功可监听。|
8516| callback | AsyncCallback\<[AutoDeviceSwitchStatus](#autodeviceswitchstatus13)\> | 否   | 回调函数,如果指定参数则取消对应callback(callback对象不可是匿名函数),否则取消所有callback。 |
8517
8518**示例:**
8519
8520```ts
8521function unregisterSmoothZoomInfo(photoSession: camera.PhotoSession): void {
8522  photoSession.off('autoDeviceSwitchStatusChange');
8523}
8524```
8525
8526## QualityPrioritization<sup>14+</sup>
8527
8528枚举,录像质量优先级。
8529
8530**系统能力:** SystemCapability.Multimedia.Camera.Core
8531
8532| 名称          | 值  | 说明       |
8533| ------------- | --- | ---------- |
8534| HIGH_QUALITY  | 0   | 高录像质量。   |
8535| POWER_BALANCE | 1   | 功耗平衡的录像质量。 |
8536
8537## VideoSession<sup>11+</sup>
8538
8539VideoSession extends [Session](#session11), [Flash](#flash11), [AutoExposure](#autoexposure11), [Focus](#focus11), [Zoom](#zoom11), [Stabilization](#stabilization11), [ColorManagement](#colormanagement12), [AutoDeviceSwitch](#autodeviceswitch13)
8540
8541普通录像模式会话类,提供了对闪光灯、曝光、对焦、变焦、视频防抖、色彩空间的操作。
8542
8543> **说明:**
8544>
8545> 默认的视频录制模式,适用于一般场景。支持720P、1080p等多种分辨率的录制,可选择不同帧率(如30fps、60fps)。
8546
8547### canPreconfig<sup>12+</sup>
8548
8549canPreconfig(preconfigType: PreconfigType, preconfigRatio?: PreconfigRatio): boolean
8550
8551查询当前Session是否支持指定的与配置类型。
8552
8553**系统能力:** SystemCapability.Multimedia.Camera.Core
8554
8555**参数:**
8556
8557| 参数名            | 类型                                  | 必填  | 说明              |
8558|----------------|-------------------------------------|-----|-----------------|
8559| preconfigType  | [PreconfigType](#preconfigtype12)   | 是   | 指定配置预期分辨率。      |
8560| preconfigRatio | [PreconfigRatio](#preconfigratio12) | 否   | 可选画幅比例,默认为16:9。 |
8561
8562**返回值:**
8563
8564| 类型      | 说明                                      |
8565|---------|-----------------------------------------|
8566| boolean | true: 支持指定预配值类型。<br/>false: 不支持指定预配值类型。 |
8567
8568**错误码:**
8569
8570以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
8571
8572| 错误码ID   | 错误信息                        |
8573|---------|-----------------------------|
8574| 7400201 | Camera service fatal error. |
8575
8576**示例:**
8577
8578```ts
8579function testCanPreconfig(videoSession: camera.VideoSession, preconfigType: camera.PreconfigType,
8580  preconfigRatio: camera.PreconfigRatio): void {
8581  try {
8582    let result = videoSession.canPreconfig(preconfigType, preconfigRatio);
8583    console.info(`canPreconfig ${preconfigType} ${preconfigRatio} result is : ${result}`);
8584  } catch (error) {
8585    let err = error as BusinessError;
8586    console.error(`The canPreconfig call failed. error code: ${err.code}`);
8587  }
8588}
8589```
8590
8591### preconfig<sup>12+</sup>
8592
8593preconfig(preconfigType: PreconfigType, preconfigRatio?: PreconfigRatio): void
8594
8595对当前Session进行预配置。
8596
8597**系统能力:** SystemCapability.Multimedia.Camera.Core
8598
8599**参数:**
8600
8601| 参数名            | 类型                                  | 必填  | 说明              |
8602|----------------|-------------------------------------|-----|-----------------|
8603| preconfigType  | [PreconfigType](#preconfigtype12)   | 是   | 指定配置预期分辨率。      |
8604| preconfigRatio | [PreconfigRatio](#preconfigratio12) | 否   | 可选画幅比例,默认为16:9。 |
8605
8606**错误码:**
8607
8608以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
8609
8610| 错误码ID   | 错误信息                        |
8611|---------|-----------------------------|
8612| 7400201 | Camera service fatal error. |
8613
8614**示例:**
8615
8616```ts
8617function testPreconfig(videoSession: camera.VideoSession, preconfigType: camera.PreconfigType,
8618  preconfigRatio: camera.PreconfigRatio): void {
8619  try {
8620    videoSession.preconfig(preconfigType, preconfigRatio);
8621    console.info(`preconfig ${preconfigType} ${preconfigRatio} success`);
8622  } catch (error) {
8623    let err = error as BusinessError;
8624    console.error(`The preconfig call failed. error code: ${err.code}`);
8625  }
8626}
8627```
8628
8629### on('error')<sup>11+</sup>
8630
8631on(type: 'error', callback: ErrorCallback): void
8632
8633监听普通录像会话的错误事件,通过注册回调函数获取结果。使用callback异步回调。
8634
8635> **说明:**
8636>
8637> 当前注册监听接口,不支持在on监听的回调方法里,调用off注销回调。
8638
8639**系统能力:** SystemCapability.Multimedia.Camera.Core
8640
8641**参数:**
8642
8643| 参数名     | 类型              | 必填 | 说明                           |
8644| -------- | ------------------ | ---- | ------------------------------ |
8645| type     | string             | 是   | 监听事件,固定为'error',session创建成功之后可监听该接口。session调用相关接口出现错误时会触发该事件,比如调用[beginConfig](#beginconfig11),[commitConfig](#commitconfig11-1),[addInput](#addinput11)等接口发生错误时返回错误信息。 |
8646| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)      | 是   | 回调函数,用于获取错误信息。返回错误码,错误码类型[CameraErrorCode](#cameraerrorcode)。   |
8647
8648**示例:**
8649
8650```ts
8651import { BusinessError } from '@kit.BasicServicesKit';
8652
8653function callback(err: BusinessError): void {
8654  console.error(`Video session error code: ${err.code}`);
8655}
8656
8657function registerSessionError(videoSession: camera.VideoSession): void {
8658  videoSession.on('error', callback);
8659}
8660```
8661
8662### off('error')<sup>11+</sup>
8663
8664off(type: 'error', callback?: ErrorCallback): void
8665
8666注销监听普通录像会话的错误事件,通过注册回调函数获取结果。
8667
8668**系统能力:** SystemCapability.Multimedia.Camera.Core
8669
8670**参数:**
8671
8672| 参数名     | 类型                          | 必填 | 说明                           |
8673| -------- | --------------------------- | ---- | ------------------------------ |
8674| type     | string                    | 是   | 监听事件,固定为'error',session创建成功之后可监听该接口。 |
8675| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| 否   | 回调函数,如果指定参数则取消对应callback(callback对象不可是匿名函数),否则取消所有callback。 |
8676
8677**示例:**
8678
8679```ts
8680function unregisterSessionError(videoSession: camera.VideoSession): void {
8681  videoSession.off('error');
8682}
8683```
8684
8685### on('focusStateChange')<sup>11+</sup>
8686
8687on(type: 'focusStateChange', callback: AsyncCallback\<FocusState\>): void
8688
8689监听相机聚焦的状态变化,通过注册回调函数获取结果。使用callback异步回调。
8690
8691> **说明:**
8692>
8693> 当前注册监听接口,不支持在on监听的回调方法里,调用off注销回调。
8694
8695**系统能力:** SystemCapability.Multimedia.Camera.Core
8696
8697**参数:**
8698
8699| 参数名     | 类型                    | 必填 | 说明                       |
8700| -------- | ---------------- | ---- | ------------------------ |
8701| type     | string                                    | 是   | 监听事件,固定为'focusStateChange',session创建成功可监听。仅当自动对焦模式时,且相机对焦状态发生改变时可触发该事件。 |
8702| callback | AsyncCallback\<[FocusState](#focusstate)\> | 是   | 回调函数,用于获取当前对焦状态。  |
8703
8704**示例:**
8705
8706```ts
8707import { BusinessError } from '@kit.BasicServicesKit';
8708
8709function callback(err: BusinessError, focusState: camera.FocusState): void {
8710  if (err !== undefined && err.code !== 0) {
8711    console.error(`Callback Error, errorCode: ${err.code}`);
8712    return;
8713  }
8714  console.info(`Focus state: ${focusState}`);
8715}
8716
8717function registerFocusStateChange(videoSession: camera.VideoSession): void {
8718  videoSession.on('focusStateChange', callback);
8719}
8720```
8721
8722### off('focusStateChange')<sup>11+</sup>
8723
8724off(type: 'focusStateChange', callback?: AsyncCallback\<FocusState\>): void
8725
8726注销监听相机聚焦的状态变化。
8727
8728**系统能力:** SystemCapability.Multimedia.Camera.Core
8729
8730**参数:**
8731
8732| 参数名     | 类型                                      | 必填 | 说明                       |
8733| -------- | ----------------------------------------- | ---- | ------------------------ |
8734| type     | string                                    | 是   | 监听事件,固定为'focusStateChange',session创建成功可监听。 |
8735| callback | AsyncCallback\<[FocusState](#focusstate)\> | 否  | 回调函数,如果指定参数则取消对应callback(callback对象不可是匿名函数),否则取消所有callback。 |
8736
8737**示例:**
8738
8739```ts
8740function unregisterFocusStateChange(videoSession: camera.VideoSession): void {
8741  videoSession.off('focusStateChange');
8742}
8743```
8744
8745### on('smoothZoomInfoAvailable')<sup>11+</sup>
8746
8747on(type: 'smoothZoomInfoAvailable', callback: AsyncCallback\<SmoothZoomInfo\>): void
8748
8749监听相机平滑变焦的状态变化,通过注册回调函数获取结果。使用callback异步回调。
8750
8751> **说明:**
8752>
8753> 当前注册监听接口,不支持在on监听的回调方法里,调用off注销回调。
8754
8755**系统能力:** SystemCapability.Multimedia.Camera.Core
8756
8757**参数:**
8758
8759| 参数名     | 类型                   | 必填 | 说明                       |
8760| -------- | ----------------------- | ---- | ------------------------ |
8761| type     | string                  | 是   | 监听事件,固定为'smoothZoomInfoAvailable',session创建成功可监听。|
8762| callback | AsyncCallback\<[SmoothZoomInfo](#smoothzoominfo11)\> | 是   | 回调函数,用于获取当前平滑变焦状态。  |
8763
8764**示例:**
8765
8766```ts
8767import { BusinessError } from '@kit.BasicServicesKit';
8768
8769function callback(err: BusinessError, smoothZoomInfo: camera.SmoothZoomInfo): void {
8770  if (err !== undefined && err.code !== 0) {
8771    console.error(`Callback Error, errorCode: ${err.code}`);
8772    return;
8773  }
8774  console.info(`The duration of smooth zoom: ${smoothZoomInfo.duration}`);
8775}
8776
8777function registerSmoothZoomInfo(videoSession: camera.VideoSession): void {
8778  videoSession.on('smoothZoomInfoAvailable', callback);
8779}
8780```
8781
8782### off('smoothZoomInfoAvailable')<sup>11+</sup>
8783
8784off(type: 'smoothZoomInfoAvailable', callback?: AsyncCallback\<SmoothZoomInfo\>): void
8785
8786注销监听相机平滑变焦的状态变化。
8787
8788**系统能力:** SystemCapability.Multimedia.Camera.Core
8789
8790**参数:**
8791
8792| 参数名     | 类型                                      | 必填 | 说明                       |
8793| -------- | ----------------------------------------- | ---- | ------------------------ |
8794| type     | string              | 是   | 监听事件,固定为'smoothZoomInfoAvailable',session创建成功可监听。|
8795| callback | AsyncCallback\<[SmoothZoomInfo](#smoothzoominfo11)\> | 否   | 回调函数,如果指定参数则取消对应callback(callback对象不可是匿名函数),否则取消所有callback。 |
8796
8797**示例:**
8798
8799```ts
8800function unregisterSmoothZoomInfo(videoSession: camera.VideoSession): void {
8801  videoSession.off('smoothZoomInfoAvailable');
8802}
8803```
8804
8805### on('autoDeviceSwitchStatusChange')<sup>13+</sup>
8806
8807on(type: 'autoDeviceSwitchStatusChange', callback: AsyncCallback\<AutoDeviceSwitchStatus\>): void
8808
8809监听相机自动切换镜头状态变化,通过注册回调函数获取结果。使用callback异步回调。
8810
8811> **说明:**
8812>
8813> 当前注册监听接口,不支持在on监听的回调方法里,调用off注销回调。
8814
8815**系统能力:** SystemCapability.Multimedia.Camera.Core
8816
8817**参数:**
8818
8819| 参数名     | 类型                                                                   | 必填 | 说明                       |
8820| -------- |----------------------------------------------------------------------| ---- | ------------------------ |
8821| type     | string                                                               | 是   | 监听事件,固定为'autoDeviceSwitchStatusChange',session创建成功可监听。|
8822| callback | AsyncCallback\<[AutoDeviceSwitchStatus](#autodeviceswitchstatus13)\> | 是   | 回调函数,用于获取当前自动切换镜头的状态。  |
8823
8824**示例:**
8825
8826```ts
8827import { BusinessError } from '@kit.BasicServicesKit';
8828
8829function callback(err: BusinessError, autoDeviceSwitchStatus: camera.AutoDeviceSwitchStatus): void {
8830  if (err !== undefined && err.code !== 0) {
8831    console.error(`Callback Error, errorCode: ${err.code}`);
8832    return;
8833  }
8834  console.info(`isDeviceSwitched: ${autoDeviceSwitchStatus.isDeviceSwitched}, isDeviceCapabilityChanged: ${autoDeviceSwitchStatus.isDeviceCapabilityChanged}`);
8835}
8836
8837function registerAutoDeviceSwitchStatus(videoSession: camera.VideoSession): void {
8838  videoSession.on('autoDeviceSwitchStatusChange', callback);
8839}
8840```
8841
8842### off('autoDeviceSwitchStatusChange')<sup>13+</sup>
8843
8844off(type: 'autoDeviceSwitchStatusChange', callback?: AsyncCallback\<AutoDeviceSwitchStatus\>): void
8845
8846注销监听相机自动切换镜头状态变化。
8847
8848**系统能力:** SystemCapability.Multimedia.Camera.Core
8849
8850**参数:**
8851
8852| 参数名     | 类型                                           | 必填 | 说明                       |
8853| -------- |----------------------------------------------| ---- | ------------------------ |
8854| type     | string                                       | 是   | 监听事件,固定为'autoDeviceSwitchStatusChange',session创建成功可监听。|
8855| callback | AsyncCallback\<[AutoDeviceSwitchStatus](#autodeviceswitchstatus13)\> | 否   | 回调函数,如果指定参数则取消对应callback(callback对象不可是匿名函数),否则取消所有callback。 |
8856
8857**示例:**
8858
8859```ts
8860function unregisterSmoothZoomInfo(videoSession: camera.VideoSession): void {
8861  videoSession.off('autoDeviceSwitchStatusChange');
8862}
8863```
8864
8865### setQualityPrioritization<sup>14+</sup>
8866
8867setQualityPrioritization(quality : QualityPrioritization) : void;
8868
8869设置录像质量优先级。
8870
8871> **说明:**
8872> 默认为高质量,设置为功耗平衡将降低录像质量以减少功耗。实际功耗收益因平台而异。
8873
8874**系统能力:** SystemCapability.Multimedia.Camera.Core
8875
8876**参数:**
8877
8878| 参数名  | 类型                                              | 必填 | 说明                                       |
8879| ------- | ------------------------------------------------- | ---- | ------------------------------------------ |
8880| quality | [QualityPrioritization](#qualityprioritization14) | 是   | 需要设置的视频质量优先级(默认为高质量)。 |
8881
8882**错误码:**
8883
8884以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
8885
8886| 错误码ID | 错误信息                                                                                                                                        |
8887| -------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
8888| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
8889| 7400103  | Session not config. The session has not been committed or configured.                                                                           |
8890
8891**示例:**
8892
8893```ts
8894import { BusinessError } from '@kit.BasicServicesKit';
8895
8896function setQualityPrioritization(videoSession: camera.VideoSession): void {
8897  try {
8898    videoSession.setQualityPrioritization(camera.QualityPrioritization.POWER_BALANCE);
8899  } catch (error) {
8900    // 失败返回错误码error.code并处理。
8901    let err = error as BusinessError;
8902    console.error(`The setQualityPrioritization call failed. error code: ${err.code}`);
8903  }
8904}
8905```
8906
8907## SecureSession<sup>12+</sup>
8908
8909SecureSession extends [Session](#session11), [Flash](#flash11), [AutoExposure](#autoexposure11), [Focus](#focus11), [Zoom](#zoom11)
8910
8911安全模式会话类,提供了对闪光灯、曝光、对焦、变焦的操作。
8912
8913> **说明:**
8914>
8915> 通过[createSession](#createsession11)接口传入[SceneMode](#scenemode11)为SECURE_PHOTO模式创建一个安全模式的会话。该模式开放给人脸识别、银行等有安全诉求的应用,需要结合<!--RP1-->安全TA<!--RP1End-->使用,支持同时出普通预览流和安全流的业务场景。<!--RP2-->
8916> <br>安全TA:可用于图片处理,它具备验证服务器下发数据的验签能力、图片签名、解析及组装tlv逻辑的能力,还具备密钥读取、创建及操作能力。<!--RP2End-->
8917
8918### addSecureOutput<sup>12+</sup>
8919
8920addSecureOutput(previewOutput: PreviewOutput): void
8921
8922把其中一条[PreviewOutput](#previewoutput)标记成安全输出。
8923
8924**系统能力:** SystemCapability.Multimedia.Camera.Core
8925
8926**参数:**
8927
8928| 参数名           | 类型                             | 必填 | 说明            |
8929| ------------- | ------------------------------- | ---- |---------------|
8930| previewOutput  | [PreviewOutput](#previewoutput)   | 是   | 需要标记成安全输出的预览流,传参异常时,会返回错误码。 |
8931
8932**错误码:**
8933
8934以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
8935
8936| 错误码ID         | 错误信息        |
8937| --------------- | --------------- |
8938| 7400101                |  Parameter missing or parameter type incorrect.        |
8939| 7400102                |  Operation not allowed.                                  |
8940
8941**示例:**
8942
8943```ts
8944import { BusinessError } from '@kit.BasicServicesKit';
8945
8946function addSecureOutput(session: camera.SecureSession, previewOutput: camera.PreviewOutput): void {
8947  try {
8948    session.addSecureOutput(previewOutput);
8949  } catch (error) {
8950    // 失败返回错误码error.code并处理。
8951    let err = error as BusinessError;
8952    console.error(`The addOutput call failed. error code: ${err.code}`);
8953  }
8954}
8955```
8956### on('error')<sup>12+</sup>
8957
8958on(type: 'error', callback: ErrorCallback): void
8959
8960监听安全相机会话的错误事件,通过注册回调函数获取结果。使用callback异步回调。
8961
8962> **说明:**
8963>
8964> 当前注册监听接口,不支持在on监听的回调方法里,调用off注销回调。
8965
8966**系统能力:** SystemCapability.Multimedia.Camera.Core
8967
8968**参数:**
8969
8970| 参数名     | 类型              | 必填 | 说明                           |
8971| -------- | ------------------ | ---- | ------------------------------ |
8972| type     | string             | 是   | 监听事件,固定为'error',session创建成功之后可监听该接口。session调用相关接口出现错误时会触发该事件,比如调用[beginConfig](#beginconfig11),[commitConfig](#commitconfig11-1),[addInput](#addinput11)等接口发生错误时返回错误信息。 |
8973| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)      | 是   | 回调函数,用于获取错误信息。返回错误码,错误码类型[CameraErrorCode](#cameraerrorcode)。   |
8974
8975**示例:**
8976
8977```ts
8978import { BusinessError } from '@kit.BasicServicesKit';
8979
8980function callback(err: BusinessError): void {
8981  console.error(`Video session error code: ${err.code}`);
8982}
8983
8984function registerSessionError(secureSession: camera.SecureSession): void {
8985  secureSession.on('error', callback);
8986}
8987```
8988
8989### off('error')<sup>12+</sup>
8990
8991off(type: 'error', callback?: ErrorCallback): void
8992
8993注销监听安全相机会话的错误事件,通过注册回调函数获取结果。
8994
8995**系统能力:** SystemCapability.Multimedia.Camera.Core
8996
8997**参数:**
8998
8999| 参数名     | 类型                          | 必填 | 说明                           |
9000| -------- | --------------------------- | ---- | ------------------------------ |
9001| type     | string                    | 是   | 监听事件,固定为'error',session创建成功之后可监听该接口。 |
9002| callback | [ErrorCallback](../apis-basic-services-kit/js-apis-base.md#errorcallback)| 否   | 回调函数,如果指定参数则取消对应callback(callback对象不可是匿名函数),否则取消所有callback。 |
9003
9004**示例:**
9005
9006```ts
9007function unregisterSessionError(secureSession: camera.SecureSession): void {
9008  secureSession.off('error');
9009}
9010```
9011
9012### on('focusStateChange')<sup>12+</sup>
9013
9014on(type: 'focusStateChange', callback: AsyncCallback\<FocusState\>): void
9015
9016监听相机聚焦的状态变化,通过注册回调函数获取结果。使用callback异步回调。
9017
9018> **说明:**
9019>
9020> 当前注册监听接口,不支持在on监听的回调方法里,调用off注销回调。
9021
9022**系统能力:** SystemCapability.Multimedia.Camera.Core
9023
9024**参数:**
9025
9026| 参数名     | 类型                    | 必填 | 说明                       |
9027| -------- | ---------------- | ---- | ------------------------ |
9028| type     | string                                    | 是   | 监听事件,固定为'focusStateChange',session创建成功可监听。仅当自动对焦模式时,且相机对焦状态发生改变时可触发该事件。 |
9029| callback | AsyncCallback\<[FocusState](#focusstate)\> | 是   | 回调函数,用于获取当前对焦状态。  |
9030
9031**示例:**
9032
9033```ts
9034import { BusinessError } from '@kit.BasicServicesKit';
9035
9036function callback(err: BusinessError, focusState: camera.FocusState): void {
9037  if (err !== undefined && err.code !== 0) {
9038    console.error(`Callback Error, errorCode: ${err.code}`);
9039    return;
9040  }
9041  console.info(`Focus state: ${focusState}`);
9042}
9043
9044function registerFocusStateChange(secureSession: camera.SecureSession): void {
9045  secureSession.on('focusStateChange', callback);
9046}
9047```
9048
9049### off('focusStateChange')<sup>12+</sup>
9050
9051off(type: 'focusStateChange', callback?: AsyncCallback\<FocusState\>): void
9052
9053注销监听相机聚焦的状态变化。
9054
9055**系统能力:** SystemCapability.Multimedia.Camera.Core
9056
9057**参数:**
9058
9059| 参数名     | 类型                                      | 必填 | 说明                       |
9060| -------- | ----------------------------------------- | ---- | ------------------------ |
9061| type     | string                                    | 是   | 监听事件,固定为'focusStateChange',session创建成功可监听。 |
9062| callback | AsyncCallback\<[FocusState](#focusstate)\> | 否  | 回调函数,如果指定参数则取消对应callback(callback对象不可是匿名函数),否则取消所有callback。 |
9063
9064**示例:**
9065
9066```ts
9067function unregisterFocusStateChange(secureSession: camera.SecureSession): void {
9068  secureSession.off('focusStateChange');
9069}
9070```