Table of Contents

Class OpusEncodeStream

Namespace
Discord.Audio.Streams
Assembly
Discord.Net.WebSocket.dll

Converts PCM to Opus

public class OpusEncodeStream : AudioOutStream, IAsyncDisposable, IDisposable
Inheritance
OpusEncodeStream
Implements
Inherited Members

Constructors

OpusEncodeStream(AudioStream, int, AudioApplication, int)

public OpusEncodeStream(AudioStream next, int bitrate, AudioApplication application, int packetLoss)

Parameters

next AudioStream
bitrate int
application AudioApplication
packetLoss int

Fields

SampleRate

public const int SampleRate = 48000

Field Value

int

Methods

ClearAsync(CancellationToken)

public override Task ClearAsync(CancellationToken cancelToken)

Parameters

cancelToken CancellationToken

Returns

Task

Dispose(bool)

Releases the unmanaged resources used by the Stream and optionally releases the managed resources.

protected override void Dispose(bool disposing)

Parameters

disposing bool

true to release both managed and unmanaged resources; false to release only unmanaged resources.

FlushAsync(CancellationToken)

Asynchronously clears all buffers for this stream, causes any buffered data to be written to the underlying device, and monitors cancellation requests.

public override Task FlushAsync(CancellationToken cancelToken)

Parameters

cancelToken CancellationToken

Returns

Task

A task that represents the asynchronous flush operation.

Exceptions

ObjectDisposedException

The stream has been disposed.

OperationCanceledException

The cancellation token was canceled. This exception is stored into the returned task.

WriteAsync(byte[], int, int, CancellationToken)

Asynchronously writes a sequence of bytes to the current stream, advances the current position within this stream by the number of bytes written, and monitors cancellation requests.

public override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancelToken)

Parameters

buffer byte[]

The buffer to write data from.

offset int

The zero-based byte offset in buffer from which to begin copying bytes to the stream.

count int

The maximum number of bytes to write.

cancelToken CancellationToken

Returns

Task

A task that represents the asynchronous write operation.

Exceptions

ArgumentNullException

buffer is null.

ArgumentOutOfRangeException

offset or count is negative.

ArgumentException

The sum of offset and count is larger than the buffer length.

NotSupportedException

The stream does not support writing.

ObjectDisposedException

The stream has been disposed.

InvalidOperationException

The stream is currently in use by a previous write operation.

OperationCanceledException

The cancellation token was canceled. This exception is stored into the returned task.

WriteSilentFramesAsync()

Sends silent frames to avoid interpolation errors after breaks in data transmission.

public Task WriteSilentFramesAsync()

Returns

Task

A task representing the asynchronous operation of sending a silent frame.