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