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

Side by Side Diff: webrtc/modules/audio_device/audio_device_impl.h

Issue 1206783002: Cleanup of iOS AudioDevice implementation (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rebased Created 5 years, 5 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 (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_AUDIO_DEVICE_AUDIO_DEVICE_IMPL_H 11 #ifndef WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_IMPL_H
12 #define WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_IMPL_H 12 #define WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_IMPL_H
13 13
14 #if defined(WEBRTC_INCLUDE_INTERNAL_AUDIO_DEVICE) 14 #if defined(WEBRTC_INCLUDE_INTERNAL_AUDIO_DEVICE)
15 15
16 #include "webrtc/base/checks.h" 16 #include "webrtc/base/checks.h"
17 #include "webrtc/base/scoped_ptr.h" 17 #include "webrtc/base/scoped_ptr.h"
18 #include "webrtc/modules/audio_device/audio_device_buffer.h" 18 #include "webrtc/modules/audio_device/audio_device_buffer.h"
19 #include "webrtc/modules/audio_device/include/audio_device.h" 19 #include "webrtc/modules/audio_device/include/audio_device.h"
20 20
21 namespace webrtc 21 namespace webrtc {
22 {
23 22
24 class AudioDeviceGeneric; 23 class AudioDeviceGeneric;
25 class AudioManager; 24 class AudioManager;
26 class CriticalSectionWrapper; 25 class CriticalSectionWrapper;
27 26
28 class AudioDeviceModuleImpl : public AudioDeviceModule 27 class AudioDeviceModuleImpl : public AudioDeviceModule {
29 { 28 public:
30 public: 29 enum PlatformType {
31 enum PlatformType 30 kPlatformNotSupported = 0,
32 { 31 kPlatformWin32 = 1,
33 kPlatformNotSupported = 0, 32 kPlatformWinCe = 2,
34 kPlatformWin32 = 1, 33 kPlatformLinux = 3,
35 kPlatformWinCe = 2, 34 kPlatformMac = 4,
36 kPlatformLinux = 3, 35 kPlatformAndroid = 5,
37 kPlatformMac = 4, 36 kPlatformIOS = 6
38 kPlatformAndroid = 5, 37 };
39 kPlatformIOS = 6 38
40 }; 39 int32_t CheckPlatform();
41 40 int32_t CreatePlatformSpecificObjects();
42 int32_t CheckPlatform(); 41 int32_t AttachAudioBuffer();
43 int32_t CreatePlatformSpecificObjects(); 42
44 int32_t AttachAudioBuffer(); 43 AudioDeviceModuleImpl(const int32_t id, const AudioLayer audioLayer);
45 44 virtual ~AudioDeviceModuleImpl();
46 AudioDeviceModuleImpl(const int32_t id, const AudioLayer audioLayer); 45
47 virtual ~AudioDeviceModuleImpl(); 46 int64_t TimeUntilNextProcess() override;
48 47 int32_t Process() override;
49 public: // RefCountedModule 48
50 int64_t TimeUntilNextProcess() override; 49 // Factory methods (resource allocation/deallocation)
51 int32_t Process() override; 50 static AudioDeviceModule* Create(
52 51 const int32_t id,
53 public: 52 const AudioLayer audioLayer = kPlatformDefaultAudio);
54 // Factory methods (resource allocation/deallocation) 53
55 static AudioDeviceModule* Create( 54 // Retrieve the currently utilized audio layer
56 const int32_t id, 55 int32_t ActiveAudioLayer(AudioLayer* audioLayer) const override;
57 const AudioLayer audioLayer = kPlatformDefaultAudio); 56
58 57 // Error handling
59 // Retrieve the currently utilized audio layer 58 ErrorCode LastError() const override;
60 int32_t ActiveAudioLayer(AudioLayer* audioLayer) const override; 59 int32_t RegisterEventObserver(AudioDeviceObserver* eventCallback) override;
61 60
62 // Error handling 61 // Full-duplex transportation of PCM audio
63 ErrorCode LastError() const override; 62 int32_t RegisterAudioCallback(AudioTransport* audioCallback) override;
64 int32_t RegisterEventObserver(AudioDeviceObserver* eventCallback) override; 63
65 64 // Main initializaton and termination
66 // Full-duplex transportation of PCM audio 65 int32_t Init() override;
67 int32_t RegisterAudioCallback(AudioTransport* audioCallback) override; 66 int32_t Terminate() override;
68 67 bool Initialized() const override;
69 // Main initializaton and termination 68
70 int32_t Init() override; 69 // Device enumeration
71 int32_t Terminate() override; 70 int16_t PlayoutDevices() override;
72 bool Initialized() const override; 71 int16_t RecordingDevices() override;
73 72 int32_t PlayoutDeviceName(uint16_t index,
74 // Device enumeration 73 char name[kAdmMaxDeviceNameSize],
75 int16_t PlayoutDevices() override; 74 char guid[kAdmMaxGuidSize]) override;
76 int16_t RecordingDevices() override; 75 int32_t RecordingDeviceName(uint16_t index,
77 int32_t PlayoutDeviceName(uint16_t index,
78 char name[kAdmMaxDeviceNameSize], 76 char name[kAdmMaxDeviceNameSize],
79 char guid[kAdmMaxGuidSize]) override; 77 char guid[kAdmMaxGuidSize]) override;
80 int32_t RecordingDeviceName(uint16_t index, 78
81 char name[kAdmMaxDeviceNameSize], 79 // Device selection
82 char guid[kAdmMaxGuidSize]) override; 80 int32_t SetPlayoutDevice(uint16_t index) override;
83 81 int32_t SetPlayoutDevice(WindowsDeviceType device) override;
84 // Device selection 82 int32_t SetRecordingDevice(uint16_t index) override;
85 int32_t SetPlayoutDevice(uint16_t index) override; 83 int32_t SetRecordingDevice(WindowsDeviceType device) override;
86 int32_t SetPlayoutDevice(WindowsDeviceType device) override; 84
87 int32_t SetRecordingDevice(uint16_t index) override; 85 // Audio transport initialization
88 int32_t SetRecordingDevice(WindowsDeviceType device) override; 86 int32_t PlayoutIsAvailable(bool* available) override;
89 87 int32_t InitPlayout() override;
90 // Audio transport initialization 88 bool PlayoutIsInitialized() const override;
91 int32_t PlayoutIsAvailable(bool* available) override; 89 int32_t RecordingIsAvailable(bool* available) override;
92 int32_t InitPlayout() override; 90 int32_t InitRecording() override;
93 bool PlayoutIsInitialized() const override; 91 bool RecordingIsInitialized() const override;
94 int32_t RecordingIsAvailable(bool* available) override; 92
95 int32_t InitRecording() override; 93 // Audio transport control
96 bool RecordingIsInitialized() const override; 94 int32_t StartPlayout() override;
97 95 int32_t StopPlayout() override;
98 // Audio transport control 96 bool Playing() const override;
99 int32_t StartPlayout() override; 97 int32_t StartRecording() override;
100 int32_t StopPlayout() override; 98 int32_t StopRecording() override;
101 bool Playing() const override; 99 bool Recording() const override;
102 int32_t StartRecording() override; 100
103 int32_t StopRecording() override; 101 // Microphone Automatic Gain Control (AGC)
104 bool Recording() const override; 102 int32_t SetAGC(bool enable) override;
105 103 bool AGC() const override;
106 // Microphone Automatic Gain Control (AGC) 104
107 int32_t SetAGC(bool enable) override; 105 // Volume control based on the Windows Wave API (Windows only)
108 bool AGC() const override; 106 int32_t SetWaveOutVolume(uint16_t volumeLeft, uint16_t volumeRight) override;
109 107 int32_t WaveOutVolume(uint16_t* volumeLeft,
110 // Volume control based on the Windows Wave API (Windows only) 108 uint16_t* volumeRight) const override;
111 int32_t SetWaveOutVolume(uint16_t volumeLeft, 109
112 uint16_t volumeRight) override; 110 // Audio mixer initialization
113 int32_t WaveOutVolume(uint16_t* volumeLeft, 111 int32_t InitSpeaker() override;
114 uint16_t* volumeRight) const override; 112 bool SpeakerIsInitialized() const override;
115 113 int32_t InitMicrophone() override;
116 // Audio mixer initialization 114 bool MicrophoneIsInitialized() const override;
117 int32_t InitSpeaker() override; 115
118 bool SpeakerIsInitialized() const override; 116 // Speaker volume controls
119 int32_t InitMicrophone() override; 117 int32_t SpeakerVolumeIsAvailable(bool* available) override;
120 bool MicrophoneIsInitialized() const override; 118 int32_t SetSpeakerVolume(uint32_t volume) override;
121 119 int32_t SpeakerVolume(uint32_t* volume) const override;
122 // Speaker volume controls 120 int32_t MaxSpeakerVolume(uint32_t* maxVolume) const override;
123 int32_t SpeakerVolumeIsAvailable(bool* available) override; 121 int32_t MinSpeakerVolume(uint32_t* minVolume) const override;
124 int32_t SetSpeakerVolume(uint32_t volume) override; 122 int32_t SpeakerVolumeStepSize(uint16_t* stepSize) const override;
125 int32_t SpeakerVolume(uint32_t* volume) const override; 123
126 int32_t MaxSpeakerVolume(uint32_t* maxVolume) const override; 124 // Microphone volume controls
127 int32_t MinSpeakerVolume(uint32_t* minVolume) const override; 125 int32_t MicrophoneVolumeIsAvailable(bool* available) override;
128 int32_t SpeakerVolumeStepSize(uint16_t* stepSize) const override; 126 int32_t SetMicrophoneVolume(uint32_t volume) override;
129 127 int32_t MicrophoneVolume(uint32_t* volume) const override;
130 // Microphone volume controls 128 int32_t MaxMicrophoneVolume(uint32_t* maxVolume) const override;
131 int32_t MicrophoneVolumeIsAvailable(bool* available) override; 129 int32_t MinMicrophoneVolume(uint32_t* minVolume) const override;
132 int32_t SetMicrophoneVolume(uint32_t volume) override; 130 int32_t MicrophoneVolumeStepSize(uint16_t* stepSize) const override;
133 int32_t MicrophoneVolume(uint32_t* volume) const override; 131
134 int32_t MaxMicrophoneVolume(uint32_t* maxVolume) const override; 132 // Speaker mute control
135 int32_t MinMicrophoneVolume(uint32_t* minVolume) const override; 133 int32_t SpeakerMuteIsAvailable(bool* available) override;
136 int32_t MicrophoneVolumeStepSize(uint16_t* stepSize) const override; 134 int32_t SetSpeakerMute(bool enable) override;
137 135 int32_t SpeakerMute(bool* enabled) const override;
138 // Speaker mute control 136
139 int32_t SpeakerMuteIsAvailable(bool* available) override; 137 // Microphone mute control
140 int32_t SetSpeakerMute(bool enable) override; 138 int32_t MicrophoneMuteIsAvailable(bool* available) override;
141 int32_t SpeakerMute(bool* enabled) const override; 139 int32_t SetMicrophoneMute(bool enable) override;
142 140 int32_t MicrophoneMute(bool* enabled) const override;
143 // Microphone mute control 141
144 int32_t MicrophoneMuteIsAvailable(bool* available) override; 142 // Microphone boost control
145 int32_t SetMicrophoneMute(bool enable) override; 143 int32_t MicrophoneBoostIsAvailable(bool* available) override;
146 int32_t MicrophoneMute(bool* enabled) const override; 144 int32_t SetMicrophoneBoost(bool enable) override;
147 145 int32_t MicrophoneBoost(bool* enabled) const override;
148 // Microphone boost control 146
149 int32_t MicrophoneBoostIsAvailable(bool* available) override; 147 // Stereo support
150 int32_t SetMicrophoneBoost(bool enable) override; 148 int32_t StereoPlayoutIsAvailable(bool* available) const override;
151 int32_t MicrophoneBoost(bool* enabled) const override; 149 int32_t SetStereoPlayout(bool enable) override;
152 150 int32_t StereoPlayout(bool* enabled) const override;
153 // Stereo support 151 int32_t StereoRecordingIsAvailable(bool* available) const override;
154 int32_t StereoPlayoutIsAvailable(bool* available) const override; 152 int32_t SetStereoRecording(bool enable) override;
155 int32_t SetStereoPlayout(bool enable) override; 153 int32_t StereoRecording(bool* enabled) const override;
156 int32_t StereoPlayout(bool* enabled) const override; 154 int32_t SetRecordingChannel(const ChannelType channel) override;
157 int32_t StereoRecordingIsAvailable(bool* available) const override; 155 int32_t RecordingChannel(ChannelType* channel) const override;
158 int32_t SetStereoRecording(bool enable) override; 156
159 int32_t StereoRecording(bool* enabled) const override; 157 // Delay information and control
160 int32_t SetRecordingChannel(const ChannelType channel) override; 158 int32_t SetPlayoutBuffer(const BufferType type, uint16_t sizeMS = 0) override;
161 int32_t RecordingChannel(ChannelType* channel) const override; 159 int32_t PlayoutBuffer(BufferType* type, uint16_t* sizeMS) const override;
162 160 int32_t PlayoutDelay(uint16_t* delayMS) const override;
163 // Delay information and control 161 int32_t RecordingDelay(uint16_t* delayMS) const override;
164 int32_t SetPlayoutBuffer(const BufferType type, 162
165 uint16_t sizeMS = 0) override; 163 // CPU load
166 int32_t PlayoutBuffer(BufferType* type, uint16_t* sizeMS) const override; 164 int32_t CPULoad(uint16_t* load) const override;
167 int32_t PlayoutDelay(uint16_t* delayMS) const override; 165
168 int32_t RecordingDelay(uint16_t* delayMS) const override; 166 // Recording of raw PCM data
169 167 int32_t StartRawOutputFileRecording(
170 // CPU load 168 const char pcmFileNameUTF8[kAdmMaxFileNameSize]) override;
171 int32_t CPULoad(uint16_t* load) const override; 169 int32_t StopRawOutputFileRecording() override;
172 170 int32_t StartRawInputFileRecording(
173 // Recording of raw PCM data 171 const char pcmFileNameUTF8[kAdmMaxFileNameSize]) override;
174 int32_t StartRawOutputFileRecording( 172 int32_t StopRawInputFileRecording() override;
175 const char pcmFileNameUTF8[kAdmMaxFileNameSize]) override; 173
176 int32_t StopRawOutputFileRecording() override; 174 // Native sample rate controls (samples/sec)
177 int32_t StartRawInputFileRecording( 175 int32_t SetRecordingSampleRate(const uint32_t samplesPerSec) override;
178 const char pcmFileNameUTF8[kAdmMaxFileNameSize]) override; 176 int32_t RecordingSampleRate(uint32_t* samplesPerSec) const override;
179 int32_t StopRawInputFileRecording() override; 177 int32_t SetPlayoutSampleRate(const uint32_t samplesPerSec) override;
180 178 int32_t PlayoutSampleRate(uint32_t* samplesPerSec) const override;
181 // Native sample rate controls (samples/sec) 179
182 int32_t SetRecordingSampleRate(const uint32_t samplesPerSec) override; 180 // Mobile device specific functions
183 int32_t RecordingSampleRate(uint32_t* samplesPerSec) const override; 181 int32_t ResetAudioDevice() override;
184 int32_t SetPlayoutSampleRate(const uint32_t samplesPerSec) override; 182 int32_t SetLoudspeakerStatus(bool enable) override;
185 int32_t PlayoutSampleRate(uint32_t* samplesPerSec) const override; 183 int32_t GetLoudspeakerStatus(bool* enabled) const override;
186 184
187 // Mobile device specific functions 185 bool BuiltInAECIsAvailable() const override;
188 int32_t ResetAudioDevice() override; 186
189 int32_t SetLoudspeakerStatus(bool enable) override; 187 int32_t EnableBuiltInAEC(bool enable) override;
190 int32_t GetLoudspeakerStatus(bool* enabled) const override; 188 bool BuiltInAECIsEnabled() const override;
191 189
192 bool BuiltInAECIsAvailable() const override; 190 int GetPlayoutAudioParameters(AudioParameters* params) const override;
193 191 int GetRecordAudioParameters(AudioParameters* params) const override;
194 int32_t EnableBuiltInAEC(bool enable) override; 192
195 bool BuiltInAECIsEnabled() const override; 193 int32_t Id() { return _id; }
196
197 public:
198 int32_t Id() {return _id;}
199 #if defined(WEBRTC_ANDROID) 194 #if defined(WEBRTC_ANDROID)
200 // Only use this acccessor for test purposes on Android. 195 // Only use this acccessor for test purposes on Android.
201 AudioManager* GetAndroidAudioManagerForTest() { 196 AudioManager* GetAndroidAudioManagerForTest() {
202 return _audioManagerAndroid.get(); 197 return _audioManagerAndroid.get();
203 } 198 }
204 #endif 199 #endif
205 AudioDeviceBuffer* GetAudioDeviceBuffer() { 200 AudioDeviceBuffer* GetAudioDeviceBuffer() { return &_audioDeviceBuffer; }
206 return &_audioDeviceBuffer; 201
207 } 202 private:
208 203 PlatformType Platform() const;
209 private: 204 AudioLayer PlatformAudioLayer() const;
210 PlatformType Platform() const; 205
211 AudioLayer PlatformAudioLayer() const; 206 CriticalSectionWrapper& _critSect;
212 207 CriticalSectionWrapper& _critSectEventCb;
213 private: 208 CriticalSectionWrapper& _critSectAudioCb;
214 CriticalSectionWrapper& _critSect; 209
215 CriticalSectionWrapper& _critSectEventCb; 210 AudioDeviceObserver* _ptrCbAudioDeviceObserver;
216 CriticalSectionWrapper& _critSectAudioCb; 211
217 212 AudioDeviceGeneric* _ptrAudioDevice;
218 AudioDeviceObserver* _ptrCbAudioDeviceObserver; 213
219 214 AudioDeviceBuffer _audioDeviceBuffer;
220 AudioDeviceGeneric* _ptrAudioDevice;
221
222 AudioDeviceBuffer _audioDeviceBuffer;
223 #if defined(WEBRTC_ANDROID) 215 #if defined(WEBRTC_ANDROID)
224 rtc::scoped_ptr<AudioManager> _audioManagerAndroid; 216 rtc::scoped_ptr<AudioManager> _audioManagerAndroid;
225 #endif 217 #endif
226 int32_t _id; 218 int32_t _id;
227 AudioLayer _platformAudioLayer; 219 AudioLayer _platformAudioLayer;
228 int64_t _lastProcessTime; 220 int64_t _lastProcessTime;
229 PlatformType _platformType; 221 PlatformType _platformType;
230 bool _initialized; 222 bool _initialized;
231 mutable ErrorCode _lastError; 223 mutable ErrorCode _lastError;
232 }; 224 };
233 225
234 } // namespace webrtc 226 } // namespace webrtc
235 227
236 #endif // defined(WEBRTC_INCLUDE_INTERNAL_AUDIO_DEVICE) 228 #endif // defined(WEBRTC_INCLUDE_INTERNAL_AUDIO_DEVICE)
237 229
238 #endif // WEBRTC_MODULES_INTERFACE_AUDIO_DEVICE_IMPL_H_ 230 #endif // WEBRTC_MODULES_INTERFACE_AUDIO_DEVICE_IMPL_H_
OLDNEW
« no previous file with comments | « webrtc/modules/audio_device/audio_device_generic.cc ('k') | webrtc/modules/audio_device/audio_device_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698