Package com.avaya.clientservices.media

## Interface AudioInterface

-     public interface AudioInterface

  The implementation object needs to inherit from BluetoothProfile.ServiceListener

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `addAudioDeviceListener​(AudioDeviceListener listener)` | Add a new listener to be informed when audio devices are added and removed or audio state changes.
    `AudioCapturer` | `createAudioCapturer​(AudioCapturerConfig cfg, AudioStreamListener callback)` | This function creates AudioCapturer object, which provides audio capture control capability.
    `AudioFilePlayer` | `createAudioFilePlayer​(android.content.Context context, AudioFilePlayerListener pAudioFilePlayerListener)` | Create an Audio File Player.
    `AudioMixer` | `createAudioMixer​(AudioMixerConfig cfg)` | This function creates AudioMixer object, which provides audio mixing capability.
    `AudioDevice` | `getActiveDevice()` |
    `AutomaticGainControlConfiguration` | `getAutomaticGainControlConfiguration()` | Gets the Automatic Gain Control configuration.
    `AutomaticGainControlMode` | `getAutomaticGainControlMode()` | Gets the Automatic Gain Control mode.
    `java.util.List<AudioDevice>` | `getDevices()` |
    `EchoCancellationMobileMode` | `getEchoCancellationMobileMode()` | Gets the Mobile Echo Cancellation mode.
    `EchoCancellationMode` | `getEchoCancellationMode()` | Gets the Echo Cancellation mode.
    `AudioMode` | `getMode()` |
    `NoiseSuppressionMode` | `getNoiseSuppressionMode()` | Gets the Noise Suppression mode.
    `AudioDevice` | `getUserRequestedDevice()` |
    `boolean` | `isMuted()` | This function gets's the current mute status for all audio calls
    `boolean` | `isSpeakerMuted()` | This function gets's the current mute status for speaker
    `boolean` | `isYieldBluetoothOnPhoneCall()` | Get flag to auto-yield bluetooth on phone call (incoming or outgoing)
    `boolean` | `mute​(boolean mute)` | This function set's mute status for all audio calls
    `boolean` | `muteSpeaker​(boolean mute)` | This function set's mute status for speaker
    `void` | `registerRecordPlayStatusListener​(AudioRecordPlayStatusListener listener)` | Sets a listener that wants to track playback and recording status.
    `void` | `removeAudioDeviceListener​(AudioDeviceListener listener)` | Remove an existing listener informing when audio device are added and removed.
    `boolean` | `setAutomaticGainControlConfiguration​(AutomaticGainControlConfiguration config)` | Sets the Automatic Gain Control configuration.
    `boolean` | `setAutomaticGainControlMode​(AutomaticGainControlMode mode)` | Sets the Automatic Gain Control mode.
    `boolean` | `setDscp​(int dscpValue)` | This function sets DSCP value for audio.
    `boolean` | `setEchoCancellationMobileMode​(EchoCancellationMobileMode mode)` | Sets the Echo Cancellation Mobile mode.
    `boolean` | `setEchoCancellationMode​(EchoCancellationMode mode)` | Sets the Echo Cancellation mode.
    `void` | `setMode​(AudioMode mode)` | setMode will immediatly set the mode using AudioManager.setMode().
    `boolean` | `setNoiseSuppressionMode​(NoiseSuppressionMode mode)` | Sets the Noise Suppression mode.
    `boolean` | `setUserRequestedDevice​(AudioDevice device)` | User preferred audio device.
    `boolean` | `setYieldBluetoothOnPhoneCall​(boolean yieldBluetoothOnPhoneCall)` | Set flag to auto-yield bluetooth on phone call (incoming or outgoing)
    `boolean` | `yieldBluetooth()` | yield bluetooth

- - ### Method Detail

    - #### setMode

          void setMode​(AudioMode mode)

      setMode will immediatly set the mode using AudioManager.setMode(). If the necessary the media engine will restore the mode if finds that it has been changed either by other applications or by the applicaiton. The application should never call AudioManger.setMode() directly if it is using the AudioInterface APIs.
      Parameters:
        `mode` - Audio mode for the media engine to use.

    - #### getMode

          AudioMode getMode()

      Returns:
        AudioMode as returned by AudioManager.getMode().

    - #### getDevices

          java.util.List<AudioDevice> getDevices()

      Returns:
        List of (AudioDevice) available audio devices.

    - #### getActiveDevice

          AudioDevice getActiveDevice()

      Returns:
        Audio output device currently used by the platform. It may be different from what user selected.

    - #### getUserRequestedDevice

          AudioDevice getUserRequestedDevice()

      Returns:
        Audio device requested by the user.

    - #### setUserRequestedDevice

          boolean setUserRequestedDevice​(AudioDevice device)

      User preferred audio device. This affects both playback and microphone devices. When the audio device is set to HANDSET or SPEAKER, the platform built-in microphone device of the platform is selected. When it is set to WIRED_HEADSET, depending on the headset's capabilities, either the headset's microphone or the platform built-in microphone is selected. When it is set to BLUETOOTH_HEADSET, the headset's microphone is selected.
      Parameters:
        `device` - Selected device
      Returns:
        True if successful, false otherwise.

    - #### yieldBluetooth

          boolean yieldBluetooth()

      yield bluetooth
      Returns:
        `true` if successful; false, otherwise.

    - #### setYieldBluetoothOnPhoneCall

          boolean setYieldBluetoothOnPhoneCall​(boolean yieldBluetoothOnPhoneCall)

      Set flag to auto-yield bluetooth on phone call (incoming or outgoing)
      Parameters:
        `yieldBluetoothOnPhoneCall` - The new yield status
      Returns:
        `true` if successful; false, otherwise.

    - #### isYieldBluetoothOnPhoneCall

          boolean isYieldBluetoothOnPhoneCall()

      Get flag to auto-yield bluetooth on phone call (incoming or outgoing)
      Returns:
        `true` if currently yielding; false, otherwise.

    - #### mute

          boolean mute​(boolean mute)

      This function set's mute status for all audio calls
      Parameters:
        `mute` - The new mute status
      Returns:
        true if successful; false, otherwise.

    - #### isMuted

          boolean isMuted()

      This function gets's the current mute status for all audio calls
      Returns:
        audio mute status

    - #### muteSpeaker

          boolean muteSpeaker​(boolean mute)

      This function set's mute status for speaker
      Parameters:
        `mute` - The new mute status
      Returns:
        true if successful; false, otherwise.

    - #### isSpeakerMuted

          boolean isSpeakerMuted()

      This function gets's the current mute status for speaker
      Returns:
        speaker mute status

    - #### createAudioFilePlayer

          AudioFilePlayer createAudioFilePlayer​(android.content.Context context,
                                                AudioFilePlayerListener pAudioFilePlayerListener)

      Create an Audio File Player.
      Parameters:
        `context` - Caller's context
        `pAudioFilePlayerListener` - AudioFilePlayerListener for start/stop events.
      Returns:
        AudioFilePlayer to control audio playback.

    - #### registerRecordPlayStatusListener

          void registerRecordPlayStatusListener​(AudioRecordPlayStatusListener listener)

      Sets a listener that wants to track playback and recording status. This is used for notifying when media streams are initialized, started or stopped.
      Parameters:
        `listener` - Listener instance.

    - #### addAudioDeviceListener

          void addAudioDeviceListener​(AudioDeviceListener listener)

      Add a new listener to be informed when audio devices are added and removed or audio state changes.
      Parameters:
        `listener` - The new listener.

    - #### removeAudioDeviceListener

          void removeAudioDeviceListener​(AudioDeviceListener listener)

      Remove an existing listener informing when audio device are added and removed. or audio state changes.
      Parameters:
        `listener` - The listener to be removed.

    - #### setEchoCancellationMode

          boolean setEchoCancellationMode​(EchoCancellationMode mode)

      Sets the Echo Cancellation mode.
      Parameters:
        `mode` - EchoCancellationMode
      Returns:
        success (true) or failure (false)

    - #### getEchoCancellationMode

          EchoCancellationMode getEchoCancellationMode()

      Gets the Echo Cancellation mode.
      Returns:
        EchoCancellationMode on success, null on failure

    - #### setEchoCancellationMobileMode

          boolean setEchoCancellationMobileMode​(EchoCancellationMobileMode mode)

      Sets the Echo Cancellation Mobile mode.
      Parameters:
        `mode` - EchoCancellationMobileMode
      Returns:
        success (true) or failure (false)

    - #### getEchoCancellationMobileMode

          EchoCancellationMobileMode getEchoCancellationMobileMode()

      Gets the Mobile Echo Cancellation mode.
      Returns:
        EchoCancellationMobileMode on success, null on failure

    - #### setNoiseSuppressionMode

          boolean setNoiseSuppressionMode​(NoiseSuppressionMode mode)

      Sets the Noise Suppression mode.
      Parameters:
        `mode` - NoiseSuppressionMode
      Returns:
        success (true) or failure (false)

    - #### getNoiseSuppressionMode

          NoiseSuppressionMode getNoiseSuppressionMode()

      Gets the Noise Suppression mode.
      Returns:
        NoiseSuppressionMode on success, null on failure

    - #### setAutomaticGainControlMode

          boolean setAutomaticGainControlMode​(AutomaticGainControlMode mode)

      Sets the Automatic Gain Control mode.
      Parameters:
        `mode` - AutomaticGainControlMode
      Returns:
        success (true) or failure (false)

    - #### getAutomaticGainControlMode

          AutomaticGainControlMode getAutomaticGainControlMode()

      Gets the Automatic Gain Control mode.
      Returns:
        AutomaticGainControlMode on success, null on failure

    - #### setAutomaticGainControlConfiguration

          boolean setAutomaticGainControlConfiguration​(AutomaticGainControlConfiguration config)

      Sets the Automatic Gain Control configuration.
      Parameters:
        `config` - AutomaticGainControlConfiguration object
      Returns:
        success (true) or failure (false)

    - #### getAutomaticGainControlConfiguration

          AutomaticGainControlConfiguration getAutomaticGainControlConfiguration()

      Gets the Automatic Gain Control configuration.
      Returns:
        AutomaticGainControlConfiguration object with configuration on success, null on failure

    - #### setDscp

          boolean setDscp​(int dscpValue)

      This function sets DSCP value for audio.
      Parameters:
        `dscpValue` - DSCP value must be in range 0-63.
      Returns:
        true if DSCP value is set, otherwise false.

    - #### createAudioCapturer

          AudioCapturer createAudioCapturer​(AudioCapturerConfig cfg,
                                            AudioStreamListener callback)
                                     throws AudioCapturerException

      This function creates AudioCapturer object, which provides audio capture control capability.
      Parameters:
        `cfg` - Configuration for audio capturing
        `callback` - A callback object, which will receive an incoming audio stream
      Returns:
        AudioCapturer object, which can be used for audio capture control
      Throws:
        `AudioCapturerException` - when fails to initialize AudioCapturer, refer to logs for more information

    - #### createAudioMixer

          AudioMixer createAudioMixer​(AudioMixerConfig cfg)
                               throws AudioMixerException

      This function creates AudioMixer object, which provides audio mixing capability.
      Parameters:
        `cfg` - Configuration for audio mixing
      Returns:
        AudioMixer object, which can be used for providing data for mixing
      Throws:
        `AudioMixerException` - when fails to initialize AudioMixer, refer to logs for more information