Use the OpenTok audio fallback API to dynamically prioritize audio in response to network quality.
For conceptual information, see the audio fallback overview.
Notes:
OTPublisherKit.audioFallbackEnabled
property will be
deprecated. Please use the OTPublisherKit.subscriberAudioFallbackEnabled
property instead.
This topic includes the following sections:
To enable publisher audio fallback, set the
OTPublisherKitSettings.publisherAudioFallbackEnabled
property when creating the publisher.
// Enable publisher audio fallback
OTPublisherKitSettings *settings = [[OTPublisherKitSettings alloc] init];
settings.publisherAudioFallbackEnabled = YES;
// Enable publisher audio fallback and disable subscriber audio fallback
OTPublisherKitSettings *settings = [[OTPublisherKitSettings alloc] init];
settings.publisherAudioFallbackEnabled = YES;
settings.subscriberAudioFallbackEnabled = NO;
// Enable subscriber audio fallback and disable publisher audio fallback
OTPublisherKitSettings *settings = [[OTPublisherKitSettings alloc] init];
settings.publisherAudioFallbackEnabled = NO;
settings.subscriberAudioFallbackEnabled = YES;
To enable and disable subscriber audio fallback (for all subscribers to the stream), set the
OTPublisherKitSettings.subscriberAudioFallbackEnabled
property when creating the publisher.
Subscriber audio fallback is only supported in
routed sessions (sessions that use the
OpenTok Media Router). Subscriber audio fallback is enabled by default
(in routed sessions) for streams with a camera video source.
When publisher audio fallback is enabled, the
PublisherKitDelegate
object will send the following messages pertaining
to publisher audio fallback-related events:
[OTPublisherKitDelegate publisherVideoDisableWarning:]
— Called when the Publisher determines that the stream quality has degraded and the video will be disabled if the quality degrades more.[OTPublisherKitDelegate publisherVideoDisableWarningLifted:]
— 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.[OTPublisherKitDelegate publisherVideoDisabled:reason:]
— 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.[OTPublisherKitDelegate publisherVideoEnabled:reason:]
— 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):
-(void) publisherVideoDisableWarning:(OTPublisherKit *)publisher videoDisableWarning {
// Custom action — for example, add custom UI notification
}
-(void) publisherVideoDisableWarningLifted:(OTPublisherKit *)publisher videoDisableWarningLifted {
// Custom action — for example, remove custom UI notification
}
-(void) publisherVideoDisabled:(OTPublisherKit *)publisher reason:(OTPublisherVideoEventReason)reason {
// Custom action — for example, add custom UI notification
}
-(void) publisherVideoEnabled:(OTPublisherKit *)publisher reason:(OTPublisherVideoEventReason)reason {
// Custom action — for example, remove custom UI notification
}
When subscriber audio fallback is enabled, the
SubscriberKitDelegate
object will send the following messages pertaining
to subscriber audio fallback-related events:
[OTSubscriberKitDelegate subscriberVideoDisableWarning:]
— Called when the Subscriber determines that the stream quality has degraded and the video will be disabled if the quality degrades more.[OTSubscriberKitDelegate subscriberVideoDisableWarningLifted:]
— Called when the Subscriber determines that the stream quality has improved to the point at which the video being disabled is not an immediate risk.[OTSubscriberKitDelegate subscriberVideoDisabled:reason:]
— Called when the Subscriber determines 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.[OTSubscriberKitDelegate subscriberVideoEnabled:reason:]
— Called with reason "quality" when the Subscriber 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):
-(void) subscriberVideoDisableWarning:(OTSubscriberKit *)subscriber videoDisableWarning {
// Custom action — for example, add custom UI notification
}
-(void) subscriberVideoDisableWarningLifted:(OTSubscriberKit *)subscriber videoDisableWarningLifted {
// Custom action — for example, remove custom UI notification
}
-(void) subscriberVideoDisabled:(OTSubscriberKit *)subscriber reason:(OTSubscriberVideoEventReason)reason {
// Custom action — for example, add custom UI notification
}
-(void) subscriberVideoEnabled:(OTSubscriberKit *)subscriber reason:(OTSubscriberVideoEventReason)reason {
// Custom action — for example, remove custom UI notification
}