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> |
| 15 |
14 #include <AudioUnit/AudioUnit.h> | 16 #include <AudioUnit/AudioUnit.h> |
15 | 17 |
16 #include "webrtc/base/scoped_ptr.h" | |
17 #include "webrtc/base/thread_checker.h" | 18 #include "webrtc/base/thread_checker.h" |
18 #include "webrtc/modules/audio_device/audio_device_generic.h" | 19 #include "webrtc/modules/audio_device/audio_device_generic.h" |
19 | 20 |
20 namespace webrtc { | 21 namespace webrtc { |
21 | 22 |
22 class FineAudioBuffer; | 23 class FineAudioBuffer; |
23 | 24 |
24 // Implements full duplex 16-bit mono PCM audio support for iOS using a | 25 // Implements full duplex 16-bit mono PCM audio support for iOS using a |
25 // Voice-Processing (VP) I/O audio unit in Core Audio. The VP I/O audio unit | 26 // Voice-Processing (VP) I/O audio unit in Core Audio. The VP I/O audio unit |
26 // supports audio echo cancellation. It also adds automatic gain control, | 27 // supports audio echo cancellation. It also adds automatic gain control, |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 // audio data samples. Is also supports a similar scheme for the recording | 250 // audio data samples. Is also supports a similar scheme for the recording |
250 // side. | 251 // side. |
251 // Example: native buffer size can be 128 audio frames at 16kHz sample rate. | 252 // Example: native buffer size can be 128 audio frames at 16kHz sample rate. |
252 // WebRTC will provide 480 audio frames per 10ms but iOS asks for 128 | 253 // WebRTC will provide 480 audio frames per 10ms but iOS asks for 128 |
253 // in each callback (one every 8ms). This class can then ask for 128 and the | 254 // in each callback (one every 8ms). This class can then ask for 128 and the |
254 // FineAudioBuffer will ask WebRTC for new data only when needed and also | 255 // FineAudioBuffer will ask WebRTC for new data only when needed and also |
255 // cache non-utilized audio between callbacks. On the recording side, iOS | 256 // cache non-utilized audio between callbacks. On the recording side, iOS |
256 // can provide audio data frames of size 128 and these are accumulated until | 257 // can provide audio data frames of size 128 and these are accumulated until |
257 // enough data to supply one 10ms call exists. This 10ms chunk is then sent | 258 // enough data to supply one 10ms call exists. This 10ms chunk is then sent |
258 // to WebRTC and the remaining part is stored. | 259 // to WebRTC and the remaining part is stored. |
259 rtc::scoped_ptr<FineAudioBuffer> fine_audio_buffer_; | 260 std::unique_ptr<FineAudioBuffer> fine_audio_buffer_; |
260 | 261 |
261 // Extra audio buffer to be used by the playout side for rendering audio. | 262 // Extra audio buffer to be used by the playout side for rendering audio. |
262 // The buffer size is given by FineAudioBuffer::RequiredBufferSizeBytes(). | 263 // The buffer size is given by FineAudioBuffer::RequiredBufferSizeBytes(). |
263 rtc::scoped_ptr<SInt8[]> playout_audio_buffer_; | 264 std::unique_ptr<SInt8[]> playout_audio_buffer_; |
264 | 265 |
265 // Provides a mechanism for encapsulating one or more buffers of audio data. | 266 // Provides a mechanism for encapsulating one or more buffers of audio data. |
266 // Only used on the recording side. | 267 // Only used on the recording side. |
267 AudioBufferList audio_record_buffer_list_; | 268 AudioBufferList audio_record_buffer_list_; |
268 | 269 |
269 // Temporary storage for recorded data. AudioUnitRender() renders into this | 270 // Temporary storage for recorded data. AudioUnitRender() renders into this |
270 // array as soon as a frame of the desired buffer size has been recorded. | 271 // array as soon as a frame of the desired buffer size has been recorded. |
271 rtc::scoped_ptr<SInt8[]> record_audio_buffer_; | 272 std::unique_ptr<SInt8[]> record_audio_buffer_; |
272 | 273 |
273 // Set to 1 when recording is active and 0 otherwise. | 274 // Set to 1 when recording is active and 0 otherwise. |
274 volatile int recording_; | 275 volatile int recording_; |
275 | 276 |
276 // Set to 1 when playout is active and 0 otherwise. | 277 // Set to 1 when playout is active and 0 otherwise. |
277 volatile int playing_; | 278 volatile int playing_; |
278 | 279 |
279 // Set to true after successful call to Init(), false otherwise. | 280 // Set to true after successful call to Init(), false otherwise. |
280 bool initialized_; | 281 bool initialized_; |
281 | 282 |
282 // Set to true after successful call to InitRecording(), false otherwise. | 283 // Set to true after successful call to InitRecording(), false otherwise. |
283 bool rec_is_initialized_; | 284 bool rec_is_initialized_; |
284 | 285 |
285 // Set to true after successful call to InitPlayout(), false otherwise. | 286 // Set to true after successful call to InitPlayout(), false otherwise. |
286 bool play_is_initialized_; | 287 bool play_is_initialized_; |
287 | 288 |
288 // Audio interruption observer instance. | 289 // Audio interruption observer instance. |
289 void* audio_interruption_observer_; | 290 void* audio_interruption_observer_; |
290 void* route_change_observer_; | 291 void* route_change_observer_; |
291 | 292 |
292 // Contains the audio data format specification for a stream of audio. | 293 // Contains the audio data format specification for a stream of audio. |
293 AudioStreamBasicDescription application_format_; | 294 AudioStreamBasicDescription application_format_; |
294 }; | 295 }; |
295 | 296 |
296 } // namespace webrtc | 297 } // namespace webrtc |
297 | 298 |
298 #endif // WEBRTC_MODULES_AUDIO_DEVICE_IOS_AUDIO_DEVICE_IOS_H_ | 299 #endif // WEBRTC_MODULES_AUDIO_DEVICE_IOS_AUDIO_DEVICE_IOS_H_ |
OLD | NEW |