1#ifndef SKYWAY_MEDIA_AUDIO_CUSTOM_AUDIO_DEVICE_MODULE_HPP_
2#define SKYWAY_MEDIA_AUDIO_CUSTOM_AUDIO_DEVICE_MODULE_HPP_
8#include "modules/audio_device/include/audio_device.h"
9#include "rtc_base/ref_counted_object.h"
16class CustomAudioDeviceModule :
public webrtc::AudioDeviceModule {
18 static rtc::scoped_refptr<CustomAudioDeviceModule> Create(
19 rtc::scoped_refptr<webrtc::AudioDeviceModule> pulse_audio_adm);
21 CustomAudioDeviceModule(rtc::scoped_refptr<webrtc::AudioDeviceModule> pulse_audio_adm);
23 ~CustomAudioDeviceModule()
override;
26 int32_t ActiveAudioLayer(AudioLayer* audioLayer)
const override;
27 int32_t RegisterAudioCallback(webrtc::AudioTransport* audioCallback)
override;
28 int32_t Init()
override;
29 int32_t Terminate()
override;
30 bool Initialized()
const override;
31 int16_t PlayoutDevices()
override;
32 int16_t RecordingDevices()
override;
33 int32_t PlayoutDeviceName(uint16_t index,
34 char name[webrtc::kAdmMaxDeviceNameSize],
35 char guid[webrtc::kAdmMaxGuidSize])
override;
36 int32_t RecordingDeviceName(uint16_t index,
37 char name[webrtc::kAdmMaxDeviceNameSize],
38 char guid[webrtc::kAdmMaxGuidSize])
override;
39 int32_t SetPlayoutDevice(uint16_t index)
override;
40 int32_t SetPlayoutDevice(WindowsDeviceType)
override {
return -1; }
41 int32_t SetRecordingDevice(uint16_t index)
override;
42 int32_t SetRecordingDevice(WindowsDeviceType)
override {
return -1; }
43 int32_t PlayoutIsAvailable(
bool* available)
override;
44 int32_t InitPlayout()
override;
45 bool PlayoutIsInitialized()
const override;
46 int32_t RecordingIsAvailable(
bool* available)
override;
47 int32_t InitRecording()
override;
48 bool RecordingIsInitialized()
const override;
49 int32_t StartPlayout()
override;
50 int32_t StopPlayout()
override;
51 bool Playing()
const override;
52 int32_t StartRecording()
override;
53 int32_t StopRecording()
override;
54 bool Recording()
const override;
55 int32_t InitSpeaker()
override;
56 bool SpeakerIsInitialized()
const override;
57 int32_t InitMicrophone()
override;
58 bool MicrophoneIsInitialized()
const override;
59 int32_t SpeakerVolumeIsAvailable(
bool* available)
override;
60 int32_t SetSpeakerVolume(uint32_t volume)
override;
61 int32_t SpeakerVolume(uint32_t* volume)
const override;
62 int32_t MaxSpeakerVolume(uint32_t* maxVolume)
const override;
63 int32_t MinSpeakerVolume(uint32_t* minVolume)
const override;
64 int32_t MicrophoneVolumeIsAvailable(
bool* available)
override;
65 int32_t SetMicrophoneVolume(uint32_t volume)
override;
66 int32_t MicrophoneVolume(uint32_t* volume)
const override;
67 int32_t MaxMicrophoneVolume(uint32_t* maxVolume)
const override;
68 int32_t MinMicrophoneVolume(uint32_t* minVolume)
const override;
69 int32_t SpeakerMuteIsAvailable(
bool* available)
override;
70 int32_t SetSpeakerMute(
bool enable)
override;
71 int32_t SpeakerMute(
bool* enabled)
const override;
72 int32_t MicrophoneMuteIsAvailable(
bool* available)
override;
73 int32_t SetMicrophoneMute(
bool enable)
override;
74 int32_t MicrophoneMute(
bool* enabled)
const override;
75 int32_t StereoPlayoutIsAvailable(
bool* available)
const override;
76 int32_t SetStereoPlayout(
bool enable)
override;
77 int32_t StereoPlayout(
bool* enabled)
const override;
78 int32_t StereoRecordingIsAvailable(
bool* available)
const override;
79 int32_t SetStereoRecording(
bool enable)
override;
80 int32_t StereoRecording(
bool* enabled)
const override;
81 int32_t PlayoutDelay(uint16_t* delayMS)
const override;
83 bool BuiltInAECIsAvailable()
const override {
return false; }
84 bool BuiltInAGCIsAvailable()
const override {
return false; }
85 bool BuiltInNSIsAvailable()
const override {
return false; }
86 int32_t EnableBuiltInAEC(
bool)
override {
return -1; }
87 int32_t EnableBuiltInAGC(
bool)
override {
return -1; }
88 int32_t EnableBuiltInNS(
bool)
override {
return -1; }
90 bool UsingDummySpeaker()
const {
return use_dummy_speaker_; }
93 void PlayoutPumpLoop_();
95 rtc::scoped_refptr<webrtc::AudioDeviceModule> pulse_audio_adm_;
96 std::atomic<webrtc::AudioTransport*> transport_ =
nullptr;
97 std::atomic<bool> inited_ =
false;
98 std::atomic<bool> playout_inited_ =
false;
99 std::atomic<bool> recording_inited_ =
false;
100 std::atomic<bool> playing_ =
false;
101 std::atomic<bool> recording_ =
false;
102 std::atomic<bool> use_dummy_speaker_ =
false;
103 std::thread playout_thread_;
104 std::atomic<bool> stop_playout_thread_ =
false;
105 std::atomic<bool> stereo_playout_ =
true;
106 std::atomic<bool> stereo_recording_ =
true;