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 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #ifndef AUDIO_DEVICE_AUDIO_DEVICE_GENERIC_H_ |
| 12 | #define AUDIO_DEVICE_AUDIO_DEVICE_GENERIC_H_ |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 13 | |
Yves Gerey | 988cc08 | 2018-10-23 12:03:01 +0200 | [diff] [blame] | 14 | #include <stdint.h> |
| 15 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 16 | #include "modules/audio_device/audio_device_buffer.h" |
| 17 | #include "modules/audio_device/include/audio_device.h" |
Yves Gerey | 988cc08 | 2018-10-23 12:03:01 +0200 | [diff] [blame] | 18 | #include "modules/audio_device/include/audio_device_defines.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 19 | |
| 20 | namespace webrtc { |
| 21 | |
henrika | ba35d05 | 2015-07-14 17:04:08 +0200 | [diff] [blame] | 22 | class AudioDeviceGeneric { |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 23 | public: |
Max Morin | 84cab20 | 2016-07-01 13:35:19 +0200 | [diff] [blame] | 24 | // For use with UMA logging. Must be kept in sync with histograms.xml in |
| 25 | // Chrome, located at |
| 26 | // https://cs.chromium.org/chromium/src/tools/metrics/histograms/histograms.xml |
| 27 | enum class InitStatus { |
| 28 | OK = 0, |
| 29 | PLAYOUT_ERROR = 1, |
| 30 | RECORDING_ERROR = 2, |
| 31 | OTHER_ERROR = 3, |
| 32 | NUM_STATUSES = 4 |
| 33 | }; |
henrika | ba35d05 | 2015-07-14 17:04:08 +0200 | [diff] [blame] | 34 | // Retrieve the currently utilized audio layer |
| 35 | virtual int32_t ActiveAudioLayer( |
| 36 | AudioDeviceModule::AudioLayer& audioLayer) const = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 37 | |
henrika | ba35d05 | 2015-07-14 17:04:08 +0200 | [diff] [blame] | 38 | // Main initializaton and termination |
Max Morin | 84cab20 | 2016-07-01 13:35:19 +0200 | [diff] [blame] | 39 | virtual InitStatus Init() = 0; |
henrika | ba35d05 | 2015-07-14 17:04:08 +0200 | [diff] [blame] | 40 | virtual int32_t Terminate() = 0; |
| 41 | virtual bool Initialized() const = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 42 | |
henrika | ba35d05 | 2015-07-14 17:04:08 +0200 | [diff] [blame] | 43 | // Device enumeration |
| 44 | virtual int16_t PlayoutDevices() = 0; |
| 45 | virtual int16_t RecordingDevices() = 0; |
| 46 | virtual int32_t PlayoutDeviceName(uint16_t index, |
| 47 | char name[kAdmMaxDeviceNameSize], |
| 48 | char guid[kAdmMaxGuidSize]) = 0; |
| 49 | virtual int32_t RecordingDeviceName(uint16_t index, |
| 50 | char name[kAdmMaxDeviceNameSize], |
| 51 | char guid[kAdmMaxGuidSize]) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 52 | |
henrika | ba35d05 | 2015-07-14 17:04:08 +0200 | [diff] [blame] | 53 | // Device selection |
| 54 | virtual int32_t SetPlayoutDevice(uint16_t index) = 0; |
| 55 | virtual int32_t SetPlayoutDevice( |
| 56 | AudioDeviceModule::WindowsDeviceType device) = 0; |
| 57 | virtual int32_t SetRecordingDevice(uint16_t index) = 0; |
| 58 | virtual int32_t SetRecordingDevice( |
| 59 | AudioDeviceModule::WindowsDeviceType device) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 60 | |
henrika | ba35d05 | 2015-07-14 17:04:08 +0200 | [diff] [blame] | 61 | // Audio transport initialization |
| 62 | virtual int32_t PlayoutIsAvailable(bool& available) = 0; |
| 63 | virtual int32_t InitPlayout() = 0; |
| 64 | virtual bool PlayoutIsInitialized() const = 0; |
| 65 | virtual int32_t RecordingIsAvailable(bool& available) = 0; |
| 66 | virtual int32_t InitRecording() = 0; |
| 67 | virtual bool RecordingIsInitialized() const = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 68 | |
henrika | ba35d05 | 2015-07-14 17:04:08 +0200 | [diff] [blame] | 69 | // Audio transport control |
| 70 | virtual int32_t StartPlayout() = 0; |
| 71 | virtual int32_t StopPlayout() = 0; |
| 72 | virtual bool Playing() const = 0; |
| 73 | virtual int32_t StartRecording() = 0; |
| 74 | virtual int32_t StopRecording() = 0; |
| 75 | virtual bool Recording() const = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 76 | |
henrika | ba35d05 | 2015-07-14 17:04:08 +0200 | [diff] [blame] | 77 | // Audio mixer initialization |
| 78 | virtual int32_t InitSpeaker() = 0; |
| 79 | virtual bool SpeakerIsInitialized() const = 0; |
| 80 | virtual int32_t InitMicrophone() = 0; |
| 81 | virtual bool MicrophoneIsInitialized() const = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 82 | |
henrika | ba35d05 | 2015-07-14 17:04:08 +0200 | [diff] [blame] | 83 | // Speaker volume controls |
| 84 | virtual int32_t SpeakerVolumeIsAvailable(bool& available) = 0; |
| 85 | virtual int32_t SetSpeakerVolume(uint32_t volume) = 0; |
| 86 | virtual int32_t SpeakerVolume(uint32_t& volume) const = 0; |
| 87 | virtual int32_t MaxSpeakerVolume(uint32_t& maxVolume) const = 0; |
| 88 | virtual int32_t MinSpeakerVolume(uint32_t& minVolume) const = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 89 | |
henrika | ba35d05 | 2015-07-14 17:04:08 +0200 | [diff] [blame] | 90 | // Microphone volume controls |
| 91 | virtual int32_t MicrophoneVolumeIsAvailable(bool& available) = 0; |
| 92 | virtual int32_t SetMicrophoneVolume(uint32_t volume) = 0; |
| 93 | virtual int32_t MicrophoneVolume(uint32_t& volume) const = 0; |
| 94 | virtual int32_t MaxMicrophoneVolume(uint32_t& maxVolume) const = 0; |
| 95 | virtual int32_t MinMicrophoneVolume(uint32_t& minVolume) const = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 96 | |
henrika | ba35d05 | 2015-07-14 17:04:08 +0200 | [diff] [blame] | 97 | // Speaker mute control |
| 98 | virtual int32_t SpeakerMuteIsAvailable(bool& available) = 0; |
| 99 | virtual int32_t SetSpeakerMute(bool enable) = 0; |
| 100 | virtual int32_t SpeakerMute(bool& enabled) const = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 101 | |
henrika | ba35d05 | 2015-07-14 17:04:08 +0200 | [diff] [blame] | 102 | // Microphone mute control |
| 103 | virtual int32_t MicrophoneMuteIsAvailable(bool& available) = 0; |
| 104 | virtual int32_t SetMicrophoneMute(bool enable) = 0; |
| 105 | virtual int32_t MicrophoneMute(bool& enabled) const = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 106 | |
henrika | ba35d05 | 2015-07-14 17:04:08 +0200 | [diff] [blame] | 107 | // Stereo support |
| 108 | virtual int32_t StereoPlayoutIsAvailable(bool& available) = 0; |
| 109 | virtual int32_t SetStereoPlayout(bool enable) = 0; |
| 110 | virtual int32_t StereoPlayout(bool& enabled) const = 0; |
| 111 | virtual int32_t StereoRecordingIsAvailable(bool& available) = 0; |
| 112 | virtual int32_t SetStereoRecording(bool enable) = 0; |
| 113 | virtual int32_t StereoRecording(bool& enabled) const = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 114 | |
henrika | ba35d05 | 2015-07-14 17:04:08 +0200 | [diff] [blame] | 115 | // Delay information and control |
henrika | ba35d05 | 2015-07-14 17:04:08 +0200 | [diff] [blame] | 116 | virtual int32_t PlayoutDelay(uint16_t& delayMS) const = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 117 | |
henrika | ba35d05 | 2015-07-14 17:04:08 +0200 | [diff] [blame] | 118 | // Android only |
| 119 | virtual bool BuiltInAECIsAvailable() const; |
henrika | c14f5ff | 2015-09-23 14:08:33 +0200 | [diff] [blame] | 120 | virtual bool BuiltInAGCIsAvailable() const; |
| 121 | virtual bool BuiltInNSIsAvailable() const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 122 | |
henrika | ba35d05 | 2015-07-14 17:04:08 +0200 | [diff] [blame] | 123 | // Windows Core Audio and Android only. |
| 124 | virtual int32_t EnableBuiltInAEC(bool enable); |
henrika | c14f5ff | 2015-09-23 14:08:33 +0200 | [diff] [blame] | 125 | virtual int32_t EnableBuiltInAGC(bool enable); |
| 126 | virtual int32_t EnableBuiltInNS(bool enable); |
henrika@webrtc.org | a954c07 | 2014-12-09 16:22:09 +0000 | [diff] [blame] | 127 | |
Alex Narest | bbeb109 | 2019-08-16 11:49:04 +0200 | [diff] [blame] | 128 | // Play underrun count. |
| 129 | virtual int32_t GetPlayoutUnderrunCount() const; |
| 130 | |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 131 | // iOS only. |
| 132 | // TODO(henrika): add Android support. |
maxmorin | 88e31a3 | 2016-08-16 00:56:09 -0700 | [diff] [blame] | 133 | #if defined(WEBRTC_IOS) |
henrika | ba35d05 | 2015-07-14 17:04:08 +0200 | [diff] [blame] | 134 | virtual int GetPlayoutAudioParameters(AudioParameters* params) const; |
| 135 | virtual int GetRecordAudioParameters(AudioParameters* params) const; |
maxmorin | 88e31a3 | 2016-08-16 00:56:09 -0700 | [diff] [blame] | 136 | #endif // WEBRTC_IOS |
andrew@webrtc.org | a3c6d61 | 2011-09-13 17:17:49 +0000 | [diff] [blame] | 137 | |
henrika | ba35d05 | 2015-07-14 17:04:08 +0200 | [diff] [blame] | 138 | virtual void AttachAudioBuffer(AudioDeviceBuffer* audioBuffer) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 139 | |
henrika | ba35d05 | 2015-07-14 17:04:08 +0200 | [diff] [blame] | 140 | virtual ~AudioDeviceGeneric() {} |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 141 | }; |
| 142 | |
| 143 | } // namespace webrtc |
| 144 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 145 | #endif // AUDIO_DEVICE_AUDIO_DEVICE_GENERIC_H_ |