Browse Source

Added AudioServiceConfig.MaxBitrate constant

pull/22/head
RogueException 9 years ago
parent
commit
1ae7c36d31
2 changed files with 5 additions and 3 deletions
  1. +4
    -2
      src/Discord.Net.Audio/AudioServiceConfig.cs
  2. +1
    -1
      src/Discord.Net.Audio/Opus/OpusEncoder.cs

+ 4
- 2
src/Discord.Net.Audio/AudioServiceConfig.cs View File

@@ -12,6 +12,8 @@ namespace Discord.Audio

public class AudioServiceConfig
{
public const int MaxBitrate = 128;

/// <summary> Max time in milliseconds to wait for DiscordAudioClient to connect and initialize. </summary>
public int ConnectionTimeout { get { return _connectionTimeout; } set { SetValue(ref _connectionTimeout, value); } }
private int _connectionTimeout = 30000;
@@ -33,8 +35,8 @@ namespace Discord.Audio
public int BufferLength { get { return _bufferLength; } set { SetValue(ref _bufferLength, value); } }
private int _bufferLength = 1000;

/// <summary> Gets or sets the bitrate used (in kbit/s, between 1 and 128 inclusively) for outgoing voice packets. A null value will use default Opus settings. </summary>
public int? Bitrate { get { return _bitrate; } set { SetValue(ref _bitrate, value); } }
/// <summary> Gets or sets the bitrate used (in kbit/s, between 1 and MaxBitrate inclusively) for outgoing voice packets. A null value will use default Opus settings. </summary>
public int? Bitrate { get { return _bitrate; } set { SetValue(ref _bitrate, value); } }
private int? _bitrate = null;
/// <summary> 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). </summary>
public int Channels { get { return _channels; } set { SetValue(ref _channels, value); } }


+ 1
- 1
src/Discord.Net.Audio/Opus/OpusEncoder.cs View File

@@ -18,7 +18,7 @@ namespace Discord.Audio.Opus
public OpusEncoder(int samplingRate, int channels, int frameLength, int? bitrate, OpusApplication application)
: base(samplingRate, channels, frameLength)
{
if (bitrate != null && (bitrate < 1 || bitrate > 512))
if (bitrate != null && (bitrate < 1 || bitrate > AudioServiceConfig.MaxBitrate))
throw new ArgumentOutOfRangeException(nameof(bitrate));

BitRate = bitrate;


Loading…
Cancel
Save