本文整理汇总了C#中BufferChunk.Reset方法的典型用法代码示例。如果您正苦于以下问题:C# BufferChunk.Reset方法的具体用法?C# BufferChunk.Reset怎么用?C# BufferChunk.Reset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BufferChunk
的用法示例。
在下文中一共展示了BufferChunk.Reset方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReturnBuffer
/// <summary>
/// This method is called to return buffers to the bufferPool
/// </summary>
/// <param name="buffer"></param>
private void ReturnBuffer(BufferChunk buffer)
{
buffer.Reset();
bufferPool.Push(buffer);
}
示例2: ReturnBuffer
/// <summary>
/// This method is called to return buffers to the bufferPool
/// </summary>
/// <param name="buffer"></param>
private void ReturnBuffer(BufferChunk buffer)
{
buffer.Reset();
if (null != bufferPool)
{
bufferPool.Push(buffer);
}
else
{
Console.WriteLine("RtpListener.ReturnBuffer() - Buffer Pool is null");
}
}
示例3: 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);
}
示例4: CheckForStaleParticipants
/// <summary>
/// Called by RtcpSender when it is time to collect Rtcp data
/// </summary>
/// <returns>A CompoundPacketBuilder</returns>
CompoundPacketBuilder RtcpSender.IRtpSession.RtcpReportIntervalReached()
{
// Limit the frequency of the cleanup in order to avoid participants and streams being
// inappropriately designated as stale. This can happen if we start up a lot of senders at once.
// Each sender triggers an RTCP packet which without the frequency limitation could
// increment the stale counter to its limit and cause the participant or stream to be removed.
bool cleanUpNow = false;
if (DateTime.Now > this.lastCleanUp.AddSeconds(5)) {
cleanUpNow = true;
this.lastCleanUp = DateTime.Now;
}
// A stale participant is one who is not sending Rtcp data
if (cleanUpNow)
CheckForStaleParticipants();
// Add participant data
Debug.Assert(participant.SSRC != 0);
cpb.ParticipantData(participant);
// Add Rtp data
if(rtpTraffic)
{
// A stale stream is one not sending Rtp traffic
if (cleanUpNow)
CheckForStaleStreams();
// Collect SenderReportPackets and SDESReports from each Sender
lock(rtpSenders)
{
foreach(RtpSender sender in rtpSenders.Values)
{
// this adds the SR and SDES packets
sender.UpdateRtcpData();
}
}
// add a sdes (source description)
//cpb.Add_SDESReport(participant.SSRC, participant);
// Collect ReceiverReports from each of the streams
lock(streamsAndIPs)
{
foreach(IPStreamPairHashtable.IPStreamPair ipsp in streamsAndIPs.Values)
{
if( ipsp.stream != null )
{
ipsp.stream.AddReceiverReport(cpb);
}
}
}
}
#if USE_APP_PACKET
// andrew: Add an app packet that reflects the time and the current venue...
if ((VenueName != null) && (this.groupEP != null))
{
string appPayload = VenueName + "#" + this.groupEP.Address.ToString();
long time = DateTime.Now.Ticks;
// 8 bytes for time + venue name
int count = 8 + utf8.GetByteCount(appPayload);
// count must be 4-byte alligned
int mod = count % 4;
if (mod != 0)
{
count += (4 - mod);
}
BufferChunk buffer = new BufferChunk(count);
buffer.Reset(0, count);
buffer.Clear();
buffer.SetInt64(0, time);
buffer.SetUTF8String(8, appPayload);
byte[] rawBytes = buffer.Buffer;
cpb.Add_APPReport(participant.SSRC, Rtcp.APP_PACKET_NAME, Rtcp.VENUE_APP_PACKET_SUBTYPE, rawBytes);
}
#endif
return cpb;
}