Class RtpWriteStream
表示一个 RTP 帧写入流。
public class RtpWriteStream : AudioOutStream, IAsyncDisposable, IDisposable
- Inheritance
-
RtpWriteStream
- Implements
- Inherited Members
Constructors
RtpWriteStream(AudioStream, uint, byte, int)
初始化一个 RtpWriteStream 类的新实例。
public RtpWriteStream(AudioStream next, uint ssrc, byte payloadType, int bufferSize = 4000)
Parameters
nextAudioStream要写入 RTP 帧数据的音频流,是音频流写入链中的下一个音频流对象。
ssrcuintRTP 连接的同步源标识符。
payloadTypebyteRTP 连接的负载类型。
bufferSizeintRTP 帧缓冲区的大小,默认为 4000 字节。
Methods
ClearAsync(CancellationToken)
清空该流.
public override Task ClearAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationToken用于取消该异步操作的取消令牌。
Returns
- Task
一个清空操作的异步任务。
Remarks
此操作会导致丢失所有缓冲的数据。
Dispose(bool)
Releases the unmanaged resources used by the Stream and optionally releases the managed resources.
protected override void Dispose(bool disposing)
Parameters
disposingbooltrue 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 cancellationToken)
Parameters
cancellationTokenCancellationTokenThe token to monitor for cancellation requests. The default value is None.
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 cancellationToken)
Parameters
bufferbyte[]The buffer to write data from.
offsetintThe zero-based byte offset in
bufferfrom which to begin copying bytes to the stream.countintThe maximum number of bytes to write.
cancellationTokenCancellationTokenThe token to monitor for cancellation requests. The default value is None.
Returns
- Task
A task that represents the asynchronous write operation.
Exceptions
- ArgumentNullException
bufferis null.- ArgumentOutOfRangeException
offsetorcountis negative.- ArgumentException
The sum of
offsetandcountis 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.
WriteHeader(ushort, uint, bool)
向流中写入一个头部信息。
public override void WriteHeader(ushort seq, uint timestamp, bool missed)
Parameters
Exceptions
- InvalidOperationException
该流不接收头部信息。