internal OpusEncodeStream(IAudioTarget target, byte[] secretKey, int channels, int samplesPerFrame, uint ssrc, int?bitrate = null) : base(target, secretKey, samplesPerFrame, ssrc) { _encoder = new OpusEncoder(SampleRate, channels); _frameSize = samplesPerFrame * channels * 2; _partialFrameBuffer = new byte[_frameSize]; _encoder.SetForwardErrorCorrection(true); if (bitrate != null) { _encoder.SetBitrate(bitrate.Value); } }
internal RTPWriteStream(IAudioTarget target, byte[] secretKey, int samplesPerFrame, uint ssrc) { _target = target; _secretKey = secretKey; _samplesPerFrame = samplesPerFrame; _ssrc = ssrc; _buffer = new byte[4000]; _nonce = new byte[24]; _nonce[0] = 0x80; _nonce[1] = 0x78; _nonce[8] = (byte)(_ssrc >> 24); _nonce[9] = (byte)(_ssrc >> 16); _nonce[10] = (byte)(_ssrc >> 8); _nonce[11] = (byte)(_ssrc >> 0); }