Package com.opentok.android
Class BaseAudioDevice
java.lang.Object
com.opentok.android.BaseAudioDevice
Defines an audio device for use in a session. See
AudioDeviceManager.setAudioDevice(BaseAudioDevice device)
.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
The audio bus marshals audio data between the network and the audio device.static class
Defines the format of the audio when a custom audio driver is used.static enum
Defines values for thegetBluetoothState()
method.static enum
Defines values for thesetOutputMode(OutputMode mode)
method. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract boolean
Stops the audio capturer thread.abstract boolean
Stops the audio renderer thread.protected void
finalize()
Gets the AudioBus instance that this audio device uses.ReturnsBaseAudioDevice.BluetoothState.Connected
if there is a Bluetooth device and audio is being rendered to this device.abstract BaseAudioDevice.AudioSettings
Returns the AudioSettings object defining the audio capture settings used by this device.abstract int
The estimated capturing delay in ms.abstract int
Returns the estimated rendering delay in ms.Returns the audio output mode for the app.abstract BaseAudioDevice.AudioSettings
Returns the AudioSettings object defining the audio rendering settings used by this device.abstract boolean
Requests the audio device to initialize itself for audio sampling.abstract boolean
Requests the audio device to initialize itself for rendering.abstract void
onPause()
Call this method when the activity pauses.abstract void
onResume()
Call this method when the activity resumes.boolean
Set the audio output mode for the app: video (the default) or voice.abstract boolean
Requests that the device start capturing audio samples.abstract boolean
Requests that the device start rendering audio.abstract boolean
Requests that the device stop sampling audio.abstract boolean
Requests that the device stop rendering audio.
-
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
Returns the AudioSettings object defining the audio capture settings used by this device.- Returns:
- AudioSettings The
BaseAudioDevice.AudioSettings
object.
-
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
-
setOutputMode
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
Returns the audio output mode for the app.- See Also:
-
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
ReturnsBaseAudioDevice.BluetoothState.Connected
if there is a Bluetooth device and audio is being rendered to this device. ReturnsBaseAudioDevice.BluetoothState.Disconnected
otherwise.- Returns:
- The current Bluetooth state.
-