niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1 | /* |
leozwang@webrtc.org | 28f3913 | 2012-03-01 18:01:48 +0000 | [diff] [blame] | 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 3 | * |
| 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 |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
| 11 | #ifndef WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_GENERIC_H |
| 12 | #define WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_GENERIC_H |
| 13 | |
pbos@webrtc.org | 811269d | 2013-07-11 13:24:38 +0000 | [diff] [blame] | 14 | #include "webrtc/modules/audio_device/audio_device_buffer.h" |
| 15 | #include "webrtc/modules/audio_device/include/audio_device.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 16 | |
| 17 | namespace webrtc { |
| 18 | |
henrika | ba35d05 | 2015-07-14 17:04:08 +0200 | [diff] [blame] | 19 | class AudioDeviceGeneric { |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 20 | public: |
henrika | ba35d05 | 2015-07-14 17:04:08 +0200 | [diff] [blame] | 21 | // Retrieve the currently utilized audio layer |
| 22 | virtual int32_t ActiveAudioLayer( |
| 23 | AudioDeviceModule::AudioLayer& audioLayer) const = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 24 | |
henrika | ba35d05 | 2015-07-14 17:04:08 +0200 | [diff] [blame] | 25 | // Main initializaton and termination |
| 26 | virtual int32_t Init() = 0; |
| 27 | virtual int32_t Terminate() = 0; |
| 28 | virtual bool Initialized() const = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 29 | |
henrika | ba35d05 | 2015-07-14 17:04:08 +0200 | [diff] [blame] | 30 | // Device enumeration |
| 31 | virtual int16_t PlayoutDevices() = 0; |
| 32 | virtual int16_t RecordingDevices() = 0; |
| 33 | virtual int32_t PlayoutDeviceName(uint16_t index, |
| 34 | char name[kAdmMaxDeviceNameSize], |
| 35 | char guid[kAdmMaxGuidSize]) = 0; |
| 36 | virtual int32_t RecordingDeviceName(uint16_t index, |
| 37 | char name[kAdmMaxDeviceNameSize], |
| 38 | char guid[kAdmMaxGuidSize]) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 39 | |
henrika | ba35d05 | 2015-07-14 17:04:08 +0200 | [diff] [blame] | 40 | // Device selection |
| 41 | virtual int32_t SetPlayoutDevice(uint16_t index) = 0; |
| 42 | virtual int32_t SetPlayoutDevice( |
| 43 | AudioDeviceModule::WindowsDeviceType device) = 0; |
| 44 | virtual int32_t SetRecordingDevice(uint16_t index) = 0; |
| 45 | virtual int32_t SetRecordingDevice( |
| 46 | AudioDeviceModule::WindowsDeviceType device) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 47 | |
henrika | ba35d05 | 2015-07-14 17:04:08 +0200 | [diff] [blame] | 48 | // Audio transport initialization |
| 49 | virtual int32_t PlayoutIsAvailable(bool& available) = 0; |
| 50 | virtual int32_t InitPlayout() = 0; |
| 51 | virtual bool PlayoutIsInitialized() const = 0; |
| 52 | virtual int32_t RecordingIsAvailable(bool& available) = 0; |
| 53 | virtual int32_t InitRecording() = 0; |
| 54 | virtual bool RecordingIsInitialized() const = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 55 | |
henrika | ba35d05 | 2015-07-14 17:04:08 +0200 | [diff] [blame] | 56 | // Audio transport control |
| 57 | virtual int32_t StartPlayout() = 0; |
| 58 | virtual int32_t StopPlayout() = 0; |
| 59 | virtual bool Playing() const = 0; |
| 60 | virtual int32_t StartRecording() = 0; |
| 61 | virtual int32_t StopRecording() = 0; |
| 62 | virtual bool Recording() const = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 63 | |
henrika | ba35d05 | 2015-07-14 17:04:08 +0200 | [diff] [blame] | 64 | // Microphone Automatic Gain Control (AGC) |
| 65 | virtual int32_t SetAGC(bool enable) = 0; |
| 66 | virtual bool AGC() const = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 67 | |
henrika | ba35d05 | 2015-07-14 17:04:08 +0200 | [diff] [blame] | 68 | // Volume control based on the Windows Wave API (Windows only) |
| 69 | virtual int32_t SetWaveOutVolume(uint16_t volumeLeft, |
| 70 | uint16_t volumeRight) = 0; |
| 71 | virtual int32_t WaveOutVolume(uint16_t& volumeLeft, |
| 72 | uint16_t& volumeRight) const = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 73 | |
henrika | ba35d05 | 2015-07-14 17:04:08 +0200 | [diff] [blame] | 74 | // Audio mixer initialization |
| 75 | virtual int32_t InitSpeaker() = 0; |
| 76 | virtual bool SpeakerIsInitialized() const = 0; |
| 77 | virtual int32_t InitMicrophone() = 0; |
| 78 | virtual bool MicrophoneIsInitialized() const = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 79 | |
henrika | ba35d05 | 2015-07-14 17:04:08 +0200 | [diff] [blame] | 80 | // Speaker volume controls |
| 81 | virtual int32_t SpeakerVolumeIsAvailable(bool& available) = 0; |
| 82 | virtual int32_t SetSpeakerVolume(uint32_t volume) = 0; |
| 83 | virtual int32_t SpeakerVolume(uint32_t& volume) const = 0; |
| 84 | virtual int32_t MaxSpeakerVolume(uint32_t& maxVolume) const = 0; |
| 85 | virtual int32_t MinSpeakerVolume(uint32_t& minVolume) const = 0; |
| 86 | virtual int32_t SpeakerVolumeStepSize(uint16_t& stepSize) const = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 87 | |
henrika | ba35d05 | 2015-07-14 17:04:08 +0200 | [diff] [blame] | 88 | // Microphone volume controls |
| 89 | virtual int32_t MicrophoneVolumeIsAvailable(bool& available) = 0; |
| 90 | virtual int32_t SetMicrophoneVolume(uint32_t volume) = 0; |
| 91 | virtual int32_t MicrophoneVolume(uint32_t& volume) const = 0; |
| 92 | virtual int32_t MaxMicrophoneVolume(uint32_t& maxVolume) const = 0; |
| 93 | virtual int32_t MinMicrophoneVolume(uint32_t& minVolume) const = 0; |
| 94 | virtual int32_t MicrophoneVolumeStepSize(uint16_t& stepSize) const = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 95 | |
henrika | ba35d05 | 2015-07-14 17:04:08 +0200 | [diff] [blame] | 96 | // Speaker mute control |
| 97 | virtual int32_t SpeakerMuteIsAvailable(bool& available) = 0; |
| 98 | virtual int32_t SetSpeakerMute(bool enable) = 0; |
| 99 | virtual int32_t SpeakerMute(bool& enabled) const = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 100 | |
henrika | ba35d05 | 2015-07-14 17:04:08 +0200 | [diff] [blame] | 101 | // Microphone mute control |
| 102 | virtual int32_t MicrophoneMuteIsAvailable(bool& available) = 0; |
| 103 | virtual int32_t SetMicrophoneMute(bool enable) = 0; |
| 104 | virtual int32_t MicrophoneMute(bool& enabled) const = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 105 | |
henrika | ba35d05 | 2015-07-14 17:04:08 +0200 | [diff] [blame] | 106 | // Microphone boost control |
| 107 | virtual int32_t MicrophoneBoostIsAvailable(bool& available) = 0; |
| 108 | virtual int32_t SetMicrophoneBoost(bool enable) = 0; |
| 109 | virtual int32_t MicrophoneBoost(bool& enabled) const = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 110 | |
henrika | ba35d05 | 2015-07-14 17:04:08 +0200 | [diff] [blame] | 111 | // Stereo support |
| 112 | virtual int32_t StereoPlayoutIsAvailable(bool& available) = 0; |
| 113 | virtual int32_t SetStereoPlayout(bool enable) = 0; |
| 114 | virtual int32_t StereoPlayout(bool& enabled) const = 0; |
| 115 | virtual int32_t StereoRecordingIsAvailable(bool& available) = 0; |
| 116 | virtual int32_t SetStereoRecording(bool enable) = 0; |
| 117 | virtual int32_t StereoRecording(bool& enabled) const = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 118 | |
henrika | ba35d05 | 2015-07-14 17:04:08 +0200 | [diff] [blame] | 119 | // Delay information and control |
| 120 | virtual int32_t SetPlayoutBuffer(const AudioDeviceModule::BufferType type, |
| 121 | uint16_t sizeMS = 0) = 0; |
| 122 | virtual int32_t PlayoutBuffer(AudioDeviceModule::BufferType& type, |
| 123 | uint16_t& sizeMS) const = 0; |
| 124 | virtual int32_t PlayoutDelay(uint16_t& delayMS) const = 0; |
| 125 | virtual int32_t RecordingDelay(uint16_t& delayMS) const = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 126 | |
henrika | ba35d05 | 2015-07-14 17:04:08 +0200 | [diff] [blame] | 127 | // CPU load |
| 128 | virtual int32_t CPULoad(uint16_t& load) const = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 129 | |
henrika | ba35d05 | 2015-07-14 17:04:08 +0200 | [diff] [blame] | 130 | // Native sample rate controls (samples/sec) |
| 131 | virtual int32_t SetRecordingSampleRate(const uint32_t samplesPerSec); |
| 132 | virtual int32_t SetPlayoutSampleRate(const uint32_t samplesPerSec); |
andrew@webrtc.org | c7c432a | 2014-04-02 16:49:26 +0000 | [diff] [blame] | 133 | |
henrika | ba35d05 | 2015-07-14 17:04:08 +0200 | [diff] [blame] | 134 | // Speaker audio routing (for mobile devices) |
| 135 | virtual int32_t SetLoudspeakerStatus(bool enable); |
| 136 | virtual int32_t GetLoudspeakerStatus(bool& enable) const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 137 | |
henrika | ba35d05 | 2015-07-14 17:04:08 +0200 | [diff] [blame] | 138 | // Reset Audio Device (for mobile devices) |
| 139 | virtual int32_t ResetAudioDevice(); |
andrew@webrtc.org | c7c432a | 2014-04-02 16:49:26 +0000 | [diff] [blame] | 140 | |
henrika | ba35d05 | 2015-07-14 17:04:08 +0200 | [diff] [blame] | 141 | // Sound Audio Device control (for WinCE only) |
| 142 | virtual int32_t SoundDeviceControl(unsigned int par1 = 0, |
| 143 | unsigned int par2 = 0, |
| 144 | unsigned int par3 = 0, |
| 145 | unsigned int par4 = 0); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 146 | |
henrika | ba35d05 | 2015-07-14 17:04:08 +0200 | [diff] [blame] | 147 | // Android only |
| 148 | virtual bool BuiltInAECIsAvailable() const; |
henrika | c14f5ff | 2015-09-23 14:08:33 +0200 | [diff] [blame] | 149 | virtual bool BuiltInAGCIsAvailable() const; |
| 150 | virtual bool BuiltInNSIsAvailable() const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 151 | |
henrika | ba35d05 | 2015-07-14 17:04:08 +0200 | [diff] [blame] | 152 | // Windows Core Audio and Android only. |
| 153 | virtual int32_t EnableBuiltInAEC(bool enable); |
henrika | c14f5ff | 2015-09-23 14:08:33 +0200 | [diff] [blame] | 154 | virtual int32_t EnableBuiltInAGC(bool enable); |
| 155 | virtual int32_t EnableBuiltInNS(bool enable); |
henrika@webrtc.org | a954c07 | 2014-12-09 16:22:09 +0000 | [diff] [blame] | 156 | |
henrika | ba35d05 | 2015-07-14 17:04:08 +0200 | [diff] [blame] | 157 | // Windows Core Audio only. |
| 158 | virtual bool BuiltInAECIsEnabled() const; |
henrika@webrtc.org | a954c07 | 2014-12-09 16:22:09 +0000 | [diff] [blame] | 159 | |
henrika | ba35d05 | 2015-07-14 17:04:08 +0200 | [diff] [blame] | 160 | // iOS only. |
| 161 | // TODO(henrika): add Android support. |
| 162 | virtual int GetPlayoutAudioParameters(AudioParameters* params) const; |
| 163 | virtual int GetRecordAudioParameters(AudioParameters* params) const; |
andrew@webrtc.org | a3c6d61 | 2011-09-13 17:17:49 +0000 | [diff] [blame] | 164 | |
henrika | ba35d05 | 2015-07-14 17:04:08 +0200 | [diff] [blame] | 165 | virtual bool PlayoutWarning() const = 0; |
| 166 | virtual bool PlayoutError() const = 0; |
| 167 | virtual bool RecordingWarning() const = 0; |
| 168 | virtual bool RecordingError() const = 0; |
| 169 | virtual void ClearPlayoutWarning() = 0; |
| 170 | virtual void ClearPlayoutError() = 0; |
| 171 | virtual void ClearRecordingWarning() = 0; |
| 172 | virtual void ClearRecordingError() = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 173 | |
henrika | ba35d05 | 2015-07-14 17:04:08 +0200 | [diff] [blame] | 174 | virtual void AttachAudioBuffer(AudioDeviceBuffer* audioBuffer) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 175 | |
henrika | ba35d05 | 2015-07-14 17:04:08 +0200 | [diff] [blame] | 176 | virtual ~AudioDeviceGeneric() {} |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 177 | }; |
| 178 | |
| 179 | } // namespace webrtc |
| 180 | |
| 181 | #endif // WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_GENERIC_H |