• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2* Copyright (C) 2021 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, Callback} from './basic';
17
18/**
19 * @name audio
20 * @since 7
21 * @import import audio from '@ohos.multimedia.audio'
22 */
23declare namespace audio {
24
25  /**
26   * Obtains an AudioManager instance.
27   * @return AudioManager object.
28   * @since 7
29   * @syscap SystemCapability.Multimedia.Audio.Core
30   */
31  function getAudioManager(): AudioManager;
32
33  /**
34   * Obtains an AudioCapturer instance. This method uses an asynchronous callback to return the capturer instance.
35   * @param options Capturer configurations.
36   * @param callback Callback used to return the audio capturer instance.
37   * @since 8
38   * @syscap SystemCapability.Multimedia.Audio.Capturer
39   */
40  function createAudioCapturer(options: AudioCapturerOptions, callback: AsyncCallback<AudioCapturer>): void;
41
42  /**
43   * Obtains an AudioCapturer instance. This method uses a promise to return the capturer instance.
44   * @param options Capturer configurations.
45   * @return Promise used to return the audio capturer instance.
46   * @since 8
47   * @syscap SystemCapability.Multimedia.Audio.Capturer
48   */
49  function createAudioCapturer(options: AudioCapturerOptions): Promise<AudioCapturer>;
50
51  /**
52   * Obtains an AudioRenderer instance. This method uses an asynchronous callback to return the renderer instance.
53   * @param options Renderer configurations.
54   * @param callback Callback used to return the audio renderer instance.
55   * @since 8
56   * @syscap SystemCapability.Multimedia.Audio.Renderer
57   */
58  function createAudioRenderer(options: AudioRendererOptions, callback: AsyncCallback<AudioRenderer>): void;
59
60  /**
61   * Obtains an AudioRenderer instance. This method uses a promise to return the renderer instance.
62   * @param options Renderer configurations.
63   * @return Promise used to return the audio renderer instance.
64   * @since 8
65   * @syscap SystemCapability.Multimedia.Audio.Renderer
66   */
67  function createAudioRenderer(options: AudioRendererOptions): Promise<AudioRenderer>;
68
69  /**
70   * Enumerates the audio states.
71   * @since 8
72   * @syscap SystemCapability.Multimedia.Audio.Core
73   */
74  enum AudioState {
75    /**
76     * Invalid state.
77     * @since 8
78     * @syscap SystemCapability.Multimedia.Audio.Core
79     */
80    STATE_INVALID = -1,
81    /**
82     * Create new instance state.
83     * @since 8
84     * @syscap SystemCapability.Multimedia.Audio.Core
85     */
86    STATE_NEW,
87    /**
88     * Prepared state.
89     * @since 8
90     * @syscap SystemCapability.Multimedia.Audio.Core
91     */
92    STATE_PREPARED,
93    /**
94     * Running state.
95     * @since 8
96     * @syscap SystemCapability.Multimedia.Audio.Core
97     */
98    STATE_RUNNING,
99    /**
100     * Stopped state.
101     * @since 8
102     * @syscap SystemCapability.Multimedia.Audio.Core
103     */
104    STATE_STOPPED,
105    /**
106     * Released state.
107     * @since 8
108     * @syscap SystemCapability.Multimedia.Audio.Core
109     */
110    STATE_RELEASED,
111    /**
112     * Paused state.
113     * @since 8
114     * @syscap SystemCapability.Multimedia.Audio.Core
115     */
116    STATE_PAUSED
117  }
118
119  /**
120   * Enumerates audio stream types.
121   * @since 7
122   * @syscap SystemCapability.Multimedia.Audio.Volume
123   */
124  enum AudioVolumeType {
125    /**
126     * Audio streams for voice calls.
127     * @since 8
128     * @syscap SystemCapability.Multimedia.Audio.Volume
129     */
130    VOICE_CALL = 0,
131    /**
132     * Audio streams for ringtones.
133     * @since 7
134     * @syscap SystemCapability.Multimedia.Audio.Volume
135     */
136    RINGTONE = 2,
137    /**
138     * Audio streams for media purpose.
139     * @since 7
140     * @syscap SystemCapability.Multimedia.Audio.Volume
141     */
142    MEDIA = 3,
143    /**
144     * Audio stream for voice assistant.
145     * @since 8
146     * @syscap SystemCapability.Multimedia.Audio.Volume
147     */
148    VOICE_ASSISTANT = 9,
149  }
150
151  /**
152   * Enumerates audio device flags.
153   * @since 7
154   * @syscap SystemCapability.Multimedia.Audio.Device
155   */
156  enum DeviceFlag {
157    /**
158     * Output devices.
159     * @since 7
160     * @syscap SystemCapability.Multimedia.Audio.Device
161     */
162    OUTPUT_DEVICES_FLAG = 1,
163    /**
164     * Input devices.
165     * @since 7
166     * @syscap SystemCapability.Multimedia.Audio.Device
167     */
168    INPUT_DEVICES_FLAG = 2,
169    /**
170     * All devices.
171     * @since 7
172     * @syscap SystemCapability.Multimedia.Audio.Device
173     */
174    ALL_DEVICES_FLAG = 3,
175  }
176
177  /**
178   * Enumerates device roles.
179   * @since 7
180   * @syscap SystemCapability.Multimedia.Audio.Device
181   */
182  enum DeviceRole {
183    /**
184     * Input role.
185     * @since 7
186     * @syscap SystemCapability.Multimedia.Audio.Device
187     */
188    INPUT_DEVICE = 1,
189    /**
190     * Output role.
191     * @since 7
192     * @syscap SystemCapability.Multimedia.Audio.Device
193     */
194    OUTPUT_DEVICE = 2,
195  }
196
197  /**
198   * Enumerates device types.
199   * @since 7
200   * @syscap SystemCapability.Multimedia.Audio.Device
201   */
202  enum DeviceType {
203    /**
204     * Invalid device.
205     * @since 7
206     * @syscap SystemCapability.Multimedia.Audio.Device
207     */
208    INVALID = 0,
209    /**
210     * Built-in earpiece.
211     * @since 7
212     * @syscap SystemCapability.Multimedia.Audio.Device
213     */
214    EARPIECE = 1,
215    /**
216     * Built-in speaker.
217     * @since 7
218     * @syscap SystemCapability.Multimedia.Audio.Device
219     */
220    SPEAKER = 2,
221    /**
222     * Wired headset, which is a combination of a pair of earpieces and a microphone.
223     * @since 7
224     * @syscap SystemCapability.Multimedia.Audio.Device
225     */
226    WIRED_HEADSET = 3,
227    /**
228     * A pair of wired headphones.
229     * @since 7
230     * @syscap SystemCapability.Multimedia.Audio.Device
231     */
232    WIRED_HEADPHONES = 4,
233    /**
234     * Bluetooth device using the synchronous connection oriented link (SCO).
235     * @since 7
236     * @syscap SystemCapability.Multimedia.Audio.Device
237     */
238    BLUETOOTH_SCO = 7,
239    /**
240     * Bluetooth device using advanced audio distribution profile (A2DP).
241     * @since 7
242     * @syscap SystemCapability.Multimedia.Audio.Device
243     */
244    BLUETOOTH_A2DP = 8,
245    /**
246     * Built-in microphone.
247     * @since 7
248     * @syscap SystemCapability.Multimedia.Audio.Device
249     */
250    MIC = 15,
251    /**
252     * USB audio headset.
253     * @since 7
254     * @syscap SystemCapability.Multimedia.Audio.Device
255     */
256    USB_HEADSET = 22,
257  }
258
259  /**
260   * Enumerates the active device types.
261   * @since 7
262   * @syscap SystemCapability.Multimedia.Audio.Device
263   */
264   enum ActiveDeviceType {
265    /**
266     * Speaker.
267     * @since 7
268     * @syscap SystemCapability.Multimedia.Audio.Device
269     */
270    SPEAKER = 2,
271    /**
272     * Bluetooth device using the SCO link.
273     * @since 7
274     * @syscap SystemCapability.Multimedia.Audio.Device
275     */
276    BLUETOOTH_SCO = 7,
277  }
278
279  /**
280   * Enumerates ringer modes.
281   * @since 7
282   * @syscap SystemCapability.Multimedia.Audio.Communication
283   */
284  enum AudioRingMode {
285    /**
286     * Silent mode.
287     * @since 7
288     * @syscap SystemCapability.Multimedia.Audio.Communication
289     */
290    RINGER_MODE_SILENT = 0,
291    /**
292     * Vibration mode.
293     * @since 7
294     * @syscap SystemCapability.Multimedia.Audio.Communication
295     */
296    RINGER_MODE_VIBRATE = 1,
297    /**
298     * Normal mode.
299     * @since 7
300     * @syscap SystemCapability.Multimedia.Audio.Communication
301     */
302    RINGER_MODE_NORMAL = 2,
303  }
304
305  /**
306   * Enumerates the audio sample formats.
307   * @since 8
308   * @syscap SystemCapability.Multimedia.Audio.Core
309   */
310  enum AudioSampleFormat {
311    /**
312     * Invalid format.
313     * @since 8
314     * @syscap SystemCapability.Multimedia.Audio.Core
315     */
316    SAMPLE_FORMAT_INVALID = -1,
317    /**
318     * Unsigned 8 format.
319     * @since 8
320     * @syscap SystemCapability.Multimedia.Audio.Core
321     */
322    SAMPLE_FORMAT_U8 = 0,
323    /**
324     * Signed 16 bit integer, little endian.
325     * @since 8
326     * @syscap SystemCapability.Multimedia.Audio.Core
327     */
328    SAMPLE_FORMAT_S16LE = 1,
329    /**
330     * Signed 24 bit integer, little endian.
331     * @since 8
332     * @syscap SystemCapability.Multimedia.Audio.Core
333     */
334    SAMPLE_FORMAT_S24LE = 2,
335    /**
336     * Signed 32 bit integer, little endian.
337     * @since 8
338     * @syscap SystemCapability.Multimedia.Audio.Core
339     */
340    SAMPLE_FORMAT_S32LE = 3,
341  }
342
343  /**
344   * Enumerates the audio channel.
345   * @since 8
346   * @syscap SystemCapability.Multimedia.Audio.Core
347   */
348  enum AudioChannel {
349    /**
350     * Channel 1.
351     * @since 8
352     * @syscap SystemCapability.Multimedia.Audio.Core
353     */
354    CHANNEL_1 = 0x1 << 0,
355    /**
356     * Channel 2.
357     * @since 8
358     * @syscap SystemCapability.Multimedia.Audio.Core
359     */
360    CHANNEL_2 = 0x1 << 1
361  }
362
363  /**
364   * Enumerates the audio sampling rate.
365   * @since 8
366   * @syscap SystemCapability.Multimedia.Audio.Core
367   */
368  enum AudioSamplingRate {
369    /**
370     * 8kHz sample rate.
371     * @since 8
372     * @syscap SystemCapability.Multimedia.Audio.Core
373     */
374    SAMPLE_RATE_8000 = 8000,
375    /**
376     * 11.025kHz sample rate.
377     * @since 8
378     * @syscap SystemCapability.Multimedia.Audio.Core
379     */
380    SAMPLE_RATE_11025 = 11025,
381    /**
382     * 12kHz sample rate.
383     * @since 8
384     * @syscap SystemCapability.Multimedia.Audio.Core
385     */
386    SAMPLE_RATE_12000 = 12000,
387    /**
388     * 16kHz sample rate.
389     * @since 8
390     * @syscap SystemCapability.Multimedia.Audio.Core
391     */
392    SAMPLE_RATE_16000 = 16000,
393    /**
394     * 22.05kHz sample rate.
395     * @since 8
396     * @syscap SystemCapability.Multimedia.Audio.Core
397     */
398    SAMPLE_RATE_22050 = 22050,
399    /**
400     * 24kHz sample rate.
401     * @since 8
402     * @syscap SystemCapability.Multimedia.Audio.Core
403     */
404    SAMPLE_RATE_24000 = 24000,
405    /**
406     * 32kHz sample rate.
407     * @since 8
408     * @syscap SystemCapability.Multimedia.Audio.Core
409     */
410    SAMPLE_RATE_32000 = 32000,
411    /**
412     * 44.1kHz sample rate.
413     * @since 8
414     * @syscap SystemCapability.Multimedia.Audio.Core
415     */
416    SAMPLE_RATE_44100 = 44100,
417    /**
418     * 48kHz sample rate.
419     * @since 8
420     * @syscap SystemCapability.Multimedia.Audio.Core
421     */
422    SAMPLE_RATE_48000 = 48000,
423    /**
424     * 64kHz sample rate.
425     * @since 8
426     * @syscap SystemCapability.Multimedia.Audio.Core
427     */
428    SAMPLE_RATE_64000 = 64000,
429    /**
430     * 96kHz sample rate.
431     * @since 8
432     * @syscap SystemCapability.Multimedia.Audio.Core
433     */
434    SAMPLE_RATE_96000 = 96000
435  }
436
437  /**
438   * Enumerates the audio encoding type.
439   * @since 8
440   * @syscap SystemCapability.Multimedia.Audio.Core
441   */
442  enum AudioEncodingType {
443    /**
444     * Invalid type.
445     * @since 8
446     * @syscap SystemCapability.Multimedia.Audio.Core
447     */
448    ENCODING_TYPE_INVALID = -1,
449    /**
450     * PCM encoding.
451     * @since 8
452     * @syscap SystemCapability.Multimedia.Audio.Core
453     */
454    ENCODING_TYPE_RAW = 0
455  }
456
457  /**
458   * Enumerates the audio content type.
459   * @since 7
460   * @syscap SystemCapability.Multimedia.Audio.Core
461   */
462  enum ContentType {
463    /**
464     * Unknown content.
465     * @since 7
466     * @syscap SystemCapability.Multimedia.Audio.Core
467     */
468    CONTENT_TYPE_UNKNOWN = 0,
469    /**
470     * Speech content.
471     * @since 7
472     * @syscap SystemCapability.Multimedia.Audio.Core
473     */
474    CONTENT_TYPE_SPEECH = 1,
475    /**
476     * Music content.
477     * @since 7
478     * @syscap SystemCapability.Multimedia.Audio.Core
479     */
480    CONTENT_TYPE_MUSIC = 2,
481    /**
482     * Movie content.
483     * @since 7
484     * @syscap SystemCapability.Multimedia.Audio.Core
485     */
486    CONTENT_TYPE_MOVIE = 3,
487    /**
488     * Notification content.
489     * @since 7
490     * @syscap SystemCapability.Multimedia.Audio.Core
491     */
492    CONTENT_TYPE_SONIFICATION = 4,
493    /**
494     * Ringtone content.
495     * @since 8
496     * @syscap SystemCapability.Multimedia.Audio.Core
497     */
498    CONTENT_TYPE_RINGTONE = 5,
499  }
500
501  /**
502   * Enumerates the stream usage.
503   * @since 7
504   * @syscap SystemCapability.Multimedia.Audio.Core
505   */
506  enum StreamUsage {
507    /**
508     * Unkown usage.
509     * @since 7
510     * @syscap SystemCapability.Multimedia.Audio.Core
511     */
512    STREAM_USAGE_UNKNOWN = 0,
513    /**
514     * Media usage.
515     * @since 7
516     * @syscap SystemCapability.Multimedia.Audio.Core
517     */
518    STREAM_USAGE_MEDIA = 1,
519    /**
520     * Voice communication usage.
521     * @since 7
522     * @syscap SystemCapability.Multimedia.Audio.Core
523     */
524    STREAM_USAGE_VOICE_COMMUNICATION = 2,
525    /**
526     * Notification or ringtone usage.
527     * @since 7
528     * @syscap SystemCapability.Multimedia.Audio.Core
529     */
530    STREAM_USAGE_NOTIFICATION_RINGTONE = 6
531  }
532
533  /**
534   * Describes audio stream information.
535   * @since 8
536   * @syscap SystemCapability.Multimedia.Audio.Core
537   */
538  interface AudioStreamInfo {
539    /**
540     * Sampling rate.
541     * @since 8
542     * @syscap SystemCapability.Multimedia.Audio.Core
543     */
544    samplingRate: AudioSamplingRate;
545    /**
546     * Audio channels.
547     * @since 8
548     * @syscap SystemCapability.Multimedia.Audio.Core
549     */
550    channels: AudioChannel;
551    /**
552     * Audio sample format.
553     * @since 8
554     * @syscap SystemCapability.Multimedia.Audio.Core
555     */
556    sampleFormat: AudioSampleFormat;
557    /**
558     * Audio encoding type.
559     * @since 8
560     * @syscap SystemCapability.Multimedia.Audio.Core
561     */
562    encodingType: AudioEncodingType;
563  }
564
565  /**
566   * Describes audio renderer information.
567   * @since 8
568   * @syscap SystemCapability.Multimedia.Audio.Core
569   */
570  interface AudioRendererInfo {
571    /**
572     * Content type.
573     * @since 8
574     * @syscap SystemCapability.Multimedia.Audio.Core
575     */
576    content: ContentType;
577    /**
578     * Stream usage.
579     * @since 8
580     * @syscap SystemCapability.Multimedia.Audio.Core
581     */
582    usage: StreamUsage;
583    /**
584     * Audio renderer flags.
585     * @since 8
586     * @syscap SystemCapability.Multimedia.Audio.Core
587     */
588    rendererFlags: number;
589  }
590
591  /**
592   * Describes audio renderer configuration options.
593   * @since 8
594   * @syscap SystemCapability.Multimedia.Audio.Renderer
595   */
596  interface AudioRendererOptions {
597    /**
598     * Stream information.
599     * @since 8
600     * @syscap SystemCapability.Multimedia.Audio.Renderer
601     */
602    streamInfo: AudioStreamInfo;
603    /**
604     * Renderer information.
605     * @since 8
606     * @syscap SystemCapability.Multimedia.Audio.Renderer
607     */
608    rendererInfo: AudioRendererInfo;
609  }
610
611  /**
612   * Enumerates the audio renderer rates.
613   * @since 8
614   * @syscap SystemCapability.Multimedia.Audio.Renderer
615   */
616  enum AudioRendererRate {
617    /**
618     * Normal rate.
619     * @since 8
620     * @syscap SystemCapability.Multimedia.Audio.Renderer
621     */
622    RENDER_RATE_NORMAL = 0,
623    /**
624     * Double rate.
625     * @since 8
626     * @syscap SystemCapability.Multimedia.Audio.Renderer
627     */
628    RENDER_RATE_DOUBLE = 1,
629    /**
630     * Half rate.
631     * @since 8
632     * @syscap SystemCapability.Multimedia.Audio.Renderer
633     */
634    RENDER_RATE_HALF = 2
635  }
636
637  /**
638   * Enumerates the interrupt types.
639   * @since 7
640   * @syscap SystemCapability.Multimedia.Audio.Renderer
641   */
642  enum InterruptType {
643    /**
644     * Audio playback interruption started.
645     * @since 7
646     * @syscap SystemCapability.Multimedia.Audio.Renderer
647     */
648    INTERRUPT_TYPE_BEGIN = 1,
649
650    /**
651     * Audio playback interruption ended.
652     * @since 7
653     * @syscap SystemCapability.Multimedia.Audio.Renderer
654     */
655    INTERRUPT_TYPE_END = 2
656  }
657
658  /**
659   * Enumerates the interrupt hints.
660   * @since 7
661   * @syscap SystemCapability.Multimedia.Audio.Renderer
662   */
663  enum InterruptHint {
664    /**
665     * None.
666     * @since 8
667     * @syscap SystemCapability.Multimedia.Audio.Renderer
668     */
669    INTERRUPT_HINT_NONE = 0,
670    /**
671     * Resume the playback.
672     * @since 7
673     * @syscap SystemCapability.Multimedia.Audio.Renderer
674     */
675    INTERRUPT_HINT_RESUME = 1,
676
677    /**
678     * Paused/Pause the playback.
679     * @since 7
680     * @syscap SystemCapability.Multimedia.Audio.Renderer
681     */
682    INTERRUPT_HINT_PAUSE = 2,
683
684    /**
685     * Stopped/Stop the playback.
686     * @since 7
687     * @syscap SystemCapability.Multimedia.Audio.Renderer
688     */
689    INTERRUPT_HINT_STOP = 3,
690
691    /**
692     * Ducked the playback. (In ducking, the audio volume is reduced, but not silenced.)
693     * @since 7
694     * @syscap SystemCapability.Multimedia.Audio.Renderer
695     */
696    INTERRUPT_HINT_DUCK = 4,
697
698    /**
699     * Unducked the playback.
700     * @since 8
701     * @syscap SystemCapability.Multimedia.Audio.Renderer
702     */
703    INTERRUPT_HINT_UNDUCK = 5,
704  }
705
706  /**
707   * Enumerates interrupt action types.
708   * @since 7
709   * @syscap SystemCapability.Multimedia.Audio.Renderer
710   */
711  enum InterruptActionType {
712
713    /**
714     * Focus gain event.
715     * @since 7
716     * @syscap SystemCapability.Multimedia.Audio.Renderer
717     */
718    TYPE_ACTIVATED = 0,
719
720    /**
721     * Audio interruption event.
722     * @since 7
723     * @syscap SystemCapability.Multimedia.Audio.Renderer
724     */
725    TYPE_INTERRUPT = 1
726  }
727
728  /**
729   * Enumerates device change types.
730   * @since 7
731   * @syscap SystemCapability.Multimedia.Audio.Device
732   */
733  enum DeviceChangeType {
734    /**
735     * Device connection.
736     * @since 7
737     * @syscap SystemCapability.Multimedia.Audio.Device
738     */
739    CONNECT = 0,
740
741    /**
742     * Device disconnection.
743     * @since 7
744     * @syscap SystemCapability.Multimedia.Audio.Device
745     */
746    DISCONNECT = 1,
747  }
748
749  /**
750   * Enumerates audio scenes.
751   * @since 8
752   * @syscap SystemCapability.Multimedia.Audio.Communication
753   */
754  enum AudioScene {
755    /**
756     * Default audio scene
757     * @since 8
758     * @syscap SystemCapability.Multimedia.Audio.Communication
759     */
760    AUDIO_SCENE_DEFAULT = 0,
761    /**
762     * Ringing audio scene
763     * @since 8
764     * @syscap SystemCapability.Multimedia.Audio.Communication
765     * @systemapi
766     */
767    AUDIO_SCENE_RINGING,
768    /**
769     * Phone call audio scene
770     * @since 8
771     * @syscap SystemCapability.Multimedia.Audio.Communication
772     * @systemapi
773     */
774    AUDIO_SCENE_PHONE_CALL,
775    /**
776     * Voice chat audio scene
777     * @since 8
778     * @syscap SystemCapability.Multimedia.Audio.Communication
779     */
780    AUDIO_SCENE_VOICE_CHAT
781  }
782
783  /**
784   * Implements audio volume and audio device management.
785   * @since 7
786   * @syscap SystemCapability.Multimedia.Audio.Core
787   */
788  interface AudioManager {
789    /**
790     * Sets the volume for a stream. This method uses an asynchronous callback to return the result.
791     * @param volumeType Audio stream type.
792     * @param volume Volume to set. The value range can be obtained by calling getMinVolume and getMaxVolume.
793     * @param callback Callback used to return the result.
794     * @since 7
795     * @syscap SystemCapability.Multimedia.Audio.Volume
796     * @permission ohos.permission.ACCESS_NOTIFICATION_POLICY
797     */
798    setVolume(volumeType: AudioVolumeType, volume: number, callback: AsyncCallback<void>): void;
799    /**
800     * Sets the volume for a stream. This method uses a promise to return the result.
801     * @param volumeType Audio stream type.
802     * @param volume Volume to set. The value range can be obtained by calling getMinVolume and getMaxVolume.
803     * @return Promise used to return the result.
804     * @since 7
805     * @syscap SystemCapability.Multimedia.Audio.Volume
806     * @permission ohos.permission.ACCESS_NOTIFICATION_POLICY
807     */
808    setVolume(volumeType: AudioVolumeType, volume: number): Promise<void>;
809    /**
810     * Obtains the volume of a stream. This method uses an asynchronous callback to return the query result.
811     * @param volumeType Audio stream type.
812     * @param callback Callback used to return the volume.
813     * @since 7
814     * @syscap SystemCapability.Multimedia.Audio.Volume
815     */
816    getVolume(volumeType: AudioVolumeType, callback: AsyncCallback<number>): void;
817    /**
818     * Obtains the volume of a stream. This method uses a promise to return the query result.
819     * @param volumeType Audio stream type.
820     * @return Promise used to return the volume.
821     * @since 7
822     * @syscap SystemCapability.Multimedia.Audio.Volume
823     */
824    getVolume(volumeType: AudioVolumeType): Promise<number>;
825    /**
826     * Obtains the minimum volume allowed for a stream. This method uses an asynchronous callback to return the query result.
827     * @param volumeType Audio stream type.
828     * @param callback Callback used to return the minimum volume.
829     * @since 7
830     * @syscap SystemCapability.Multimedia.Audio.Volume
831     */
832    getMinVolume(volumeType: AudioVolumeType, callback: AsyncCallback<number>): void;
833    /**
834     * Obtains the minimum volume allowed for a stream. This method uses a promise to return the query result.
835     * @param volumeType Audio stream type.
836     * @return Promise used to return the minimum volume.
837     * @since 7
838     * @syscap SystemCapability.Multimedia.Audio.Volume
839     */
840    getMinVolume(volumeType: AudioVolumeType): Promise<number>;
841    /**
842     * Obtains the maximum volume allowed for a stream. This method uses an asynchronous callback to return the query result.
843     * @param volumeType Audio stream type.
844     * @param callback Callback used to return the maximum volume.
845     * @since 7
846     * @syscap SystemCapability.Multimedia.Audio.Volume
847     */
848    getMaxVolume(volumeType: AudioVolumeType, callback: AsyncCallback<number>): void;
849    /**
850     * Obtains the maximum volume allowed for a stream. This method uses a promise to return the query result.
851     * @param volumeType Audio stream type.
852     * @return Promise used to return the maximum volume.
853     * @since 7
854     * @syscap SystemCapability.Multimedia.Audio.Volume
855     */
856    getMaxVolume(volumeType: AudioVolumeType): Promise<number>;
857    /**
858     * Obtains the audio devices with a specific flag. This method uses an asynchronous callback to return the query result.
859     * @param deviceFlag Audio device flag.
860     * @param callback Callback used to return the device list.
861     * @since 7
862     * @syscap SystemCapability.Multimedia.Audio.Device
863     */
864    getDevices(deviceFlag: DeviceFlag, callback: AsyncCallback<AudioDeviceDescriptors>): void;
865    /**
866     * Obtains the audio devices with a specific flag. This method uses a promise to return the query result.
867     * @param deviceFlag Audio device flag.
868     * @return Promise used to return the device list.
869     * @since 7
870     * @syscap SystemCapability.Multimedia.Audio.Device
871     */
872    getDevices(deviceFlag: DeviceFlag): Promise<AudioDeviceDescriptors>;
873    /**
874     * Mutes a stream. This method uses an asynchronous callback to return the result.
875     * @param volumeType Audio stream type.
876     * @param mute Mute status to set. The value true means to mute the stream, and false means the opposite.
877     * @param callback Callback used to return the result.
878     * @since 7
879     * @syscap SystemCapability.Multimedia.Audio.Volume
880     */
881    mute(volumeType: AudioVolumeType, mute: boolean, callback: AsyncCallback<void>): void;
882    /**
883     * Mutes a stream. This method uses a promise to return the result.
884     * @param volumeType Audio stream type.
885     * @param mute Mute status to set. The value true means to mute the stream, and false means the opposite.
886     * @return Promise used to return the result.
887     * @since 7
888     * @syscap SystemCapability.Multimedia.Audio.Volume
889     */
890    mute(volumeType: AudioVolumeType, mute: boolean): Promise<void>;
891    /**
892     * Checks whether a stream is muted. This method uses an asynchronous callback to return the query result.
893     * @param volumeType Audio stream type.
894     * @param callback Callback used to return the mute status of the stream. The value true means that the stream is
895     * muted, and false means the opposite.
896     * @since 7
897     * @syscap SystemCapability.Multimedia.Audio.Volume
898     */
899    isMute(volumeType: AudioVolumeType, callback: AsyncCallback<boolean>): void;
900    /**
901     * Checks whether a stream is muted. This method uses a promise to return the result.
902     * @param volumeType Audio stream type.
903     * @return Promise used to return the mute status of the stream. The value true means that the stream is muted,
904     * and false means the opposite.
905     * @since 7
906     * @syscap SystemCapability.Multimedia.Audio.Volume
907     */
908    isMute(volumeType: AudioVolumeType): Promise<boolean>;
909    /**
910     * Checks whether a stream is active. This method uses an asynchronous callback to return the query result.
911     * @param volumeType Audio stream type.
912     * @param callback Callback used to return the active status of the stream. The value true means that the stream is
913     * active, and false means the opposite.
914     * @since 7
915     * @syscap SystemCapability.Multimedia.Audio.Volume
916     */
917    isActive(volumeType: AudioVolumeType, callback: AsyncCallback<boolean>): void;
918    /**
919     * Checks whether a stream is active. This method uses a promise to return the query result.
920     * @param volumeType Audio stream type.
921     * @return Promise used to return the active status of the stream. The value true means that the stream is active,
922     * and false means the opposite.
923     * @since 7
924     * @syscap SystemCapability.Multimedia.Audio.Volume
925     */
926    isActive(volumeType: AudioVolumeType): Promise<boolean>;
927    /**
928     * Mutes or unmutes the microphone. This method uses an asynchronous callback to return the result.
929     * @param mute Mute status to set. The value true means to mute the microphone, and false means the opposite.
930     * @param callback Callback used to return the result.
931     * @since 7
932     * @syscap SystemCapability.Multimedia.Audio.Device
933     * @permission ohos.permission.MICROPHONE
934     */
935    setMicrophoneMute(mute: boolean, callback: AsyncCallback<void>): void;
936    /**
937     * Mutes or unmutes the microphone. This method uses a promise to return the result.
938     * @param mute Mute status to set. The value true means to mute the microphone, and false means the opposite.
939     * @return Promise used to return the result.
940     * @since 7
941     * @syscap SystemCapability.Multimedia.Audio.Device
942     * @permission ohos.permission.MICROPHONE
943     */
944    setMicrophoneMute(mute: boolean): Promise<void>;
945    /**
946     * Checks whether the microphone is muted. This method uses an asynchronous callback to return the query result.
947     * @param Callback used to return the mute status of the microphone. The value true means that the microphone is
948     * muted, and false means the opposite.
949     * @since 7
950     * @syscap SystemCapability.Multimedia.Audio.Device
951     * @permission ohos.permission.MICROPHONE
952     */
953    isMicrophoneMute(callback: AsyncCallback<boolean>): void;
954    /**
955     * Checks whether the microphone is muted. This method uses a promise to return the query result.
956     * @return Promise used to return the mute status of the microphone. The value true means that the microphone is
957     * muted, and false means the opposite.
958     * @since 7
959     * @syscap SystemCapability.Multimedia.Audio.Device
960     * @permission ohos.permission.MICROPHONE
961     */
962    isMicrophoneMute(): Promise<boolean>;
963    /**
964     * Sets the ringer mode. This method uses an asynchronous callback to return the result.
965     * @param mode Ringer mode.
966     * @param callback Callback used to return the result.
967     * @since 7
968     * @syscap SystemCapability.Multimedia.Audio.Communication
969     * @permission ohos.permission.ACCESS_NOTIFICATION_POLICY
970     */
971    setRingerMode(mode: AudioRingMode, callback: AsyncCallback<void>): void;
972    /**
973     * Sets the ringer mode. This method uses a promise to return the result.
974     * @param mode Ringer mode.
975     * @return Promise used to return the result.
976     * @since 7
977     * @syscap SystemCapability.Multimedia.Audio.Communication
978     * @permission ohos.permission.ACCESS_NOTIFICATION_POLICY
979     */
980    setRingerMode(mode: AudioRingMode): Promise<void>;
981    /**
982     * Obtains the ringer mode. This method uses an asynchronous callback to return the query result.
983     * @param callback Callback used to return the ringer mode.
984     * @since 7
985     * @syscap SystemCapability.Multimedia.Audio.Communication
986     */
987    getRingerMode(callback: AsyncCallback<AudioRingMode>): void;
988    /**
989     * Obtains the ringer mode. This method uses a promise to return the query result.
990     * @return Promise used to return the ringer mode.
991     * @since 7
992     * @syscap SystemCapability.Multimedia.Audio.Communication
993     */
994    getRingerMode(): Promise<AudioRingMode>;
995    /**
996     * Sets an audio parameter. This method uses an asynchronous callback to return the result.
997     * @param key Key of the audio parameter to set.
998     * @param value Value of the audio parameter to set.
999     * @param callback Callback used to return the result.
1000     * @since 7
1001     * @syscap SystemCapability.Multimedia.Audio.Core
1002     * @permission ohos.permission.MODIFY_AUDIO_SETTINGS
1003     */
1004    setAudioParameter(key: string, value: string, callback: AsyncCallback<void>): void;
1005    /**
1006     * Sets an audio parameter. This method uses a promise to return the result.
1007     * @param key Key of the audio parameter to set.
1008     * @param value Value of the audio parameter to set.
1009     * @return Promise used to return the result.
1010     * @since 7
1011     * @syscap SystemCapability.Multimedia.Audio.Core
1012     * @permission ohos.permission.MODIFY_AUDIO_SETTINGS
1013     */
1014    setAudioParameter(key: string, value: string): Promise<void>;
1015    /**
1016     * Obtains the value of an audio parameter. This method uses an asynchronous callback to return the query result.
1017     * @param key Key of the audio parameter whose value is to be obtained.
1018     * @param callback Callback used to return the value of the audio parameter.
1019     * @since 7
1020     * @syscap SystemCapability.Multimedia.Audio.Core
1021     */
1022    getAudioParameter(key: string, callback: AsyncCallback<string>): void;
1023    /**
1024     * Obtains the value of an audio parameter. This method uses a promise to return the query result.
1025     * @param key Key of the audio parameter whose value is to be obtained.
1026     * @return Promise used to return the value of the audio parameter.
1027     * @since 7
1028     * @syscap SystemCapability.Multimedia.Audio.Core
1029     */
1030    getAudioParameter(key: string): Promise<string>;
1031    /**
1032     * Sets a device to the active state. This method uses an asynchronous callback to return the result.
1033     * @param deviceType Audio device type.
1034     * @param active Active status to set. The value true means to set the device to the active status, and false
1035     * means the opposite.
1036     * @param callback Callback used to return the result.
1037     * @since 7
1038     * @syscap SystemCapability.Multimedia.Audio.Device
1039     */
1040    setDeviceActive(deviceType: ActiveDeviceType, active: boolean, callback: AsyncCallback<void>): void;
1041    /**
1042     * Sets a device to the active state. This method uses a promise to return the result.
1043     * @param deviceType Audio device type.
1044     * @param active Active status to set. The value true means to set the device to the active status, and false
1045     * means the opposite.
1046     * @return Promise used to return the result.
1047     * @since 7
1048     * @syscap SystemCapability.Multimedia.Audio.Device
1049     */
1050    setDeviceActive(deviceType: ActiveDeviceType, active: boolean): Promise<void>;
1051    /**
1052     * Checks whether a device is active. This method uses an asynchronous callback to return the query result.
1053     * @param deviceType Audio device type.
1054     * @param callback Callback used to return the active status of the device.
1055     * @since 7
1056     * @syscap SystemCapability.Multimedia.Audio.Device
1057     */
1058    isDeviceActive(deviceType: ActiveDeviceType, callback: AsyncCallback<boolean>): void;
1059    /**
1060     * Checks whether a device is active. This method uses a promise to return the query result.
1061     * @param deviceType Audio device type.
1062     * @return Promise used to return the active status of the device.
1063     * @since 7
1064     * @syscap SystemCapability.Multimedia.Audio.Device
1065     */
1066    isDeviceActive(deviceType: ActiveDeviceType): Promise<boolean>;
1067    /**
1068     * Listens for system volume change events. This method uses a callback to get volume change events.
1069     * @param callback Callback used to get the system volume change event.
1070     * @since 8
1071     * @syscap SystemCapability.Multimedia.Audio.Volume
1072     * @systemapi
1073     */
1074    on(type: 'volumeChange', callback: Callback<VolumeEvent>): void;
1075    /**
1076     * Listens for ringer mode change events. This method uses a callback to get ringer mode changes.
1077     * @param callback Callback used to get the updated ringer mode.
1078     * @since 8
1079     * @syscap SystemCapability.Multimedia.Audio.Communication
1080     * @systemapi
1081     */
1082    on(type: 'ringerModeChange', callback: Callback<AudioRingMode>): void;
1083    /**
1084     * Sets the audio scene mode to change audio strategies. This method uses an asynchronous callback to return the
1085     * result.
1086     * @param scene Audio scene mode.
1087     * @param callback Callback used to return the result.
1088     * @since 8
1089     * @syscap SystemCapability.Multimedia.Audio.Communication
1090     * @systemapi
1091     */
1092    setAudioScene(scene: AudioScene, callback: AsyncCallback<void> ): void;
1093    /**
1094     * Sets the audio scene mode to change audio strategies. This method uses a promise to return the result.
1095     * @param scene Audio scene mode.
1096     * @return Promise used to return the result.
1097     * @since 8
1098     * @syscap SystemCapability.Multimedia.Audio.Communication
1099     * @systemapi
1100     */
1101    setAudioScene(scene: AudioScene): Promise<void>;
1102    /**
1103     * Obtains the audio scene mode. This method uses an asynchronous callback to return the query result.
1104     * @param callback Callback used to return the audio scene mode.
1105     * @since 8
1106     * @syscap SystemCapability.Multimedia.Audio.Communication
1107     */
1108    getAudioScene(callback: AsyncCallback<AudioScene>): void;
1109    /**
1110     * Obtains the audio scene mode. This method uses a promise to return the query result.
1111     * @return Promise used to return the audio scene mode.
1112     * @since 8
1113     * @syscap SystemCapability.Multimedia.Audio.Communication
1114     */
1115    getAudioScene(): Promise<AudioScene>;
1116    /**
1117     * Subscribes to device change events. When a device is connected/disconnected, registered clients will receive
1118     * the callback.
1119     * @param callback Callback used to obtain the device update details.
1120     * @since 7
1121     * @syscap SystemCapability.Multimedia.Audio.Device
1122     */
1123    on(type: 'deviceChange', callback: Callback<DeviceChangeAction>): void;
1124
1125    /**
1126     * UnSubscribes to device change events.
1127     * @param callback Callback used to obtain the device update details.
1128     * @since 7
1129     * @syscap SystemCapability.Multimedia.Audio.Device
1130     */
1131    off(type: 'deviceChange', callback?: Callback<DeviceChangeAction>): void;
1132
1133    /**
1134     * Listens for audio interruption events. When the audio of an application is interrupted by another application,
1135     * the callback is invoked to notify the former application.
1136     * @param type Type of the event to listen for. Only the interrupt event is supported.
1137     * @param interrupt Parameters of the audio interruption event type.
1138     * @param callback Callback invoked for the audio interruption event.
1139     * @since 7
1140     * @syscap SystemCapability.Multimedia.Audio.Renderer
1141     */
1142    on(type: 'interrupt', interrupt: AudioInterrupt, callback: Callback<InterruptAction>): void;
1143
1144    /**
1145     * Cancels the listening of audio interruption events.
1146     * @param type Type of the event to listen for. Only the interrupt event is supported.
1147     * @param interrupt Input parameters of the audio interruption event.
1148     * @param callback Callback invoked for the audio interruption event.
1149     * @since 7
1150     * @syscap SystemCapability.Multimedia.Audio.Renderer
1151     */
1152    off(type: 'interrupt', interrupt: AudioInterrupt, callback?: Callback<InterruptAction>): void;
1153  }
1154
1155  /**
1156   * Describes an audio device.
1157   * @since 7
1158   * @syscap SystemCapability.Multimedia.Audio.Device
1159   */
1160  interface AudioDeviceDescriptor {
1161    /**
1162     * Audio device role.
1163     * @since 7
1164     * @syscap SystemCapability.Multimedia.Audio.Device
1165     */
1166    readonly deviceRole: DeviceRole;
1167    /**
1168     * Audio device type.
1169     * @since 7
1170     * @syscap SystemCapability.Multimedia.Audio.Device
1171     */
1172    readonly deviceType: DeviceType;
1173  }
1174
1175  /**
1176   * Array of AudioDeviceDescriptors, which is read-only.
1177   * @since 7
1178   * @syscap SystemCapability.Multimedia.Audio.Device
1179   */
1180  type AudioDeviceDescriptors = Array<Readonly<AudioDeviceDescriptor>>;
1181
1182  /**
1183   * Describes the volume event received by the app when the volume is changed.
1184   * @since 8
1185   * @syscap SystemCapability.Multimedia.Audio.Volume
1186   * @systemapi
1187   */
1188  interface VolumeEvent {
1189    /**
1190     * Volume type of the current stream.
1191     * @since 8
1192     * @syscap SystemCapability.Multimedia.Audio.Volume
1193     */
1194    volumeType: AudioVolumeType;
1195    /**
1196     * Volume level.
1197     * @since 8
1198     * @syscap SystemCapability.Multimedia.Audio.Volume
1199     */
1200    volume: number;
1201    /**
1202     * Whether to show the volume change in UI.
1203     * @since 8
1204     * @syscap SystemCapability.Multimedia.Audio.Volume
1205     */
1206    updateUi: boolean;
1207  }
1208
1209  /**
1210   * Describes the callback invoked for audio interruption or focus gain events.When the audio of an application
1211   * is interrupted by another application, the callback is invoked to notify the former application.
1212   * @since 7
1213   * @syscap SystemCapability.Multimedia.Audio.Renderer
1214   */
1215  interface InterruptAction {
1216
1217    /**
1218     * Event type.
1219     * The value TYPE_ACTIVATED means the focus gain event, and TYPE_INTERRUPT means the audio interruption event.
1220     * @since 7
1221     * @syscap SystemCapability.Multimedia.Audio.Renderer
1222     */
1223    actionType: InterruptActionType;
1224
1225    /**
1226     * Type of the audio interruption event.
1227     * @since 7
1228     * @syscap SystemCapability.Multimedia.Audio.Renderer
1229     */
1230    type?: InterruptType;
1231
1232    /**
1233     * Hint for the audio interruption event.
1234     * @since 7
1235     * @syscap SystemCapability.Multimedia.Audio.Renderer
1236     */
1237    hint?: InterruptHint;
1238
1239    /**
1240     * Whether the focus is gained or released. The value true means that the focus is gained or released,
1241     * and false means that the focus fails to be gained or released.
1242     * @since 7
1243     * @syscap SystemCapability.Multimedia.Audio.Renderer
1244     */
1245    activated?: boolean;
1246  }
1247
1248  /**
1249   * Describes input parameters of audio listening events.
1250   * @since 7
1251   * @syscap SystemCapability.Multimedia.Audio.Renderer
1252   */
1253  interface AudioInterrupt {
1254
1255    /**
1256     * Audio stream usage type.
1257     * @since 7
1258     * @syscap SystemCapability.Multimedia.Audio.Renderer
1259     */
1260    streamUsage: StreamUsage;
1261
1262    /**
1263     * Type of the media interrupted.
1264     * @since 7
1265     * @syscap SystemCapability.Multimedia.Audio.Renderer
1266     */
1267    contentType: ContentType;
1268
1269    /**
1270     * Whether audio playback can be paused when it is interrupted.
1271     * The value true means that audio playback can be paused when it is interrupted, and false means the opposite.
1272     * @since 7
1273     * @syscap SystemCapability.Multimedia.Audio.Renderer
1274     */
1275    pauseWhenDucked: boolean;
1276  }
1277
1278  /**
1279   * Describes the device change type and device information.
1280   * @since 7
1281   * @syscap SystemCapability.Multimedia.Audio.Device
1282   */
1283  interface DeviceChangeAction {
1284    /**
1285     * Device change type.
1286     * @since 7
1287     * @syscap SystemCapability.Multimedia.Audio.Device
1288     */
1289    type: DeviceChangeType;
1290
1291    /**
1292     * Device information.
1293     * @since 7
1294     * @syscap SystemCapability.Multimedia.Audio.Device
1295     */
1296    deviceDescriptors: AudioDeviceDescriptors;
1297  }
1298
1299  /**
1300   * Provides audio playback APIs.
1301   * @since 8
1302   * @syscap SystemCapability.Multimedia.Audio.Renderer
1303   */
1304  interface AudioRenderer {
1305    /**
1306     * Defines the current render state.
1307     * @since 8
1308     * @syscap SystemCapability.Multimedia.Audio.Renderer
1309     */
1310    readonly state: AudioState;
1311    /**
1312     * Obtains the renderer information provided while creating a renderer instance. This method uses an asynchronous
1313     * callback to return the result.
1314     * @param callback Callback used to return the renderer information.
1315     * @since 8
1316     * @syscap SystemCapability.Multimedia.Audio.Renderer
1317     */
1318    getRendererInfo(callback: AsyncCallback<AudioRendererInfo>): void;
1319    /**
1320     * Obtains the renderer information provided while creating a renderer instance. This method uses a promise to
1321     * return the result.
1322     * @return Promise used to return the renderer information.
1323     * @since 8
1324     * @syscap SystemCapability.Multimedia.Audio.Renderer
1325     */
1326    getRendererInfo(): Promise<AudioRendererInfo>;
1327    /**
1328     * Obtains the renderer stream information. This method uses an asynchronous callback to return the result.
1329     * @param callback Callback used to return the stream information.
1330     * @since 8
1331     * @syscap SystemCapability.Multimedia.Audio.Renderer
1332     */
1333    getStreamInfo(callback: AsyncCallback<AudioStreamInfo>): void;
1334    /**
1335     * Obtains the renderer stream information. This method uses a promise to return the result.
1336     * @return Promise used to return the stream information.
1337     * @since 8
1338     * @syscap SystemCapability.Multimedia.Audio.Renderer
1339     */
1340    getStreamInfo(): Promise<AudioStreamInfo>;
1341    /**
1342     * Starts the renderer. This method uses an asynchronous callback to return the result.
1343     * @param callback Callback used to return the result.
1344     * @since 8
1345     * @syscap SystemCapability.Multimedia.Audio.Renderer
1346     */
1347    start(callback: AsyncCallback<void>): void;
1348    /**
1349     * Starts the renderer. This method uses a promise to return the result.
1350     * @return Promise used to return the result.
1351     * @since 8
1352     * @syscap SystemCapability.Multimedia.Audio.Renderer
1353     */
1354    start(): Promise<void>;
1355    /**
1356     * Writes the buffer. This method uses an asynchronous callback to return the result.
1357     * @param buffer Buffer to be written.
1358     * @param callback Returns the number of bytes written if the operation is successful; returns an error code
1359     * otherwise.
1360     * @since 8
1361     * @syscap SystemCapability.Multimedia.Audio.Renderer
1362     */
1363    write(buffer: ArrayBuffer, callback: AsyncCallback<number>): void;
1364    /**
1365     * Writes the buffer. This method uses a promise to return the result.
1366     * @param buffer Buffer to be written.
1367     * @return Returns the number of bytes written if the operation is successful; returns an error code otherwise.
1368     * @since 8
1369     * @syscap SystemCapability.Multimedia.Audio.Renderer
1370     */
1371    write(buffer: ArrayBuffer): Promise<number>;
1372    /**
1373     * Obtains the timestamp in Unix epoch time (starts from January 1, 1970), in nanoseconds. This method uses an
1374     * asynchronous callback to return the result.
1375     * @param callback Callback used to return the timestamp.
1376     * @since 8
1377     * @syscap SystemCapability.Multimedia.Audio.Renderer
1378     */
1379    getAudioTime(callback: AsyncCallback<number>): void;
1380    /**
1381     * Obtains the timestamp in Unix epoch time (starts from January 1, 1970), in nanoseconds. This method uses a
1382     * promise to return the result.
1383     * @return Promise used to return the timestamp.
1384     * @since 8
1385     * @syscap SystemCapability.Multimedia.Audio.Renderer
1386     */
1387    getAudioTime(): Promise<number>;
1388    /**
1389     * Drains the playback buffer. This method uses an asynchronous callback to return the result.
1390     * @param callback Callback used to return the result.
1391     * @since 8
1392     * @syscap SystemCapability.Multimedia.Audio.Renderer
1393     */
1394    drain(callback: AsyncCallback<void>): void;
1395    /**
1396     * Drains the playback buffer. This method uses a promise to return the result.
1397     * @return Promise used to return the result.
1398     * @since 8
1399     * @syscap SystemCapability.Multimedia.Audio.Renderer
1400     */
1401    drain(): Promise<void>;
1402    /**
1403     * Pauses rendering. This method uses an asynchronous callback to return the result.
1404     * @param callback Callback used to return the result.
1405     * @since 8
1406     * @syscap SystemCapability.Multimedia.Audio.Renderer
1407     */
1408    pause(callback: AsyncCallback<void>): void;
1409    /**
1410     * Pauses rendering. This method uses a promise to return the result.
1411     * @return Promise used to return the result.
1412     * @since 8
1413     * @syscap SystemCapability.Multimedia.Audio.Renderer
1414     */
1415    pause(): Promise<void>;
1416    /**
1417     * Stops rendering. This method uses an asynchronous callback to return the result.
1418     * @param callback Callback used to return the result.
1419     * @since 8
1420     * @syscap SystemCapability.Multimedia.Audio.Renderer
1421     */
1422    stop(callback: AsyncCallback<void>): void;
1423    /**
1424     * Stops rendering. This method uses a promise to return the result.
1425     * @return Promise used to return the result.
1426     * @since 8
1427     * @syscap SystemCapability.Multimedia.Audio.Renderer
1428     */
1429    stop(): Promise<void>;
1430    /**
1431     * Releases the renderer. This method uses an asynchronous callback to return the result.
1432     * @param callback Callback used to return the result.
1433     * @since 8
1434     * @syscap SystemCapability.Multimedia.Audio.Renderer
1435     */
1436    release(callback: AsyncCallback<void>): void;
1437    /**
1438     * Releases the renderer. This method uses a promise to return the result.
1439     * @return Promise used to return the result.
1440     * @since 8
1441     * @syscap SystemCapability.Multimedia.Audio.Renderer
1442     */
1443    release(): Promise<void>;
1444    /**
1445     * Obtains a reasonable minimum buffer size in bytes for rendering. This method uses an asynchronous callback to
1446     * return the result.
1447     * @param callback Callback used to return the buffer size.
1448     * @since 8
1449     * @syscap SystemCapability.Multimedia.Audio.Renderer
1450     */
1451    getBufferSize(callback: AsyncCallback<number>): void;
1452    /**
1453     * Obtains a reasonable minimum buffer size in bytes for rendering. This method uses a promise to return the result.
1454     * @return Promise used to return the buffer size.
1455     * @since 8
1456     * @syscap SystemCapability.Multimedia.Audio.Renderer
1457     */
1458    getBufferSize(): Promise<number>;
1459    /**
1460     * Sets the render rate. This method uses an asynchronous callback to return the result.
1461     * @param rate Audio render rate.
1462     * @param callback Callback used to return the result.
1463     * @since 8
1464     * @syscap SystemCapability.Multimedia.Audio.Renderer
1465     */
1466    setRenderRate(rate: AudioRendererRate, callback: AsyncCallback<void>): void;
1467    /**
1468     * Sets the render rate. This method uses a promise to return the result.
1469     * @param rate Audio render rate.
1470     * @return Promise used to return the result.
1471     * @since 8
1472     * @syscap SystemCapability.Multimedia.Audio.Renderer
1473     */
1474    setRenderRate(rate: AudioRendererRate): Promise<void>;
1475    /**
1476     * Obtains the current render rate. This method uses an asynchronous callback to return the result.
1477     * @param callback Callback used to return the audio render rate.
1478     * @since 8
1479     * @syscap SystemCapability.Multimedia.Audio.Renderer
1480     */
1481    getRenderRate(callback: AsyncCallback<AudioRendererRate>): void;
1482    /**
1483     * Obtains the current render rate. This method uses a promise to return the result.
1484     * @return Promise used to return the audio render rate.
1485     * @since 8
1486     * @syscap SystemCapability.Multimedia.Audio.Renderer
1487     */
1488    getRenderRate(): Promise<AudioRendererRate>;
1489    /**
1490     * Subscribes to mark reached events. When the number of frames rendered reaches the value of the frame parameter,
1491     * the callback is invoked.
1492     * @param frame Number of frames to trigger the event. The value must be greater than 0.
1493     * @param callback Callback invoked when the event is triggered.
1494     * @since 8
1495     * @syscap SystemCapability.Multimedia.Audio.Renderer
1496     */
1497    on(type: "markReach", frame: number, callback: (position: number) => {}): void;
1498    /**
1499     * Unsubscribes from mark reached events.
1500     * @since 8
1501     * @syscap SystemCapability.Multimedia.Audio.Renderer
1502     */
1503    off(type: "markReach"): void;
1504    /**
1505     * Subscribes to period reached events. When the period of frame rendering reaches the value of frame parameter,
1506     * the callback is invoked.
1507     * @param frame Period during which frame rendering is listened. The value must be greater than 0.
1508     * @param callback Callback invoked when the event is triggered.
1509     * @since 8
1510     * @syscap SystemCapability.Multimedia.Audio.Renderer
1511     */
1512    on(type: "periodReach", frame: number, callback: (position: number) => {}): void;
1513    /**
1514     * Unsubscribes from period reached events.
1515     * @since 8
1516     * @syscap SystemCapability.Multimedia.Audio.Renderer
1517     */
1518    off(type: "periodReach"): void;
1519    /**
1520     * Subscribes audio state change event callback.
1521     * @param callback Callback invoked when state change.
1522     * @since 8
1523     * @syscap SystemCapability.Multimedia.Audio.Renderer
1524     */
1525    on(type: "stateChange", callback: Callback<AudioState>): void;
1526  }
1527
1528  /**
1529   * Enumerates source types.
1530   * @since 8
1531   * @syscap SystemCapability.Multimedia.Audio.Core
1532   */
1533  enum SourceType {
1534    /**
1535     * Invalid source type.
1536     * @since 8
1537     * @syscap SystemCapability.Multimedia.Audio.Core
1538     */
1539    SOURCE_TYPE_INVALID = -1,
1540    /**
1541     * Mic source type.
1542     * @since 8
1543     * @syscap SystemCapability.Multimedia.Audio.Core
1544     */
1545    SOURCE_TYPE_MIC = 0,
1546    /**
1547     * Voice communication source type.
1548     * @since 8
1549     * @syscap SystemCapability.Multimedia.Audio.Core
1550     */
1551    SOURCE_TYPE_VOICE_COMMUNICATION = 7
1552  }
1553
1554  /**
1555   * Describes audio capturer information.
1556   * @since 8
1557   * @syscap SystemCapability.Multimedia.Audio.Core
1558   */
1559  interface AudioCapturerInfo {
1560    /**
1561     * Audio source type.
1562     * @since 8
1563     * @syscap SystemCapability.Multimedia.Audio.Core
1564     */
1565    source: SourceType;
1566    /**
1567     * Audio capturer flags.
1568     * @since 8
1569     * @syscap SystemCapability.Multimedia.Audio.Core
1570     */
1571    capturerFlags: number;
1572  }
1573
1574  /**
1575   * Describes audio capturer configuration options.
1576   * @since 8
1577   * @syscap SystemCapability.Multimedia.Audio.Capturer
1578   */
1579  interface AudioCapturerOptions {
1580    /**
1581     * Stream information.
1582     * @since 8
1583     * @syscap SystemCapability.Multimedia.Audio.Capturer
1584     */
1585    streamInfo: AudioStreamInfo;
1586    /**
1587     * Capturer information.
1588     * @since 8
1589     * @syscap SystemCapability.Multimedia.Audio.Capturer
1590     */
1591    capturerInfo: AudioCapturerInfo;
1592  }
1593
1594  /**
1595   * Provides APIs for audio recording.
1596   * @since 8
1597   * @syscap SystemCapability.Multimedia.Audio.Capturer
1598   */
1599  interface AudioCapturer {
1600    /**
1601     * Defines the current capture state.
1602     * @since 8
1603     * @syscap SystemCapability.Multimedia.Audio.Capturer
1604     */
1605    readonly state: AudioState;
1606    /**
1607     * Obtains the capturer information provided while creating a capturer instance. This method uses an asynchronous
1608     * callback to return the result.
1609     * @param callback Callback used to return the capturer information.
1610     * @since 8
1611     * @syscap SystemCapability.Multimedia.Audio.Capturer
1612     */
1613    getCapturerInfo(callback: AsyncCallback<AudioCapturerInfo>): void;
1614    /**
1615     * Obtains the capturer information provided while creating a capturer instance. This method uses a promise to
1616     * return the result.
1617     * @return Promise used to return the capturer information.
1618     * @since 8
1619     * @syscap SystemCapability.Multimedia.Audio.Capturer
1620     */
1621    getCapturerInfo(): Promise<AudioCapturerInfo>;
1622
1623    /**
1624     * Obtains the capturer stream information. This method uses an asynchronous callback to return the result.
1625     * @param callback Callback used to return the stream information.
1626     * @since 8
1627     * @syscap SystemCapability.Multimedia.Audio.Capturer
1628     */
1629    getStreamInfo(callback: AsyncCallback<AudioStreamInfo>): void;
1630    /**
1631     * Obtains the capturer stream information. This method uses a promise to return the result.
1632     * @return Promise used to return the stream information.
1633     * @since 8
1634     * @syscap SystemCapability.Multimedia.Audio.Capturer
1635     */
1636    getStreamInfo(): Promise<AudioStreamInfo>;
1637
1638    /**
1639     * Starts capturing. This method uses an asynchronous callback to return the result.
1640     * @param callback Callback used to return the result.
1641     * @since 8
1642     * @syscap SystemCapability.Multimedia.Audio.Capturer
1643     */
1644    start(callback: AsyncCallback<void>): void;
1645    /**
1646     * Starts capturing. This method uses a promise to return the result.
1647     * @return Promise used to return the result.
1648     * @since 8
1649     * @syscap SystemCapability.Multimedia.Audio.Capturer
1650     */
1651    start(): Promise<void>;
1652
1653    /**
1654     * Reads the buffer from the audio capturer. This method uses an asynchronous callback to return the result.
1655     * @param size Number of bytes to read.
1656     * @param isBlockingRead Whether the read operation should be blocked.
1657     * @param callback Callback used to return the buffer.
1658     * @since 8
1659     * @syscap SystemCapability.Multimedia.Audio.Capturer
1660     */
1661    read(size: number, isBlockingRead: boolean, callback: AsyncCallback<ArrayBuffer>): void;
1662    /**
1663     * Reads the buffer from the audio capturer. This method uses a promise to return the result.
1664     * @param size Number of bytes to read.
1665     * @param isBlockingRead Whether the read operation should be blocked.
1666     * @return Returns the buffer data read if the operation is successful; returns an error code otherwise.
1667     * @since 8
1668     * @syscap SystemCapability.Multimedia.Audio.Capturer
1669     */
1670    read(size: number, isBlockingRead: boolean): Promise<ArrayBuffer>;
1671
1672    /**
1673     * Obtains the timestamp in Unix epoch time (starts from January 1, 1970), in nanoseconds. This method uses an
1674     * asynchronous callback to return the result.
1675     * @param callback Callback used to return the timestamp.
1676     * @since 8
1677     * @syscap SystemCapability.Multimedia.Audio.Capturer
1678     */
1679    getAudioTime(callback: AsyncCallback<number>): void;
1680    /**
1681     * Obtains the timestamp in Unix epoch time (starts from January 1, 1970), in nanoseconds. This method uses a
1682     * promise to return the result.
1683     * @return Promise used to return the timestamp.
1684     * @since 8
1685     * @syscap SystemCapability.Multimedia.Audio.Capturer
1686     */
1687    getAudioTime(): Promise<number>;
1688
1689    /**
1690     * Stops capturing. This method uses an asynchronous callback to return the result.
1691     * @param callback Callback used to return the result.
1692     * @since 8
1693     * @syscap SystemCapability.Multimedia.Audio.Capturer
1694     */
1695    stop(callback: AsyncCallback<void>): void;
1696    /**
1697     * Stops capturing. This method uses a promise to return the result.
1698     * @return Promise used to return the result.
1699     * @since 8
1700     * @syscap SystemCapability.Multimedia.Audio.Capturer
1701     */
1702    stop(): Promise<void>;
1703
1704    /**
1705     * Releases the capturer. This method uses an asynchronous callback to return the result.
1706     * @param callback Callback used to return the result.
1707     * @since 8
1708     * @syscap SystemCapability.Multimedia.Audio.Capturer
1709     */
1710    release(callback: AsyncCallback<void>): void;
1711    /**
1712     * Releases the capturer. This method uses a promise to return the result.
1713     * @return Promise used to return the result.
1714     * @since 8
1715     * @syscap SystemCapability.Multimedia.Audio.Capturer
1716     */
1717    release(): Promise<void>;
1718
1719    /**
1720     * Obtains a reasonable minimum buffer size in bytes for capturing. This method uses an asynchronous callback to
1721     * return the result.
1722     * @param callback Callback used to return the buffer size.
1723     * @since 8
1724     * @syscap SystemCapability.Multimedia.Audio.Capturer
1725     */
1726    getBufferSize(callback: AsyncCallback<number>): void;
1727    /**
1728     * Obtains a reasonable minimum buffer size in bytes for capturing. This method uses a promise to return the result.
1729     * @return Promise used to return the buffer size.
1730     * @since 8
1731     * @syscap SystemCapability.Multimedia.Audio.Capturer
1732     */
1733    getBufferSize(): Promise<number>;
1734
1735    /**
1736     * Subscribes to mark reached events. When the number of frames captured reaches the value of the frame parameter,
1737     * the callback is invoked.
1738     * @param frame Number of frames to trigger the event. The value must be greater than 0.
1739     * @param callback Callback invoked when the event is triggered.
1740     * @since 8
1741     * @syscap SystemCapability.Multimedia.Audio.Capturer
1742     */
1743    on(type: "markReach", frame: number, callback: (position: number) => {}): void;
1744    /**
1745     * Unsubscribes from the mark reached events.
1746     * @since 8
1747     * @syscap SystemCapability.Multimedia.Audio.Capturer
1748     */
1749    off(type: "markReach"): void;
1750
1751    /**
1752     * Subscribes to period reached events. When the period of frame capturing reaches the value of frame parameter,
1753     * the callback is invoked.
1754     * @param frame Period during which frame capturing is listened. The value must be greater than 0.
1755     * @param callback Callback invoked when the event is triggered.
1756     * @since 8
1757     * @syscap SystemCapability.Multimedia.Audio.Capturer
1758     */
1759    on(type: "periodReach", frame: number, callback: (position: number) => {}): void;
1760    /**
1761     * Unsubscribes from period reached events.
1762     * @since 8
1763     * @syscap SystemCapability.Multimedia.Audio.Capturer
1764     */
1765    off(type: "periodReach"): void;
1766
1767    /**
1768     * Subscribes audio state change event callback.
1769     * @param callback Callback used to listen for the audio state change event.
1770     * @since 8
1771     * @syscap SystemCapability.Multimedia.Audio.Capturer
1772     */
1773    on(type: "stateChange", callback: Callback<AudioState>): void;
1774  }
1775}
1776
1777export default audio;
1778