本文整理汇总了C#中MSR.LST.BufferChunk.NextUtf8String方法的典型用法代码示例。如果您正苦于以下问题:C# BufferChunk.NextUtf8String方法的具体用法?C# BufferChunk.NextUtf8String怎么用?C# BufferChunk.NextUtf8String使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MSR.LST.BufferChunk
的用法示例。
在下文中一共展示了BufferChunk.NextUtf8String方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Run
override public void Run()
{
BufferChunk bc = new BufferChunk(new byte[]{65, 66, 67}, 0, 0);
try
{
string data = bc.NextUtf8String(2);
throw new TestCaseException("no data");
}
catch(BufferChunk.NoDataException){}
}
示例2: Start
private void Start()
{
//BufferChunk chunk = new BufferChunk(2048);
CompoundPacket compoundPacket = new CompoundPacket();
EndPoint endPoint = null;
while (isRunning)
{
try
{
compoundPacket.Reset();
udpListener.ReceiveFrom(compoundPacket.Buffer, out endPoint);
compoundPacket.ParseBuffer();
//IPAddress ipAddress = ((IPEndPoint)endPoint).Address;
IPEndPoint ipEndpoint = (IPEndPoint)endPoint;
// The compound packet enumerator destroys its list during enumeration,
// so we keep track of packets that have yet to be processed
IList<RtcpPacket> yetToBeProcessed = new List<RtcpPacket>();
String venueName = null;
//uint ssrc = 0;
long when = 0; // in units of "ticks"
// scan through the compound packet, looking for key pieces of meta-data
// first, look for the app packet that specifies the venue
// also, obtain the ssrc and the time stamp
foreach (RtcpPacket packet in compoundPacket)
{
if (packet.PacketType == (byte)Rtcp.PacketType.APP)
{
AppPacket appPacket = new AppPacket(packet);
if (appPacket.Name.Equals(Rtcp.APP_PACKET_NAME) &&
appPacket.Subtype == Rtcp.VENUE_APP_PACKET_SUBTYPE)
{
BufferChunk chunk = new BufferChunk(appPacket.Data);
when = chunk.NextInt64();
venueName = chunk.NextUtf8String(chunk.Length);
int padIndex = venueName.IndexOf((char)0);
if (padIndex > 0)
venueName = venueName.Substring(0, padIndex);
}
}
else
{
yetToBeProcessed.Add(packet);
}
}
if (venueName == null)
continue; // can't do anything if we don't know the venue for this packet
if (when == 0)
continue; // need a timestamp
VenueState venueState = null;
// compound operations must always be locked...
lock (venueStateMap)
{
if (!venueStateMap.ContainsKey(venueName))
venueState = new VenueState(venueName);
else venueState = venueStateMap[venueName];
}
// scan again, this time processing the RTCP packets
foreach (RtcpPacket packet in yetToBeProcessed)
{
switch (packet.PacketType)
{
case (byte)Rtcp.PacketType.SR:
{
SrPacket sr = new SrPacket(packet);
SenderData senderData = venueState.GetSenderState(sr.SSRC);
senderData.Source = ipEndpoint;
senderData.updateSenderState(sr.SenderReport, when);
// this "refreshes" the host state (so that it won't expire)
venueState.SenderData[sr.SSRC] = senderData;
break;
}
case (byte)Rtcp.PacketType.RR:
{
RrPacket rr = new RrPacket(packet);
ReceiverData receiverData = venueState.GetReceiverData (ipEndpoint);
// currently, we replace all receiver summaries with the data
// from a single RR packet
receiverData.updateReceiverState(rr.ReceiverReports, when, venueState);
// this "refreshes" the host state (so that it won't expire)
//.........这里部分代码省略.........