using System; namespace Discord.Audio { public enum AudioMode : byte { Outgoing = 1, Incoming = 2, Both = Outgoing | Incoming } public class AudioServiceConfig { /// Max time in milliseconds to wait for DiscordAudioClient to connect and initialize. public int ConnectionTimeout { get { return _connectionTimeout; } set { SetValue(ref _connectionTimeout, value); } } private int _connectionTimeout = 30000; //Experimental Features /// (Experimental) Enables the voice websocket and UDP client and specifies how it will be used. public AudioMode Mode { get { return _mode; } set { SetValue(ref _mode, value); } } private AudioMode _mode = AudioMode.Outgoing; /// (Experimental) Enables the voice websocket and UDP client. This option requires the libsodium .dll or .so be in the local or system folder. public bool EnableEncryption { get { return _enableEncryption; } set { SetValue(ref _enableEncryption, value); } } private bool _enableEncryption = true; /// (Experimental) Enables the client to be simultaneously connected to multiple channels at once (Discord still limits you to one channel per server). public bool EnableMultiserver { get { return _enableMultiserver; } set { SetValue(ref _enableMultiserver, value); } } private bool _enableMultiserver = false; /// Gets or sets the buffer length (in milliseconds) for outgoing voice packets. public int BufferLength { get { return _bufferLength; } set { SetValue(ref _bufferLength, value); } } private int _bufferLength = 1000; /// Gets or sets the bitrate used (in kbit/s, between 1 and 512 inclusively) for outgoing voice packets. A null value will use default Opus settings. public int? Bitrate { get { return _bitrate; } set { SetValue(ref _bitrate, value); } } private int? _bitrate = null; /// Gets or sets the number of channels (1 or 2) used in both input provided to IAudioClient and output send to Discord. Defaults to 2 (stereo). public int Channels { get { return _channels; } set { SetValue(ref _channels, value); } } private int _channels = 2; //Lock protected bool _isLocked; internal void Lock() { _isLocked = true; } protected void SetValue(ref T storage, T value) { if (_isLocked) throw new InvalidOperationException("Unable to modify a service's configuration after it has been created."); storage = value; } public AudioServiceConfig Clone() { var config = MemberwiseClone() as AudioServiceConfig; config._isLocked = false; return config; } } }