コード例 #1
0
        public TcpPipeline(Socket socket)
        {
            if (socket == null)
            {
                throw new ArgumentNullException(nameof(socket));
            }

            pipelineName = socket.RemoteEndPoint + "=>" + socket.LocalEndPoint;
            packetBuffer = new byte[socket.ReceiveBufferSize];
            this.input   = new BufferPacket(this, packetBuffer);
            this.socket  = socket;
        }
コード例 #2
0
        private BufferPacket?GetNextEncodedData()
        {
            lock (_encodedBuffer)
            {
                if (_encodedBuffer.Count == 0)
                {
                    return(null);
                }

                BufferPacket packet = _encodedBuffer.Dequeue();
                return(packet);
            }
        }
コード例 #3
0
        /// <summary>
        /// Add a new packet of encoded data
        /// </summary>
        /// <param name="sequence">Sequence number of this packet</param>
        /// <param name="data">The encoded audio packet</param>
        /// <param name="codec">The codec to use to decode this packet</param>
        public void AddEncodedPacket(long sequence, byte[] data, bool isLast)
        {
            /* TODO this messes up when we hit configure in the desktop mumble app. The sequence number drops to 0
             * //If the next seq we expect to decode comes after this packet we've already missed our opportunity!
             * if (_nextSequenceToDecode > sequence)
             * {
             *  Debug.LogWarning("Dropping packet number: " + sequence + " we're decoding number " + _nextSequenceToDecode);
             *  return;
             * }
             */

            BufferPacket packet = new BufferPacket
            {
                Data     = data,
                Sequence = sequence,
                IsLast   = isLast
            };

            //Debug.Log("Adding #" + sequence);
            lock (_encodedBuffer)
            {
                int count = _encodedBuffer.Count;
                if (count > MumbleConstants.RECEIVED_PACKET_BUFFER_SIZE)
                {
                    // TODO this seems to happen at times
                    Debug.LogWarning("Max recv buffer size reached, dropping for user " + _name);
                    return;
                }

                _encodedBuffer.Enqueue(packet);
                if (!HasFilledInitialBuffer && count + 1 >= InitialSampleBuffer)
                {
                    HasFilledInitialBuffer = true;
                }
                //Debug.Log("Count is now: " + _encodedBuffer.Count);
            }
        }
コード例 #4
0
 public TcpPipeline(Socket socket)
 {
     this.socket = socket;
     packet      = new BufferPacket(this, socket.ReceiveBufferSize);
 }