Package com.opentok.android
Class BaseAudioDevice
- java.lang.Object
-
- com.opentok.android.BaseAudioDevice
-
public abstract class BaseAudioDevice extends java.lang.ObjectDefines an audio device for use in a session. SeeAudioDeviceManager.setAudioDevice(BaseAudioDevice device).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classBaseAudioDevice.AudioBusThe audio bus marshals audio data between the network and the audio device.static classBaseAudioDevice.AudioSettingsDefines the format of the audio when a custom audio driver is used.static classBaseAudioDevice.BluetoothStateDefines values for thegetBluetoothState()method.static classBaseAudioDevice.OutputModeDefines values for thesetOutputMode(OutputMode mode)method.
-
Constructor Summary
Constructors Constructor Description BaseAudioDevice()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract booleandestroyCapturer()Stops the audio capturer thread.abstract booleandestroyRenderer()Stops the audio renderer thread.protected voidfinalize()BaseAudioDevice.AudioBusgetAudioBus()Gets the AudioBus instance that this audio device uses.BaseAudioDevice.BluetoothStategetBluetoothState()ReturnsBaseAudioDevice.BluetoothState.Connectedif there is a Bluetooth device and audio is being rendered to this device.abstract BaseAudioDevice.AudioSettingsgetCaptureSettings()Returns the AudioSettings object defining the audio capture settings used by this device.abstract intgetEstimatedCaptureDelay()The estimated capturing delay in ms.abstract intgetEstimatedRenderDelay()Returns the estimated rendering delay in ms.BaseAudioDevice.OutputModegetOutputMode()Returns the audio output mode for the app.abstract BaseAudioDevice.AudioSettingsgetRenderSettings()Returns the AudioSettings object defining the audio rendering settings used by this device.abstract booleaninitCapturer()Requests the audio device to initialize itself for audio sampling.abstract booleaninitRenderer()Requests the audio device to initialize itself for rendering.abstract voidonPause()Call this method when the activity pauses.abstract voidonResume()Call this method when the activity resumes.booleansetOutputMode(BaseAudioDevice.OutputMode mode)Set the audio output mode for the app: video (the default) or voice.abstract booleanstartCapturer()Requests that the device start capturing audio samples.abstract booleanstartRenderer()Requests that the device start rendering audio.abstract booleanstopCapturer()Requests that the device stop sampling audio.abstract booleanstopRenderer()Requests that the device stop rendering audio.
-
-
-
Method Detail
-
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.AudioSettingsobject.
-
getRenderSettings
public abstract BaseAudioDevice.AudioSettings getRenderSettings()
Returns the AudioSettings object defining the audio rendering settings used by this device.- Returns:
- AudioSettings The
BaseAudioDevice.AudioSettingsobject.
-
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()
-
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:
onPause()
-
finalize
protected void finalize() throws java.lang.Throwable- Overrides:
finalizein classjava.lang.Object- Throws:
java.lang.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:
setOutputMode(OutputMode mode)
-
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()
ReturnsBaseAudioDevice.BluetoothState.Connectedif there is a Bluetooth device and audio is being rendered to this device. ReturnsBaseAudioDevice.BluetoothState.Disconnectedotherwise.- Returns:
- The current Bluetooth state.
-
-