当前位置: 首页>>代码示例>>C#>>正文


C# BufferChunk.Clear方法代码示例

本文整理汇总了C#中BufferChunk.Clear方法的典型用法代码示例。如果您正苦于以下问题:C# BufferChunk.Clear方法的具体用法?C# BufferChunk.Clear怎么用?C# BufferChunk.Clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BufferChunk的用法示例。


在下文中一共展示了BufferChunk.Clear方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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;
        }
开发者ID:psyCHOder,项目名称:conferencexp,代码行数:89,代码来源:RtpSession.cs


注:本文中的BufferChunk.Clear方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。