Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(572)

Side by Side Diff: webrtc/modules/audio_device/ios/objc/RTCAudioSession.h

Issue 1778793005: Refactor AVAudioSession intialization code. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Make isConfigured private Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2016 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2016 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #import <AVFoundation/AVFoundation.h> 11 #import <AVFoundation/AVFoundation.h>
12 #import <Foundation/Foundation.h> 12 #import <Foundation/Foundation.h>
13 13
14 NS_ASSUME_NONNULL_BEGIN 14 NS_ASSUME_NONNULL_BEGIN
15 15
16 extern NSString * const kRTCAudioSessionErrorDomain; 16 extern NSString * const kRTCAudioSessionErrorDomain;
17 /** Method that requires lock was called without lock. */
17 extern NSInteger const kRTCAudioSessionErrorLockRequired; 18 extern NSInteger const kRTCAudioSessionErrorLockRequired;
19 /** Unknown configuration error occurred. */
20 extern NSInteger const kRTCAudioSessionErrorConfiguration;
18 21
19 @class RTCAudioSession; 22 @class RTCAudioSession;
23 @class RTCAudioSessionConfiguration;
20 24
21 // Surfaces AVAudioSession events. WebRTC will listen directly for notifications 25 // Surfaces AVAudioSession events. WebRTC will listen directly for notifications
22 // from AVAudioSession and handle them before calling these delegate methods, 26 // from AVAudioSession and handle them before calling these delegate methods,
23 // at which point applications can perform additional processing if required. 27 // at which point applications can perform additional processing if required.
24 @protocol RTCAudioSessionDelegate <NSObject> 28 @protocol RTCAudioSessionDelegate <NSObject>
25 29
26 /** Called when AVAudioSession starts an interruption event. */ 30 /** Called when AVAudioSession starts an interruption event. */
27 - (void)audioSessionDidBeginInterruption:(RTCAudioSession *)session; 31 - (void)audioSessionDidBeginInterruption:(RTCAudioSession *)session;
28 32
29 /** Called when AVAudioSession ends an interruption event. */ 33 /** Called when AVAudioSession ends an interruption event. */
30 - (void)audioSessionDidEndInterruption:(RTCAudioSession *)session 34 - (void)audioSessionDidEndInterruption:(RTCAudioSession *)session
31 shouldResumeSession:(BOOL)shouldResumeSession; 35 shouldResumeSession:(BOOL)shouldResumeSession;
32 36
33 /** Called when AVAudioSession changes the route. */ 37 /** Called when AVAudioSession changes the route. */
34 - (void)audioSessionDidChangeRoute:(RTCAudioSession *)session 38 - (void)audioSessionDidChangeRoute:(RTCAudioSession *)session
35 reason:(AVAudioSessionRouteChangeReason)reason 39 reason:(AVAudioSessionRouteChangeReason)reason
36 previousRoute:(AVAudioSessionRouteDescription *)previousRoute; 40 previousRoute:(AVAudioSessionRouteDescription *)previousRoute;
37 41
38 /** Called when AVAudioSession media server terminates. */ 42 /** Called when AVAudioSession media server terminates. */
39 - (void)audioSessionMediaServicesWereLost:(RTCAudioSession *)session; 43 - (void)audioSessionMediaServicesWereLost:(RTCAudioSession *)session;
40 44
41 /** Called when AVAudioSession media server restarts. */ 45 /** Called when AVAudioSession media server restarts. */
42 - (void)audioSessionMediaServicesWereReset:(RTCAudioSession *)session; 46 - (void)audioSessionMediaServicesWereReset:(RTCAudioSession *)session;
43 47
48 /** Called when WebRTC needs to take over audio. Applications should call
49 * -[RTCAudioSession configure] to allow WebRTC to play and record audio.
50 * TODO(tkchin): Implement this behavior in RTCAudioSession.
51 */
52 - (void)audioSessionShouldConfigure:(RTCAudioSession *)session;
53
54 /** Called when WebRTC no longer requires audio. Applications should restore
55 * their audio state at this point.
56 * TODO(tkchin): Implement this behavior in RTCAudioSession.
57 */
58 - (void)audioSessionShouldUnconfigure:(RTCAudioSession *)session;
59
44 // TODO(tkchin): Maybe handle SilenceSecondaryAudioHintNotification. 60 // TODO(tkchin): Maybe handle SilenceSecondaryAudioHintNotification.
45 61
46 @end 62 @end
47 63
48 /** Proxy class for AVAudioSession that adds a locking mechanism similar to 64 /** Proxy class for AVAudioSession that adds a locking mechanism similar to
49 * AVCaptureDevice. This is used to that interleaving configurations between 65 * AVCaptureDevice. This is used to that interleaving configurations between
50 * WebRTC and the application layer are avoided. Only setter methods are 66 * WebRTC and the application layer are avoided. Only setter methods are
51 * currently proxied. Getters can be accessed directly off AVAudioSession. 67 * currently proxied. Getters can be accessed directly off AVAudioSession.
52 * 68 *
53 * RTCAudioSession also coordinates activation so that the audio session is 69 * RTCAudioSession also coordinates activation so that the audio session is
54 * activated only once. See |setActive:error:|. 70 * activated only once. See |setActive:error:|.
55 */ 71 */
56 @interface RTCAudioSession : NSObject 72 @interface RTCAudioSession : NSObject
57 73
58 /** Convenience property to access the AVAudioSession singleton. Callers should 74 /** Convenience property to access the AVAudioSession singleton. Callers should
59 * not call setters on AVAudioSession directly, but other method invocations 75 * not call setters on AVAudioSession directly, but other method invocations
60 * are fine. 76 * are fine.
61 */ 77 */
62 @property(nonatomic, readonly) AVAudioSession *session; 78 @property(nonatomic, readonly) AVAudioSession *session;
63 79
64 /** Our best guess at whether the session is active based on results of calls to 80 /** Our best guess at whether the session is active based on results of calls to
65 * AVAudioSession. 81 * AVAudioSession.
66 */ 82 */
67 @property(nonatomic, readonly) BOOL isActive; 83 @property(nonatomic, readonly) BOOL isActive;
68 /** Whether RTCAudioSession is currently locked for configuration. */ 84 /** Whether RTCAudioSession is currently locked for configuration. */
69 @property(nonatomic, readonly) BOOL isLocked; 85 @property(nonatomic, readonly) BOOL isLocked;
70 86
87 /** If YES, WebRTC will not initialize the audio unit automatically when an
88 * audio track is ready for playout or recording. Instead, applications should
89 * listen to the delegate method |audioSessionShouldConfigure| and configure
90 * the session manually. This should be set before making WebRTC media calls.
91 * TODO(tkchin): Implement behavior. Currently this just stores a BOOL.
92 */
93 @property(nonatomic, assign) BOOL shouldDelayAudioConfiguration;
94
71 // Proxy properties. 95 // Proxy properties.
72 @property(readonly) NSString *category; 96 @property(readonly) NSString *category;
73 @property(readonly) AVAudioSessionCategoryOptions categoryOptions; 97 @property(readonly) AVAudioSessionCategoryOptions categoryOptions;
74 @property(readonly) NSString *mode; 98 @property(readonly) NSString *mode;
75 @property(readonly) BOOL secondaryAudioShouldBeSilencedHint; 99 @property(readonly) BOOL secondaryAudioShouldBeSilencedHint;
76 @property(readonly) AVAudioSessionRouteDescription *currentRoute; 100 @property(readonly) AVAudioSessionRouteDescription *currentRoute;
77 @property(readonly) NSInteger maximumInputNumberOfChannels; 101 @property(readonly) NSInteger maximumInputNumberOfChannels;
78 @property(readonly) NSInteger maximumOutputNumberOfChannels; 102 @property(readonly) NSInteger maximumOutputNumberOfChannels;
79 @property(readonly) float inputGain; 103 @property(readonly) float inputGain;
80 @property(readonly) BOOL inputGainSettable; 104 @property(readonly) BOOL inputGainSettable;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 error:(NSError **)outError; 167 error:(NSError **)outError;
144 - (BOOL)setPreferredInput:(AVAudioSessionPortDescription *)inPort 168 - (BOOL)setPreferredInput:(AVAudioSessionPortDescription *)inPort
145 error:(NSError **)outError; 169 error:(NSError **)outError;
146 - (BOOL)setInputDataSource:(AVAudioSessionDataSourceDescription *)dataSource 170 - (BOOL)setInputDataSource:(AVAudioSessionDataSourceDescription *)dataSource
147 error:(NSError **)outError; 171 error:(NSError **)outError;
148 - (BOOL)setOutputDataSource:(AVAudioSessionDataSourceDescription *)dataSource 172 - (BOOL)setOutputDataSource:(AVAudioSessionDataSourceDescription *)dataSource
149 error:(NSError **)outError; 173 error:(NSError **)outError;
150 174
151 @end 175 @end
152 176
177 @interface RTCAudioSession (Configuration)
178
179 /** Applies the configuration to the current session. Attempts to set all
180 * properties even if previous ones fail. Only the last error will be
181 * returned. Also calls setActive with |active|.
182 * |lockForConfiguration| must be called first.
183 */
184 - (BOOL)setConfiguration:(RTCAudioSessionConfiguration *)configuration
185 active:(BOOL)active
186 error:(NSError **)outError;
187
188 /** Configure the audio session for WebRTC. On failure, we will attempt to
189 * restore the previously used audio session configuration.
190 * |lockForConfiguration| must be called first.
191 */
192 - (BOOL)configureWebRTCSession:(NSError **)outError;
193
194 @end
195
153 NS_ASSUME_NONNULL_END 196 NS_ASSUME_NONNULL_END
OLDNEW
« no previous file with comments | « webrtc/modules/audio_device/ios/audio_device_ios.mm ('k') | webrtc/modules/audio_device/ios/objc/RTCAudioSession.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698