Index: webrtc/modules/audio_device/ios/objc/RTCAudioSession.h |
diff --git a/webrtc/modules/audio_device/ios/objc/RTCAudioSession.h b/webrtc/modules/audio_device/ios/objc/RTCAudioSession.h |
index e797a05b4b86410af99585368e0fbafa42e0e06f..4af4423c22a84c7226241ae35e604fc47ae944ca 100644 |
--- a/webrtc/modules/audio_device/ios/objc/RTCAudioSession.h |
+++ b/webrtc/modules/audio_device/ios/objc/RTCAudioSession.h |
@@ -17,6 +17,7 @@ extern NSString * const kRTCAudioSessionErrorDomain; |
extern NSInteger const kRTCAudioSessionErrorLockRequired; |
@class RTCAudioSession; |
+@class RTCAudioSessionConfiguration; |
// Surfaces AVAudioSession events. WebRTC will listen directly for notifications |
// from AVAudioSession and handle them before calling these delegate methods, |
@@ -41,6 +42,18 @@ extern NSInteger const kRTCAudioSessionErrorLockRequired; |
/** Called when AVAudioSession media server restarts. */ |
- (void)audioSessionMediaServicesWereReset:(RTCAudioSession *)session; |
+/** Called when WebRTC needs to take over audio. Applications should call |
+ * -[RTCAudioSession configure] to allow WebRTC to play and record audio. |
+ * TODO(tkchin): Implement this behavior in RTCAudioSession. |
+ */ |
+- (void)audioSessionShouldConfigure:(RTCAudioSession *)session; |
+ |
+/** Called when WebRTC no longer requires audio. Applications should restore |
+ * their audio state at this point. |
+ * TODO(tkchin): Implement this behavior in RTCAudioSession. |
+ */ |
+- (void)audioSessionShouldUnconfigure:(RTCAudioSession *)session; |
+ |
// TODO(tkchin): Maybe handle SilenceSecondaryAudioHintNotification. |
@end |
@@ -68,6 +81,14 @@ extern NSInteger const kRTCAudioSessionErrorLockRequired; |
/** Whether RTCAudioSession is currently locked for configuration. */ |
@property(nonatomic, readonly) BOOL isLocked; |
+/** If YES, WebRTC will not initialize the audio unit automatically when an |
+ * audio track is ready for playout or recording. Instead, applications should |
+ * listen to the delegate method |audioSessionShouldConfigure| and configure |
+ * the session manually. This should be set before making WebRTC media calls. |
+ * TODO(tkchin): Implement behavior. Currently this just stores a BOOL. |
+ */ |
+@property(nonatomic, assign) BOOL shouldDelayAudioConfiguration; |
+ |
// Proxy properties. |
@property(readonly) NSString *category; |
@property(readonly) AVAudioSessionCategoryOptions categoryOptions; |
@@ -150,4 +171,27 @@ extern NSInteger const kRTCAudioSessionErrorLockRequired; |
@end |
+@interface RTCAudioSession (Configuration) |
+ |
+/** Returns YES if the audio session is correctly configured for WebRTC. |
+ * |lockForConfiguration| must be called first. |
+ */ |
+- (BOOL)isConfiguredForWebRTC; |
+ |
+/** Applies the configuration to the current session. Attempts to set all |
+ * properties even if previous ones fail. Only the last error will be |
+ * returned. |
+ * Also calls setActive with |active|. |
+ */ |
+- (BOOL)setConfiguration:(RTCAudioSessionConfiguration *)configuration |
+ active:(BOOL)active |
+ error:(NSError **)outError; |
+ |
+/** Configure the audio session for WebRTC. On failure, we will attempt to |
+ * restore the previously used audio session configuration. |
+ */ |
+- (BOOL)configureWebRTCSession:(NSError **)outError; |
+ |
+@end |
+ |
NS_ASSUME_NONNULL_END |