123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261 |
- namespace Agora.Rtc
- {
- public sealed class AudioDeviceManager : IAudioDeviceManager
- {
- private IRtcEngine _rtcEngineInstance = null;
- private AudioDeviceManagerImpl _audioDeviecManagerImpl = null;
- private const int ErrorCode = -7;
- private AudioDeviceManager(IRtcEngine rtcEngine, AudioDeviceManagerImpl impl)
- {
- _rtcEngineInstance = rtcEngine;
- _audioDeviecManagerImpl = impl;
- }
- ~AudioDeviceManager()
- {
- _rtcEngineInstance = null;
- }
- private static IAudioDeviceManager instance = null;
- public static IAudioDeviceManager Instance
- {
- get
- {
- return instance;
- }
- }
- #region PlaybackDevices
- public override DeviceInfo[] EnumeratePlaybackDevices()
- {
- if (_rtcEngineInstance == null || _audioDeviecManagerImpl == null)
- {
- return null;
- }
- return _audioDeviecManagerImpl.EnumeratePlaybackDevices();
- }
- public override int SetPlaybackDevice(string deviceId)
- {
- if (_rtcEngineInstance == null || _audioDeviecManagerImpl == null)
- {
- return ErrorCode;
- }
- return _audioDeviecManagerImpl.SetPlaybackDevice(deviceId);
- }
- public override int GetPlaybackDevice(ref string deviceId)
- {
- if (_rtcEngineInstance == null || _audioDeviecManagerImpl == null)
- {
- return ErrorCode;
- }
- return _audioDeviecManagerImpl.GetPlaybackDevice(ref deviceId);
- }
- public override int GetPlaybackDeviceInfo(ref string deviceId, ref string deviceName)
- {
- if (_rtcEngineInstance == null || _audioDeviecManagerImpl == null)
- {
- return ErrorCode;
- }
- return _audioDeviecManagerImpl.GetPlaybackDeviceInfo(ref deviceId, ref deviceName);
- }
- public override int SetPlaybackDeviceVolume(int volume)
- {
- if (_rtcEngineInstance == null || _audioDeviecManagerImpl == null)
- {
- return ErrorCode;
- }
- return _audioDeviecManagerImpl.SetPlaybackDeviceVolume(volume);
- }
- public override int GetPlaybackDeviceVolume(ref int volume)
- {
- if (_rtcEngineInstance == null || _audioDeviecManagerImpl == null)
- {
- return ErrorCode;
- }
- return _audioDeviecManagerImpl.GetPlaybackDeviceVolume(ref volume);
- }
- public override int SetPlaybackDeviceMute(bool mute)
- {
- if (_rtcEngineInstance == null || _audioDeviecManagerImpl == null)
- {
- return ErrorCode;
- }
- return _audioDeviecManagerImpl.SetPlaybackDeviceMute(mute);
- }
- public override int GetPlaybackDeviceMute(ref bool mute)
- {
- if (_rtcEngineInstance == null || _audioDeviecManagerImpl == null)
- {
- return ErrorCode;
- }
- return _audioDeviecManagerImpl.GetPlaybackDeviceMute(ref mute);
- }
- public override int StartPlaybackDeviceTest(string testAudioFilePath)
- {
- if (_rtcEngineInstance == null || _audioDeviecManagerImpl == null)
- {
- return ErrorCode;
- }
- return _audioDeviecManagerImpl.StartPlaybackDeviceTest(testAudioFilePath);
- }
- public override int StopPlaybackDeviceTest()
- {
- if (_rtcEngineInstance == null || _audioDeviecManagerImpl == null)
- {
- return ErrorCode;
- }
- return _audioDeviecManagerImpl.StopPlaybackDeviceTest();
- }
- public override int FollowSystemPlaybackDevice(bool enable)
- {
- if (_rtcEngineInstance == null || _audioDeviecManagerImpl == null)
- {
- return ErrorCode;
- }
- return _audioDeviecManagerImpl.FollowSystemPlaybackDevice(enable);
- }
- #endregion
- #region RecordingDevices
- public override DeviceInfo[] EnumerateRecordingDevices()
- {
- if (_rtcEngineInstance == null || _audioDeviecManagerImpl == null)
- {
- return null;
- }
- return _audioDeviecManagerImpl.EnumerateRecordingDevices();
- }
- public override int SetRecordingDevice(string deviceId)
- {
- if (_rtcEngineInstance == null || _audioDeviecManagerImpl == null)
- {
- return ErrorCode;
- }
- return _audioDeviecManagerImpl.SetRecordingDevice(deviceId);
- }
- public override int GetRecordingDevice(ref string deviceId)
- {
- if (_rtcEngineInstance == null || _audioDeviecManagerImpl == null)
- {
- return ErrorCode;
- }
- return _audioDeviecManagerImpl.GetRecordingDevice(ref deviceId);
- }
- public override int GetRecordingDeviceInfo(ref string deviceId, ref string deviceName)
- {
- if (_rtcEngineInstance == null || _audioDeviecManagerImpl == null)
- {
- return ErrorCode;
- }
- return _audioDeviecManagerImpl.GetRecordingDeviceInfo(ref deviceId, ref deviceName);
- }
- public override int SetRecordingDeviceVolume(int volume)
- {
- if (_rtcEngineInstance == null || _audioDeviecManagerImpl == null)
- {
- return ErrorCode;
- }
- return _audioDeviecManagerImpl.SetRecordingDeviceVolume(volume);
- }
- public override int GetRecordingDeviceVolume(ref int volume)
- {
- if (_rtcEngineInstance == null || _audioDeviecManagerImpl == null)
- {
- return ErrorCode;
- }
- return _audioDeviecManagerImpl.GetRecordingDeviceVolume(ref volume);
- }
- public override int SetRecordingDeviceMute(bool mute)
- {
- if (_rtcEngineInstance == null || _audioDeviecManagerImpl == null)
- {
- return ErrorCode;
- }
- return _audioDeviecManagerImpl.SetRecordingDeviceMute(mute);
- }
- public override int GetRecordingDeviceMute(ref bool mute)
- {
- if (_rtcEngineInstance == null || _audioDeviecManagerImpl == null)
- {
- return ErrorCode;
- }
- return _audioDeviecManagerImpl.GetRecordingDeviceMute(ref mute);
- }
- public override int StartRecordingDeviceTest(int indicationInterval)
- {
- if (_rtcEngineInstance == null || _audioDeviecManagerImpl == null)
- {
- return ErrorCode;
- }
- return _audioDeviecManagerImpl.StartRecordingDeviceTest(indicationInterval);
- }
- public override int StopRecordingDeviceTest()
- {
- if (_rtcEngineInstance == null || _audioDeviecManagerImpl == null)
- {
- return ErrorCode;
- }
- return _audioDeviecManagerImpl.StopRecordingDeviceTest();
- }
- public override int FollowSystemRecordingDevice(bool enable)
- {
- if (_rtcEngineInstance == null || _audioDeviecManagerImpl == null)
- {
- return ErrorCode;
- }
- return _audioDeviecManagerImpl.FollowSystemRecordingDevice(enable);
- }
- #endregion
- #region AudioDevice
- public override int StartAudioDeviceLoopbackTest(int indicationInterval)
- {
- if (_rtcEngineInstance == null || _audioDeviecManagerImpl == null)
- {
- return ErrorCode;
- }
- return _audioDeviecManagerImpl.StartAudioDeviceLoopbackTest(indicationInterval);
- }
- public override int StopAudioDeviceLoopbackTest()
- {
- if (_rtcEngineInstance == null || _audioDeviecManagerImpl == null)
- {
- return ErrorCode;
- }
- return _audioDeviecManagerImpl.StopAudioDeviceLoopbackTest();
- }
- #endregion
- internal static IAudioDeviceManager GetInstance(IRtcEngine rtcEngine, AudioDeviceManagerImpl impl)
- {
- return instance ?? (instance = new AudioDeviceManager(rtcEngine, impl));
- }
- internal static void ReleaseInstance()
- {
- instance = null;
- }
- }
- }
|