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: |
Max Morin | 84cab20 | 2016-07-01 13:35:19 +0200 | [diff] [blame] | 21 | // For use with UMA logging. Must be kept in sync with histograms.xml in |
| 22 | // Chrome, located at |
| 23 | // https://cs.chromium.org/chromium/src/tools/metrics/histograms/histograms.xml |
| 24 | enum class InitStatus { |
| 25 | OK = 0, |
| 26 | PLAYOUT_ERROR = 1, |
| 27 | RECORDING_ERROR = 2, |
| 28 | OTHER_ERROR = 3, |
| 29 | NUM_STATUSES = 4 |
| 30 | }; |
henrika | ba35d05 | 2015-07-14 17:04:08 +0200 | [diff] [blame] | 31 | // Retrieve the currently utilized audio layer |
| 32 | virtual int32_t ActiveAudioLayer( |
| 33 | AudioDeviceModule::AudioLayer& audioLayer) const = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 34 | |
henrika | ba35d05 | 2015-07-14 17:04:08 +0200 | [diff] [blame] | 35 | // Main initializaton and termination |
Max Morin | 84cab20 | 2016-07-01 13:35:19 +0200 | [diff] [blame] | 36 | virtual InitStatus Init() = 0; |
henrika | ba35d05 | 2015-07-14 17:04:08 +0200 | [diff] [blame] | 37 | virtual int32_t Terminate() = 0; |
| 38 | virtual bool Initialized() const = 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 enumeration |
| 41 | virtual int16_t PlayoutDevices() = 0; |
| 42 | virtual int16_t RecordingDevices() = 0; |
| 43 | virtual int32_t PlayoutDeviceName(uint16_t index, |
| 44 | char name[kAdmMaxDeviceNameSize], |
| 45 | char guid[kAdmMaxGuidSize]) = 0; |
| 46 | virtual int32_t RecordingDeviceName(uint16_t index, |
| 47 | char name[kAdmMaxDeviceNameSize], |
| 48 | char guid[kAdmMaxGuidSize]) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 49 | |
henrika | ba35d05 | 2015-07-14 17:04:08 +0200 | [diff] [blame] | 50 | // Device selection |
| 51 | virtual int32_t SetPlayoutDevice(uint16_t index) = 0; |
| 52 | virtual int32_t SetPlayoutDevice( |
| 53 | AudioDeviceModule::WindowsDeviceType device) = 0; |
| 54 | virtual int32_t SetRecordingDevice(uint16_t index) = 0; |
| 55 | virtual int32_t SetRecordingDevice( |
| 56 | AudioDeviceModule::WindowsDeviceType device) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 57 | |
henrika | ba35d05 | 2015-07-14 17:04:08 +0200 | [diff] [blame] | 58 | // Audio transport initialization |
| 59 | virtual int32_t PlayoutIsAvailable(bool& available) = 0; |
| 60 | virtual int32_t InitPlayout() = 0; |
| 61 | virtual bool PlayoutIsInitialized() const = 0; |
| 62 | virtual int32_t RecordingIsAvailable(bool& available) = 0; |
| 63 | virtual int32_t InitRecording() = 0; |
| 64 | virtual bool RecordingIsInitialized() const = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 65 | |
henrika | ba35d05 | 2015-07-14 17:04:08 +0200 | [diff] [blame] | 66 | // Audio transport control |
| 67 | virtual int32_t StartPlayout() = 0; |
| 68 | virtual int32_t StopPlayout() = 0; |
| 69 | virtual bool Playing() const = 0; |
| 70 | virtual int32_t StartRecording() = 0; |
| 71 | virtual int32_t StopRecording() = 0; |
| 72 | virtual bool Recording() 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 | // Microphone Automatic Gain Control (AGC) |
| 75 | virtual int32_t SetAGC(bool enable) = 0; |
| 76 | virtual bool AGC() const = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 77 | |
henrika | ba35d05 | 2015-07-14 17:04:08 +0200 | [diff] [blame] | 78 | // Audio mixer initialization |
| 79 | virtual int32_t InitSpeaker() = 0; |
| 80 | virtual bool SpeakerIsInitialized() const = 0; |
| 81 | virtual int32_t InitMicrophone() = 0; |
| 82 | virtual bool MicrophoneIsInitialized() const = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 83 | |
henrika | ba35d05 | 2015-07-14 17:04:08 +0200 | [diff] [blame] | 84 | // Speaker volume controls |
| 85 | virtual int32_t SpeakerVolumeIsAvailable(bool& available) = 0; |
| 86 | virtual int32_t SetSpeakerVolume(uint32_t volume) = 0; |
| 87 | virtual int32_t SpeakerVolume(uint32_t& volume) const = 0; |
| 88 | virtual int32_t MaxSpeakerVolume(uint32_t& maxVolume) const = 0; |
| 89 | virtual int32_t MinSpeakerVolume(uint32_t& minVolume) const = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 90 | |
henrika | ba35d05 | 2015-07-14 17:04:08 +0200 | [diff] [blame] | 91 | // Microphone volume controls |
| 92 | virtual int32_t MicrophoneVolumeIsAvailable(bool& available) = 0; |
| 93 | virtual int32_t SetMicrophoneVolume(uint32_t volume) = 0; |
| 94 | virtual int32_t MicrophoneVolume(uint32_t& volume) const = 0; |
| 95 | virtual int32_t MaxMicrophoneVolume(uint32_t& maxVolume) const = 0; |
| 96 | virtual int32_t MinMicrophoneVolume(uint32_t& minVolume) const = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 97 | |
henrika | ba35d05 | 2015-07-14 17:04:08 +0200 | [diff] [blame] | 98 | // Speaker mute control |
| 99 | virtual int32_t SpeakerMuteIsAvailable(bool& available) = 0; |
| 100 | virtual int32_t SetSpeakerMute(bool enable) = 0; |
| 101 | virtual int32_t SpeakerMute(bool& enabled) const = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 102 | |
henrika | ba35d05 | 2015-07-14 17:04:08 +0200 | [diff] [blame] | 103 | // Microphone mute control |
| 104 | virtual int32_t MicrophoneMuteIsAvailable(bool& available) = 0; |
| 105 | virtual int32_t SetMicrophoneMute(bool enable) = 0; |
| 106 | virtual int32_t MicrophoneMute(bool& enabled) const = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 107 | |
henrika | ba35d05 | 2015-07-14 17:04:08 +0200 | [diff] [blame] | 108 | // Stereo support |
| 109 | virtual int32_t StereoPlayoutIsAvailable(bool& available) = 0; |
| 110 | virtual int32_t SetStereoPlayout(bool enable) = 0; |
| 111 | virtual int32_t StereoPlayout(bool& enabled) const = 0; |
| 112 | virtual int32_t StereoRecordingIsAvailable(bool& available) = 0; |
| 113 | virtual int32_t SetStereoRecording(bool enable) = 0; |
| 114 | virtual int32_t StereoRecording(bool& enabled) const = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 115 | |
henrika | ba35d05 | 2015-07-14 17:04:08 +0200 | [diff] [blame] | 116 | // Delay information and control |
henrika | ba35d05 | 2015-07-14 17:04:08 +0200 | [diff] [blame] | 117 | virtual int32_t PlayoutDelay(uint16_t& delayMS) const = 0; |
| 118 | virtual int32_t RecordingDelay(uint16_t& delayMS) const = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 119 | |
henrika | ba35d05 | 2015-07-14 17:04:08 +0200 | [diff] [blame] | 120 | // Native sample rate controls (samples/sec) |
| 121 | virtual int32_t SetRecordingSampleRate(const uint32_t samplesPerSec); |
| 122 | virtual int32_t SetPlayoutSampleRate(const uint32_t samplesPerSec); |
andrew@webrtc.org | c7c432a | 2014-04-02 16:49:26 +0000 | [diff] [blame] | 123 | |
henrika | ba35d05 | 2015-07-14 17:04:08 +0200 | [diff] [blame] | 124 | // Speaker audio routing (for mobile devices) |
| 125 | virtual int32_t SetLoudspeakerStatus(bool enable); |
| 126 | virtual int32_t GetLoudspeakerStatus(bool& enable) const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 127 | |
henrika | ba35d05 | 2015-07-14 17:04:08 +0200 | [diff] [blame] | 128 | // Android only |
| 129 | virtual bool BuiltInAECIsAvailable() const; |
henrika | c14f5ff | 2015-09-23 14:08:33 +0200 | [diff] [blame] | 130 | virtual bool BuiltInAGCIsAvailable() const; |
| 131 | virtual bool BuiltInNSIsAvailable() const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 132 | |
henrika | ba35d05 | 2015-07-14 17:04:08 +0200 | [diff] [blame] | 133 | // Windows Core Audio and Android only. |
| 134 | virtual int32_t EnableBuiltInAEC(bool enable); |
henrika | c14f5ff | 2015-09-23 14:08:33 +0200 | [diff] [blame] | 135 | virtual int32_t EnableBuiltInAGC(bool enable); |
| 136 | virtual int32_t EnableBuiltInNS(bool enable); |
henrika@webrtc.org | a954c07 | 2014-12-09 16:22:09 +0000 | [diff] [blame] | 137 | |
henrika | ba35d05 | 2015-07-14 17:04:08 +0200 | [diff] [blame] | 138 | // iOS only. |
| 139 | // TODO(henrika): add Android support. |
maxmorin | 88e31a3 | 2016-08-16 00:56:09 -0700 | [diff] [blame] | 140 | #if defined(WEBRTC_IOS) |
henrika | ba35d05 | 2015-07-14 17:04:08 +0200 | [diff] [blame] | 141 | virtual int GetPlayoutAudioParameters(AudioParameters* params) const; |
| 142 | virtual int GetRecordAudioParameters(AudioParameters* params) const; |
maxmorin | 88e31a3 | 2016-08-16 00:56:09 -0700 | [diff] [blame] | 143 | #endif // WEBRTC_IOS |
andrew@webrtc.org | a3c6d61 | 2011-09-13 17:17:49 +0000 | [diff] [blame] | 144 | |
henrika | ba35d05 | 2015-07-14 17:04:08 +0200 | [diff] [blame] | 145 | virtual bool PlayoutWarning() const = 0; |
| 146 | virtual bool PlayoutError() const = 0; |
| 147 | virtual bool RecordingWarning() const = 0; |
| 148 | virtual bool RecordingError() const = 0; |
| 149 | virtual void ClearPlayoutWarning() = 0; |
| 150 | virtual void ClearPlayoutError() = 0; |
| 151 | virtual void ClearRecordingWarning() = 0; |
| 152 | virtual void ClearRecordingError() = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 153 | |
henrika | ba35d05 | 2015-07-14 17:04:08 +0200 | [diff] [blame] | 154 | virtual void AttachAudioBuffer(AudioDeviceBuffer* audioBuffer) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 155 | |
henrika | ba35d05 | 2015-07-14 17:04:08 +0200 | [diff] [blame] | 156 | virtual ~AudioDeviceGeneric() {} |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 157 | }; |
| 158 | |
| 159 | } // namespace webrtc |
| 160 | |
| 161 | #endif // WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_GENERIC_H |