Table of Contents

Class RtpReadStream

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

表示一个 RTP 帧读取流。

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

Constructors

RtpReadStream(AudioStream, int)

public RtpReadStream(AudioStream next, int bufferSize = 4000)

Parameters

next AudioStream
bufferSize int

Properties

CanRead

When overridden in a derived class, gets a value indicating whether the current stream supports reading.

public override bool CanRead { get; }

Property Value

bool

true if the stream supports reading; otherwise, false.

CanSeek

When overridden in a derived class, gets a value indicating whether the current stream supports seeking.

public override bool CanSeek { get; }

Property Value

bool

true if the stream supports seeking; otherwise, false.

CanWrite

When overridden in a derived class, gets a value indicating whether the current stream supports writing.

public override bool CanWrite { get; }

Property Value

bool

true if the stream supports writing; otherwise, false.

Methods

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.

GetHeaderSize(byte[], int)

获取 RTP 数据报的头部大小。

public static int GetHeaderSize(byte[] buffer, int offset)

Parameters

buffer byte[]

要获取头部大小的数据报。

offset int

数据报的偏移量。

Returns

int

数据报的头部大小。

TryReadSsrc(byte[], int, out uint)

尝试从 RTP 数据报中读取 SSRC。

public static bool TryReadSsrc(byte[] buffer, int offset, out uint ssrc)

Parameters

buffer byte[]

要从中读取 SSRC 的数据报。

offset int

数据报的偏移量。

ssrc uint

如果读取成功,则为 SSRC 值;否则为 0。

Returns

bool

读取是否成功。

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 cancellationToken)

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.

cancellationToken CancellationToken

The token to monitor for cancellation requests. The default value is None.

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.