Class RtpUtils
This class contains various static functions for reading and writing words, double words (4 bytes) and double double words (8 bytes) from byte arrays.
Inherited Members
Namespace: SipLib.Rtp
Assembly: SipLib.dll
Syntax
public class RtpUtils
Methods
| Edit this page View SourceDateTimeToNtpTimestamp(DateTime)
Converts specified DateTime value to long NTP time.
Declaration
public static ulong DateTimeToNtpTimestamp(DateTime value)
Parameters
Type | Name | Description |
---|---|---|
DateTime | value | DateTime value to convert. This value must be in local time. |
Returns
Type | Description |
---|---|
ulong | Returns NTP Timestamp value. |
DumpByteArray(byte[])
Declaration
public static void DumpByteArray(byte[] Ary)
Parameters
Type | Name | Description |
---|---|---|
byte[] | Ary |
Get3Bytes(byte[], int)
Gets a 24-bit value from a 3-byte array into a UInt32.
Declaration
public static uint Get3Bytes(byte[] SrcBytes, int idx)
Parameters
Type | Name | Description |
---|---|---|
byte[] | SrcBytes | Source byte array. Must contain at least 3 bytes starting at the idx value. The byte order must be Big-Endian (MSB first). |
int | idx | Starting index of the 24-bit field. |
Returns
Type | Description |
---|---|
uint | The 24-bit value packeted into the least significant 3 bytes of a uint value |
Get8ByteWord(byte[], int)
Gets a ulong (64-bit) value from a byte array starting at the specified index value with the MSB first (Big Endian format).
Declaration
public static ulong Get8ByteWord(byte[] SrcBytes, int idx)
Parameters
Type | Name | Description |
---|---|---|
byte[] | SrcBytes | Source byte array. Must contain at least 8 bytes starting at the idx value. |
int | idx | Starting index of the 8 byte long field. |
Returns
Type | Description |
---|---|
ulong | Returns the ulong value. |
GetDWord(byte[], int)
Gets a uint (32-bit DWORD) value from a byte array starting at the specified index value with the MSB first (Big Endian format).
Declaration
public static uint GetDWord(byte[] SrcBytes, int idx)
Parameters
Type | Name | Description |
---|---|---|
byte[] | SrcBytes | Source byte array. Must contain at least 4 bytes starting at the idx value. |
int | idx | Starting index of the 4 byte long field. |
Returns
Type | Description |
---|---|
uint | Returns the uint value. |
GetWord(byte[], int)
Gets a ushort value (16-bit WORD) from a byte array that contains the MSB first (Big Endian format).
Declaration
public static ushort GetWord(byte[] SrcBytes, int i)
Parameters
Type | Name | Description |
---|---|---|
byte[] | SrcBytes | Source array. Must contain at least 2 bytes starting at the idx value. |
int | i | Starting index of the 2 byte long field within the array. |
Returns
Type | Description |
---|---|
ushort | Returns the word value. |
NtpTimeStampToDateTime(ulong)
Converts a NTP timestamp value (as received in an RTCP packet or from an NTP server) to a UTC DateTime value.
Declaration
public static DateTime NtpTimeStampToDateTime(ulong NtpTimeStamp)
Parameters
Type | Name | Description |
---|---|---|
ulong | NtpTimeStamp | NTP timestamp value to convert. |
Returns
Type | Description |
---|---|
DateTime | Return a UTC DateTime value. Returns DateTime.MinValue if the input NtpTimeStamp parameter is 0 or otherwise not valid. |
Remarks
The caller must be prepared to deal with the case where the returned DateTime value is equal to DateTime.MinValue.
Set3Bytes(byte[], int, uint)
Loads the 3 least significant bytes into a 3-byte long destination byte array with the MSB first (Big Endian format).
Declaration
public static void Set3Bytes(byte[] DestBytes, int i, uint DWord)
Parameters
Type | Name | Description |
---|---|---|
byte[] | DestBytes | Destination byte aray. Must contain at least 3 bytes starting at the idx value. |
int | i | Starting index of the 24-bit field. |
uint | DWord | Contains the 24-bit value to load. |
Set8ByteWord(byte[], int, ulong)
Loads a ulong value (64-bit word) into a byte array starting at the specified index value with the MSB first (Big Endian format).
Declaration
public static void Set8ByteWord(byte[] DestBytes, int Start, ulong DDw)
Parameters
Type | Name | Description |
---|---|---|
byte[] | DestBytes | Destination byte array. Must contain at least 8 bytes starting at the Start value. |
int | Start | Starting index of the 8 byte long field. |
ulong | DDw | 64-bit value to load. |
SetDWord(byte[], int, uint)
Loads a uint value (32-bit DWORD) into a byte array starting at the specified index value with the MSB first (Big Endian format).
Declaration
public static void SetDWord(byte[] DestBytes, int Start, uint DWord)
Parameters
Type | Name | Description |
---|---|---|
byte[] | DestBytes | Destination byte array. Must contain at least 4 bytes starting at the Start value. |
int | Start | Starting index of the 4 byte long field. |
uint | DWord | 32-bit value to load. |
SetWord(byte[], int, ushort)
Loads a ushort value (16-bit WORD) into a byte array starting at the specified index value with the MSB first (Big Endian format).
Declaration
public static void SetWord(byte[] DestBytes, int Start, ushort Word)
Parameters
Type | Name | Description |
---|---|---|
byte[] | DestBytes | Destination byte array. Must contain at least 2 bytes starting at the Start value. |
int | Start | Starting index of the 2 byte long field. |
ushort | Word | 16-bit value to load. |