internal void InitializeOpusEncoder() { if (Channel != null && Channel.Type == ChannelType.Voice) { if (Channel.Bitrate > 0) { mainOpusEncoder = new OpusEncoder(VoiceConfig.SampleRate, VoiceConfig.Channels, VoiceConfig.FrameLengthMs, (Channel.Bitrate / 1000), VoiceConfig.OpusMode); } else { mainOpusEncoder = new OpusEncoder(VoiceConfig.SampleRate, VoiceConfig.Channels, VoiceConfig.FrameLengthMs, null, VoiceConfig.OpusMode); } mainOpusEncoder.SetForwardErrorCorrection(true); msToSend = VoiceConfig.FrameLengthMs; } if (!VoiceConfig.SendOnly) { InitializeOpusDecoder(); } }
internal OpusEncodeStream(AudioClient audioClient, byte[] secretKey, int samplesPerFrame, uint ssrc, int?bitrate = null, OpusApplication application = OpusApplication.MusicOrMixed, int bufferSize = 4000) : base(audioClient, secretKey, samplesPerFrame, ssrc, bufferSize) { _encoder = new OpusEncoder(SampleRate, Channels); _encoder.SetForwardErrorCorrection(true); if (bitrate != null) { _encoder.SetBitrate(bitrate.Value); } }