diff --git a/api/@ohos.multimedia.audio.d.ts b/api/@ohos.multimedia.audio.d.ts index e068644e18df0cbc79ac6241378e32a1988cd09a..a06c56605d284dac35757528113b7941eb6258d0 100644 --- a/api/@ohos.multimedia.audio.d.ts +++ b/api/@ohos.multimedia.audio.d.ts @@ -22,17 +22,59 @@ import {ErrorCallback, AsyncCallback, Callback} from './basic'; */ declare namespace audio { /** - * Define local device network id for audio - * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Device - * @systemapi - */ + * Enumerates audio errors. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + enum AudioErrors { + /** + * Common errors. + */ + ERROR_INVALID_PARAM = 6800101, + ERROR_NO_MEMORY = 6800102, + ERROR_ILLEGAL_STATE = 6800103, + ERROR_UNSUPPORTED = 6800104, + ERROR_TIMEOUT = 6800105, + /** + * Audio specific errors. + */ + ERROR_STREAM_LIMIT = 6800201, + /** + * Default error. + */ + ERROR_SYSTEM = 6800301 + } + + /** + * Define local device network id for audio + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Device + * @systemapi + */ const LOCAL_NETWORK_ID: string; + + /** + * Define local volume group id for audio + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Volume + * @systemapi + */ + const LOCAL_VOLUME_GROUP_ID: number; + + /** + * Define local interrupt group id for audio + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Interrupt + * @systemapi + */ + const LOCAL_INTERRUPT_GROUP_ID: number; + /** * Obtains an AudioManager instance. * @return AudioManager object. * @since 7 * @syscap SystemCapability.Multimedia.Audio.Core + * @deprecated since 9 */ function getAudioManager(): AudioManager; @@ -42,6 +84,7 @@ declare namespace audio { * @param callback Callback used to return the audio capturer instance. * @since 8 * @syscap SystemCapability.Multimedia.Audio.Capturer + * @deprecated since 9 */ function createAudioCapturer(options: AudioCapturerOptions, callback: AsyncCallback): void; @@ -51,6 +94,7 @@ declare namespace audio { * @return Promise used to return the audio capturer instance. * @since 8 * @syscap SystemCapability.Multimedia.Audio.Capturer + * @deprecated since 9 */ function createAudioCapturer(options: AudioCapturerOptions): Promise; @@ -60,6 +104,7 @@ declare namespace audio { * @param callback Callback used to return the audio renderer instance. * @since 8 * @syscap SystemCapability.Multimedia.Audio.Renderer + * @deprecated since 9 */ function createAudioRenderer(options: AudioRendererOptions, callback: AsyncCallback): void; @@ -69,6 +114,7 @@ declare namespace audio { * @return Promise used to return the audio renderer instance. * @since 8 * @syscap SystemCapability.Multimedia.Audio.Renderer + * @deprecated since 9 */ function createAudioRenderer(options: AudioRendererOptions): Promise; @@ -307,8 +353,9 @@ declare namespace audio { * Enumerates the active device types. * @since 7 * @syscap SystemCapability.Multimedia.Audio.Device + * @deprecated since 9 */ - enum ActiveDeviceType { + enum ActiveDeviceType { /** * Speaker. * @since 7 @@ -323,6 +370,20 @@ declare namespace audio { BLUETOOTH_SCO = 7, } + /** + * Enumerates the available device types for communication. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Communication + */ + enum CommunicationDeviceType { + /** + * Speaker. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Communication + */ + SPEAKER = 2 + } + /** * Enumerates ringer modes. * @since 7 @@ -397,22 +458,53 @@ declare namespace audio { * Enumerates the audio channel. * @since 8 * @syscap SystemCapability.Multimedia.Audio.Core + * @deprecated since 9 */ enum AudioChannel { /** * Channel 1. * @since 8 * @syscap SystemCapability.Multimedia.Audio.Core + * @deprecated since 9 */ CHANNEL_1 = 0x1 << 0, /** * Channel 2. * @since 8 * @syscap SystemCapability.Multimedia.Audio.Core + * @deprecated since 9 */ CHANNEL_2 = 0x1 << 1 } + /** + * Enumerates the audio render channel mask. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + enum AudioRendererChannelMask { + CHANNEL_OUT_FRONT_LEFT = 0x1 << 0, + CHANNEL_OUT_FRONT_RIGHT = 0x1 << 1, + CHANNEL_OUT_FRONT_CENTER = 0x1 << 2, + CHANNEL_OUT_LOW_FREQUENCY = 0x1 << 3, + CHANNEL_OUT_SIDE_LEFT = 0x1 << 4, + CHANNEL_OUT_SIDE_RIGHT = 0x1 << 5, + CHANNEL_OUT_BACK_LEFT = 0x1 << 6, + CHANNEL_OUT_BACK_RIGHT = 0x1 << 7 + } + + /** + * Enumerates the audio capture channel mask. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + enum AudioCapturerChannelMask { + CHANNEL_IN_LEFT = 0x1 << 0, + CHANNEL_IN_RIGHT = 0x1 << 1, + CHANNEL_IN_FRONT = 0x1 << 2, + CHANNEL_IN_BACK = 0x1 << 3 + } + /** * Enumerates the audio sampling rate. * @since 8 @@ -591,42 +683,47 @@ declare namespace audio { */ enum FocusType { /** - * Recording type. + * Default focus type. * @since 9 * @syscap SystemCapability.Multimedia.Audio.Core * @systemapi */ - FOCUS_TYPE_RECORDING = 0, + FOCUS_TYPE_DEFAULT = 0, } /** * Describes audio stream information. * @since 8 * @syscap SystemCapability.Multimedia.Audio.Core + * @deprecated since 9 */ interface AudioStreamInfo { /** * Sampling rate. * @since 8 * @syscap SystemCapability.Multimedia.Audio.Core + * @deprecated since 9 */ samplingRate: AudioSamplingRate; /** * Audio channels. * @since 8 * @syscap SystemCapability.Multimedia.Audio.Core + * @deprecated since 9 */ channels: AudioChannel; /** * Audio sample format. * @since 8 * @syscap SystemCapability.Multimedia.Audio.Core + * @deprecated since 9 */ sampleFormat: AudioSampleFormat; /** * Audio encoding type. * @since 8 * @syscap SystemCapability.Multimedia.Audio.Core + * @deprecated since 9 */ encodingType: AudioEncodingType; } @@ -635,29 +732,34 @@ declare namespace audio { * Describes audio renderer information. * @since 8 * @syscap SystemCapability.Multimedia.Audio.Core + * @deprecated since 9 */ interface AudioRendererInfo { /** * Content type. * @since 8 * @syscap SystemCapability.Multimedia.Audio.Core + * @deprecated since 9 */ content: ContentType; /** * Stream usage. * @since 8 * @syscap SystemCapability.Multimedia.Audio.Core + * @deprecated since 9 */ usage: StreamUsage; /** * Audio renderer flags. * @since 8 * @syscap SystemCapability.Multimedia.Audio.Core + * @deprecated since 9 */ rendererFlags: number; } - /** Describes audio renderer filter. + /** + * Describes audio renderer filter. * @since 9 * @syscap SystemCapability.Multimedia.Audio.Core * @systemapi @@ -676,7 +778,7 @@ declare namespace audio { * @syscap SystemCapability.Multimedia.Audio.Renderer * @systemapi */ - rendererInfo?: AudioRendererInfo; + rendererInfo?: AudioStreamRendererInfo; /** * AudioRenderer id. * @since 9 @@ -690,18 +792,21 @@ declare namespace audio { * Describes audio renderer configuration options. * @since 8 * @syscap SystemCapability.Multimedia.Audio.Renderer + * @deprecated since 9 */ interface AudioRendererOptions { /** * Stream information. * @since 8 * @syscap SystemCapability.Multimedia.Audio.Renderer + * @deprecated since 9 */ streamInfo: AudioStreamInfo; /** * Renderer information. * @since 8 * @syscap SystemCapability.Multimedia.Audio.Renderer + * @deprecated since 9 */ rendererInfo: AudioRendererInfo; } @@ -873,6 +978,7 @@ declare namespace audio { * Enumerates interrupt action types. * @since 7 * @syscap SystemCapability.Multimedia.Audio.Renderer + * @deprecated since 9 */ enum InterruptActionType { @@ -880,6 +986,7 @@ declare namespace audio { * Focus gain event. * @since 7 * @syscap SystemCapability.Multimedia.Audio.Renderer + * @deprecated since 9 */ TYPE_ACTIVATED = 0, @@ -887,6 +994,7 @@ declare namespace audio { * Audio interruption event. * @since 7 * @syscap SystemCapability.Multimedia.Audio.Renderer + * @deprecated since 9 */ TYPE_INTERRUPT = 1 } @@ -950,6 +1058,7 @@ declare namespace audio { * Implements audio volume and audio device management. * @since 7 * @syscap SystemCapability.Multimedia.Audio.Core + * @deprecated since 9 */ interface AudioManager { /** @@ -960,6 +1069,7 @@ declare namespace audio { * @since 7 * @syscap SystemCapability.Multimedia.Audio.Volume * @permission ohos.permission.ACCESS_NOTIFICATION_POLICY + * @deprecated since 9 */ setVolume(volumeType: AudioVolumeType, volume: number, callback: AsyncCallback): void; /** @@ -970,6 +1080,7 @@ declare namespace audio { * @since 7 * @syscap SystemCapability.Multimedia.Audio.Volume * @permission ohos.permission.ACCESS_NOTIFICATION_POLICY + * @deprecated since 9 */ setVolume(volumeType: AudioVolumeType, volume: number): Promise; /** @@ -978,6 +1089,7 @@ declare namespace audio { * @param callback Callback used to return the volume. * @since 7 * @syscap SystemCapability.Multimedia.Audio.Volume + * @deprecated since 9 */ getVolume(volumeType: AudioVolumeType, callback: AsyncCallback): void; /** @@ -986,6 +1098,7 @@ declare namespace audio { * @return Promise used to return the volume. * @since 7 * @syscap SystemCapability.Multimedia.Audio.Volume + * @deprecated since 9 */ getVolume(volumeType: AudioVolumeType): Promise; /** @@ -994,6 +1107,7 @@ declare namespace audio { * @param callback Callback used to return the minimum volume. * @since 7 * @syscap SystemCapability.Multimedia.Audio.Volume + * @deprecated since 9 */ getMinVolume(volumeType: AudioVolumeType, callback: AsyncCallback): void; /** @@ -1002,6 +1116,7 @@ declare namespace audio { * @return Promise used to return the minimum volume. * @since 7 * @syscap SystemCapability.Multimedia.Audio.Volume + * @deprecated since 9 */ getMinVolume(volumeType: AudioVolumeType): Promise; /** @@ -1010,6 +1125,7 @@ declare namespace audio { * @param callback Callback used to return the maximum volume. * @since 7 * @syscap SystemCapability.Multimedia.Audio.Volume + * @deprecated since 9 */ getMaxVolume(volumeType: AudioVolumeType, callback: AsyncCallback): void; /** @@ -1018,6 +1134,7 @@ declare namespace audio { * @return Promise used to return the maximum volume. * @since 7 * @syscap SystemCapability.Multimedia.Audio.Volume + * @deprecated since 9 */ getMaxVolume(volumeType: AudioVolumeType): Promise; /** @@ -1026,6 +1143,7 @@ declare namespace audio { * @param callback Callback used to return the device list. * @since 7 * @syscap SystemCapability.Multimedia.Audio.Device + * @deprecated since 9 */ getDevices(deviceFlag: DeviceFlag, callback: AsyncCallback): void; /** @@ -1034,42 +1152,9 @@ declare namespace audio { * @return Promise used to return the device list. * @since 7 * @syscap SystemCapability.Multimedia.Audio.Device + * @deprecated since 9 */ getDevices(deviceFlag: DeviceFlag): Promise; - /** - * Get the volume group list for a networkId. This method uses an asynchronous callback to return the result. - * @param networkId Device network id - * @param callback Callback used to return the result. - * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Volume - * @systemapi - */ - getVolumeGroups(networkId: string, callback: AsyncCallback): void; - /** - * Get the volume group list for a networkId. This method uses a promise to return the result. - * @param networkId Device network id - * @return Promise used to return the result. - * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Volume - * @systemapi - */ - getVolumeGroups(networkId: string): Promise; - /** - * Obtains an AudioGroupManager instance. This method uses an asynchronous callback to return the result. - * @param callback Callback used to return the result. - * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Volume - * @systemapi - */ - getGroupManager(groupId: number, callback: AsyncCallback): void; - /** - * Obtains an AudioGroupManager instance. This method uses a promise to return the result. - * @param callback Callback used to return the result. - * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Volume - * @systemapi - */ - getGroupManager(groupId: number): Promise; /** * Mutes a stream. This method uses an asynchronous callback to return the result. * @param volumeType Audio stream type. @@ -1077,6 +1162,7 @@ declare namespace audio { * @param callback Callback used to return the result. * @since 7 * @syscap SystemCapability.Multimedia.Audio.Volume + * @deprecated since 9 */ mute(volumeType: AudioVolumeType, mute: boolean, callback: AsyncCallback): void; /** @@ -1086,6 +1172,7 @@ declare namespace audio { * @return Promise used to return the result. * @since 7 * @syscap SystemCapability.Multimedia.Audio.Volume + * @deprecated since 9 */ mute(volumeType: AudioVolumeType, mute: boolean): Promise; /** @@ -1095,6 +1182,7 @@ declare namespace audio { * muted, and false means the opposite. * @since 7 * @syscap SystemCapability.Multimedia.Audio.Volume + * @deprecated since 9 */ isMute(volumeType: AudioVolumeType, callback: AsyncCallback): void; /** @@ -1104,6 +1192,7 @@ declare namespace audio { * and false means the opposite. * @since 7 * @syscap SystemCapability.Multimedia.Audio.Volume + * @deprecated since 9 */ isMute(volumeType: AudioVolumeType): Promise; /** @@ -1113,6 +1202,7 @@ declare namespace audio { * active, and false means the opposite. * @since 7 * @syscap SystemCapability.Multimedia.Audio.Volume + * @deprecated since 9 */ isActive(volumeType: AudioVolumeType, callback: AsyncCallback): void; /** @@ -1122,6 +1212,7 @@ declare namespace audio { * and false means the opposite. * @since 7 * @syscap SystemCapability.Multimedia.Audio.Volume + * @deprecated since 9 */ isActive(volumeType: AudioVolumeType): Promise; /** @@ -1131,6 +1222,7 @@ declare namespace audio { * @since 7 * @syscap SystemCapability.Multimedia.Audio.Device * @permission ohos.permission.MICROPHONE + * @deprecated since 9 */ setMicrophoneMute(mute: boolean, callback: AsyncCallback): void; /** @@ -1140,6 +1232,7 @@ declare namespace audio { * @since 7 * @syscap SystemCapability.Multimedia.Audio.Device * @permission ohos.permission.MICROPHONE + * @deprecated since 9 */ setMicrophoneMute(mute: boolean): Promise; /** @@ -1149,6 +1242,7 @@ declare namespace audio { * @since 7 * @syscap SystemCapability.Multimedia.Audio.Device * @permission ohos.permission.MICROPHONE + * @deprecated since 9 */ isMicrophoneMute(callback: AsyncCallback): void; /** @@ -1158,6 +1252,7 @@ declare namespace audio { * @since 7 * @syscap SystemCapability.Multimedia.Audio.Device * @permission ohos.permission.MICROPHONE + * @deprecated since 9 */ isMicrophoneMute(): Promise; /** @@ -1167,6 +1262,7 @@ declare namespace audio { * @since 7 * @syscap SystemCapability.Multimedia.Audio.Communication * @permission ohos.permission.ACCESS_NOTIFICATION_POLICY + * @deprecated since 9 */ setRingerMode(mode: AudioRingMode, callback: AsyncCallback): void; /** @@ -1176,6 +1272,7 @@ declare namespace audio { * @since 7 * @syscap SystemCapability.Multimedia.Audio.Communication * @permission ohos.permission.ACCESS_NOTIFICATION_POLICY + * @deprecated since 9 */ setRingerMode(mode: AudioRingMode): Promise; /** @@ -1183,6 +1280,7 @@ declare namespace audio { * @param callback Callback used to return the ringer mode. * @since 7 * @syscap SystemCapability.Multimedia.Audio.Communication + * @deprecated since 9 */ getRingerMode(callback: AsyncCallback): void; /** @@ -1190,6 +1288,7 @@ declare namespace audio { * @return Promise used to return the ringer mode. * @since 7 * @syscap SystemCapability.Multimedia.Audio.Communication + * @deprecated since 9 */ getRingerMode(): Promise; /** @@ -1200,6 +1299,7 @@ declare namespace audio { * @since 7 * @syscap SystemCapability.Multimedia.Audio.Core * @permission ohos.permission.MODIFY_AUDIO_SETTINGS + * @deprecated since 9 */ setAudioParameter(key: string, value: string, callback: AsyncCallback): void; /** @@ -1210,6 +1310,7 @@ declare namespace audio { * @since 7 * @syscap SystemCapability.Multimedia.Audio.Core * @permission ohos.permission.MODIFY_AUDIO_SETTINGS + * @deprecated since 9 */ setAudioParameter(key: string, value: string): Promise; /** @@ -1218,6 +1319,7 @@ declare namespace audio { * @param callback Callback used to return the value of the audio parameter. * @since 7 * @syscap SystemCapability.Multimedia.Audio.Core + * @deprecated since 9 */ getAudioParameter(key: string, callback: AsyncCallback): void; /** @@ -1226,6 +1328,7 @@ declare namespace audio { * @return Promise used to return the value of the audio parameter. * @since 7 * @syscap SystemCapability.Multimedia.Audio.Core + * @deprecated since 9 */ getAudioParameter(key: string): Promise; /** @@ -1236,6 +1339,7 @@ declare namespace audio { * @param callback Callback used to return the result. * @since 7 * @syscap SystemCapability.Multimedia.Audio.Device + * @deprecated since 9 */ setDeviceActive(deviceType: ActiveDeviceType, active: boolean, callback: AsyncCallback): void; /** @@ -1246,6 +1350,7 @@ declare namespace audio { * @return Promise used to return the result. * @since 7 * @syscap SystemCapability.Multimedia.Audio.Device + * @deprecated since 9 */ setDeviceActive(deviceType: ActiveDeviceType, active: boolean): Promise; /** @@ -1254,6 +1359,7 @@ declare namespace audio { * @param callback Callback used to return the active status of the device. * @since 7 * @syscap SystemCapability.Multimedia.Audio.Device + * @deprecated since 9 */ isDeviceActive(deviceType: ActiveDeviceType, callback: AsyncCallback): void; /** @@ -1262,6 +1368,7 @@ declare namespace audio { * @return Promise used to return the active status of the device. * @since 7 * @syscap SystemCapability.Multimedia.Audio.Device + * @deprecated since 9 */ isDeviceActive(deviceType: ActiveDeviceType): Promise; /** @@ -1270,6 +1377,7 @@ declare namespace audio { * @since 8 * @syscap SystemCapability.Multimedia.Audio.Volume * @systemapi + * @deprecated since 9 */ on(type: 'volumeChange', callback: Callback): void; /** @@ -1278,6 +1386,7 @@ declare namespace audio { * @since 8 * @syscap SystemCapability.Multimedia.Audio.Communication * @systemapi + * @deprecated since 9 */ on(type: 'ringerModeChange', callback: Callback): void; /** @@ -1288,6 +1397,7 @@ declare namespace audio { * @since 8 * @syscap SystemCapability.Multimedia.Audio.Communication * @systemapi + * @deprecated since 9 */ setAudioScene(scene: AudioScene, callback: AsyncCallback ): void; /** @@ -1297,6 +1407,7 @@ declare namespace audio { * @since 8 * @syscap SystemCapability.Multimedia.Audio.Communication * @systemapi + * @deprecated since 9 */ setAudioScene(scene: AudioScene): Promise; /** @@ -1304,6 +1415,7 @@ declare namespace audio { * @param callback Callback used to return the audio scene mode. * @since 8 * @syscap SystemCapability.Multimedia.Audio.Communication + * @deprecated since 9 */ getAudioScene(callback: AsyncCallback): void; /** @@ -1311,6 +1423,7 @@ declare namespace audio { * @return Promise used to return the audio scene mode. * @since 8 * @syscap SystemCapability.Multimedia.Audio.Communication + * @deprecated since 9 */ getAudioScene(): Promise; /** @@ -1319,6 +1432,7 @@ declare namespace audio { * @param callback Callback used to obtain the device update details. * @since 7 * @syscap SystemCapability.Multimedia.Audio.Device + * @deprecated since 9 */ on(type: 'deviceChange', callback: Callback): void; @@ -1327,6 +1441,7 @@ declare namespace audio { * @param callback Callback used to obtain the device update details. * @since 7 * @syscap SystemCapability.Multimedia.Audio.Device + * @deprecated since 9 */ off(type: 'deviceChange', callback?: Callback): void; @@ -1338,6 +1453,7 @@ declare namespace audio { * @param callback Callback invoked for the audio interruption event. * @since 7 * @syscap SystemCapability.Multimedia.Audio.Renderer + * @deprecated since 9 */ on(type: 'interrupt', interrupt: AudioInterrupt, callback: Callback): void; @@ -1348,261 +1464,1316 @@ declare namespace audio { * @param callback Callback invoked for the audio interruption event. * @since 7 * @syscap SystemCapability.Multimedia.Audio.Renderer + * @deprecated since 9 */ off(type: 'interrupt', interrupt: AudioInterrupt, callback?: Callback): void; + } + /** + * Describes an audio device. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Device + */ + interface AudioDeviceDescriptor { /** - * Request independent interrupt event. - * @param focusType The focus type. - * @param callback Callback used to return the result. - * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Renderer - * @systemapi + * Audio device role. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Device */ - requestIndependentInterrupt(focusType: FocusType, callback: AsyncCallback): void; + readonly deviceRole: DeviceRole; /** - * Request independent interrupt event. - * @param focusType The focus type. - * @return Promise used to return the result. - * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Renderer - * @systemapi + * Audio device type. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Device */ - requestIndependentInterrupt(focusType: FocusType): Promise; + readonly deviceType: DeviceType; /** - * Abandon the requested independent interrupt event. - * @param focusType The focus type. - * @param callback Callback used to return the result. + * Audio device id. * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Renderer - * @systemapi + * @SysCap SystemCapability.Multimedia.Audio.Device */ - abandonIndependentInterrupt(focusType: FocusType, callback: AsyncCallback): void; + readonly id: number; /** - * Abandon the requested independent interrupt event. - * @param focusType The focus type. - * @return Promise used to return the result. + * Audio device name. * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Renderer - * @systemapi + * @SysCap SystemCapability.Multimedia.Audio.Device */ - abandonIndependentInterrupt(focusType: FocusType): Promise; + readonly name: string; /** - * Listens for independent interruption events. When the audio of an application is interrupted by another application, - * the callback is invoked to notify the former application. - * @param type Type of the event to listen for. Only the independentInterrupt event is supported. - * @param callback Callback invoked for the independent interruption event. + * Audio device address. * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Renderer - * @systemapi + * @SysCap SystemCapability.Multimedia.Audio.Device */ - on(type: 'independentInterrupt', callback: Callback): void; + readonly address: string; /** - * Cancels the listening of independent interruption events. - * @param type Type of the event to listen for. Only the independentInterrupt event is supported. - * @param callback Callback invoked for the independent interruption event. + * Supported sampling rates. * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Renderer - * @systemapi + * @SysCap SystemCapability.Multimedia.Audio.Device */ - off(type: 'independentInterrupt', callback?: Callback): void; + readonly sampleRates: Array; /** - * Obtains an AudioStreamManager instance. This method uses an asynchronous callback to return the result. - * @param callback Callback used to return the result. + * Supported channel counts. * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Core + * @SysCap SystemCapability.Multimedia.Audio.Device */ - getStreamManager(callback: AsyncCallback): void; + readonly channelCounts: Array; /** - * Obtains an AudioStreamManager instance. This method uses a promise to return the result. - * @return Promise used to return the result. + * Supported channel masks. * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Core + * @SysCap SystemCapability.Multimedia.Audio.Device */ - getStreamManager(): Promise; - + readonly channelMasks: Array; /** - * Obtains an AudioRoutingManager instance. This method uses an asynchronous callback to return the result. - * @param callback Callback used to return the result. + * Device network id * @since 9 * @syscap SystemCapability.Multimedia.Audio.Device + * @systemapi */ - getRoutingManager(callback: AsyncCallback): void; - + readonly networkId: string; /** - * Obtains an AudioRoutingManager instance. This method uses a promise to return the result. - * @param callback Callback used to return the result. + * Interrupt group id + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Device + * @systemapi + */ + readonly interruptGroupId: number; + /** + * Volume group id * @since 9 * @syscap SystemCapability.Multimedia.Audio.Device + * @systemapi */ - getRoutingManager(): Promise; + readonly volumeGroupId: number; } /** - * Implements audio router management. - * @since 9 + * Array of AudioDeviceDescriptors, which is read-only. + * @since 7 * @syscap SystemCapability.Multimedia.Audio.Device */ - interface AudioRoutingManager { + type AudioDeviceDescriptors = Array>; + + /** + * Array of VolumeGroupInfos, which is read-only. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Volume + * @systemapi + */ + type VolumeGroupInfos = Array>; + + /** + * Describes the volume event received by the app when the volume is changed. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Volume + * @systemapi + */ + interface VolumeEvent { /** - * Obtains the audio devices with a specific flag. This method uses an asynchronous callback to return the query result. - * @param deviceFlag Audio device flag. - * @param callback Callback used to return the device list. - * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Device + * Volume type of the current stream. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Volume */ - getDevices(deviceFlag: DeviceFlag, callback: AsyncCallback): void; + volumeType: AudioVolumeType; /** - * Obtains the audio devices with a specific flag. This method uses a promise to return the query result. - * @param deviceFlag Audio device flag. - * @return Promise used to return the device list. - * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Device + * Volume level. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Volume */ - getDevices(deviceFlag: DeviceFlag): Promise; + volume: number; /** - * Subscribes to device change events. When a device is connected/disconnected, registered clients will receive - * the callback. - * @param deviceFlag Audio device flag. - * @param callback Callback used to obtain the device update details. - * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Device + * Whether to show the volume change in UI. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Volume */ - on(type: 'deviceChange', deviceFlag: DeviceFlag, callback: Callback): void; + updateUi: boolean; /** - * UnSubscribes to device change events. - * @param callback Callback used to obtain the device update details. + * volumeGroup id * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Device + * @syscap SystemCapability.Multimedia.Audio.Volume */ - off(type: 'deviceChange', callback?: Callback): void; + volumeGroupId: number; /** - * Select the output device. This method uses an asynchronous callback to return the result. - * @param outputAudioDevices Audio device description - * @param callback Callback used to return the result. + * Device network id * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Device - * @systemapi + * @syscap SystemCapability.Multimedia.Audio.Volume */ - selectOutputDevice(outputAudioDevices: AudioDeviceDescriptors, callback: AsyncCallback): void; + networkId: string; + } + + /** + * Describes the callback invoked for audio interruption or focus gain events.When the audio of an application + * is interrupted by another application, the callback is invoked to notify the former application. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Renderer + * @deprecated since 9 + */ + interface InterruptAction { + /** - * Select the output device. This method uses a promise to return the result. - * @param outputAudioDevices Audio device description - * @return Promise used to return the result. - * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Device - * @systemapi + * Event type. + * The value TYPE_ACTIVATED means the focus gain event, and TYPE_INTERRUPT means the audio interruption event. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Renderer + * @deprecated since 9 */ - selectOutputDevice(outputAudioDevices: AudioDeviceDescriptors): Promise; + actionType: InterruptActionType; + /** - * Select the output device with desired AudioRenderer. This method uses an asynchronous callback to return the result. - * @param filter Filter for AudioRenderer. - * @param outputAudioDevices Audio device description - * @param callback Callback used to return the result. - * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Device - * @systemapi + * Type of the audio interruption event. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Renderer + * @deprecated since 9 */ - selectOutputDeviceByFilter(filter: AudioRendererFilter, outputAudioDevices: AudioDeviceDescriptors, callback: AsyncCallback): void; + type?: InterruptType; + /** - * Select the output device with desired AudioRenderer. This method uses a promise to return the result. - * @param filter Filter for AudioRenderer. - * @param outputAudioDevices Audio device description + * Hint for the audio interruption event. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Renderer + * @deprecated since 9 + */ + hint?: InterruptHint; + + /** + * Whether the focus is gained or released. The value true means that the focus is gained or released, + * and false means that the focus fails to be gained or released. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Renderer + * @deprecated since 9 + */ + activated?: boolean; + } + + /** + * Describes input parameters of audio listening events. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Renderer + * @deprecated since 9 + */ + interface AudioInterrupt { + + /** + * Audio stream usage type. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Renderer + * @deprecated since 9 + */ + streamUsage: StreamUsage; + + /** + * Type of the media interrupted. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Renderer + * @deprecated since 9 + */ + contentType: ContentType; + + /** + * Whether audio playback can be paused when it is interrupted. + * The value true means that audio playback can be paused when it is interrupted, and false means the opposite. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Renderer + * @deprecated since 9 + */ + pauseWhenDucked: boolean; + } + + /** + * Describes the device change type and device information. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Device + */ + interface DeviceChangeAction { + /** + * Device change type. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Device + */ + type: DeviceChangeType; + + /** + * Device information. + * @since 7 + * @syscap SystemCapability.Multimedia.Audio.Device + */ + deviceDescriptors: AudioDeviceDescriptors; + } + + /** + * Provides audio playback APIs. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Renderer + * @deprecated since 9 + */ + interface AudioRenderer { + /** + * Defines the current render state. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Renderer + * @deprecated since 9 + */ + readonly state: AudioState; + /** + * Obtains the renderer information provided while creating a renderer instance. This method uses an asynchronous + * callback to return the result. + * @param callback Callback used to return the renderer information. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Renderer + * @deprecated since 9 + */ + getRendererInfo(callback: AsyncCallback): void; + /** + * Obtains the renderer information provided while creating a renderer instance. This method uses a promise to + * return the result. + * @return Promise used to return the renderer information. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Renderer + * @deprecated since 9 + */ + getRendererInfo(): Promise; + /** + * Obtains the renderer stream information. This method uses an asynchronous callback to return the result. + * @param callback Callback used to return the stream information. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Renderer + * @deprecated since 9 + */ + getStreamInfo(callback: AsyncCallback): void; + /** + * Obtains the renderer stream information. This method uses a promise to return the result. + * @return Promise used to return the stream information. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Renderer + * @deprecated since 9 + */ + getStreamInfo(): Promise; + /** + * Starts the renderer. This method uses an asynchronous callback to return the result. + * @param callback Callback used to return the result. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Renderer + * @deprecated since 9 + */ + start(callback: AsyncCallback): void; + /** + * Starts the renderer. This method uses a promise to return the result. + * @return Promise used to return the result. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Renderer + * @deprecated since 9 + */ + start(): Promise; + /** + * Writes the buffer. This method uses an asynchronous callback to return the result. + * @param buffer Buffer to be written. + * @param callback Returns the number of bytes written if the operation is successful; returns an error code + * otherwise. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Renderer + * @deprecated since 9 + */ + write(buffer: ArrayBuffer, callback: AsyncCallback): void; + /** + * Writes the buffer. This method uses a promise to return the result. + * @param buffer Buffer to be written. + * @return Returns the number of bytes written if the operation is successful; returns an error code otherwise. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Renderer + * @deprecated since 9 + */ + write(buffer: ArrayBuffer): Promise; + /** + * Obtains the timestamp in Unix epoch time (starts from January 1, 1970), in nanoseconds. This method uses an + * asynchronous callback to return the result. + * @param callback Callback used to return the timestamp. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Renderer + * @deprecated since 9 + */ + getAudioTime(callback: AsyncCallback): void; + /** + * Obtains the timestamp in Unix epoch time (starts from January 1, 1970), in nanoseconds. This method uses a + * promise to return the result. + * @return Promise used to return the timestamp. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Renderer + * @deprecated since 9 + */ + getAudioTime(): Promise; + /** + * Drains the playback buffer. This method uses an asynchronous callback to return the result. + * @param callback Callback used to return the result. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Renderer + * @deprecated since 9 + */ + drain(callback: AsyncCallback): void; + /** + * Drains the playback buffer. This method uses a promise to return the result. + * @return Promise used to return the result. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Renderer + * @deprecated since 9 + */ + drain(): Promise; + /** + * Pauses rendering. This method uses an asynchronous callback to return the result. + * @param callback Callback used to return the result. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Renderer + * @deprecated since 9 + */ + pause(callback: AsyncCallback): void; + /** + * Pauses rendering. This method uses a promise to return the result. + * @return Promise used to return the result. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Renderer + * @deprecated since 9 + */ + pause(): Promise; + /** + * Stops rendering. This method uses an asynchronous callback to return the result. + * @param callback Callback used to return the result. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Renderer + * @deprecated since 9 + */ + stop(callback: AsyncCallback): void; + /** + * Stops rendering. This method uses a promise to return the result. + * @return Promise used to return the result. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Renderer + * @deprecated since 9 + */ + stop(): Promise; + /** + * Releases the renderer. This method uses an asynchronous callback to return the result. + * @param callback Callback used to return the result. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Renderer + * @deprecated since 9 + */ + release(callback: AsyncCallback): void; + /** + * Releases the renderer. This method uses a promise to return the result. + * @return Promise used to return the result. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Renderer + * @deprecated since 9 + */ + release(): Promise; + /** + * Obtains a reasonable minimum buffer size in bytes for rendering. This method uses an asynchronous callback to + * return the result. + * @param callback Callback used to return the buffer size. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Renderer + * @deprecated since 9 + */ + getBufferSize(callback: AsyncCallback): void; + /** + * Obtains a reasonable minimum buffer size in bytes for rendering. This method uses a promise to return the result. + * @return Promise used to return the buffer size. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Renderer + * @deprecated since 9 + */ + getBufferSize(): Promise; + /** + * Sets the render rate. This method uses an asynchronous callback to return the result. + * @param rate Audio render rate. + * @param callback Callback used to return the result. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Renderer + * @deprecated since 9 + */ + setRenderRate(rate: AudioRendererRate, callback: AsyncCallback): void; + /** + * Sets the render rate. This method uses a promise to return the result. + * @param rate Audio render rate. + * @return Promise used to return the result. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Renderer + * @deprecated since 9 + */ + setRenderRate(rate: AudioRendererRate): Promise; + /** + * Obtains the current render rate. This method uses an asynchronous callback to return the result. + * @param callback Callback used to return the audio render rate. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Renderer + * @deprecated since 9 + */ + getRenderRate(callback: AsyncCallback): void; + /** + * Obtains the current render rate. This method uses a promise to return the result. + * @return Promise used to return the audio render rate. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Renderer + * @deprecated since 9 + */ + getRenderRate(): Promise; + /** + * Subscribes to mark reached events. When the number of frames rendered reaches the value of the frame parameter, + * the callback is invoked. + * @param frame Number of frames to trigger the event. The value must be greater than 0. + * @param callback Callback invoked when the event is triggered. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Renderer + * @deprecated since 9 + */ + on(type: "markReach", frame: number, callback: Callback): void; + /** + * Unsubscribes from mark reached events. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Renderer + * @deprecated since 9 + */ + off(type: "markReach"): void; + /** + * Subscribes to period reached events. When the period of frame rendering reaches the value of frame parameter, + * the callback is invoked. + * @param frame Period during which frame rendering is listened. The value must be greater than 0. + * @param callback Callback invoked when the event is triggered. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Renderer + * @deprecated since 9 + */ + on(type: "periodReach", frame: number, callback: Callback): void; + /** + * Unsubscribes from period reached events. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Renderer + * @deprecated since 9 + */ + off(type: "periodReach"): void; + /** + * Subscribes audio state change event callback. + * @param callback Callback invoked when state change. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Renderer + * @deprecated since 9 + */ + on(type: "stateChange", callback: Callback): void; + } + + /** + * Enumerates source types. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + enum SourceType { + /** + * Invalid source type. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + SOURCE_TYPE_INVALID = -1, + /** + * Mic source type. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + SOURCE_TYPE_MIC = 0, + /** + * Voice communication source type. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + SOURCE_TYPE_VOICE_COMMUNICATION = 7 + } + + /** + * Describes audio capturer information. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Core + * @deprecated since 9 + */ + interface AudioCapturerInfo { + /** + * Audio source type. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Core + * @deprecated since 9 + */ + source: SourceType; + /** + * Audio capturer flags. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Core + * @deprecated since 9 + */ + capturerFlags: number; + } + + /** + * Describes audio capturer configuration options. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Capturer + * @deprecated since 9 + */ + interface AudioCapturerOptions { + /** + * Stream information. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Capturer + * @deprecated since 9 + */ + streamInfo: AudioStreamInfo; + /** + * Capturer information. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Capturer + * @deprecated since 9 + */ + capturerInfo: AudioCapturerInfo; + } + + /** + * Provides APIs for audio recording. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Capturer + * @deprecated since 9 + */ + interface AudioCapturer { + /** + * Defines the current capture state. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Capturer + * @deprecated since 9 + */ + readonly state: AudioState; + /** + * Obtains the capturer information provided while creating a capturer instance. This method uses an asynchronous + * callback to return the result. + * @param callback Callback used to return the capturer information. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Capturer + * @deprecated since 9 + */ + getCapturerInfo(callback: AsyncCallback): void; + /** + * Obtains the capturer information provided while creating a capturer instance. This method uses a promise to + * return the result. + * @return Promise used to return the capturer information. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Capturer + * @deprecated since 9 + */ + getCapturerInfo(): Promise; + + /** + * Obtains the capturer stream information. This method uses an asynchronous callback to return the result. + * @param callback Callback used to return the stream information. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Capturer + * @deprecated since 9 + */ + getStreamInfo(callback: AsyncCallback): void; + /** + * Obtains the capturer stream information. This method uses a promise to return the result. + * @return Promise used to return the stream information. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Capturer + * @deprecated since 9 + */ + getStreamInfo(): Promise; + + /** + * Starts capturing. This method uses an asynchronous callback to return the result. + * @param callback Callback used to return the result. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Capturer + * @deprecated since 9 + */ + start(callback: AsyncCallback): void; + /** + * Starts capturing. This method uses a promise to return the result. + * @return Promise used to return the result. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Capturer + * @deprecated since 9 + */ + start(): Promise; + + /** + * Reads the buffer from the audio capturer. This method uses an asynchronous callback to return the result. + * @param size Number of bytes to read. + * @param isBlockingRead Whether the read operation should be blocked. + * @param callback Callback used to return the buffer. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Capturer + * @deprecated since 9 + */ + read(size: number, isBlockingRead: boolean, callback: AsyncCallback): void; + /** + * Reads the buffer from the audio capturer. This method uses a promise to return the result. + * @param size Number of bytes to read. + * @param isBlockingRead Whether the read operation should be blocked. + * @return Returns the buffer data read if the operation is successful; returns an error code otherwise. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Capturer + * @deprecated since 9 + */ + read(size: number, isBlockingRead: boolean): Promise; + + /** + * Obtains the timestamp in Unix epoch time (starts from January 1, 1970), in nanoseconds. This method uses an + * asynchronous callback to return the result. + * @param callback Callback used to return the timestamp. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Capturer + * @deprecated since 9 + */ + getAudioTime(callback: AsyncCallback): void; + /** + * Obtains the timestamp in Unix epoch time (starts from January 1, 1970), in nanoseconds. This method uses a + * promise to return the result. + * @return Promise used to return the timestamp. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Capturer + * @deprecated since 9 + */ + getAudioTime(): Promise; + + /** + * Stops capturing. This method uses an asynchronous callback to return the result. + * @param callback Callback used to return the result. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Capturer + * @deprecated since 9 + */ + stop(callback: AsyncCallback): void; + /** + * Stops capturing. This method uses a promise to return the result. + * @return Promise used to return the result. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Capturer + * @deprecated since 9 + */ + stop(): Promise; + + /** + * Releases the capturer. This method uses an asynchronous callback to return the result. + * @param callback Callback used to return the result. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Capturer + * @deprecated since 9 + */ + release(callback: AsyncCallback): void; + /** + * Releases the capturer. This method uses a promise to return the result. + * @return Promise used to return the result. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Capturer + * @deprecated since 9 + */ + release(): Promise; + + /** + * Obtains a reasonable minimum buffer size in bytes for capturing. This method uses an asynchronous callback to + * return the result. + * @param callback Callback used to return the buffer size. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Capturer + * @deprecated since 9 + */ + getBufferSize(callback: AsyncCallback): void; + /** + * Obtains a reasonable minimum buffer size in bytes for capturing. This method uses a promise to return the result. + * @return Promise used to return the buffer size. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Capturer + * @deprecated since 9 + */ + getBufferSize(): Promise; + + /** + * Subscribes to mark reached events. When the number of frames captured reaches the value of the frame parameter, + * the callback is invoked. + * @param frame Number of frames to trigger the event. The value must be greater than 0. + * @param callback Callback invoked when the event is triggered. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Capturer + * @deprecated since 9 + */ + on(type: "markReach", frame: number, callback: Callback): void; + /** + * Unsubscribes from the mark reached events. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Capturer + * @deprecated since 9 + */ + off(type: "markReach"): void; + + /** + * Subscribes to period reached events. When the period of frame capturing reaches the value of frame parameter, + * the callback is invoked. + * @param frame Period during which frame capturing is listened. The value must be greater than 0. + * @param callback Callback invoked when the event is triggered. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Capturer + * @deprecated since 9 + */ + on(type: "periodReach", frame: number, callback: Callback): void; + /** + * Unsubscribes from period reached events. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Capturer + * @deprecated since 9 + */ + off(type: "periodReach"): void; + + /** + * Subscribes audio state change event callback. + * @param callback Callback used to listen for the audio state change event. + * @since 8 + * @syscap SystemCapability.Multimedia.Audio.Capturer + * @deprecated since 9 + */ + on(type: "stateChange", callback: Callback): void; + } + + /** + * Obtains an AudioController instance. + * @return AudioController object. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + function getAudioController(): AudioController; + + /** + * Obtains an AudioStreamCapturer instance. This method uses an asynchronous callback to return the capturer instance. + * @param options Capturer configurations. + * @param callback Callback used to return the audio capturer instance. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Capturer + */ + function createAudioStreamCapturer(options: AudioStreamCapturerOptions, callback: AsyncCallback): void; + + /** + * Obtains an AudioStreamCapturer instance. This method uses a promise to return the capturer instance. + * @param options Capturer configurations. + * @return Promise used to return the audio capturer instance. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Capturer + */ + function createAudioStreamCapturer(options: AudioStreamCapturerOptions): Promise; + + /** + * Obtains an AudioStreamRenderer instance. This method uses an asynchronous callback to return the renderer instance. + * @param options Renderer configurations. + * @param callback Callback used to return the audio renderer instance. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + function createAudioStreamRenderer(options: AudioStreamRendererOptions, callback: AsyncCallback): void; + + /** + * Obtains an AudioStreamRenderer instance. This method uses a promise to return the renderer instance. + * @param options Renderer configurations. + * @return Promise used to return the audio renderer instance. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + function createAudioStreamRenderer(options: AudioStreamRendererOptions): Promise; + + /** + * Obtains a TonePlayer instance. This method uses an asynchronous callback to return the renderer instance. + * @param options Tone playing attribute. + * @return Promise used to return the tone player instance. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Tone + */ + function createTonePlayer(options: AudioStreamRendererInfo, callback: AsyncCallback): void; + + /** + * Obtains a TonePlayer instance. This method uses a promise to return the renderer instance. + * @param options Tone playing attribute. + * @return Promise used to return the tone player instance. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Tone + */ + function createTonePlayer(options: AudioStreamRendererInfo): Promise; + + /** + * Implements audio interrupt management. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Interrupt + * @systemapi + */ + interface AudioInterruptManager { + /** + * Request Interrupt event. + * @param focusType The Interrupt type. + * @param eventCallback Callback used to receive interrupt event. + * @return resultCallback Callback used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Interrupt + * @systemapi + */ + on(type: 'requestInterrupt', focusType: FocusType, eventCallback: Callback): boolean; + + /** + * Abandon the requested Interrupt event. + * @param focusType The Interrupt type. + * @return callback Callback used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Interrupt + * @systemapi + */ + off(type: 'requestInterrupt', focusType: FocusType, eventCallback?: Callback): boolean; + } + + /** + * Implements audio volume management. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Volume + */ + interface AudioVolumeManager { + /** + * Get the volume group list for a networkId. This method uses an asynchronous callback to return the result. + * @param networkId Distributed deice net work id + * @param callback Callback used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Volume + * @systemapi + */ + getVolumeGroupInfos(networkId: string, callback: AsyncCallback): void; + /** + * Get the volume group list for a networkId. This method uses a promise to return the result. + * @param networkId Distributed deice net work id + * @return Promise used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Volume + * @systemapi + */ + getVolumeGroupInfos(networkId: string): Promise; + + /** + * Obtains an AudioVolumeGroupManager instance. This method uses an asynchronous callback to return the result. + * @param groupId volume group id, use LOCAL_VOLUME_GROUP_ID in default + * @param callback Callback used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Volume + */ + getVolumeGroup(groupId: number, callback: AsyncCallback): void; + /** + * Obtains an AudioVolumeGroupManager instance. This method uses a promise to return the result. + * @param groupId volume group id, use LOCAL_VOLUME_GROUP_ID in default + * @param callback Callback used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Volume + */ + getVolumeGroup(groupId: number): Promise; + + /** + * Listens for system volume change events. This method uses a callback to get volume change events. + * @param callback Callback used to get the system volume change event. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Volume + */ + on(type: 'volumeChange', callback: Callback): void; + } + + /** + * Implements audio stream management. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + interface AudioStreamManager { + /** + * Get information of current existing audio renderers. + * @param callback Callback used to return the information of current existing audio renderers. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + getCurrentAudioRendererInfoArray(callback: AsyncCallback): void; + /** + * Get information of current existing audio renderers. + * @return Promise used to return the information of current existing audio renderers. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + getCurrentAudioRendererInfoArray(): Promise; + + /** + * Get information of current existing audio capturers. + * @param callback Callback used to return the information of current existing audio capturers. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + getCurrentAudioCapturerInfoArray(callback: AsyncCallback): void; + /** + * Get information of current existing audio capturers. + * @return Promise used to return the information of current existing audio capturers. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + getCurrentAudioCapturerInfoArray(): Promise; + + /** + * Listens for audio renderer change events. When there is any audio renderer change, + * registered clients will receive the callback. + * @param type Type of the event to listen for. Only the audioRendererChange event is supported. + * @param callback Callback invoked for the audio renderer change event. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + on(type: "audioRendererChange", callback: Callback): void; + + /** + * UnSubscribes to audio renderer change events. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + off(type: "audioRendererChange"):void; + + /** + * Listens for audio capturer change events. When there is any audio capturer change, + * registered clients will receive the callback. + * @param type Type of the event to listen for. Only the audioCapturerChange event is supported. + * @param callback Callback invoked for the audio capturer change event. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Capturer + */ + on(type: "audioCapturerChange", callback: Callback): void; + + /** + * UnSubscribes to audio capturer change events. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Capturer + */ + off(type: "audioCapturerChange"):void; + + /** + * Checks whether a stream is active. This method uses an asynchronous callback to return the query result. + * @param volumeType Audio stream type. + * @param callback Callback used to return the active status of the stream. The value true means that the stream is + * active, and false means the opposite. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + isActive(volumeType: AudioVolumeType, callback: AsyncCallback): void; + /** + * Checks whether a stream is active. This method uses a promise to return the query result. + * @param volumeType Audio stream type. + * @return Promise used to return the active status of the stream. The value true means that the stream is active, + * and false means the opposite. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + isActive(volumeType: AudioVolumeType): Promise; + + /** + * Check if system support low latency configuration in audio renderer. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + isAudioRendererLowLatencySupported(streamInfo: AudioStreamInfo, callback: Callback): void; + /** + * Check if system support low latency configuration in audio renderer. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + isAudioRendererLowLatencySupported(streamInfo: AudioStreamInfo): Promise; + } + + /** + * Array of AudioRendererChangeInfo, which is read-only. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + type AudioRendererChangeInfoArray = Array>; + + /** + * Describes audio renderer change information. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + interface AudioRendererChangeInfo { + /** + * Audio stream unique id. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + readonly streamId: number; + + /** + * Uid for audio renderer client application. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer + * @systemapi + */ + readonly clientUid: number; + + /** + * Audio renderer information. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + readonly rendererInfo: AudioStreamRendererInfo; + + /** + * Audio state. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer + * @systemapi + */ + readonly rendererState: AudioState; + + /** + * Audio output devices. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + readonly deviceDescriptors: AudioDeviceDescriptors; + } + + /** + * Array of AudioCapturerChangeInfo, which is read-only. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Capturer + */ + type AudioCapturerChangeInfoArray = Array>; + + /** + * Describes audio capturer change information. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Capturer + */ + interface AudioCapturerChangeInfo { + /** + * Audio stream unique id. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Capturer + */ + readonly streamId: number; + + /** + * Uid for audio capturer client application. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Capturer + * @systemapi + */ + readonly clientUid: number; + + /** + * Audio capturer information. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Capturer + */ + readonly capturerInfo: AudioStreamCapturerInfo; + + /** + * Audio state. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Capturer + * @systemapi + */ + readonly capturerState: AudioState; + + /** + * Audio input devices. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Capturer + */ + readonly deviceDescriptors: AudioDeviceDescriptors; + } + + /** + * Implements audio device and routing management. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Device + */ + interface AudioRoutingManager { + /** + * Obtains the audio devices with a specific flag. This method uses an asynchronous callback to return the query result. + * @param deviceFlag Audio device flag. + * @param callback Callback used to return the device list. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Device + */ + getDevices(deviceFlag: DeviceFlag, callback: AsyncCallback): void; + /** + * Obtains the audio devices with a specific flag. This method uses a promise to return the query result. + * @param deviceFlag Audio device flag. + * @return Promise used to return the device list. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Device + */ + getDevices(deviceFlag: DeviceFlag): Promise; + + /** + * Subscribes to device change events. When a device is connected/disconnected, registered clients will receive + * the callback. + * @param deviceFlag Audio device flag. + * @param callback Callback used to obtain the device update details. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Device + */ + on(type: 'deviceChange', deviceFlag: DeviceFlag, callback: Callback): void; + + /** + * UnSubscribes to device change events. + * @param callback Callback used to obtain the device update details. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Device + */ + off(type: 'deviceChange', callback?: Callback): void; + + /** + * Mutes or unmutes the microphone. This method uses an asynchronous callback to return the result. + * @param mute Mute status to set. The value true means to mute the microphone, and false means the opposite. + * @param callback Callback used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Device + * @permission ohos.permission.MANAGE_AUDIO_CONFIG + */ + setMicrophoneMute(mute: boolean, callback: AsyncCallback): void; + /** + * Mutes or unmutes the microphone. This method uses a promise to return the result. + * @param mute Mute status to set. The value true means to mute the microphone, and false means the opposite. * @return Promise used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Audio.Device - * @systemapi + * @permission ohos.permission.MANAGE_AUDIO_CONFIG */ - selectOutputDeviceByFilter(filter: AudioRendererFilter, outputAudioDevices: AudioDeviceDescriptors): Promise; - } + setMicrophoneMute(mute: boolean): Promise; - /** - * Implements audio stream management. - * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Core - */ - interface AudioStreamManager { /** - * Get information of current existing audio renderers. - * @param callback Callback used to return the information of current existing audio renderers. + * Checks whether the microphone is muted. This method uses an asynchronous callback to return the query result. + * @param Callback used to return the mute status of the microphone. The value true means that the microphone is + * muted, and false means the opposite. * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Renderer + * @syscap SystemCapability.Multimedia.Audio.Device */ - getCurrentAudioRendererInfoArray(callback: AsyncCallback): void; - + isMicrophoneMute(callback: AsyncCallback): void; /** - * Get information of current existing audio renderers. - * @return Promise used to return the information of current existing audio renderers. + * Checks whether the microphone is muted. This method uses a promise to return the query result. + * @return Promise used to return the mute status of the microphone. The value true means that the microphone is + * muted, and false means the opposite. * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Renderer + * @syscap SystemCapability.Multimedia.Audio.Device */ - getCurrentAudioRendererInfoArray(): Promise; + isMicrophoneMute(): Promise; /** - * Get information of current existing audio capturers. - * @param callback Callback used to return the information of current existing audio capturers. + * Listens for system microphone state change events. This method uses a callback to get microphone change events. + * @param callback Callback used to get the system microphone state change event. * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Renderer + * @syscap SystemCapability.Multimedia.Audio.Device */ - getCurrentAudioCapturerInfoArray(callback: AsyncCallback): void; + on(type: 'micStateChange', callback: Callback): void; /** - * Get information of current existing audio capturers. - * @return Promise used to return the information of current existing audio capturers. + * Sets a device to the active state. This method uses an asynchronous callback to return the result. + * @param deviceType Audio device type. + * @param active Active status to set. The value true means to set the device to the active status, and false + * means the opposite. + * @param callback Callback used to return the result. * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Renderer + * @syscap SystemCapability.Multimedia.Audio.Communication */ - getCurrentAudioCapturerInfoArray(): Promise; + setCommunicationDevice(deviceType: ActiveDeviceType, active: boolean, callback: AsyncCallback): void; + /** + * Sets a device to the active state. This method uses a promise to return the result. + * @param deviceType Audio device type. + * @param active Active status to set. The value true means to set the device to the active status, and false + * means the opposite. + * @return Promise used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Communication + */ + setCommunicationDevice(deviceType: CommunicationDeviceType, active: boolean): Promise; /** - * Listens for audio renderer change events. When there is any audio renderer change, - * registered clients will receive the callback. - * @param type Type of the event to listen for. Only the audioRendererChange event is supported. - * @param callback Callback invoked for the audio renderer change event. + * Checks whether a device is active. This method uses an asynchronous callback to return the query result. + * @param deviceType Audio device type. + * @param callback Callback used to return the active status of the device. * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Renderer + * @syscap SystemCapability.Multimedia.Audio.Communication */ - on(type: "audioRendererChange", callback: Callback): void; + isCommunicationDeviceActive(deviceType: CommunicationDeviceType, callback: AsyncCallback): void; + /** + * Checks whether a device is active. This method uses a promise to return the query result. + * @param deviceType Audio device type. + * @return Promise used to return the active status of the device. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Communication + */ + isCommunicationDeviceActive(deviceType: CommunicationDeviceType): Promise; /** - * UnSubscribes to audio renderer change events. + * Select the output device. This method uses an asynchronous callback to return the result. + * @param outputAudioDevices Audio device description + * @param callback Callback used to return the result. * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Renderer + * @syscap SystemCapability.Multimedia.Audio.Device + * @systemapi + */ + selectOutputDevice(outputAudioDevices: AudioDeviceDescriptors, callback: AsyncCallback): void; + /** + * Select the output device. This method uses a promise to return the result. + * @param outputAudioDevices Audio device description + * @return Promise used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Device + * @systemapi */ - off(type: "audioRendererChange"); + selectOutputDevice(outputAudioDevices: AudioDeviceDescriptors): Promise; /** - * Listens for audio capturer change events. When there is any audio capturer change, - * registered clients will receive the callback. - * @param type Type of the event to listen for. Only the audioCapturerChange event is supported. - * @param callback Callback invoked for the audio capturer change event. + * Select the output device with desired AudioRenderer. This method uses an asynchronous callback to return the result. + * @param filter Filter for AudioRenderer. + * @param outputAudioDevices Audio device description + * @param callback Callback used to return the result. * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Capturer + * @syscap SystemCapability.Multimedia.Audio.Device + * @systemapi */ - on(type: "audioCapturerChange", callback: Callback): void; + selectOutputDeviceByFilter(filter: AudioRendererFilter, outputAudioDevices: AudioDeviceDescriptors, callback: AsyncCallback): void; + /** + * Select the output device with desired AudioRenderer. This method uses a promise to return the result. + * @param filter Filter for AudioRenderer. + * @param outputAudioDevices Audio device description + * @return Promise used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Device + * @systemapi + */ + selectOutputDeviceByFilter(filter: AudioRendererFilter, outputAudioDevices: AudioDeviceDescriptors): Promise; + } + /** + * Describes the microphone state change event received by the app when the microphone state is changed. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Device + */ + interface MicStateChangeEvent { /** - * UnSubscribes to audio capturer change events. + * Mic mute state. * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Capturer + * @syscap SystemCapability.Multimedia.Audio.Device */ - off(type: "audioCapturerChange"); + mute: boolean; } /** * Implements audio volume group management. * @since 9 * @syscap SystemCapability.Multimedia.Audio.Volume - * @systemapi */ - interface AudioGroupManager { + interface AudioVolumeGroupManager { /** * Sets the volume for a stream. This method uses an asynchronous callback to return the result. * @param volumeType Audio stream type. @@ -1611,6 +2782,7 @@ declare namespace audio { * @since 9 * @syscap SystemCapability.Multimedia.Audio.Volume * @permission ohos.permission.ACCESS_NOTIFICATION_POLICY + * @systemapi */ setVolume(volumeType: AudioVolumeType, volume: number, callback: AsyncCallback): void; /** @@ -1621,8 +2793,10 @@ declare namespace audio { * @since 9 * @syscap SystemCapability.Multimedia.Audio.Volume * @permission ohos.permission.ACCESS_NOTIFICATION_POLICY + * @systemapi */ setVolume(volumeType: AudioVolumeType, volume: number): Promise; + /** * Obtains the volume of a stream. This method uses an asynchronous callback to return the query result. * @param volumeType Audio stream type. @@ -1639,6 +2813,7 @@ declare namespace audio { * @syscap SystemCapability.Multimedia.Audio.Volume */ getVolume(volumeType: AudioVolumeType): Promise; + /** * Obtains the minimum volume allowed for a stream. This method uses an asynchronous callback to return the query result. * @param volumeType Audio stream type. @@ -1655,6 +2830,7 @@ declare namespace audio { * @syscap SystemCapability.Multimedia.Audio.Volume */ getMinVolume(volumeType: AudioVolumeType): Promise; + /** * Obtains the maximum volume allowed for a stream. This method uses an asynchronous callback to return the query result. * @param volumeType Audio stream type. @@ -1671,6 +2847,7 @@ declare namespace audio { * @syscap SystemCapability.Multimedia.Audio.Volume */ getMaxVolume(volumeType: AudioVolumeType): Promise; + /** * Mutes a stream. This method uses an asynchronous callback to return the result. * @param volumeType Audio stream type. @@ -1678,6 +2855,8 @@ declare namespace audio { * @param callback Callback used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Audio.Volume + * @permission ohos.permission.ACCESS_NOTIFICATION_POLICY + * @systemapi */ mute(volumeType: AudioVolumeType, mute: boolean, callback: AsyncCallback): void; /** @@ -1687,8 +2866,11 @@ declare namespace audio { * @return Promise used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Audio.Volume + * @permission ohos.permission.ACCESS_NOTIFICATION_POLICY + * @systemapi */ mute(volumeType: AudioVolumeType, mute: boolean): Promise; + /** * Checks whether a stream is muted. This method uses an asynchronous callback to return the query result. * @param volumeType Audio stream type. @@ -1707,6 +2889,50 @@ declare namespace audio { * @syscap SystemCapability.Multimedia.Audio.Volume */ isMute(volumeType: AudioVolumeType): Promise; + + /** + * Sets the ringer mode. This method uses an asynchronous callback to return the result. + * @param mode Ringer mode. + * @param callback Callback used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Volume + * @permission ohos.permission.ACCESS_NOTIFICATION_POLICY + * @systemapi + */ + setRingerMode(mode: AudioRingMode, callback: AsyncCallback): void; + /** + * Sets the ringer mode. This method uses a promise to return the result. + * @param mode Ringer mode. + * @return Promise used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Volume + * @permission ohos.permission.ACCESS_NOTIFICATION_POLICY + * @systemapi + */ + setRingerMode(mode: AudioRingMode): Promise; + + /** + * Obtains the ringer mode. This method uses an asynchronous callback to return the query result. + * @param callback Callback used to return the ringer mode. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Volume + */ + getRingerMode(callback: AsyncCallback): void; + /** + * Obtains the ringer mode. This method uses a promise to return the query result. + * @return Promise used to return the ringer mode. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Volume + */ + getRingerMode(): Promise; + + /** + * Listens for ringer mode change events. This method uses a callback to get ringer mode changes. + * @param callback Callback used to get the updated ringer mode. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Volume + */ + on(type: 'ringerModeChange', callback: Callback): void; } /** @@ -1719,13 +2945,14 @@ declare namespace audio { /** * Descript connect type for local device. * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Device + * @syscap SystemCapability.Multimedia.Audio.Volume */ CONNECT_TYPE_LOCAL = 1, + /** * Descript virtual type for local device. * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Device + * @syscap SystemCapability.Multimedia.Audio.Volume */ CONNECT_TYPE_DISTRIBUTED = 2 } @@ -1738,32 +2965,36 @@ declare namespace audio { */ interface VolumeGroupInfo { /** - * Device network id. + * Distributed device net work id. * @since 9 * @syscap SystemCapability.Multimedia.Audio.Volume * @systemapi */ - readonly networkId: string; + readonly networkId: string; + /** * Volume group id. * @since 9 * @syscap SystemCapability.Multimedia.Audio.Volume */ readonly groupId: number; + /** * Volume mapping group id. * @since 9 * @syscap SystemCapability.Multimedia.Audio.Volume */ readonly mappingId: number; + /** * Volume group name. * @since 9 * @syscap SystemCapability.Multimedia.Audio.Volume */ readonly groupName: string; + /** - * Connect type of device for this group. + * Connect type of group device. * @since 9 * @syscap SystemCapability.Multimedia.Audio.Volume */ @@ -1771,397 +3002,404 @@ declare namespace audio { } /** - * Array of VolumeGroupInfos, which is read-only. + * Enumerates tone types for player. * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Volume + * @syscap SystemCapability.Multimedia.Audio.Tone * @systemapi */ - type VolumeGroupInfos = Array>; - - /** - * Array of AudioRendererChangeInfo, which is read-only. - * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Renderer - */ - type AudioRendererChangeInfoArray = Array>; - - /** - * Describes audio renderer change information. - * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Renderer - */ - interface AudioRendererChangeInfo { - /** - * Audio stream unique id. - * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Renderer - */ - readonly streamId: number; - - /** - * Uid for audio renderer client application. - * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Renderer - * @systemapi - */ - readonly clientUid: number; - - /** - * Audio renderer information. - * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Renderer - */ - readonly rendererInfo: AudioRendererInfo; - - /** - * Audio state. - * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Renderer - * @systemapi - */ - readonly rendererState: AudioState; - - /** - * Audio output devices. - * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Renderer - */ - readonly deviceDescriptors: AudioDeviceDescriptors; + enum ToneType { + TONE_TYPE_DIAL_0 = 0, // 0 key + TONE_TYPE_DIAL_1, // 1 key + TONE_TYPE_DIAL_2, // 2 key + TONE_TYPE_DIAL_3, // 3 key + TONE_TYPE_DIAL_4, // 4 key + TONE_TYPE_DIAL_5, // 5 key + TONE_TYPE_DIAL_6, // 6 key + TONE_TYPE_DIAL_7, // 7 key + TONE_TYPE_DIAL_8, // 8 key + TONE_TYPE_DIAL_9, // 9 key + TONE_TYPE_DIAL_S, // * key + TONE_TYPE_DIAL_P, // # key + TONE_TYPE_DIAL_A, // A key + TONE_TYPE_DIAL_B, // B key + TONE_TYPE_DIAL_C, // C key + TONE_TYPE_DIAL_D, // D key + + TONE_TYPE_COMMON_SUPERVISORY_DIAL = 100, + TONE_TYPE_COMMON_SUPERVISORY_BUSY, + TONE_TYPE_COMMON_SUPERVISORY_CONGESTION, + TONE_TYPE_COMMON_SUPERVISORY_RADIO_ACK, + TONE_TYPE_COMMON_SUPERVISORY_RADIO_NOTAVAIL, + TONE_TYPE_COMMON_SUPERVISORY_ERROR, + TONE_TYPE_COMMON_SUPERVISORY_CALL_WAITING, + TONE_TYPE_COMMON_SUPERVISORY_RINGTONE, + + TONE_TYPE_COMMON_PROPRIETARY_BEEP = 200, + TONE_TYPE_COMMON_PROPRIETARY_ACK, + TONE_TYPE_COMMON_PROPRIETARY_NACK, + TONE_TYPE_COMMON_PROPRIETARY_PROMPT, + TONE_TYPE_COMMON_PROPRIETARY_BEEP2, } /** - * Array of AudioCapturerChangeInfo, which is read-only. - * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Capturer - */ - type AudioCapturerChangeInfoArray = Array>; - - /** - * Describes audio capturer change information. + * Provides APIs for tone playing. * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Capturer + * @syscap SystemCapability.Multimedia.Audio.Tone + * @systemapi */ - interface AudioCapturerChangeInfo { + interface TonePlayer { /** - * Audio stream unique id. + * Starts player. This method uses an asynchronous callback to return the result. + * @param type Tone type to play. + * @param callback Callback used to return the result. * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Capturer + * @syscap SystemCapability.Multimedia.Audio.Tone */ - readonly streamId: number; - + load(type: ToneType, callback: AsyncCallback): void; /** - * Uid for audio capturer client application. + * Starts tplayerone. This method uses a promise to return the result. + * @param type Tone type to play. + * @return Promise used to return the result. * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Capturer - * @systemapi + * @syscap SystemCapability.Multimedia.Audio.Tone */ - readonly clientUid: number; + load(type: ToneType): Promise; /** - * Audio capturer information. + * Starts player. This method uses an asynchronous callback to return the result. + * @param callback Callback used to return the result. * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Capturer + * @syscap SystemCapability.Multimedia.Audio.Tone */ - readonly capturerInfo: AudioCapturerInfo; - + start(callback: AsyncCallback): void; /** - * Audio state. + * Starts player. This method uses a promise to return the result. + * @return Promise used to return the result. * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Capturer - * @systemapi + * @syscap SystemCapability.Multimedia.Audio.Tone */ - readonly capturerState: AudioState; + start(): Promise; /** - * Audio input devices. + * Stops player. This method uses an asynchronous callback to return the result. + * @param callback Callback used to return the result. * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Capturer + * @syscap SystemCapability.Multimedia.Audio.Tone */ - readonly deviceDescriptors: AudioDeviceDescriptors; - } - - /** - * Describes an audio device. - * @since 7 - * @syscap SystemCapability.Multimedia.Audio.Device - */ - interface AudioDeviceDescriptor { + stop(callback: AsyncCallback): void; /** - * Audio device role. - * @since 7 - * @syscap SystemCapability.Multimedia.Audio.Device + * Stops player. This method uses a promise to return the result. + * @return Promise used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Tone */ - readonly deviceRole: DeviceRole; + stop(): Promise; /** - * Audio device type. - * @since 7 - * @syscap SystemCapability.Multimedia.Audio.Device + * Releases the player. This method uses an asynchronous callback to return the result. + * @param callback Callback used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Tone */ - readonly deviceType: DeviceType; - + release(callback: AsyncCallback): void; /** - * Audio device id. + * Releases the player. This method uses a promise to return the result. + * @return Promise used to return the result. * @since 9 - * @SysCap SystemCapability.Multimedia.Audio.Device + * @syscap SystemCapability.Multimedia.Audio.Tone */ - readonly id: number; + release(): Promise; + } + /** + * Implements audio volume and audio device management. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + interface AudioController { /** - * Audio device name. + * Sets an audio parameter. This method uses an asynchronous callback to return the result. + * @param key Key of the audio parameter to set. + * @param value Value of the audio parameter to set. + * @param callback Callback used to return the result. * @since 9 - * @SysCap SystemCapability.Multimedia.Audio.Device + * @syscap SystemCapability.Multimedia.Audio.Core + * @permission ohos.permission.MODIFY_AUDIO_SETTINGS */ - readonly name: string; - + setAudioParameter(key: string, value: string, callback: AsyncCallback): void; /** - * Audio device address. + * Sets an audio parameter. This method uses a promise to return the result. + * @param key Key of the audio parameter to set. + * @param value Value of the audio parameter to set. + * @return Promise used to return the result. * @since 9 - * @SysCap SystemCapability.Multimedia.Audio.Device + * @syscap SystemCapability.Multimedia.Audio.Core + * @permission ohos.permission.MODIFY_AUDIO_SETTINGS */ - readonly address: string; + setAudioParameter(key: string, value: string): Promise; /** - * Supported sampling rates. + * Obtains the value of an audio parameter. This method uses an asynchronous callback to return the query result. + * @param key Key of the audio parameter whose value is to be obtained. + * @param callback Callback used to return the value of the audio parameter. * @since 9 - * @SysCap SystemCapability.Multimedia.Audio.Device + * @syscap SystemCapability.Multimedia.Audio.Core */ - readonly sampleRates: Array; - + getAudioParameter(key: string, callback: AsyncCallback): void; /** - * Supported channel counts. + * Obtains the value of an audio parameter. This method uses a promise to return the query result. + * @param key Key of the audio parameter whose value is to be obtained. + * @return Promise used to return the value of the audio parameter. * @since 9 - * @SysCap SystemCapability.Multimedia.Audio.Device + * @syscap SystemCapability.Multimedia.Audio.Core */ - readonly channelCounts: Array; + getAudioParameter(key: string): Promise; /** - * Supported channel masks. + * Sets the audio scene mode to change audio strategies. This method uses an asynchronous callback to return the + * result. + * @param scene Audio scene mode. + * @param callback Callback used to return the result. * @since 9 - * @SysCap SystemCapability.Multimedia.Audio.Device + * @syscap SystemCapability.Multimedia.Audio.Communication + * @systemapi */ - readonly channelMasks: Array; + setAudioScene(scene: AudioScene, callback: AsyncCallback ): void; /** - * Device network id + * Sets the audio scene mode to change audio strategies. This method uses a promise to return the result. + * @param scene Audio scene mode. + * @return Promise used to return the result. * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Device + * @syscap SystemCapability.Multimedia.Audio.Communication * @systemapi */ - readonly networkId: string; + setAudioScene(scene: AudioScene): Promise; + /** - * Interrupt group id + * Obtains the audio scene mode. This method uses an asynchronous callback to return the query result. + * @param callback Callback used to return the audio scene mode. * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Device - * @systemapi + * @syscap SystemCapability.Multimedia.Audio.Communication */ - readonly interruptGroupId: number; + getAudioScene(callback: AsyncCallback): void; /** - * Volume group id + * Obtains the audio scene mode. This method uses a promise to return the query result. + * @return Promise used to return the audio scene mode. * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Device - * @systemapi + * @syscap SystemCapability.Multimedia.Audio.Communication */ - readonly volumeGroupId: number; - } - - /** - * Array of AudioDeviceDescriptors, which is read-only. - * @since 7 - * @syscap SystemCapability.Multimedia.Audio.Device - */ - type AudioDeviceDescriptors = Array>; + getAudioScene(): Promise; - /** - * Describes the volume event received by the app when the volume is changed. - * @since 8 - * @syscap SystemCapability.Multimedia.Audio.Volume - * @systemapi - */ - interface VolumeEvent { - /** - * Volume type of the current stream. - * @since 8 - * @syscap SystemCapability.Multimedia.Audio.Volume - */ - volumeType: AudioVolumeType; /** - * Volume level. - * @since 8 - * @syscap SystemCapability.Multimedia.Audio.Volume + * Obtains an AudioInterruptManager instance. + * @return AudioInterruptManager instance. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Interrupt + * @systemapi */ - volume: number; + getInterruptManager(): AudioInterruptManager; + /** - * Whether to show the volume change in UI. - * @since 8 + * Obtains an AudioVolumeManager instance. + * @return AudioVolumeManager instance. + * @since 9 * @syscap SystemCapability.Multimedia.Audio.Volume */ - updateUi: boolean; + getVolumeManager(): AudioVolumeManager; + /** - * volumeGroup id + * Obtains an AudioStreamManager instance. This method uses an asynchronous callback to return the result. + * @return AudioStreamManager instance. * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Volume + * @syscap SystemCapability.Multimedia.Audio.Core */ - volumeGroupId: number; + getStreamManager(): AudioStreamManager; + /** - * Device network id + * Obtains an AudioRoutingManager instance. + * @return AudioRoutingManager instance. * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Volume + * @syscap SystemCapability.Multimedia.Audio.Device */ - networkId: string; + getRoutingManager(): AudioRoutingManager; } /** - * Describes the callback invoked for audio interruption or focus gain events.When the audio of an application - * is interrupted by another application, the callback is invoked to notify the former application. - * @since 7 + * Describes audio stream renderer format. + * @since 9 * @syscap SystemCapability.Multimedia.Audio.Renderer */ - interface InterruptAction { - + interface AudioStreamRendererFormat { /** - * Event type. - * The value TYPE_ACTIVATED means the focus gain event, and TYPE_INTERRUPT means the audio interruption event. - * @since 7 - * @syscap SystemCapability.Multimedia.Audio.Renderer + * Sampling rate. + * @since 9 */ - actionType: InterruptActionType; + samplingRate: AudioSamplingRate; /** - * Type of the audio interruption event. - * @since 7 - * @syscap SystemCapability.Multimedia.Audio.Renderer + * Audio channel mask. + * @since 9 */ - type?: InterruptType; + channels: AudioRendererChannelMask; /** - * Hint for the audio interruption event. - * @since 7 - * @syscap SystemCapability.Multimedia.Audio.Renderer + * Audio sample format. + * @since 9 */ - hint?: InterruptHint; + sampleFormat: AudioSampleFormat; /** - * Whether the focus is gained or released. The value true means that the focus is gained or released, - * and false means that the focus fails to be gained or released. - * @since 7 - * @syscap SystemCapability.Multimedia.Audio.Renderer + * Audio encoding type. + * @since 9 */ - activated?: boolean; + encodingType: AudioEncodingType; } /** - * Describes input parameters of audio listening events. - * @since 7 + * Describes audio stream renderer information. + * @since 9 * @syscap SystemCapability.Multimedia.Audio.Renderer */ - interface AudioInterrupt { - + interface AudioStreamRendererInfo { /** - * Audio stream usage type. - * @since 7 - * @syscap SystemCapability.Multimedia.Audio.Renderer + * Content type. + * @since 9 */ - streamUsage: StreamUsage; - + content: ContentType; /** - * Type of the media interrupted. - * @since 7 - * @syscap SystemCapability.Multimedia.Audio.Renderer + * Stream usage. + * @since 9 */ - contentType: ContentType; + usage: StreamUsage; + /** + * Audio renderer flags. + * @since 9 + */ + flags: number; + } + /** + * Describes audio stream renderer configuration options. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + interface AudioStreamRendererOptions { /** - * Whether audio playback can be paused when it is interrupted. - * The value true means that audio playback can be paused when it is interrupted, and false means the opposite. - * @since 7 - * @syscap SystemCapability.Multimedia.Audio.Renderer + * Stream information. + * @since 9 */ - pauseWhenDucked: boolean; + streamFormat: AudioStreamRendererFormat; + /** + * Renderer information. + * @since 9 + */ + rendererInfo: AudioStreamRendererInfo; } /** - * Describes the device change type and device information. - * @since 7 - * @syscap SystemCapability.Multimedia.Audio.Device + * Describe data info. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer */ - interface DeviceChangeAction { + interface AudioStreamRendererDataInfo { /** - * Device change type. - * @since 7 - * @syscap SystemCapability.Multimedia.Audio.Device + * Buffer to fill. + * @since 9 */ - type: DeviceChangeType; - + buffer: ArrayBuffer; /** - * Device information. - * @since 7 - * @syscap SystemCapability.Multimedia.Audio.Device + * Data written length. + * @since 9 */ - deviceDescriptors: AudioDeviceDescriptors; + dataLength: number; + /** + * Extend info with buffer. + * @since 9 + */ + bufferFlags: number; } /** * Provides audio playback APIs. - * @since 8 + * @since 9 * @syscap SystemCapability.Multimedia.Audio.Renderer */ - interface AudioRenderer { + interface AudioStreamRenderer { /** * Defines the current render state. - * @since 8 + * @since 9 * @syscap SystemCapability.Multimedia.Audio.Renderer */ readonly state: AudioState; + /** * Obtains the renderer information provided while creating a renderer instance. This method uses an asynchronous * callback to return the result. * @param callback Callback used to return the renderer information. - * @since 8 + * @since 9 * @syscap SystemCapability.Multimedia.Audio.Renderer */ - getRendererInfo(callback: AsyncCallback): void; + getRendererInfo(callback: AsyncCallback): void; /** * Obtains the renderer information provided while creating a renderer instance. This method uses a promise to * return the result. * @return Promise used to return the renderer information. - * @since 8 + * @since 9 * @syscap SystemCapability.Multimedia.Audio.Renderer */ - getRendererInfo(): Promise; + getRendererInfo(): Promise; + /** - * Obtains the renderer stream information. This method uses an asynchronous callback to return the result. - * @param callback Callback used to return the stream information. - * @since 8 + * Obtains the renderer stream format. This method uses an asynchronous callback to return the result. + * @param callback Callback used to return the stream format. + * @since 9 * @syscap SystemCapability.Multimedia.Audio.Renderer */ - getStreamInfo(callback: AsyncCallback): void; + getStreamFormat(callback: AsyncCallback): void; /** - * Obtains the renderer stream information. This method uses a promise to return the result. - * @return Promise used to return the stream information. - * @since 8 + * Obtains the renderer stream format. This method uses a promise to return the result. + * @return Promise used to return the stream format. + * @since 9 * @syscap SystemCapability.Multimedia.Audio.Renderer */ - getStreamInfo(): Promise; + getStreamFormat(): Promise; + + /** + * Obtains the renderer stream id. This method uses an asynchronous callback to return the result. + * @param callback Callback used to return the stream id. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + getAudioStreamId(callback: AsyncCallback): void; + /** + * Obtains the renderer stream id. This method uses a promise to return the result. + * @return Promise used to return the stream id. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + getAudioStreamId(): Promise; + /** * Starts the renderer. This method uses an asynchronous callback to return the result. * @param callback Callback used to return the result. - * @since 8 + * @since 9 * @syscap SystemCapability.Multimedia.Audio.Renderer */ start(callback: AsyncCallback): void; /** * Starts the renderer. This method uses a promise to return the result. * @return Promise used to return the result. - * @since 8 + * @since 9 * @syscap SystemCapability.Multimedia.Audio.Renderer */ start(): Promise; + /** * Writes the buffer. This method uses an asynchronous callback to return the result. * @param buffer Buffer to be written. * @param callback Returns the number of bytes written if the operation is successful; returns an error code * otherwise. - * @since 8 + * @since 9 * @syscap SystemCapability.Multimedia.Audio.Renderer */ write(buffer: ArrayBuffer, callback: AsyncCallback): void; @@ -2169,15 +3407,16 @@ declare namespace audio { * Writes the buffer. This method uses a promise to return the result. * @param buffer Buffer to be written. * @return Returns the number of bytes written if the operation is successful; returns an error code otherwise. - * @since 8 + * @since 9 * @syscap SystemCapability.Multimedia.Audio.Renderer */ write(buffer: ArrayBuffer): Promise; + /** * Obtains the timestamp in Unix epoch time (starts from January 1, 1970), in nanoseconds. This method uses an * asynchronous callback to return the result. * @param callback Callback used to return the timestamp. - * @since 8 + * @since 9 * @syscap SystemCapability.Multimedia.Audio.Renderer */ getAudioTime(callback: AsyncCallback): void; @@ -2185,86 +3424,92 @@ declare namespace audio { * Obtains the timestamp in Unix epoch time (starts from January 1, 1970), in nanoseconds. This method uses a * promise to return the result. * @return Promise used to return the timestamp. - * @since 8 + * @since 9 * @syscap SystemCapability.Multimedia.Audio.Renderer */ getAudioTime(): Promise; + /** * Drains the playback buffer. This method uses an asynchronous callback to return the result. * @param callback Callback used to return the result. - * @since 8 + * @since 9 * @syscap SystemCapability.Multimedia.Audio.Renderer */ drain(callback: AsyncCallback): void; /** * Drains the playback buffer. This method uses a promise to return the result. * @return Promise used to return the result. - * @since 8 + * @since 9 * @syscap SystemCapability.Multimedia.Audio.Renderer */ drain(): Promise; + /** * Pauses rendering. This method uses an asynchronous callback to return the result. * @param callback Callback used to return the result. - * @since 8 + * @since 9 * @syscap SystemCapability.Multimedia.Audio.Renderer */ pause(callback: AsyncCallback): void; /** * Pauses rendering. This method uses a promise to return the result. * @return Promise used to return the result. - * @since 8 + * @since 9 * @syscap SystemCapability.Multimedia.Audio.Renderer */ pause(): Promise; + /** * Stops rendering. This method uses an asynchronous callback to return the result. * @param callback Callback used to return the result. - * @since 8 + * @since 9 * @syscap SystemCapability.Multimedia.Audio.Renderer */ stop(callback: AsyncCallback): void; /** * Stops rendering. This method uses a promise to return the result. * @return Promise used to return the result. - * @since 8 + * @since 9 * @syscap SystemCapability.Multimedia.Audio.Renderer */ stop(): Promise; + /** * Releases the renderer. This method uses an asynchronous callback to return the result. * @param callback Callback used to return the result. - * @since 8 + * @since 9 * @syscap SystemCapability.Multimedia.Audio.Renderer */ release(callback: AsyncCallback): void; /** * Releases the renderer. This method uses a promise to return the result. * @return Promise used to return the result. - * @since 8 + * @since 9 * @syscap SystemCapability.Multimedia.Audio.Renderer */ release(): Promise; + /** * Obtains a reasonable minimum buffer size in bytes for rendering. This method uses an asynchronous callback to * return the result. * @param callback Callback used to return the buffer size. - * @since 8 + * @since 9 * @syscap SystemCapability.Multimedia.Audio.Renderer */ getBufferSize(callback: AsyncCallback): void; /** * Obtains a reasonable minimum buffer size in bytes for rendering. This method uses a promise to return the result. * @return Promise used to return the buffer size. - * @since 8 + * @since 9 * @syscap SystemCapability.Multimedia.Audio.Renderer */ getBufferSize(): Promise; + /** * Sets the render rate. This method uses an asynchronous callback to return the result. * @param rate Audio render rate. * @param callback Callback used to return the result. - * @since 8 + * @since 9 * @syscap SystemCapability.Multimedia.Audio.Renderer */ setRenderRate(rate: AudioRendererRate, callback: AsyncCallback): void; @@ -2272,30 +3517,32 @@ declare namespace audio { * Sets the render rate. This method uses a promise to return the result. * @param rate Audio render rate. * @return Promise used to return the result. - * @since 8 + * @since 9 * @syscap SystemCapability.Multimedia.Audio.Renderer */ setRenderRate(rate: AudioRendererRate): Promise; + /** * Obtains the current render rate. This method uses an asynchronous callback to return the result. * @param callback Callback used to return the audio render rate. - * @since 8 + * @since 9 * @syscap SystemCapability.Multimedia.Audio.Renderer */ getRenderRate(callback: AsyncCallback): void; /** * Obtains the current render rate. This method uses a promise to return the result. * @return Promise used to return the audio render rate. - * @since 8 + * @since 9 * @syscap SystemCapability.Multimedia.Audio.Renderer */ getRenderRate(): Promise; + /** * Set interrupt mode. * @param mode The interrupt mode. * @param callback Callback used to return the result. * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Renderer + * @syscap SystemCapability.Multimedia.Audio.Interrupt */ setInterruptMode(mode: InterruptMode, callback: AsyncCallback): void; /** @@ -2303,177 +3550,225 @@ declare namespace audio { * @param mode The interrupt mode. * @return Promise used to return the result. * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Renderer + * @syscap SystemCapability.Multimedia.Audio.Interrupt */ setInterruptMode(mode: InterruptMode): Promise; + + /** + * Sets the volume for this stream. This method uses an asynchronous callback to return the result. + * @param volume Volume to set. The value range can be obtained by calling getMinVolume and getMaxVolume. + * @param callback Callback used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + setVolume(volume: number, callback: AsyncCallback): void; + /** + * Sets the volume for a stream. This method uses a promise to return the result. + * @param volume Volume to set. The value range can be obtained by calling getMinVolume and getMaxVolume. + * @return Promise used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + setVolume(volume: number): Promise; + /** * Listens for audio interrupt events. This method uses a callback to get interrupt events. The interrupt event is * triggered when audio playback is interrupted. * @param callback Callback used to listen for interrupt callback. * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Renderer + * @syscap SystemCapability.Multimedia.Audio.Interrupt */ - on(type: 'interrupt', callback: Callback): void; + on(type: 'audioInterrupt', callback: Callback): void; + /** * Subscribes to mark reached events. When the number of frames rendered reaches the value of the frame parameter, * the callback is invoked. * @param frame Number of frames to trigger the event. The value must be greater than 0. * @param callback Callback invoked when the event is triggered. - * @since 8 + * @since 9 * @syscap SystemCapability.Multimedia.Audio.Renderer */ on(type: "markReach", frame: number, callback: Callback): void; /** * Unsubscribes from mark reached events. - * @since 8 + * @since 9 * @syscap SystemCapability.Multimedia.Audio.Renderer */ off(type: "markReach"): void; + /** * Subscribes to period reached events. When the period of frame rendering reaches the value of frame parameter, * the callback is invoked. * @param frame Period during which frame rendering is listened. The value must be greater than 0. * @param callback Callback invoked when the event is triggered. - * @since 8 + * @since 9 * @syscap SystemCapability.Multimedia.Audio.Renderer */ on(type: "periodReach", frame: number, callback: Callback): void; /** * Unsubscribes from period reached events. - * @since 8 + * @since 9 * @syscap SystemCapability.Multimedia.Audio.Renderer */ off(type: "periodReach"): void; + /** * Subscribes audio state change event callback. * @param callback Callback invoked when state change. - * @since 8 + * @since 9 * @syscap SystemCapability.Multimedia.Audio.Renderer */ on(type: "stateChange", callback: Callback): void; + + /** + * Subscribes audio data requeset event callback. + * @param callback Callback invoked when need audio data. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + on(type: "dataRequest", callback: Callback): void; } /** - * Enumerates source types. - * @since 8 - * @syscap SystemCapability.Multimedia.Audio.Core + * Describes audio stream capturer format. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Capturer */ - enum SourceType { + interface AudioStreamCapturerFormat { /** - * Invalid source type. - * @since 8 - * @syscap SystemCapability.Multimedia.Audio.Core + * Sampling rate. + * @since 9 */ - SOURCE_TYPE_INVALID = -1, + samplingRate: AudioSamplingRate; + /** - * Mic source type. - * @since 8 - * @syscap SystemCapability.Multimedia.Audio.Core + * Audio channel mask. + * @since 9 */ - SOURCE_TYPE_MIC = 0, + channels: AudioCapturerChannelMask; + /** - * Voice communication source type. - * @since 8 - * @syscap SystemCapability.Multimedia.Audio.Core + * Audio sample format. + * @since 9 */ - SOURCE_TYPE_VOICE_COMMUNICATION = 7 + sampleFormat: AudioSampleFormat; + + /** + * Audio encoding type. + * @since 9 + */ + encodingType: AudioEncodingType; } /** * Describes audio capturer information. - * @since 8 - * @syscap SystemCapability.Multimedia.Audio.Core + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Capturer */ - interface AudioCapturerInfo { + interface AudioStreamCapturerInfo { /** * Audio source type. - * @since 8 - * @syscap SystemCapability.Multimedia.Audio.Core + * @since 9 */ source: SourceType; + /** * Audio capturer flags. - * @since 8 - * @syscap SystemCapability.Multimedia.Audio.Core + * @since 9 */ - capturerFlags: number; + flags: number; } /** * Describes audio capturer configuration options. - * @since 8 + * @since 9 * @syscap SystemCapability.Multimedia.Audio.Capturer */ - interface AudioCapturerOptions { + interface AudioStreamCapturerOptions { /** - * Stream information. - * @since 8 - * @syscap SystemCapability.Multimedia.Audio.Capturer + * Stream format. + * @since 9 */ - streamInfo: AudioStreamInfo; + streamFormat: AudioStreamCapturerFormat; + /** * Capturer information. - * @since 8 - * @syscap SystemCapability.Multimedia.Audio.Capturer + * @since 9 */ - capturerInfo: AudioCapturerInfo; + capturerInfo: AudioStreamCapturerInfo; } /** * Provides APIs for audio recording. - * @since 8 + * @since 9 * @syscap SystemCapability.Multimedia.Audio.Capturer */ - interface AudioCapturer { + interface AudioStreamCapturer { /** * Defines the current capture state. - * @since 8 + * @since 9 * @syscap SystemCapability.Multimedia.Audio.Capturer */ readonly state: AudioState; + /** * Obtains the capturer information provided while creating a capturer instance. This method uses an asynchronous * callback to return the result. * @param callback Callback used to return the capturer information. - * @since 8 + * @since 9 * @syscap SystemCapability.Multimedia.Audio.Capturer */ - getCapturerInfo(callback: AsyncCallback): void; + getCapturerInfo(callback: AsyncCallback): void; /** * Obtains the capturer information provided while creating a capturer instance. This method uses a promise to * return the result. * @return Promise used to return the capturer information. - * @since 8 + * @since 9 * @syscap SystemCapability.Multimedia.Audio.Capturer */ - getCapturerInfo(): Promise; + getCapturerInfo(): Promise; /** * Obtains the capturer stream information. This method uses an asynchronous callback to return the result. * @param callback Callback used to return the stream information. - * @since 8 + * @since 9 * @syscap SystemCapability.Multimedia.Audio.Capturer */ - getStreamInfo(callback: AsyncCallback): void; + getStreamFormat(callback: AsyncCallback): void; /** * Obtains the capturer stream information. This method uses a promise to return the result. * @return Promise used to return the stream information. - * @since 8 + * @since 9 * @syscap SystemCapability.Multimedia.Audio.Capturer */ - getStreamInfo(): Promise; + getStreamFormat(): Promise; + + /** + * Obtains the capturer stream id. This method uses an asynchronous callback to return the result. + * @param callback Callback used to return the stream id. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Capturer + */ + getAudioStreamId(callback: AsyncCallback): void; + /** + * Obtains the capturer stream id. This method uses a promise to return the result. + * @return Promise used to return the stream id. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Capturer + */ + getAudioStreamId(): Promise; /** * Starts capturing. This method uses an asynchronous callback to return the result. * @param callback Callback used to return the result. - * @since 8 + * @since 9 * @syscap SystemCapability.Multimedia.Audio.Capturer */ start(callback: AsyncCallback): void; /** * Starts capturing. This method uses a promise to return the result. * @return Promise used to return the result. - * @since 8 + * @since 9 * @syscap SystemCapability.Multimedia.Audio.Capturer */ start(): Promise; @@ -2483,7 +3778,7 @@ declare namespace audio { * @param size Number of bytes to read. * @param isBlockingRead Whether the read operation should be blocked. * @param callback Callback used to return the buffer. - * @since 8 + * @since 9 * @syscap SystemCapability.Multimedia.Audio.Capturer */ read(size: number, isBlockingRead: boolean, callback: AsyncCallback): void; @@ -2492,7 +3787,7 @@ declare namespace audio { * @param size Number of bytes to read. * @param isBlockingRead Whether the read operation should be blocked. * @return Returns the buffer data read if the operation is successful; returns an error code otherwise. - * @since 8 + * @since 9 * @syscap SystemCapability.Multimedia.Audio.Capturer */ read(size: number, isBlockingRead: boolean): Promise; @@ -2501,7 +3796,7 @@ declare namespace audio { * Obtains the timestamp in Unix epoch time (starts from January 1, 1970), in nanoseconds. This method uses an * asynchronous callback to return the result. * @param callback Callback used to return the timestamp. - * @since 8 + * @since 9 * @syscap SystemCapability.Multimedia.Audio.Capturer */ getAudioTime(callback: AsyncCallback): void; @@ -2509,7 +3804,7 @@ declare namespace audio { * Obtains the timestamp in Unix epoch time (starts from January 1, 1970), in nanoseconds. This method uses a * promise to return the result. * @return Promise used to return the timestamp. - * @since 8 + * @since 9 * @syscap SystemCapability.Multimedia.Audio.Capturer */ getAudioTime(): Promise; @@ -2517,14 +3812,14 @@ declare namespace audio { /** * Stops capturing. This method uses an asynchronous callback to return the result. * @param callback Callback used to return the result. - * @since 8 + * @since 9 * @syscap SystemCapability.Multimedia.Audio.Capturer */ stop(callback: AsyncCallback): void; /** * Stops capturing. This method uses a promise to return the result. * @return Promise used to return the result. - * @since 8 + * @since 9 * @syscap SystemCapability.Multimedia.Audio.Capturer */ stop(): Promise; @@ -2532,14 +3827,14 @@ declare namespace audio { /** * Releases the capturer. This method uses an asynchronous callback to return the result. * @param callback Callback used to return the result. - * @since 8 + * @since 9 * @syscap SystemCapability.Multimedia.Audio.Capturer */ release(callback: AsyncCallback): void; /** * Releases the capturer. This method uses a promise to return the result. * @return Promise used to return the result. - * @since 8 + * @since 9 * @syscap SystemCapability.Multimedia.Audio.Capturer */ release(): Promise; @@ -2548,14 +3843,14 @@ declare namespace audio { * Obtains a reasonable minimum buffer size in bytes for capturing. This method uses an asynchronous callback to * return the result. * @param callback Callback used to return the buffer size. - * @since 8 + * @since 9 * @syscap SystemCapability.Multimedia.Audio.Capturer */ getBufferSize(callback: AsyncCallback): void; /** * Obtains a reasonable minimum buffer size in bytes for capturing. This method uses a promise to return the result. * @return Promise used to return the buffer size. - * @since 8 + * @since 9 * @syscap SystemCapability.Multimedia.Audio.Capturer */ getBufferSize(): Promise; @@ -2565,13 +3860,13 @@ declare namespace audio { * the callback is invoked. * @param frame Number of frames to trigger the event. The value must be greater than 0. * @param callback Callback invoked when the event is triggered. - * @since 8 + * @since 9 * @syscap SystemCapability.Multimedia.Audio.Capturer */ on(type: "markReach", frame: number, callback: Callback): void; /** * Unsubscribes from the mark reached events. - * @since 8 + * @since 9 * @syscap SystemCapability.Multimedia.Audio.Capturer */ off(type: "markReach"): void; @@ -2581,13 +3876,13 @@ declare namespace audio { * the callback is invoked. * @param frame Period during which frame capturing is listened. The value must be greater than 0. * @param callback Callback invoked when the event is triggered. - * @since 8 + * @since 9 * @syscap SystemCapability.Multimedia.Audio.Capturer */ on(type: "periodReach", frame: number, callback: Callback): void; /** * Unsubscribes from period reached events. - * @since 8 + * @since 9 * @syscap SystemCapability.Multimedia.Audio.Capturer */ off(type: "periodReach"): void; @@ -2595,7 +3890,7 @@ declare namespace audio { /** * Subscribes audio state change event callback. * @param callback Callback used to listen for the audio state change event. - * @since 8 + * @since 9 * @syscap SystemCapability.Multimedia.Audio.Capturer */ on(type: "stateChange", callback: Callback): void;