1
我正在使用PacketDotNet從RTP頭中檢索數據。但有時候時間戳是負值。獲取時間戳rtp包
GetTimeStamp(UdpPacket packetUdp)
{
byte[] packet = packetUdp.PayloadData;
long timestamp = GetRTPHeaderValue(packet, 32, 63);
return timestamp;
}
private static int GetRTPHeaderValue(byte[] packet, int startBit, int endBit)
{
int result = 0;
// Number of bits in value
int length = endBit - startBit + 1;
// Values in RTP header are big endian, so need to do these conversions
for (int i = startBit; i <= endBit; i++)
{
int byteIndex = i/8;
int bitShift = 7 - (i % 8);
result += ((packet[byteIndex] >> bitShift) & 1) *
(int)Math.Pow(2, length - i + startBit - 1);
}
return result;
}
HI @康拉德 - 脫溼這種情況下,問題是,我是在可變結果作爲整數,切換到「長」鍵入該問題已經解決:) –