• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (C) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16import {ErrorCallback, AsyncCallback} from './basic';
17import { Context } from './app/context';
18
19/**
20 * @name camera
21 * @syscap SystemCapability.Multimedia.Camera.Core
22 * @import import camera from '@ohos.multimedia.camera';
23 * @since 9
24 */
25declare namespace camera {
26
27  /**
28   * Creates a CameraManager instance.
29   * @param context Current application context.
30   * @param callback Callback used to return the CameraManager instance.
31   * @since 9
32   * @syscap SystemCapability.Multimedia.Camera.Core
33   */
34  function getCameraManager(context: Context, callback: AsyncCallback<CameraManager>): void;
35
36  /**
37   * Creates a CameraManager instance.
38   * @param context Current application context.
39   * @return Promise used to return the CameraManager instance.
40   * @since 9
41   * @syscap SystemCapability.Multimedia.Camera.Core
42   */
43  function getCameraManager(context: Context): Promise<CameraManager>;
44
45  /**
46   * Enum for camera status.
47   * @since 9
48   * @syscap SystemCapability.Multimedia.Camera.Core
49   */
50  enum CameraStatus {
51    /**
52     * Appear status.
53     * @since 9
54     * @syscap SystemCapability.Multimedia.Camera.Core
55     */
56    CAMERA_STATUS_APPEAR = 0,
57    /**
58     * Disappear status.
59     * @since 9
60     * @syscap SystemCapability.Multimedia.Camera.Core
61     */
62    CAMERA_STATUS_DISAPPEAR = 1,
63    /**
64     * Available status.
65     * @since 9
66     * @syscap SystemCapability.Multimedia.Camera.Core
67     */
68    CAMERA_STATUS_AVAILABLE = 2,
69    /**
70     * Unavailable status.
71     * @since 9
72     * @syscap SystemCapability.Multimedia.Camera.Core
73     */
74    CAMERA_STATUS_UNAVAILABLE = 3
75  }
76
77  /**
78   * Profile for camera streams.
79   * @since 9
80   * @syscap SystemCapability.Multimedia.Camera.Core
81   */
82  interface Profile {
83    /**
84     * Camera format.
85     * @since 9
86     * @syscap SystemCapability.Multimedia.Camera.Core
87     */
88    readonly format: CameraFormat;
89    /**
90     * Picture size.
91     * @since 9
92     * @syscap SystemCapability.Multimedia.Camera.Core
93     */
94    readonly size: Size;
95  }
96
97  /**
98   * Frame rate range.
99   * @since 9
100   * @syscap SystemCapability.Multimedia.Camera.Core
101   */
102  interface FrameRateRange {
103    /**
104     * Min frame rate.
105     * @since 9
106     * @syscap SystemCapability.Multimedia.Camera.Core
107     */
108    readonly min: number;
109    /**
110     * Max frame rate.
111     * @since 9
112     * @syscap SystemCapability.Multimedia.Camera.Core
113     */
114    readonly max: number;
115  }
116
117  /**
118   * Video profile.
119   * @since 9
120   * @syscap SystemCapability.Multimedia.Camera.Core
121   */
122  interface VideoProfile extends Profile {
123    /**
124     * Frame rate in unit fps (frames per second).
125     * @since 9
126     * @syscap SystemCapability.Multimedia.Camera.Core
127     */
128    readonly frameRateRange: FrameRateRange;
129  }
130
131  /**
132   * Camera output capability.
133   * @since 9
134   * @syscap SystemCapability.Multimedia.Camera.Core
135   */
136  interface CameraOutputCapability  {
137    /**
138     * Preview profiles.
139     * @since 9
140     * @syscap SystemCapability.Multimedia.Camera.Core
141     */
142    readonly previewProfiles: Array<Profile>;
143    /**
144     * Photo profiles.
145     * @since 9
146     * @syscap SystemCapability.Multimedia.Camera.Core
147     */
148    readonly photoProfiles: Array<Profile>;
149    /**
150     * Video profiles.
151     * @since 9
152     * @syscap SystemCapability.Multimedia.Camera.Core
153     */
154    readonly videoProfiles: Array<VideoProfile>;
155    /**
156     * All the supported metadata Object Types.
157     * @since 9
158     * @syscap SystemCapability.Multimedia.Camera.Core
159     */
160    readonly supportedMetadataObjectTypes: Array<MetadataObjectType>;
161  }
162
163  /**
164   * Camera manager object.
165   * @since 9
166   * @syscap SystemCapability.Multimedia.Camera.Core
167   */
168  interface CameraManager  {
169    /**
170     * Gets supported camera descriptions.
171     * @param callback Callback used to return the array of supported cameras.
172     * @since 9
173     * @syscap SystemCapability.Multimedia.Camera.Core
174     */
175    getSupportedCameras(callback: AsyncCallback<Array<CameraDevice>>): void;
176
177    /**
178     * Gets supported camera descriptions.
179     * @return Promise used to return an array of supported cameras.
180     * @since 9
181     * @syscap SystemCapability.Multimedia.Camera.Core
182     */
183    getSupportedCameras(): Promise<Array<CameraDevice>>;
184
185    /**
186     * Gets supported output capability for specific camera.
187     * @param camera Camera device.
188     * @param callback Callback used to return the camera output capability.
189     * @since 9
190     * @syscap SystemCapability.Multimedia.Camera.Core
191     */
192    getSupportedOutputCapability(camera: CameraDevice, callback: AsyncCallback<CameraOutputCapability>): void;
193
194    /**
195     * Gets supported output capability for specific camera.
196     * @param camera Camera device.
197     * @return Promise used to return the camera output capability.
198     * @since 9
199     * @syscap SystemCapability.Multimedia.Camera.Core
200     */
201    getSupportedOutputCapability(camera: CameraDevice): Promise<CameraOutputCapability>;
202
203    /**
204     * Determine whether camera is muted.
205     * @return Is camera muted.
206     * @since 9
207     * @syscap SystemCapability.Multimedia.Camera.Core
208     */
209    isCameraMuted(): boolean;
210
211    /**
212     * Determine whether camera mute is supported.
213     * @return Is camera mute supported.
214     * @since 9
215     * @syscap SystemCapability.Multimedia.Camera.Core
216     * @systemapi
217     */
218    isCameraMuteSupported(): boolean;
219
220    /**
221     * Mute camera.
222     * @param mute Mute camera if TRUE, otherwise unmute camera.
223     * @since 9
224     * @syscap SystemCapability.Multimedia.Camera.Core
225     * @systemapi
226     */
227    muteCamera(mute: boolean): void;
228
229    /**
230     * Creates a CameraInput instance by camera.
231     * @param camera Camera device used to create the instance.
232     * @param callback Callback used to return the CameraInput instance.
233     * @since 9
234     * @syscap SystemCapability.Multimedia.Camera.Core
235     * @permission ohos.permission.CAMERA
236     */
237    createCameraInput(camera: CameraDevice, callback: AsyncCallback<CameraInput>): void;
238
239    /**
240     * Creates a CameraInput instance by camera.
241     * @param camera Camera device used to create the instance.
242     * @return Promise used to return the CameraInput instance.
243     * @since 9
244     * @syscap SystemCapability.Multimedia.Camera.Core
245     * @permission ohos.permission.CAMERA
246     */
247    createCameraInput(camera: CameraDevice): Promise<CameraInput>;
248
249    /**
250     * Creates a CameraInput instance by camera position and type.
251     * @param position Target camera position.
252     * @param type Target camera type.
253     * @param callback Callback used to return the CameraInput instance.
254     * @since 9
255     * @syscap SystemCapability.Multimedia.Camera.Core
256     * @permission ohos.permission.CAMERA
257     */
258    createCameraInput(position: CameraPosition, type: CameraType, callback: AsyncCallback<CameraInput>): void;
259
260    /**
261     * Creates a CameraInput instance by camera position and type.
262     * @param position Target camera position.
263     * @param type Target camera type.
264     * @return Promise used to return the CameraInput instance.
265     * @since 9
266     * @syscap SystemCapability.Multimedia.Camera.Core
267     * @permission ohos.permission.CAMERA
268     */
269    createCameraInput(position: CameraPosition, type: CameraType): Promise<CameraInput>;
270
271    /**
272     * Creates a PreviewOutput instance.
273     * @param profile Preview output profile.
274     * @param surfaceId Surface object id used in camera photo output.
275     * @param callback Callback used to return the PreviewOutput instance.
276     * @since 9
277     * @syscap SystemCapability.Multimedia.Camera.Core
278     */
279    createPreviewOutput(profile: Profile, surfaceId: string, callback: AsyncCallback<PreviewOutput>): void;
280
281    /**
282     * Creates a PreviewOutput instance.
283     * @param profile Preview output profile.
284     * @param surfaceId Surface object id used in camera photo output.
285     * @return Promise used to return the PreviewOutput instance.
286     * @since 9
287     * @syscap SystemCapability.Multimedia.Camera.Core
288     */
289    createPreviewOutput(profile: Profile, surfaceId: string): Promise<PreviewOutput>;
290
291    /**
292     * Creates a PhotoOutput instance.
293     * @param profile Photo output profile.
294     * @param surfaceId Surface object id used in camera photo output.
295     * @param callback Callback used to return the PhotoOutput instance.
296     * @since 9
297     * @syscap SystemCapability.Multimedia.Camera.Core
298     */
299    createPhotoOutput(profile: Profile, surfaceId: string, callback: AsyncCallback<PhotoOutput>): void;
300
301    /**
302     * Creates a PhotoOutput instance.
303     * @param profile Photo output profile.
304     * @param surfaceId Surface object id used in camera photo output.
305     * @return Promise used to return the PhotoOutput instance.
306     * @since 9
307     * @syscap SystemCapability.Multimedia.Camera.Core
308     */
309    createPhotoOutput(profile: Profile, surfaceId: string): Promise<PhotoOutput>;
310
311    /**
312     * Creates a VideoOutput instance.
313     * @param profile Video profile.
314     * @param surfaceId Surface object id used in camera video output.
315     * @param callback Callback used to return the VideoOutput instance.
316     * @since 9
317     * @syscap SystemCapability.Multimedia.Camera.Core
318     */
319    createVideoOutput(profile: VideoProfile, surfaceId: string, callback: AsyncCallback<VideoOutput>): void;
320
321    /**
322     * Creates a VideoOutput instance.
323     * @param profile Video profile.
324     * @param surfaceId Surface object id used in camera video output.
325     * @return Promise used to return the VideoOutput instance.
326     * @since 9
327     * @syscap SystemCapability.Multimedia.Camera.Core
328     */
329    createVideoOutput(profile: VideoProfile, surfaceId: string): Promise<VideoOutput>;
330
331    /**
332     * Creates a MetadataOutput instance.
333     * @param metadataObjectTypes Array of MetadataObjectType.
334     * @param callback Callback used to return the MetadataOutput instance.
335     * @since 9
336     * @syscap SystemCapability.Multimedia.Camera.Core
337     */
338    createMetadataOutput(metadataObjectTypes: Array<MetadataObjectType>, callback: AsyncCallback<MetadataOutput>): void;
339
340    /**
341     * Creates a MetadataOutput instance.
342     * @param metadataObjectTypes Array of MetadataObjectType.
343     * @return Promise used to return the MetadataOutput instance.
344     * @since 9
345     * @syscap SystemCapability.Multimedia.Camera.Core
346     */
347    createMetadataOutput(metadataObjectTypes: Array<MetadataObjectType>): Promise<MetadataOutput>;
348
349    /**
350     * Gets a CaptureSession instance.
351     * @param callback Callback used to return the CaptureSession instance.
352     * @since 9
353     * @syscap SystemCapability.Multimedia.Camera.Core
354     */
355    createCaptureSession(callback: AsyncCallback<CaptureSession>): void;
356
357    /**
358     * Gets a CaptureSession instance.
359     * @return Promise used to return the CaptureSession instance.
360     * @since 9
361     * @syscap SystemCapability.Multimedia.Camera.Core
362     */
363    createCaptureSession(): Promise<CaptureSession>;
364
365    /**
366     * Subscribes camera status change event callback.
367     * @param type Event type.
368     * @param callback Callback used to get the camera status change.
369     * @since 9
370     * @syscap SystemCapability.Multimedia.Camera.Core
371     */
372    on(type: 'cameraStatus', callback: AsyncCallback<CameraStatusInfo>): void;
373
374    /**
375     * Subscribes camera mute change event callback.
376     * @param type Event type.
377     * @param callback Callback used to get the camera mute change.
378     * @since 9
379     * @syscap SystemCapability.Multimedia.Camera.Core
380     * @systemapi
381     */
382    on(type: 'cameraMute', callback: AsyncCallback<boolean>): void;
383  }
384
385  /**
386   * Camera status info.
387   * @since 9
388   * @syscap SystemCapability.Multimedia.Camera.Core
389   */
390  interface CameraStatusInfo {
391    /**
392     * Camera instance.
393     * @since 9
394     * @syscap SystemCapability.Multimedia.Camera.Core
395     */
396    camera: CameraDevice;
397    /**
398     * Current camera status.
399     * @since 9
400     * @syscap SystemCapability.Multimedia.Camera.Core
401     */
402    status: CameraStatus;
403  }
404
405  /**
406   * Enum for camera position.
407   * @since 9
408   * @syscap SystemCapability.Multimedia.Camera.Core
409   */
410  enum CameraPosition {
411    /**
412     * Unspecified position.
413     * @since 9
414     * @syscap SystemCapability.Multimedia.Camera.Core
415     */
416    CAMERA_POSITION_UNSPECIFIED = 0,
417    /**
418     * Back position.
419     * @since 9
420     * @syscap SystemCapability.Multimedia.Camera.Core
421     */
422    CAMERA_POSITION_BACK = 1,
423    /**
424     * Front position.
425     * @since 9
426     * @syscap SystemCapability.Multimedia.Camera.Core
427     */
428    CAMERA_POSITION_FRONT = 2
429  }
430
431  /**
432   * Enum for camera type.
433   * @since 9
434   * @syscap SystemCapability.Multimedia.Camera.Core
435   */
436  enum CameraType {
437    /**
438     * Unspecified camera type
439     * @since 9
440     * @syscap SystemCapability.Multimedia.Camera.Core
441     */
442    CAMERA_TYPE_UNSPECIFIED = 0,
443
444    /**
445     * Wide camera
446     * @since 9
447     * @syscap SystemCapability.Multimedia.Camera.Core
448     */
449    CAMERA_TYPE_WIDE_ANGLE = 1,
450
451    /**
452     * Ultra wide camera
453     * @since 9
454     * @syscap SystemCapability.Multimedia.Camera.Core
455     */
456    CAMERA_TYPE_ULTRA_WIDE = 2,
457
458    /**
459     * Telephoto camera
460     * @since 9
461     * @syscap SystemCapability.Multimedia.Camera.Core
462     */
463    CAMERA_TYPE_TELEPHOTO = 3,
464
465    /**
466     * True depth camera
467     * @since 9
468     * @syscap SystemCapability.Multimedia.Camera.Core
469     */
470    CAMERA_TYPE_TRUE_DEPTH = 4
471  }
472
473  /**
474   * Enum for camera connection type.
475   * @since 9
476   * @syscap SystemCapability.Multimedia.Camera.Core
477   */
478  enum ConnectionType {
479    /**
480     * Built-in camera.
481     * @since 9
482     * @syscap SystemCapability.Multimedia.Camera.Core
483     */
484    CAMERA_CONNECTION_BUILT_IN = 0,
485
486    /**
487     * Camera connected using USB
488     * @since 9
489     * @syscap SystemCapability.Multimedia.Camera.Core
490     */
491    CAMERA_CONNECTION_USB_PLUGIN = 1,
492
493    /**
494     * Remote camera
495     * @since 9
496     * @syscap SystemCapability.Multimedia.Camera.Core
497     */
498    CAMERA_CONNECTION_REMOTE = 2
499  }
500
501  /**
502   * Camera device object.
503   * @since 9
504   * @syscap SystemCapability.Multimedia.Camera.Core
505   */
506  interface CameraDevice {
507    /**
508     * Camera id attribute.
509     * @since 9
510     * @syscap SystemCapability.Multimedia.Camera.Core
511     */
512    readonly cameraId: string;
513    /**
514     * Camera position attribute.
515     * @since 9
516     * @syscap SystemCapability.Multimedia.Camera.Core
517     */
518    readonly cameraPosition: CameraPosition;
519    /**
520     * Camera type attribute.
521     * @since 9
522     * @syscap SystemCapability.Multimedia.Camera.Core
523     */
524    readonly cameraType: CameraType;
525    /**
526     * Camera connection type attribute.
527     * @since 9
528     * @syscap SystemCapability.Multimedia.Camera.Core
529     */
530    readonly connectionType: ConnectionType;
531  }
532
533  /**
534   * Size parameter.
535   * @since 9
536   * @syscap SystemCapability.Multimedia.Camera.Core
537   */
538  interface Size {
539    /**
540     * Height.
541     * @since 9
542     * @syscap SystemCapability.Multimedia.Camera.Core
543     */
544    height: number;
545    /**
546     * Width.
547     * @since 9
548     * @syscap SystemCapability.Multimedia.Camera.Core
549     */
550    width: number;
551  }
552
553  /**
554   * Point parameter.
555   * @since 9
556   * @syscap SystemCapability.Multimedia.Camera.Core
557   */
558  interface Point {
559    /**
560     * x co-ordinate
561     * @since 9
562     * @syscap SystemCapability.Multimedia.Camera.Core
563     */
564    x: number;
565    /**
566     * y co-ordinate
567     * @since 9
568     * @syscap SystemCapability.Multimedia.Camera.Core
569     */
570    y: number;
571  }
572
573  /**
574   * Camera input object.
575   * @since 9
576   * @syscap SystemCapability.Multimedia.Camera.Core
577   */
578  interface CameraInput {
579    /**
580     * Open camera.
581     * @param callback Callback used to return the result.
582     * @since 9
583     * @syscap SystemCapability.Multimedia.Camera.Core
584     */
585    open(callback: AsyncCallback<void>): void;
586
587    /**
588     * Open camera.
589     * @return Promise used to return the result.
590     * @since 9
591     * @syscap SystemCapability.Multimedia.Camera.Core
592     */
593    open(): Promise<void>;
594
595    /**
596     * Close camera.
597     * @param callback Callback used to return the result.
598     * @since 9
599     * @syscap SystemCapability.Multimedia.Camera.Core
600     */
601    close(callback: AsyncCallback<void>): void;
602
603    /**
604     * Close camera.
605     * @return Promise used to return the result.
606     * @since 9
607     * @syscap SystemCapability.Multimedia.Camera.Core
608     */
609    close(): Promise<void>;
610
611    /**
612     * Releases instance.
613     * @param callback Callback used to return the result.
614     * @since 9
615     * @syscap SystemCapability.Multimedia.Camera.Core
616     */
617    release(callback: AsyncCallback<void>): void;
618
619    /**
620     * Releases instance.
621     * @return Promise used to return the result.
622     * @since 9
623     * @syscap SystemCapability.Multimedia.Camera.Core
624     */
625    release(): Promise<void>;
626
627    /**
628     * Subscribes error event callback.
629     * @param type Event type.
630     * @param camera Camera device.
631     * @param callback Callback used to get the camera input errors.
632     * @since 9
633     * @syscap SystemCapability.Multimedia.Camera.Core
634     */
635    on(type: 'error', camera: CameraDevice, callback: ErrorCallback<CameraInputError>): void;
636  }
637
638  /**
639   * Enum for CameraInput error code.
640   * @since 9
641   * @syscap SystemCapability.Multimedia.Camera.Core
642   */
643  enum CameraInputErrorCode {
644    /**
645     * Unknown error.
646     * @since 9
647     */
648    ERROR_UNKNOWN = -1,
649    /**
650     * No permission.
651     * @since 9
652     */
653    ERROR_NO_PERMISSION = 0,
654    /**
655     * Camera device preempted.
656     * @since 9
657     */
658    ERROR_DEVICE_PREEMPTED = 1,
659    /**
660     * Camera device disconnected.
661     * @since 9
662     */
663    ERROR_DEVICE_DISCONNECTED = 2,
664    /**
665     * Camera device in use.
666     * @since 9
667     */
668    ERROR_DEVICE_IN_USE = 3,
669    /**
670     * Driver error.
671     * @since 9
672     */
673    ERROR_DRIVER_ERROR = 4,
674  }
675
676  /**
677   * Camera input error object.
678   * @since 9
679   * @syscap SystemCapability.Multimedia.Camera.Core
680   */
681  interface CameraInputError extends Error {
682    code: CameraInputErrorCode;
683  }
684
685  /**
686   * Enum for camera format type.
687   * @since 9
688   * @syscap SystemCapability.Multimedia.Camera.Core
689   */
690   enum CameraFormat {
691    /**
692     * RGBA 8888 Format.
693     * @since 9
694     * @syscap SystemCapability.Multimedia.Camera.Core
695     */
696     CAMERA_FORMAT_RGBA_8888 = 3,
697
698    /**
699     * YUV 420 Format.
700     * @since 9
701     * @syscap SystemCapability.Multimedia.Camera.Core
702     */
703    CAMERA_FORMAT_YUV_420_SP = 1003,
704
705    /**
706     * JPEG Format.
707     * @since 9
708     * @syscap SystemCapability.Multimedia.Camera.Core
709     */
710    CAMERA_FORMAT_JPEG = 2000
711  }
712
713  /**
714   * Enum for flash mode.
715   * @since 9
716   * @syscap SystemCapability.Multimedia.Camera.Core
717   */
718  enum FlashMode {
719    /**
720     * Close mode.
721     * @since 9
722     * @syscap SystemCapability.Multimedia.Camera.Core
723     */
724    FLASH_MODE_CLOSE = 0,
725    /**
726     * Open mode.
727     * @since 9
728     * @syscap SystemCapability.Multimedia.Camera.Core
729     */
730    FLASH_MODE_OPEN = 1,
731    /**
732     * Auto mode.
733     * @since 9
734     * @syscap SystemCapability.Multimedia.Camera.Core
735     */
736    FLASH_MODE_AUTO = 2,
737    /**
738     * Always open mode.
739     * @since 9
740     * @syscap SystemCapability.Multimedia.Camera.Core
741     */
742    FLASH_MODE_ALWAYS_OPEN = 3
743  }
744
745  /**
746   * Enum for exposure mode.
747   * @since 9
748   */
749  enum ExposureMode {
750    /**
751     * Lock exposure mode.
752     * @since 9
753     */
754    EXPOSURE_MODE_LOCKED = 0,
755    /**
756     * Auto exposure mode.
757     * @since 9
758     */
759     EXPOSURE_MODE_AUTO = 1,
760     /**
761     * Continuous automatic exposure.
762     * @since 9
763     */
764    EXPOSURE_MODE_CONTINUOUS_AUTO = 2
765  }
766
767  /**
768   * Enum for focus mode.
769   * @since 9
770   * @syscap SystemCapability.Multimedia.Camera.Core
771   */
772  enum FocusMode {
773    /**
774     * Manual mode.
775     * @since 9
776     * @syscap SystemCapability.Multimedia.Camera.Core
777     */
778    FOCUS_MODE_MANUAL = 0,
779    /**
780     * Continuous auto mode.
781     * @since 9
782     * @syscap SystemCapability.Multimedia.Camera.Core
783     */
784    FOCUS_MODE_CONTINUOUS_AUTO = 1,
785    /**
786     * Auto mode.
787     * @since 9
788     * @syscap SystemCapability.Multimedia.Camera.Core
789     */
790    FOCUS_MODE_AUTO = 2,
791    /**
792     * Locked mode.
793     * @since 9
794     * @syscap SystemCapability.Multimedia.Camera.Core
795     */
796    FOCUS_MODE_LOCKED = 3
797  }
798
799  /**
800   * Enum for focus state.
801   * @since 9
802   * @syscap SystemCapability.Multimedia.Camera.Core
803   */
804  enum FocusState {
805    /**
806     * Scan state.
807     * @since 9
808     * @syscap SystemCapability.Multimedia.Camera.Core
809     */
810    FOCUS_STATE_SCAN = 0,
811    /**
812     * Focused state.
813     * @since 9
814     * @syscap SystemCapability.Multimedia.Camera.Core
815     */
816    FOCUS_STATE_FOCUSED = 1,
817    /**
818     * Unfocused state.
819     * @since 9
820     * @syscap SystemCapability.Multimedia.Camera.Core
821     */
822    FOCUS_STATE_UNFOCUSED = 2
823  }
824
825  /**
826   * Enum for video stabilization mode.
827   * @since 9
828   * @syscap SystemCapability.Multimedia.Camera.Core
829   */
830   enum VideoStabilizationMode {
831    /**
832     * Turn off video stablization.
833     * @since 9
834     * @syscap SystemCapability.Multimedia.Camera.Core
835     */
836    OFF = 0,
837    /**
838     * LOW mode provides basic stabilization effect.
839     * @since 9
840     * @syscap SystemCapability.Multimedia.Camera.Core
841     */
842    LOW = 1,
843    /**
844     * MIDDLE mode means algorithms can achieve better effects than LOW mode.
845     * @since 9
846     * @syscap SystemCapability.Multimedia.Camera.Core
847     */
848    MIDDLE = 2,
849    /**
850     * HIGH mode means algorithms can achieve better effects than MIDDLE mode.
851     * @since 9
852     * @syscap SystemCapability.Multimedia.Camera.Core
853     */
854    HIGH = 3,
855    /**
856     * Camera HDF can select mode automatically.
857     * @since 9
858     * @syscap SystemCapability.Multimedia.Camera.Core
859     */
860    AUTO = 4
861  }
862
863  /**
864   * Capture session object.
865   * @since 9
866   * @syscap SystemCapability.Multimedia.Camera.Core
867   */
868  interface CaptureSession {
869    /**
870     * Begin capture session config.
871     * @param callback Callback used to return the result.
872     * @since 9
873     * @syscap SystemCapability.Multimedia.Camera.Core
874     */
875    beginConfig(callback: AsyncCallback<void>): void;
876
877    /**
878     * Begin capture session config.
879     * @return Promise used to return the result.
880     * @since 9
881     * @syscap SystemCapability.Multimedia.Camera.Core
882     */
883    beginConfig(): Promise<void>;
884
885    /**
886     * Commit capture session config.
887     * @param callback Callback used to return the result.
888     * @since 9
889     * @syscap SystemCapability.Multimedia.Camera.Core
890     */
891    commitConfig(callback: AsyncCallback<void>): void;
892
893    /**
894     * Commit capture session config.
895     * @return Promise used to return the result.
896     * @since 9
897     * @syscap SystemCapability.Multimedia.Camera.Core
898     */
899    commitConfig(): Promise<void>;
900
901    /**
902     * Adds a camera input.
903     * @param cameraInput Target camera input to add.
904     * @param callback Callback used to return the result.
905     * @since 9
906     * @syscap SystemCapability.Multimedia.Camera.Core
907     */
908    addInput(cameraInput: CameraInput, callback: AsyncCallback<void>): void;
909
910    /**
911     * Adds a camera input.
912     * @param cameraInput Target camera input to add.
913     * @return Promise used to return the result.
914     * @since 9
915     * @syscap SystemCapability.Multimedia.Camera.Core
916     */
917    addInput(cameraInput: CameraInput): Promise<void>;
918
919    /**
920     * Removes a camera input.
921     * @param cameraInput Target camera input to remove.
922     * @param callback Callback used to return the result.
923     * @since 9
924     * @syscap SystemCapability.Multimedia.Camera.Core
925     */
926    removeInput(cameraInput: CameraInput, callback: AsyncCallback<void>): void;
927
928    /**
929     * Removes a camera input.
930     * @param cameraInput Target camera input to remove.
931     * @return Promise used to return the result.
932     * @since 9
933     * @syscap SystemCapability.Multimedia.Camera.Core
934     */
935    removeInput(cameraInput: CameraInput): Promise<void>;
936
937    /**
938     * Adds a camera output.
939     * @param cameraOutput Target camera output to add.
940     * @param callback Callback used to return the result.
941     * @since 9
942     * @syscap SystemCapability.Multimedia.Camera.Core
943     */
944    addOutput(cameraOutput: CameraOutput, callback: AsyncCallback<void>): void;
945
946    /**
947     * Adds a camera output.
948     * @param cameraOutput Target camera output to add.
949     * @return Promise used to return the result.
950     * @since 9
951     * @syscap SystemCapability.Multimedia.Camera.Core
952     */
953    addOutput(cameraOutput: CameraOutput): Promise<void>;
954
955    /**
956     * Removes a camera output.
957     * @param previewOutput Target camera output to remove.
958     * @param callback Callback used to return the result.
959     * @since 9
960     * @syscap SystemCapability.Multimedia.Camera.Core
961     */
962    removeOutput(cameraOutput: CameraOutput, callback: AsyncCallback<void>): void;
963
964    /**
965     * Removes a camera output.
966     * @param previewOutput Target camera output to remove.
967     * @return Promise used to return the result.
968     * @since 9
969     * @syscap SystemCapability.Multimedia.Camera.Core
970     */
971    removeOutput(cameraOutput: CameraOutput): Promise<void>;
972
973    /**
974     * Starts capture session.
975     * @param callback Callback used to return the result.
976     * @since 9
977     * @syscap SystemCapability.Multimedia.Camera.Core
978     */
979    start(callback: AsyncCallback<void>): void;
980
981    /**
982     * Starts capture session.
983     * @return Promise used to return the result.
984     * @since 9
985     * @syscap SystemCapability.Multimedia.Camera.Core
986     */
987    start(): Promise<void>;
988
989    /**
990     * Stops capture session.
991     * @param callback Callback used to return the result.
992     * @since 9
993     * @syscap SystemCapability.Multimedia.Camera.Core
994     */
995    stop(callback: AsyncCallback<void>): void;
996
997    /**
998     * Stops capture session.
999     * @return Promise used to return the result.
1000     * @since 9
1001     * @syscap SystemCapability.Multimedia.Camera.Core
1002     */
1003    stop(): Promise<void>;
1004
1005    /**
1006     * Release capture session instance.
1007     * @param callback Callback used to return the result.
1008     * @since 9
1009     * @syscap SystemCapability.Multimedia.Camera.Core
1010     */
1011    release(callback: AsyncCallback<void>): void;
1012
1013    /**
1014     * Release capture session instance.
1015     * @return Promise used to return the result.
1016     * @since 9
1017     * @syscap SystemCapability.Multimedia.Camera.Core
1018     */
1019    release(): Promise<void>;
1020
1021    /**
1022     * Check if device has flash light.
1023     * @param callback Callback used to return the flash light support status.
1024     * @since 9
1025     * @syscap SystemCapability.Multimedia.Camera.Core
1026     */
1027    hasFlash(callback: AsyncCallback<boolean>): void;
1028
1029    /**
1030     * Check if device has flash light.
1031     * @return Promise used to return the flash light support status.
1032     * @since 9
1033     * @syscap SystemCapability.Multimedia.Camera.Core
1034     */
1035    hasFlash(): Promise<boolean>;
1036
1037    /**
1038     * Checks whether a specified flash mode is supported.
1039     * @param flashMode Flash mode.
1040     * @param callback Callback used to return the flash light support status.
1041     * @since 9
1042     * @syscap SystemCapability.Multimedia.Camera.Core
1043     */
1044    isFlashModeSupported(flashMode: FlashMode, callback: AsyncCallback<boolean>): void;
1045
1046    /**
1047     * Checks whether a specified flash mode is supported.
1048     * @param flashMode Flash mode
1049     * @return Promise used to return flash mode support status.
1050     * @since 9
1051     * @syscap SystemCapability.Multimedia.Camera.Core
1052     */
1053    isFlashModeSupported(flashMode: FlashMode): Promise<boolean>;
1054
1055    /**
1056     * Gets current flash mode.
1057     * @param callback Callback used to return the current flash mode.
1058     * @since 9
1059     * @syscap SystemCapability.Multimedia.Camera.Core
1060     */
1061    getFlashMode(callback: AsyncCallback<FlashMode>): void;
1062
1063    /**
1064     * Gets current flash mode.
1065     * @return Promise used to return the flash mode.
1066     * @since 9
1067     * @syscap SystemCapability.Multimedia.Camera.Core
1068     */
1069    getFlashMode(): Promise<FlashMode>;
1070
1071    /**
1072     * Sets flash mode.
1073     * @param flashMode Target flash mode.
1074     * @param callback Callback used to return the result.
1075     * @since 9
1076     * @syscap SystemCapability.Multimedia.Camera.Core
1077     */
1078    setFlashMode(flashMode: FlashMode, callback: AsyncCallback<void>): void;
1079
1080    /**
1081     * Sets flash mode.
1082     * @param flashMode Target flash mode.
1083     * @return Promise used to return the result.
1084     * @since 9
1085     * @syscap SystemCapability.Multimedia.Camera.Core
1086     */
1087    setFlashMode(flashMode: FlashMode): Promise<void>;
1088
1089    /**
1090     * Checks whether a specified exposure mode is supported.
1091     * @param aeMode Exposure mode.
1092     * @param callback Callback used to return the exposure mode support status.
1093     * @since 9
1094     * @syscap SystemCapability.Multimedia.Camera.Core
1095     */
1096    isExposureModeSupported(aeMode: ExposureMode, callback: AsyncCallback<boolean>): void;
1097
1098    /**
1099     * Checks whether a specified exposure mode is supported.
1100     * @param aeMode Exposure mode
1101     * @return Promise used to return exposure mode support status.
1102     * @since 9
1103     * @syscap SystemCapability.Multimedia.Camera.Core
1104     */
1105    isExposureModeSupported(aeMode: ExposureMode): Promise<boolean>;
1106
1107    /**
1108     * Gets current exposure mode.
1109     * @param callback Callback used to return the current exposure mode.
1110     * @since 9
1111     * @syscap SystemCapability.Multimedia.Camera.Core
1112     */
1113    getExposureMode(callback: AsyncCallback<ExposureMode>): void;
1114
1115    /**
1116     * Gets current exposure mode.
1117     * @return Promise used to return the current exposure mode.
1118     * @since 9
1119     * @syscap SystemCapability.Multimedia.Camera.Core
1120     */
1121    getExposureMode(): Promise<ExposureMode>;
1122
1123    /**
1124     * Sets exposure mode.
1125     * @param aeMode Exposure mode
1126     * @param callback Callback used to return the result.
1127     * @since 9
1128     * @syscap SystemCapability.Multimedia.Camera.Core
1129     */
1130    setExposureMode(aeMode: ExposureMode, callback: AsyncCallback<void>): void;
1131
1132     /**
1133      * Sets Exposure mode.
1134      * @param aeMode Exposure mode
1135      * @return Promise used to return the result.
1136      * @since 9
1137      * @syscap SystemCapability.Multimedia.Camera.Core
1138      */
1139    setExposureMode(aeMode: ExposureMode): Promise<void>;
1140
1141    /**
1142     * Gets current metering point.
1143     * @param callback Callback used to return the current metering point.
1144     * @since 9
1145     * @syscap SystemCapability.Multimedia.Camera.Core
1146     */
1147    getMeteringPoint(callback: AsyncCallback<Point>): void;
1148
1149    /**
1150     * Gets current metering point.
1151     * @return Promise used to return the current metering point.
1152     * @since 9
1153     * @syscap SystemCapability.Multimedia.Camera.Core
1154     */
1155    getMeteringPoint(): Promise<Point>;
1156
1157    /**
1158     * Set the center point of the metering area.
1159     * @param point Metering point
1160     * @param callback Callback used to return the result.
1161     * @since 9
1162     * @syscap SystemCapability.Multimedia.Camera.Core
1163     */
1164    setMeteringPoint(point: Point, callback: AsyncCallback<void>): void;
1165
1166     /**
1167      * Set the center point of the metering area.
1168      * @param point metering point
1169      * @return Promise used to return the result.
1170      * @since 9
1171      * @syscap SystemCapability.Multimedia.Camera.Core
1172      */
1173    setMeteringPoint(point: Point): Promise<void>;
1174
1175    /**
1176     * Query the exposure compensation range.
1177     * @param callback Callback used to return the array of compenstation range.
1178     * @since 9
1179     * @syscap SystemCapability.Multimedia.Camera.Core
1180     */
1181    getExposureBiasRange(callback: AsyncCallback<Array<number>>): void;
1182
1183    /**
1184     * Query the exposure compensation range.
1185     * @return Promise used to return the array of compenstation range.
1186     * @since 9
1187     * @syscap SystemCapability.Multimedia.Camera.Core
1188     */
1189    getExposureBiasRange(): Promise<Array<number>>;
1190
1191    /**
1192     * Set exposure compensation.
1193     * @param exposureBias Exposure compensation
1194     * @param callback Callback used to return the result.
1195     * @since 9
1196     * @syscap SystemCapability.Multimedia.Camera.Core
1197     */
1198    setExposureBias(exposureBias: number, callback: AsyncCallback<void>): void;
1199
1200    /**
1201     * Set exposure compensation.
1202     * @param exposureBias Exposure compensation
1203     * @return Promise used to return the result.
1204     * @since 9
1205     * @syscap SystemCapability.Multimedia.Camera.Core
1206     */
1207    setExposureBias(exposureBias: number): Promise<void>;
1208
1209    /**
1210     * Query the exposure value.
1211     * @param callback Callback used to return the exposure value.
1212     * @since 9
1213     * @syscap SystemCapability.Multimedia.Camera.Core
1214     */
1215    getExposureValue(callback: AsyncCallback<number>): void;
1216
1217    /**
1218     * Query the exposure value.
1219     * @return Promise used to return the exposure value.
1220     * @since 9
1221     * @syscap SystemCapability.Multimedia.Camera.Core
1222     */
1223    getExposureValue(): Promise<number>;
1224
1225      /**
1226     * Checks whether a specified focus mode is supported.
1227     * @param afMode Focus mode.
1228     * @param callback Callback used to return the device focus support status.
1229     * @since 9
1230     * @syscap SystemCapability.Multimedia.Camera.Core
1231     */
1232    isFocusModeSupported(afMode: FocusMode, callback: AsyncCallback<boolean>): void;
1233
1234    /**
1235     * Checks whether a specified focus mode is supported.
1236     * @param afMode Focus mode.
1237     * @return Promise used to return the focus mode support status.
1238     * @since 9
1239     * @syscap SystemCapability.Multimedia.Camera.Core
1240     */
1241    isFocusModeSupported(afMode: FocusMode): Promise<boolean>;
1242
1243    /**
1244     * Gets current focus mode.
1245     * @param callback Callback used to return the current focus mode.
1246     * @since 9
1247     * @syscap SystemCapability.Multimedia.Camera.Core
1248     */
1249    getFocusMode(callback: AsyncCallback<FocusMode>): void;
1250
1251    /**
1252     * Gets current focus mode.
1253     * @return Promise used to return the focus mode.
1254     * @since 9
1255     * @syscap SystemCapability.Multimedia.Camera.Core
1256     */
1257    getFocusMode(): Promise<FocusMode>;
1258
1259    /**
1260     * Sets focus mode.
1261     * @param afMode Target focus mode.
1262     * @param callback Callback used to return the result.
1263     * @since 9
1264     * @syscap SystemCapability.Multimedia.Camera.Core
1265     */
1266    setFocusMode(afMode: FocusMode, callback: AsyncCallback<void>): void;
1267
1268    /**
1269     * Sets focus mode.
1270     * @param afMode Target focus mode.
1271     * @return Promise used to return the result.
1272     * @since 9
1273     * @syscap SystemCapability.Multimedia.Camera.Core
1274     */
1275    setFocusMode(afMode: FocusMode): Promise<void>;
1276
1277    /**
1278     * Sets focus point.
1279     * @param point Target focus point.
1280     * @param callback Callback used to return the result.
1281     * @since 9
1282     * @syscap SystemCapability.Multimedia.Camera.Core
1283     */
1284    setFocusPoint(point: Point, callback: AsyncCallback<void>): void;
1285
1286    /**
1287     * Sets focus point.
1288     * @param afMode Target focus point.
1289     * @return Promise used to return the result.
1290     * @since 9
1291     * @syscap SystemCapability.Multimedia.Camera.Core
1292     */
1293    setFocusPoint(point: Point): Promise<void>;
1294
1295    /**
1296     * Gets current focus point.
1297     * @param callback Callback used to return the current focus point.
1298     * @since 9
1299     * @syscap SystemCapability.Multimedia.Camera.Core
1300     */
1301    getFocusPoint(callback: AsyncCallback<Point>): void;
1302
1303    /**
1304     * Gets current focus point.
1305     * @return Promise used to return the current focus point.
1306     * @since 9
1307     * @syscap SystemCapability.Multimedia.Camera.Core
1308     */
1309    getFocusPoint(): Promise<Point>;
1310
1311    /**
1312     * Gets current focal length.
1313     * @param callback Callback used to return the current focal point.
1314     * @since 9
1315     * @syscap SystemCapability.Multimedia.Camera.Core
1316     */
1317    getFocalLength(callback: AsyncCallback<number>): void;
1318
1319    /**
1320     * Gets current focal length.
1321     * @return Promise used to return the current focal point.
1322     * @since 9
1323     * @syscap SystemCapability.Multimedia.Camera.Core
1324     */
1325    getFocalLength(): Promise<number>;
1326
1327    /**
1328     * Gets all supported zoom ratio range.
1329     * @param callback Callback used to return the zoom ratio range.
1330     * @since 9
1331     * @syscap SystemCapability.Multimedia.Camera.Core
1332     */
1333    getZoomRatioRange(callback: AsyncCallback<Array<number>>): void;
1334
1335    /**
1336     * Gets all supported zoom ratio range.
1337     * @return Promise used to return the zoom ratio range.
1338     * @since 9
1339     * @syscap SystemCapability.Multimedia.Camera.Core
1340     */
1341    getZoomRatioRange(): Promise<Array<number>>;
1342
1343    /**
1344     * Gets zoom ratio.
1345     * @param callback Callback used to return the current zoom ratio value.
1346     * @since 9
1347     * @syscap SystemCapability.Multimedia.Camera.Core
1348     */
1349    getZoomRatio(callback: AsyncCallback<number>): void;
1350
1351    /**
1352     * Gets zoom ratio.
1353     * @return Promise used to return the zoom ratio value.
1354     * @since 9
1355     * @syscap SystemCapability.Multimedia.Camera.Core
1356     */
1357    getZoomRatio(): Promise<number>;
1358
1359    /**
1360     * Sets zoom ratio.
1361     * @param zoomRatio Target zoom ratio.
1362     * @param callback Callback used to return the result.
1363     * @since 9
1364     * @syscap SystemCapability.Multimedia.Camera.Core
1365     */
1366    setZoomRatio(zoomRatio: number, callback: AsyncCallback<void>): void;
1367
1368    /**
1369     * Sets zoom ratio.
1370     * @param zoomRatio Target zoom ratio.
1371     * @return Promise used to return the result.
1372     * @since 9
1373     * @syscap SystemCapability.Multimedia.Camera.Core
1374     */
1375    setZoomRatio(zoomRatio: number): Promise<void>;
1376
1377    /**
1378     * Check whether the specified video stabilization mode is supported.
1379     * @param vsMode Video Stabilization mode.
1380     * @param callback Callback used to return if video stablization mode is supported.
1381     * @since 9
1382     * @syscap SystemCapability.Multimedia.Camera.Core
1383     */
1384    isVideoStabilizationModeSupported(vsMode: VideoStabilizationMode, callback: AsyncCallback<boolean>): void;
1385
1386    /**
1387     * Check whether the specified video stabilization mode is supported.
1388     * @param callback Callback used to return if video stablization mode is supported.
1389     * @return Promise used to return flash mode support status.
1390     * @since 9
1391     * @syscap SystemCapability.Multimedia.Camera.Core
1392     */
1393    isVideoStabilizationModeSupported(vsMode: VideoStabilizationMode): Promise<boolean>;
1394
1395    /**
1396     * Query the video stabilization mode currently in use.
1397     * @param callback Callback used to return the current video stabilization mode.
1398     * @since 9
1399     * @syscap SystemCapability.Multimedia.Camera.Core
1400     */
1401    getActiveVideoStabilizationMode(callback: AsyncCallback<VideoStabilizationMode>): void;
1402
1403    /**
1404     * Query the video stabilization mode currently in use.
1405     * @return Promise used to return the current video stabilization mode.
1406     * @since 9
1407     * @syscap SystemCapability.Multimedia.Camera.Core
1408     */
1409    getActiveVideoStabilizationMode(): Promise<VideoStabilizationMode>;
1410
1411    /**
1412     * Set video stabilization mode.
1413     * @param mode video stabilization mode to set.
1414     * @param callback Callback used to return the result.
1415     * @since 9
1416     * @syscap SystemCapability.Multimedia.Camera.Core
1417     */
1418    setVideoStabilizationMode(mode: VideoStabilizationMode, callback: AsyncCallback<void>): void;
1419
1420    /**
1421     * Set video stabilization mode.
1422     * @param mode video stabilization mode to set.
1423     * @return Promise used to return the result.
1424     * @since 9
1425     * @syscap SystemCapability.Multimedia.Camera.Core
1426     */
1427    setVideoStabilizationMode(mode: VideoStabilizationMode): Promise<void>;
1428
1429    /**
1430     * Subscribes focus status change event callback.
1431     * @param type Event type.
1432     * @param callback Callback used to get the focus state change.
1433     * @since 9
1434     * @syscap SystemCapability.Multimedia.Camera.Core
1435     */
1436    on(type: 'focusStateChange', callback: AsyncCallback<FocusState>): void;
1437
1438    /**
1439     * Subscribes error event callback.
1440     * @param type Event type.
1441     * @param callback Callback used to get the capture session errors.
1442     * @since 9
1443     * @syscap SystemCapability.Multimedia.Camera.Core
1444     */
1445    on(type: 'error', callback: ErrorCallback<CaptureSessionError>): void;
1446  }
1447
1448  /**
1449   * Enum for CaptureSession error code.
1450   * @since 9
1451   * @syscap SystemCapability.Multimedia.Camera.Core
1452   */
1453  enum CaptureSessionErrorCode {
1454    /**
1455     * Unknown error.
1456     * @since 9
1457     */
1458    ERROR_UNKNOWN = -1,
1459    /**
1460     * Insufficient resources.
1461     * @since 9
1462     */
1463    ERROR_INSUFFICIENT_RESOURCES = 0,
1464    /**
1465     * Timeout error.
1466     * @since 9
1467     */
1468    ERROR_TIMEOUT = 1,
1469  }
1470
1471  /**
1472   * Capture session error object.
1473   * @since 9
1474   * @syscap SystemCapability.Multimedia.Camera.Core
1475   */
1476  interface CaptureSessionError extends Error {
1477    code: CaptureSessionErrorCode;
1478  }
1479
1480  /**
1481   * Camera output object.
1482   * @since 9
1483   * @syscap SystemCapability.Multimedia.Camera.Core
1484   */
1485  interface CameraOutput {
1486    /**
1487     * Release output instance.
1488     * @param callback Callback used to return the result.
1489     * @since 9
1490     * @syscap SystemCapability.Multimedia.Camera.Core
1491     */
1492    release(callback: AsyncCallback<void>): void;
1493
1494    /**
1495     * Release output instance.
1496     * @return Promise used to return the result.
1497     * @since 9
1498     * @syscap SystemCapability.Multimedia.Camera.Core
1499     */
1500    release(): Promise<void>;
1501  }
1502
1503  /**
1504   * Preview output object.
1505   * @since 9
1506   * @syscap SystemCapability.Multimedia.Camera.Core
1507   */
1508  interface PreviewOutput extends CameraOutput {
1509    /**
1510     * Start output instance.
1511     * @param callback Callback used to return the result.
1512     * @since 9
1513     * @syscap SystemCapability.Multimedia.Camera.Core
1514     */
1515    start(callback: AsyncCallback<void>): void;
1516
1517    /**
1518     * Start output instance.
1519     * @return Promise used to return the result.
1520     * @since 9
1521     * @syscap SystemCapability.Multimedia.Camera.Core
1522     */
1523    start(): Promise<void>;
1524
1525    /**
1526     * Stop output instance.
1527     * @param callback Callback used to return the result.
1528     * @since 9
1529     * @syscap SystemCapability.Multimedia.Camera.Core
1530     */
1531    stop(callback: AsyncCallback<void>): void;
1532
1533    /**
1534     * Stop output instance.
1535     * @return Promise used to return the result.
1536     * @since 9
1537     * @syscap SystemCapability.Multimedia.Camera.Core
1538     */
1539    stop(): Promise<void>;
1540
1541    /**
1542     * Subscribes frame start event callback.
1543     * @param type Event type.
1544     * @param callback Callback used to return the result.
1545     * @since 9
1546     * @syscap SystemCapability.Multimedia.Camera.Core
1547     */
1548    on(type: 'frameStart', callback: AsyncCallback<void>): void;
1549
1550    /**
1551     * Subscribes frame end event callback.
1552     * @param type Event type.
1553     * @param callback Callback used to return the result.
1554     * @since 9
1555     * @syscap SystemCapability.Multimedia.Camera.Core
1556     */
1557    on(type: 'frameEnd', callback: AsyncCallback<void>): void;
1558
1559    /**
1560     * Subscribes error event callback.
1561     * @param type Event type.
1562     * @param callback Callback used to get the preview output errors.
1563     * @since 9
1564     * @syscap SystemCapability.Multimedia.Camera.Core
1565     */
1566    on(type: 'error', callback: ErrorCallback<PreviewOutputError>): void;
1567  }
1568
1569  /**
1570   * Enum for preview output error code.
1571   * @since 9
1572   * @syscap SystemCapability.Multimedia.Camera.Core
1573   */
1574  enum PreviewOutputErrorCode {
1575    /**
1576     * Unknown error.
1577     * @since 9
1578     */
1579    ERROR_UNKNOWN = -1,
1580  }
1581
1582  /**
1583   * Preview output error object.
1584   * @since 9
1585   * @syscap SystemCapability.Multimedia.Camera.Core
1586   */
1587  interface PreviewOutputError extends Error {
1588    code: PreviewOutputErrorCode;
1589  }
1590
1591  /**
1592   * Enumerates the image rotation angles.
1593   * @since 9
1594   * @syscap SystemCapability.Multimedia.Camera.Core
1595   */
1596  enum ImageRotation {
1597    /**
1598     * The capture image rotates 0 degrees.
1599     * @since 9
1600     * @syscap SystemCapability.Multimedia.Camera.Core
1601     */
1602    ROTATION_0 = 0,
1603
1604    /**
1605     * The capture image rotates 90 degrees.
1606     * @since 9
1607     * @syscap SystemCapability.Multimedia.Camera.Core
1608     */
1609    ROTATION_90 = 90,
1610
1611    /**
1612     * The capture image rotates 180 degrees.
1613     * @since 9
1614     * @syscap SystemCapability.Multimedia.Camera.Core
1615     */
1616    ROTATION_180 = 180,
1617
1618    /**
1619     * The capture image rotates 270 degrees.
1620     * @since 9
1621     * @syscap SystemCapability.Multimedia.Camera.Core
1622     */
1623    ROTATION_270 = 270
1624  }
1625
1626  interface Location {
1627    /**
1628     * Latitude.
1629     * @since 9
1630     */
1631    latitude: number;
1632
1633    /**
1634     * Longitude.
1635     * @since 9
1636     */
1637    longitude: number;
1638
1639    /**
1640     * Altitude.
1641     * @since 9
1642     */
1643    altitude: number;
1644  }
1645
1646  /**
1647   * Enumerates the image quality levels.
1648   * @since 9
1649   * @syscap SystemCapability.Multimedia.Camera.Core
1650   */
1651  enum QualityLevel {
1652    /**
1653     * High image quality.
1654     * @since 9
1655     * @syscap SystemCapability.Multimedia.Camera.Core
1656     */
1657    QUALITY_LEVEL_HIGH = 0,
1658
1659    /**
1660     * Medium image quality.
1661     * @since 9
1662     * @syscap SystemCapability.Multimedia.Camera.Core
1663     */
1664    QUALITY_LEVEL_MEDIUM = 1,
1665
1666    /**
1667     * Low image quality.
1668     * @since 9
1669     * @syscap SystemCapability.Multimedia.Camera.Core
1670     */
1671    QUALITY_LEVEL_LOW = 2
1672  }
1673
1674  /**
1675   * Photo capture options to set.
1676   * @since 9
1677   */
1678  interface PhotoCaptureSetting {
1679    /**
1680     * Photo image quality.
1681     * @since 9
1682     * @syscap SystemCapability.Multimedia.Camera.Core
1683     */
1684    quality?: QualityLevel;
1685
1686    /**
1687     * Photo rotation.
1688     * @since 9
1689     * @syscap SystemCapability.Multimedia.Camera.Core
1690     */
1691    rotation?: ImageRotation;
1692
1693    /**
1694     * Photo location.
1695     * @since 9
1696     * @syscap SystemCapability.Multimedia.Camera.Core
1697     */
1698    location?: Location;
1699
1700    /**
1701     * Set the mirror photo function switch, default to false.
1702     * @since 9
1703     * @syscap SystemCapability.Multimedia.Camera.Core
1704     */
1705    mirror?: boolean;
1706  }
1707
1708  /**
1709   * Photo output object.
1710   * @since 9
1711   * @syscap SystemCapability.Multimedia.Camera.Core
1712   */
1713  interface PhotoOutput extends CameraOutput {
1714    /**
1715     * Start capture output.
1716     * @param callback Callback used to return the result.
1717     * @since 9
1718     * @syscap SystemCapability.Multimedia.Camera.Core
1719     */
1720    capture(callback: AsyncCallback<void>): void;
1721
1722    /**
1723     * Start capture output.
1724     * @param setting Photo capture settings.
1725     * @param callback Callback used to return the result.
1726     * @since 9
1727     * @syscap SystemCapability.Multimedia.Camera.Core
1728     */
1729    capture(setting: PhotoCaptureSetting, callback: AsyncCallback<void>): void;
1730
1731    /**
1732     * Start capture output.
1733     * @param setting Photo capture settings.
1734     * @return Promise used to return the result.
1735     * @since 9
1736     * @syscap SystemCapability.Multimedia.Camera.Core
1737     */
1738    capture(setting?: PhotoCaptureSetting): Promise<void>;
1739
1740    /**
1741     * Check whether to support mirror photo.
1742     * @param callback Callback used to return the mirror support status.
1743     * @since 9
1744     * @syscap SystemCapability.Multimedia.Camera.Core
1745     */
1746    isMirrorSupported(callback: AsyncCallback<boolean>): void;
1747
1748    /**
1749     * Check whether to support mirror photo.
1750     * @return Promise used to return the mirror support status.
1751     * @since 9
1752     * @syscap SystemCapability.Multimedia.Camera.Core
1753     */
1754    isMirrorSupported(): Promise<boolean>;
1755
1756    /**
1757     * Subscribes capture start event callback.
1758     * @param type Event type.
1759     * @param callback Callback used to get the capture ID.
1760     * @since 9
1761     * @syscap SystemCapability.Multimedia.Camera.Core
1762     */
1763    on(type: 'captureStart', callback: AsyncCallback<number>): void;
1764
1765    /**
1766     * Subscribes frame shutter event callback.
1767     * @param type Event type.
1768     * @param callback Callback used to get the frame shutter information.
1769     * @since 9
1770     * @syscap SystemCapability.Multimedia.Camera.Core
1771     */
1772    on(type: 'frameShutter', callback: AsyncCallback<FrameShutterInfo>): void;
1773
1774    /**
1775     * Subscribes capture end event callback.
1776     * @param type Event type.
1777     * @param callback Callback used to get the capture end information.
1778     * @since 9
1779     * @syscap SystemCapability.Multimedia.Camera.Core
1780     */
1781    on(type: 'captureEnd', callback: AsyncCallback<CaptureEndInfo>): void;
1782
1783    /**
1784     * Subscribes error event callback.
1785     * @param type Event type.
1786     * @param callback Callback used to get the photo output errors.
1787     * @since 9
1788     * @syscap SystemCapability.Multimedia.Camera.Core
1789     */
1790    on(type: 'error', callback: ErrorCallback<PhotoOutputError>): void;
1791  }
1792
1793  /**
1794   * Frame shutter callback info.
1795   * @since 9
1796   * @syscap SystemCapability.Multimedia.Camera.Core
1797   */
1798  interface FrameShutterInfo {
1799    /**
1800     * Capture id.
1801     * @since 9
1802     * @syscap SystemCapability.Multimedia.Camera.Core
1803     */
1804    captureId: number;
1805    /**
1806     * Timestamp for frame.
1807     * @since 9
1808     * @syscap SystemCapability.Multimedia.Camera.Core
1809     */
1810    timestamp: number;
1811  }
1812
1813  /**
1814   * Capture end info.
1815   * @since 9
1816   * @syscap SystemCapability.Multimedia.Camera.Core
1817   */
1818  interface CaptureEndInfo {
1819    /**
1820     * Capture id.
1821     * @since 9
1822     * @syscap SystemCapability.Multimedia.Camera.Core
1823     */
1824    captureId: number;
1825    /**
1826     * Frame count.
1827     * @since 9
1828     * @syscap SystemCapability.Multimedia.Camera.Core
1829     */
1830    frameCount: number;
1831  }
1832
1833  /**
1834   * Enum for photo output error code.
1835   * @since 9
1836   * @syscap SystemCapability.Multimedia.Camera.Core
1837   */
1838  enum PhotoOutputErrorCode {
1839    /**
1840     * Unknown error.
1841     * @since 9
1842     */
1843    ERROR_UNKNOWN = -1,
1844    /**
1845     * Driver error.
1846     * @since 9
1847     */
1848    ERROR_DRIVER_ERROR = 0,
1849    /**
1850     * Insufficient resources.
1851     * @since 9
1852     */
1853    ERROR_INSUFFICIENT_RESOURCES = 1,
1854    /**
1855     * Timeout error.
1856     * @since 9
1857     */
1858    ERROR_TIMEOUT = 2
1859  }
1860
1861  /**
1862   * Photo output error object.
1863   * @since 9
1864   * @syscap SystemCapability.Multimedia.Camera.Core
1865   */
1866  interface PhotoOutputError extends Error {
1867    code: PhotoOutputErrorCode;
1868  }
1869
1870  /**
1871   * Video output object.
1872   * @since 9
1873   * @syscap SystemCapability.Multimedia.Camera.Core
1874   */
1875  interface VideoOutput extends CameraOutput {
1876    /**
1877     * Start video output.
1878     * @param callback Callback used to return the result.
1879     * @since 9
1880     * @syscap SystemCapability.Multimedia.Camera.Core
1881     */
1882    start(callback: AsyncCallback<void>): void;
1883
1884    /**
1885     * Start video output.
1886     * @return Promise used to return the result.
1887     * @since 9
1888     * @syscap SystemCapability.Multimedia.Camera.Core
1889     */
1890    start(): Promise<void>;
1891
1892    /**
1893     * Stop video output.
1894     * @param callback Callback used to return the result.
1895     * @since 9
1896     * @syscap SystemCapability.Multimedia.Camera.Core
1897     */
1898    stop(callback: AsyncCallback<void>): void;
1899
1900    /**
1901     * Stop video output.
1902     * @return Promise used to return the result.
1903     * @since 9
1904     * @syscap SystemCapability.Multimedia.Camera.Core
1905     */
1906    stop(): Promise<void>;
1907
1908    /**
1909     * Subscribes frame start event callback.
1910     * @param type Event type.
1911     * @param callback Callback used to return the result.
1912     * @since 9
1913     * @syscap SystemCapability.Multimedia.Camera.Core
1914     */
1915    on(type: 'frameStart', callback: AsyncCallback<void>): void;
1916
1917    /**
1918     * Subscribes frame end event callback.
1919     * @param type Event type.
1920     * @param callback Callback used to return the result.
1921     * @since 9
1922     * @syscap SystemCapability.Multimedia.Camera.Core
1923     */
1924    on(type: 'frameEnd', callback: AsyncCallback<void>): void;
1925
1926    /**
1927     * Subscribes error event callback.
1928     * @param type Event type.
1929     * @param callback Callback used to get the video output errors.
1930     * @since 9
1931     * @syscap SystemCapability.Multimedia.Camera.Core
1932     */
1933    on(type: 'error', callback: ErrorCallback<VideoOutputError>): void;
1934  }
1935
1936  /**
1937   * Enum for video output error code.
1938   * @since 9
1939   * @syscap SystemCapability.Multimedia.Camera.Core
1940   */
1941  enum VideoOutputErrorCode {
1942    /**
1943     * Unknown error.
1944     * @since 9
1945     */
1946    ERROR_UNKNOWN = -1,
1947    /**
1948     * Driver error.
1949     * @since 9
1950     */
1951    ERROR_DRIVER_ERROR = 0
1952  }
1953
1954  /**
1955   * Video output error object.
1956   * @since 9
1957   * @syscap SystemCapability.Multimedia.Camera.Core
1958   */
1959  interface VideoOutputError extends Error {
1960    code: VideoOutputErrorCode;
1961  }
1962
1963  /**
1964   * Metadata object type.
1965   * @since 9
1966   * @syscap SystemCapability.Multimedia.Camera.Core
1967   */
1968  enum MetadataObjectType {
1969    FACE_DETECTION = 0
1970  }
1971
1972  /**
1973   * Rectangle definition.
1974   * @since 9
1975   * @syscap SystemCapability.Multimedia.Camera.Core
1976   */
1977  interface Rect {
1978    /**
1979     * X coordinator of top left point.
1980     * @param Promise used to return the result.
1981     * @since 9
1982     * @syscap SystemCapability.Multimedia.Camera.Core
1983     */
1984    topLeftX: number;
1985    /**
1986     * Y coordinator of top left point.
1987     * @param Promise used to return the result.
1988     * @since 9
1989     * @syscap SystemCapability.Multimedia.Camera.Core
1990     */
1991    topLeftY: number;
1992    /**
1993     * Width of this rectangle.
1994     * @since 9
1995     * @syscap SystemCapability.Multimedia.Camera.Core
1996     */
1997    width: number;
1998    /**
1999     * Height of this rectangle.
2000     * @since 9
2001     * @syscap SystemCapability.Multimedia.Camera.Core
2002     */
2003    height: number;
2004  }
2005
2006  /**
2007   * Metadata object basis.
2008   * @since 9
2009   * @syscap SystemCapability.Multimedia.Camera.Core
2010   */
2011  interface MetadataObject {
2012    /**
2013     * Get current metadata object type.
2014     * @param callback Callback used to return the result.
2015     * @since 9
2016     * @syscap SystemCapability.Multimedia.Camera.Core
2017     */
2018    getType(callback: AsyncCallback<MetadataObjectType>): void;
2019
2020    /**
2021     * Get current metadata object type.
2022     * @param Promise used to return the result.
2023     * @since 9
2024     * @syscap SystemCapability.Multimedia.Camera.Core
2025     */
2026    getType(): Promise<MetadataObjectType>;
2027
2028    /**
2029     * Get current metadata object timestamp in milliseconds.
2030     * @param callback Callback used to return the result.
2031     * @since 9
2032     * @syscap SystemCapability.Multimedia.Camera.Core
2033     */
2034    getTimestamp(callback: AsyncCallback<number>): void;
2035
2036    /**
2037     * Get current metadata object timestamp in milliseconds.
2038     * @param Promise used to return the result.
2039     * @since 9
2040     * @syscap SystemCapability.Multimedia.Camera.Core
2041     */
2042    getTimestamp(): Promise<number>;
2043
2044    /**
2045     * Get the axis-aligned bounding box of detected metadata object.
2046     * @param callback Callback used to return the result.
2047     * @since 9
2048     * @syscap SystemCapability.Multimedia.Camera.Core
2049     */
2050    getBoundingBox(callback: AsyncCallback<Rect>): void;
2051
2052    /**
2053     * Get the axis-aligned bounding box of detected metadata object.
2054     * @param Promise used to return the result.
2055     * @since 9
2056     * @syscap SystemCapability.Multimedia.Camera.Core
2057     */
2058    getBoundingBox(): Promise<Rect>;
2059  }
2060
2061  /**
2062   * Metadata face object.
2063   * @since 9
2064   * @syscap SystemCapability.Multimedia.Camera.Core
2065   */
2066  interface MetadataFaceObject extends MetadataObject {
2067  }
2068
2069  /**
2070   * Metadata Output object
2071   * @since 9
2072   * @syscap SystemCapability.Multimedia.Camera.Core
2073   */
2074  interface MetadataOutput extends CameraOutput {
2075    /**
2076     * Start output metadata
2077     * @param callback Callback used to return the result.
2078     * @since 9
2079     * @syscap SystemCapability.Multimedia.Camera.Core
2080     */
2081    start(callback: AsyncCallback<void>): void;
2082
2083    /**
2084     * Start output metadata
2085     * @return Promise used to return the result.
2086     * @since 9
2087     * @syscap SystemCapability.Multimedia.Camera.Core
2088     */
2089    start(): Promise<void>;
2090
2091    /**
2092     * Stop output metadata
2093     * @param callback Callback used to return the result.
2094     * @since 9
2095     * @syscap SystemCapability.Multimedia.Camera.Core
2096     */
2097    stop(callback: AsyncCallback<void>): void;
2098
2099    /**
2100     * Stop output metadata
2101     * @return Promise used to return the result.
2102     * @since 9
2103     * @syscap SystemCapability.Multimedia.Camera.Core
2104     */
2105    stop(): Promise<void>;
2106
2107    /**
2108     * Subscribes to metadata objects available event callback.
2109     * @param type Event type.
2110     * @param callback Callback used to get the available metadata objects.
2111     * @since 9
2112     * @syscap SystemCapability.Multimedia.Camera.Core
2113     */
2114    on(type: 'metadataObjectsAvailable', callback: AsyncCallback<Array<MetadataObject>>): void;
2115
2116    /**
2117     * Subscribes error event callback.
2118     * @param type Event type.
2119     * @param callback Callback used to get the video output errors.
2120     * @since 9
2121     * @syscap SystemCapability.Multimedia.Camera.Core
2122     */
2123    on(type: 'error', callback: ErrorCallback<MetadataOutputError>): void;
2124  }
2125
2126  /**
2127   * Enum for metadata output error code.
2128   * @since 9
2129   * @syscap SystemCapability.Multimedia.Camera.Core
2130   */
2131  enum MetadataOutputErrorCode {
2132    /**
2133     * Unknown errors.
2134     * @since 9
2135     */
2136    ERROR_UNKNOWN = -1,
2137    /**
2138     * Insufficient resources.
2139     * @since 9
2140     */
2141    ERROR_INSUFFICIENT_RESOURCES = 0
2142  }
2143
2144  /**
2145   * Metadata output error object.
2146   * @since 9
2147   * @syscap SystemCapability.Multimedia.Camera.Core
2148   */
2149  interface MetadataOutputError extends Error {
2150    code: MetadataOutputErrorCode;
2151  }
2152}
2153
2154export default camera;
2155