OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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 #ifndef WEBRTC_MODULES_AUDIO_DEVICE_IOS_AUDIO_DEVICE_IOS_H_ | 11 #ifndef WEBRTC_MODULES_AUDIO_DEVICE_IOS_AUDIO_DEVICE_IOS_H_ |
12 #define WEBRTC_MODULES_AUDIO_DEVICE_IOS_AUDIO_DEVICE_IOS_H_ | 12 #define WEBRTC_MODULES_AUDIO_DEVICE_IOS_AUDIO_DEVICE_IOS_H_ |
13 | 13 |
14 #include <memory> | 14 #include <memory> |
15 | 15 |
16 #include <AudioUnit/AudioUnit.h> | 16 #include <AudioUnit/AudioUnit.h> |
17 | 17 |
18 #include "webrtc/base/objc/RTCMacros.h" | |
18 #include "webrtc/base/thread_checker.h" | 19 #include "webrtc/base/thread_checker.h" |
19 #include "webrtc/modules/audio_device/audio_device_generic.h" | 20 #include "webrtc/modules/audio_device/audio_device_generic.h" |
20 | 21 |
22 RTC_FWD_DECL_OBJC_CLASS(RTCAudioSessionDelegateAdapter); | |
23 | |
21 namespace webrtc { | 24 namespace webrtc { |
22 | 25 |
23 class FineAudioBuffer; | 26 class FineAudioBuffer; |
24 | 27 |
25 // Implements full duplex 16-bit mono PCM audio support for iOS using a | 28 // Implements full duplex 16-bit mono PCM audio support for iOS using a |
26 // Voice-Processing (VP) I/O audio unit in Core Audio. The VP I/O audio unit | 29 // Voice-Processing (VP) I/O audio unit in Core Audio. The VP I/O audio unit |
27 // supports audio echo cancellation. It also adds automatic gain control, | 30 // supports audio echo cancellation. It also adds automatic gain control, |
28 // adjustment of voice-processing quality and muting. | 31 // adjustment of voice-processing quality and muting. |
29 // | 32 // |
30 // An instance must be created and destroyed on one and the same thread. | 33 // An instance must be created and destroyed on one and the same thread. |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
144 int32_t CPULoad(uint16_t& load) const override; | 147 int32_t CPULoad(uint16_t& load) const override; |
145 bool PlayoutWarning() const override; | 148 bool PlayoutWarning() const override; |
146 bool PlayoutError() const override; | 149 bool PlayoutError() const override; |
147 bool RecordingWarning() const override; | 150 bool RecordingWarning() const override; |
148 bool RecordingError() const override; | 151 bool RecordingError() const override; |
149 void ClearPlayoutWarning() override {} | 152 void ClearPlayoutWarning() override {} |
150 void ClearPlayoutError() override {} | 153 void ClearPlayoutError() override {} |
151 void ClearRecordingWarning() override {} | 154 void ClearRecordingWarning() override {} |
152 void ClearRecordingError() override {} | 155 void ClearRecordingError() override {} |
153 | 156 |
157 // These methods should be called in response to audio events. | |
henrika_webrtc
2016/03/15 08:53:44
Any restrictions on the calling thread?
tkchin_webrtc
2016/03/15 20:14:58
Done.
| |
158 void OnInterruptionBegin(); | |
159 void OnInterruptionEnd(); | |
160 void OnValidRouteChange(); | |
161 | |
154 private: | 162 private: |
155 // Uses current |playout_parameters_| and |record_parameters_| to inform the | 163 // Uses current |playout_parameters_| and |record_parameters_| to inform the |
156 // audio device buffer (ADB) about our internal audio parameters. | 164 // audio device buffer (ADB) about our internal audio parameters. |
157 void UpdateAudioDeviceBuffer(); | 165 void UpdateAudioDeviceBuffer(); |
158 | 166 |
159 // Registers observers for the AVAudioSessionRouteChangeNotification and | |
160 // AVAudioSessionInterruptionNotification notifications. | |
161 void RegisterNotificationObservers(); | |
162 void UnregisterNotificationObservers(); | |
163 | |
164 // Since the preferred audio parameters are only hints to the OS, the actual | 167 // Since the preferred audio parameters are only hints to the OS, the actual |
165 // values may be different once the AVAudioSession has been activated. | 168 // values may be different once the AVAudioSession has been activated. |
166 // This method asks for the current hardware parameters and takes actions | 169 // This method asks for the current hardware parameters and takes actions |
167 // if they should differ from what we have asked for initially. It also | 170 // if they should differ from what we have asked for initially. It also |
168 // defines |playout_parameters_| and |record_parameters_|. | 171 // defines |playout_parameters_| and |record_parameters_|. |
169 void SetupAudioBuffersForActiveAudioSession(); | 172 void SetupAudioBuffersForActiveAudioSession(); |
170 | 173 |
171 // Creates a Voice-Processing I/O unit and configures it for full-duplex | 174 // Creates a Voice-Processing I/O unit and configures it for full-duplex |
172 // audio. The selected stream format is selected to avoid internal resampling | 175 // audio. The selected stream format is selected to avoid internal resampling |
173 // and to match the 10ms callback rate for WebRTC as well as possible. | 176 // and to match the 10ms callback rate for WebRTC as well as possible. |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
279 | 282 |
280 // Set to true after successful call to Init(), false otherwise. | 283 // Set to true after successful call to Init(), false otherwise. |
281 bool initialized_; | 284 bool initialized_; |
282 | 285 |
283 // Set to true after successful call to InitRecording(), false otherwise. | 286 // Set to true after successful call to InitRecording(), false otherwise. |
284 bool rec_is_initialized_; | 287 bool rec_is_initialized_; |
285 | 288 |
286 // Set to true after successful call to InitPlayout(), false otherwise. | 289 // Set to true after successful call to InitPlayout(), false otherwise. |
287 bool play_is_initialized_; | 290 bool play_is_initialized_; |
288 | 291 |
292 // Set to true if audio session is interrupted, false otherwise. | |
293 bool is_interrupted_; | |
294 | |
289 // Audio interruption observer instance. | 295 // Audio interruption observer instance. |
290 void* audio_interruption_observer_; | 296 RTCAudioSessionDelegateAdapter* audio_session_observer_; |
291 void* route_change_observer_; | |
292 | 297 |
293 // Contains the audio data format specification for a stream of audio. | 298 // Contains the audio data format specification for a stream of audio. |
294 AudioStreamBasicDescription application_format_; | 299 AudioStreamBasicDescription application_format_; |
295 }; | 300 }; |
296 | 301 |
297 } // namespace webrtc | 302 } // namespace webrtc |
298 | 303 |
299 #endif // WEBRTC_MODULES_AUDIO_DEVICE_IOS_AUDIO_DEVICE_IOS_H_ | 304 #endif // WEBRTC_MODULES_AUDIO_DEVICE_IOS_AUDIO_DEVICE_IOS_H_ |
OLD | NEW |