Use the audio fallback API to dynamically prioritize audio in response to network quality.
Enabling and disabling audio-only fallback
To enable publisher audio fallback, set the Publisher.Builder.PublisherAudioFallback property when creating a Publisher object.
To enable and disable subscriber audio fallback (for all subscribers to the stream), call the Publisher.Builder.SubscriberAudioFallback property when creating a Publisher object. Subscriber audio fallback is only supported in routed sessions (sessions that use the Media Router). Subscriber audio fallback is enabled by default (in routed sessions) for streams with a camera video source.
// Enable publisher audio fallback
Publisher = new Publisher.Builder(context)
{
PublisherAudioFallback = true
}.Build();
// Enable publisher audio fallback and disable subscriber audio fallback
Publisher = new Publisher.Builder(context)
{
PublisherAudioFallback = true,
SubscriberAudioFallback = false
}.Build();
// Enable subscriber audio fallback and disable publisher audio fallback
Publisher = new Publisher.Builder(context)
{
PublisherAudioFallback = false,
SubscriberAudioFallback = true
}.Build();
Audio fallback events
When publisher audio fallback is enabled, the Publisher object dispatches audio fallback-related events:
Publisher.VideoDisableWarning— Sent when the Publisher determines that the stream quality has degraded and the video will be disabled if the quality degrades more. Publisher.VideoDisableWarningLifted — Sent when the Publisher determines that the stream quality has improved to the point at which the video being disabled is not an immediate risk.Publisher.VideoDisabled— Sent 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.Publisher.VideoEnabled— Sent with reason set to "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):
publisher.VideoDisableWarning += (object sender) =>
{
// Custom action — for example, add custom UI notification
}
publisher.VideoDisableWarningLifted += (object sender) =>
{
// Custom action — for example, remove custom UI notification
}
publisher.VideoDisabled += (object sender, VideoEventArgs e) =>
{
// Custom action — for example, add custom UI notification
}
publisher.VideoEnabled += (object sender, VideoEventArgs e) =>
{
// 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 subscriber audio fallback is enabled, the Subscriber object dispatches audio fallback-related events:
Subscriber.VideoDisableWarning— Sent when it is determined that the stream quality has degraded and the video will be disabled if the quality degrades more. Subscriber.VideoDisableWarningLifted — Sent when it is determined that the stream quality has improved to the point at which the video being disabled is not an immediate risk.Subscriber.VideoDisabled— Sent 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.Subscriber.VideoEnabled— Sent with reason set to "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):
subscriber.VideoDisableWarning += (object sender) =>
{
// Custom action — for example, add custom UI notification
}
subscriber.VideoDisableWarningLifted += (object sender) =>
{
// Custom action — for example, remove custom UI notification
}
subscriber.VideoDisabled += (object sender, VideoEventArgs e) =>
{
// Custom action — for example, add custom UI notification
}
subscriber.VideoEnabled += (object sender, VideoEventArgs e) =>
{
// Custom action — for example, remove custom UI notification
}```