Use the audio fallback API to dynamically prioritize audio in response to network quality.
Notes: The PublisherKit.setAudioFallbackEnabled() and PublisherKit.getAudioFallbackEnabled() methods will be deprecated. Please use the PublisherKit.Builder.publisherAudioFallbackEnabled() and PublisherKit.Builder.subscriberAudioFallbackEnabled() methods instead.
Enabling and disabling audio-only fallback
To enable publisher audio fallback, call the PublisherKit.Builder.publisherAudioFallbackEnabled() function when creating the publisher.
// Enable publisher audio fallback
mPublisher = new Publisher.Builder(context)
.publisherAudioFallbackEnabled(true)
.build();
// Enable publisher audio fallback and disable subscriber audio fallback
mPublisher = new Publisher.Builder(context)
.publisherAudioFallbackEnabled(true)
.subscriberAudioFallbackEnabled(false)
.build();
// Enable subscriber audio fallback and disable publisher audio fallback
mPublisher = new Publisher.Builder(context)
.publisherAudioFallbackEnabled(false)
.subscriberAudioFallbackEnabled(true)
.build();
To enable and disable subscriber audio fallback (for all subscribers to the stream), call the PublisherKit.Builder.subscriberAudioFallbackEnabled() function when creating the publisher. Subscriber audio fallback is only supported in routed sessions (sessions that use the Vonage Video Media Router). Subscriber audio fallback is enabled by default (in routed sessions) for streams with a camera video source.
Audio fallback events
When publisher audio fallback is enabled, callback methods of the PublisherKit.VideoListener are invoked for publisher audio fallback-related events:
PublisherKit.VideoListener.onVideoDisableWarning()— Called when the Publisher determines that the stream quality has degraded and the video will be disabled if the quality degrades more.PublisherKit.VideoListener.onVideoDisableWarningLifted()— Called when the Publisher determines that the stream quality has improved to the point at which the video being disabled is not an immediate risk.PublisherKit.VideoListener.onVideoDisabled()— Called when the Publisher determines that the stream quality has degraded and the outgoing video transport has been disabled. Note: while the video is disabled, the Publisher still displays the publisher video (such as the camera image) in the publishing client's UI.PublisherKit.VideoListener.onVideoEnabled()— Called with reason "quality" when the Publisher determines that the stream quality has improved and outgoing video transport has been re-enabled. For example the following code handles the related events (so that you can provide your own user interface notifications):
@Override
public void onVideoDisableWarning(PublisherKit publisher) {
// Custom action — for example, add custom UI notification
}
@Override
public void onVideoDisableWarningLifted(PublisherKit publisher) {
// Custom action — for example, remove custom UI notification
}
@Override
public void onVideoDisabled(PublisherKit publisher, String reason) {
// Custom action — for example, add custom UI notification
}
@Override
public void onVideoEnabled(PublisherKit subscriber, String reason) {
// Custom action — for example, remove custom UI notification
}
From the subscriber’s perspective, the following events indicate that audio fallback has occurred. Although these events are tied to the subscriber, they can occur both due to subscriber audio fallback and as a consequence of publisher audio fallback. In other words, the difference between publisher and subscriber audio fallback is that, in the publisher case, the publishing client may trigger the audio fallback based on its own stream degradation, which is why additional publisher-side events are dispatched. For subscriber audio fallback, the Vonage Video Media Router assesses network degradation affecting the subscriber. In both cases, upon publisher or subscriber audio fallback, subscriber events are always dispatched to indicate that audio fallback has occurred for the receiver.
When audio fallback occurs, callback methods of the SubscriberKit.VideoListener are invoked for subscriber audio fallback-related events:
SubscriberKit.VideoListener.onVideoDisableWarning() — Called when it is determined that the stream quality has degraded and the video will be disabled if the quality degrades more.
SubscriberKit.VideoListener.onVideoDisableWarningLifted() — Called when it is determined that the stream quality has improved to the point at which the video being disabled is not an immediate risk.
SubscriberKit.VideoListener.onVideoDisabled() — Called when it is determined that the stream quality has degraded and the outgoing video transport has been disabled. Note: while the video is disabled, the Subscriber still displays the subscriber video (such as the camera image) in the publishing client's UI.
SubscriberKit.VideoListener.onVideoEnabled() — Called with reason "quality" when it is determined that the stream quality has improved and outgoing video transport has been re-enabled.
For example the following code handles the related events (so that you can provide your own user interface notifications):
@Override
public void onVideoDisableWarning(SubscriberKit subscriber) {
// Custom action — for example, add custom UI notification
}
@Override
public void onVideoDisableWarningLifted(SubscriberKit subscriber) {
// Custom action — for example, remove custom UI notification
}
@Override
public void onVideoDisabled(SubscriberKit subscriber, String reason) {
// Custom action — for example, add custom UI notification
}
@Override
public void onVideoEnabled(SubscriberKit subscriber, String reason) {
// Custom action — for example, remove custom UI notification
}