Adding a custom audio driver
Use the AudioSettings class, defined in the Vonage Android SDK, to define the audio format used by the custom audio driver. The NoiseAudioDevice constructor instantiates two AudioSettings instances -- one for the custom audio capturer and one for the custom audio renderer. It sets the sample rate and number of channels for each:
class NoiseAudioDevice(Context context) {
init {
captureSettings = AudioSettings(SAMPLING_RATE, NUM_CHANNELS_CAPTURING)
rendererSettings = AudioSettings(SAMPLING_RATE, NUM_CHANNELS_RENDERING)
capturerStarted = false
rendererStarted = false
audioDriverPaused = false
capturerHandler = Handler()
rendererHandler = Handler()
}
}
The constructor also sets up some local properties that report whether the device is capturing or rendering. It also sets a Handler instance to process the capturer Runnable object.
NoiseAudioDevice instance is passed into the AudioDeviceManager.setAudioDevice method:
AudioDeviceManager.setAudioDevice(noiseAudioDevice);
The NoiseAudioDevice.getAudioBus method gets the AudioBus instance that this audio device uses, defined by the NoiseAudioDevice.AudioBus class. Use the AudioBus instance to send and receive audio samples to and from a session. The publisher will access the AudioBus object to obtain the audio samples. Subscribers will send audio samples (from subscribed streams) to the AudioBus object.
Custom audio driver
Learn how to use a custom audio driver to customize publisher and subscriber stream audio. You will use the custom audio driver when you want to start and stop the audio play your own audio file, and do anything outside the default behavior of live video chat provided by the SDK.