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
DiscordPayloadType
public const byte DiscordPayloadType = 120
Field Value
HeaderSize
public const int HeaderSize = 12
Field Value
RtpExtensionOneByte
public static readonly byte[] RtpExtensionOneByte
Field Value
- byte[]
Version
public const byte Version = 128
Field Value
VersionWithExtension
public const byte VersionWithExtension = 144
Field Value
Methods
DecodeHeader(ReadOnlySpan<byte>)
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
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.
EncodeHeader(RtpHeader, Span<byte>)
Encodes a RTP header into the given buffer.
public static void EncodeHeader(RtpHeader header, Span<byte> target)
Parameters
Exceptions
- ArgumentException
The target buffer must have a minimum of 12 bytes for the RTP header to fit.
GetHeaderExtensionLength(ReadOnlySpan<byte>)
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.
HasRtpHeader(ReadOnlySpan<byte>)
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.