Package com.twilio.video
Interface AudioDevice
-
- All Superinterfaces:
AudioDeviceCapturer
,AudioDeviceRenderer
- All Known Implementing Classes:
DefaultAudioDevice
public interface AudioDevice extends AudioDeviceCapturer, AudioDeviceRenderer
AudioDevice interface allows developers to inject custom audio device capturer and audio device renderer of audio by replacing the default device used by the SDK.
-
-
Method Summary
Static Methods Modifier and Type Method Description static void
audioDeviceExecuteWorkerBlock(AudioDeviceContext audioDeviceContext, java.lang.Runnable runnable)
A utility method to execute a runnable on the media engine's worker thread asynchronously.static void
audioDeviceFormatChanged(AudioDeviceContext audioDeviceContext)
This method should be called any time the capturing or rendering format changes.static void
audioDeviceReadRenderData(AudioDeviceContext audioDeviceContext, java.nio.ByteBuffer audioSample)
This method needs to be called byAudioDeviceRenderer
to pull renderable audio data from the media engine.static void
audioDeviceWriteCaptureData(AudioDeviceContext audioDeviceContext, java.nio.ByteBuffer audioSample)
This method needs to be called byAudioDeviceCapturer
implementation to provide captured data to the media engine.-
Methods inherited from interface com.twilio.video.AudioDeviceCapturer
getCapturerFormat, onInitCapturer, onStartCapturing, onStopCapturing
-
Methods inherited from interface com.twilio.video.AudioDeviceRenderer
getRendererFormat, onInitRenderer, onStartRendering, onStopRendering
-
-
-
-
Method Detail
-
audioDeviceFormatChanged
static void audioDeviceFormatChanged(@NonNull AudioDeviceContext audioDeviceContext)
This method should be called any time the capturing or rendering format changes. If both format change simultaneously its fine to call this method just once. As a result, the media engine will read the new audio format, stop capturing and/or rendering by callingAudioDeviceCapturer.onStopCapturing()
and/orAudioDeviceRenderer.onStopRendering()
and then callAudioDeviceCapturer.onStartCapturing(AudioDeviceContext)
and/orAudioDeviceRenderer.onStartRendering(AudioDeviceContext)
.- Parameters:
audioDeviceContext
- The AudioDevice context. You should use the same context provided inAudioDeviceCapturer.onStartCapturing(AudioDeviceContext)
and/orAudioDeviceRenderer.onStartRendering(AudioDeviceContext)
here.
-
audioDeviceWriteCaptureData
static void audioDeviceWriteCaptureData(@NonNull AudioDeviceContext audioDeviceContext, @NonNull java.nio.ByteBuffer audioSample)
This method needs to be called byAudioDeviceCapturer
implementation to provide captured data to the media engine. WhenAudioDeviceCapturer.onStartCapturing(AudioDeviceContext)
callback is raised, call this method in a loop to provide captured data to media engine.- Parameters:
audioDeviceContext
- The AudioDevice context. You should use the same context provided inAudioDeviceCapturer.onStartCapturing(AudioDeviceContext)
and/orAudioDeviceRenderer.onStartRendering(AudioDeviceContext)
here.audioSample
- Audio data you wish to deliver.
-
audioDeviceReadRenderData
static void audioDeviceReadRenderData(@NonNull AudioDeviceContext audioDeviceContext, @NonNull java.nio.ByteBuffer audioSample)
This method needs to be called byAudioDeviceRenderer
to pull renderable audio data from the media engine.- Parameters:
audioDeviceContext
- The context reference. You should use the same context provided inAudioDeviceRenderer.onStartRendering(AudioDeviceContext)
here.audioSample
- A reference to a buffer where the signed 16-bit LPCM audio data will be copied into.
-
audioDeviceExecuteWorkerBlock
static void audioDeviceExecuteWorkerBlock(@NonNull AudioDeviceContext audioDeviceContext, @NonNull java.lang.Runnable runnable)
A utility method to execute a runnable on the media engine's worker thread asynchronously.AudioDevice invokes the callbacks on the media engine's worker thread. If you wish to initialize, start or stop the audio device from your application code, to avoid the thread-safety problems, you should execute code from the media engine's worker thread.
- Parameters:
audioDeviceContext
- The AudioDevice context. You should use the same context provided inAudioDeviceRenderer.onStartRendering(AudioDeviceContext)
orAudioDeviceCapturer.onStartCapturing(AudioDeviceContext)
here.runnable
- A block which will be executed on the media engine's worker thread.
-
-