Java

Using a custom audio driver

By default, the Android SDK uses the device microphone to capture audio to transmit to a published stream. And it uses the and speakers (or headphones) to play back audio from a subscribed stream. Create a class that extends the BaseAudioDevice, defined in the Android SDK:

Then call the AudioDeviceManager.setAudioDevice() method to set the app to use the an instance of the audio device class for capturing and rendering audio samples:

The BaseAudioDevice class has a getAudioBus() method that returns a AudioBus object, defined in the Android SDK. The AudioBus has a readRenderData() method for reading audio samples from subscribed audio streams. And it has a a writeCaputureData() method for supplying audio samples to the publisher's audio stream.

Tuning audio quality

To fine tune audio quality for a publisher stream the following approaches can be used:

You adjust the audio bitrate for a publisher stream by calling the audioBitrate() method of the PublisherKit.Builder object you use to instantiate a Publisher.
The desired bitrate for the published audio, in bits per second. The supported range of values is 6,000 - 510,000. (Invalid values are ignored.) Set this value to enable high-quality audio (or to reduce bandwidth usage with lower-quality audio). If you do not set this option, OpenTok automatically assigns an audio bitrate for the stream.

The following are recommended settings:

  • 8,000 - 12,000 for narrowband (NB) speech
  • 16,000 - 20,000 for wideband (WB) speech
  • 28,000 - 40,000 for full-band (FB) speech
  • 48,000 - 64,000 for full-band (FB) music

Setting the audio output mode for a voice session

By default, the Android SDK uses the device loudspeaker (instead of the headset speaker) for playing audio. This is preferable for apps that include both video and audio. However, in a voice-only session, it is preferable to have the audio played back using the headset speaker. You can have the app do this by making the following call:

Applying audio and video transformations to published streams

You can use pre-built transformers from the Vonage Media Processor library or create your own custom audio or video transformer to apply to published video. See this topic

Reducing audio bandwidth with Opus DTX

Opus DTX (Discontinuous Transmission) is an audio codec that can reduce the bandwidth usage when a participant is not speaking. This can be useful in large sessions with many audio participants.

You enable Opus DTX by calling the enableOpusDtx() method of the PublisherKit.Builder object you use to instantiate a Publisher.

For more information, see this Vonage Video API knowledge base article.

Setting the audio volume for a subscriber

You can individually set the audio volume for each subscriber by calling the Subscriber.setAudioVolume() method.

Adjusting audio and video

Learn more about manipulating audio and video of Vonage Video API streams for your web application. Publish only video or audio, adjust the frame rate, and more.

手順
1
Introduction
2
Prerequisites
3
Adjusting audio and video
4
Adjusting video settings
5
Adjusting audio settings
6
Subscribing to audio or video only
7
Detecting audio or video
8
What's next?