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


C# BufferChunk类代码示例

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


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

示例1: BufferPlayer

        /// <summary>
        /// set ourselves up, we are pretty dumb so need to be told who we're sending for
        /// and where to get our data from, and when to start sending..
        /// </summary>
        /// <remarks>
        /// It seems that we don't use maxFrameSize any more.  hmm.  Remove it?
        /// </remarks>
        public BufferPlayer(int streamID, int maxFrameSize, int maxFrameCount, int maxBufferSize)
        {
            Debug.Assert( maxBufferSize >= maxFrameSize ); // just for kicks...

            buffer = new BufferChunk( maxBufferSize );
            indices = new Index[maxFrameCount+1]; // Pri3: why is this "+1" here? (DO NOT REMOVE YET)

            this.populating = false;
            this.streamOutOfData = false;
            this.streamID = streamID;

            this.currentIndex = 0;
            this.indexCount = 0;
            this.startingTick = 0;

            canPopulate = new AutoResetEvent(false);

            // pool a thread to re-populate ourselves
            waitHandle = ThreadPool.RegisterWaitForSingleObject( 
                canPopulate,
                new WaitOrTimerCallback( InitiatePopulation ), 
                this, 
                -1, // never timeout to perform a population
                false );
        }
开发者ID:psyCHOder,项目名称:conferencexp,代码行数:32,代码来源:BufferPlayer.cs

示例2: WriteDataToBuffer

 public void WriteDataToBuffer(BufferChunk buffer)
 {
     buffer += Time;
     buffer += TimeStamp;
     buffer += PacketCount;
     buffer += BytesSent;
 }
开发者ID:tdhieu,项目名称:openvss,代码行数:7,代码来源:RtcpData.cs

示例3: Encode

        /// <summary>
        /// This method creates as many checksum buffers as exist in the checksum array
        /// </summary>
        /// <param name="bytes">Array of buffer chunk that represents the data to encode</param>
        /// <param name="checksum">Contains 1 BufferChunk, which should be Reset() before calling</param>
        /// <returns>The checksum packet</returns>
        public void Encode(BufferChunk[] data, BufferChunk[] checksum)
        {
            ValidateObjectNotNull(data);
            ValidateObjectNotNull(checksum);
            ValidateNullData(data, 0);
            ValidateNullData(checksum, 0);
            ValidateChecksumPacketCount(checksum.Length);

            // Sort the BufferChunks from longest to shortest
            ActiveColumns(data, data.Length);

            // Add 2 bytes so the checksum packet can contain the length of the missing packet
            int xorDataLength = activeColumns[0].Length + 2;
            BufferChunk xorData = checksum[0];
            int index = xorData.Index;
            
            // Store the xor'd lengths of the data
            xorData += (ushort)(XORLength() ^ xorDataLength);
            xorData.Reset(index + 2, xorDataLength - 2);

            // Populate the checksum buffer (xorData)
            XORData(xorData, xorDataLength - 2);

            // Set xorData.Index back to 0
            xorData.Reset(index, xorDataLength);
        }
开发者ID:psyCHOder,项目名称:conferencexp,代码行数:32,代码来源:fec.cs

示例4: ReadDataFromBuffer

 public void ReadDataFromBuffer(BufferChunk buffer)
 {
     Time = buffer.NextUInt64();
     TimeStamp = buffer.NextUInt32();
     PacketCount = buffer.NextUInt32();
     BytesSent = buffer.NextUInt32();
 }
开发者ID:tdhieu,项目名称:openvss,代码行数:7,代码来源:RtcpData.cs

示例5: asyncReceiveState

 internal asyncReceiveState(MSR.LST.Net.Sockets.Socket sock, BufferChunk bufferChunk, Queue queue, ReceivedFromCallback receivedFromCallback)
 {
     this.sock = sock;
     this.bufferChunk = bufferChunk;
     this.queue = queue;
     this.receivedFromCallback = receivedFromCallback;
 }
开发者ID:psyCHOder,项目名称:conferencexp,代码行数:7,代码来源:udplistener.cs

示例6: EncodeRS

        /// <summary>
        /// Encode the packets that are in the data BufferChunk array and place the 
        /// encoded result over GF16 in the checksum packets that are in 
        /// the result BufferChunk array. This method encode the size on the first 2
        /// bytes of the checksum packet and the data after that. Every checksum BufferChunk
        /// has the same size, which is the size of the largest BufferChunk in the data BufferChunk
        /// array, plus one if this BufferChunk doesn't end on a 16 bits boundary, plus
        /// two to store the encoded length 
        /// </summary>
        /// <param name="data">The data BufferChunk array (left part of the multiplication)</param>
        /// <param name="result"></param>
        /// <param name="encode">The encoding Vandermonde GF16 matrix (right part of the multiplication)</param>
        public static void EncodeRS(BufferChunk[] data, BufferChunk[] checksum, UInt16[,] encode)
        {
            // Get the length in byte of largest BufferChunk in the data BufferChunk array 
            // (which is an array of BufferChunk that could have different sizes)
            int maxDataLength = GetMaxLength(data);

            // The checksum packet as a even number of bytes so we can stay with GF16
            // and not have to use GF8 for the last byte when length odd
            int checksumNbRowsByte = maxDataLength;
            if ((maxDataLength & 1) == 1)
            {
                checksumNbRowsByte += 1;
            }

            // Add 2 more bytes to store the length
            checksumNbRowsByte += CFec.SIZE_OVERHEAD;

            // Encode the length of the data and place that on the first 2 bytes
            // of the checksum BufferChunk
            EncodeRSLength(data, checksum, encode);

            // Start to put encoded data at index + 2, because the 2 first bytes
            // of the checksum already contain the encoded size
            for (int i = 0; i < checksum.Length; i++)
            {
                BufferChunk bc = checksum[i];
                bc.Reset(bc.Index + CFec.SIZE_OVERHEAD, checksumNbRowsByte - CFec.SIZE_OVERHEAD);
                
                // Reset all of the checksum packets so they have no data
                // TODO - Temporary workaround for column based approach - JVE 7/6/2004
                bc.Clear();
            }

            // Place all the packets in a 16bits boundary to avoid byte operation
            // Important: This suppose that the memory reserved for all the bc passed in param 
            // to this method ends on a 16bits boundary (so at least one addition availabe byte 
            // when the last item is on a even address)
            Queue paddedData = new Queue();
            AddPadding(data, 0, paddedData);

            // Encode the data and place the encoded information in the checksum BufferChunk
            EncodeRSData(data, checksum, encode, maxDataLength);

            // Earlier, we changed the boundary of all data BufferChunk
            // that was not ending on a 16 bits boundary in order to have
            // better performance during the encoding. Now we need to 
            // restore the data to their original state to be clean.
            RemovePadding(paddedData);

            // Restore the BufferChunk index in the checksum checksum BufferChunk
            // to 0 to be clean. Earlier, We changed the index in order to encode 
            // the data after the encoding length.
            for (int i=0; i < checksum.Length; i++)
            {
                BufferChunk bc = checksum[i];
                bc.Reset(bc.Index - CFec.SIZE_OVERHEAD, checksumNbRowsByte);
            }
        }
开发者ID:psyCHOder,项目名称:conferencexp,代码行数:70,代码来源:FEC_BufferChunk.cs

示例7: Run

        private void Run()
        {
            while (true)
            {
                Console.Out.WriteLine("Sending to address: " + ADDRESS);

                byte[] buffer = new byte[sizeof(uint)];
                BufferChunk packetBuffer = new BufferChunk(buffer);
                packetBuffer.SetUInt32(0, COOKIE);

                udpSender.Send(packetBuffer);

                Thread.Sleep(PERIOD);
            }
        }
开发者ID:psyCHOder,项目名称:conferencexp,代码行数:15,代码来源:HeartbeatServerConsole.cs

示例8: HeartbeatServer

        public HeartbeatServer(String addr, int port, uint cookie, int period, ushort ttl) {
            m_Period = period;
            m_Thread = null;
            m_Disposed = false;

            //Set up the send buffer
            byte[] buffer = new byte[sizeof(uint)];
            m_PacketBuffer = new BufferChunk(buffer);
            m_PacketBuffer.SetUInt32(0, cookie);

            //Create the Sender
            IPAddress ipaddr = IPAddress.Parse(addr);
            m_IpEp = new IPEndPoint(ipaddr, port);
            m_UdpSender = new UdpSender(m_IpEp, ttl);
        }
开发者ID:psyCHOder,项目名称:conferencexp,代码行数:15,代码来源:HeartbeatServer.cs

示例9: ReceiveFrom

 /// <summary>
 /// Calls the base class ReceiveFrom.  Performs an efficient conversion from BufferChunk.
 /// </summary>
 /// <param name="bufferChunk">BufferChunk</param>
 /// <param name="endPoint">ref EndPoint</param>
 /// <example>
 /// Socket sock = new MSR.LST.Net.Sockets.Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
 /// sock.ReceiveFrom(bufferChunk, ref endPoint);
 /// </example>
 public void ReceiveFrom(BufferChunk bufferChunk, ref EndPoint endPoint)
 {
     bufferChunk.Length = base.ReceiveFrom(bufferChunk.Buffer, 0, bufferChunk.Buffer.Length, SocketFlags.None, ref endPoint);
 }
开发者ID:tdhieu,项目名称:openvss,代码行数:13,代码来源:Socket.cs

示例10: Receive

 /// <summary>
 /// Calls the base class Receive.  Performs an efficient conversion from BufferChunk.
 /// </summary>
 /// <param name="bufferChunk">BufferChunk</param>
 /// <param name="socketFlags">SocketFlags</param>
 /// <example>
 /// Socket sock = new MSR.LST.Net.Sockets.Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
 /// sock.Receive(bufferChunk, SocketFlags.None);
 /// </example>
 public void Receive(BufferChunk bufferChunk, SocketFlags socketFlags)
 {
     bufferChunk.Length = base.Receive(bufferChunk.Buffer, 0, bufferChunk.Buffer.Length, socketFlags);
 }
开发者ID:tdhieu,项目名称:openvss,代码行数:13,代码来源:Socket.cs

示例11: Send

 /// <summary>
 /// Calls the base class Send.  Performs an efficient conversion from BufferChunk.
 /// </summary>
 /// <param name="bufferChunk">BufferChunk to send</param>
 /// <param name="socketFlags">SocketFlags</param>
 /// <returns>int bytes sent</returns>
 /// <example>
 /// Socket sock = new MSR.LST.Net.Sockets.Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
 /// sock.Send(bufferChunk, SocketFlags.None);
 /// </example>
 public int Send(BufferChunk bufferChunk, SocketFlags socketFlags)
 {
     return base.Send(bufferChunk.Buffer, bufferChunk.Index, bufferChunk.Length, socketFlags);
 }
开发者ID:tdhieu,项目名称:openvss,代码行数:14,代码来源:Socket.cs

示例12: 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));
 }
开发者ID:tdhieu,项目名称:openvss,代码行数:5,代码来源:RtpListener.cs

示例13: AddPadding

        /// <summary>
        /// Adds padding to make sure buffer ends on a 32 bit boundary
        /// </summary>
        /// <param name="cbBuffer">Size of buffer in bytes</param>
        protected static int AddPadding(BufferChunk buffer)
        {
            // We use the negative to take the 2's complement
            // and & 3 to retain the first 2 bits (0-3).
            int padding = GetNeededPadding(buffer.Length);
                
            if(padding > 0)
            {
                buffer += new byte[padding];
            }

            return padding;
        }
开发者ID:tdhieu,项目名称:openvss,代码行数:17,代码来源:RtcpPacket.cs

示例14: WriteDataToBuffer

        /// <summary>
        /// Converts member data to byte[]
        /// </summary>
        /// <param name="buffer"></param>
        public void WriteDataToBuffer(BufferChunk buffer)
        {
            // "Clear" the byte by setting the Version
            // 2 (10) becomes 128 (10000000) when you shift it into place in the header
            buffer[0] = Rtp.VERSION << 6;

            // Padding
            if(Padding == true)
            {
                buffer[0] |= PADDING_MASK;
            }

            // ItemCount
            buffer[0] += (byte)(ItemCount); // Add in the new value

            // PacketType
            buffer[1] = PacketType;

            // Length
            buffer.SetInt16(2, Length);
        }
开发者ID:tdhieu,项目名称:openvss,代码行数:25,代码来源:RtcpPacket.cs

示例15: CompoundPacket

 public CompoundPacket(BufferChunk buffer)
 {
     this.buffer = buffer;
     ParseBuffer();
 }
开发者ID:tdhieu,项目名称:openvss,代码行数:5,代码来源:RtcpPacket.cs


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