Table of Contents

Class RtpUtilities

Namespace
DSharpPlus.VoiceLink.Rtp
Assembly
DSharpPlus.VoiceLink.dll

General helper methods for handling RTP headers.

public static class RtpUtilities
Inheritance
RtpUtilities
Inherited Members

Fields

public const byte DiscordPayloadType = 120

Field Value

byte
public const int HeaderSize = 12

Field Value

int
public static readonly byte[] RtpExtensionOneByte

Field Value

byte[]
public const byte Version = 128

Field Value

byte
public const byte VersionWithExtension = 144

Field Value

byte

Methods

Attempts to decode the RTP header from the given buffer.

public static RtpHeader DecodeHeader(ReadOnlySpan<byte> source)

Parameters

source ReadOnlySpan<byte>

The source data; Both the RTP header and the encrypted audio.

Returns

RtpHeader

Exceptions

ArgumentException

The source buffer must have a minimum of 12 bytes for it to be a RTP header or contains an unknown RTP header version or type.

Encodes a RTP header into the given buffer.

public static void EncodeHeader(RtpHeader header, Span<byte> target)

Parameters

header RtpHeader
target Span<byte>

Which buffer to write to.

Exceptions

ArgumentException

The target buffer must have a minimum of 12 bytes for the RTP header to fit.

Gets the length in bytes of an RTP header extension. The extension will prefix the RTP payload. Use HasExtension to determined whether an RTP packet includes an extension.

public static ushort GetHeaderExtensionLength(ReadOnlySpan<byte> rtpPayload)

Parameters

rtpPayload ReadOnlySpan<byte>

The RTP payload that is prefixed by a header extension.

Returns

ushort

The byte length of the extension.

Determines if the given buffer contains a valid RTP header.

public static bool HasRtpHeader(ReadOnlySpan<byte> source)

Parameters

source ReadOnlySpan<byte>

The data to reference.

Returns

bool

Whether the data contains a valid RTP header.