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

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

Issue 1945563003: Provide isAudioEnabled flag to control audio unit. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fix some bluetooth issue. Created 4 years, 7 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
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 */ 51 */
52 - (void)audioSessionMediaServicesWereLost:(RTCAudioSession *)session; 52 - (void)audioSessionMediaServicesWereLost:(RTCAudioSession *)session;
53 53
54 /** Called on a system notification thread when AVAudioSession media server 54 /** Called on a system notification thread when AVAudioSession media server
55 * restarts. 55 * restarts.
56 */ 56 */
57 - (void)audioSessionMediaServicesWereReset:(RTCAudioSession *)session; 57 - (void)audioSessionMediaServicesWereReset:(RTCAudioSession *)session;
58 58
59 // TODO(tkchin): Maybe handle SilenceSecondaryAudioHintNotification. 59 // TODO(tkchin): Maybe handle SilenceSecondaryAudioHintNotification.
60 60
61 /** Called on a WebRTC thread when WebRTC needs to take over audio. Applications 61 - (void)audioSession:(RTCAudioSession *)session
62 * should call -[RTCAudioSession configureWebRTCSession] to allow WebRTC to 62 didChangeCanPlayOrRecord:(BOOL)canPlayOrRecord;
63 * play and record audio. Will only occur if shouldDelayAudioConfiguration is 63
64 * set to YES. 64 /** Called on a WebRTC thread when the audio device is notified to begin
65 * playback or recording.
65 */ 66 */
66 - (void)audioSessionShouldConfigure:(RTCAudioSession *)session; 67 - (void)audioSessionDidStartPlayOrRecord:(RTCAudioSession *)session;
67 68
68 /** Called on a WebRTC thread when WebRTC no longer requires audio. Applications 69 /** Called on a WebRTC thread when the audio device is notified to stop
69 * should call -[RTCAudioSession unconfigureWebRTCSession] to restore their 70 * playback or recording.
70 * audio session settings. Will only occur if shouldDelayAudioConfiguration is
71 * set to YES.
72 */ 71 */
73 - (void)audioSessionShouldUnconfigure:(RTCAudioSession *)session; 72 - (void)audioSessionDidStopPlayOrRecord:(RTCAudioSession *)session;
74
75 /** Called on a WebRTC thread when WebRTC has configured the audio session for
76 * WebRTC audio.
77 */
78 - (void)audioSessionDidConfigure:(RTCAudioSession *)session;
79
80 /** Called on a WebRTC thread when WebRTC has unconfigured the audio session for
81 * WebRTC audio.
82 */
83 - (void)audioSessionDidUnconfigure:(RTCAudioSession *)session;
84 73
85 @end 74 @end
86 75
87 /** Proxy class for AVAudioSession that adds a locking mechanism similar to 76 /** Proxy class for AVAudioSession that adds a locking mechanism similar to
88 * AVCaptureDevice. This is used to that interleaving configurations between 77 * AVCaptureDevice. This is used to that interleaving configurations between
89 * WebRTC and the application layer are avoided. 78 * WebRTC and the application layer are avoided.
90 * 79 *
91 * RTCAudioSession also coordinates activation so that the audio session is 80 * RTCAudioSession also coordinates activation so that the audio session is
92 * activated only once. See |setActive:error:|. 81 * activated only once. See |setActive:error:|.
93 */ 82 */
94 @interface RTCAudioSession : NSObject 83 @interface RTCAudioSession : NSObject
95 84
96 /** Convenience property to access the AVAudioSession singleton. Callers should 85 /** Convenience property to access the AVAudioSession singleton. Callers should
97 * not call setters on AVAudioSession directly, but other method invocations 86 * not call setters on AVAudioSession directly, but other method invocations
98 * are fine. 87 * are fine.
99 */ 88 */
100 @property(nonatomic, readonly) AVAudioSession *session; 89 @property(nonatomic, readonly) AVAudioSession *session;
101 90
102 /** Our best guess at whether the session is active based on results of calls to 91 /** Our best guess at whether the session is active based on results of calls to
103 * AVAudioSession. 92 * AVAudioSession.
104 */ 93 */
105 @property(nonatomic, readonly) BOOL isActive; 94 @property(nonatomic, readonly) BOOL isActive;
106 /** Whether RTCAudioSession is currently locked for configuration. */ 95 /** Whether RTCAudioSession is currently locked for configuration. */
107 @property(nonatomic, readonly) BOOL isLocked; 96 @property(nonatomic, readonly) BOOL isLocked;
108 97
109 /** If YES, WebRTC will not initialize the audio unit automatically when an 98 /** If YES, WebRTC will not initialize the audio unit automatically when an
110 * audio track is ready for playout or recording. Instead, applications should 99 * audio track is ready for playout or recording. Instead, applications should
111 * listen to the delegate method |audioSessionShouldConfigure| and configure 100 * call setIsWebRTCAudioEnabled. If NO, WebRTC will initialize the audio unit
112 * the session manually. This should be set before making WebRTC media calls 101 * as soon as an audio track is ready for playout or recording.
113 * and should not be changed while a call is active.
114 */ 102 */
115 @property(nonatomic, assign) BOOL shouldDelayAudioConfiguration; 103 @property(nonatomic, assign) BOOL useManualAudio;
104 /** Setting this to YES will cause the audio session to be configured for WebRTC
henrika_webrtc 2016/05/04 12:33:07 Rather tricky to read IMHO. Can you add an example
tkchin_webrtc 2016/05/05 23:23:28 Better?
henrika_webrtc 2016/05/06 11:22:16 Perfect ;-)
105 * and activated, and the audio unit to be initialized and started, provided
106 * an audio track is active. Likewise, setting this to NO will terminate any
107 * current audio. This property is ignored if useManualAudio is NO.
108 */
109 @property(nonatomic, assign) BOOL isAudioEnabled;
116 110
117 // Proxy properties. 111 // Proxy properties.
118 @property(readonly) NSString *category; 112 @property(readonly) NSString *category;
119 @property(readonly) AVAudioSessionCategoryOptions categoryOptions; 113 @property(readonly) AVAudioSessionCategoryOptions categoryOptions;
120 @property(readonly) NSString *mode; 114 @property(readonly) NSString *mode;
121 @property(readonly) BOOL secondaryAudioShouldBeSilencedHint; 115 @property(readonly) BOOL secondaryAudioShouldBeSilencedHint;
122 @property(readonly) AVAudioSessionRouteDescription *currentRoute; 116 @property(readonly) AVAudioSessionRouteDescription *currentRoute;
123 @property(readonly) NSInteger maximumInputNumberOfChannels; 117 @property(readonly) NSInteger maximumInputNumberOfChannels;
124 @property(readonly) NSInteger maximumOutputNumberOfChannels; 118 @property(readonly) NSInteger maximumOutputNumberOfChannels;
125 @property(readonly) float inputGain; 119 @property(readonly) float inputGain;
126 @property(readonly) BOOL inputGainSettable; 120 @property(readonly) BOOL inputGainSettable;
127 @property(readonly) BOOL inputAvailable; 121 @property(readonly) BOOL inputAvailable;
128 @property(readonly, nullable) 122 @property(readonly, nullable)
129 NSArray<AVAudioSessionDataSourceDescription *> * inputDataSources; 123 NSArray<AVAudioSessionDataSourceDescription *> * inputDataSources;
130 @property(readonly, nullable) 124 @property(readonly, nullable)
131 AVAudioSessionDataSourceDescription *inputDataSource; 125 AVAudioSessionDataSourceDescription *inputDataSource;
132 @property(readonly, nullable) 126 @property(readonly, nullable)
133 NSArray<AVAudioSessionDataSourceDescription *> * outputDataSources; 127 NSArray<AVAudioSessionDataSourceDescription *> * outputDataSources;
134 @property(readonly, nullable) 128 @property(readonly, nullable)
135 AVAudioSessionDataSourceDescription *outputDataSource; 129 AVAudioSessionDataSourceDescription *outputDataSource;
136 @property(readonly) double sampleRate; 130 @property(readonly) double sampleRate;
131 @property(readonly) double preferredSampleRate;
137 @property(readonly) NSInteger inputNumberOfChannels; 132 @property(readonly) NSInteger inputNumberOfChannels;
138 @property(readonly) NSInteger outputNumberOfChannels; 133 @property(readonly) NSInteger outputNumberOfChannels;
139 @property(readonly) float outputVolume; 134 @property(readonly) float outputVolume;
140 @property(readonly) NSTimeInterval inputLatency; 135 @property(readonly) NSTimeInterval inputLatency;
141 @property(readonly) NSTimeInterval outputLatency; 136 @property(readonly) NSTimeInterval outputLatency;
142 @property(readonly) NSTimeInterval IOBufferDuration; 137 @property(readonly) NSTimeInterval IOBufferDuration;
138 @property(readonly) NSTimeInterval preferredIOBufferDuration;
143 139
144 /** Default constructor. */ 140 /** Default constructor. */
145 + (instancetype)sharedInstance; 141 + (instancetype)sharedInstance;
146 - (instancetype)init NS_UNAVAILABLE; 142 - (instancetype)init NS_UNAVAILABLE;
147 143
148 /** Adds a delegate, which is held weakly. */ 144 /** Adds a delegate, which is held weakly. */
149 - (void)addDelegate:(id<RTCAudioSessionDelegate>)delegate; 145 - (void)addDelegate:(id<RTCAudioSessionDelegate>)delegate;
150 /** Removes an added delegate. */ 146 /** Removes an added delegate. */
151 - (void)removeDelegate:(id<RTCAudioSessionDelegate>)delegate; 147 - (void)removeDelegate:(id<RTCAudioSessionDelegate>)delegate;
152 148
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 error:(NSError **)outError; 185 error:(NSError **)outError;
190 - (BOOL)setInputDataSource:(AVAudioSessionDataSourceDescription *)dataSource 186 - (BOOL)setInputDataSource:(AVAudioSessionDataSourceDescription *)dataSource
191 error:(NSError **)outError; 187 error:(NSError **)outError;
192 - (BOOL)setOutputDataSource:(AVAudioSessionDataSourceDescription *)dataSource 188 - (BOOL)setOutputDataSource:(AVAudioSessionDataSourceDescription *)dataSource
193 error:(NSError **)outError; 189 error:(NSError **)outError;
194 190
195 @end 191 @end
196 192
197 @interface RTCAudioSession (Configuration) 193 @interface RTCAudioSession (Configuration)
198 194
199 /** Whether or not |configureWebRTCSession| has been called without a balanced
200 * call to |unconfigureWebRTCSession|. This is not an indication of whether the
201 * audio session has the right settings.
202 */
203 @property(readonly) BOOL isConfiguredForWebRTC;
204
205 /** Applies the configuration to the current session. Attempts to set all 195 /** Applies the configuration to the current session. Attempts to set all
206 * properties even if previous ones fail. Only the last error will be 196 * properties even if previous ones fail. Only the last error will be
207 * returned. Also calls setActive with |active|. 197 * returned.
198 * |lockForConfiguration| must be called first.
199 */
200 - (BOOL)setConfiguration:(RTCAudioSessionConfiguration *)configuration
201 error:(NSError **)outError;
202
203 /** Convenience method that calls both setConfiguration and setActive.
208 * |lockForConfiguration| must be called first. 204 * |lockForConfiguration| must be called first.
209 */ 205 */
210 - (BOOL)setConfiguration:(RTCAudioSessionConfiguration *)configuration 206 - (BOOL)setConfiguration:(RTCAudioSessionConfiguration *)configuration
211 active:(BOOL)active 207 active:(BOOL)active
212 error:(NSError **)outError; 208 error:(NSError **)outError;
213 209
214 /** Configure the audio session for WebRTC. This call will fail if the session
215 * is already configured. On other failures, we will attempt to restore the
216 * previously used audio session configuration.
217 * |lockForConfiguration| must be called first.
218 * Successful calls to configureWebRTCSession must be matched by calls to
219 * |unconfigureWebRTCSession|.
220 */
221 - (BOOL)configureWebRTCSession:(NSError **)outError;
222
223 /** Unconfigures the session for WebRTC. This will attempt to restore the
224 * audio session to the settings used before |configureWebRTCSession| was
225 * called.
226 * |lockForConfiguration| must be called first.
227 */
228 - (BOOL)unconfigureWebRTCSession:(NSError **)outError;
229
230 @end 210 @end
231 211
232 NS_ASSUME_NONNULL_END 212 NS_ASSUME_NONNULL_END
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698