public VoicePacket Create(int seqNumber, int timeStamp, byte[] payload, int count) { VoicePacket packet; if (!_pool.TryPop(out packet)) { packet = new VoicePacket(this); } packet.Init(seqNumber, timeStamp, payload, count); return packet; }
public VoicePacket Create(int seqNumber, int timeStamp, byte[] payload, int count) { VoicePacket packet; if (!_pool.TryPop(out packet)) { packet = new VoicePacket(this); } packet.Init(seqNumber, timeStamp, payload, count); return(packet); }
private void Insert(VoicePacket packet) { if (!_reset) { var node = _buffer.First; while (node != null) { if (packet.TimeStamp + _span <= _timestamp) { node.Value.Dispose(); _buffer.RemoveFirst(); } node = node.Next; } } if (_lostCount > 20) { this.Reset(); } if (_reset || packet.TimeStamp + _span >= _timestamp) { if (_buffer.Count == MaxBufferSize) { _buffer.First.Value.Dispose(); _buffer.RemoveFirst(); } var node = _buffer.First; while (node != null && node.Value.TimeStamp <= packet.TimeStamp) { node = node.Next; } if (node == null) { _buffer.AddLast(packet); } else { _buffer.AddBefore(node, packet); } } }
public void Recycle(VoicePacket packet) { _pool.Push(packet); }
public void Enqueue(VoicePacket packet) { _incoming.Enqueue(packet); }