Class BaseAudioDevice

java.lang.Object
com.opentok.android.BaseAudioDevice

public abstract class BaseAudioDevice extends Object
Defines an audio device for use in a session. See AudioDeviceManager.setAudioDevice(BaseAudioDevice device).
  • Constructor Details

    • BaseAudioDevice

      public BaseAudioDevice()
  • Method Details

    • initCapturer

      public abstract boolean initCapturer()
      Requests the audio device to initialize itself for audio sampling. Call this method before attempting to start sampling.
    • startCapturer

      public abstract boolean startCapturer()
      Requests that the device start capturing audio samples. After successful return from this function, the audio bus is ready to receive audio sample data.
    • stopCapturer

      public abstract boolean stopCapturer()
      Requests that the device stop sampling audio.
    • destroyCapturer

      public abstract boolean destroyCapturer()
      Stops the audio capturer thread.
    • initRenderer

      public abstract boolean initRenderer()
      Requests the audio device to initialize itself for rendering. Call this method before attempting to start rendering.
    • startRenderer

      public abstract boolean startRenderer()
      Requests that the device start rendering audio. After successful return from this function, audio samples become available on the audio bus.
    • stopRenderer

      public abstract boolean stopRenderer()
      Requests that the device stop rendering audio.
    • destroyRenderer

      public abstract boolean destroyRenderer()
      Stops the audio renderer thread.
    • getEstimatedCaptureDelay

      public abstract int getEstimatedCaptureDelay()
      The estimated capturing delay in ms. This is used to adjust timing transmission information for encoded audio samples.
    • getEstimatedRenderDelay

      public abstract int getEstimatedRenderDelay()
      Returns the estimated rendering delay in ms. This is used to adjust audio signal processing and rendering.
    • getCaptureSettings

      public abstract BaseAudioDevice.AudioSettings getCaptureSettings()
      Returns the AudioSettings object defining the audio capture settings used by this device.
      Returns:
      AudioSettings The BaseAudioDevice.AudioSettings object.
    • getRenderSettings

      public abstract BaseAudioDevice.AudioSettings getRenderSettings()
      Returns the AudioSettings object defining the audio rendering settings used by this device.
      Returns:
      AudioSettings The BaseAudioDevice.AudioSettings object.
    • onPause

      public abstract void onPause()
      Call this method when the activity pauses. When you override this method, implement code to respond to the activity being paused. For example, you may pause capturing and rendering audio.
      See Also:
    • onResume

      public abstract void onResume()
      Call this method when the activity resumes. When you override this method, implement code to respond to the activity being resumed. For example, you may resume capturing and rendering audio.
      See Also:
    • finalize

      protected void finalize() throws Throwable
      Overrides:
      finalize in class Object
      Throws:
      Throwable
    • setOutputMode

      public boolean setOutputMode(BaseAudioDevice.OutputMode mode)
      Set the audio output mode for the app: video (the default) or voice. The audio output mode defines which audio outputs are used:

      • OutputMode.SpeakerPhone — Pass in this value to set the audio output mode for video communication (the default setting). When using the default audio driver, the app uses the device loudspeaker instead of the headset speaker. This is preferable for apps that include both video and audio.
      • OutputMode.Handset — Pass in this value to set the audio output mode for voice communication. When using the default audio driver, the app uses the headset speaker (and the loudspeaker is disabled), so that the device can be used as in a regular phone call. This is preferable in voice-only apps. When a Bluetooth device is connected, this will send the audio to it instead of the Handset.

      Call this method before you connect to a session.

      The following code sets the app to use handset audio output mode, which is preferred in a voice-only app:

       AudioDeviceManager.getAudioDevice().setOutputMode(OutputMode.Handset);
       
      Parameters:
      mode - The audio output mode for the app.
    • getOutputMode

      public BaseAudioDevice.OutputMode getOutputMode()
      Returns the audio output mode for the app.
      See Also:
    • getAudioBus

      public BaseAudioDevice.AudioBus getAudioBus()
      Gets the AudioBus instance that this audio device uses. Use the AudioBus instance to send and receive audio samples to and from a session.
    • getBluetoothState

      public BaseAudioDevice.BluetoothState getBluetoothState()
      Returns BaseAudioDevice.BluetoothState.Connected if there is a Bluetooth device and audio is being rendered to this device. Returns BaseAudioDevice.BluetoothState.Disconnected otherwise.
      Returns:
      The current Bluetooth state.