Agora RTC Objective-C API Reference Refactor

NGIAgoraAudioDeviceManager.h
Go to the documentation of this file.
1 //
2 // Agora SDK
3 //
4 // Copyright (c) 2018 Agora.io. All rights reserved.
5 //
6
7 #pragma once // NOLINT(build/header_guard)
8
9 #include <cstring>
10
11 #include "AgoraBase.h"
12 #include "AgoraRefPtr.h"
13 namespace agora {
14 namespace media {
15 namespace base {
16 class IAudioFrameObserver;
17 } // namespace base
18 } // namespace media
19
20 namespace rtc {
21
22 static const int kIntervalInMillseconds = 200;
23
24
30 struct LoopbackRecordingOption {
34 Optional<const char *> deviceName;
38 Optional<bool> allowDeviceChange;
39 };
40
44 class IAudioDeviceManagerObserver
45 {
46 public:
47 virtual ~IAudioDeviceManagerObserver() {}
48
54 virtual void onDeviceStateChanged() = 0;
55
66 virtual void onAudioDeviceStateChanged(const char *deviceId, int deviceType, int deviceState) = 0;
67
73 virtual void onVolumeIndication(int deviceType, int volume) = 0;
74
81 virtual void onRoutingChanged(int deviceType, AudioRoute route) = 0;
82
92 virtual void onAudioDeviceVolumeChanged(int deviceType, int volume, bool muted) = 0;
93 };
94
95 class IRecordingDeviceSource : public RefCountInterface {
96 public:
103 virtual int initRecording(const char* deviceName = NULL) = 0;
104
111 virtual int startRecording() = 0;
112
119 virtual int stopRecording() = 0;
120
129 virtual int registerAudioFrameObserver(media::IAudioPcmFrameSink* observer) = 0;
130
139 virtual int unregisterAudioFrameObserver(media::IAudioPcmFrameSink* observer) = 0;
140
147 virtual int setLoopbackDeviceParameter(const LoopbackRecordingOption &option) = 0;
148
149 virtual ~IRecordingDeviceSource() {}
150 };
151
158 class INGAudioDeviceManager : public RefCountInterface {
159 public:
168 virtual agora_refptr<IRecordingDeviceSource> createRecordingDeviceSource(char deviceId[kAdmMaxDeviceNameSize]) = 0;
169
177 virtual int setMicrophoneVolume(unsigned int volume) = 0;
185 virtual int getMicrophoneVolume(unsigned int& volume) = 0;
193 virtual int setSpeakerVolume(unsigned int volume) = 0;
201 virtual int getSpeakerVolume(unsigned int& volume) = 0;
211 virtual int setMicrophoneMute(bool mute) = 0;
219 virtual int getMicrophoneMute(bool& mute) = 0;
229 virtual int setSpeakerMute(bool mute) = 0;
237 virtual int getSpeakerMute(bool& mute) = 0;
238
246 virtual int getPlayoutAudioParameters(AudioParameters* params) const = 0;
247
255 virtual int getRecordAudioParameters(AudioParameters* params) const = 0;
256
257 #if defined(__ANDROID__) || (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE)
258
273 virtual int setDefaultAudioRouting(AudioRoute route) = 0;
285 virtual int changeAudioRouting(AudioRoute route) = 0;
297 virtual int setAudioRoutingSpeakerOn(bool enable) = 0;
309 virtual int getCurrentRouting(AudioRoute& route) = 0;
310 #endif // __ANDROID__ || TARGET_OS_IPHONE
311
312 #if defined(_WIN32) || (defined(__APPLE__) && TARGET_OS_MAC && !TARGET_OS_IPHONE)
313
323 virtual int getNumberOfPlayoutDevices() = 0;
324
335 virtual int getNumberOfRecordingDevices() = 0;
346 virtual AudioDeviceInfo getPlayoutDeviceInfo(int index) = 0;
357 virtual AudioDeviceInfo getRecordingDeviceInfo(int index) = 0;
369 virtual int setPlayoutDevice(int index) = 0;
381 virtual int setRecordingDevice(int index) = 0;
393 virtual int followSystemPlaybackDevice(bool enable) = 0;
394
406 virtual int followSystemRecordingDevice(bool enable) = 0;
407 #endif // _WIN32 || (TARGET_OS_MAC && !TARGET_OS_IPHONE)
408
409 #if defined(_WIN32)
410
421 virtual int setApplicationVolume(unsigned int volume) = 0;
433 virtual int getApplicationVolume(unsigned int& volume) = 0;
447 virtual int setApplicationMuteState(bool mute) = 0;
459 virtual int getApplicationMuteState(bool& mute) = 0;
470 virtual AudioDeviceInfo getLoopbackDeviceInfo(int index) = 0;
482 virtual int setLoopbackDevice(int index) = 0;
494 virtual int followSystemLoopbackDevice(bool enable) = 0;
495 #endif // _WIN32
496
508 virtual int registerObserver(IAudioDeviceManagerObserver* observer, void(*safeDeleter)(IAudioDeviceManagerObserver*) = NULL) = 0;
516 virtual int unregisterObserver(IAudioDeviceManagerObserver* observer) = 0;
517
518 virtual int setupAudioAttributeContext(void* audioAttr) = 0;
519
520 protected:
521 ~INGAudioDeviceManager() {}
522 };
523
524 } //namespace rtc
525 } // namespace agora
agora::rtc::INGAudioDeviceManager::setSpeakerMute
virtual int setSpeakerMute(bool mute)=0
agora::media::IAudioPcmFrameSink
Definition: AgoraMediaBase.h:994
AgoraBase.h
agora::rtc::INGAudioDeviceManager::setMicrophoneVolume
virtual int setMicrophoneVolume(unsigned int volume)=0
agora::agora_refptr
Definition: AgoraRefPtr.h:44
agora::rtc::IRecordingDeviceSource::setLoopbackDeviceParameter
virtual int setLoopbackDeviceParameter(const LoopbackRecordingOption &option)=0
agora::rtc::IAudioDeviceManagerObserver::~IAudioDeviceManagerObserver
virtual ~IAudioDeviceManagerObserver()
Definition: NGIAgoraAudioDeviceManager.h:47
agora::rtc::AudioParameters
Definition: AgoraMediaBase.h:173
agora::rtc::INGAudioDeviceManager::getRecordAudioParameters
virtual int getRecordAudioParameters(AudioParameters *params) const =0
agora::rtc::AudioRoute
AudioRoute
Definition: AgoraMediaBase.h:108
agora::rtc::INGAudioDeviceManager::createRecordingDeviceSource
virtual agora_refptr< IRecordingDeviceSource > createRecordingDeviceSource(char deviceId[kAdmMaxDeviceNameSize])=0
agora::rtc::INGAudioDeviceManager::~INGAudioDeviceManager
~INGAudioDeviceManager()
Definition: NGIAgoraAudioDeviceManager.h:521
agora::rtc::IAudioDeviceManagerObserver::onVolumeIndication
virtual void onVolumeIndication(int deviceType, int volume)=0
agora::media::IAudioFrameObserver
Definition: AgoraMediaBase.h:1272
agora::rtc::INGAudioDeviceManager::getMicrophoneMute
virtual int getMicrophoneMute(bool &mute)=0
agora::rtc::IRecordingDeviceSource::startRecording
virtual int startRecording()=0
agora::rtc::INGAudioDeviceManager::getPlayoutAudioParameters
virtual int getPlayoutAudioParameters(AudioParameters *params) const =0
agora::rtc::INGAudioDeviceManager::setMicrophoneMute
virtual int setMicrophoneMute(bool mute)=0
agora::rtc::INGAudioDeviceManager::getSpeakerMute
virtual int getSpeakerMute(bool &mute)=0
agora::rtc::INGAudioDeviceManager::getMicrophoneVolume
virtual int getMicrophoneVolume(unsigned int &volume)=0
agora
Definition: AgoraAtomicOps.h:21
agora::rtc::IAudioDeviceManagerObserver::onAudioDeviceVolumeChanged
virtual void onAudioDeviceVolumeChanged(int deviceType, int volume, bool muted)=0
agora::rtc::LoopbackRecordingOption
Definition: NGIAgoraAudioDeviceManager.h:30
agora::rtc::INGAudioDeviceManager::changeAudioRouting
virtual int changeAudioRouting(AudioRoute route)=0
agora::rtc::INGAudioDeviceManager::setSpeakerVolume
virtual int setSpeakerVolume(unsigned int volume)=0
agora::rtc::LoopbackRecordingOption::allowDeviceChange
Optional< bool > allowDeviceChange
Definition: NGIAgoraAudioDeviceManager.h:38
agora::rtc::IRecordingDeviceSource
Definition: NGIAgoraAudioDeviceManager.h:95
agora::rtc::IAudioDeviceManagerObserver::onRoutingChanged
virtual void onRoutingChanged(int deviceType, AudioRoute route)=0
agora::rtc::kIntervalInMillseconds
static const int kIntervalInMillseconds
Definition: NGIAgoraAudioDeviceManager.h:22
agora::rtc::kAdmMaxDeviceNameSize
static const int kAdmMaxDeviceNameSize
Definition: AgoraMediaBase.h:38
agora::rtc::IAudioDeviceManagerObserver::onAudioDeviceStateChanged
virtual void onAudioDeviceStateChanged(const char *deviceId, int deviceType, int deviceState)=0
agora::rtc::INGAudioDeviceManager::getCurrentRouting
virtual int getCurrentRouting(AudioRoute &route)=0
agora::rtc::IRecordingDeviceSource::registerAudioFrameObserver
virtual int registerAudioFrameObserver(media::IAudioPcmFrameSink *observer)=0
agora::rtc::IAudioDeviceManagerObserver::onDeviceStateChanged
virtual void onDeviceStateChanged()=0
agora::rtc::IRecordingDeviceSource::unregisterAudioFrameObserver
virtual int unregisterAudioFrameObserver(media::IAudioPcmFrameSink *observer)=0
agora::rtc::IRecordingDeviceSource::initRecording
virtual int initRecording(const char *deviceName=NULL)=0
AgoraRefPtr.h
agora::rtc::INGAudioDeviceManager
Definition: NGIAgoraAudioDeviceManager.h:158
agora::rtc::IAudioDeviceManagerObserver
Definition: NGIAgoraAudioDeviceManager.h:45
agora::rtc::INGAudioDeviceManager::setAudioRoutingSpeakerOn
virtual int setAudioRoutingSpeakerOn(bool enable)=0
agora::rtc::INGAudioDeviceManager::getSpeakerVolume
virtual int getSpeakerVolume(unsigned int &volume)=0
agora::RefCountInterface
Definition: AgoraRefPtr.h:31
agora::rtc::INGAudioDeviceManager::registerObserver
virtual int registerObserver(IAudioDeviceManagerObserver *observer, void(*safeDeleter)(IAudioDeviceManagerObserver *)=NULL)=0
agora::rtc::INGAudioDeviceManager::setDefaultAudioRouting
virtual int setDefaultAudioRouting(AudioRoute route)=0
agora::rtc::INGAudioDeviceManager::unregisterObserver
virtual int unregisterObserver(IAudioDeviceManagerObserver *observer)=0
agora::rtc::IRecordingDeviceSource::stopRecording
virtual int stopRecording()=0
agora::rtc::INGAudioDeviceManager::setupAudioAttributeContext
virtual int setupAudioAttributeContext(void *audioAttr)=0
agora::rtc::IRecordingDeviceSource::~IRecordingDeviceSource
virtual ~IRecordingDeviceSource()
Definition: NGIAgoraAudioDeviceManager.h:149
agora::rtc::AudioDeviceInfo
Definition: AgoraMediaBase.h:218
agora::rtc::LoopbackRecordingOption::deviceName
Optional< const char * > deviceName
Definition: NGIAgoraAudioDeviceManager.h:34
agora::Optional< const char * >