webkit  2cdf99a9e3038c7e01b3c37e8ad903ecbe5eecf1
https://github.com/WebKit/webkit
Instance Methods | Class Methods | Properties | List of all members
RTCAudioSession Class Reference

#import <RTCAudioSession.h>

Inheritance diagram for RTCAudioSession:
NSObject NSObject

Instance Methods

(instancetype) - NS_UNAVAILABLE
 
(void- addDelegate:
 
(void- removeDelegate:
 
(void- lockForConfiguration
 
(void- unlockForConfiguration
 
(BOOL- setActive:error:
 
(BOOL- setCategory:withOptions:error:
 
(BOOL- setMode:error:
 
(BOOL- setInputGain:error:
 
(BOOL- setPreferredSampleRate:error:
 
(BOOL- setPreferredIOBufferDuration:error:
 
(BOOL- setPreferredInputNumberOfChannels:error:
 
(BOOL- setPreferredOutputNumberOfChannels:error:
 
(BOOL- overrideOutputAudioPort:error:
 
(BOOL- setPreferredInput:error:
 
(BOOL- setInputDataSource:error:
 
(BOOL- setOutputDataSource:error:
 
(instancetype) - NS_UNAVAILABLE
 
(void- addDelegate:
 
(void- removeDelegate:
 
(void- lockForConfiguration
 
(void- unlockForConfiguration
 
(BOOL- setActive:error:
 
(BOOL- setCategory:withOptions:error:
 
(BOOL- setMode:error:
 
(BOOL- setInputGain:error:
 
(BOOL- setPreferredSampleRate:error:
 
(BOOL- setPreferredIOBufferDuration:error:
 
(BOOL- setPreferredInputNumberOfChannels:error:
 
(BOOL- setPreferredOutputNumberOfChannels:error:
 
(BOOL- overrideOutputAudioPort:error:
 
(BOOL- setPreferredInput:error:
 
(BOOL- setInputDataSource:error:
 
(BOOL- setOutputDataSource:error:
 
(BOOL- checkLock: [implementation]
 
(BOOL- checkLock: [implementation]
 
(void- pushDelegate: [implementation]
 
(void- pushDelegate: [implementation]
 
(BOOL- beginWebRTCSession: [implementation]
 
(BOOL- beginWebRTCSession: [implementation]
 
(BOOL- endWebRTCSession: [implementation]
 
(BOOL- endWebRTCSession: [implementation]
 
(BOOL- configureWebRTCSession: [implementation]
 
(BOOL- configureWebRTCSession: [implementation]
 
(BOOL- unconfigureWebRTCSession: [implementation]
 
(BOOL- unconfigureWebRTCSession: [implementation]
 
(NSError *) - configurationErrorWithDescription: [implementation]
 
(NSError *) - configurationErrorWithDescription: [implementation]
 
(void- notifyDidBeginInterruption [implementation]
 
(void- notifyDidBeginInterruption [implementation]
 
(void- notifyDidEndInterruptionWithShouldResumeSession: [implementation]
 
(void- notifyDidEndInterruptionWithShouldResumeSession: [implementation]
 
(void- notifyDidChangeRouteWithReason:previousRoute: [implementation]
 
(void- notifyDidChangeRouteWithReason:previousRoute: [implementation]
 
(void- notifyMediaServicesWereLost [implementation]
 
(void- notifyMediaServicesWereLost [implementation]
 
(void- notifyMediaServicesWereReset [implementation]
 
(void- notifyMediaServicesWereReset [implementation]
 
(void- notifyDidChangeCanPlayOrRecord: [implementation]
 
(void- notifyDidChangeCanPlayOrRecord: [implementation]
 
(void- notifyDidStartPlayOrRecord [implementation]
 
(void- notifyDidStartPlayOrRecord [implementation]
 
(void- notifyDidStopPlayOrRecord [implementation]
 
(void- notifyDidStopPlayOrRecord [implementation]
 
(BOOL- setConfiguration:error:
 
(BOOL- setConfiguration:error:
 
(BOOL- setConfiguration:active:error:
 
(BOOL- setConfiguration:active:error:
 

Class Methods

(instancetype) + sharedInstance
 
(instancetype) + sharedInstance
 

Properties

AVAudioSession * session
 
BOOL isActive
 
BOOL isLocked
 
BOOL useManualAudio
 
BOOL isAudioEnabled
 
NSStringcategory
 
AVAudioSessionCategoryOptions categoryOptions
 
NSStringmode
 
BOOL secondaryAudioShouldBeSilencedHint
 
AVAudioSessionRouteDescription * currentRoute
 
NSInteger maximumInputNumberOfChannels
 
NSInteger maximumOutputNumberOfChannels
 
float inputGain
 
BOOL inputGainSettable
 
BOOL inputAvailable
 
NSArray< AVAudioSessionDataSourceDescription * > * inputDataSources
 
AVAudioSessionDataSourceDescription * inputDataSource
 
NSArray< AVAudioSessionDataSourceDescription * > * outputDataSources
 
AVAudioSessionDataSourceDescription * outputDataSource
 
double sampleRate
 
double preferredSampleRate
 
NSInteger inputNumberOfChannels
 
NSInteger outputNumberOfChannels
 
float outputVolume
 
NSTimeInterval inputLatency
 
NSTimeInterval outputLatency
 
NSTimeInterval IOBufferDuration
 
NSTimeInterval preferredIOBufferDuration
 
int activationCount [implementation]
 
int webRTCSessionCount [implementation]
 
BOOL canPlayOrRecord [implementation]
 
BOOL isInterrupted [implementation]
 
std::vector< __weak id< RTCAudioSessionDelegate > > delegates [implementation]
 

Detailed Description

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:|.

Method Documentation

◆ addDelegate:() [1/2]

- (void) addDelegate: (id<RTCAudioSessionDelegate>)  delegate

Adds a delegate, which is held weakly.

◆ addDelegate:() [2/2]

- (void) addDelegate: (id< RTCAudioSessionDelegate >)  delegate

Adds a delegate, which is held weakly.

◆ beginWebRTCSession:() [1/2]

- (BOOL) beginWebRTCSession: (NSError **)  outError
implementation

Signals RTCAudioSession that a WebRTC session is about to begin and audio configuration is needed. Will configure the audio session for WebRTC if not already configured and if configuration is not delayed. Successful calls must be balanced by a call to endWebRTCSession.

◆ beginWebRTCSession:() [2/2]

- (BOOL) beginWebRTCSession: (NSError **)  outError
implementation

Signals RTCAudioSession that a WebRTC session is about to begin and audio configuration is needed. Will configure the audio session for WebRTC if not already configured and if configuration is not delayed. Successful calls must be balanced by a call to endWebRTCSession.

◆ checkLock:() [1/2]

- (BOOL) checkLock: (NSError **)  outError
implementation

◆ checkLock:() [2/2]

- (BOOL) checkLock: (NSError **)  outError
implementation

◆ configurationErrorWithDescription:() [1/2]

- (NSError *) configurationErrorWithDescription: (NSString *)  description
implementation

Returns a configuration error with the given description.

◆ configurationErrorWithDescription:() [2/2]

- (NSError *) configurationErrorWithDescription: (NSString *)  description
implementation

Returns a configuration error with the given description.

◆ configureWebRTCSession:() [1/2]

- (BOOL) configureWebRTCSession: (NSError **)  outError
implementation

Configure the audio session for WebRTC. This call will fail if the session is already configured. On other failures, we will attempt to restore the previously used audio session configuration. |lockForConfiguration| must be called first. Successful calls to configureWebRTCSession must be matched by calls to |unconfigureWebRTCSession|.

◆ configureWebRTCSession:() [2/2]

- (BOOL) configureWebRTCSession: (NSError **)  outError
implementation

Configure the audio session for WebRTC. This call will fail if the session is already configured. On other failures, we will attempt to restore the previously used audio session configuration. |lockForConfiguration| must be called first. Successful calls to configureWebRTCSession must be matched by calls to |unconfigureWebRTCSession|.

◆ endWebRTCSession:() [1/2]

- (BOOL) endWebRTCSession: (NSError **)  outError
implementation

Signals RTCAudioSession that a WebRTC session is about to end and audio unconfiguration is needed. Will unconfigure the audio session for WebRTC if this is the last unmatched call and if configuration is not delayed.

◆ endWebRTCSession:() [2/2]

- (BOOL) endWebRTCSession: (NSError **)  outError
implementation

Signals RTCAudioSession that a WebRTC session is about to end and audio unconfiguration is needed. Will unconfigure the audio session for WebRTC if this is the last unmatched call and if configuration is not delayed.

◆ lockForConfiguration() [1/2]

- (void) lockForConfiguration

Request exclusive access to the audio session for configuration. This call will block if the lock is held by another object.

◆ lockForConfiguration() [2/2]

- (void) lockForConfiguration

Request exclusive access to the audio session for configuration. This call will block if the lock is held by another object.

◆ notifyDidBeginInterruption() [1/2]

- (void) notifyDidBeginInterruption
implementation

◆ notifyDidBeginInterruption() [2/2]

- (void) notifyDidBeginInterruption
implementation

◆ notifyDidChangeCanPlayOrRecord:() [1/2]

- (void) notifyDidChangeCanPlayOrRecord: (BOOL canPlayOrRecord
implementation

◆ notifyDidChangeCanPlayOrRecord:() [2/2]

- (void) notifyDidChangeCanPlayOrRecord: (BOOL canPlayOrRecord
implementation

◆ notifyDidChangeRouteWithReason:previousRoute:() [1/2]

- (void) notifyDidChangeRouteWithReason: (AVAudioSessionRouteChangeReason)  reason
previousRoute: (AVAudioSessionRouteDescription *)  previousRoute 
implementation

◆ notifyDidChangeRouteWithReason:previousRoute:() [2/2]

- (void) notifyDidChangeRouteWithReason: (AVAudioSessionRouteChangeReason)  reason
previousRoute: (AVAudioSessionRouteDescription *)  previousRoute 
implementation

◆ notifyDidEndInterruptionWithShouldResumeSession:() [1/2]

- (void) notifyDidEndInterruptionWithShouldResumeSession: (BOOL shouldResumeSession
implementation

◆ notifyDidEndInterruptionWithShouldResumeSession:() [2/2]

- (void) notifyDidEndInterruptionWithShouldResumeSession: (BOOL shouldResumeSession
implementation

◆ notifyDidStartPlayOrRecord() [1/2]

- (void) notifyDidStartPlayOrRecord
implementation

◆ notifyDidStartPlayOrRecord() [2/2]

- (void) notifyDidStartPlayOrRecord
implementation

◆ notifyDidStopPlayOrRecord() [1/2]

- (void) notifyDidStopPlayOrRecord
implementation

◆ notifyDidStopPlayOrRecord() [2/2]

- (void) notifyDidStopPlayOrRecord
implementation

◆ notifyMediaServicesWereLost() [1/2]

- (void) notifyMediaServicesWereLost
implementation

◆ notifyMediaServicesWereLost() [2/2]

- (void) notifyMediaServicesWereLost
implementation

◆ notifyMediaServicesWereReset() [1/2]

- (void) notifyMediaServicesWereReset
implementation

◆ notifyMediaServicesWereReset() [2/2]

- (void) notifyMediaServicesWereReset
implementation

◆ NS_UNAVAILABLE() [1/2]

- (instancetype) NS_UNAVAILABLE

◆ NS_UNAVAILABLE() [2/2]

- (instancetype) NS_UNAVAILABLE

◆ overrideOutputAudioPort:error:() [1/2]

- (BOOL) overrideOutputAudioPort: (AVAudioSessionPortOverride)  portOverride
error: (NSError **)  outError 

◆ overrideOutputAudioPort:error:() [2/2]

- (BOOL) overrideOutputAudioPort: (AVAudioSessionPortOverride)  portOverride
error: (NSError **)  outError 

◆ pushDelegate:() [1/2]

- (void) pushDelegate: (id< RTCAudioSessionDelegate >)  delegate
implementation

Adds the delegate to the list of delegates, and places it at the front of the list. This delegate will be notified before other delegates of audio events.

◆ pushDelegate:() [2/2]

- (void) pushDelegate: (id< RTCAudioSessionDelegate >)  delegate
implementation

Adds the delegate to the list of delegates, and places it at the front of the list. This delegate will be notified before other delegates of audio events.

◆ removeDelegate:() [1/2]

- (void) removeDelegate: (id<RTCAudioSessionDelegate>)  delegate

Removes an added delegate.

◆ removeDelegate:() [2/2]

- (void) removeDelegate: (id< RTCAudioSessionDelegate >)  delegate

Removes an added delegate.

◆ setActive:error:() [1/2]

- (BOOL) setActive: (BOOL active
error: (NSError **)  outError 

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.

◆ setActive:error:() [2/2]

- (BOOL) setActive: (BOOL active
error: (NSError **)  outError 

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.

◆ setCategory:withOptions:error:() [1/2]

- (BOOL) setCategory: (NSString *)  category
withOptions: (AVAudioSessionCategoryOptions)  options
error: (NSError **)  outError 

◆ setCategory:withOptions:error:() [2/2]

- (BOOL) setCategory: (NSString *)  category
withOptions: (AVAudioSessionCategoryOptions)  options
error: (NSError **)  outError 

◆ setConfiguration:active:error:() [1/2]

- (BOOL) setConfiguration: (RTCAudioSessionConfiguration *)  configuration
active: (BOOL active
error: (NSError **)  outError 

Convenience method that calls both setConfiguration and setActive. |lockForConfiguration| must be called first.

Provided by category RTCAudioSession(Configuration).

◆ setConfiguration:active:error:() [2/2]

- (BOOL) setConfiguration: (RTCAudioSessionConfiguration *)  configuration
active: (BOOL active
error: (NSError **)  outError 

Convenience method that calls both setConfiguration and setActive. |lockForConfiguration| must be called first.

Provided by category RTCAudioSession(Configuration).

◆ setConfiguration:error:() [1/2]

- (BOOL) setConfiguration: (RTCAudioSessionConfiguration *)  configuration
error: (NSError **)  outError 

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.

Provided by category RTCAudioSession(Configuration).

◆ setConfiguration:error:() [2/2]

- (BOOL) setConfiguration: (RTCAudioSessionConfiguration *)  configuration
error: (NSError **)  outError 

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.

Provided by category RTCAudioSession(Configuration).

◆ setInputDataSource:error:() [1/2]

- (BOOL) setInputDataSource: (AVAudioSessionDataSourceDescription *)  dataSource
error: (NSError **)  outError 

◆ setInputDataSource:error:() [2/2]

- (BOOL) setInputDataSource: (AVAudioSessionDataSourceDescription *)  dataSource
error: (NSError **)  outError 

◆ setInputGain:error:() [1/2]

- (BOOL) setInputGain: (float)  gain
error: (NSError **)  outError 

◆ setInputGain:error:() [2/2]

- (BOOL) setInputGain: (float)  gain
error: (NSError **)  outError 

◆ setMode:error:() [1/2]

- (BOOL) setMode: (NSString *)  mode
error: (NSError **)  outError 

◆ setMode:error:() [2/2]

- (BOOL) setMode: (NSString *)  mode
error: (NSError **)  outError 

◆ setOutputDataSource:error:() [1/2]

- (BOOL) setOutputDataSource: (AVAudioSessionDataSourceDescription *)  dataSource
error: (NSError **)  outError 

◆ setOutputDataSource:error:() [2/2]

- (BOOL) setOutputDataSource: (AVAudioSessionDataSourceDescription *)  dataSource
error: (NSError **)  outError 

◆ setPreferredInput:error:() [1/2]

- (BOOL) setPreferredInput: (AVAudioSessionPortDescription *)  inPort
error: (NSError **)  outError 

◆ setPreferredInput:error:() [2/2]

- (BOOL) setPreferredInput: (AVAudioSessionPortDescription *)  inPort
error: (NSError **)  outError 

◆ setPreferredInputNumberOfChannels:error:() [1/2]

- (BOOL) setPreferredInputNumberOfChannels: (NSInteger)  count
error: (NSError **)  outError 

◆ setPreferredInputNumberOfChannels:error:() [2/2]

- (BOOL) setPreferredInputNumberOfChannels: (NSInteger)  count
error: (NSError **)  outError 

◆ setPreferredIOBufferDuration:error:() [1/2]

- (BOOL) setPreferredIOBufferDuration: (NSTimeInterval duration
error: (NSError **)  outError 

◆ setPreferredIOBufferDuration:error:() [2/2]

- (BOOL) setPreferredIOBufferDuration: (NSTimeInterval duration
error: (NSError **)  outError 

◆ setPreferredOutputNumberOfChannels:error:() [1/2]

- (BOOL) setPreferredOutputNumberOfChannels: (NSInteger)  count
error: (NSError **)  outError 

◆ setPreferredOutputNumberOfChannels:error:() [2/2]

- (BOOL) setPreferredOutputNumberOfChannels: (NSInteger)  count
error: (NSError **)  outError 

◆ setPreferredSampleRate:error:() [1/2]

- (BOOL) setPreferredSampleRate: (double)  sampleRate
error: (NSError **)  outError 

◆ setPreferredSampleRate:error:() [2/2]

- (BOOL) setPreferredSampleRate: (double)  sampleRate
error: (NSError **)  outError 

◆ sharedInstance() [1/2]

+ (instancetype) sharedInstance

Default constructor.

◆ sharedInstance() [2/2]

+ (instancetype) sharedInstance

Default constructor.

◆ unconfigureWebRTCSession:() [1/2]

- (BOOL) unconfigureWebRTCSession: (NSError **)  outError
implementation

Unconfigures the session for WebRTC. This will attempt to restore the audio session to the settings used before |configureWebRTCSession| was called. |lockForConfiguration| must be called first.

◆ unconfigureWebRTCSession:() [2/2]

- (BOOL) unconfigureWebRTCSession: (NSError **)  outError
implementation

Unconfigures the session for WebRTC. This will attempt to restore the audio session to the settings used before |configureWebRTCSession| was called. |lockForConfiguration| must be called first.

◆ unlockForConfiguration() [1/2]

- (void) unlockForConfiguration

Relinquishes exclusive access to the audio session.

◆ unlockForConfiguration() [2/2]

- (void) unlockForConfiguration

Relinquishes exclusive access to the audio session.

Property Documentation

◆ activationCount

- (int) activationCount
readnonatomicassignimplementation

Number of times setActive:YES has succeeded without a balanced call to setActive:NO.

◆ canPlayOrRecord

- (BOOL) canPlayOrRecord
readatomicassignimplementation

Convenience BOOL that checks useManualAudio and isAudioEnebled.

◆ category

- (NSString *) category
readatomicassign

◆ categoryOptions

- (AVAudioSessionCategoryOptions) categoryOptions
readatomicassign

◆ currentRoute

- (AVAudioSessionRouteDescription *) currentRoute
readatomicassign

◆ delegates

- (vector< __weak id< RTCAudioSessionDelegate > > RTCAudioSession()):
readnonatomicassignimplementation

◆ inputAvailable

- (BOOL) inputAvailable
readatomicassign

◆ inputDataSource

- (AVAudioSessionDataSourceDescription *) inputDataSource
readatomicassign

◆ inputDataSources

- (NSArray< AVAudioSessionDataSourceDescription * > *) inputDataSources
readatomicassign

◆ inputGain

- (float) inputGain
readatomicassign

◆ inputGainSettable

- (BOOL) inputGainSettable
readatomicassign

◆ inputLatency

- (NSTimeInterval) inputLatency
readatomicassign

◆ inputNumberOfChannels

- (NSInteger) inputNumberOfChannels
readatomicassign

◆ IOBufferDuration

- (NSTimeInterval) IOBufferDuration
readatomicassign

◆ isActive

- (BOOL) isActive
readnonatomicassign

Our best guess at whether the session is active based on results of calls to AVAudioSession.

◆ isAudioEnabled

- (BOOL) isAudioEnabled
readwritenonatomicassign

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.

◆ isInterrupted

- (BOOL) isInterrupted
readwritenonatomicassignimplementation

Tracks whether we have been sent an interruption event that hasn't been matched by either an interrupted end event or a foreground event.

◆ isLocked

- (BOOL) isLocked
readnonatomicassign

Whether RTCAudioSession is currently locked for configuration.

◆ maximumInputNumberOfChannels

- (NSInteger) maximumInputNumberOfChannels
readatomicassign

◆ maximumOutputNumberOfChannels

- (NSInteger) maximumOutputNumberOfChannels
readatomicassign

◆ mode

- (NSString *) mode
readatomicassign

◆ outputDataSource

- (AVAudioSessionDataSourceDescription *) outputDataSource
readatomicassign

◆ outputDataSources

- (NSArray< AVAudioSessionDataSourceDescription * > *) outputDataSources
readatomicassign

◆ outputLatency

- (NSTimeInterval) outputLatency
readatomicassign

◆ outputNumberOfChannels

- (NSInteger) outputNumberOfChannels
readatomicassign

◆ outputVolume

- (float) outputVolume
readatomicassign

◆ preferredIOBufferDuration

- (NSTimeInterval) preferredIOBufferDuration
readatomicassign

◆ preferredSampleRate

- (double) preferredSampleRate
readatomicassign

◆ sampleRate

- (double) sampleRate
readatomicassign

◆ secondaryAudioShouldBeSilencedHint

- (BOOL) secondaryAudioShouldBeSilencedHint
readatomicassign

◆ session

- (AVAudioSession *) session
readnonatomicassign

Convenience property to access the AVAudioSession singleton. Callers should not call setters on AVAudioSession directly, but other method invocations are fine.

◆ useManualAudio

- (BOOL) useManualAudio
readwritenonatomicassign

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.

◆ webRTCSessionCount

- (int) webRTCSessionCount
readnonatomicassignimplementation

The number of times |beginWebRTCSession| was called without a balanced call to |endWebRTCSession|.


The documentation for this class was generated from the following files: