2011-07-07 08:21:25 +00:00
|
|
|
/*
|
2012-03-01 18:01:48 +00:00
|
|
|
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
2011-07-07 08:21:25 +00:00
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
2017-10-11 13:16:17 +02:00
|
|
|
#ifndef MODULES_AUDIO_DEVICE_AUDIO_DEVICE_IMPL_H_
|
|
|
|
|
#define MODULES_AUDIO_DEVICE_AUDIO_DEVICE_IMPL_H_
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2015-05-20 09:44:38 +02:00
|
|
|
#if defined(WEBRTC_INCLUDE_INTERNAL_AUDIO_DEVICE)
|
|
|
|
|
|
2018-10-23 12:03:01 +02:00
|
|
|
#include <stdint.h>
|
2019-07-05 19:08:33 +02:00
|
|
|
|
2016-02-24 05:00:36 -08:00
|
|
|
#include <memory>
|
|
|
|
|
|
2019-04-01 09:16:12 +02:00
|
|
|
#include "api/task_queue/task_queue_factory.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "modules/audio_device/audio_device_buffer.h"
|
|
|
|
|
#include "modules/audio_device/include/audio_device.h"
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2015-07-14 17:04:08 +02:00
|
|
|
namespace webrtc {
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
class AudioDeviceGeneric;
|
|
|
|
|
|
2018-09-05 14:34:40 +02:00
|
|
|
class AudioDeviceModuleImpl : public AudioDeviceModuleForTest {
|
2015-07-14 17:04:08 +02:00
|
|
|
public:
|
|
|
|
|
enum PlatformType {
|
|
|
|
|
kPlatformNotSupported = 0,
|
|
|
|
|
kPlatformWin32 = 1,
|
|
|
|
|
kPlatformWinCe = 2,
|
|
|
|
|
kPlatformLinux = 3,
|
|
|
|
|
kPlatformMac = 4,
|
|
|
|
|
kPlatformAndroid = 5,
|
2023-06-30 15:26:09 +02:00
|
|
|
kPlatformIOS = 6,
|
|
|
|
|
// Fuchsia isn't fully supported, as there is no implementation for
|
|
|
|
|
// AudioDeviceGeneric which will be created for Fuchsia, so
|
|
|
|
|
// `CreatePlatformSpecificObjects()` call will fail unless usable
|
|
|
|
|
// implementation will be provided by the user.
|
|
|
|
|
kPlatformFuchsia = 7,
|
2015-07-14 17:04:08 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
int32_t CheckPlatform();
|
|
|
|
|
int32_t CreatePlatformSpecificObjects();
|
|
|
|
|
int32_t AttachAudioBuffer();
|
|
|
|
|
|
2019-04-01 09:16:12 +02:00
|
|
|
AudioDeviceModuleImpl(AudioLayer audio_layer,
|
|
|
|
|
TaskQueueFactory* task_queue_factory);
|
2023-06-30 15:26:09 +02:00
|
|
|
// If `create_detached` is true, created ADM can be used on another thread
|
|
|
|
|
// compared to the one on which it was created. It's useful for testing.
|
|
|
|
|
AudioDeviceModuleImpl(AudioLayer audio_layer,
|
|
|
|
|
std::unique_ptr<AudioDeviceGeneric> audio_device,
|
|
|
|
|
TaskQueueFactory* task_queue_factory,
|
|
|
|
|
bool create_detached);
|
2016-08-16 00:56:09 -07:00
|
|
|
~AudioDeviceModuleImpl() override;
|
2015-07-14 17:04:08 +02:00
|
|
|
|
|
|
|
|
// Retrieve the currently utilized audio layer
|
|
|
|
|
int32_t ActiveAudioLayer(AudioLayer* audioLayer) const override;
|
|
|
|
|
|
|
|
|
|
// Full-duplex transportation of PCM audio
|
|
|
|
|
int32_t RegisterAudioCallback(AudioTransport* audioCallback) override;
|
|
|
|
|
|
|
|
|
|
// Main initializaton and termination
|
|
|
|
|
int32_t Init() override;
|
|
|
|
|
int32_t Terminate() override;
|
|
|
|
|
bool Initialized() const override;
|
|
|
|
|
|
|
|
|
|
// Device enumeration
|
|
|
|
|
int16_t PlayoutDevices() override;
|
|
|
|
|
int16_t RecordingDevices() override;
|
|
|
|
|
int32_t PlayoutDeviceName(uint16_t index,
|
|
|
|
|
char name[kAdmMaxDeviceNameSize],
|
|
|
|
|
char guid[kAdmMaxGuidSize]) override;
|
|
|
|
|
int32_t RecordingDeviceName(uint16_t index,
|
2015-03-04 12:58:35 +00:00
|
|
|
char name[kAdmMaxDeviceNameSize],
|
|
|
|
|
char guid[kAdmMaxGuidSize]) override;
|
2015-07-14 17:04:08 +02:00
|
|
|
|
|
|
|
|
// Device selection
|
|
|
|
|
int32_t SetPlayoutDevice(uint16_t index) override;
|
|
|
|
|
int32_t SetPlayoutDevice(WindowsDeviceType device) override;
|
|
|
|
|
int32_t SetRecordingDevice(uint16_t index) override;
|
|
|
|
|
int32_t SetRecordingDevice(WindowsDeviceType device) override;
|
|
|
|
|
|
|
|
|
|
// Audio transport initialization
|
|
|
|
|
int32_t PlayoutIsAvailable(bool* available) override;
|
|
|
|
|
int32_t InitPlayout() override;
|
|
|
|
|
bool PlayoutIsInitialized() const override;
|
|
|
|
|
int32_t RecordingIsAvailable(bool* available) override;
|
|
|
|
|
int32_t InitRecording() override;
|
|
|
|
|
bool RecordingIsInitialized() const override;
|
|
|
|
|
|
|
|
|
|
// Audio transport control
|
|
|
|
|
int32_t StartPlayout() override;
|
|
|
|
|
int32_t StopPlayout() override;
|
|
|
|
|
bool Playing() const override;
|
|
|
|
|
int32_t StartRecording() override;
|
|
|
|
|
int32_t StopRecording() override;
|
|
|
|
|
bool Recording() const override;
|
|
|
|
|
|
|
|
|
|
// Audio mixer initialization
|
|
|
|
|
int32_t InitSpeaker() override;
|
|
|
|
|
bool SpeakerIsInitialized() const override;
|
|
|
|
|
int32_t InitMicrophone() override;
|
|
|
|
|
bool MicrophoneIsInitialized() const override;
|
|
|
|
|
|
|
|
|
|
// Speaker volume controls
|
|
|
|
|
int32_t SpeakerVolumeIsAvailable(bool* available) override;
|
|
|
|
|
int32_t SetSpeakerVolume(uint32_t volume) override;
|
|
|
|
|
int32_t SpeakerVolume(uint32_t* volume) const override;
|
|
|
|
|
int32_t MaxSpeakerVolume(uint32_t* maxVolume) const override;
|
|
|
|
|
int32_t MinSpeakerVolume(uint32_t* minVolume) const override;
|
|
|
|
|
|
|
|
|
|
// Microphone volume controls
|
|
|
|
|
int32_t MicrophoneVolumeIsAvailable(bool* available) override;
|
|
|
|
|
int32_t SetMicrophoneVolume(uint32_t volume) override;
|
|
|
|
|
int32_t MicrophoneVolume(uint32_t* volume) const override;
|
|
|
|
|
int32_t MaxMicrophoneVolume(uint32_t* maxVolume) const override;
|
|
|
|
|
int32_t MinMicrophoneVolume(uint32_t* minVolume) const override;
|
|
|
|
|
|
|
|
|
|
// Speaker mute control
|
|
|
|
|
int32_t SpeakerMuteIsAvailable(bool* available) override;
|
|
|
|
|
int32_t SetSpeakerMute(bool enable) override;
|
|
|
|
|
int32_t SpeakerMute(bool* enabled) const override;
|
|
|
|
|
|
|
|
|
|
// Microphone mute control
|
|
|
|
|
int32_t MicrophoneMuteIsAvailable(bool* available) override;
|
|
|
|
|
int32_t SetMicrophoneMute(bool enable) override;
|
|
|
|
|
int32_t MicrophoneMute(bool* enabled) const override;
|
|
|
|
|
|
|
|
|
|
// Stereo support
|
|
|
|
|
int32_t StereoPlayoutIsAvailable(bool* available) const override;
|
|
|
|
|
int32_t SetStereoPlayout(bool enable) override;
|
|
|
|
|
int32_t StereoPlayout(bool* enabled) const override;
|
|
|
|
|
int32_t StereoRecordingIsAvailable(bool* available) const override;
|
|
|
|
|
int32_t SetStereoRecording(bool enable) override;
|
|
|
|
|
int32_t StereoRecording(bool* enabled) const override;
|
|
|
|
|
|
|
|
|
|
// Delay information and control
|
|
|
|
|
int32_t PlayoutDelay(uint16_t* delayMS) const override;
|
|
|
|
|
|
|
|
|
|
bool BuiltInAECIsAvailable() const override;
|
|
|
|
|
int32_t EnableBuiltInAEC(bool enable) override;
|
2015-09-23 14:08:33 +02:00
|
|
|
bool BuiltInAGCIsAvailable() const override;
|
|
|
|
|
int32_t EnableBuiltInAGC(bool enable) override;
|
|
|
|
|
bool BuiltInNSIsAvailable() const override;
|
|
|
|
|
int32_t EnableBuiltInNS(bool enable) override;
|
2015-07-14 17:04:08 +02:00
|
|
|
|
2019-08-16 11:49:04 +02:00
|
|
|
// Play underrun count.
|
|
|
|
|
int32_t GetPlayoutUnderrunCount() const override;
|
|
|
|
|
|
2016-08-16 00:56:09 -07:00
|
|
|
#if defined(WEBRTC_IOS)
|
2015-07-14 17:04:08 +02:00
|
|
|
int GetPlayoutAudioParameters(AudioParameters* params) const override;
|
|
|
|
|
int GetRecordAudioParameters(AudioParameters* params) const override;
|
2016-08-16 00:56:09 -07:00
|
|
|
#endif // WEBRTC_IOS
|
2015-07-14 17:04:08 +02:00
|
|
|
|
2017-10-11 13:16:17 +02:00
|
|
|
AudioDeviceBuffer* GetAudioDeviceBuffer() { return &audio_device_buffer_; }
|
2015-03-09 12:39:53 +00:00
|
|
|
|
2018-09-05 14:34:40 +02:00
|
|
|
int RestartPlayoutInternally() override { return -1; }
|
|
|
|
|
int RestartRecordingInternally() override { return -1; }
|
|
|
|
|
int SetPlayoutSampleRate(uint32_t sample_rate) override { return -1; }
|
|
|
|
|
int SetRecordingSampleRate(uint32_t sample_rate) override { return -1; }
|
|
|
|
|
|
2015-07-14 17:04:08 +02:00
|
|
|
private:
|
|
|
|
|
PlatformType Platform() const;
|
|
|
|
|
AudioLayer PlatformAudioLayer() const;
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2017-10-11 13:16:17 +02:00
|
|
|
AudioLayer audio_layer_;
|
|
|
|
|
PlatformType platform_type_ = kPlatformNotSupported;
|
|
|
|
|
bool initialized_ = false;
|
|
|
|
|
AudioDeviceBuffer audio_device_buffer_;
|
|
|
|
|
std::unique_ptr<AudioDeviceGeneric> audio_device_;
|
2011-07-07 08:21:25 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace webrtc
|
|
|
|
|
|
2015-05-20 09:44:38 +02:00
|
|
|
#endif // defined(WEBRTC_INCLUDE_INTERNAL_AUDIO_DEVICE)
|
|
|
|
|
|
2017-10-11 13:16:17 +02:00
|
|
|
#endif // MODULES_AUDIO_DEVICE_AUDIO_DEVICE_IMPL_H_
|