RTCAudioSession Class Reference
Inherits from | NSObject |
---|---|
Conforms to | RTCAudioSessionActivationDelegate |
Declared in | RTCAudioSession.h RTCAudioSession_old.h |
Overview
Proxy class for AVAudioSession that adds a locking mechanism similar to AVCaptureDevice. This is used to that interleaving configurations between WebRTC and the application layer are avoided.
RTCAudioSession also coordinates activation so that the audio session is activated only once. See |setActive:error:|.
Other Methods
session
Convenience property to access the AVAudioSession singleton. Callers should not call setters on AVAudioSession directly, but other method invocations are fine.
@property (nonatomic, readonly) AVAudioSession *session
Discussion
Convenience property to access the AVAudioSession singleton. Callers should not call setters on AVAudioSession directly, but other method invocations are fine.
Declared In
RTCAudioSession.h
isLocked
Whether RTCAudioSession is currently locked for configuration.
@property (nonatomic, readonly) BOOL isLocked
Discussion
Whether RTCAudioSession is currently locked for configuration.
Declared In
RTCAudioSession.h
useManualAudio
If YES, WebRTC will not initialize the audio unit automatically when an audio track is ready for playout or recording. Instead, applications should call setIsAudioEnabled. If NO, WebRTC will initialize the audio unit as soon as an audio track is ready for playout or recording.
@property (nonatomic, assign) BOOL useManualAudio
Discussion
If YES, WebRTC will not initialize the audio unit automatically when an audio track is ready for playout or recording. Instead, applications should call setIsAudioEnabled. If NO, WebRTC will initialize the audio unit as soon as an audio track is ready for playout or recording.
Declared In
RTCAudioSession.h
isAudioEnabled
This property is only effective if useManualAudio is YES. Represents permission for WebRTC to initialize the VoIP audio unit. When set to NO, if the VoIP audio unit used by WebRTC is active, it will be stopped and uninitialized. This will stop incoming and outgoing audio. When set to YES, WebRTC will initialize and start the audio unit when it is needed (e.g. due to establishing an audio connection). This property was introduced to work around an issue where if an AVPlayer is playing audio while the VoIP audio unit is initialized, its audio would be either cut off completely or played at a reduced volume. By preventing the audio unit from being initialized until after the audio has completed, we are able to prevent the abrupt cutoff.
@property (nonatomic, assign) BOOL isAudioEnabled
Discussion
This property is only effective if useManualAudio is YES. Represents permission for WebRTC to initialize the VoIP audio unit. When set to NO, if the VoIP audio unit used by WebRTC is active, it will be stopped and uninitialized. This will stop incoming and outgoing audio. When set to YES, WebRTC will initialize and start the audio unit when it is needed (e.g. due to establishing an audio connection). This property was introduced to work around an issue where if an AVPlayer is playing audio while the VoIP audio unit is initialized, its audio would be either cut off completely or played at a reduced volume. By preventing the audio unit from being initialized until after the audio has completed, we are able to prevent the abrupt cutoff.
Declared In
RTCAudioSession.h
inputDataSource
NSArray<AVAudioSessionDataSourceDescription *> * inputDataSources;
@property (readonly, nullable) AVAudioSessionDataSourceDescription *inputDataSource
Discussion
NSArray<AVAudioSessionDataSourceDescription *> * inputDataSources;
Declared In
RTCAudioSession_old.h
outputDataSource
NSArray<AVAudioSessionDataSourceDescription *> * outputDataSources;
@property (readonly, nullable) AVAudioSessionDataSourceDescription *outputDataSource
Discussion
NSArray<AVAudioSessionDataSourceDescription *> * outputDataSources;
Declared In
RTCAudioSession_old.h
+ sharedInstance
Default constructor.
+ (instancetype)sharedInstance
Discussion
Default constructor.
Declared In
RTCAudioSession.h
– addDelegate:
Adds a delegate, which is held weakly.
- (void)addDelegate:(id<RTCAudioSessionDelegate>)delegate
Discussion
Adds a delegate, which is held weakly.
Declared In
RTCAudioSession.h
– removeDelegate:
Removes an added delegate.
- (void)removeDelegate:(id<RTCAudioSessionDelegate>)delegate
Discussion
Removes an added delegate.
Declared In
RTCAudioSession.h
– lockForConfiguration
Request exclusive access to the audio session for configuration. This call will block if the lock is held by another object.
- (void)lockForConfiguration
Discussion
Request exclusive access to the audio session for configuration. This call will block if the lock is held by another object.
Declared In
RTCAudioSession.h
– setActive:error:
If |active|, activates the audio session if it isn’t already active. Successful calls must be balanced with a setActive:NO when activation is no longer required. If not |active|, deactivates the audio session if one is active and this is the last balanced call. When deactivating, the AVAudioSessionSetActiveOptionNotifyOthersOnDeactivation option is passed to AVAudioSession.
- (BOOL)setActive:(BOOL)active error:(NSError **)outError
Discussion
If |active|, activates the audio session if it isn’t already active. Successful calls must be balanced with a setActive:NO when activation is no longer required. If not |active|, deactivates the audio session if one is active and this is the last balanced call. When deactivating, the AVAudioSessionSetActiveOptionNotifyOthersOnDeactivation option is passed to AVAudioSession.
Declared In
RTCAudioSession.h
Configuration Methods
– setConfiguration:error:
Applies the configuration to the current session. Attempts to set all properties even if previous ones fail. Only the last error will be returned. |lockForConfiguration| must be called first.
- (BOOL)setConfiguration:(RTCAudioSessionConfiguration *)configuration error:(NSError **)outError
Discussion
Applies the configuration to the current session. Attempts to set all properties even if previous ones fail. Only the last error will be returned. |lockForConfiguration| must be called first.
Declared In
RTCAudioSession.h
– setConfiguration:active:error:
Convenience method that calls both setConfiguration and setActive. |lockForConfiguration| must be called first.
- (BOOL)setConfiguration:(RTCAudioSessionConfiguration *)configuration active:(BOOL)active error:(NSError **)outError
Discussion
Convenience method that calls both setConfiguration and setActive. |lockForConfiguration| must be called first.
Declared In
RTCAudioSession.h