blob: a4c320eaf7542394db6f693eebc1bce664f5dfb6 [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
leozwang@webrtc.org28f39132012-03-01 18:01:48 +00002 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
niklase@google.com470e71d2011-07-07 08:21:25 +00003 *
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.org811269d2013-07-11 13:24:38 +000014#include "webrtc/modules/audio_device/audio_device_buffer.h"
15#include "webrtc/modules/audio_device/include/audio_device.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000016
17namespace webrtc {
18
19class AudioDeviceGeneric
20{
21 public:
22
23 // Retrieve the currently utilized audio layer
pbos@webrtc.org25509882013-04-09 10:30:35 +000024 virtual int32_t ActiveAudioLayer(
niklase@google.com470e71d2011-07-07 08:21:25 +000025 AudioDeviceModule::AudioLayer& audioLayer) const = 0;
26
27 // Main initializaton and termination
pbos@webrtc.org25509882013-04-09 10:30:35 +000028 virtual int32_t Init() = 0;
29 virtual int32_t Terminate() = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000030 virtual bool Initialized() const = 0;
31
32 // Device enumeration
pbos@webrtc.org25509882013-04-09 10:30:35 +000033 virtual int16_t PlayoutDevices() = 0;
34 virtual int16_t RecordingDevices() = 0;
35 virtual int32_t PlayoutDeviceName(
36 uint16_t index,
leozwang@webrtc.org28f39132012-03-01 18:01:48 +000037 char name[kAdmMaxDeviceNameSize],
38 char guid[kAdmMaxGuidSize]) = 0;
pbos@webrtc.org25509882013-04-09 10:30:35 +000039 virtual int32_t RecordingDeviceName(
40 uint16_t index,
leozwang@webrtc.org28f39132012-03-01 18:01:48 +000041 char name[kAdmMaxDeviceNameSize],
42 char guid[kAdmMaxGuidSize]) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000043
44 // Device selection
pbos@webrtc.org25509882013-04-09 10:30:35 +000045 virtual int32_t SetPlayoutDevice(uint16_t index) = 0;
46 virtual int32_t SetPlayoutDevice(
niklase@google.com470e71d2011-07-07 08:21:25 +000047 AudioDeviceModule::WindowsDeviceType device) = 0;
pbos@webrtc.org25509882013-04-09 10:30:35 +000048 virtual int32_t SetRecordingDevice(uint16_t index) = 0;
49 virtual int32_t SetRecordingDevice(
niklase@google.com470e71d2011-07-07 08:21:25 +000050 AudioDeviceModule::WindowsDeviceType device) = 0;
51
52 // Audio transport initialization
pbos@webrtc.org25509882013-04-09 10:30:35 +000053 virtual int32_t PlayoutIsAvailable(bool& available) = 0;
54 virtual int32_t InitPlayout() = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000055 virtual bool PlayoutIsInitialized() const = 0;
pbos@webrtc.org25509882013-04-09 10:30:35 +000056 virtual int32_t RecordingIsAvailable(bool& available) = 0;
57 virtual int32_t InitRecording() = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000058 virtual bool RecordingIsInitialized() const = 0;
59
60 // Audio transport control
pbos@webrtc.org25509882013-04-09 10:30:35 +000061 virtual int32_t StartPlayout() = 0;
62 virtual int32_t StopPlayout() = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000063 virtual bool Playing() const = 0;
pbos@webrtc.org25509882013-04-09 10:30:35 +000064 virtual int32_t StartRecording() = 0;
65 virtual int32_t StopRecording() = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000066 virtual bool Recording() const = 0;
67
68 // Microphone Automatic Gain Control (AGC)
pbos@webrtc.org25509882013-04-09 10:30:35 +000069 virtual int32_t SetAGC(bool enable) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000070 virtual bool AGC() const = 0;
71
72 // Volume control based on the Windows Wave API (Windows only)
pbos@webrtc.org25509882013-04-09 10:30:35 +000073 virtual int32_t SetWaveOutVolume(uint16_t volumeLeft,
74 uint16_t volumeRight) = 0;
75 virtual int32_t WaveOutVolume(uint16_t& volumeLeft,
76 uint16_t& volumeRight) const = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000077
78 // Audio mixer initialization
pbos@webrtc.org25509882013-04-09 10:30:35 +000079 virtual int32_t InitSpeaker() = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000080 virtual bool SpeakerIsInitialized() const = 0;
pbos@webrtc.org25509882013-04-09 10:30:35 +000081 virtual int32_t InitMicrophone() = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000082 virtual bool MicrophoneIsInitialized() const = 0;
83
84 // Speaker volume controls
pbos@webrtc.org25509882013-04-09 10:30:35 +000085 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;
90 virtual int32_t SpeakerVolumeStepSize(
91 uint16_t& stepSize) const = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000092
93 // Microphone volume controls
pbos@webrtc.org25509882013-04-09 10:30:35 +000094 virtual int32_t MicrophoneVolumeIsAvailable(bool& available) = 0;
95 virtual int32_t SetMicrophoneVolume(uint32_t volume) = 0;
96 virtual int32_t MicrophoneVolume(uint32_t& volume) const = 0;
97 virtual int32_t MaxMicrophoneVolume(
98 uint32_t& maxVolume) const = 0;
99 virtual int32_t MinMicrophoneVolume(
100 uint32_t& minVolume) const = 0;
101 virtual int32_t MicrophoneVolumeStepSize(
102 uint16_t& stepSize) const = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000103
104 // Speaker mute control
pbos@webrtc.org25509882013-04-09 10:30:35 +0000105 virtual int32_t SpeakerMuteIsAvailable(bool& available) = 0;
106 virtual int32_t SetSpeakerMute(bool enable) = 0;
107 virtual int32_t SpeakerMute(bool& enabled) const = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000108
109 // Microphone mute control
pbos@webrtc.org25509882013-04-09 10:30:35 +0000110 virtual int32_t MicrophoneMuteIsAvailable(bool& available) = 0;
111 virtual int32_t SetMicrophoneMute(bool enable) = 0;
112 virtual int32_t MicrophoneMute(bool& enabled) const = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000113
114 // Microphone boost control
pbos@webrtc.org25509882013-04-09 10:30:35 +0000115 virtual int32_t MicrophoneBoostIsAvailable(bool& available) = 0;
116 virtual int32_t SetMicrophoneBoost(bool enable) = 0;
117 virtual int32_t MicrophoneBoost(bool& enabled) const = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000118
119 // Stereo support
pbos@webrtc.org25509882013-04-09 10:30:35 +0000120 virtual int32_t StereoPlayoutIsAvailable(bool& available) = 0;
121 virtual int32_t SetStereoPlayout(bool enable) = 0;
122 virtual int32_t StereoPlayout(bool& enabled) const = 0;
123 virtual int32_t StereoRecordingIsAvailable(bool& available) = 0;
124 virtual int32_t SetStereoRecording(bool enable) = 0;
125 virtual int32_t StereoRecording(bool& enabled) const = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000126
127 // Delay information and control
pbos@webrtc.org25509882013-04-09 10:30:35 +0000128 virtual int32_t SetPlayoutBuffer(
niklase@google.com470e71d2011-07-07 08:21:25 +0000129 const AudioDeviceModule::BufferType type,
pbos@webrtc.org25509882013-04-09 10:30:35 +0000130 uint16_t sizeMS = 0) = 0;
131 virtual int32_t PlayoutBuffer(
132 AudioDeviceModule::BufferType& type, uint16_t& sizeMS) const = 0;
133 virtual int32_t PlayoutDelay(uint16_t& delayMS) const = 0;
134 virtual int32_t RecordingDelay(uint16_t& delayMS) const = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000135
136 // CPU load
pbos@webrtc.org25509882013-04-09 10:30:35 +0000137 virtual int32_t CPULoad(uint16_t& load) const = 0;
andrew@webrtc.orgc7c432a2014-04-02 16:49:26 +0000138
niklase@google.com470e71d2011-07-07 08:21:25 +0000139 // Native sample rate controls (samples/sec)
pbos@webrtc.org25509882013-04-09 10:30:35 +0000140 virtual int32_t SetRecordingSampleRate(
141 const uint32_t samplesPerSec);
142 virtual int32_t SetPlayoutSampleRate(
143 const uint32_t samplesPerSec);
niklase@google.com470e71d2011-07-07 08:21:25 +0000144
145 // Speaker audio routing (for mobile devices)
pbos@webrtc.org25509882013-04-09 10:30:35 +0000146 virtual int32_t SetLoudspeakerStatus(bool enable);
147 virtual int32_t GetLoudspeakerStatus(bool& enable) const;
andrew@webrtc.orgc7c432a2014-04-02 16:49:26 +0000148
niklase@google.com470e71d2011-07-07 08:21:25 +0000149 // Reset Audio Device (for mobile devices)
pbos@webrtc.org25509882013-04-09 10:30:35 +0000150 virtual int32_t ResetAudioDevice();
niklase@google.com470e71d2011-07-07 08:21:25 +0000151
152 // Sound Audio Device control (for WinCE only)
pbos@webrtc.org25509882013-04-09 10:30:35 +0000153 virtual int32_t SoundDeviceControl(unsigned int par1 = 0,
154 unsigned int par2 = 0,
155 unsigned int par3 = 0,
156 unsigned int par4 = 0);
niklase@google.com470e71d2011-07-07 08:21:25 +0000157
andrew@webrtc.orga3c6d612011-09-13 17:17:49 +0000158 // Windows Core Audio only.
159 virtual int32_t EnableBuiltInAEC(bool enable);
160 virtual bool BuiltInAECIsEnabled() const;
161
niklase@google.com470e71d2011-07-07 08:21:25 +0000162public:
163 virtual bool PlayoutWarning() const = 0;
164 virtual bool PlayoutError() const = 0;
165 virtual bool RecordingWarning() const = 0;
166 virtual bool RecordingError() const = 0;
167 virtual void ClearPlayoutWarning() = 0;
168 virtual void ClearPlayoutError() = 0;
169 virtual void ClearRecordingWarning() = 0;
170 virtual void ClearRecordingError() = 0;
171
172public:
173 virtual void AttachAudioBuffer(AudioDeviceBuffer* audioBuffer) = 0;
174
175 virtual ~AudioDeviceGeneric() {}
176};
177
178} // namespace webrtc
179
180#endif // WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_GENERIC_H