本文整理汇总了C#中BufferChunk.NextByte方法的典型用法代码示例。如果您正苦于以下问题:C# BufferChunk.NextByte方法的具体用法?C# BufferChunk.NextByte怎么用?C# BufferChunk.NextByte使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BufferChunk
的用法示例。
在下文中一共展示了BufferChunk.NextByte方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HandleInvalidPacket
private void HandleInvalidPacket(BufferChunk packet, IPEndPoint src, string exception)
{
rtpSession.RaiseInvalidPacketEvent(string.Format("First byte: {0}, Source IP: {1}, " +
"Exception: {2}", packet.NextByte(), src, exception));
}
示例2: ReadPrivatePropertyFromBuffer
private void ReadPrivatePropertyFromBuffer(BufferChunk buffer)
{
byte totalLength = buffer.NextByte();
byte prefixLength = buffer.NextByte();
int dataLength = totalLength - prefixLength - 1;
// The cast to byte[] does a copy
byte[] prefix = (byte[])buffer.NextBufferChunk(prefixLength);
byte[] data = null;
if(dataLength > 0)
{
// The cast to byte[] does a copy
data = (byte[])buffer.NextBufferChunk(dataLength);
}
privs[prefix] = data;
}
示例3: ReadDataFromBuffer
/// <summary>
/// Converts buffer into member data
/// </summary>
/// <param name="packet"></param>
public override void ReadDataFromBuffer(BufferChunk buffer)
{
// Read SSRCs
for(int i = 0; i < Header.ItemCount; i++)
{
ssrcs.Add(buffer.NextUInt32());
}
// Determine if there is a reason...
// SSRCs are 32 bits each, Length is number of 32 bit words in packet data
if(Header.Length > Header.ItemCount)
{
reason = (byte[])buffer.NextBufferChunk(buffer.NextByte());
}
}
示例4: ReadDataFromBuffer
/// <summary>
/// Deserializes the provided buffer into this object
/// </summary>
/// <param name="buffer"></param>
public void ReadDataFromBuffer(BufferChunk buffer)
{
Rtcp.SDESType type;
while((type = (Rtcp.SDESType)buffer.NextByte()) != Rtcp.SDESType.END)
{
switch(type)
{
case Rtcp.SDESType.CNAME:
case Rtcp.SDESType.EMAIL:
case Rtcp.SDESType.LOC:
case Rtcp.SDESType.NAME:
case Rtcp.SDESType.NOTE:
case Rtcp.SDESType.PHONE:
case Rtcp.SDESType.TOOL:
ReadPropertyFromBuffer((int)type, buffer);
break;
case Rtcp.SDESType.PRIV:
ReadPrivatePropertyFromBuffer(buffer);
break;
default:
throw new ApplicationException("Unexpected SDES type: " + type);
}
}
}
示例5: ReadPropertyFromBuffer
private void ReadPropertyFromBuffer(int type, BufferChunk buffer)
{
int dataLength = buffer.NextByte();
if(dataLength != 0)
{
data[type] = (byte[])buffer.NextBufferChunk(dataLength);
}
else // Clear value
{
data[type] = null;
}
}
示例6: ThreeBytesToInt
/// <summary>
/// Converts 3 bytes into a big-endian integer
/// </summary>
/// <param name="data"></param>
/// <returns>Big-endian formatted integer</returns>
private static int ThreeBytesToInt(BufferChunk data)
{
int ret = 0;
ret += (data.NextByte() << 1 * 8);
ret += (data.NextByte() << 2 * 8);
ret += (data.NextByte() << 3 * 8);
// If the 8th bit of the second byte (what will be the 24th bit)
// is turned on, the value is signed, so sign extend our integer
if(((byte)(ret >> 1 * 8) & 0x80) == 0x80)
{
ret += 0xFF;
}
return ret;
}
示例7: ReadDataFromBuffer
/// <summary>
/// Deserializes the provided buffer into this object
/// </summary>
/// <param name="buffer"></param>
public override void ReadDataFromBuffer(BufferChunk buffer)
{
SDESType type;
while ((type = (SDESType)buffer.NextByte()) != SDESType.END)
{
switch (type)
{
case SDESType.CNAME:
case SDESType.EMAIL:
case SDESType.LOC:
case SDESType.NAME:
case SDESType.NOTE:
case SDESType.PHONE:
case SDESType.TOOL:
ReadPropertyFromBuffer((int)type, buffer);
break;
case SDESType.PRIV:
ReadPrivatePropertyFromBuffer(buffer);
break;
default:
throw new ApplicationException(string.Format(CultureInfo.CurrentCulture,
Strings.UnexpectedSDESType, type));
}
}
}
示例8: ThreeBytesToInt
/// <summary>
/// Converts 3 bytes into a big-endian integer
/// </summary>
/// <param name="data"></param>
/// <returns>Big-endian formatted integer</returns>
private static int ThreeBytesToInt(BufferChunk data)
{
int ret = 0;
ret += data.NextByte();
ret += (data.NextByte() << 8);
ret += (data.NextByte() << 16);
if(((byte)(ret >> 16) & 0x80) == 0x80)
{
ret += 0xFF;
}
return ret;
}
示例9: Run
override public void Run()
{
BufferChunk bc = new BufferChunk(7);
short s = 25000;
int i = 545434;
byte b = 56;
bc += s;
bc += i;
bc += b;
if (bc.NextInt16() != s)
throw new TestCaseException("Short failed for " + s);
if (bc.NextInt32() != i)
throw new TestCaseException("Int failed for " + i);
if (bc.NextByte() != b)
throw new TestCaseException("Byte failed for " + b);
bc.Reset();
s = short.MaxValue;
i = int.MaxValue;
b = byte.MaxValue;
bc += s;
bc += i;
bc += b;
if (bc.NextInt16() != s)
throw new TestCaseException("Short failed for " + s);
if (bc.NextInt32() != i)
throw new TestCaseException("Int failed for " + i);
if (bc.NextByte() != b)
throw new TestCaseException("Byte failed for " + b);
bc.Reset();
s = short.MinValue;
i = int.MinValue;
b = byte.MinValue;
bc += s;
bc += i;
bc += b;
if (bc.NextInt16() != s)
throw new TestCaseException("Short failed for " + s);
if (bc.NextInt32() != i)
throw new TestCaseException("Int failed for " + i);
if (bc.NextByte() != b)
throw new TestCaseException("Byte failed for " + b);
}