SkyWay Linux SDK
読み取り中…
検索中…
一致する文字列を見つけられません
custom_audio_device_module.hpp
1//
2// © NTT DOCOMO BUSINESS, Inc. All Rights Reserved.
3//
4
5#ifndef SKYWAY_MEDIA_AUDIO_CUSTOM_AUDIO_DEVICE_MODULE_HPP_
6#define SKYWAY_MEDIA_AUDIO_CUSTOM_AUDIO_DEVICE_MODULE_HPP_
7
8#include <atomic>
9#include <cstdint>
10#include <thread>
11
12#include "modules/audio_device/include/audio_device.h"
13#include "rtc_base/ref_counted_object.h"
14
15namespace skyway {
16namespace media {
17namespace audio {
18
19class CustomAudioDeviceModule : public webrtc::AudioDeviceModule {
20public:
21 static rtc::scoped_refptr<CustomAudioDeviceModule> Create(
22 rtc::scoped_refptr<webrtc::AudioDeviceModule> pulse_audio_adm);
23
24 CustomAudioDeviceModule(rtc::scoped_refptr<webrtc::AudioDeviceModule> pulse_audio_adm);
25
26 ~CustomAudioDeviceModule() override;
27
28 // webrtc::AudioDeviceModule
29 int32_t ActiveAudioLayer(AudioLayer* audioLayer) const override;
30 int32_t RegisterAudioCallback(webrtc::AudioTransport* audioCallback) override;
31 int32_t Init() override;
32 int32_t Terminate() override;
33 bool Initialized() const override;
34 int16_t PlayoutDevices() override;
35 int16_t RecordingDevices() override;
36 int32_t PlayoutDeviceName(uint16_t index,
37 char name[webrtc::kAdmMaxDeviceNameSize],
38 char guid[webrtc::kAdmMaxGuidSize]) override;
39 int32_t RecordingDeviceName(uint16_t index,
40 char name[webrtc::kAdmMaxDeviceNameSize],
41 char guid[webrtc::kAdmMaxGuidSize]) override;
42 int32_t SetPlayoutDevice(uint16_t index) override;
43 int32_t SetPlayoutDevice(WindowsDeviceType) override { return -1; }
44 int32_t SetRecordingDevice(uint16_t index) override;
45 int32_t SetRecordingDevice(WindowsDeviceType) override { return -1; }
46 int32_t PlayoutIsAvailable(bool* available) override;
47 int32_t InitPlayout() override;
48 bool PlayoutIsInitialized() const override;
49 int32_t RecordingIsAvailable(bool* available) override;
50 int32_t InitRecording() override;
51 bool RecordingIsInitialized() const override;
52 int32_t StartPlayout() override;
53 int32_t StopPlayout() override;
54 bool Playing() const override;
55 int32_t StartRecording() override;
56 int32_t StopRecording() override;
57 bool Recording() const override;
58 int32_t InitSpeaker() override;
59 bool SpeakerIsInitialized() const override;
60 int32_t InitMicrophone() override;
61 bool MicrophoneIsInitialized() const override;
62 int32_t SpeakerVolumeIsAvailable(bool* available) override;
63 int32_t SetSpeakerVolume(uint32_t volume) override;
64 int32_t SpeakerVolume(uint32_t* volume) const override;
65 int32_t MaxSpeakerVolume(uint32_t* maxVolume) const override;
66 int32_t MinSpeakerVolume(uint32_t* minVolume) const override;
67 int32_t MicrophoneVolumeIsAvailable(bool* available) override;
68 int32_t SetMicrophoneVolume(uint32_t volume) override;
69 int32_t MicrophoneVolume(uint32_t* volume) const override;
70 int32_t MaxMicrophoneVolume(uint32_t* maxVolume) const override;
71 int32_t MinMicrophoneVolume(uint32_t* minVolume) const override;
72 int32_t SpeakerMuteIsAvailable(bool* available) override;
73 int32_t SetSpeakerMute(bool enable) override;
74 int32_t SpeakerMute(bool* enabled) const override;
75 int32_t MicrophoneMuteIsAvailable(bool* available) override;
76 int32_t SetMicrophoneMute(bool enable) override;
77 int32_t MicrophoneMute(bool* enabled) const override;
78 int32_t StereoPlayoutIsAvailable(bool* available) const override;
79 int32_t SetStereoPlayout(bool enable) override;
80 int32_t StereoPlayout(bool* enabled) const override;
81 int32_t StereoRecordingIsAvailable(bool* available) const override;
82 int32_t SetStereoRecording(bool enable) override;
83 int32_t StereoRecording(bool* enabled) const override;
84 int32_t PlayoutDelay(uint16_t* delayMS) const override;
85
86 // Android built-ins (not used; return defaults)
87 bool BuiltInAECIsAvailable() const override { return false; }
88 bool BuiltInAGCIsAvailable() const override { return false; }
89 bool BuiltInNSIsAvailable() const override { return false; }
90 int32_t EnableBuiltInAEC(bool) override { return -1; }
91 int32_t EnableBuiltInAGC(bool) override { return -1; }
92 int32_t EnableBuiltInNS(bool) override { return -1; }
93
94 bool UsingDummySpeaker() const { return use_dummy_speaker_; }
95
96private:
97 void PlayoutPumpLoop_();
98
99 rtc::scoped_refptr<webrtc::AudioDeviceModule> pulse_audio_adm_;
100 std::atomic<webrtc::AudioTransport*> transport_ = nullptr;
101 std::atomic<bool> inited_ = false;
102 std::atomic<bool> playout_inited_ = false;
103 std::atomic<bool> recording_inited_ = false;
104 std::atomic<bool> playing_ = false;
105 std::atomic<bool> recording_ = false;
106 std::atomic<bool> use_dummy_speaker_ = false;
107 std::thread playout_thread_;
108 std::atomic<bool> stop_playout_thread_ = false;
109 std::atomic<bool> stereo_playout_ = true;
110 std::atomic<bool> stereo_recording_ = true;
111};
112
113} // namespace audio
114} // namespace media
115} // namespace skyway
116
117#endif // SKYWAY_MEDIA_AUDIO_CUSTOM_AUDIO_DEVICE_MODULE_HPP_
Definition custom_audio_device_module.hpp:19